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


PHP YiiBase类代码示例

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


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

示例1: actionEdit

 /**
  * Provides functionality for a user to edit their profile
  */
 public function actionEdit()
 {
     $model = Users::model()->findByPk(Yii::app()->user->id);
     if (Cii::get($_POST, 'Users', NULL) !== NULL) {
         // Load the bcrypt hashing tools if the user is running a version of PHP < 5.5.x
         if (!function_exists('password_hash')) {
             require_once YiiBase::getPathOfAlias('ext.bcrypt.bcrypt') . '.php';
         }
         $cost = Cii::getBcryptCost();
         if ($_POST['Users']['password'] != '') {
             $_POST['Users']['password'] = password_hash(Users::model()->encryptHash($_POST['Users']['email'], $_POST['Users']['password'], Yii::app()->params['encryptionKey']), PASSWORD_BCRYPT, array('cost' => $cost));
         } else {
             unset($_POST['Users']['password']);
         }
         unset($_POST['Users']['status']);
         unset($_POST['Users']['user_role']);
         $model->attributes = Cii::get($_POST, 'Users', array());
         $model->about = Cii::get(Cii::get($_POST, 'Users', array()), 'about', NULL);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'Your profile has been updated!'));
             $this->redirect($this->createUrl('/profile/' . $model->id));
         } else {
             Yii::app()->user->setFlash('warning', Yii::t('ciims.controllers.Profile', 'There were errors saving your profile. Please correct them before trying to save again.'));
         }
     }
     $this->render('edit', array('model' => $model));
 }
开发者ID:fandikurnia,项目名称:CiiMS,代码行数:30,代码来源:ProfileController.php

示例2: actionGetCardsByCategory

 /**
  * Retrieves all cards in a particular category
  * @param  string $id The category id
  */
 public function actionGetCardsByCategory($id = NULL)
 {
     if ($id === NULL) {
         throw new CHttpException(400, Yii::t('Dashboard.main', 'Missing category id'));
     }
     $categories = Yii::app()->cache->get('cards_in_category');
     if ($categories === false) {
         $this->getCards();
         $categories = Yii::app()->cache->get('cards_in_category');
     }
     $cards = $categories[$id];
     $elements = $elementOptions = array();
     // TODO: Fix multiple select
     //$elementOptions['multiple'] = 'multiple';
     foreach ($cards as $k => $card) {
         $asset = Yii::app()->assetManager->publish(YiiBase::getPathOfAlias($card['path']), true, -1, YII_DEBUG);
         $elements[] = $k;
         $elementOptions['options'][] = array('value' => $k, 'data-img-src' => Yii::app()->getBaseUrl(true) . $asset . '/default.png');
     }
     $form = $this->beginWidget('ext.cii.widgets.CiiActiveForm', array('htmlOptions' => array('class' => 'pure-form pure-form-aligned item-selection-form')));
     echo CHtml::openTag('div', array('class' => 'pure-form-group', 'style' => 'padding-bottom: 20px'));
     echo CHtml::link(Yii::t('Dashboard.main', 'Add to Dashboard'), '#', array('id' => 'add-cards-button', 'class' => 'pure-button pure-button-link pure-button-primary pull-right pure-button-small', 'style' => 'position: absolute; top: 15px; right: 3%;'));
     echo CHtml::tag('legend', array(), $id);
     echo CHtml::dropDownList('card', NULL, $elements, $elementOptions);
     echo CHtml::closeTag('div');
     $this->endWidget();
 }
开发者ID:fandikurnia,项目名称:CiiMS,代码行数:31,代码来源:DefaultController.php

示例3: init

 /**
  * Registers Analytics.js and initializes the tracking code
  */
 public function init()
 {
     if (php_sapi_name() === 'cli') {
         return;
     }
     // Set the alias path
     if (Yii::getPathOfAlias('analytics') === false) {
         Yii::setPathOfAlias('analytics', realpath(dirname(__FILE__) . '/..'));
     }
     parent::init();
     // Don't load up the analytics.js if we don't have any data
     $providers = $this->getProviders();
     if (empty($providers)) {
         return;
     }
     // Conver options into json
     $json = CJSON::encode($this->getProviders());
     // Load up the asset manager
     $asset = Yii::app()->assetManager->publish(YiiBase::getPathOfAlias('ext.EAnalytics.assets.js'), true, -1, YII_DEBUG);
     $cs = Yii::app()->getClientScript();
     // Register the appropriate script file
     $cs->registerScriptFile($asset . (YII_DEBUG ? '/analytics.js' : '/analytics.min.js'));
     // Initialize
     $cs->registerScript('analytics.js', "analytics.initialize({$json});");
     if ($this->lowerBounceRate) {
         $cs->registerScript('analytics.js-bounce-rate-15', 'setTimeout(function() { analytics.track("_trackEvent", "15 Seconds"); }, 15000 );');
         $cs->registerScript('analytics.js-bounce-rate-30', 'setTimeout(function() { analytics.track("_trackEvent", "30 Seconds"); }, 30000 );');
         $cs->registerScript('analytics.js-bounce-rate-60', 'setTimeout(function() { analytics.track("_trackEvent", "60 Seconds"); }, 60000 );');
     }
 }
开发者ID:fandikurnia,项目名称:CiiMS,代码行数:33,代码来源:EAnalytics.php

示例4: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'update' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     // set attributes from get
     if (isset($_GET['SaleGroup'])) {
         $model->attributes = $_GET['SaleGroup'];
     }
     if (isset($_POST['SaleGroup'])) {
         $model->attributes = $_POST['SaleGroup'];
         $model->imagefile = CUploadedFile::getInstance($model, 'imagefile');
         if (isset($model->imagefile)) {
             $ext = pathinfo($model->imagefile);
             $model->image = $ext['extension'];
         }
         if ($model->save()) {
             if (isset($model->imagefile) && ($modelSettings = SiteModuleSettings::model()->find('site_module_id = 9'))) {
                 $filename = $model->id . '.' . $model->image;
                 $filepatch = '/../uploads/filestorage/sale/rubrics/';
                 $model->imagefile->saveAs(YiiBase::getPathOfAlias('webroot') . $filepatch . $filename);
                 //Обработка изображения
                 SiteModuleSettings::model()->chgImgModel($modelSettings, 'GD', 1, $model->id);
             }
             $url = isset($_POST['go_to_list']) ? $this->listUrl('index') : $this->itemUrl('update', $model->id);
             $this->redirect($url);
         }
     }
     $this->render('update', array('model' => $model));
 }
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:35,代码来源:SalegroupController.php

示例5: GetSize

 public static function GetSize($intImageTypeId)
 {
     list($intDefWidth, $intDefHeight) = ImagesType::$SizeArray[$intImageTypeId];
     $strCfg = ImagesType::GetConfigKey($intImageTypeId);
     $strCfgWidth = $strCfg . '_WIDTH';
     $strCfgHeight = $strCfg . '_HEIGHT';
     $intWidth = Yii::app()->theme->info->{$strCfgWidth};
     $intHeight = Yii::app()->theme->info->{$strCfgHeight};
     //If our theme doesn't have the config there, see if we have a 3.0 style config.xml
     if (empty($intWidth) || empty($intHeight)) {
         $fnOptions = YiiBase::getPathOfAlias('webroot') . "/themes/" . Yii::app()->theme->name . "/config.xml";
         if (file_exists($fnOptions)) {
             $strXml = file_get_contents($fnOptions);
             // Parse xml for response values
             $oXML = new SimpleXMLElement($strXml);
             if (isset($oXML->defaults->configuration)) {
                 foreach ($oXML->defaults->configuration as $item) {
                     if ((string) $item->key_name == $strCfgWidth) {
                         $intWidth = (string) $item->key_value;
                     }
                     if ((string) $item->key_name == $strCfgHeight) {
                         $intHeight = (string) $item->key_value;
                     }
                 }
             }
         }
     }
     //if all else STILL fails, go old school and get them from the config (And even more so, use defaults)
     if (empty($intWidth) || empty($intHeight)) {
         $intWidth = _xls_get_conf($strCfgWidth, $intDefWidth);
         $intHeight = _xls_get_conf($strCfgHeight, $intDefHeight);
     }
     return array($intWidth, $intHeight);
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:34,代码来源:ImagesType.php

示例6: mail

 /**
  * @static send a email
  * @param array $data
  *      array('subject'=>?, 'params'=>array(), 'view'=>?, 'to'=>?, 'from'=>?)
  * @param bool $requireView if true, it will only send email if view is existed
  */
 public static function mail($data, $requireView = false)
 {
     //        self::_setTestEmail($data, 'quocbao1087@gmail.com');
     $message = new YiiMailMessage($data['subject']);
     if (isset($data['view'])) {
         if ($requireView) {
             $path = YiiBase::getPathOfAlias(Yii::app()->mail->viewPath) . '/' . $data['view'] . '.php';
             if (!file_exists($path)) {
                 return;
             }
         }
         $message->view = $data['view'];
     } elseif ($requireView) {
         return;
     }
     $message->setBody($data['params'], 'text/html');
     if (is_array($data['to'])) {
         foreach ($data['to'] as $t) {
             $message->addTo($t);
         }
     } else {
         $message->addTo($data['to']);
     }
     $message->from = $data['from'];
     $message->setFrom(array($data['from'] => Yii::app()->setting->getItem('title_all_mail')));
     // test email using local mail server
     if ($_SERVER['HTTP_HOST'] == 'localhost') {
         Yii::app()->mail->transportType = 'smtp';
         Yii::app()->mail->transportOptions = array('host' => 'localhost', 'username' => null, 'password' => null);
     }
     return Yii::app()->mail->send($message);
 }
开发者ID:jasonhai,项目名称:onehome,代码行数:38,代码来源:CmsEmail.php

示例7: add

 /**
  * Usergroups::delete()
  * Function responsible to delete a user group.
  * @return void
  */
 public function add()
 {
     $clang = Yii::app()->lang;
     $aData = array();
     $aViewUrls = array();
     if (Permission::model()->hasGlobalPermission('CMS', 'create')) {
         //echo $test = getBasePath();
         $controllername = $this->getId();
         $newPath = "application.views.";
         $newPath = YiiBase::getPathOfAlias($newPath);
         //$filepath = $newPath . '\admin\cms\template\default.tpl.php';
         $filepath = $newPath . '/admin/cms/template/default.tpl.php';
         $page_content = $_POST['template_editor'];
         //            $page_content = html_entity_decode($page_content, ENT_QUOTES, "UTF-8");
         //            $page_content = fixCKeditorText($page_content);
         if (file_put_contents($filepath, $page_content, LOCK_EX)) {
             Yii::app()->setFlashMessage($clang->gT("Template updated successfully"));
             $this->getController()->redirect(array("admin/template/index"));
         }
     } else {
         Yii::app()->setFlashMessage($clang->gT("You do not have sufficient rights to access page."), 'error');
         $this->getController()->redirect(array("admin/index"));
     }
     $this->_renderWrappedTemplate('cms/cms', $aViewUrls, $aData);
 }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:30,代码来源:templateaction.php

示例8: thumb

 */
class ImageHelper
{
    /**
     * Directory to store thumbnails
     * @var string 
     */
    const THUMB_DIR = '.tmb';
    /**
     * Create a thumbnail of an image and returns relative path in webroot
     * the options array is an associative array which can take the values
     * quality (jpg quality) and method (the method for resizing)
     *
     * @param int $width
     * @param int $height
     * @param string $img
     * @param array $options
     * @return string $path
     */
    public static function thumb($width, $height, $img, $options = null)
    {
        if (!file_exists($img)) {
            $img = str_replace('\\', '/', YiiBase::getPathOfAlias('webroot') . $img);
            if (!file_exists($img)) {
                throw new ExceptionClass('Image not found');
            }
        }
        // Jpeg quality
        $quality = 80;
        // Method for resizing
        $method = 'adaptiveResize';
        if ($options) {
            extract($options, EXTR_IF_EXISTS);
        }
开发者ID:jackycgq,项目名称:advanced,代码行数:34,代码来源:ImageHelper.php

示例9: actionIndex

 public function actionIndex()
 {
     $users_dp = new CActiveDataProvider(User::model()->cache(60 * 15, null, 2), array("criteria" => array(), "pagination" => array("pageSize" => 50), "sort" => array("attributes" => array("login", "rate_u", "rate_t", "n_trs"), "defaultOrder" => array("rate_t" => true))));
     $this->side_view = "list_side";
     $global_stats = unserialize(file_get_contents(YiiBase::getPathOfAlias("application.runtime") . "/global_stat.ser"));
     $this->side_params = $global_stats;
     $this->render("list", array("users_dp" => $users_dp));
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:8,代码来源:UsersController.php

示例10: tempPath

 public static function tempPath()
 {
     static $tempPath;
     if (empty($tempPath)) {
         $tempPath = YiiBase::getPathOfAlias('webroot.temp');
     }
     return $tempPath;
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:8,代码来源:Amo.php

示例11: post_image

 public function post_image($id, $image, $width = '150', $class = 'post_img')
 {
     if (isset($image) && file_exists(YiiBase::getPathOfAlias('webroot') . '/images/' . $image)) {
         return CHtml::image(Yii::app()->getBaseUrl(true) . '/images/' . $image);
     } else {
         return CHtml::image(Yii::app()->getBaseUrl(true) . '/images/noimage.png', 'no image', array('width' => $width, 'class' => $class));
     }
 }
开发者ID:holyshved,项目名称:guestbook,代码行数:8,代码来源:AvatarsController.php

示例12: menuWidgets

 public function menuWidgets()
 {
     if (file_exists(YiiBase::getPathOfAlias("application.widgets.AdminmenuWidget") . '.php')) {
         $this->widget("application.widgets.AdminmenuWidget");
     }
     foreach (Yii::app()->modulesMenus as $path) {
         $this->widget($path);
     }
 }
开发者ID:kvvn,项目名称:homeforpets,代码行数:9,代码来源:BackEndController.php

示例13: init

 public function init()
 {
     Yii::app()->clientScript->coreScriptUrl = Yii::app()->baseUrl . "/js";
     //设置css路径
     YiiBase::setPathOfAlias('webcss', YiiBase::getPathOfAlias('webroot') . '/css');
     $this->layout = 'application.views.layouts.adminRight';
     parent::init();
     $_GET['r'] = isset($_GET['r']) ? $_GET['r'] : Yii::app()->homeUrl;
 }
开发者ID:dalinhuang,项目名称:ice-sanky,代码行数:9,代码来源:FController.php

示例14: __construct

 function __construct()
 {
     foreach (Yii::app()->modules as $module => $value) {
         $path = 'application.modules.' . $module . '.components.' . ucwords($module) . 'AdminmenuWidget';
         if (file_exists(YiiBase::getPathOfAlias($path) . '.php')) {
             $this->modulesMenus[$module] = $path;
         }
     }
 }
开发者ID:rash012,项目名称:cms,代码行数:9,代码来源:ModulesInformationBehavior.php

示例15: __construct

 /**
  * Initializes initializer.
  */
 public function __construct($frameworkScript, $configScript, $webApplicationFactory)
 {
     defined('YII_DEBUG') or define('YII_DEBUG', true);
     require_once $frameworkScript;
     // tells Yii to not just include files, but to let other
     // autoloaders or the include path try
     \YiiBase::$enableIncludePath = false;
     // create the application and remember it
     $this->yii = $webApplicationFactory::createWebApplication($configScript);
 }
开发者ID:cybercog,项目名称:YiiExtension,代码行数:13,代码来源:YiiAwareInitializer.php


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