本文整理汇总了PHP中Files::result方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::result方法的具体用法?PHP Files::result怎么用?PHP Files::result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::result方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: folder_contents
/**
* Get all folders and files within a folder
*
* @param int $parent The id of this folder
* @return array
*
**/
public static function folder_contents($parent = 0, $type = null)
{
// they can also pass a url hash such as #foo/bar/some-other-folder-slug
if (!is_numeric($parent)) {
$segment = explode('/', trim($parent, '/#'));
$result = ci()->file_folders_m->get_by('slug', array_pop($segment));
$parent = $result ? $result->id : 0;
}
$folders = ci()->file_folders_m->where('parent_id', $parent)->where('hidden', 0)->order_by('sort')->get_all();
// $files = ci()->file_m->where(array('folder_id' => $parent))
// ->order_by('sort')
// ->get_all();
$files = ci()->file_m->where(array('folder_id' => $parent, 'type' => $type))->order_by('sort')->get_all();
// let's be nice and add a date in that's formatted like the rest of the CMS
if ($folders) {
foreach ($folders as &$folder) {
$folder->formatted_date = format_date($folder->date_added);
$folder->file_count = ci()->file_m->count_by('folder_id', $folder->id);
}
}
if ($files) {
ci()->load->library('keywords/keywords');
foreach ($files as &$file) {
$file->keywords_hash = $file->keywords;
$file->keywords = ci()->keywords->get_string($file->keywords);
$file->formatted_date = format_date($file->date_added);
}
}
return Files::result(true, null, null, array('folder' => $folders, 'file' => $files, 'parent_id' => $parent));
}
示例2: save_alt
/**
* Edit the "alt" attribute of an image file
*/
public function save_alt()
{
if ($id = $this->input->post('file_id') and $alt_attribute = $this->input->post('alt_attribute')) {
$this->file_m->update($id, array('alt_attribute' => $alt_attribute));
echo json_encode(Files::result(TRUE, lang('files:alt_saved')));
}
}
示例3: save_description
/**
* Edit description of a file
*/
public function save_description()
{
if ($id = $this->input->post('file_id') and $description = $this->input->post('description')) {
$this->file_m->update($id, array('description' => $description));
echo json_encode(Files::result(TRUE, lang('files:description_saved')));
}
}