本文整理汇总了PHP中Files::listFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::listFiles方法的具体用法?PHP Files::listFiles怎么用?PHP Files::listFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::listFiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listFiles
public function listFiles()
{
Zend_Loader::loadClass('Files');
$files = new Files();
$list = $files->listFiles('public/files/uploaded/');
sort($list);
$all = array();
foreach ($list as $filename) {
$row['name'] = $filename;
$row['filesize'] = filesize('public/files/uploaded/' . $filename);
array_push($all, $row);
}
return $all;
}
示例2: listAction
public function listAction()
{
$format = $this->_getParam('format', 'ajax');
switch ($format) {
case 'xml':
$this->_helper->layout->setLayout('xml');
$this->_helper->viewRenderer('list-xml');
break;
default:
$this->_helper->layout->setLayout('ajax');
}
Zend_Loader::loadClass('Files');
$files = new Files();
$this->view->list = $files->listFiles('public/files/uploaded/');
}
示例3: synchronize
/**
* Index files from a remote container
*
* @param string $folder_id The folder id to refresh. Files will be fetched from its assigned container
* @return array
*
**/
public function synchronize($folder_id)
{
$folder = Folder::find($folder_id);
//list of files should be obtainable via files
$files = Files::listFiles($folder->location, $folder->remote_container);
// did the fetch go ok?
if ($files['status']) {
$valid_records = array();
$known = array();
$known_files = File::findByFolderId($folder_id);
// now we build an array with the database filenames as the keys so we can compare with the cloud list
foreach ($known_files as $item) {
$known[$item->filename] = $item;
}
foreach ($files['data'] as $file) {
// it's a totally new file
if (!array_key_exists($file['filename'], $known)) {
$insert = array('id' => substr(md5(microtime() + $data['filename']), 0, 15), 'folder_id' => $folder_id, 'user_id' => ci()->current_user->id, 'type' => $file['type'], 'name' => $file['filename'], 'filename' => $file['filename'], 'path' => $file['path'], 'description' => '', 'extension' => $file['extension'], 'mimetype' => $file['mimetype'], 'filesize' => $file['filesize'], 'date_added' => $file['date_added']);
// we add the id to the list of records that have existing files to match them
$valid_records[] = File::create($insert);
} else {
// it's totally not a new file
// update with the details we got from the cloud
File::where('id', $known[$file['filename']]->id)->update($file);
// we add the id to the list of records that have existing files to match them
$valid_records[] = $known[$file['filename']]->id;
}
}
// Ok then. Let's clean up the records with no files and get out of here
File::where('folder_id', $folder_id)->whereNotIn('id', $valid_records)->delete();
return $this->result(true, trans('files.synchronization_complete'), $folder->name, $files['data']);
} else {
return $this->result(null, trans('files.no_records_found'));
}
}