當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CFileHelper類代碼示例

本文整理匯總了PHP中CFileHelper的典型用法代碼示例。如果您正苦於以下問題:PHP CFileHelper類的具體用法?PHP CFileHelper怎麽用?PHP CFileHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CFileHelper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _installExampleTemplates

 /**
  * Install templates
  *
  * @return void
  */
 private function _installExampleTemplates()
 {
     try {
         $fileHelper = new \CFileHelper();
         @mkdir(craft()->path->getSiteTemplatesPath() . 'sproutemail');
         $fileHelper->copyDirectory(craft()->path->getPluginsPath() . 'sproutemail/templates/_special/examples/emails', craft()->path->getSiteTemplatesPath() . 'sproutemail');
     } catch (\Exception $e) {
         $this->_handleError($e);
     }
 }
開發者ID:aladrach,項目名稱:Bluefoot-Craft-Starter,代碼行數:15,代碼來源:SproutEmail_ExamplesController.php

示例2: run

 public function run($args = null)
 {
     $theme = $args[0];
     $themePath = realpath(dirname(__FILE__) . '/../../themes') . DIRECTORY_SEPARATOR . $theme;
     if (!file_exists($themePath)) {
         mkdir($themePath);
         mkdir($themePath . '/views');
     }
     // Find all modules views and copy to theme directory
     $files = glob(realpath(dirname(__FILE__) . '/../') . '/modules/*', GLOB_ONLYDIR);
     foreach ($files as $file) {
         $parts = explode('/', $file);
         $module = end($parts);
         $moduleThemePath = $themePath . '/views/' . $module;
         $moduleViews = glob($file . '/views/*', GLOB_ONLYDIR);
         foreach ($moduleViews as $viewsDirPath) {
             $parts = explode('/', $viewsDirPath);
             if (end($parts) != 'admin') {
                 if (!file_exists($moduleThemePath)) {
                     mkdir($moduleThemePath);
                 }
                 CFileHelper::copyDirectory($viewsDirPath, $moduleThemePath . '/' . end($parts));
             }
         }
     }
 }
開發者ID:Aplay,項目名稱:Fastreview_site,代碼行數:26,代碼來源:ThemeCommand.php

示例3: run

 public function run($args = null)
 {
     $theme = $args[0];
     $themePath = realpath(dirname(__FILE__) . '/../../themes') . '/' . $theme;
     if (!file_exists($themePath)) {
         mkdir($themePath);
         mkdir($themePath . '/views');
     }
     // Find all modules views and copy to theme directory
     $files = glob(realpath(dirname(__FILE__) . '/../') . '/modules/*', GLOB_ONLYDIR);
     foreach ($files as $file) {
         $parts = explode('/', $file);
         $module = end($parts);
         // Don't copy next modules to theme dir.
         if (in_array($module, array('admin', 'install', 'rights'))) {
             continue;
         }
         $moduleThemePath = $themePath . '/views/' . $module;
         $moduleViews = glob($file . '/views/*', GLOB_ONLYDIR);
         foreach ($moduleViews as $viewsDirPath) {
             $parts = explode('/', $viewsDirPath);
             if (end($parts) != 'admin') {
                 if (!file_exists($moduleThemePath)) {
                     mkdir($moduleThemePath, 0777, true);
                 }
                 CFileHelper::copyDirectory($viewsDirPath, $moduleThemePath . '/' . end($parts));
             }
         }
     }
 }
開發者ID:kolbensky,項目名稱:rybolove,代碼行數:30,代碼來源:ThemeCommand.php

示例4: getModels

 protected function getModels()
 {
     $models = array();
     $files = scandir(Yii::getPathOfAlias('application.models'));
     foreach ($files as $file) {
         if ($file[0] !== '.' && CFileHelper::getExtension($file) === 'php') {
             $fileClassName = substr($file, 0, strpos($file, '.'));
             if (class_exists($fileClassName) && is_subclass_of($fileClassName, 'GiiyActiveRecord')) {
                 $fileClass = new ReflectionClass($fileClassName);
                 if (!$fileClass->isAbstract() && !is_array(GiiyActiveRecord::model($fileClassName)->getPrimaryKey())) {
                     $models[] = $fileClassName;
                 }
             }
         }
     }
     foreach (Yii::app()->getModules() as $module => $moduleConf) {
         if (Yii::getPathOfAlias($module . '.models')) {
             $files = scandir(Yii::getPathOfAlias($module . '.models'));
             foreach ($files as $file) {
                 if ($file[0] !== '.' && CFileHelper::getExtension($file) === 'php') {
                     $fileClassName = substr($file, 0, strpos($file, '.'));
                     if (class_exists($fileClassName) && is_subclass_of($fileClassName, 'GiiyActiveRecord')) {
                         $fileClass = new ReflectionClass($fileClassName);
                         if (!$fileClass->isAbstract() && !is_array(GiiyActiveRecord::model($fileClassName)->getPrimaryKey())) {
                             $models[] = $fileClassName;
                         }
                     }
                 }
             }
         }
     }
     return $models;
 }
開發者ID:schyzoo,項目名稱:giiy,代碼行數:33,代碼來源:GiiyCrudGenerator.php

示例5: 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

示例6: 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

示例7: 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

示例8: afterSave

 public function afterSave($event)
 {
     if (!empty($_FILES)) {
         $model = $this->getOwner();
         $file = new File();
         $file->filename = UploadUtils::createUniquefilename($_FILES[self::NAME]['name'], UploadUtils::getPath(self::$fileDir));
         if (move_uploaded_file($_FILES[self::NAME]['tmp_name'], UploadUtils::getPath(self::$fileDir) . DIRECTORY_SEPARATOR . $file->filename)) {
             $file->entity = get_class($model);
             $file->EXid = $model->getPrimaryKey();
             $file->uid = Yii::app()->user->id;
             $file->tag = $this->tag;
             $file->weight = 0;
             $file->timestamp = time();
             $file->filemime = CFileHelper::getMimeTypeByExtension($_FILES[self::NAME]['name']);
             $file->filesize = $_FILES[self::NAME]['size'];
             $file->status = File::STATUS_SAVED;
             // Ensure all other files of the entity are deleted
             //UploadUtils::deleteAllFiles(get_class($this->getOwner()), self::$fileDir);
             if ($file->save()) {
                 Yii::trace("File saved " . $file . "!!!!");
             } else {
                 Yii::log("Could not save File " . print_r($file->getErrors(), true), CLogger::LEVEL_ERROR);
             }
         } else {
             Yii::log("Couldnt move the file", CLogger::LEVEL_ERROR);
         }
     } else {
         Yii::log("Files empty!!!", CLogger::LEVEL_ERROR);
     }
 }
開發者ID:CHILMEX,項目名稱:amocasion,代碼行數:30,代碼來源:SimpleUploadWidget.php

示例9: run

 public function run($thumb)
 {
     $key = key($_GET);
     if (NULL == ($file = Files::model()->findByPk($key))) {
         throw new CException('Page not found', 404);
     }
     $path = Yii::getPathOfAlias('webroot') . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'photos';
     $src_file = $file->id . '.' . $file->extension;
     $in_file = $path . DIRECTORY_SEPARATOR . $src_file;
     $out_file = $path . DIRECTORY_SEPARATOR . $thumb . DIRECTORY_SEPARATOR . $src_file;
     if (is_file($out_file)) {
         $mime = CFileHelper::getMimeType($out_file);
         header('Content-Type: ' . $mime);
         readfile($out_file);
         exit;
     }
     if (is_file($in_file)) {
         $dir = $path . DIRECTORY_SEPARATOR . $thumb;
         if (YII_DEBUG && !file_exists($dir)) {
             mkdir($dir, 0777);
         }
         if (file_exists($dir)) {
             if (($out_file = $file->resize($thumb)) == 0) {
                 throw new CException('Page not found', 404);
             }
             $mime = CFileHelper::getMimeType($in_file);
             header('Content-Type: ' . $mime);
             readfile($out_file);
             exit;
         }
     }
     return parent::run($thumb);
 }
開發者ID:BGCX067,項目名稱:facecom-svn-to-git,代碼行數:33,代碼來源:ImagesController.php

示例10: up

 public function up()
 {
     CFileHelper::removeDirectory(Yii::app()->basePath . "/components/dashboard/");
     CFileHelper::removeDirectory(Yii::app()->basePath . "/../update/");
     CFileHelper::removeDirectory(Yii::app()->basePath . "/../assets/lib/chosen/");
     $this->update('openformat', array("export" => "this.reg_date", "import" => 'this.reg_date'), "id='1362'");
 }
開發者ID:hkhateb,項目名稱:linet3,代碼行數:7,代碼來源:m301120_250215_0031.php

示例11: 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

示例12: actionUpload

 /**
  * Feltölt egy fájlt a megadott tantárgyhoz.
  * @param int $id A tantárgy azonosítója
  */
 public function actionUpload($id)
 {
     if (!Yii::app()->user->getId()) {
         throw new CHttpException(403, 'A funkció használatához be kell jelentkeznie');
     }
     $id = (int) $id;
     $file = CUploadedFile::getInstanceByName("to_upload");
     if ($file == null) {
         throw new CHttpException(404, 'Nem lett fájl kiválasztva a feltöltéshez');
     }
     $filename = $file->getName();
     $localFileName = sha1($filename . microtime()) . "." . CFileHelper::getExtension($filename);
     if (in_array(strtolower(CFileHelper::getExtension($filename)), Yii::app()->params["deniedexts"])) {
         throw new CHttpException(403, ucfirst(CFileHelper::getExtension($filename)) . ' kiterjesztésű fájl nem tölthető fel a szerverre');
     }
     $model = new File();
     $model->subject_id = $id;
     $model->filename_real = $filename;
     $model->filename_local = $localFileName;
     $model->description = htmlspecialchars($_POST["description"]);
     $model->user_id = Yii::app()->user->getId();
     $model->date_created = new CDbExpression('NOW()');
     $model->date_updated = new CDbExpression('NOW()');
     $model->downloads = 0;
     $model->save();
     if ($file->saveAs("upload/" . $localFileName)) {
         $this->redirect(Yii::App()->createUrl("file/list", array("id" => $id)));
     }
 }
開發者ID:std66,項目名稱:de-pti,代碼行數:33,代碼來源:FileController.php

示例13: 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

示例14: 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

示例15: 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


注:本文中的CFileHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。