当前位置: 首页>>代码示例>>PHP>>正文


PHP Folder::cd方法代码示例

本文整理汇总了PHP中Cake\Filesystem\Folder::cd方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::cd方法的具体用法?PHP Folder::cd怎么用?PHP Folder::cd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Filesystem\Folder的用法示例。


在下文中一共展示了Folder::cd方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload

 /**
  * This function is used to uplodad file in /uploads/YEAR/MONTH directory 
  * and to create Content record contextually.
  * 
  * 
  * @param type $inputfile
  * @param string $destfile
  * @return boolean
  */
 public function upload($inputfile, $destfile = null)
 {
     if (strlen(trim($inputfile['name'])) === 0) {
         return FALSE;
     }
     $filename = strtolower($inputfile['name']);
     $sourcefile = $inputfile['tmp_name'];
     $file = new \Cake\Filesystem\File($sourcefile, true, 0775);
     $CONTENT_YEAR = date('Y');
     $CONTENT_MONTH = date('m');
     $UPLOAD_DIR = $this->path;
     $folder_dest = new Folder($UPLOAD_DIR);
     if (!$folder_dest->inCakePath($folder_dest->pwd() . DS . $CONTENT_YEAR)) {
         $folder_dest->create($folder_dest->pwd() . DS . $CONTENT_YEAR);
     }
     $folder_dest->cd($CONTENT_YEAR);
     if (!$folder_dest->inCakePath($folder_dest->pwd() . DS . $CONTENT_MONTH)) {
         $folder_dest->create($folder_dest->pwd() . DS . $CONTENT_MONTH);
     }
     $folder_dest->cd($CONTENT_MONTH);
     $path = DS . $CONTENT_YEAR . DS . $CONTENT_MONTH . DS;
     $permittedFilename = $this->getPermittedFilename($UPLOAD_DIR . $path, $filename);
     $destfile = $folder_dest->pwd() . DS . $permittedFilename;
     if ($file->copy($destfile, true)) {
         return $path . $permittedFilename;
     } else {
         return FALSE;
     }
 }
开发者ID:aoliverio,项目名称:content,代码行数:38,代码来源:File.php

示例2: includeCmsAdminAssets

 /**
  * Includes all necessary JS code for admin editing of CmsBlocks.
  *
  * @return void
  */
 public function includeCmsAdminAssets()
 {
     $script = 'var Cms = {AdminWidgetControllers: {}};';
     $this->Html->scriptBlock($script, ['block' => true]);
     $this->Html->script('Cms.app/lib/AdminWidgetController.js', ['block' => true]);
     $availableWidgets = WidgetManager::getAvailableWidgets();
     $adminControllers = [];
     $folder = new Folder();
     foreach ($availableWidgets as $widgetIdentifier) {
         $widget = WidgetFactory::identifierFactory($widgetIdentifier);
         $webrootPath = $widget->getWebrootPath();
         if (!is_dir($webrootPath)) {
             continue;
         }
         $folder->cd($webrootPath . 'js/');
         $jsFiles = $folder->read();
         if (empty($jsFiles[1])) {
             continue;
         }
         foreach ($jsFiles[1] as $filename) {
             if (strpos($filename, 'AdminWidgetController.js') !== false) {
                 $adminControllers[] = '/cms/widget/' . $widgetIdentifier . '/js/' . $filename;
             }
         }
     }
     $this->Html->script($adminControllers, ['block' => true]);
 }
开发者ID:scherersoftware,项目名称:cake-cms,代码行数:32,代码来源:CmsAdminHelper.php

示例3: checkIfSubfolderExistsAndCreateIfFalseAndReturnPath

 private function checkIfSubfolderExistsAndCreateIfFalseAndReturnPath($folder, $subfolder)
 {
     $folderObject = new Folder($folder);
     $folder = $folderObject->read();
     if (!in_array($subfolder, $folder[0])) {
         $folderObject->create($subfolder);
     }
     $folderObject->cd($subfolder);
     return $folderObject->path;
 }
开发者ID:alexdd55,项目名称:AMUploadBehavior,代码行数:10,代码来源:AMUploadBehavior.php

示例4: install

 /**
  * Faz uma instalação básica do plugin.
  * A instalação consiste em criar o arquivo de configurações do plugin no diretório apropriado.
  * Este método é chamado pelo método PluginStarter::load() quando necessário.
  * 
  * @param string $pluginName O nome do plugin a ser instalado.
  * @return void             
  */
 public function install($pluginName)
 {
     $settingsFileFolder = $this->pluginInstallationFolder . $pluginName . DS;
     if (Plugin::loaded($pluginName)) {
         $defaultFile = Plugin::path($pluginName) . 'config' . DS . 'default_settings.php';
         $folderHandler = new Folder();
         if (!$folderHandler->cd($settingsFileFolder)) {
             $folderHandler->create($settingsFileFolder);
         }
         $fileHandler = new File($defaultFile);
         $fileHandler->copy($settingsFileFolder . 'settings.php');
         $fileHandler->close();
     }
 }
开发者ID:mswagencia,项目名称:msw-appcore,代码行数:22,代码来源:PluginStarter.php

示例5: main

 /**
  * main method
  *
  * @param  string $tempDir an other directory to clear of all folders and files, if desired
  * @return void
  */
 public function main($tempDir = null)
 {
     if (empty($tempDir)) {
         $tempDir = Configure::read('Attachments.tmpUploadsPath');
     }
     if (!Folder::isAbsolute($tempDir)) {
         $this->out('The path must be absolute, "' . $tempDir . '" given.');
         exit;
     }
     $Folder = new Folder();
     if ($Folder->cd($tempDir) === false) {
         $this->out('Path "' . $tempDir . '" doesn\'t seem to exist.');
         exit;
     }
     $dir = new Folder($tempDir);
     $folders = $dir->read();
     $files = $dir->findRecursive();
     $deletedFiles = 0;
     $deletedFolders = 0;
     $this->out('Found ' . count($folders[0]) . ' folders and ' . count($files) . ' files');
     foreach ($files as $filePath) {
         $file = new File($filePath);
         // only delete if last change is longer than 24 hours ago
         if ($file->lastChange() < time() - 24 * 60 * 60 && $file->delete()) {
             $deletedFiles++;
         }
         $file->close();
     }
     foreach ($folders[0] as $folderName) {
         $folder = new Folder($dir->pwd() . $folderName);
         // only delete if folder is empty
         if ($folder->dirsize() === 0 && $folder->delete()) {
             $deletedFolders++;
         }
     }
     $this->out('Deleted ' . $deletedFolders . ' folders and ' . $deletedFiles . ' files.');
 }
开发者ID:cleptric,项目名称:cake-attachments,代码行数:43,代码来源:CleanTempShell.php

示例6: includeCmsAssets

 /**
  * Include necessary cms assets. This has to be called after the page has been rendered.
  * Best place is in the layout.
  *
  * @param array $options Options for the Html->script() calls
  * @return void|string
  */
 public function includeCmsAssets(array $options = [])
 {
     if ($this->_cmsAssetsIncluded) {
         return;
     }
     $options = Hash::merge(['block' => true], $options);
     $out = '';
     $out .= $this->Html->scriptBlock('var Cms = {WidgetControllers: {}};', $options);
     $out .= $this->Html->script('Cms.app/lib/WidgetController.js', $options);
     $folder = new Folder();
     $controllers = [];
     $jsonData = [];
     foreach (WidgetManager::getRegistry() as $uniqueId => $widget) {
         $webrootPath = $widget->getWebrootPath();
         if (!is_dir($webrootPath)) {
             continue;
         }
         $jsonData[$uniqueId] = ['identifier' => $widget->getFullIdentifier(), 'blockId' => $widget->getCmsBlock()->id, 'jsonData' => $widget->getJsonData()];
         $folder->cd($webrootPath . 'js/');
         $jsFiles = $folder->read();
         if (empty($jsFiles[1])) {
             continue;
         }
         foreach ($jsFiles[1] as $filename) {
             if (strpos($filename, 'WidgetController.js') !== false && strpos($filename, 'AdminWidgetController.js') === false) {
                 $controllers[] = '/cms/widget/' . $widget->getIdentifier() . '/js/' . $filename;
             }
         }
     }
     $this->FrontendBridge->setFrontendData('Cms', ['widgets' => $jsonData]);
     $out .= $this->Html->script($controllers, $options);
     $this->_cmsAssetsIncluded = true;
     if (!$options['block']) {
         return $out;
     }
 }
开发者ID:scherersoftware,项目名称:cake-cms,代码行数:43,代码来源:CmsHelper.php

示例7: scan

 /**
  * Scan plugin directories and returns plugin names and their paths within file
  * system. We consider "plugin name" as the name of the container directory.
  *
  * Example output:
  *
  * ```php
  * [
  *     'Users' => '/full/path/plugins/Users/',
  *     'ThemeManager' => '/full/path/plugins/ThemeManager/',
  *     ...
  *     'MySuperPlugin' => '/full/path/plugins/MySuperPlugin/',
  *     'DarkGreenTheme' => '/full/path/plugins/DarkGreenTheme/',
  * ]
  * ```
  *
  * If $ignoreThemes is set to true `DarkGreenTheme` will not be part of the
  * result.
  *
  * NOTE: All paths includes trailing slash.
  *
  * @param bool $ignoreThemes Whether include themes as well or not
  * @return array Associative array as `PluginName` => `/full/path/to/PluginName`
  */
 public static function scan($ignoreThemes = false)
 {
     $cacheKey = "scan({$ignoreThemes})";
     $cache = static::cache($cacheKey);
     if (!$cache) {
         $cache = [];
         $paths = App::path('Plugin');
         $Folder = new Folder();
         $Folder->sort = true;
         foreach ($paths as $path) {
             $Folder->cd($path);
             foreach ($Folder->read(true, true, true)[0] as $dir) {
                 $name = basename($dir);
                 $cache[$name] = normalizePath("{$dir}/");
             }
         }
         // look for Cake plugins installed using Composer
         if (file_exists(VENDOR_INCLUDE_PATH . 'cakephp-plugins.php')) {
             $cakePlugins = (array) (include VENDOR_INCLUDE_PATH . 'cakephp-plugins.php');
             if (!empty($cakePlugins['plugins'])) {
                 $cache = Hash::merge($cakePlugins['plugins'], $cache);
             }
         }
         // filter, remove hidden folders and others
         foreach ($cache as $name => $path) {
             if (strpos($name, '.') === 0) {
                 unset($cache[$name]);
             } elseif ($name == 'CMS') {
                 unset($cache[$name]);
             } elseif ($ignoreThemes && str_ends_with($name, 'Theme')) {
                 unset($cache[$name]);
             }
         }
         $cache = static::cache($cacheKey, $cache);
     }
     return $cache;
 }
开发者ID:quickapps-plugins,项目名称:cms,代码行数:61,代码来源:Plugin.php

示例8: upload

 public function upload($system, $path)
 {
     // UPLOAD THE FILE TO THE RIGHT SYSTEM
     if ($system == 'production') {
         $other = 'development';
     } else {
         $other = 'production';
     }
     $path = str_replace('___', '/', $path);
     $file = new File('../../' . $other . $path);
     $file2 = new File('../../' . $system . $path);
     if (!$file2->exists()) {
         $dirs = explode('/', $path);
         $prod = new Folder('../../' . $system);
         for ($i = 0; $i < sizeof($dirs) - 1; $i++) {
             if (!$prod->cd($dirs[$i])) {
                 $prod->create($dirs[$i]);
                 $prod->cd($dirs[$i]);
             }
         }
     }
     if ($file->copy('../../' . $system . $path)) {
         if (touch('../../' . $system . $path, $file->lastChange())) {
             $this->Flash->success(__('File copied successfully.'));
         } else {
             $this->Flash->success(__('File copied successfully, but time not updated.'));
         }
     } else {
         $this->Flash->error(__('Unable copy file. '));
     }
     return $this->redirect($this->referer());
 }
开发者ID:jaambageek,项目名称:cakeboot-template,代码行数:32,代码来源:FilesController.php

示例9: testConstructWithNonExistentPath

 /**
  * testConstructWithNonExistentPath method
  *
  * @return void
  */
 public function testConstructWithNonExistentPath()
 {
     $path = TMP . 'tests' . DS;
     $Folder = new Folder($path . 'config_non_existent', true);
     $this->assertTrue(is_dir($path . 'config_non_existent'));
     $Folder->cd($path);
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:12,代码来源:FolderTest.php

示例10: getControllersForApp

 /**
  * Retrieve all controller names + paths for the app src.
  *
  * @return array
  */
 public function getControllersForApp()
 {
     $controllers = [];
     $ctrlFolder = new Folder();
     /** @var Folder $ctrlFolder */
     $ctrlFolder->cd(ROOT . DS . 'src' . DS . 'Controller');
     if (!empty($ctrlFolder)) {
         $files = $ctrlFolder->find('.*Controller\\.php$');
         $subLength = strlen('Controller.php');
         foreach ($files as $f) {
             $filename = basename($f);
             if ($filename === 'AppController.php') {
                 continue;
             }
             $ctrlName = substr($filename, 0, strlen($filename) - $subLength);
             $controllers[] = ['name' => $ctrlName, 'path' => $ctrlFolder->path . DS . $f];
         }
         $subFolders = $ctrlFolder->read(true, false, true)[0];
         foreach ($subFolders as $subFolder) {
             $ctrlFolder->cd($subFolder);
             $files = $ctrlFolder->find('.*Controller\\.php$');
             $subLength = strlen('Controller.php');
             foreach ($files as $f) {
                 $filename = basename($f);
                 if ($filename === 'AppController.php') {
                     continue;
                 }
                 $ctrlName = substr($filename, 0, strlen($filename) - $subLength);
                 $controllers[] = ['name' => $ctrlName, 'path' => $ctrlFolder->path . DS . $f];
             }
         }
     }
     return $controllers;
 }
开发者ID:wasabi-cms,项目名称:core,代码行数:39,代码来源:GuardianComponent.php


注:本文中的Cake\Filesystem\Folder::cd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。