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


PHP cmsModel::getCachedResult方法代码示例

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


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

示例1: run

 public function run()
 {
     $ctype = cmsModel::getCachedResult('current_ctype');
     $ctype_name = $this->getOption('ctype_name');
     $active_cat = false;
     if (!$ctype_name) {
         if (!$ctype) {
             return false;
         }
         $ctype_name = $ctype['name'];
     }
     if ($ctype && $ctype['name'] == $ctype_name) {
         if (strpos(cmsCore::getInstance()->uri, '.html') === false) {
             $current_ctype_category = cmsModel::getCachedResult('current_ctype_category');
             if (!empty($current_ctype_category['id'])) {
                 $active_cat = $current_ctype_category;
             }
         } else {
             $item = cmsModel::getCachedResult('current_ctype_item');
             if (!$item) {
                 return false;
             }
             if (!empty($item['category'])) {
                 $active_cat = $item['category'];
             }
         }
     }
     $model = cmsCore::getModel('content');
     $cats = $model->getCategoriesTree($ctype_name, $this->getOption('is_root'));
     if (!$cats) {
         return false;
     }
     if ($active_cat) {
         $path = array_filter($cats, function ($cat) use($active_cat) {
             return $cat['ns_left'] <= $active_cat['ns_left'] && $cat['ns_level'] <= $active_cat['ns_level'] && $cat['ns_right'] >= $active_cat['ns_right'] && $cat['ns_level'] > 0;
         });
     }
     return array('ctype_name' => $ctype_name, 'cats' => $cats, 'active_cat' => $active_cat, 'path' => !empty($path) ? $path : array());
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:39,代码来源:widget.php

示例2: run

 public function run()
 {
     $user = cmsUser::getInstance();
     $photo = cmsCore::getController('photos');
     // мы в профиле?
     $current_profile = cmsModel::getCachedResult('current_profile');
     if ($this->getOption('auto_user') && $current_profile) {
         $this->disableCache();
         $current_profile['user_id'] = $current_profile['id'];
         $this->photo_params = $current_profile;
         $photo->model->filterEqual('user_id', $current_profile['id']);
     }
     // мы на странице записи типа контента?
     $current_ctype_item = cmsModel::getCachedResult('current_ctype_item');
     if ($this->getOption('auto_ctype_item') && $current_ctype_item) {
         $this->disableCache();
         $photo->model->filterRelated('title', $current_ctype_item['title']);
     }
     // мы на странице группы?
     $current_group = cmsModel::getCachedResult('current_group');
     if ($this->getOption('auto_group') && $current_group) {
         $this->disableCache();
         $group_albums = cmsCore::getModel('content')->limit(false)->filterEqual('parent_id', $current_group['id'])->filterEqual('parent_type', 'group')->getContentItemsForSitemap('albums', array('id'));
         if ($group_albums) {
             foreach ($group_albums as $group_album) {
                 $albums_ids[] = $group_album['id'];
             }
             $photo->model->filterIn('album_id', $albums_ids);
         }
     }
     // альбом
     if ($this->getOption('album_id')) {
         $this->photo_params['id'] = $this->getOption('album_id');
         $this->photo_params['user_id'] = 0;
         $photo->model->filterEqual('album_id', $this->getOption('album_id'));
     }
     // типы альбомов
     switch ($this->getOption('target')) {
         case 1:
             // общие
             $photo->model->joinInner('con_albums', 'a', 'a.id = i.album_id');
             $photo->model->filterEqual('a.is_public', 1);
             break;
         case 2:
             // личные
             $photo->model->joinInner('con_albums', 'a', 'a.id = i.album_id');
             $photo->model->filterEqual('a.is_public', null);
             break;
     }
     // остальные опции
     if ($this->getOption('ordering')) {
         $photo->model->orderBy($this->getOption('ordering'), 'desc');
     }
     if (cmsUser::isAllowed('albums', 'view_all')) {
         $photo->model->disablePrivacyFilter();
     }
     if ($this->getOption('type')) {
         $photo->model->filterEqual('type', $this->getOption('type'));
     }
     if ($this->getOption('orientation')) {
         $photo->model->filterEqual('orientation', $this->getOption('orientation'));
     }
     if ($this->getOption('width')) {
         $photo->model->filterGtEqual('width', $this->getOption('width'));
     }
     if ($this->getOption('height')) {
         $photo->model->filterGtEqual('height', $this->getOption('height'));
     }
     $photo->model->limit($this->getOption('limit', 10));
     $photos = $photo->getPhotosList();
     if (!$photos) {
         return false;
     }
     $is_owner = cmsUser::isAllowed('albums', 'delete', 'all') || cmsUser::isAllowed('albums', 'delete', 'own') && ($user->id && $this->photo_params['user_id'] == $user->id);
     return array('row_height' => $photo->getRowHeight(), 'user' => $user, 'item' => $this->photo_params, 'photos' => $photos, 'is_owner' => $is_owner, 'preset_small' => $photo->options['preset_small']);
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:76,代码来源:widget.php


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