本文整理汇总了PHP中Folder::cd方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::cd方法的具体用法?PHP Folder::cd怎么用?PHP Folder::cd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::cd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Find all defined callbacks in the app or other plugins
*
* @param undefined $cached
* @return void
* @access public
*/
public function load()
{
$cached = Cache::read('_plugin_callbacks_', '_cake_models_');
if ($cached !== false) {
$this->settings = $cached;
return $cached;
}
App::import('Folder');
$Folder = new Folder($this->path . 'plugins');
$folders = current($Folder->ls());
$files = array();
foreach ($folders as $folder) {
if ($Folder->cd($this->path . 'models' . DS . 'callbacks')) {
$files = $Folder->findRecursive('([a-z_]+)_' . $folder . '.php');
}
$files = array_flip($files);
foreach ($folders as $_folder) {
if ($Folder->cd($this->path . 'plugins' . DS . $_folder . DS . 'models' . DS . 'callbacks')) {
$files = array_merge($files, array_flip($Folder->findRecursive('([a-z_]+)_' . $folder . '.php')));
}
}
foreach (array_keys($files) as $k => $file) {
if (!preg_match_all('/models\\/callbacks\\/([a-z_]+)_' . $folder . '\\.php/i', $file, $matches)) {
continue;
}
$plugin = current($matches[1]);
if (empty($plugin)) {
$plugin = 'app';
}
$callbackName = Inflector::camelize(sprintf('%s_%s', $plugin, $folder));
$this->settings[$folder][$plugin] = $callbackName;
}
}
Cache::write('_plugin_callbacks_', $this->settings, '_cake_models_');
}
示例2: main
/**
* The main method: where things happen
*
* @access public
*/
function main()
{
if (isset($this->params['quiet'])) {
$this->quiet = true;
}
$tmp = new Folder(TMP);
$folders = reset($tmp->read());
// read only directories (array[0])
foreach ($folders as $folder) {
$tmp->cd(TMP);
$tmp->cd($folder);
$files = end($tmp->read());
// read only files (array[1])
if (in_array('last_interaction', $files)) {
$file_interaction = (int) file_get_contents($tmp->pwd() . DS . 'last_interaction');
// as each piece is 1Mb, this will give the user the chance of uploading at 13,7 kbps (1,7 kb/s)
if (time() - $file_interaction > 600) {
$this->out("Removing {$folder}");
foreach ($files as $file) {
unlink($tmp->pwd() . DS . $file);
}
$tmp->delete();
}
}
}
}
示例3: getJobs
function getJobs()
{
App::import('Core', 'Folder');
$Folder = new Folder();
$jobs = array();
if ($Folder->cd(APP . 'vendors' . DS . 'shells' . DS . 'jobs' . DS)) {
$x = $Folder->read(true, true, true);
$jobs = array_merge($jobs, $x[1]);
}
if ($Folder->cd(VENDORS . DS . 'shells' . DS . 'jobs' . DS)) {
$x = $Folder->read(true, true, true);
$jobs = array_merge($jobs, $x[1]);
}
return $jobs;
}
示例4: __loadEventHandlers
/**
* Loads all available event handler classes for enabled plugins
*
*/
private function __loadEventHandlers()
{
$this->__eventHandlerCache = Cache::read('event_handlers', 'core');
if (empty($this->__eventHandlerCache)) {
App::import('Core', 'Folder');
$folder = new Folder();
$pluginsPaths = App::path('plugins');
foreach ($pluginsPaths as $pluginsPath) {
$folder->cd($pluginsPath);
$plugins = $folder->read();
$plugins = $plugins[0];
if (count($plugins)) {
foreach ($plugins as $pluginName) {
$filename = $pluginsPath . $pluginName . DS . $pluginName . '_events.php';
$className = Inflector::camelize($pluginName . '_events');
if (file_exists($filename)) {
if (EventCore::__loadEventClass($className, $filename)) {
EventCore::__getAvailableHandlers($this->__eventClasses[$className]);
}
}
}
}
}
Cache::write('event_handlers', $this->__eventHandlerCache, 'core');
}
}
示例5: fileList
/**
* Recursive Read a path and return files and folders not in the excluded Folder list
*
* @param string $path The path you wish to read.
* @return array
**/
public function fileList($path)
{
$this->_Folder->cd($path);
$filePattern = $this->fileRegExp . '\\.' . implode('|', $this->allowedExtensions);
$contents = $this->_Folder->findRecursive($filePattern);
$this->_filterFolders($contents);
$this->_filterFiles($contents);
return $contents;
}
示例6: createTemporaryFolder
/**
* createTemporaryFolder
*
* @param string $folderName temporary middle name
* @return Folder
*/
public function createTemporaryFolder($controller, $folderName = 'download')
{
$folder = new Folder();
if (!$folder) {
throw new Exception(__d('net_commons', 'can not create folder'));
}
$folderName = TMP . $controller->plugin . DS . $folderName . DS . microtime(true);
$folder->create($folderName);
if (!$folder->cd($folderName)) {
throw new Exception(__d('net_commons', 'can not change folder'));
}
$this->_workingFolder = $folder;
return $folder;
}
示例7: run
function run()
{
$return = array();
$paths = array(CACHE . 'models', CACHE . 'persistent', CACHE . 'views');
$folder = new Folder();
foreach ($paths as $path) {
$folder->cd($path);
$files = $folder->read();
foreach ($files[1] as $file) {
if ($file == 'empty') {
continue;
}
$return[] = $path . DS . $file;
unlink($path . DS . $file);
}
}
return $return;
}
示例8: expire
/**
* Чистка хранилища по условию
*
* @param array $conditions условие
*
* @return bool
*/
public function expire($conditions = [])
{
$dir = $this->_config['dir'] . DS;
// обрабатываем директории для логов
// переходив в нужную директорию
chdir($dir);
$entries = scandir($dir);
\App::uses('Folder', 'Utility');
$Dir = new \Folder();
$Dir->cd($dir);
foreach ($entries as $entry) {
if (!is_dir($entry) || in_array($entry, ['.', '..']) || !is_writable($entry)) {
continue;
}
if (strtotime($entry) < strtotime($conditions)) {
$Dir->delete($entry);
}
}
return true;
}
示例9: listFiles
public function listFiles()
{
$paths = array('app' => APP . 'Config' . DS . 'Schema' . DS);
$plugins = App::objects('plugin');
CakePlugin::loadAll();
foreach ($plugins as $plugin) {
$paths[$plugin] = App::pluginPath($plugin) . 'Config' . DS . 'Schema' . DS;
}
$fileList = array();
$folder = new Folder();
foreach ($paths as $plugin => $path) {
if ($folder->cd($path)) {
$files = $folder->find('.*\\.mwb');
if (!empty($files)) {
foreach ($files as $file) {
$pathinfo = pathinfo($file);
$fileList[] = array('name' => $plugin . '/' . $pathinfo['filename']);
}
}
}
}
return $fileList;
}
示例10: testNoTestCaseSupplied
/**
* testNoTestCaseSupplied method
*
* @access public
* @return void
*/
function testNoTestCaseSupplied()
{
if (php_sapi_name() != 'cli') {
unset($_GET['group']);
CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter());
CodeCoverageManager::report(false);
$this->assertError();
CodeCoverageManager::start('libs/' . basename(__FILE__), new CakeHtmlReporter());
CodeCoverageManager::report(false);
$this->assertError();
$path = LIBS;
if (strpos(LIBS, ROOT) === false) {
$path = ROOT . DS . LIBS;
}
App::import('Core', 'Folder');
$folder = new Folder();
$folder->cd($path);
$contents = $folder->ls();
/**
* remove method
*
* @param mixed $var
* @access public
* @return void
*/
function remove($var)
{
return $var != basename(__FILE__);
}
$contents[1] = array_filter($contents[1], "remove");
foreach ($contents[1] as $file) {
CodeCoverageManager::start('libs' . DS . $file, new CakeHtmlReporter());
CodeCoverageManager::report(false);
$this->assertNoErrors('libs' . DS . $file);
}
}
}
示例11: testNoTestCaseSuppliedNoErrors
/**
* Test that test cases don't cause errors
*
* @return void
*/
function testNoTestCaseSuppliedNoErrors()
{
if ($this->skipIf(PHP_SAPI == 'cli', 'Is cli, cannot run this test %s')) {
return;
}
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
$path = LIBS;
if (strpos(LIBS, ROOT) === false) {
$path = ROOT . DS . LIBS;
}
App::import('Core', 'Folder');
$folder = new Folder();
$folder->cd($path);
$contents = $folder->read();
$contents[1] = array_filter($contents[1], array(&$this, '_basenameFilter'));
foreach ($contents[1] as $file) {
CodeCoverageManager::init('libs' . DS . $file, $reporter);
CodeCoverageManager::report(false);
$this->assertNoErrors('libs' . DS . $file);
}
}
示例12: get_all_app_controllers
public function get_all_app_controllers()
{
$controllers = array();
App::uses('Folder', 'Utility');
$folder = new Folder();
$didCD = $folder->cd(APP . 'Controller');
if (!empty($didCD)) {
$files = $folder->findRecursive('.*Controller\\.php');
foreach ($files as $fileName) {
$file = basename($fileName);
// Get the controller name
//$controller_class_name = Inflector::camelize(substr($file, 0, strlen($file) - strlen('Controller.php')));
$controller_class_name = Inflector::camelize(substr($file, 0, strlen($file) - strlen('.php')));
App::uses($controller_class_name, 'Controller');
$controllers[] = array('file' => $fileName, 'name' => substr($controller_class_name, 0, strlen($controller_class_name) - strlen('Controller')));
}
}
sort($controllers);
return $controllers;
}
示例13: strtotime
function __loadDbItems()
{
// variable used to determine the read dir time
$acdate = strtotime("now");
// check to see whether a valid directory was passed to the script
if ($this->Session->read('User.dirname_get')) {
// if it is valid, we'll set it as the directory to read data from
$this->dirpath = $this->Session->read('User.dirname_get');
} else {
// if it is invalid, we'll use the default directory
$this->dirpath = Configure::read('default_get_dir');
}
// use Folder class
$dir = new Folder($this->dirpath);
// try to change the current working directory to the one from wich i want to read contents from
if (!$dir->cd($this->dirpath)) {
// if the change failed, I'll use the default directory
$this->dirpath = Configure::read('default_get_dir');
$dir->cd(Configure::read('default_get_dir'));
}
// once the current working directory is set, it is opened and read from
$dir_listing = $dir->read(true, false, true);
if ($dir_listing) {
// while there are still entries
foreach ($dir_listing[1] as $entry) {
// if the entry is to be shown (not part of the 'not_to_be_shown' array)
if (!in_array($entry, Configure::read('not_to_be_shown'))) {
$file = new File($entry);
if ($file->readable()) {
// store the file extension
$fext = $file->ext();
// store the filename
$fname = $file->name;
// store the lowercased extension
$lfext = strtolower($fext);
// store size of file into KB
$fsize = round($file->size() / 1024, 2);
// store date of file
$fidate = $file->lastChange();
// store dirpath with file
$finfokey = $entry;
// store absfilename
$fnameabs = $file->name();
// define check for filestatus_status (if updated)
$update_status = Configure::read('msg_items_file_unselected');
// check table fileinfo for update or insert
$file_info = $this->FileInfo->find('first', array('conditions' => array('fileinfo_id' => $finfokey), 'fields' => array('fileinfo_id', 'fileinfo_filedate')));
if (!empty($file_info)) {
$this->FileInfo->read(null, $file_info['FileInfo']['fileinfo_id']);
$this->FileInfo->set(array('fileinfo_dirname' => $this->dirpath, 'fileinfo_filename' => $fname, 'fileinfo_absfilename' => $fnameabs, 'fileinfo_ext' => $lfext, 'fileinfo_size' => $fsize, 'fileinfo_filedate' => $fidate, 'fileinfo_timenow' => $acdate));
$this->FileInfo->save();
// check data modified file is changed
if ($fidate > $file_info['FileInfo']['fileinfo_filedate']) {
$update_status = Configure::read('msg_items_file_updated');
}
} else {
$this->FileInfo->create();
$this->FileInfo->set(array('fileinfo_id' => $finfokey, 'fileinfo_dirname' => $this->dirpath, 'fileinfo_filename' => $fname, 'fileinfo_absfilename' => $fnameabs, 'fileinfo_ext' => $lfext, 'fileinfo_size' => $fsize, 'fileinfo_filedate' => $fidate, 'fileinfo_timenow' => $acdate));
$this->FileInfo->save();
}
// check table filestatus for update or insert
$file_status = $this->FileStatus->find('first', array('conditions' => array('filestatus_fileinfo_key' => $finfokey, 'filestatus_users_id' => $this->Session->read('User.id')), 'fields' => array('filestatus_id', 'filestatus_status')));
if (!empty($file_status)) {
if ($file_status['FileStatus']['filestatus_status'] == Configure::read('msg_items_file_selected') && $update_status != Configure::read('msg_items_file_updated')) {
$update_status = Configure::read('msg_items_file_selected');
}
$this->FileStatus->read(null, $file_status['FileStatus']['filestatus_id']);
$this->FileStatus->set(array('filestatus_status' => $update_status, 'filestatus_users_id' => $this->Session->read('User.id'), 'filestatus_timenow' => $acdate));
$this->FileStatus->save();
} else {
$this->FileStatus->create();
$this->FileStatus->set(array('filestatus_fileinfo_key' => $finfokey, 'filestatus_status' => $update_status, 'filestatus_users_id' => $this->Session->read('User.id'), 'filestatus_timenow' => $acdate));
$this->FileStatus->save();
}
}
}
}
// check consistency : delete from db files that's removed from directory
$file_info_del = $this->FileInfo->deleteAll(array('fileinfo_timenow < ' => $acdate));
if (!$file_info_del) {
$this->log('DownloadsController:__loadDbItems - Unable delete FileInfo model record', Configure::read('log_file'));
}
// check consistency : delete from db files that's removed from directory
$file_status_del = $this->FileStatus->deleteAll(array('filestatus_timenow < ' => $acdate, 'filestatus_users_id' => $this->Session->read('User.id')));
if (!$file_status_del) {
$this->log('DownloadsController:__loadDbItems - Unable delete FileStatus model record', Configure::read('log_file'));
}
}
}
示例14: Folder
/**
* Checks to see if the temporary plugin folder exists
* and creates it if it does not
*
* @return void
* @author Jose Diaz-Gonzalez
**/
function __checkPluginFolder()
{
$tempHandler = new Folder();
$tempPath = trim(TMP);
$pluginPath = trim(TMP . 'plugins');
$tempHandler->cd($tempPath);
$temp = $tempHandler->ls();
foreach ($temp[0] as $tempFolder) {
if ($tempFolder !== 'plugins') {
$tempHandler->create($pluginPath);
}
}
}
示例15: Folder
/**
* Creates thumbnail folders if they do not already exist
*
* @param string $dir Path to uploads
* @param array $thumbsizes List of names of thumbnail type
* @return void
* @access protected
*/
function _createFolders($dir, $thumbsizes)
{
if ($dir[0] !== '/') {
$dir = WWW_ROOT . $dir;
}
$folder = new Folder();
if (!$folder->cd($dir)) {
$folder->create($dir);
}
if (!$folder->cd($dir . DS . 'thumb')) {
$folder->create($dir . DS . 'thumb');
}
foreach ($thumbsizes as $thumbName) {
if (!$folder->cd($dir . DS . 'thumb' . DS . $thumbName)) {
$folder->create($dir . DS . 'thumb' . DS . $thumbName);
}
}
}