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


PHP CFileHelper::getExtension方法代码示例

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


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

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

示例2: prepare

 public function prepare()
 {
     $this->files = array();
     $templatePath = $this->templatePath;
     $controllerTemplateFile = $templatePath . DIRECTORY_SEPARATOR . 'controller.php';
     $this->files[] = new CCodeFile($this->controllerFile, $this->render($controllerTemplateFile));
     $this->files[] = new CCodeFile(str_replace("Controller.php", "AdminController.php", $this->controllerFile), $this->render(str_replace("controller.php", "adminController.php", $controllerTemplateFile)));
     $files = scandir($templatePath);
     foreach ($files as $file) {
         if (is_file($templatePath . '/' . $file) && CFileHelper::getExtension($file) === 'php' && $file !== 'controller.php') {
             $path = $this->viewPath . DIRECTORY_SEPARATOR . $file;
             if ($file == "adminController.php") {
                 continue;
             }
             if ($file == "form.php") {
                 //                    $path = str_replace('\\', '/', $path);
                 //
                 //                    $path_params = str_replace(
                 //                        array("/form.php", MODULES_PATH),
                 //                        null,
                 //                        $path
                 //                    );
                 //
                 //                    $path_params = explode("/", $path_params);
                 //
                 //                    $module_name = $path_params[0];
                 //                    $model_name  = ucfirst($path_params[2]);
                 //
                 //                    $module_dir = MODULES_PATH . $module_name . "/";
                 //
                 //                    $forms_dir = $module_dir . "forms/";
                 //
                 //
                 //                    if (!is_dir($forms_dir))
                 //                    {
                 //                        mkdir($forms_dir);
                 //                        chmod($forms_dir, 0777);
                 //                    }
                 //
                 //                    $path = $forms_dir . $model_name . "Form.php";
             }
             $this->files[] = new CCodeFile($path, $this->render($templatePath . '/' . $file));
         }
     }
     $templatePath = $templatePath . "/admin/";
     $viewPath = $this->viewPath . "Admin/";
     //        if (!is_dir($viewPath))
     //        {
     //            mkdir($viewPath);
     //            chmod($viewPath, 0777);
     //        }
     $files = scandir($templatePath);
     foreach ($files as $file) {
         if ($file[0] == ".") {
             continue;
         }
         $path = $viewPath . $file;
         $this->files[] = new CCodeFile($path, $this->render($templatePath . '/' . $file));
     }
 }
开发者ID:nizsheanez,项目名称:alp.ru,代码行数:60,代码来源:CrudCode.php

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

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

 protected static function geraFilename($url, $outDir = null, $hash = false)
 {
     if ($outDir === null) {
         $outDir = Yii::app()->runtimePath;
     }
     $name = $hash ? md5($url) : tempnam('', 'external');
     $ext = CFileHelper::getExtension(basename($url));
     return "{$outDir}/{$name}.{$ext}";
 }
开发者ID:bruno-melo,项目名称:components,代码行数:9,代码来源:Requests.php

示例7: renderContent

 protected function renderContent()
 {
     if (isset($this->block) && $this->block != null) {
         $model = new UserAvatarForm();
         if (isset($_POST['UserAvatarForm'])) {
             $model->attributes = $_POST['UserAvatarForm'];
             $model->image = CUploadedFile::getInstance($model, 'image');
             if ($model->validate()) {
                 //Get the User Id to determine the folder
                 $folder = user()->id >= 1000 ? (string) (round(user()->id / 1000) * 1000) : '1000';
                 $filename = user()->id . '_' . gen_uuid();
                 if (!(file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder) && AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder)) {
                     mkdir(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder, 0777, true);
                 }
                 if (file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $filename . '.' . strtolower(CFileHelper::getExtension($model->image->name)))) {
                     $filename .= '_' . time();
                 }
                 $filename = $filename . '.' . strtolower(CFileHelper::getExtension($model->image->name));
                 $path = $folder . DIRECTORY_SEPARATOR . $filename;
                 if ($model->image->saveAs(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $path)) {
                     //Generate thumbs
                     //
                     GxcHelpers::generateAvatarThumb($filename, $folder, $filename);
                     //So we will start to check the info from the user
                     $current_user = User::model()->findByPk(user()->id);
                     if ($current_user) {
                         if ($current_user->avatar != null && $current_user->avatar != '') {
                             //We will delete the old avatar here
                             $old_avatar_path = $current_user->avatar;
                             $current_user->avatar = $path;
                             if (file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $old_avatar_path)) {
                                 @unlink(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $old_avatar_path);
                             }
                             //Delete old file Sizes
                             $sizes = AvatarSize::getSizes();
                             foreach ($sizes as $size) {
                                 if (file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size['id'] . DIRECTORY_SEPARATOR . $old_avatar_path)) {
                                     @unlink(AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size['id'] . DIRECTORY_SEPARATOR . $old_avatar_path);
                                 }
                             }
                         } else {
                             //$current_user
                             $current_user->avatar = $path;
                         }
                         $current_user->save();
                     }
                 } else {
                     throw new CHttpException('503', 'Error while uploading!');
                 }
             }
         }
         $this->render(BlockRenderWidget::setRenderOutput($this), array('model' => $model));
     } else {
         echo '';
     }
 }
开发者ID:nganhtuan63,项目名称:gxc-app,代码行数:56,代码来源:AvatarBlock.php

示例8: actionServe

 /**
  * Serve files.
  */
 public function actionServe()
 {
     Yii::$enableIncludePath = false;
     // preload CFileHelper before disabling Yii autoload
     $tmp = CFileHelper::getExtension('');
     $tmp = CLogger::LEVEL_ERROR;
     //@YiiBase::autoload('CHttpException');
     //@YiiBase::autoload('CExceptionEvent');
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     require dirname(dirname(__FILE__)) . '/vendors/minify/min/index.php';
 }
开发者ID:barricade86,项目名称:raui,代码行数:14,代码来源:ExtMinScriptController.php

示例9: getModels

 /**
  * Returns the model names in an array.
  * Only non abstract and subclasses of AweActiveRecord models are returned.
  * The array is used to build the autocomplete field.
  * @return array The names of the models
  */
 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, '.'));
             $models[] = $fileClassName;
         }
     }
     return $models;
 }
开发者ID:azizbekvahidov,项目名称:foods,代码行数:18,代码来源:CrudGenerator.php

示例10: UploadFile

 public function UploadFile(&$resource, $model, &$process, &$message, $remote = false)
 {
     if ($model->upload->size > $this->max_file_size) {
         $allow_size = $this->max_file_size / (1024 * 1024);
         $model->addError('upload', t('cms', 'File size is larger than allowed size : ') . $allow_size . ' mb');
         $process = false;
         return false;
     }
     if ($model->upload->size < $this->min_file_size) {
         $model->addError('upload', t('cms', 'File is too small!'));
         $process = false;
         return false;
     }
     if (count($this->allow_types) > 0) {
         if (!in_array(strtolower(CFileHelper::getExtension($model->upload->name)), $this->allow_types)) {
             $model->addError('upload', t('cms', 'File extension is not allowed!'));
             $process = false;
             return false;
         }
     }
     $filename = $resource->resource_name = $model->upload->name;
     if (settings()->get('system', 'keep_file_name_upload') == '0') {
         $filename = gen_uuid();
     } else {
         $filename = str_replace(" ", "-", $filename);
     }
     // folder for uploaded files
     $folder = date('Y') . DIRECTORY_SEPARATOR . date('m') . DIRECTORY_SEPARATOR;
     if (!(file_exists(self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $folder) && is_dir(self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $folder))) {
         mkdir(self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $folder, 0777, true);
     }
     if (settings()->get('cms', 'system', 'keep_file_name_upload') == '1') {
         //Check if File exists, so Rename the Filename again;
         while (file_exists(self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $filename . '.' . strtolower(CFileHelper::getExtension($model->upload->name)))) {
             $filename .= rand(10, 99);
         }
     }
     if (settings()->get('system', 'keep_file_name_upload') == '0') {
         $filename = $filename . '.' . strtolower(CFileHelper::getExtension($model->upload->name));
     }
     $path = $folder . $filename;
     if ($model->upload->saveAs(self::RESOURCES_FOLDER . DIRECTORY_SEPARATOR . $path)) {
         $resource->resource_path = $path;
         //Resource::generateThumb($model->upload->name,$folder,$filename);
         $process = true;
         return true;
     } else {
         $process = false;
         $message = t('cms', 'Error while Uploading. Try again later.');
         return false;
     }
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:52,代码来源:LocalStorage.php

示例11: prepare

 public function prepare()
 {
     $this->files = array();
     $templatePath = $this->templatePath;
     $controllerTemplateFile = $templatePath . DIRECTORY_SEPARATOR . 'controller.php';
     $this->files[] = new CCodeFile($this->controllerFile, $this->render($controllerTemplateFile));
     $files = scandir($templatePath);
     foreach ($files as $file) {
         if (is_file($templatePath . '/' . $file) && CFileHelper::getExtension($file) === 'php' && $file !== 'controller.php') {
             $this->files[] = new CCodeFile($this->viewPath . DIRECTORY_SEPARATOR . $file, $this->render($templatePath . '/' . $file));
         }
     }
 }
开发者ID:israelCanul,项目名称:Bonanza_V2,代码行数:13,代码来源:CrudCode.php

示例12: getExtension

 /**
  * Получает расширение файла
  * @param string $fileName - имя файла
  * @param string $lower - приводить расширение к нижнему регистру
  * @return string 
  */
 public static function getExtension($fileName, $lower = true)
 {
     $ext = parent::getExtension($fileName);
     if ($lower) {
         $ext = mb_strtolower($ext);
     }
     return $ext;
     preg_match_all('~\\.([^\\.]*)$~u', $fileName, $matches);
     $ext = '';
     if (isset($matches[1][0])) {
         $ext = $matches[1][0];
     }
     return $ext;
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:20,代码来源:HFile.php

示例13: generateAvatarThumb

 public static function generateAvatarThumb($upload_name, $folder, $filename)
 {
     //Start to check if the File type is Image type, so we Generate Everythumb size for it
     if (in_array(strtolower(CFileHelper::getExtension($upload_name)), array('gif', 'jpg', 'png'))) {
         //Start to create Thumbs for it
         $sizes = AvatarSize::getSizes();
         foreach ($sizes as $size) {
             if (!(file_exists(AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size['id'] . DIRECTORY_SEPARATOR . $folder) && AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size . DIRECTORY_SEPARATOR . $folder)) {
                 mkdir(AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size['id'] . DIRECTORY_SEPARATOR . $folder, 0777, true);
             }
             $thumbs = new ImageResizer(AVATAR_FOLDER . DIRECTORY_SEPARATOR . 'root' . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR, $filename, AVATAR_FOLDER . DIRECTORY_SEPARATOR . $size['id'] . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR, $filename, $size['width'], $size['height'], $size['ratio'], 90, '#FFFFFF');
             $thumbs->output();
         }
     }
 }
开发者ID:ntquyen,项目名称:GXC-CMS,代码行数:15,代码来源:GxcHelpers.php

示例14: renderFile

 /**
  * Renders a view file.
  *
  * @param string $viewFile view file path
  * @param array $data data to be extracted and made available to the view
  * @param boolean $return whether the rendering result should be returned instead of being echoed
  * @return string the rendering result. Null if the rendering result is not required.
  * @throws CException if the view file does not exist
  */
 public function renderFile($viewFile, $data = null, $return = false)
 {
     $widgetCount = count($this->_widgetStack);
     if (($renderer = Yii::app()->getViewRenderer()) !== null && $renderer->fileExtension === '.' . CFileHelper::getExtension($viewFile)) {
         $content = $renderer->renderFile($this, $viewFile, $data, $return);
     } else {
         $content = $this->renderInternal($viewFile, $data, $return);
     }
     if (count($this->_widgetStack) === $widgetCount) {
         return $content;
     } else {
         $widget = end($this->_widgetStack);
         throw new CException(Yii::t('yii', '{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.', array('{controller}' => get_class($this), '{view}' => $viewFile, '{widget}' => get_class($widget))));
     }
 }
开发者ID:IuriiP,项目名称:yii-tracker,代码行数:24,代码来源:CBaseController.php

示例15: getLayouts

 /**
  * @return array
  */
 protected function getLayouts()
 {
     $layouts = array();
     $files = scandir(Yii::getPathOfAlias('application.views.layouts'));
     foreach ($files as $file) {
         if ($file[0] !== '.') {
             if (CFileHelper::getExtension($file) === 'php') {
                 $layoutName = substr($file, 0, strpos($file, '.'));
             } else {
                 $layoutName = $file;
             }
             $layoutName = '//layouts/' . $layoutName;
             $layouts[$layoutName] = $layoutName;
         }
     }
     return $layouts;
 }
开发者ID:JoaquinWaldrop,项目名称:globo_tech,代码行数:20,代码来源:AweCrudGenerator.php


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