本文整理汇总了PHP中Folder::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::find方法的具体用法?PHP Folder::find怎么用?PHP Folder::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildCss
public function buildCss()
{
App::import('Vendor', 'AssetMinify.JSMinPlus');
// Ouverture des fichiers de config
$dir = new Folder(Configure::read('App.www_root') . 'css' . DS . 'minified');
if ($dir->path !== null) {
foreach ($dir->find('config_.*.ini') as $file) {
preg_match('`^config_(.*)\\.ini$`', $file, $grep);
$file = new File($dir->pwd() . DS . $file);
$ini = parse_ini_file($file->path, true);
$fileFull = new File($dir->path . DS . 'full_' . $grep[1] . '.css', true, 0644);
$fileGz = new File($dir->path . DS . 'gz_' . $grep[1] . '.css', true, 0644);
$contentFull = '';
foreach ($ini as $data) {
// On a pas de version minifié
if (!($fileMin = $dir->find('file_' . md5($data['url'] . $data['md5']) . '.css'))) {
$fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css', true, 0644);
$this->out("Compression de " . $data['file'] . ' ... ', 0);
$fileMin->write(MinifyUtils::compressCss(MinifyUtils::cssAbsoluteUrl($data['url'], file_get_contents($data['file']))));
$this->out('OK');
} else {
$fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css');
}
$contentFull .= $fileMin->read() . PHP_EOL;
}
// version full
$fileFull->write($contentFull);
$fileFull->close();
// compression
$fileGz->write(gzencode($contentFull, 6));
}
}
}
示例2: getVideoFile
private function getVideoFile($id)
{
if (empty($id)) {
return false;
}
$dir = new Folder('files/Video/' . $id);
if (isset($dir->find()[0])) {
return $dir->find()[0];
} else {
return false;
}
}
示例3: read
function read($dir = null, $recursive = false)
{
$notes = array();
$path = CORE_PATH . APP_PATH . $dir;
$folder = new Folder(APP_PATH . $dir);
$fold = $recursive ? $folder->findRecursive('.*\\.php') : $folder->find('.*\\.php');
foreach ($fold as $file) {
$file = $recursive ? $file : $path . $file;
$file_path = r(CORE_PATH . APP_PATH, '', $file);
$handle = new File($file_path);
$content = $handle->read();
$lines = explode(PHP_EOL, $content);
//$lines = file($file);
$ln = 1;
if (!empty($lines)) {
foreach ($lines as $line) {
if ((is_null($this->type) || $this->type == 'TODO') && preg_match("/[#\\*\\/\\/]\\s*TODO\\s*(.*)/", $line, $match)) {
$this->notes[$file_path]['TODO'][$ln] = $match[1];
}
if ((is_null($this->type) || $this->type == 'OPTIMIZE') && preg_match("/[#\\*\\/\\/]\\s*OPTIMIZE|OPTIMISE\\s*(.*)/", $line, $match)) {
$this->notes[$file_path]['OPTIMIZE'][$ln] = $match[1];
}
if ((is_null($this->type) || $this->type == 'FIXME') && preg_match("/[#\\*\\/\\/]\\s*FIXME|BUG\\s*(.*)/", $line, $match)) {
$this->notes[$file_path]['FIXME'][$ln] = $match[1];
}
$ln++;
}
}
}
return $this->notes;
}
示例4: initialize
/**
* Overwrite shell initialize to dynamically load all queue related tasks.
*
* @return void
*/
public function initialize()
{
// Check for tasks inside plugins and application
$paths = App::path('Console/Command/Task');
foreach ($paths as $path) {
$Folder = new Folder($path);
$res = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
foreach ($res as &$r) {
$r = basename($r, 'Task.php');
}
$this->tasks = $res;
}
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$pluginPaths = App::path('Console/Command/Task', $plugin);
foreach ($pluginPaths as $pluginPath) {
$Folder = new Folder($pluginPath);
$res = $Folder->find('Queue.*Task\\.php');
foreach ($res as &$r) {
$r = $plugin . '.' . basename($r, 'Task.php');
}
$this->tasks = array_merge($this->tasks, $res);
}
}
$conf = Configure::read('Queue');
if (!is_array($conf)) {
$conf = [];
}
// Merge with default configuration vars.
Configure::write('Queue', array_merge(['workers' => 3, 'sleepTime' => 10, 'gcprop' => 10, 'defaultWorkerTimeout' => 2 * MINUTE, 'defaultWorkerRetries' => 4, 'workerMaxRuntime' => 0, 'cleanupTimeout' => DAY, 'exitWhenNothingToDo' => false], $conf));
parent::initialize();
}
示例5: render
public function render($view = null, $layout = null)
{
// set vars
$name = $download = $extension = $id = $modified = $path = $cache = $mimeType = $compress = null;
extract($this->viewVars, EXTR_OVERWRITE);
$this->viewVars['thumbName'] = $thumbName = md5(json_encode($this->viewVars['params']));
$dir = new Folder(CACHE . 'thumbs', true, 0755);
$files = $dir->find($this->viewVars['thumbName']);
if (empty($files)) {
$pos = strpos($this->viewVars['params']['image'], 'http://');
if ($pos !== FALSE) {
$this->_loadExternalFile();
$this->_resizeFile();
unlink($this->viewVars['params']['image']);
} else {
$this->viewVars['params']['image'] = WWW_ROOT . $this->viewVars['params']['image'];
$this->_resizeFile();
}
}
$modified = @filemtime(CACHE . 'thumbs/' . $thumbName);
$pos1 = strrpos($params['image'], '.');
$id = substr($params['image'], $pos1 + 1, 8);
$this->response->type($id);
$this->viewVars['path'] = CACHE . 'thumbs' . DS . $thumbName;
$this->viewVars['download'] = false;
$this->viewVars['cache'] = '+1 day';
$this->viewVars['modified'] = '@' . $modified;
// Must be a string to work. See MediaView->render()
parent::render();
}
示例6: initialize
/**
* Overwrite shell initialize to dynamically load all Queue Related Tasks.
*
* @return void
*/
public function initialize()
{
$paths = App::path('Console/Command/Task');
foreach ($paths as $path) {
$Folder = new Folder($path);
$res = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
foreach ($res as &$r) {
$r = basename($r, 'Task.php');
}
$this->tasks = $res;
}
$plugins = CakePlugin::loaded();
foreach ($plugins as $plugin) {
$pluginPaths = App::path('Console/Command/Task', $plugin);
foreach ($pluginPaths as $pluginPath) {
$Folder = new Folder($pluginPath);
$res = $Folder->find('Queue.*Task\\.php');
foreach ($res as &$r) {
$r = $plugin . '.' . basename($r, 'Task.php');
}
$this->tasks = array_merge($this->tasks, $res);
}
}
parent::initialize();
$this->QueuedTask->initConfig();
}
示例7: view
public function view($id = null)
{
$this->layout = 'index';
$this->Anotacion->id = $id;
$user = $this->User->findByUsername('transparenciapasiva');
if (!$this->Anotacion->exists() || $this->Anotacion->field('user_id') != $user['User']['id']) {
$this->Session->setFlash('<h2 class="alert alert-error">La Anotacion no Existe</h2>', 'default', array(), 'buscar');
$this->redirect(array('controller' => 'home', 'action' => 'index/tab:3'));
}
$this->set('anotacion', $this->Anotacion->read(null, $id));
$folder_anot = new Folder(WWW_ROOT . 'files' . DS . 'Anotaciones' . DS . 'anot_' . $this->Anotacion->id);
$files_url = array();
foreach ($folder_anot->find('.*') as $file) {
$files_url[] = basename($folder_anot->pwd()) . DS . $file;
}
$this->set('files', $files_url);
////////////////////////////////////////////////////////////////////
$folder_anot = new Folder(WWW_ROOT . 'files' . DS . 'Anotaciones' . DS . 'anot_' . $this->Anotacion->id . DS . 'Respuestas');
$files_url = array();
$dir = $folder_anot->read(true, false, true);
foreach ($dir[0] as $key => $value) {
$folder = new Folder($value);
foreach ($folder->find('.*') as $file) {
$files_url[basename($folder->pwd())][] = $file;
}
}
$this->set('files_res', $files_url);
}
示例8: admin_reset
public function admin_reset($user_id)
{
if ($this->Auth->user('role') > 1) {
$dir = new Folder('../webroot/img/avatars/');
if ($dir->path != null) {
// On supprime le fichier
$files = $dir->find($user_id . '.jpg');
foreach ($files as $file) {
$file = new File($dir->pwd() . DS . $file);
$file->delete();
$file->close();
}
// On sauvegarde
$user = $this->User->find('first', ['conditions' => ['User.id' => $user_id]]);
$username = $user['User']['username'];
$avatar = 'http://cravatar.eu/helmavatar/' . $username;
$this->User->id = $user_id;
$this->User->saveField('avatar', $avatar);
// Redirection
$this->Session->setFlash('L\'avatar de ' . $username . ' a été réinitialisé', 'toastr_success');
return $this->redirect(['controller' => 'users', 'action' => 'edit', $user_id]);
}
} else {
throw new NotFoundException();
}
}
示例9: get
function get()
{
$result = array();
$controllers_folder = new Folder(APP . 'controllers');
$controllers = $controllers_folder->find('.*_controller\\.php');
$appmet = get_class_methods("AppController");
foreach ($controllers as $controller) {
$views = array();
$controller_name = substr($controller, 0, strpos($controller, '_controller'));
if ($controller_name !== 'app') {
// consulta los metodos de la clase
require_once APP . 'controllers' . DS . $controller;
if (strpos($controller_name, '_')) {
$arr = split('_', $controller_name);
$controller_name = '';
foreach ($arr as $i => $a) {
if ($i > 0) {
$controller_name .= ucfirst($a);
} else {
$controller_name .= $a;
}
}
}
$methods = get_class_methods(ucfirst($controller_name) . "Controller");
$x = array();
foreach ($methods as $m) {
if (!in_array($m, $appmet)) {
$x[] = $m;
}
}
$result[$controller_name] = $x;
}
}
return $result;
}
示例10: initialize
/**
* Overwrite shell initialize to dynamically load all Queue Related Tasks.
*
* @return void
*/
public function initialize()
{
$this->_loadModels();
$x = App::objects('Queue.Task');
//'Console/Command/Task'
//$x = App::path('Task', 'Queue');
$paths = App::path('Console/Command/Task');
foreach ($paths as $path) {
$Folder = new Folder($path);
$this->tasks = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
}
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$pluginPaths = App::path('Console/Command/Task', $plugin);
foreach ($pluginPaths as $pluginPath) {
$Folder = new Folder($pluginPath);
$res = $Folder->find('Queue.*Task\\.php');
foreach ($res as &$r) {
$r = $plugin . '.' . basename($r, 'Task.php');
}
$this->tasks = array_merge($this->tasks, $res);
}
}
//Config can be overwritten via local app config.
Configure::load('Queue.queue');
$conf = (array) Configure::read('Queue');
//merge with default configuration vars.
Configure::write('Queue', array_merge(['maxruntime' => DAY, 'cleanuptimeout' => MONTH], $conf));
}
示例11: __construct
/**
* Constructor. Binds the model's database table to the object.
*
* @param bool|int|string|array $id Set this ID for this model on startup,
* can also be an array of options, see above.
* @param string $table Name of database table to use.
* @param string $ds DataSource connection name.
* @see Model::__construct()
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function __construct($id = false, $table = null, $ds = null)
{
parent::__construct($id, $table, $ds);
$pluginDir = APP . 'Plugin' . DS . $this->plugin . DS . WEBROOT_DIR . DS . 'img' . DS;
//カテゴリ間の区切り線
$dir = new Folder($pluginDir . 'line');
$files = $dir->find('.*\\..*');
$files = Hash::sort($files, '{n}', 'asc');
self::$categorySeparators = array(array('key' => null, 'name' => __d('links', '(no line)'), 'style' => null), array('key' => self::CATEGORY_SEPARATOR_DEFAULT, 'name' => '', 'style' => ''));
foreach ($files as $file) {
$info = getimagesize($dir->pwd() . DS . $file);
$img = '/' . Inflector::underscore($this->plugin) . DS . 'img' . DS . 'line' . DS . $file;
self::$categorySeparators[] = array('key' => $file, 'name' => '', 'style' => 'background-image: url(' . $img . '); ' . 'border-image: url(' . $img . '); ' . 'height: ' . $info[1] . 'px;');
}
unset($dir);
//線スタイル
$dir = new Folder($pluginDir . 'mark');
$files = $dir->find('.*\\..*');
$files = Hash::sort($files, '{n}', 'asc');
self::$listStyles = array(array('key' => null, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_NONE . ';'), array('key' => self::LINE_STYLE_DISC, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_DISC . ';'), array('key' => self::LINE_STYLE_CIRCLE, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_CIRCLE . ';'), array('key' => self::LINE_STYLE_LOWER_ALPHA, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_LOWER_ALPHA . ';'), array('key' => self::LINE_STYLE_UPPER_ALPHA, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_UPPER_ALPHA . ';'));
foreach ($files as $file) {
$info = getimagesize($dir->pwd() . DS . $file);
$img = '/' . Inflector::underscore($this->plugin) . DS . 'img' . DS . 'mark' . DS . $file;
self::$listStyles[] = array('key' => $file, 'name' => '', 'style' => 'list-style-type: none; ' . 'list-style-image: url(' . $img . '); ');
}
unset($dir);
}
示例12: upload
function upload()
{
$directory = $this->getNextParam(null, 'path');
$container = $this->getNextParam(null, 'container');
if (empty($directory) || empty($container)) {
$this->errorAndExit('Directory and Container required');
}
$Folder = new Folder($directory);
if ($this->params['recursive']) {
$files = $Folder->findRecursive();
} else {
$single_files = $Folder->find();
$files = array();
foreach ($single_files as $file) {
$files[] = $Folder->pwd() . DS . $file;
}
}
$this->ProgressBar->start(count($files));
foreach ($files as $file) {
CloudFiles::upload($file, $container);
$this->ProgressBar->next();
}
$this->out();
$this->out("Finished.");
}
示例13: getProcessorNames
/**
* Get list of processor names
*/
private function getProcessorNames($replaceString, $dirPath = 'controllers')
{
$path = APP . 'plugins' . DS . 'payment' . DS . $dirPath;
$thtml = new Folder($path);
$processors = $thtml->find('(.+)\\.php');
$processors = str_replace($replaceString, '', $processors);
return $processors;
}
示例14: admin_index
public function admin_index()
{
App::uses('Folder', 'Utility');
App::uses('File', 'Utility');
$folder = new Folder(WWW_ROOT . 'backups/');
$files = $folder->find('.*\\.sql');
$this->set(compact('files'));
}
示例15: ingest
public function ingest($type = "meta")
{
if ($type == "meta") {
$meta = new Folder('/Users/n00002621/Dropbox/Research - Cheminfo/OSDB/IS-DB/metadata');
$files = $meta->find('.*\\.xml');
foreach ($files as $file) {
$file = new File($meta->pwd() . DS . $file);
$text = $file->read();
$xml = simplexml_load_string($text);
$data = json_decode(json_encode($xml), true);
$set = $data['data_set'];
$sam = $data['sample'];
$set['id'] = $set['DataSetId'];
unset($set['DataSetId']);
$set['author_id'] = $set['ContactAuthor'];
unset($set['ContactAuthor']);
$set['publication_id'] = $set['PublicationId'];
unset($set['PublicationId']);
$set['sample_id'] = $set['SampleId'];
unset($set['SampleId']);
$set['datatype'] = $set['DataType'];
unset($set['DataType']);
$set['dataformat'] = $set['DataFormat'];
unset($set['DataFormat']);
$set['description'] = $set['Description'];
unset($set['Description']);
if (isset($set['Instrument'])) {
$set['instrument'] = $set['Instrument'];
unset($set['Instrument']);
} else {
$set['instrument'] = "";
}
if (isset($set['MeasurementTechnique'])) {
$set['measurement'] = $set['MeasurementTechnique'];
unset($set['MeasurementTechnique']);
} else {
$set['measurement'] = "";
}
$set['oldfilename'] = $set['OldFileName'];
unset($set['OldFileName']);
$set['newfilename'] = $set['NewFileName'];
unset($set['NewFileName']);
$set['mimetype'] = $set['MimeType'];
unset($set['MimeType']);
$set['filesize'] = $set['FileSize'];
unset($set['FileSize']);
$set['submitted'] = $set['SubmissionDate'];
unset($set['SubmissionDate']);
$set['flags'] = $set['DataSetFlags'];
unset($set['DataSetFlags']);
debug($set);
debug($sam);
exit;
}
debug($files);
exit;
}
}