• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Yii类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: actionUpdate

 public function actionUpdate($fid = 0, $gid = 0, $sort = '')
 {
     $timer = new CountTimer();
     $cacheToken = 'cache-update';
     Yii::beginProfile($cacheToken);
     ob_start();
     // 生成版块列表缓存
     $this->forward('forum/forumlist', false);
     // 生成帖子列表缓存
     $sortArr = array('', 'new', 'marrow', 'top');
     $fids = $this->_getFids($fid);
     $uids = $this->_getUidsByGid($gid);
     foreach ($sortArr as $sort) {
         foreach ($fids as $fid) {
             foreach ($uids as $uid) {
                 $_GET = array_merge($_GET, array('hacker_uid' => $uid, 'boardId' => $fid, 'page' => 1, 'pageSize' => 10, 'sortby' => $sort));
                 $res = $this->forward('forum/topiclist', false);
                 ob_clean();
             }
         }
     }
     ob_end_clean();
     var_dump($timer->stop());
     Yii::endProfile($cacheToken);
 }
开发者ID:frogoscar,项目名称:mobcent-discuz,代码行数:25,代码来源:CacheController.php


示例17: actionRegister

 /**
  * Creates account for new users
  */
 public function actionRegister()
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->request->redirect('/');
     }
     $user = new User('register');
     $profile = new UserProfile();
     if (Yii::app()->request->isPostRequest && isset($_POST['User'], $_POST['UserProfile'])) {
         $user->attributes = $_POST['User'];
         $profile->attributes = $_POST['UserProfile'];
         $valid = $user->validate();
         $valid = $profile->validate() && $valid;
         if ($valid) {
             $user->save();
             $profile->save();
             $profile->setUser($user);
             // Add user to authenticated group
             Yii::app()->authManager->assign('Authenticated', $user->id);
             $this->addFlashMessage(Yii::t('UsersModule.core', 'Спасибо за регистрацию на нашем сайте.'));
             // Authenticate user
             $identity = new UserIdentity($user->username, $_POST['User']['password']);
             if ($identity->authenticate()) {
                 Yii::app()->user->login($identity, Yii::app()->user->rememberTime);
                 Yii::app()->request->redirect($this->createUrl('/users/profile/index'));
             }
         }
     }
     $this->render('register', array('user' => $user, 'profile' => $profile));
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:32,代码来源:RegisterController.php


示例18: error

 /**
  *  $controller::$configuration['statusKey'] = 'status' by default
  * $controller::$configuration['statusError'] = 'error' by default
  * $controller::$configuration['resourceKey'] = 'resource' by default
  * $controller::$configuration['errorDescriptionKey'] = 'errorDescription' by default
  * @param string $errorCode is a key of Response::$errorDictionary array.
  * @param array $errorresource null by default. Can be added to specify error body (resource) of response
  * @return array  prepeared to be JSON encoded 
  */
 public static function error($errorCode, $errorresource = null)
 {
     $controller = Yii::app()->controller;
     $errorDescription = self::errorDescription($errorCode);
     self::$response = array($controller::$configuration['statusKey'] => $controller::$configuration['statusError'], $controller::$configuration['statusError'] => array($controller::$configuration['errorCodeKey'] => $errorCode, $controller::$configuration['errorDescriptionKey'] => $errorDescription, $controller::$configuration['resourceKey'] => $errorresource));
     return self::get();
 }
开发者ID:rosko,项目名称:backvendor,代码行数:16,代码来源:Response.php


示例19: actionView

 public function actionView()
 {
     $radioId = Yii::app()->request->getParam("id", 0);
     $radioName = WapRadioModel::model()->findByPk($radioId)->name;
     $albumId = WapRadioModel::model()->getAlbumByRadio($radioId, "c2.id");
     $radioAvatar = RadioModel::model()->getAvatarUrl($radioId, 's1');
     $album = WapAlbumModel::model()->published()->findByPk($albumId);
     if (!$album) {
         $this->forward("/site/error", true);
     }
     $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId);
     $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId);
     $phone = yii::app()->user->getState('msisdn');
     $errorCode = 'success';
     $errorDescription = '';
     $registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT');
     ///meta tag
     $AlbumDetail = AlbumModel::model()->findByPk($albumId);
     $artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id;
     $ArtistInfo = ArtistModel::model()->findByPk($artistId);
     $this->itemName = $AlbumDetail->name;
     $this->artist = $ArtistInfo->name;
     $this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1');
     $this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name));
     $this->description = strip_tags($AlbumDetail->description);
     //get other radio
     $parent_id = Yii::app()->params['horoscope']['parent_id'];
     $radioListOther = WapRadioModel::model()->getHoroscopes($parent_id);
     $this->render('detail', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'registerText' => $registerText, 'radioListOther' => $radioListOther, 'radioAvatar' => $radioAvatar));
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:30,代码来源:HoroscopesController.php


示例20: redirect

 public function redirect($url, $terminate = true, $statusCode = 302)
 {
     $this->setHeader('Location', $url);
     if ($terminate) {
         Yii::app()->end(0, false);
     }
 }
开发者ID:bbwebconsult,项目名称:YiiBridge,代码行数:7,代码来源:CodeceptionHttpRequest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP YiiBase类代码示例发布时间:2022-05-23
下一篇:
PHP Yaf_Registry类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap