Exemplo n.º 1
0
 public function signupAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     if ($this->getRequest()->isPost()) {
         $signupForm = new Application_Form_Signup();
         if ($signupForm->isValid($this->getRequest()->getParams())) {
             //save new user
             $user = new Application_Model_Models_User($signupForm->getValues());
             $user->registerObserver(new Tools_Mail_Watchdog(array('trigger' => Tools_Mail_SystemMailWatchdog::TRIGGER_SIGNUP)));
             $user->setRoleId(Tools_Security_Acl::ROLE_MEMBER);
             if (isset($this->_helper->session->refererUrl)) {
                 $user->setReferer($this->_helper->session->refererUrl);
             }
             $signupResult = Application_Model_Mappers_UserMapper::getInstance()->save($user);
             if (!$user->getId()) {
                 $user->setId($signupResult);
             }
             //send mails by notifying mail observer about successful sign-up,
             $user->notifyObservers();
             //redirect to signup landing page
             $signupLandingPage = Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_SIGNUPLAND);
             if ($signupLandingPage instanceof Application_Model_Models_Page) {
                 $this->_redirect($this->_helper->website->getUrl() . $signupLandingPage->getUrl());
                 exit;
             } else {
                 $this->_redirect($this->_helper->website->getUrl());
             }
         } else {
             $this->_helper->flashMessenger->addMessage(Tools_Content_Tools::proccessFormMessagesIntoHtml($signupForm->getMessages(), get_class($signupForm)));
             $signupPageUrl = $this->_helper->session->signupPageUrl;
             unset($this->_helper->session->signupPageUrl);
             $this->_redirect($this->_helper->website->getUrl() . ($signupPageUrl ? $signupPageUrl : ''));
         }
     }
 }
Exemplo n.º 2
0
 private function _memberRedirect($success = true)
 {
     $landingPage = $success ? Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_MEMLAND) : Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_ERRLAND);
     if ($landingPage instanceof Application_Model_Models_Page) {
         $this->redirect($this->_helper->website->getUrl() . $landingPage->getUrl(), array('exit' => true));
     }
 }
Exemplo n.º 3
0
 public function init()
 {
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->addElement(new Zend_Form_Element_Text(array('id' => 'h1', 'name' => 'h1', 'label' => 'Page header H1 tag', 'value' => $this->_h1, 'required' => true, 'filters' => array('StringTrim'))));
     $this->addElement(new Zend_Form_Element_Text(array('id' => 'header-title', 'name' => 'headerTitle', 'label' => 'Display in browser title as', 'value' => $this->_headerTitle, 'required' => true, 'filters' => array('StringTrim'))));
     $this->addElement(new Zend_Form_Element_Text(array('id' => 'url', 'name' => 'url', 'label' => 'Page URL in address bar', 'value' => $this->_url, 'required' => true, 'filters' => array(new Zend_Filter_StringTrim('.')))));
     $this->addElement(new Zend_Form_Element_Text(array('id' => 'nav-name', 'name' => 'navName', 'label' => 'Display in navigation as', 'value' => $this->_navName, 'required' => true, 'filters' => array('StringTrim'))));
     $this->addElement(new Zend_Form_Element_Text(array('name' => 'metaKeywords', 'id' => 'meta-keywords', 'label' => 'Meta keywords', 'value' => $this->_metaKeywords, 'filters' => array('StringTrim'))));
     $this->addElement(new Zend_Form_Element_Textarea(array('name' => 'metaDescription', 'id' => 'meta-description', 'cols' => '45', 'rows' => '4', 'label' => 'Meta description', 'value' => $this->_metaDescription, 'filters' => array('StringTrim'))));
     $this->addElement(new Zend_Form_Element_Textarea(array('name' => 'teaserText', 'id' => 'teaser-text', 'cols' => '45', 'rows' => '6', 'value' => $this->_teaserText, 'filters' => array('StringTrim'))));
     $this->addElement(new Zend_Form_Element_Radio(array('name' => 'inMenu', 'multiOptions' => array(Application_Model_Models_Page::IN_MAINMENU => 'Main Menu', Application_Model_Models_Page::IN_STATICMENU => 'Flat Menu', Application_Model_Models_Page::IN_NOMENU => 'No Menu'), 'label' => 'Navigation', 'required' => true, 'separator' => '')));
     $this->addElement(new Zend_Form_Element_Select(array('name' => 'pageCategory', 'id' => 'page-category', 'label' => 'Main menu', 'class' => 'mb5px', 'multiOptions' => array('Seotoaster' => array(Application_Model_Models_Page::IDCATEGORY_CATEGORY => 'This page is a category')), 'registerInArrayValidator' => false, 'required' => true)));
     // Disabling translator for the list of categories
     $this->getElement('pageCategory')->setDisableTranslator(true);
     $this->addElement(new Zend_Form_Element_Select(array('name' => 'extraOptions', 'id' => 'page-options', 'class' => 'grid_8 alpha omega', 'multiOptions' => array_merge(array('0' => 'Select an option'), Tools_Page_Tools::getPageOptions(true)), 'registerInArrayValidator' => false, 'value' => $this->_pageOption)));
     $this->addElement(new Zend_Form_Element_Hidden(array('id' => 'templateId', 'name' => 'templateId', 'required' => true, 'label' => 'Current template', 'value' => $this->_templateId)));
     $this->addElement(new Zend_Form_Element_Hidden(array('id' => 'pageId', 'name' => 'pageId', 'value' => $this->_pageId)));
     $this->addElement(new Zend_Form_Element_Hidden(array('id' => 'draft', 'name' => 'draft', 'value' => $this->_draft)));
     $this->addElement(new Zend_Form_Element_Hidden(array('id' => 'optimized', 'name' => 'optimized')));
     $this->addElement(new Zend_Form_Element_Hidden(array('id' => 'publish-at', 'name' => 'publishAt', 'value' => $this->_publishAt)));
     $this->addElement(new Zend_Form_Element_Button(array('name' => 'updatePage', 'id' => 'update-page', 'type' => 'submit', 'value' => 'Save page', 'class' => 'icon-save mr-grid', 'label' => 'Save page', 'escape' => false)));
     //$this->setDecorators(array('ViewScript'));
     $this->setElementDecorators(array('ViewHelper', 'Label'));
     $this->getElement('updatePage')->removeDecorator('Label');
 }
Exemplo n.º 4
0
 /**
  * Returns amount of pages using specific template
  *
  */
 public function pagesviatemplateAction()
 {
     $templateName = $this->getRequest()->getParam('template', '');
     if ($templateName) {
         $this->view->pagesUsingTemplate = Tools_Page_Tools::getPagesCountByTemplate($templateName);
     }
 }
Exemplo n.º 5
0
 public static function renderMenuTemplate($pages, $template, $parentCategoryPage = null)
 {
     $entityParser = new Tools_Content_EntityParser();
     $website = Zend_Controller_Action_HelperBroker::getStaticHelper('website');
     $dictionary = array();
     if ($parentCategoryPage === null) {
         $menuHtml = '<ul class="main_menu" >';
     } else {
         $menuHtml = '<ul>';
     }
     $i = 1;
     foreach ($pages as $k => $page) {
         $menuItemTemplate = $template;
         $dictionary['$page:preview'] = '<img class="page-teaser-image" src="' . Tools_Page_Tools::getPreview(intval($page['id'])) . '" alt="index">';
         if ($parentCategoryPage === true) {
             $dictionary['$page:category:name'] = $parentCategoryPage['h1'];
         }
         foreach ($page as $prop => $item) {
             if ($prop === 'url') {
                 $item = $website->getUrl() . $item;
             }
             $dictionary['$page:' . $prop] = $item;
         }
         if (!empty($page['subPages'])) {
             $menuItemTemplate = preg_replace_callback('~{submenu}(.*){/submenu}~siuU', function ($match) use($page) {
                 return Widgets_Menu_Menu::renderMenuTemplate($page['subPages'], $match[1], $page);
             }, $template);
             $menuItemTemplate = preg_replace('~{ifpages}(.*){/ifpages}~siuU', '$1', $menuItemTemplate);
         } else {
             $menuItemTemplate = preg_replace('~{(submenu|ifpages)}.*{/(submenu|ifpages)}~siuU', '', $template);
         }
         $menuHtml .= '<li class="' . ($parentCategoryPage === null ? 'category cat-' . $i++ : 'page') . '">';
         $menuHtml .= $entityParser->setDictionary($dictionary)->parse($menuItemTemplate);
         $menuHtml .= '</li>';
     }
     $menuHtml .= '</ul>';
     return $menuHtml;
 }
Exemplo n.º 6
0
 public function indexAction()
 {
     $page = null;
     $pageContent = null;
     $currentUser = $this->_helper->session->getCurrentUser();
     // tracking referer
     if (!isset($this->_helper->session->refererUrl)) {
         $refererUrl = $this->getRequest()->getHeader('referer');
         $currentUser->setReferer($refererUrl);
         $this->_helper->session->setCurrentUser($currentUser);
         $this->_helper->session->refererUrl = $refererUrl;
     }
     // Getting requested url. If url is not specified - get index.html
     $pageUrl = filter_var($this->getRequest()->getParam('page', Helpers_Action_Website::DEFAULT_PAGE), FILTER_SANITIZE_STRING);
     // Trying to do canonical redirects
     $this->_helper->page->doCanonicalRedirect($pageUrl);
     //Check if 301 redirect is present for requested page then do it
     $this->_helper->page->do301Redirect($pageUrl);
     // Loading page data using url from request. First checking cache, if no cache
     // loading from the database and save result to the cache
     $pageCacheKey = md5($pageUrl);
     if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_CACHE_PAGE)) {
         $page = $this->_helper->cache->load($pageCacheKey, 'pagedata_');
     }
     // page is not in cache
     if ($page === null) {
         $page = Application_Model_Mappers_PageMapper::getInstance()->findByUrl($pageUrl);
     }
     // page found
     if ($page instanceof Application_Model_Models_Page) {
         $cacheTag = preg_replace('/[^\\w\\d_]/', '', $page->getTemplateId());
         $this->_helper->cache->save($pageCacheKey, $page, 'pagedata_', array($cacheTag, 'pageid_' . $page->getId()));
     }
     // If page doesn't exists in the system - show 404 page
     if ($page === null) {
         //show 404 page and exit
         $page = Application_Model_Mappers_PageMapper::getInstance()->find404Page();
         if (!$page instanceof Application_Model_Models_Page) {
             $this->view->websiteUrl = $this->_helper->website->getUrl();
             $this->view->adminPanel = $this->_helper->admin->renderAdminPanel($this->_helper->session->getCurrentUser()->getRoleId());
             $this->_helper->response->notFound($this->view->render('index/404page.phtml'));
             exit;
         }
         $this->getResponse()->setHeader('HTTP/1.1', '404 Not Found');
         $this->getResponse()->setHeader('Status', '404 File not found');
     }
     //if requested page is not allowed - redirect to the signup landing page
     if (!Tools_Security_Acl::isAllowed($page)) {
         $signupLanding = Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_SIGNUPLAND);
         $this->_helper->redirector->gotoUrl($signupLanding instanceof Application_Model_Models_Page ? $this->_helper->website->getUrl() . $signupLanding->getUrl() : $this->_helper->website->getUrl());
     }
     // Mobile switch
     if ((bool) $this->_config->getConfig('enableMobileTemplates')) {
         if ($this->_request->isGet() && $this->_request->has('mobileSwitch')) {
             $showMobile = filter_var($this->_request->getParam('mobileSwitch'), FILTER_SANITIZE_NUMBER_INT);
             if (!is_null($showMobile)) {
                 $this->_helper->session->mobileSwitch = (bool) $showMobile;
             }
         }
         if (!isset($showMobile) && isset($this->_helper->session->mobileSwitch)) {
             $showMobile = $this->_helper->session->mobileSwitch;
         } else {
             $showMobile = $this->_helper->mobile->isMobile();
         }
         // Mobile detect
         if ($showMobile === true) {
             $mobileTemplate = Application_Model_Mappers_TemplateMapper::getInstance()->find('mobile_' . $page->getTemplateId());
             if (null !== $mobileTemplate) {
                 $page->setTemplateId($mobileTemplate->getName())->setContent($mobileTemplate->getContent());
             }
             unset($mobileTemplate);
         }
     }
     $pageData = $page->toArray();
     //Parsing page content and saving it to the cache
     if ($pageContent === null) {
         $themeData = Zend_Registry::get('theme');
         $parserOptions = array('websiteUrl' => $this->_helper->website->getUrl(), 'websitePath' => $this->_helper->website->getPath(), 'currentTheme' => $this->_config->getConfig('currentTheme'), 'themePath' => $themeData['path']);
         $parser = new Tools_Content_Parser($page->getContent(), $pageData, $parserOptions);
         $pageContent = $parser->parse();
         unset($parser);
         unset($themeData);
         //$this->_helper->cache->save($page->getUrl(), $pageContent, 'page_');
     }
     $pageContent = $this->_pageRunkSculptingDemand($page, $pageContent);
     // Finalize page generation routine
     $this->_complete($pageContent, $pageData, $parserOptions);
 }
Exemplo n.º 7
0
 public static function toArray($template, $currentTemplate = null)
 {
     return array('id' => $template->getId(), 'name' => $template->getName(), 'isCurrent' => $currentTemplate && $template->getName() == $currentTemplate->getName() ? true : false, 'pagesCount' => Tools_Page_Tools::getPagesCountByTemplate($template->getName()), 'type' => $template->getType(), 'content' => $template->getContent(), 'protected' => in_array($template->getName(), self::$protectedTemplates));
 }
Exemplo n.º 8
0
 private function _getProductCategoryPageWhere()
 {
     $productCategoryPage = Tools_Page_Tools::getProductCategoryPage();
     return $productCategoryPage instanceof Application_Model_Models_Page ? 'parent_id != "' . $productCategoryPage->getId() . '"' : null;
 }