public function getAuthRedirectUrl($value) { $url = href_to_home(); $user_id = cmsUser::sessionGet('user:id'); if (!$user_id) { return $url; } $back_url = $this->getBackURL(); if (strpos($back_url, href_to('auth', 'login')) !== false) { $back_url = $url; } switch ($value) { case 'none': $url = $back_url; break; case 'index': $url = href_to_home(); break; case 'profile': $url = href_to('users', $user_id); break; case 'profileedit': $url = href_to('users', $user_id, 'edit'); break; } return $url; }
/** * Редирект на главную страницу */ public function redirectToHome() { $this->redirect(href_to_home()); }
<li><a href="<?php echo href_to('users', $user->id); ?> " class="user"><?php echo $user->nickname; ?> </a></li> <li><a href="<?php echo LANG_HELP_URL; ?> "><?php echo LANG_HELP; ?> </a></li> <li><a href="<?php echo href_to_home(); ?> "><?php echo LANG_CP_BACK_TO_SITE; ?> </a></li> <li><a href="<?php echo href_to('auth', 'logout'); ?> " class="logout"><?php echo LANG_LOG_OUT; ?> </a></li> </ul> </div>
</div> </div> <?php } ?> </div> </div> <?php } ?> <footer> <ul> <li id="copyright"> <a href="<?php echo $this->options['owner_url'] ? $this->options['owner_url'] : href_to_home(); ?> "> <?php html($this->options['owner_name'] ? $this->options['owner_name'] : cmsConfig::get('sitename')); ?> </a> © <?php echo $this->options['owner_year'] ? $this->options['owner_year'] : date('Y'); ?> </li> <li id="info"> <span class="item"> <?php echo LANG_POWERED_BY_INSTANTCMS;
public function run() { $user = cmsUser::getInstance(); // Получаем название типа контента и сам тип $ctype_name = $this->request->get('ctype_name'); $ctype = $this->model->getContentTypeByName($ctype_name); if (!$ctype) { cmsCore::error404(); } if (!$ctype['options']['list_on']) { cmsCore::error404(); } $category = array('id' => false); $subcats = array(); // Получаем SLUG категории $slug = $this->request->get('slug'); if (!$ctype['is_cats'] && $slug != 'index') { cmsCore::error404(); } if ($ctype['is_cats'] && $slug != 'index') { $category = $this->model->getCategoryBySLUG($ctype_name, $slug); if (!$category) { cmsCore::error404(); } } // Получаем список подкатегорий для текущей if ($ctype['is_cats']) { $current_cat_id = $category['id'] ? $category['id'] : 1; $subcats = $this->model->getSubCategories($ctype_name, $current_cat_id); } // Получаем список наборов $datasets = $this->model->getContentDatasets($ctype['id'], true); // Текущий набор $dataset = $this->request->get('dataset', false); // Это вывод на главной? $is_frontpage = $this->request->get('is_frontpage', false); // Номер страницы $page = $this->request->get('page', 1); // Если это не главная, но данный контент выводится на главной и сейчас // открыта индексная страница контента - редиректим на главную if (!$is_frontpage && cmsConfig::get('frontpage') == "content:{$ctype_name}" && $slug == 'index' && !$dataset && $page == 1) { $query = cmsCore::getInstance()->uri_query; if ($query) { $this->redirect(href_to_home() . "/?" . http_build_query($query)); } else { $this->redirectToHome(); } } // Если есть наборы, применяем фильтры текущего // иначе будем сортировать по дате создания if ($datasets) { if ($dataset && empty($datasets[$dataset])) { cmsCore::error404(); } $keys = array_keys($datasets); $current_dataset = $dataset ? $datasets[$dataset] : $datasets[$keys[0]]; $this->model->applyDatasetFilters($current_dataset); } else { $this->model->orderBy('date_pub', 'desc'); } // Фильтр по категории if ($ctype['is_cats'] && $slug != 'index') { $this->model->filterCategory($ctype_name, $category, $ctype['is_cats_recursive']); } // Скрываем записи из скрытых родителей (приватных групп и т.п.) $this->model->filterHiddenParents(); // Формируем базовые URL для страниц $page_url = array('base' => href_to($ctype['name'] . ($dataset ? '-' . $dataset : ''), isset($category['slug']) ? $category['slug'] : ''), 'first' => href_to($ctype['name'] . ($dataset ? '-' . $dataset : ''), isset($category['slug']) ? $category['slug'] : '')); list($ctype, $category) = cmsEventsManager::hook("content_before_category", array($ctype, $category)); list($ctype, $category) = cmsEventsManager::hook("content_{$ctype['name']}_before_category", array($ctype, $category)); $items_list_html = ''; $is_hide_items = !empty($ctype['options']['is_empty_root']) && $slug == 'index'; // Получаем HTML списка записей if (!$is_hide_items) { $items_list_html = $this->renderItemsList($ctype, $page_url, false, $category['id'], array(), $dataset); } return cmsTemplate::getInstance()->render('category_view', array('is_frontpage' => $is_frontpage, 'is_hide_items' => $is_hide_items, 'parent' => isset($parent) ? $parent : false, 'slug' => $slug, 'ctype' => $ctype, 'datasets' => $datasets, 'dataset' => $dataset, 'category' => $category, 'subcats' => $subcats, 'items_list_html' => $items_list_html, 'user' => $user), $this->request); }
if ((!isset($attributes['toolbar']) || $attributes['toolbar']) && $this->isToolbar()) { ?> <div class="cp_toolbar"> <?php $this->toolbar(); ?> </div> <?php } ?> <?php $is_ajax = $attributes['method'] == 'ajax'; $method = $is_ajax ? 'post' : $attributes['method']; $default_submit = array('title' => LANG_SAVE); $default_cancel = array('title' => LANG_CANCEL, 'href' => href_to_home(), 'show' => false); $submit = isset($attributes['submit']) ? array_merge($default_submit, $attributes['submit']) : $default_submit; $cancel = isset($attributes['cancel']) ? array_merge($default_cancel, $attributes['cancel']) : $default_cancel; $prepend_html = isset($attributes['prepend_html']) ? $attributes['prepend_html'] : ''; $append_html = isset($attributes['append_html']) ? $attributes['append_html'] : ''; ?> <form action="<?php echo $attributes['action']; ?> " method="<?php echo $method; ?> " <?php if ($is_ajax) {
/** * Выводит глубиномер * @param array $options Опции глубиномера */ public function breadcrumbs($options = array()) { $default_options = array('home_url' => href_to_home(), 'template' => 'breadcrumbs', 'strip_last' => true); $options = array_merge($default_options, $options); if ($this->breadcrumbs) { if ($options['strip_last']) { unset($this->breadcrumbs[sizeof($this->breadcrumbs) - 1]); } else { $this->breadcrumbs[sizeof($this->breadcrumbs) - 1]['is_last'] = true; } } $this->renderAsset('ui/' . $options['template'], array('breadcrumbs' => $this->breadcrumbs, 'options' => $options)); }