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


PHP Yii类代码示例

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


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

示例1: getLogger

 /**
  * @return Logger
  */
 public function getLogger()
 {
     if (!isset($this->_logger)) {
         $this->_logger = \Yii::getLogger();
     }
     return $this->_logger;
 }
开发者ID:phtamas,项目名称:yii2-mailer,代码行数:10,代码来源:Component.php

示例2: init

 public function init()
 {
     parent::init();
     if (!$this->items) {
         throw new InvalidConfigException(\Yii::t('front', 'No required parameter given') . ' - items');
     }
 }
开发者ID:czechcamus,项目名称:dasport,代码行数:7,代码来源:ArrayOwlCarousel.php

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

示例4: run

 public function run($action, $to, $id)
 {
     $to = CActiveRecord::model($this->getController()->CQtreeGreedView['modelClassName'])->findByPk((int) $to);
     $moved = CActiveRecord::model($this->getController()->CQtreeGreedView['modelClassName'])->findByPk((int) $id);
     if (!is_null($to) && !is_null($moved)) {
         try {
             switch ($action) {
                 case 'child':
                     $moved->moveAsLast($to);
                     break;
                 case 'before':
                     if ($to->isRoot()) {
                         $moved->moveAsRoot();
                     } else {
                         $moved->moveBefore($to);
                     }
                     break;
                 case 'after':
                     if ($to->isRoot()) {
                         $moved->moveAsRoot();
                     } else {
                         $moved->moveAfter($to);
                     }
                     break;
             }
         } catch (Exception $e) {
             Yii::app()->user->setFlash('CQTeeGridView', $e->getMessage());
         }
     }
     $this->getController()->redirect(array($this->getController()->CQtreeGreedView['adminAction']));
 }
开发者ID:kostya1017,项目名称:our,代码行数:31,代码来源:MoveNode.php

示例5: run

 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').datepicker({$options});";
     if (isset($this->language)) {
         $this->registerScriptFile($this->i18nScriptFile);
         $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
     }
     $cs = Yii::app()->getClientScript();
     $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
开发者ID:BGCX261,项目名称:zii-svn-to-git,代码行数:32,代码来源:CJuiDatePicker.php

示例6: run

 /**
  * Renders the content of the widget.
  * @throws CException
  */
 public function run()
 {
     // Hide empty breadcrumbs.
     if (empty($this->links)) {
         return;
     }
     $links = array();
     if (!isset($this->homeLink)) {
         $content = CHtml::link(Yii::t('zii', 'Inicio'), Yii::app()->homeUrl);
         $links[] = $this->renderItem($content);
     } else {
         if ($this->homeLink !== false) {
             $links[] = $this->renderItem($this->homeLink);
         }
     }
     foreach ($this->links as $label => $url) {
         if (is_string($label) || is_array($url)) {
             $content = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url);
             $links[] = $this->renderItem($content);
         } else {
             $links[] = $this->renderItem($this->encodeLabel ? CHtml::encode($url) : $url, true);
         }
     }
     echo CHtml::tag('ul', $this->htmlOptions, implode('', $links));
 }
开发者ID:VrainSystem,项目名称:Proyecto_PROFIT,代码行数:29,代码来源:TbBreadcrumbs.php

示例7: getPackages

 /**
  * Magic getter. Returns this widget's packages. 
  */
 public function getPackages()
 {
     if (!isset($this->_packages)) {
         $this->_packages = array_merge(parent::getPackages(), array('TwoColumnSortableWidgetManagerJS' => array('baseUrl' => Yii::app()->request->baseUrl, 'js' => array('js/sortableWidgets/TwoColumnSortableWidgetManager.js'), 'depends' => array('SortableWidgetManagerJS'))));
     }
     return $this->_packages;
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:10,代码来源:TwoColumnSortableWidgetManager.php

示例8: request

 /**
  * @param string $url
  * @param string $method
  * @param string $body
  *
  * @return FhirResponse
  */
 public function request($url, $method = 'GET', $body = null)
 {
     $server_name = null;
     foreach ($this->servers as $name => $server) {
         if (substr($url, 0, strlen($server['base_url']))) {
             $server_name = $name;
             break;
         }
     }
     $this->applyServerConfig($server_name ? $this->servers[$server_name] : array());
     $this->http_client->setUri($url);
     $this->http_client->setMethod($method);
     if ($body) {
         $this->http_client->setRawData($body, 'application/xml+fhir; charset=utf-8');
     }
     $response = $this->http_client->request();
     $this->http_client->resetParameters();
     if ($body = $response->getBody()) {
         $use_errors = libxml_use_internal_errors(true);
         $value = Yii::app()->fhirMarshal->parseXml($body);
         $errors = libxml_get_errors();
         libxml_use_internal_errors($use_errors);
         if ($errors) {
             throw new Exception("Error parsing XML response from {$method} to {$url}: " . print_r($errors, true));
         }
     } else {
         $value = null;
     }
     return new FhirResponse($response->getStatus(), $value);
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:37,代码来源:FhirClient.php

示例9: init

 public function init()
 {
     // register class paths for extension captcha extended
     Yii::$classMap = array_merge(Yii::$classMap, array('CaptchaExtendedAction' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedAction.php', 'CaptchaExtendedValidator' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedValidator.php'));
     $this->search = new Search();
     $this->link = new Linksite();
 }
开发者ID:hntvu,项目名称:db_for_site,代码行数:7,代码来源:Controller.php

示例10: init

 public function init()
 {
     $this->name = \Yii::t('skeeks/shop/app', 'Delivery services');
     $this->modelShowAttribute = "name";
     $this->modelClassName = ShopDelivery::className();
     parent::init();
 }
开发者ID:skeeks-cms,项目名称:cms-shop,代码行数:7,代码来源:AdminDeliveryController.php

示例11: onBeforeGrid

 /**
  * Позволяет тонко сконфигурировать грид перед самой отрисовкой
  *
  * @param BeforeGridEvent $event
  */
 public function onBeforeGrid(BeforeGridEvent $event)
 {
     if (isset(Yii::app()->controller->buttons)) {
         foreach (Yii::app()->controller->buttons as $key => $buttonConfig) {
             if (isset($buttonConfig['code']) && $buttonConfig['code'] == 'create') {
                 // Модули - типы создаваемого экземпляра
                 $addButtonData = null;
                 $phpScripts = PhpScript::model()->findAllByAttributes(array('id_php_script_interface' => PhpScript::ID_PHP_SCRIPT_INTERFACE_MODULE));
                 if (count($phpScripts) > 0) {
                     $addButtonData = '<button class="btn navbar-btn btn-success dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>';
                     $addButtonData .= '<ul class="dropdown-menu">' . "\n";
                     foreach ($phpScripts as $phpScript) {
                         /**
                          * @var $phpScript PhpScript
                          */
                         $linkModule = ObjectUrlRule::createUrlFromCurrent(BackendModule::ROUTE_INSTANCE_LIST, array(ObjectUrlRule::PARAM_OBJECT_INSTANCE => -1, ObjectUrlRule::PARAM_SYSTEM_MODULE => $phpScript->id_php_script_type));
                         $addButtonData .= "<li><a href='" . $linkModule . "'>" . $phpScript->description . "</a></li>";
                     }
                     $addButtonData .= '</ul>' . "\n";
                 }
                 $buttonConfig['addButtonData'] = $addButtonData;
                 Yii::app()->controller->buttons[$key] = $buttonConfig;
                 break;
             }
         }
     }
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:32,代码来源:SiteModuleEventHandler.php

示例12: performAjaxValidation

 protected function performAjaxValidation($model)
 {
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'create-category-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
 }
开发者ID:Wiedzal,项目名称:narisuemvse,代码行数:7,代码来源:CategoriesController.php

示例13: afterSave

 public function afterSave()
 {
     parent::afterSave();
     $sql = "UPDATE p_nfy_subscription_categories " . "set category = 'role_{$this->role_name}.' " . "where category = 'role_{$this->oldName}.';";
     Yii::app()->db->createCommand($sql)->execute();
     return true;
 }
开发者ID:reggi49,项目名称:plansys,代码行数:7,代码来源:Role.php

示例14: checkAccess

 public function checkAccess()
 {
     // Save users last action on this space
     $membership = $this->space->getMembership(Yii::app()->user->id);
     if ($membership != null) {
         $membership->updateLastVisit();
     } else {
         // Super Admin can always enter
         if (!Yii::app()->user->isAdmin()) {
             // Space invisible?
             if ($this->space->visibility == Space::VISIBILITY_NONE) {
                 // Not Space Member
                 throw new CHttpException(404, Yii::t('SpaceModule.behaviors_SpaceControllerBehavior', 'Space is invisible!'));
             }
         }
     }
     // Delete all pending notifications for this space
     $notifications = Notification::model()->findAllByAttributes(array('space_id' => $this->space->id, 'user_id' => Yii::app()->user->id), 'seen != 1');
     foreach ($notifications as $n) {
         // Ignore Approval Notifications
         if ($n->class == "SpaceApprovalRequestNotification" || $n->class == "SpaceInviteNotification") {
             continue;
         }
         $n->seen = 1;
         $n->save();
     }
 }
开发者ID:alefernie,项目名称:intranet,代码行数:27,代码来源:SpaceControllerBehavior.php

示例15: loadModel

 public function loadModel($id)
 {
     if (($model = DictionaryGroup::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('DictionaryModule.dictionary', 'Requested page was not found'));
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:4seasons,代码行数:7,代码来源:DictionaryBackendController.php


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