本文整理汇总了PHP中cmsUser::getUPS方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsUser::getUPS方法的具体用法?PHP cmsUser::getUPS怎么用?PHP cmsUser::getUPS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsUser
的用法示例。
在下文中一共展示了cmsUser::getUPS方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($ctype_id)
{
$content_model = cmsCore::getModel('content');
$ctype = $content_model->getContentType($ctype_id);
$datasets = $content_model->getContentDatasets($ctype_id);
$fields = $content_model->getContentFields($ctype['name']);
if ($ctype['is_rating']) {
$fields[] = array('title' => LANG_RATING, 'name' => 'rating', 'handler' => new fieldNumber('rating'));
}
if ($ctype['is_comments']) {
$fields[] = array('title' => LANG_COMMENTS, 'name' => 'comments', 'handler' => new fieldNumber('comments'));
}
if (!empty($ctype['options']['hits_on'])) {
$fields[] = array('title' => LANG_HITS, 'name' => 'hits_count', 'handler' => new fieldNumber('hits_count'));
}
$diff_order = cmsUser::getUPS('admin.grid_filter.content.diff_order');
return cmsTemplate::getInstance()->render('content_filter', array('ctype' => $ctype, 'datasets' => $datasets, 'fields' => $fields, 'diff_order' => $diff_order));
}
示例2: run
public function run($do = false)
{
// если нужно, передаем управление другому экшену
if ($do) {
$this->runAction('content_' . $do, array_slice($this->params, 1));
return;
}
$content_model = cmsCore::getModel('content');
$ctypes = $content_model->getContentTypes();
$tree_path = cmsUser::getCookie('content_tree_path');
if ($tree_path && ($tree_path = explode('/', $tree_path)) && !empty($tree_path[1]) && ($ctype_id = (int) $tree_path[1])) {
$ctype = $content_model->getContentType($ctype_id);
}
if (!empty($ctype)) {
$grid = $this->loadDataGrid('content_items', false, 'admin.grid_filter.content.' . $ctype['name']);
} else {
$grid = $this->loadDataGrid('content_items');
}
$diff_order = cmsUser::getUPS('admin.grid_filter.content.diff_order');
return cmsTemplate::getInstance()->render('content', array('ctypes' => $ctypes, 'grid' => $grid, 'diff_order' => $diff_order));
}
示例3: loadDataGrid
/**
* Загружает и возвращает описание структуры таблицы
* @param string $grid_name
*/
public function loadDataGrid($grid_name, $params = false, $ups_key = '')
{
$default_options = array('order_by' => 'id', 'order_to' => 'asc', 'show_id' => true, 'is_auto_init' => true, 'is_sortable' => true, 'is_filter' => true, 'is_actions' => true, 'is_pagination' => true, 'is_toolbar' => true, 'is_draggable' => false, 'is_selectable' => false, 'load_columns' => false);
$grid_file = $this->root_path . 'grids/grid_' . $grid_name . '.php';
if (!is_readable($grid_file)) {
return false;
}
include $grid_file;
$args = array($this);
if ($params) {
if (is_array($params)) {
$args = array($this) + $params;
} else {
$args[] = $params;
}
}
$grid = call_user_func_array('grid_' . $grid_name, $args);
if (!isset($grid['options'])) {
$grid['options'] = $default_options;
} else {
$grid['options'] = array_merge($default_options, $grid['options']);
}
$grid = cmsEventsManager::hook('grid_' . $this->name . '_' . $grid_name, $grid);
if ($this->request->isAjax() && $this->request->has('heads')) {
$heads = $this->request->get('heads', array());
natsort($heads);
$grid_heads = array_keys($grid['columns']);
if ($grid['actions']) {
$grid_heads[] = 'dg_actions';
}
natsort($grid_heads);
if ($heads !== $grid_heads) {
$grid['options']['load_columns'] = true;
}
}
if ($ups_key) {
$filter_str = cmsUser::getUPS($ups_key);
if ($filter_str) {
parse_str($filter_str, $filter);
$grid['filter'] = $filter;
}
}
return $grid;
}
示例4: run
public function run()
{
if (cmsUser::isLogged()) {
$this->redirectToHome();
}
$email = $this->request->get('login_email', '');
$password = $this->request->get('login_password', '');
$remember = (bool) $this->request->get('remember');
$back_url = $this->request->get('back', '');
$is_site_offline = !cmsConfig::get('is_site_on');
$is_submit = $this->request->has('submit');
if ($is_submit) {
$is_captcha_valid = true;
if (cmsUser::sessionGet('is_auth_captcha') && $this->options['auth_captcha']) {
$is_captcha_valid = cmsEventsManager::hook('captcha_validate', $this->request);
}
if ($is_captcha_valid) {
cmsUser::sessionUnset('is_auth_captcha');
$logged_id = cmsUser::login($email, $password, $remember);
if ($logged_id) {
if ($is_site_offline) {
$userSession = cmsUser::sessionGet('user');
if (!$userSession['is_admin']) {
cmsUser::addSessionMessage(LANG_LOGIN_ADMIN_ONLY, 'error');
cmsUser::logout();
$this->redirectBack();
}
}
cmsEventsManager::hook('auth_login', $logged_id);
$auth_redirect = $this->options['auth_redirect'];
$is_first_auth = cmsUser::getUPS('first_auth', $logged_id);
if ($is_first_auth) {
$auth_redirect = $this->options['first_auth_redirect'];
cmsUser::deleteUPS('first_auth', $logged_id);
}
if ($back_url) {
$this->redirect($back_url);
} else {
$this->redirect($this->getAuthRedirectUrl($auth_redirect));
}
}
}
if ($this->options['auth_captcha'] && !$is_site_offline) {
cmsUser::sessionSet('is_auth_captcha', true);
}
if ($is_captcha_valid) {
cmsUser::addSessionMessage(LANG_LOGIN_ERROR, 'error');
if ($is_site_offline) {
$this->redirectBack();
}
} else {
cmsUser::addSessionMessage(LANG_CAPTCHA_ERROR, 'error');
}
if ($this->options['auth_redirect'] == 'none' || !empty($is_first_auth) && $this->options['first_auth_redirect'] == 'none') {
if (!$back_url) {
$back_url = $this->getBackURL();
}
}
}
if ($back_url && !$is_submit) {
cmsUser::addSessionMessage(LANG_LOGIN_REQUIRED, 'error');
}
if (cmsUser::sessionGet('is_auth_captcha')) {
$captcha_html = cmsEventsManager::hook('captcha_html');
}
return $this->cms_template->render('login', array('back_url' => $back_url, 'captcha_html' => isset($captcha_html) ? $captcha_html : false));
}
示例5: run
public function run($ctype_id, $parent_id)
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$content_model = cmsCore::getModel('content');
$ctype = $content_model->getContentType($ctype_id);
if (!$ctype) {
$this->halt();
}
$category = $content_model->getCategory($ctype['name'], $parent_id);
if (!$category) {
$this->halt();
}
$grid = $this->loadDataGrid('content_items', $ctype['name']);
$filter = array();
$filter_str = $this->request->get('filter');
// Одновременно смениться и тип контента, и настройка diff_order не могут
$diff_order = cmsUser::getUPS('admin.grid_filter.content.diff_order');
if ($filter_str && mb_strpos($filter_str, 'ctype_changed=1') !== false && $diff_order) {
// Изменён тип контента и должна быть сохранена сортировка
// Проверим, что эта сортировка есть в бд, иначе будет использоваться пришедшая
$ups_filter_str = cmsUser::getUPS('admin.grid_filter.content.' . $ctype['name']);
if ($ups_filter_str) {
$filter_str = $ups_filter_str;
}
// Чтобы заполнить поля поиска фильтра
$grid['options']['load_columns'] = true;
} else {
$filter_str = cmsUser::getUPSActual('admin.grid_filter.content.' . $ctype['name'], $filter_str);
}
if ($filter_str) {
parse_str($filter_str, $filter);
if (!empty($filter['advanced_filter'])) {
parse_str($filter['advanced_filter'], $dataset_filters);
if (!empty($dataset_filters['dataset'])) {
$dataset_id = $dataset_filters['dataset'];
$dataset = $content_model->getContentDataset($dataset_id);
$content_model->applyDatasetFilters($dataset, true);
}
$content_model->applyDatasetFilters($dataset_filters);
// Различная сортировка у разных типов контента, сохранение настройки
$new_diff_order = !empty($dataset_filters['diff_order']) ? '1' : '0';
if ($new_diff_order !== $diff_order) {
cmsUser::setUPS('admin.grid_filter.content.diff_order', $new_diff_order);
}
}
$content_model->applyGridFilter($grid, $filter);
// В случае обновления 'columns' грида для заполнения полей фильтров
$grid['filter'] = $filter;
}
$content_model->filterCategory($ctype['name'], $category, $ctype['is_cats_recursive']);
$content_model->disableApprovedFilter();
$content_model->disablePubFilter();
$total = $content_model->getContentItemsCount($ctype['name']);
$perpage = isset($filter['perpage']) ? $filter['perpage'] : admin::perpage;
$pages = ceil($total / $perpage);
$content_model->setPerPage($perpage);
$items = $content_model->getContentItems($ctype['name']);
cmsTemplate::getInstance()->renderGridRowsJSON($grid, $items, $total, $pages);
$this->halt();
}