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


PHP Yii::getPathOfAlias方法代码示例

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


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

示例1: getUrlUploadMultiImages

 public static function getUrlUploadMultiImages($obj, $user_id)
 {
     $url_arr = array();
     $min_size = 1024 * 1000 * 700;
     $max_size = 1024 * 1000 * 1000 * 3.5;
     foreach ($obj["tmp_name"] as $key => $tmp_name) {
         $ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
         $name = StringHelper::filterString($obj['name'][$key]);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
         $pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $name;
         if (!file_exists($storeFolder)) {
             mkdir($storeFolder, 0777, true);
         }
         $tempFile = $obj['tmp_name'][$key];
         $targetFile = $storeFolder . time() . $name;
         $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
         $size = $obj['name']['size'];
         if (in_array($ext, $ext_arr)) {
             if ($size >= $min_size && $size <= $max_size) {
                 if (move_uploaded_file($tempFile, $targetFile)) {
                     array_push($url_arr, $pathUrl);
                 } else {
                     return NULL;
                 }
             } else {
                 return NULL;
             }
         } else {
             return NULL;
         }
     }
     return $url_arr;
 }
开发者ID:huynt57,项目名称:image_chooser,代码行数:33,代码来源:UploadHelper.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new KqxsNam();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $model->image = CUploadedFile::getInstance($model, 'image');
     if (isset($_POST['KqxsNam'])) {
         $model->attributes = $_POST['KqxsNam'];
         $kqxs = KqxsBac::model()->find("date=:date and provice=:provice", array(':date' => $model->date, ":provice" => $model->provice));
         if (!$kqxs && $model->save()) {
             $folder = 'upload/' . date('Ymd');
             if (!file_exists($folder)) {
                 mkdir($folder);
             }
             if (is_object($model->image)) {
                 $model->image->saveAs(Yii::getPathOfAlias('webroot') . '/' . $folder . '/' . $model->image);
             }
             $model->image = $folder . '/' . $model->image;
             $model->update(array('image'));
             $this->redirect(array('view', 'id' => $model->id));
         } else {
             $model->addError('date', 'Kết quả này đã có vui lòng chỉnh lại thông tin');
         }
     }
     $model->date = date("d-m-Y", time());
     $this->render('create', array('model' => $model));
 }
开发者ID:rubipikachu,项目名称:xoso-lechung,代码行数:31,代码来源:KqxsnamController.php

示例3: init

 function init()
 {
     parent::init();
     if (trim($this->id) == '' || trim($this->name) == '') {
         throw new CException('必须设置容器id和name值');
     }
     //发布资源
     $this->_assetUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.baiduUeditor.resource'));
     $clientScript = Yii::app()->clientScript;
     //注册常量
     $jsConstant = 'window.UEDITOR_HOME_URL = "' . $this->_assetUrl . '/"';
     $clientScript->registerScript('ueditor_constant', $jsConstant, CClientScript::POS_BEGIN);
     //注册js文件
     foreach ($this->jsFiles as $jsFile) {
         $clientScript->registerScriptFile($this->_assetUrl . $jsFile, CClientScript::POS_END);
     }
     //注册css文件
     foreach ($this->cssFiles as $cssFile) {
         $clientScript->registerCssFile($this->_assetUrl . $cssFile);
     }
     //判断是否存在module
     if ($this->owner->module != null) {
         $moduleId = $this->owner->module->id;
         $this->serverUrl = Yii::app()->createUrl($moduleId . '/ueditor');
     } else {
         $this->serverUrl = Yii::app()->createUrl('ueditor');
     }
     //config
     $this->config['serverUrl'] = $this->serverUrl;
     $this->render('ueditor');
 }
开发者ID:zt123,项目名称:Base-System,代码行数:31,代码来源:UeditorWidget.php

示例4: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Photo();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Photo'])) {
         $model->attributes = $_POST['Photo'];
         if (isset($_FILES['images']['name'][0]) && $_FILES['images']['name'][0] !== '') {
             $model->name = 'new';
         }
         if ($model->validate()) {
             $images = CUploadedFile::getInstancesByName('images');
             foreach ($images as $image) {
                 $imageModel = new Photo();
                 $name = uniqid() . $image->name;
                 $image->saveAs(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . $name);
                 copy(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . $name, Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR . $name);
                 $thumb = Yii::app()->image->load(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR . $name);
                 $thumb->resize(300, 300);
                 $thumb->save();
                 $imageModel->name = $name;
                 $imageModel->category_id = $_POST['Photo']['category_id'];
                 $imageModel->save();
             }
             Yii::app()->user->setFlash('success', Yii::t('main', 'Данные успешно сохранены!'));
             $this->refresh();
         } else {
             Yii::app()->user->setFlash('error', Yii::t('main', 'Ошибка!'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:Vladimirtishenko,项目名称:val.ua,代码行数:36,代码来源:PhotoController.php

示例5: getAssetsUrl

 /**
  * @return string base URL that contains all published asset files of this module.
  */
 public function getAssetsUrl()
 {
     if ($this->_assetsUrl == null) {
         $this->_assetsUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias($this->id . '.assets'), false, -1, true);
     }
     return $this->_assetsUrl;
 }
开发者ID:ever4vr,项目名称:maestro,代码行数:10,代码来源:RbacuiModule.php

示例6: init

 public function init()
 {
     if (isset($_GET[$this->grid_mode_var])) {
         $this->grid_mode = $_GET[$this->grid_mode_var];
     }
     if (isset($_GET['exportType'])) {
         $this->exportType = $_GET['exportType'];
     }
     $lib = Yii::getPathOfAlias($this->libPath) . '.php';
     if ($this->grid_mode == 'export' and !file_exists($lib)) {
         $this->grid_mode = 'grid';
         Yii::log("PHP Excel lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EExcelview');
     }
     if ($this->grid_mode == 'export') {
         $this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
         $this->initColumns();
         //parent::init();
         //Autoload fix
         spl_autoload_unregister(array('YiiBase', 'autoload'));
         Yii::import($this->libPath, true);
         $this->objPHPExcel = new PHPExcel();
         spl_autoload_register(array('YiiBase', 'autoload'));
         // Creating a workbook
         $this->objPHPExcel->getProperties()->setCreator($this->creator);
         $this->objPHPExcel->getProperties()->setTitle($this->title);
         $this->objPHPExcel->getProperties()->setSubject($this->subject);
         $this->objPHPExcel->getProperties()->setDescription($this->description);
         $this->objPHPExcel->getProperties()->setCategory($this->category);
     } else {
         parent::init();
     }
 }
开发者ID:MGGROUP,项目名称:SAMDEPURACION,代码行数:32,代码来源:EExcelView.php

示例7: actionIndex

 public function actionIndex($is_product = 1)
 {
     if (!empty($_POST)) {
         $is_new_product = $is_product;
         $images = CUploadedFile::getInstancesByName('images');
         if (isset($images) && count($images) > 0) {
             // go through each uploaded image
             foreach ($images as $image => $pic) {
                 $model = new Slides();
                 $imageType = explode('.', $pic->name);
                 $imageType = $imageType[count($imageType) - 1];
                 $imageName = md5(uniqid()) . '.' . $imageType;
                 if ($pic->saveAs(Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName)) {
                     $model->image = $imageName;
                     $model->name = $pic->name;
                     $model->is_product = $is_new_product;
                     $model->save();
                     Yii::app()->user->setFlash('success', translate('Thêm thành công.'));
                 }
                 // handle the errors here, if you want
             }
         }
         PIUrl::createUrl('/admin/slides/index', array('is_product' => $is_product));
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("is_product= {$is_product}");
     $criteria->order = 'id DESC';
     $count = Slides::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = 6;
     $pages->applyLimit($criteria);
     $model = Slides::model()->findAll($criteria);
     $this->render('index', compact('model', 'pages'));
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:35,代码来源:SlidesController.php

示例8: init

 public function init()
 {
     $this->setImport(array($this->id . '.models.*', $this->id . '.components.*'));
     $ass = Yii::getPathOfAlias('objectExport.assets');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->assetManager->publish($ass . "/script.js"));
     Yii::app()->clientScript->registerCssFile(Yii::app()->assetManager->publish($ass . "/style.css"));
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:7,代码来源:ObjectExportModule.php

示例9: init

 public function init()
 {
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $id = $this->htmlOptions['id'] = $this->getId();
     }
     if ($this->url !== null) {
         $this->url = CHtml::normalizeUrl($this->url);
     }
     $cs = Yii::app()->getClientScript();
     //$cs->registerCoreScript('treeview');
     $baseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.yii-jqTree.source'));
     $cs->registerScriptFile($baseUrl . '/tree.jquery.js');
     $options = $this->getClientOptions();
     $options = $options === array() ? '{}' : CJavaScript::encode($options);
     $cs->registerScript('Yii.JQTree#0' . $id, "if (jQuery.jqTree == undefined) {jQuery.jqTree = new Array;}");
     $cs->registerScript('Yii.JQTree#' . $id, "jQuery.jqTree[\"{$id}\"] = jQuery(\"#{$id}\").tree({$options});");
     if ($this->cssFile === null) {
         $cs->registerCssFile($baseUrl . '/jqtree.css');
     } else {
         if ($this->cssFile !== false) {
             $cs->registerCssFile($this->cssFile);
         }
     }
     echo CHtml::tag('ul', $this->htmlOptions, false, false) . "\n";
 }
开发者ID:asdmundt,项目名称:templateYiiApp,代码行数:27,代码来源:JQTree.php

示例10: afterSave

 public function afterSave($event)
 {
     if ($this->owner->isNewRecord && ($tmpId = $this->getTmpId())) {
         if ($this->owner instanceof DaInstance) {
             $finder = $this->owner;
         } else {
             $finder = $this->owner->model();
         }
         if ($this->resetScope) {
             $finder->resetScope();
         }
         $model = $finder->findByIdInstance($this->owner->getIdInstance());
         foreach ($this->getFiles() as $files) {
             foreach ($files as $file) {
                 $modelDir = $model->getDir(true);
                 $file->file_path = $modelDir . $file->getName();
                 $file->id_instance = $model->getIdInstance();
                 $file->id_tmp = null;
                 $file->save(false);
             }
         }
         if (count($this->getFiles()) > 0) {
             //переносим файлы
             $mpDir = Yii::getPathOfAlias('temp') . '/' . $this->getTmpId();
             HFile::copyDirectory($mpDir, $model->getDir(true, true));
             HFile::removeDirectoryRecursive($mpDir, true);
         }
     }
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:29,代码来源:FileUploadableBehavior.php

示例11: getAssetsUrl

 public function getAssetsUrl()
 {
     if ($this->_assetsUrl === null) {
         $this->_assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.components.blocs.document.assets'), false, -1, YII_DEBUG);
     }
     return $this->_assetsUrl;
 }
开发者ID:kostya1017,项目名称:our,代码行数:7,代码来源:DocumentBloc.php

示例12: getAssetsUrl

 /**
  * @return string the base URL that contains all published asset files of gii.
  */
 public function getAssetsUrl()
 {
     if ($this->_assetsUrl === null) {
         $this->_assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('cache.assets'));
     }
     return $this->_assetsUrl;
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:10,代码来源:CacheModule.php

示例13: beforeValidate

 protected function beforeValidate()
 {
     if (!parent::beforeValidate()) {
         return false;
     }
     if ($this->scenario == "fromAdmin") {
         if ($this->teacher_path_file == NULL) {
             $this->addError("teacher_avatar", "teacher_avatar is required");
             return false;
         }
         if (!$this->teacher_path_file->checkExt(array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG'))) {
             return FALSE;
         }
         $ext = $this->teacher_path_file->getExtension();
         $name = StringHelper::unicode_str_filter($this->teacher_path_file->name);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/teacher/';
         $targetPath = $storeFolder;
         //4
         $teacher_ava = Yii::app()->createAbsoluteUrl('uploads') . '/teacher/' . $name;
         if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "pjepg" || $ext == "png" || $ext == "x-png" || $ext == "GIF" || $ext == "JPG" || $ext == "JPEG" || $ext == "PJEPG" || $ext == "PNG" || $ext == "X_PNG") {
             $this->teacher_path_file->save($targetPath, $name);
             $this->teacher_avatar = $teacher_ava;
         }
     }
     return TRUE;
 }
开发者ID:huynt57,项目名称:bluebee-uet.com,代码行数:26,代码来源:Teacher.php

示例14: actionImport

 /**
  * Import products
  */
 public function actionImport()
 {
     $importer = new CsvImporter();
     $importer->deleteDownloadedImages = Yii::app()->request->getPost('remove_images');
     if (Yii::app()->request->isPostRequest && isset($_FILES['file'])) {
         $importer->file = $_FILES['file']['tmp_name'];
         if ($importer->validate() && !$importer->hasErrors()) {
             // Create db backup
             if (isset($_POST['create_dump']) && $_POST['create_dump']) {
                 Yii::import('application.components.SDatabaseDumper');
                 $dumper = new SDatabaseDumper();
                 $file = Yii::getPathOfAlias('webroot.protected.backups') . DIRECTORY_SEPARATOR . 'dump_' . date('Y-m-d_H_i_s') . '.sql';
                 if (is_writable(Yii::getPathOfAlias('webroot.protected.backups'))) {
                     if (function_exists('gzencode')) {
                         file_put_contents($file . '.gz', gzencode($dumper->getDump()));
                     } else {
                         file_put_contents($file, $dumper->getDump());
                     }
                 } else {
                     throw new CHttpException(503, Yii::t('CsvModule.admin', 'Ошибка. Директория для бэкапов недоступна для записи.'));
                 }
             }
             $importer->import();
         }
     }
     $this->render('import', array('importer' => $importer));
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:30,代码来源:DefaultController.php

示例15: getViewPath

 public function getViewPath($checkTheme = false)
 {
     if ($checkTheme && ($theme = Yii::app()->getTheme()) !== null) {
         return $theme->getViewPath() . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'similarads';
     }
     return Yii::getPathOfAlias('application.modules.similarads.views');
 }
开发者ID:alexjkitty,项目名称:estate,代码行数:7,代码来源:SimilarAdsWidget.php


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