本文整理汇总了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());
}
示例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']);
}