本文整理汇总了PHP中arr::rotate方法的典型用法代码示例。如果您正苦于以下问题:PHP arr::rotate方法的具体用法?PHP arr::rotate怎么用?PHP arr::rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arr
的用法示例。
在下文中一共展示了arr::rotate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_document_metadata_fields
public function get_document_metadata_fields()
{
$database = new Database();
$database->select('key');
$database->from('document_metadata');
$database->where('document_id', $this->id);
$results = arr::rotate($database->get()->result_array(false));
return $results['key'];
}
示例2: rotate
/**
* Tests the arr::rotate() function.
* @dataProvider rotate_provider
* @group core.helpers.arr.rotate
* @test
*/
public function rotate($input_array, $expected_result)
{
$result = arr::rotate($input_array);
$this->assertEquals($expected_result, $result);
}
示例3: prepare_upload
public function prepare_upload($uploadvar = 'upload')
{
if (!arr::get($_FILES, 'mediafile', 'name', $uploadvar)) {
kohana::log('error', 'Attempted to prepare upload without file');
return 'Please provide a file to upload';
}
$uploadedFile = arr::get(arr::rotate($_FILES['mediafile']), $uploadvar);
switch ($uploadedFile['error']) {
case UPLOAD_ERR_INI_SIZE:
return 'File exceeds upload_max_filesize';
case UPLOAD_ERR_FORM_SIZE:
return 'File exceeds MAX_FILE_SIZE';
case UPLOAD_ERR_PARTIAL:
return 'File was only partially uploaded';
case UPLOAD_ERR_NO_FILE:
return 'No file was uploaded';
case UPLOAD_ERR_NO_TMP_DIR:
return 'Missing a temporary folder';
case UPLOAD_ERR_CANT_WRITE:
return 'Failed to write file to disk';
case UPLOAD_ERR_EXTENSION:
return 'Invalid file extension (type)';
case UPLOAD_ERR_OK:
if (!$this->get('file')) {
$uploadFilename = $uploadedFile['name'];
if (Kohana::config('upload.remove_spaces') === TRUE) {
$uploadFilename = preg_replace('/\\s+/', '_', $uploadFilename);
}
$this->set('file', $uploadFilename);
}
if ($this->get('path')) {
$path = trim($this->get('path'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$this->set('path', $path);
}
if (!is_file($uploadedFile['tmp_name'])) {
kohana::log('error', 'Unable to locate file in temporary storage ' . $uploadedFile['tmp_name']);
return 'Unable to upload file';
}
if (!($mediainfo = MediaLib::getAudioInfo($uploadedFile['tmp_name']))) {
kohana::log('error', 'Unable to determine audio info for tmp upload file "' . $uploadedFile['tmp_name'] . '"');
return 'Upload is not a valid audio file or format';
}
$this->fromArray($mediainfo);
if (kohana::config('mediafile.upload_to_rate_folders')) {
$rate = $this->get('rates');
$path = $this->get('path');
if (in_array($rate, kohana::config('mediafile.default_rates')) and !strstr($path, $rate . DIRECTORY_SEPARATOR)) {
$path .= $this->get('rates') . DIRECTORY_SEPARATOR;
$this->set('path', $path);
} else {
if ($unknownPath = kohana::config('mediafile.unknown_rate_folder')) {
$path .= trim($unknownPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$this->set('path', $path);
}
}
}
$directory = $this->filepath();
if (!$this->get('name') or !$this->get('description')) {
$mediafiles = $this->get_resampled();
if (!$this->get('name')) {
if (isset($mediafiles[0]['name'])) {
$this->set('name', $mediafiles[0]['name']);
} else {
$this->set('name', pathinfo($uploadedFile['name'], PATHINFO_FILENAME));
}
}
if (!$this->get('description')) {
if (isset($mediafiles[0]['description'])) {
$this->set('description', $mediafiles[0]['description']);
}
}
}
if (!$directory or !filesystem::is_writable($directory) and !filesystem::createDirectory($directory)) {
kohana::log('error', 'The configured media dir is not writable, please chmod "' . $directory . '"');
return 'Media collection directory is not writable';
}
$this->uploaded_file = $uploadedFile;
break;
default:
return 'Upload failed for an unspecified reason';
}
return FALSE;
}