/** * Returns page by requested URL * * @return ModulePage_EntityPage */ protected function _getPageFromUrl() { // * Составляем полный URL страницы для поиска по нему в БД $sUrlFull = join('/', $this->GetParams()); if ($sUrlFull != '') { $sUrlFull = $this->sCurrentEvent . '/' . $sUrlFull; } else { $sUrlFull = $this->sCurrentEvent; } // * Ищем страницу в БД $oPage = E::ModulePage()->GetPageByUrlFull($sUrlFull, 1); return $oPage; }
/** * Default homepage * * @return string */ public function EventDefault() { E::ModuleViewer()->Assign('sMenuHeadItemSelect', 'homepage'); $sHomepage = Config::Get('router.config.homepage'); if ($sHomepage) { $sHomepageSelect = Config::Get('router.config.homepage_select'); if ($sHomepageSelect == 'page') { // if page not active or deleted then this homepage is off $oPage = E::ModulePage()->GetPageByUrlFull($sHomepage, 1); if ($oPage) { $sHomepage = $oPage->getUrlPath(); } else { $sHomepage = ''; } } else { if ($sHomepageSelect == 'category_homepage') { $sHomepageSelect = 'plugin-category-homepage'; } $aHomePageSelect = explode('-', $sHomepageSelect); // if homepage was from plugin and plugin is not active then this homepage is off if ($aHomePageSelect[0] == 'plugin' && isset($aHomePageSelect[1])) { if (!E::ActivePlugin($aHomePageSelect[1])) { $sHomepage = ''; } } } if ($sHomepage == 'home') { if (E::ModuleViewer()->TemplateExists('actions/homepage/action.homepage.index.tpl')) { $this->SetTemplateAction('index'); return; } } elseif ($sHomepage) { return R::Action($sHomepage); } } return R::Action('index'); }
/** * Проверка полей на корректность * * @return bool */ protected function CheckPageFields() { E::ModuleSecurity()->ValidateSendForm(); $bOk = true; /** * Проверяем есть ли заголовок топика */ if (!F::CheckVal(F::GetRequest('page_title', null, 'post'), 'text', 2, 200)) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.pages_create_title_error'), E::ModuleLang()->Get('error')); $bOk = false; } /** * Проверяем есть ли заголовок топика, с заменой всех пробельных символов на "_" */ $pageUrl = preg_replace("/\\s+/", '_', (string) F::GetRequest('page_url', null, 'post')); $_REQUEST['page_url'] = $pageUrl; if (!F::CheckVal(F::GetRequest('page_url', null, 'post'), 'login', 1, 50)) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.pages_create_url_error'), E::ModuleLang()->Get('error')); $bOk = false; } /** * Проверяем на счет плохих УРЛов */ /*if (in_array(F::GetRequest('page_url',null,'post'),$this->aBadPageUrl)) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.pages_create_url_error_bad').' '.join(',',$this->aBadPageUrl),E::ModuleLang()->Get('error')); $bOk=false; }*/ /** * Проверяем есть ли содержание страницы */ if (!F::CheckVal(F::GetRequest('page_text', null, 'post'), 'text', 1, 50000)) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.pages_create_text_error'), E::ModuleLang()->Get('error')); $bOk = false; } /** * Проверяем страницу в которую хотим вложить */ if (F::GetRequest('page_pid') != 0 && !($oPageParent = E::ModulePage()->GetPageById(F::GetRequest('page_pid')))) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.pages_create_parent_page_error'), E::ModuleLang()->Get('error')); $bOk = false; } /** * Проверяем сортировку */ if (F::GetRequest('page_sort') && !is_numeric(F::GetRequest('page_sort'))) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.pages_create_sort_error'), E::ModuleLang()->Get('error')); $bOk = false; } /** * Выполнение хуков */ E::ModuleHook()->Run('check_page_fields', array('bOk' => &$bOk)); return $bOk; }
public function Menu() { $aPages = E::ModulePage()->GetPages(array('pid' => null, 'main' => 1, 'active' => 1)); E::ModuleViewer()->Assign('aPagesMain', $aPages); return E::ModuleViewer()->Fetch('menus/menu.main_pages.tpl'); }