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


PHP CFileHelper::findFiles方法代码示例

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


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

示例1: actionImagelist

 public function actionImagelist($attr)
 {
     $attribute = strtolower($attr);
     $uploadPath = Yii::app()->basePath . '/../images';
     $uploadUrl = bu('images');
     if ($uploadPath === null) {
         $path = Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'uploads';
         $uploadPath = realpath($path);
         if ($uploadPath === false) {
             exit;
         }
     }
     if ($uploadUrl === null) {
         $uploadUrl = Yii::app()->request->baseUrl . '/uploads';
     }
     $attributePath = $uploadPath . DIRECTORY_SEPARATOR . $attribute;
     $attributeUrl = $uploadUrl . '/' . $attribute . '/';
     $files = CFileHelper::findFiles($attributePath, array('fileTypes' => array('gif', 'png', 'jpg', 'jpeg'), 'level' => 0));
     $data = array();
     if ($files) {
         foreach ($files as $file) {
             $data[] = array('thumb' => $attributeUrl . basename($file), 'image' => $attributeUrl . basename($file));
         }
     }
     echo CJSON::encode($data);
     exit;
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:27,代码来源:PaginaController.php

示例2: run

 public function run($attr)
 {
     $name = strtolower($this->getController()->getId());
     $attribute = strtolower((string) $attr);
     if ($this->uploadPath === null) {
         $path = Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'uploads';
         $this->uploadPath = realpath($path);
         if ($this->uploadPath === false) {
             exit;
         }
     }
     if ($this->uploadUrl === null) {
         $this->uploadUrl = Yii::app()->request->baseUrl . '/uploads';
     }
     $attributePath = $this->uploadPath . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . $attribute;
     $attributeUrl = $this->uploadUrl . '/' . $name . '/' . $attribute . '/';
     $files = CFileHelper::findFiles($attributePath, array('fileTypes' => array('gif', 'png', 'jpg', 'jpeg')));
     $data = array();
     if ($files) {
         foreach ($files as $file) {
             $data[] = array('thumb' => $attributeUrl . basename($file), 'image' => $attributeUrl . basename($file));
         }
     }
     echo CJSON::encode($data);
     exit;
 }
开发者ID:RodolfoRobles,项目名称:SiteNayarit,代码行数:26,代码来源:ImageList.php

示例3: run

 /**
  * Execute the action.
  * @param array command line parameters specific for this command
  */
 public function run($args)
 {
     if (!isset($args[0])) {
         $this->usageError('the CLDR data directory is not specified.');
     }
     if (!is_dir($path = $args[0])) {
         $this->usageError("directory '{$path}' does not exist.");
     }
     // collect XML files to be processed
     $options = array('exclude' => array('.svn'), 'fileTypes' => array('xml'), 'level' => 0);
     $files = CFileHelper::findFiles(realpath($path), $options);
     $sourceFiles = array();
     foreach ($files as $file) {
         $sourceFiles[basename($file)] = $file;
     }
     // sort by file name so that inheritances can be processed properly
     ksort($sourceFiles);
     // process root first because it is inherited by all
     if (isset($sourceFiles['root.xml'])) {
         $this->process($sourceFiles['root.xml']);
         unset($sourceFiles['root.xml']);
         foreach ($sourceFiles as $sourceFile) {
             $this->process($sourceFile);
         }
     } else {
         die('Unable to find the required root.xml under CLDR data directory.');
     }
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:32,代码来源:CldrCommand.php

示例4: prepare

 public function prepare()
 {
     $this->files = array();
     $templatePath = $this->templatePath;
     $modulePath = $this->modulePath;
     $moduleTemplateFile = $templatePath . DIRECTORY_SEPARATOR . 'module.php';
     $this->files[] = new CCodeFile($modulePath . '/' . $this->moduleClass . '.php', $this->render($moduleTemplateFile));
     $files = CFileHelper::findFiles($templatePath, array('exclude' => array('.svn')));
     foreach ($files as $file) {
         if ($file !== $moduleTemplateFile) {
             if (CFileHelper::getExtension($file) === 'php') {
                 $content = $this->render($file);
             } else {
                 if (basename($file) === '.yii') {
                     // an empty directory
                     $file = dirname($file);
                     $content = null;
                 } else {
                     $content = file_get_contents($file);
                 }
             }
             $this->files[] = new CCodeFile($modulePath . substr($file, strlen($templatePath)), $content);
         }
     }
 }
开发者ID:code-4-england,项目名称:OpenEyes,代码行数:25,代码来源:BaseModuleCode.php

示例5: actionGet

 public function actionGet()
 {
     $dir = Yii::getPathOfAlias(Yii::app()->params['sharedMemory']['flushDirectory']);
     $files = CFileHelper::findFiles($dir, array('fileTypes' => array(Yii::app()->params['sharedMemory']['flushExtension'])));
     if (isset($files[0])) {
         $size = filesize($files[0]);
         $file = fopen($files[0], 'r');
         $descriptor = $files[0] . ".descr";
         if (is_file($descriptor)) {
             $descr = fopen($descriptor, "r");
             $pos = fread($descr, filesize($descriptor));
             fclose($descr);
         } else {
             $pos = 0;
         }
         fseek($file, $pos);
         $content = fread($file, self::CHUNK_SIZE);
         $position = strrpos($content, '##') + 2;
         $pos += $position;
         echo substr($content, 0, $position);
         fclose($file);
         $descr = fopen($descriptor, "w");
         fwrite($descr, $pos);
         fclose($descr);
         if ($pos >= $size) {
             unlink($files[0]);
             unlink($descriptor);
         }
         Yii::app()->end();
     }
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:31,代码来源:SyncController.php

示例6: run

 /**
  * Execute the action.
  * @param array command line parameters specific for this command
  */
 public function run($args)
 {
     $options = array('fileTypes' => array('php'), 'exclude' => array('.gitignore', '/messages', '/views', '/cli', '/yii.php', '/yiit.php', '/yiilite.php', '/web/js', '/vendors', '/i18n/data', '/utils/mimeTypes.php', '/test', '/zii', '/gii'));
     $files = CFileHelper::findFiles(YII_PATH, $options);
     $map = array();
     foreach ($files as $file) {
         if (($pos = strpos($file, YII_PATH)) !== 0) {
             die("Invalid file '{$file}' found.");
         }
         $path = str_replace('\\', '/', substr($file, strlen(YII_PATH)));
         $className = substr(basename($path), 0, -4);
         if ($className[0] === 'C') {
             $map[$path] = "\t\t'{$className}' => '{$path}',\n";
         }
     }
     ksort($map);
     $map = implode($map);
     $yiiBase = file_get_contents(YII_PATH . '/YiiBase.php');
     $newYiiBase = preg_replace('/private\\s+static\\s+\\$_coreClasses\\s*=\\s*array\\s*\\([^\\)]*\\)\\s*;/', "private static \$_coreClasses=array(\n{$map}\t);", $yiiBase);
     if ($yiiBase !== $newYiiBase) {
         file_put_contents(YII_PATH . '/YiiBase.php', $newYiiBase);
         echo "YiiBase.php is updated successfully.\n";
     } else {
         echo "Nothing changed.\n";
     }
 }
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:30,代码来源:AutoloadCommand.php

示例7: actionIndex

 public function actionIndex($path = null, $fix = null)
 {
     if ($path === null) {
         $path = YII_PATH;
     }
     echo "Checking {$path} for files with BOM.\n";
     $checkFiles = CFileHelper::findFiles($path, array('exclude' => array('.gitignore')));
     $detected = false;
     foreach ($checkFiles as $file) {
         $fileObj = new SplFileObject($file);
         if (!$fileObj->eof() && false !== strpos($fileObj->fgets(), self::BOM)) {
             if (!$detected) {
                 echo "Detected BOM in:\n";
                 $detected = true;
             }
             echo $file . "\n";
             if ($fix) {
                 file_put_contents($file, substr(file_get_contents($file), 3));
             }
         }
     }
     if (!$detected) {
         echo "No files with BOM were detected.\n";
     } else {
         if ($fix) {
             echo "All files were fixed.\n";
         }
     }
 }
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:29,代码来源:CheckBomCommand.php

示例8: prepare

 public function prepare()
 {
     $this->files = array();
     $templatePath = $this->templatePath;
     $modulePath = $this->modulePath;
     $moduleTemplateFile = $templatePath . DIRECTORY_SEPARATOR . 'module.php';
     $this->files[] = new CCodeFile($modulePath . '/' . $this->moduleClass . '.php', $this->render($moduleTemplateFile));
     $files = CFileHelper::findFiles($templatePath, array('exclude' => array('.svn', '.gitignore')));
     foreach ($files as $file) {
         if ($file !== $moduleTemplateFile && !$this->isIgnireFile($file)) {
             if (CFileHelper::getExtension($file) === 'php') {
                 $content = $this->render($file);
             } elseif (basename($file) === '.gitkeep') {
                 $file = dirname($file);
                 $content = null;
             } else {
                 $content = file_get_contents($file);
             }
             $modifiedFile = $this->getModifiedFile($file);
             if ($modifiedFile !== false) {
                 $file = $modifiedFile;
             }
             $this->files[] = new CCodeFile($modulePath . substr($file, strlen($templatePath)), $content);
         }
     }
 }
开发者ID:alextravin,项目名称:yupe,代码行数:26,代码来源:YupeModuleCode.php

示例9: actionIndex

 /**
  * Lists all log files.
  */
 public function actionIndex()
 {
     //$this->setLogPath();
     $a_files = CFileHelper::findFiles($this->logPath, array('exclude' => array('zip')));
     $arr = array();
     foreach ($a_files as $k => $f) {
         $arr[] = array('id' => $k, 'name' => basename($f), 'size' => filesize($f));
     }
     //print_r($arr);
     $dataProvider = new CArrayDataProvider($arr, array('sort' => array('attributes' => array('name', 'size')), 'pagination' => array('pageSize' => 50)));
     $this->render('index', array('dataProvider' => $dataProvider));
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:15,代码来源:LogController.php

示例10: initialise

 public function initialise($properties = false)
 {
     if ($properties) {
         foreach ($properties as $key => $value) {
             $this->{$key} = $value;
         }
     }
     parent::prepare();
     $this->files = array();
     $this->moduleTemplateFile = $this->templatePath . DIRECTORY_SEPARATOR . 'module.php';
     $this->files[] = new CCodeFile($this->modulePath . '/' . $this->moduleClass . '.php', $this->render($this->moduleTemplateFile));
     $this->files_to_process = CFileHelper::findFiles($this->templatePath, array('exclude' => array('.svn')));
 }
开发者ID:code-4-england,项目名称:OpenEyes,代码行数:13,代码来源:EventTypeModuleCode.php

示例11: getFlagImagesList

 public static function getFlagImagesList()
 {
     Yii::import('system.utils.CFileHelper');
     $adminAssetsUrl = Yii::app()->getModule('admin')->assetsUrl;
     $flagsPath = 'application.modules.admin.assets.images.flags.png';
     $result = array();
     $flags = CFileHelper::findFiles(Yii::getPathOfAlias($flagsPath));
     foreach ($flags as $f) {
         $fileName = end(explode(DIRECTORY_SEPARATOR, $f));
         $result[$fileName] = $fileName;
     }
     return $result;
 }
开发者ID:Aplay,项目名称:anetika_site,代码行数:13,代码来源:SSystemLanguage.php

示例12: actionIndex

 public function actionIndex()
 {
     $files = CFileHelper::findFiles(Yii::getPathOfAlias('application.messages.zh_cn'));
     include Yii::getPathOfAlias('application.data') . '/ZhConversion.php';
     $path = Yii::getPathOfAlias('application.messages.zh_tw');
     foreach ($files as $file) {
         if (basename($file) === 'event.php') {
             continue;
         }
         $content = file_get_contents($file);
         $content = strtr($content, $zh2Hant);
         file_put_contents($path . '/' . basename($file), $content);
     }
 }
开发者ID:sunshy360,项目名称:cubingchina,代码行数:14,代码来源:TwCommand.php

示例13: run

 /**
  * Execute the action.
  * @param array command line parameters specific for this command
  */
 public function run($args)
 {
     // Url template
     $template = 'http://code.google.com/p/yii/source/diff?format=side&path=/trunk/docs/{type}/{name}&old={old}&r={new}';
     if (!isset($args[0])) {
         $this->usageError('the language ID is not specified.');
     }
     $path = Yii::getPathOfAlias('application') . '/../' . $this->type . '/' . $args[0];
     if (!is_dir($path)) {
         $this->usageError("no translation available for language '{$args[0]}'.");
     }
     $srcPath = Yii::getPathOfAlias('application') . '/../' . $this->type . '/source';
     $files = CFileHelper::findFiles($srcPath, array('fileTypes' => array('txt'), 'level' => 0));
     $results = array();
     $urls = array();
     foreach ($files as $file) {
         $name = basename($file);
         $srcContent = file_get_contents($file);
         if (!preg_match('/\\$Id:\\s*([\\w\\.\\-]+)\\s*(\\d+)/iu', $srcContent, $matches) || $name !== $matches[1]) {
             $results[$name] = "revision token not found in source file.";
             continue;
         }
         $srcRevision = $matches[2];
         if (!is_file($path . '/' . $name) || ($content = file_get_contents($path . '/' . $name)) === $srcContent) {
             $results[$name] = "not translated yet.";
         } else {
             if (!preg_match('/\\$Id:\\s*([\\w\\.\\-]+)\\s*(\\d+)/iu', $content, $matches) || $name !== $matches[1]) {
                 $results[$name] = "revision token not found in translation.";
             } else {
                 if ($matches[2] >= $srcRevision) {
                     $results[$name] = "up-to-date.";
                 } else {
                     $results[$name] = "outdated (source: r{$srcRevision}, translation: r{$matches[2]}).";
                     $tr = array('{name}' => $name, '{old}' => $matches[2], '{new}' => $srcRevision, '{type}' => $this->type);
                     $urls[$name] = strtr($template, $tr);
                 }
             }
         }
     }
     asort($results);
     foreach ($results as $name => $result) {
         echo str_pad($name, 30, ' ', STR_PAD_LEFT) . ': ' . $result . "\n";
     }
     echo "\n****************** diff URL's ******************\n";
     asort($urls);
     foreach ($urls as $name => $result) {
         echo $name . ":\n" . $result . "\n\n";
     }
 }
开发者ID:riddickam86,项目名称:yiidoc,代码行数:53,代码来源:SyncguideCommand.php

示例14: generateMessagesModules

    public function generateMessagesModules($locale)
    {
        $modules = ModulesModel::getModules();
        $t = new yandexTranslate();
        $result = array();
        $num = -1;
        $params = array();
        foreach ($modules as $key => $mod) {
            $pathDefault = Yii::getPathOfAlias(self::PATH_MOD . '.' . $key . '.messages.ru');
            $listfile = CFileHelper::findFiles($pathDefault, array('fileTypes' => array('php'), 'absolutePaths' => false));
            $path = Yii::getPathOfAlias(self::PATH_MOD . '.' . $key . '.messages' . DS . $locale);
            //CFileHelper::createDirectory($path, 0777);
            CFileHelper::copyDirectory($pathDefault, $path, array('fileTypes' => array('php'), 'level' => 1));
            foreach ($listfile as $file) {
                //   $file = str_replace('.php', '', $file);
                $openFileContent = self::PATH_MOD . ".{$key}.messages.{$locale}";
                $contentList = (include Yii::getPathOfAlias($openFileContent) . DS . $file);
                // foreach($contentList as $pkey=>$value){
                foreach ($contentList as $pkey => $val) {
                    $params[] = $val;
                    $num++;
                    $spec[$num] = $pkey;
                }
                $response = $t->translate(array('ru', $locale), $contentList);
                foreach ($response['text'] as $k => $v) {
                    $result[$spec[$k]] = $v;
                }
                if (!@file_put_contents($path . DS . $file, '<?php

/**
 * Message translations. (auto translate)
 * 
 * Each array element represents the translation (value) of a message (key).
 * If the value is empty, the message is considered as not translated.
 * Messages that no longer need translation will have their translations
 * enclosed between a pair of \'@@\' marks.
 * 
 * @author Andrew (Panix) Semenov <andrew.panix@gmail.com>
 * @package modules.messages.' . $locale . '
 */
return ' . var_export($result, true) . ';')) {
                    throw new CException(Yii::t('admin', 'Error write modules setting in {file}...', array('{file}' => $file)));
                }
            }
            die('finish ' . $key);
        }
        die('Complate');
        // $locale
    }
开发者ID:buildshop,项目名称:bs-common,代码行数:49,代码来源:TranslatesController.php

示例15: initMultipleModuleData

 /**
  * is a clone of initModuleData the differnece is this import files can contain 
  * multiple destination dataset in one single file, the key being the destignation collection 
  * http://127.0.0.1/ph/communecter/person/initDataPeopleAll
  * http://127.0.0.1/ph/communecter/person/clearInitDataPeopleAll
  * tool mongo query :: db.citoyens.find({email:/oceat/},{email:1,events:1,links:1,projects:1})
  * @param type $moduleId 
  * @param type $type , is the file type when wanting to load only one file at a time
  * @param type $isDummy , if is true, often associated with the type , on each dummy data inserted will be added dummyData:$type
  * @return type
  */
 public static function initMultipleModuleData($moduleId, $type = null, $isDummy = false, $linkAllToActiveUser = false, $reverse = false)
 {
     $res = array("module" => $moduleId, "userId" => Yii::app()->session['userId'], "imported" => array(), "errors" => 0, "linkAllToActiveUser" => $linkAllToActiveUser);
     if (file_exists(Yii::getPathOfAlias(Yii::app()->params["modulePath"] . $moduleId . ".data"))) {
         $file = null;
         foreach (CFileHelper::findFiles(Yii::getPathOfAlias(Yii::app()->params["modulePath"] . $moduleId . ".data")) as $f) {
             //echo pathinfo($f, PATHINFO_FILENAME)."<br/>";
             if (pathinfo($f, PATHINFO_FILENAME) == $type) {
                 $file = $f;
                 break;
             }
         }
         $jsonAll = json_decode(file_get_contents($file), true);
         $importRes = array("file" => $type, "isDummy" => $isDummy ? $type : false, "imports" => array(), "count" => 0, "errors" => 0);
         foreach ($jsonAll as $col => $data) {
             if (!$reverse) {
                 if ($col != "linkAllToActiveUser") {
                     $importRes['imports'][$col] = array();
                     $importRes['imports'][$col]["count"] = count($data);
                     $importRes["count"] += count($data);
                     $importRes['imports'][$col]["collection"] = $col;
                     $errors = array();
                     $infos = array();
                     foreach ($data as $row) {
                         //TODO SBAR - Faire un test sur le type pour utiliser les méthodes du modèle ?
                         $infosRes = self::insertData($row, $col, $type, $isDummy, $linkAllToActiveUser);
                         if ($infosRes["error"]) {
                             array_push($errors, $infosRes["error"]);
                         }
                         array_push($infos, $infosRes["info"]);
                     }
                     $importRes['imports'][$col]["infos"] = $infos;
                     $importRes['imports'][$col]["errors"] = $errors;
                 } else {
                     $linkAllToActiveUser = true;
                     $res["linkAllToActiveUser"] = true;
                 }
             } else {
                 $infosRes = self::removeData($col, $type, $isDummy, $linkAllToActiveUser);
                 $importRes["count"] += $infosRes["count"];
             }
         }
         array_push($res["imported"], $importRes);
     } else {
         $res["msg"] = "Nothing to import";
     }
     return $res;
 }
开发者ID:Koulio,项目名称:pixelhumain,代码行数:59,代码来源:Admin.php


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