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


PHP Folder类代码示例

本文整理汇总了PHP中Folder的典型用法代码示例。如果您正苦于以下问题:PHP Folder类的具体用法?PHP Folder怎么用?PHP Folder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

 /**
  * undocumented function
  *
  * @return void
  */
 function main()
 {
     $choice = '';
     $Tasks = new Folder(dirname(__FILE__) . DS . 'tasks');
     list($folders, $files) = $Tasks->read();
     $i = 1;
     $choices = array();
     foreach ($files as $file) {
         if (preg_match('/upgrade_/', $file)) {
             $choices[$i] = basename($file, '.php');
             $this->out($i++ . '. ' . basename($file, '.php'));
         }
     }
     while ($choice == '') {
         $choice = $this->in("Enter a number from the list above, or 'q' to exit", null, 'q');
         if ($choice === 'q') {
             $this->out("Exit");
             $this->_stop();
         }
         if ($choice == '' || intval($choice) > count($choices)) {
             $this->err("The number you selected was not an option. Please try again.");
             $choice = '';
         }
     }
     if (intval($choice) > 0 && intval($choice) <= count($choices)) {
         $upgrade = Inflector::classify($choices[intval($choice)]);
     }
     $this->tasks = array($upgrade);
     $this->loadTasks();
     return $this->{$upgrade}->execute();
 }
开发者ID:Galvanio,项目名称:Kinspir,代码行数:36,代码来源:chaw_upgrade.php

示例2: tearDown

 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     $Folder = new Folder($this->Task->path . 'bake_test_app');
     $Folder->delete();
     unset($this->Task);
 }
开发者ID:SebFav,项目名称:ApplicationInternet2,代码行数:12,代码来源:ProjectTaskTest.php

示例3: main

 /**
  * Performs the initial git-svn clone of plugins.
  *
  * This shell grabs plugins that require their initial clone in the order
  * they were requested, and clones them from the WordPress SVN repository.
  *
  * If unspecified, a maximum of 5 plugins will be cloned with one run.
  *
  * @return int Shell return code.
  */
 function main()
 {
     $max = 5;
     if (isset($this->args[0]) && is_numeric($this->args[0]) && $this->args[0] > 0) {
         $max = (int) $this->args[0];
     }
     $plugins = $this->Plugin->findByState('cloning', array('contain' => array('PluginsState' => array('State')), 'order' => array('InnerPluginsState.modified'), 'limit' => $max));
     if (count($plugins) == 0) {
         $this->out(__('<info>No plugins need to be cloned.</info>'));
         $this->_unlock();
         return 0;
     }
     $this->out(__('Cloning %d plugins...', count($plugins)));
     $dir = new Folder(TMP . 'git', true, 0755);
     $error = implode(', ', $dir->errors());
     if (!empty($error)) {
         $this->_unlock();
         $this->error(__('Filesystem Error'), __('Failed to create git clone directory: %s', $error));
     }
     $dir = new Folder(TMP . 'logs' . DS . 'git', true, 0755);
     $error = implode(', ', $dir->errors());
     if (!empty($error)) {
         $this->_unlock();
         $this->error(__('Filesystem Error'), __('Failed to create git logs directory: %s', $error));
     }
     foreach ($plugins as $plugin) {
         $this->out(__('Cloning: "%s" (%d)', $plugin['Plugin']['slug'], $plugin['Plugin']['id']));
         $svn_url = sprintf(Configure::read('App.plugin_svn_url'), $plugin['Plugin']['slug']);
         $git_path = sprintf(Configure::read('App.plugin_repo_path'), $plugin['Plugin']['slug']);
         $log_path = TMP . 'logs' . DS . 'git' . DS . $plugin['Plugin']['slug'] . '.log';
         // Clear out any existing git-svn clone attempt that failed before.
         $git_dir = new Folder($git_path);
         $git_dir->delete();
         try {
             $this->_exec('git svn clone -qq --prefix=svn/ -s %s %s >> %s 2>&1', $svn_url, $git_path, $log_path);
         } catch (RuntimeException $e) {
             $this->out(__('<warning>Failed to clone "%s", please check the git log file.</warning>', $plugin['Plugin']['slug']));
             $this->PluginsState->touch($plugin['InnerPluginsState']['id']);
             continue;
         }
         if (!$this->_createGithubRepo($plugin['Plugin']['slug'])) {
             $this->PluginsState->touch($plugin['InnerPluginsState']['id']);
             continue;
         }
         if (!$this->PluginsState->findOrCreate($plugin['Plugin']['id'], 'cloned') || !$this->PluginsState->findOrCreate($plugin['Plugin']['id'], 'updating')) {
             $this->out(__('<warning>Failed marking plugin as cloned.</warning>'));
             // Even though this plugin cloned successfully, if we can't
             // mark it as cloned, we don't want it to slip into limbo, so
             // we'll let it attempt to do the full clone all over again.
             $this->PluginsState->touch($plugin['InnerPluginsState']['id']);
             continue;
         }
         if (!$this->PluginsState->delete($plugin['InnerPluginsState']['id'])) {
             $this->out(__('<warning>Failed removing "cloning" state on cloned plugin.</warning>'));
         }
     }
     $this->out(__('<info>Finished cloning plugins.</info>'));
     $this->_unlock();
     return 0;
 }
开发者ID:hasannawaz,项目名称:pluginmirror,代码行数:70,代码来源:CloneShell.php

示例4: 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();
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:31,代码来源:QueueShell.php

示例5: main

 public function main()
 {
     $App = new Folder(APP);
     $r = $App->findRecursive('.*\\.php');
     $this->out("Checking *.php in " . APP);
     $folders = array();
     foreach ($r as $file) {
         $error = '';
         $action = '';
         $c = file_get_contents($file);
         if (preg_match('/^[\\n\\r|\\n\\r|\\n|\\r|\\s]+\\<\\?php/', $c)) {
             $error = 'leading';
         }
         if (preg_match('/\\?\\>[\\n\\r|\\n\\r|\\n|\\r|\\s]+$/', $c)) {
             $error = 'trailing';
         }
         if (!empty($error)) {
             $this->report[$error][0]++;
             $this->out('');
             $this->out('contains ' . $error . ' whitespaces: ' . $this->shortPath($file));
             if (!$this->autoCorrectAll) {
                 $dirname = dirname($file);
                 if (in_array($dirname, $folders)) {
                     $action = 'y';
                 }
                 while (empty($action)) {
                     //TODO: [r]!
                     $action = $this->in(__('Remove? [y]/[n], [a] for all in this folder, [r] for all below, [*] for all files(!), [q] to quit'), array('y', 'n', 'r', 'a', 'q', '*'), 'q');
                 }
             } else {
                 $action = 'y';
             }
             if ($action == '*') {
                 $action = 'y';
                 $this->autoCorrectAll = true;
             } elseif ($action == 'a') {
                 $action = 'y';
                 $folders[] = $dirname;
                 $this->out('All: ' . $dirname);
             }
             if ($action == 'q') {
                 die('Abort... Done');
             } elseif ($action == 'y') {
                 if ($error == 'leading') {
                     $res = preg_replace('/^[\\n\\r|\\n\\r|\\n|\\r|\\s]+\\<\\?php/', '<?php', $c);
                 } else {
                     //trailing
                     $res = preg_replace('/\\?\\>[\\n\\r|\\n\\r|\\n|\\r|\\s]+$/', '?>', $c);
                 }
                 file_put_contents($file, $res);
                 $this->report[$error][1]++;
                 $this->out('fixed ' . $error . ' whitespaces: ' . $this->shortPath($file));
             }
         }
     }
     # report
     $this->out('--------');
     $this->out('found ' . $this->report['leading'][0] . ' leading, ' . $this->report['trailing'][0] . ' trailing ws');
     $this->out('fixed ' . $this->report['leading'][1] . ' leading, ' . $this->report['trailing'][1] . ' trailing ws');
 }
开发者ID:robksawyer,项目名称:grabitdown,代码行数:60,代码来源:WhitespaceShell.php

示例6: tearDown

 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     unset($this->Package);
     $Folder = new Folder(TMP . DS . 'repos');
     $Folder->delete();
     parent::tearDown();
 }
开发者ID:superstarrajini,项目名称:cakepackages,代码行数:12,代码来源:PackageTest.php

示例7: tearDown

 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Task);
     $Folder = new Folder($this->path);
     $Folder->delete();
 }
开发者ID:robotarmy,项目名称:Phog,代码行数:12,代码来源:extract.test.php

示例8: InsertPageNumber

 public function InsertPageNumber($fileName, $alignment, $format, $isTop, $setPageNumberOnFirstPage)
 {
     try {
         //check whether files are set or not
         if ($fileName == "") {
             throw new Exception("File not specified");
         }
         //Build JSON to post
         $fieldsArray = array('Format' => $format, 'Alignment' => $alignment, 'IsTop' => $isTop, 'SetPageNumberOnFirstPage' => $setPageNumberOnFirstPage);
         $json = json_encode($fieldsArray);
         //build URI to insert page number
         $strURI = Product::$BaseProductUri . "/words/" . $fileName . "/insertPageNumbers";
         //sign URI
         $signedURI = Utils::Sign($strURI);
         $responseStream = Utils::processCommand($signedURI, "POST", "json", $json);
         $v_output = Utils::ValidateOutput($responseStream);
         if ($v_output === "") {
             //Save docs on server
             $folder = new Folder();
             $outputStream = $folder->GetFile($fileName);
             $outputPath = SaasposeApp::$OutPutLocation . $fileName;
             Utils::saveFile($outputStream, $outputPath);
             return "";
         } else {
             return $v_output;
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
开发者ID:nishantcbse,项目名称:Saaspose.SDK-for-PHP,代码行数:30,代码来源:Field.php

示例9: 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();
 }
开发者ID:awallef,项目名称:trois,代码行数:30,代码来源:TroisImageView.php

示例10: _excludeGitFolder

 /**
  * Remove a pasta .git
  */
 function _excludeGitFolder($pluginPath)
 {
     App::import('Folder');
     $gitFolder = $pluginPath . DS . '.git' . DS;
     $folder = new Folder($gitFolder, false);
     $folder->delete($gitFolder);
 }
开发者ID:rodrigorm,项目名称:plugin_manager,代码行数:10,代码来源:git.php

示例11: upload

 public function upload(Model $Model, $arquivo = array(), $altura = 800, $largura = 600, $pasta = null, $nome_arquivo)
 {
     // App::uses('Vendor', 'wideimage');
     App::import('Vendor', 'WideImage', array('file' => 'WideImage' . DS . 'WideImage.php'));
     App::uses('Folder', 'Utility');
     $ext = array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/x-jps', 'image/png', 'image/gif');
     if ($arquivo['error'] != 0 || $arquivo['size'] == 0) {
         return false;
     }
     $img = WideImage::load($arquivo['tmp_name']);
     $folder = new Folder();
     $pathinfo = pathinfo($arquivo['name']);
     if ($folder->create(WWW_ROOT . 'img' . DS . $pasta . DS)) {
         //se conseguiu criar o diretório eu dou permissão
         $folder->chmod(WWW_ROOT . 'img' . DS . $pasta . DS, 0755, true);
     } else {
         return false;
     }
     $pathinfo['filename'] = strtolower(Inflector::slug($pathinfo['filename'], '-'));
     $arquivo['name'] = $nome_arquivo . '.' . $pathinfo['extension'];
     $img->saveToFile(WWW_ROOT . 'img' . DS . $pasta . DS . 'original_' . $arquivo['name']);
     $img = $img->resize($largura, $altura, 'fill');
     $img->saveToFile(WWW_ROOT . 'img' . DS . $pasta . DS . $arquivo['name']);
     // debug(WWW_ROOT.'img'.DS.$pasta.DS.$arquivo['name']); die;
     return $arquivo['name'];
 }
开发者ID:vitorrampazzo,项目名称:cms,代码行数:26,代码来源:UploadBehavior.php

示例12: DeleteChart

 public function DeleteChart($chartIndex)
 {
     try {
         //check whether file is set or not
         if ($this->FileName == "") {
             throw new Exception("No file name specified");
         }
         //check whether workshett name is set or not
         if ($this->WorksheetName == "") {
             throw new Exception("Worksheet name not specified");
         }
         $strURI = Product::$BaseProductUri . "/cells/" . $this->FileName . "/worksheets/" . $this->WorksheetName . "/charts/" . $chartIndex;
         $signedURI = Utils::Sign($strURI);
         $responseStream = Utils::processCommand($signedURI, "DELETE", "", "");
         $v_output = Utils::ValidateOutput($responseStream);
         if ($v_output === "") {
             //Save doc on server
             $folder = new Folder();
             $outputStream = $folder->GetFile($this->FileName);
             $outputPath = SaasposeApp::$OutPutLocation . $this->FileName;
             Utils::saveFile($outputStream, $outputPath);
             return "";
         } else {
             return $v_output;
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
开发者ID:nishantcbse,项目名称:Saaspose.SDK-for-PHP,代码行数:29,代码来源:ChartEditor.php

示例13: addFolder

 public function addFolder()
 {
     $form = new Form('form-addfolder', Router::getInstance()->build('BrowserController', 'addFolder'));
     $fieldset = new Fieldset(System::getLanguage()->_('AddFolder'));
     $name = new Text('name', System::getLanguage()->_('FolderName'), true);
     $parent = new Select('parent', System::getLanguage()->_('ParentFolder'), Folder::getAll());
     $parent->selected_value = Utils::getGET('parent', 0);
     $fieldset->addElements($name, $parent);
     $form->addElements($fieldset);
     if (Utils::getPOST('submit', false) !== false) {
         if ($form->validate()) {
             try {
                 $folder = new Folder($parent->selected_value);
                 $folder->addFolder($name->value);
                 if ($folder->id == 0) {
                     System::forwardToRoute(Router::getInstance()->build('BrowserController', 'index'));
                 } else {
                     System::forwardToRoute(Router::getInstance()->build('BrowserController', 'show', $folder->id));
                 }
                 exit;
             } catch (InvalidFolderNameException $e) {
                 $name->error = System::getLanguage()->_('ErrorInvalidFolderName');
             } catch (FolderAlreadyExistsException $e) {
                 $name->error = System::getLanguage()->_('ErrorFolderAlreadyExists');
             } catch (Exception $e) {
                 $name->error = System::getLanguage()->_('ErrorInvalidParameter');
             }
         }
     }
     $form->setSubmit(new Button(System::getLanguage()->_('Create'), 'icon icon-new-folder'));
     $smarty = new Template();
     $smarty->assign('title', System::getLanguage()->_('AddFolder'));
     $smarty->assign('form', $form->__toString());
     $smarty->display('form.tpl');
 }
开发者ID:nicefirework,项目名称:sharecloud,代码行数:35,代码来源:BrowserController.class.php

示例14: getTemplates

 /**
  * レイアウトテンプレートを取得
  * コンボボックスのソースとして利用
  * 
  * @return array レイアウトの一覧データ
  */
 public function getTemplates()
 {
     $templatesPathes = array();
     if ($this->BcBaser->siteConfig['theme']) {
         $templatesPathes[] = WWW_ROOT . 'theme' . DS . $this->BcBaser->siteConfig['theme'] . DS . 'Feed' . DS;
     }
     $templatesPathes[] = BASER_PLUGINS . 'Feed' . DS . 'View' . DS . 'Feed' . DS;
     $_templates = array();
     foreach ($templatesPathes as $templatesPath) {
         $folder = new Folder($templatesPath);
         $files = $folder->read(true, true);
         $foler = null;
         if ($files[1]) {
             if ($_templates) {
                 $_templates = am($_templates, $files[1]);
             } else {
                 $_templates = $files[1];
             }
         }
     }
     $templates = array();
     foreach ($_templates as $template) {
         $ext = Configure::read('BcApp.templateExt');
         if ($template != 'ajax' . $ext && $template != 'error' . $ext) {
             $template = basename($template, $ext);
             $templates[$template] = $template;
         }
     }
     return $templates;
 }
开发者ID:naow9y,项目名称:basercms,代码行数:36,代码来源:FeedHelper.php

示例15: getUniqueFileNameWithinTarget

 /**
  * Get a unique filename within given target folder, remove uniqid() suffix from file (optional, add $strPrefix) and append file count by name to
  * file if file with same name already exists in target folder
  *
  * @param string $strTarget The target file path
  * @param string $strPrefix A uniqid prefix from the given target file, that was added to the file before and should be removed again
  * @param        $i         integer Internal counter for recursion usage or if you want to add the number to the file
  *
  * @return string | false The filename with the target folder and unique id or false if something went wrong (e.g. target does not exist)
  */
 public static function getUniqueFileNameWithinTarget($strTarget, $strPrefix = null, $i = 0)
 {
     $objFile = new \File($strTarget, true);
     $strTarget = ltrim(str_replace(TL_ROOT, '', $strTarget), '/');
     $strPath = str_replace('.' . $objFile->extension, '', $strTarget);
     if ($strPrefix && ($pos = strpos($strPath, $strPrefix)) !== false) {
         $strPath = str_replace(substr($strPath, $pos, strlen($strPath)), '', $strPath);
         $strTarget = $strPath . '.' . $objFile->extension;
     }
     // Create the parent folder
     if (!file_exists($objFile->dirname)) {
         $objFolder = new \Folder(ltrim(str_replace(TL_ROOT, '', $objFile->dirname), '/'));
         // something went wrong with folder creation
         if ($objFolder->getModel() === null) {
             return false;
         }
     }
     if (file_exists(TL_ROOT . '/' . $strTarget)) {
         // remove suffix
         if ($i > 0 && StringUtil::endsWith($strPath, '_' . $i)) {
             $strPath = rtrim($strPath, '_' . $i);
         }
         // increment counter & add extension again
         $i++;
         // for performance reasons, add new unique id to path to make recursion come to end after 100 iterations
         if ($i > 100) {
             return static::getUniqueFileNameWithinTarget(static::addUniqIdToFilename($strPath . '.' . $objFile->extension, null, false));
         }
         return static::getUniqueFileNameWithinTarget($strPath . '_' . $i . '.' . $objFile->extension, $strPrefix, $i);
     }
     return $strTarget;
 }
开发者ID:heimrichhannot,项目名称:contao-haste_plus,代码行数:42,代码来源:Files.php


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