コード例 #1
0
 public function ajaxcontentAction()
 {
     $currentPage = Application_Model_Mappers_PageMapper::getInstance()->find($this->getRequest()->getParam('pageId'));
     $currentPage = $currentPage == null ? array() : $currentPage->toArray();
     $parseContent = new Tools_Content_Parser('{$' . $this->getRequest()->getParam('widget') . '}', $currentPage, array('websiteUrl' => $this->_helper->website->getUrl()));
     $this->_helper->response->success($parseContent->parseSimple());
 }
コード例 #2
0
 public function getAction()
 {
     // at first we will try to find content by id
     if (($containerId = intval(filter_var($this->_request->getParam('id'), FILTER_SANITIZE_NUMBER_INT))) == 0) {
         $containerId = filter_var($this->_request->getParam('name'), FILTER_SANITIZE_STRING);
     }
     $pageId = $this->_request->getParam('pid', null);
     // return only content for the containers
     $contentOnly = $this->_request->getParam('co', false);
     $mapper = Application_Model_Mappers_ContainerMapper::getInstance();
     $parser = new Tools_Content_Parser(null, array(), array('websiteUrl' => Zend_Controller_Action_HelperBroker::getStaticHelper('website')->getUrl()));
     // querying all containers
     if (!$containerId) {
         $containers = $mapper->fetchAll();
         if (empty($containers)) {
             return $this->_error('404 Containers not found.', self::REST_STATUS_NOT_FOUND);
         }
         return array_map(function ($container) use($contentOnly, $parser, $pageId) {
             $container = $container->toArray();
             $page = $pageId ? Application_Model_Mappers_PageMapper::getInstance()->find($pageId) : null;
             $parser->setPageData($page instanceof Application_Model_Models_Page ? $page->toArray() : array());
             $container['content'] = $parser->setContent($container['content'])->parseSimple();
             return $contentOnly ? array($container['name'] => $container['content']) : $container;
         }, $containers);
     }
     $type = $this->_request->getParam('type', Application_Model_Models_Container::TYPE_REGULARCONTENT);
     $pageId = $this->_request->getParam('pid', null);
     if ((int) $type == Application_Model_Models_Container::TYPE_STATICCONTENT) {
         $pageId = null;
     }
     $container = is_integer($containerId) ? $mapper->find($containerId) : $mapper->findByName($containerId, $pageId, $type);
     $pageId = $this->_request->getParam('pid', null);
     if (!$container instanceof Application_Model_Models_Container) {
         $container = new Application_Model_Models_Container(array('containerType' => $type, 'name' => $containerId));
     } else {
         if (!$pageId) {
             $pageId = $container->getPageId();
         }
         $page = $pageId ? Application_Model_Mappers_PageMapper::getInstance()->find($pageId) : null;
         $parser->setPageData($page instanceof Application_Model_Models_Page ? $page->toArray() : array())->setContent($container->getContent());
         $container->setContent($parser->parseSimple());
     }
     return $contentOnly ? array($container->getName() => $container->getContent()) : $container->toArray();
 }
コード例 #3
0
 protected function _prepareEmailBody()
 {
     $tmplMessage = $this->_options['message'];
     $mailTemplate = Application_Model_Mappers_TemplateMapper::getInstance()->find($this->_options['template']);
     if (!empty($mailTemplate)) {
         $this->_entityParser->setDictionary(array('emailmessage' => !empty($tmplMessage) ? $tmplMessage : ''));
         //pushing message template to email template and cleaning dictionary
         $mailTemplate = $this->_entityParser->parse($mailTemplate->getContent());
         $this->_entityParser->setDictionary(array());
         $mailTemplate = $this->_entityParser->parse($mailTemplate);
         $themeData = Zend_Registry::get('theme');
         $extConfig = Zend_Registry::get('extConfig');
         $parserOptions = array('websiteUrl' => $this->_websiteHelper->getUrl(), 'websitePath' => $this->_websiteHelper->getPath(), 'currentTheme' => $extConfig['currentTheme'], 'themePath' => $themeData['path']);
         $cDbTable = new Application_Model_DbTable_Container();
         $select = $cDbTable->getAdapter()->select()->from('container', array('uniqHash' => new Zend_Db_Expr("MD5(CONCAT_WS('-',`name`, COALESCE(`page_id`, 0), `container_type`))"), 'id', 'name', 'page_id', 'container_type', 'content', 'published', 'publishing_date'))->where('(container_type = 2 OR container_type = 4)')->where('page_id IS NULL');
         $stat = $cDbTable->getAdapter()->fetchAssoc($select);
         $parser = new Tools_Content_Parser($mailTemplate, array('containers' => $stat), $parserOptions);
         return Tools_Content_Tools::stripEditLinks($parser->parseSimple());
     }
     return false;
 }
コード例 #4
0
 private function _complete($pageContent, $pageData, $parserOptions)
 {
     $head = '';
     $body = '';
     //parsing seo data
     $seoData = Tools_Seo_Tools::loadSeodata();
     $seoData = $seoData->toArray();
     unset($seoData['id']);
     $seoData = array_map(function ($item) use($pageData, $parserOptions) {
         $parser = new Tools_Content_Parser(null, $pageData, $parserOptions);
         return !empty($item) ? $parser->setContent($item)->parseSimple() : $item;
     }, $seoData);
     preg_match('~(<body[^\\>]*>)(.*)</body>~usi', $pageContent, $body);
     // setting default charset
     if ($this->view->doctype()->isHtml5()) {
         $this->view->headMeta()->setCharset('utf-8');
     }
     $this->_extendHead($pageContent);
     $this->view->placeholder('seo')->exchangeArray($seoData);
     $this->view->websiteUrl = $parserOptions['websiteUrl'];
     $this->view->websiteMainPage = Helpers_Action_Website::DEFAULT_PAGE;
     $this->view->currentTheme = $parserOptions['currentTheme'];
     // building canonical url
     if ('' === ($canonicalScheme = $this->_config->getConfig('canonicalScheme'))) {
         $canonicalScheme = $this->getRequest()->getScheme();
     }
     $this->view->canonicalUrl = $canonicalScheme . '://' . parse_url($parserOptions['websiteUrl'], PHP_URL_HOST) . parse_url($parserOptions['websiteUrl'], PHP_URL_PATH) . ($pageData['url'] !== Helpers_Action_Website::DEFAULT_PAGE ? $pageData['url'] : '');
     $this->view->pageData = $pageData;
     if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) {
         unset($pageData['content']);
         $body[1] .= $this->_helper->admin->renderAdminPanel($this->_helper->session->getCurrentUser()->getRoleId());
     }
     $this->view->bodyTag = $body[1];
     $this->view->content = $body[2];
     $locale = Zend_Locale::getLocaleToTerritory($this->_config->getConfig('language'));
     $this->view->htmlLang = substr($locale, 0, strpos($locale, '_'));
     $this->view->minify = $this->_config->getConfig('enableMinify') && !Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_LAYOUT);
 }