Пример #1
0
 /**
  * @param $blockId
  * @param \Fraym\Block\BlockXml $blockXML
  * @return \Fraym\Block\BlockXml
  */
 public function saveSiteMenu($blockId, \Fraym\Block\BlockXml $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $newMenuItems = json_decode($blockConfig->customMenu);
     $iteration = function (&$dom, $newMenuItems) use(&$iteration) {
         $childs = [];
         foreach ($newMenuItems as $item) {
             $element = $dom->createElement('item');
             $element->setAttribute('id', $item->key);
             if (isset($item->children) && count($item->children)) {
                 $subChilds = $iteration($dom, $item->children);
                 foreach ($subChilds as $child) {
                     $element->appendChild($child);
                 }
             }
             $childs[] = $element;
         }
         return $childs;
     };
     if (count($newMenuItems)) {
         $customDom = new \Fraym\Block\BlockXmlDom();
         $element = $customDom->createElement('menuItems');
         $element->setAttribute('site', $blockConfig->site);
         $childs = $iteration($customDom, $newMenuItems);
         foreach ($childs as $child) {
             $element->appendChild($child);
         }
         $customDom->appendChild($element);
         $blockXML->setCustomProperty($customDom);
     }
     return $blockXML;
 }
Пример #2
0
 /**
  * @param $blockId
  * @param BlockXML $blockXML
  * @return BlockXML
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXML $blockXML)
 {
     $blockConfig = $this->request->getGPAsArray();
     $customProperties = new \Fraym\Block\BlockXMLDom();
     $config = $customProperties->createElement('sliderConfig');
     foreach ($blockConfig['sliderConfig'] as $field => $value) {
         $element = $customProperties->createElement($field);
         $element->nodeValue = $value;
         $config->appendChild($element);
     }
     $customProperties->appendChild($config);
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Пример #3
0
 /**
  * @param $blockId
  * @param BlockXml $blockXML
  * @return BlockXml
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXml $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $customProperties = new \Fraym\Block\BlockXmlDom();
     if (isset($blockConfig->config)) {
         $element = $customProperties->createElement('dynamicTemplateConfig');
         $element->appendChild($customProperties->createCDATASection(serialize($blockConfig->config)));
         $customProperties->appendChild($element);
     }
     $element = $customProperties->createElement('dynamicTemplate');
     $element->nodeValue = $blockConfig->dynamicTemplate;
     $customProperties->appendChild($element);
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Пример #4
0
 /**
  * @param $blockId
  * @param \Fraym\Block\BlockXML $blockXML
  * @return \Fraym\Block\BlockXML
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXML $blockXML)
 {
     $data = $this->request->post('image');
     $data['auto_size'] = isset($data['auto_size']) && $data['auto_size'] == '1' ? true : false;
     $customProperties = new \Fraym\Block\BlockXMLDom();
     foreach ($data as $prop => $val) {
         if (!empty($val)) {
             $element = $customProperties->createElement('image_' . $prop);
             $element->nodeValue = $val;
             $customProperties->appendChild($element);
         }
     }
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Пример #5
0
 /**
  * @param $blockId
  * @param BlockXML $blockXML
  * @return BlockXML
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXML $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $customProperties = new \Fraym\Block\BlockXMLDom();
     foreach ($blockConfig->html as $localeId => $content) {
         $element = $customProperties->createElement('html');
         $domAttribute = $customProperties->createAttribute('locale');
         $domAttribute->value = $localeId;
         $element->appendChild($domAttribute);
         $element->appendChild($customProperties->createCDATASection($content));
         $customProperties->appendChild($element);
     }
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Пример #6
0
 /**
  * @param $xml
  * @return mixed
  */
 public function execBlock($xml)
 {
     $errors = array();
     $submit = false;
     $values = $this->request->getGPAsArray();
     if ($this->request->post('mailform')) {
         $submit = true;
         $required = $values['required'];
         $fields = $values['field'];
         $this->validation->setData($fields);
         $this->validation->addRule('email', 'email');
         $errorMessages = array();
         foreach ($required as $field => $val) {
             $this->validation->addRule($field, 'notEmpty');
             $errorMessages = array_merge($errorMessages, array($field => array($field => $this->translation->getTranslation('Please fill out the field'))));
         }
         $this->validation->setErrorMessages($errorMessages);
         $check = $this->validation->check();
         if ($check === true) {
             $msg = $this->mail->getMessageInstance();
             $msg->setFrom(array($fields['email']));
             $msg->setSubject($this->config->get('MAILFORM_SUBJECT')->value);
             $msg->setTo(explode(',', $this->config->get('MAILFORM_TO')->value));
             $this->template->assign('fields', $fields);
             $msg->setBody($this->template->fetch('Extension/Mailform/Mail'), 'text/html');
             $this->mail->send();
         } else {
             $errors = $check;
         }
     }
     $this->mailformController->renderHtml($submit, $values, $errors);
 }
Пример #7
0
 /**
  * save the output to cache file
  *
  * @return bool    ture or false
  */
 public function setCacheContent()
 {
     if (!is_dir(self::DIR_PAGES)) {
         mkdir(self::DIR_PAGES, 0755, true);
     }
     $filename = $this->getCacheName();
     // create the cache filename
     $cacheFilename = self::DIR_PAGES . $filename . '.cache.php';
     $cacheFilenamePhpData = self::DIR_PAGES . $filename . '.cache.config.php';
     $cacheInfo = "/*\n\n" . str_ireplace('*', '', print_r($_SERVER, true)) . "\n\n*/\n\n";
     $phpCode = '<?php ' . $cacheInfo;
     $currentMenuItem = $this->route->getCurrentMenuItemTranslation();
     if (!$this->request->isXmlHttpRequest() && !$this->request->isPost() && $this->user->isAdmin() === false && (!is_file($cacheFilename) || !is_file($cacheFilenamePhpData)) && $this->isCachingActive($currentMenuItem->menuItem)) {
         // save cached file
         $source = $this->template->outputFilter(ob_get_contents());
         $phpCode .= '$menuItemTranslation = <<<\'EOT\'' . "\n" . json_encode($currentMenuItem->toArray()) . "\n" . 'EOT;' . "\n";
         $phpCode .= '$domain = "' . $this->route->getCurrentDomain() . '";';
         $phpCode .= '$executedBlocks = <<<\'EOT\'' . "\n" . json_encode($this->blockParser->getExecutedBlocks()) . "\n" . 'EOT;' . "\n";
         file_put_contents($cacheFilenamePhpData, $phpCode);
         file_put_contents($cacheFilename, $source . "<!-- CACHED : " . date('Y-m-d H:i:s') . " -->");
         // clean the output buffer
         ob_clean();
         // parse cached blocks for first output
         echo $this->blockParser->parse($source, false, true);
         return true;
     }
     $source = $this->template->outputFilter(ob_get_contents());
     // clean the output buffer
     ob_clean();
     // parse cached blocks for first output
     echo $this->blockParser->parse($source, false, true);
     return false;
 }
Пример #8
0
 /**
  * @param $blockId
  * @param \Fraym\Block\BlockXML $blockXML
  * @return \Fraym\Block\BlockXML
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXML $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $customProperties = new \Fraym\Block\BlockXMLDom();
     $element = $customProperties->createElement('view');
     $element->appendChild($customProperties->createCDATASection($blockConfig->view));
     $customProperties->appendChild($element);
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Пример #9
0
 /**
  * @param $blockId
  * @param \Fraym\Block\BlockXml $blockXML
  * @return \Fraym\Block\BlockXml
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXml $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $customProperties = new \Fraym\Block\BlockXmlDom();
     $element = $customProperties->createElement('mailformOptions');
     $element->appendChild($customProperties->createCDATASection(json_encode($blockConfig->config)));
     $customProperties->appendChild($element);
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Пример #10
0
 /**
  * @param int $mode
  */
 public function init($mode = Core::ROUTE_NORMAL)
 {
     $globalConfigs = array('ENV' => self::ENV_DEVELOPMENT, 'JS_FOLDER' => '/js', 'CSS_FOLDER' => '/css', 'CONSOLIDATE_FOLDER' => '/consolidated', 'PROFILER_ENABLED' => false);
     foreach ($globalConfigs as $config => $val) {
         if (!defined($config)) {
             define($config, $val);
         }
     }
     if (ENV == self::ENV_DEVELOPMENT) {
         error_reporting(E_ALL | E_STRICT);
         ini_set("display_errors", 1);
     }
     if (is_object($this->session) && $this->isCLI() === false) {
         $this->session->start();
     }
     $this->mode = $mode;
     $this->startTimer(__CLASS__);
     // Assign our output handler to output clean errors
     ob_start();
     // ingore user abort, is recommed for ajax request and db changes
     if ($this->request->isXmlHttpRequest()) {
         ignore_user_abort(true);
     }
     $this->registryManager->init();
     if ($this->isCLI() === false) {
         // Sanitize all request variables
         $_GET = $this->sanitize($_GET);
         $_POST = $this->sanitize($_POST);
         $_COOKIE = $this->sanitize($_COOKIE);
         if ($mode === Core::ROUTE_NORMAL) {
             $this->cache->load();
             // Try to load a site by the requested URI
             $this->route->loadSite();
             if (!$this->request->isXmlHttpRequest() && !$this->request->isPost()) {
                 echo '<!-- ' . $this->getPageLoadTime() . 'sec -->';
             }
             $this->response->finish(false, true);
         }
     } else {
         $params = getopt('p:');
         if ($params['p']) {
             $_SERVER['REQUEST_URI'] = $params['p'];
             $this->route->loadVirtualRoutes();
             echo $this->route->checkVirtualRoute();
         }
     }
 }
Пример #11
0
 /**
  * @param int $mode
  */
 public function init($mode = Core::ROUTE_NORMAL)
 {
     if (ENV == self::ENV_DEVELOPMENT) {
         error_reporting(E_ALL | E_STRICT);
         ini_set("display_errors", 1);
     }
     if (is_object($this->session) && $this->isCLI() === false) {
         $this->session->start();
     }
     $this->mode = $mode;
     $this->startTimer(__CLASS__);
     // Assign our output handler to output clean errors
     ob_start();
     // ingore user abort, is recommed for ajax request and db changes
     if ($this->request->isXmlHttpRequest()) {
         ignore_user_abort(true);
     }
     $this->registryManager->init();
     if ($this->isCLI() === false) {
         // Sanitize all request variables
         $_GET = $this->sanitize($_GET);
         $_POST = $this->sanitize($_POST);
         $_COOKIE = $this->sanitize($_COOKIE);
         if ($mode === Core::ROUTE_NORMAL) {
             $this->cache->load();
             // Try to load a site by the requested URI
             $this->route->loadSite();
             $this->response->finish(false, true);
         }
     } else {
         $params = getopt('p:');
         if ($params['p']) {
             $_SERVER['REQUEST_URI'] = $params['p'];
             $this->route->loadRoutes();
             echo $this->route->getVirtualRouteContent();
         }
     }
 }
Пример #12
0
 /**
  * @param null $params
  * @return bool|mixed|\SimpleXMLElement|string
  */
 public function sendRepositoryRequest($params = null)
 {
     $url = self::REPOSITORY_URL;
     return $this->request->send($url, $params);
 }
Пример #13
0
 /**
  * @param $xml
  * @param $blockHtml
  * @return mixed|\SimpleXMLElement|string
  */
 private function processBlockAttributes($xml, $blockHtml)
 {
     $blockType = strtolower($this->getXMLAttr($xml, 'type'));
     if ($this->request->isXmlHttpRequest() === false) {
         if ($this->block->inEditMode() && in_array($blockType, $this->editModeTypes)) {
             $block = null;
             if (($this->getXMLAttr($xml, 'type') === 'extension' || $this->getXMLAttr($xml, 'type') === null) && ($id = $this->getXMLAttr($xml, 'id'))) {
                 $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($id);
             }
             $editable = $this->getXMLAttr($xml, 'editable');
             if ($editable === true || $editable === null) {
                 $blockHtml = $this->blockController->addBlockInfo($block, $blockHtml, $xml);
             }
         }
         // Disable cache on block attribute or on element level
         if ($this->getXMLAttr($xml, 'cached') != '1' && ($this->getXMLAttr($xml, 'cache') === false || isset($xml->cache) && $xml->cache == 0)) {
             $blockHtml = $this->disableBlockCaching($xml);
         } else {
             // add block state to check permission or end/start date on caching
             $blockHtml = $this->addBlockCacheState($xml, $blockHtml);
         }
         if ($this->getXMLAttr($xml, 'placeholder') !== null) {
             return $this->addPlaceholderReplacement($xml, $blockHtml);
         }
     }
     return $blockHtml;
 }
Пример #14
0
 /**
  * @param $blockId
  * @param \Fraym\Block\BlockXML $blockXML
  * @return \Fraym\Block\BlockXML
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXML $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $customProperties = new \Fraym\Block\BlockXMLDom();
     $element = $customProperties->createElement('view');
     $element->appendChild($customProperties->createCDATASection($blockConfig->newsView));
     $customProperties->appendChild($element);
     if ($blockConfig->newsView === 'detail' || $blockConfig->newsView === 'detail-category' || $blockConfig->newsView === 'detail-tag') {
         $element = $customProperties->createElement('checkRoute');
         $element->appendChild($customProperties->createCDATASection('newsRouteCheck'));
         $customProperties->appendChild($element);
         $element = $customProperties->createElement('listPage', intval($blockConfig->listPage));
         $customProperties->appendChild($element);
     } elseif ($blockConfig->newsView === 'list-category' || $blockConfig->newsView === 'list-tag') {
         $element = $customProperties->createElement('checkRoute');
         $element->appendChild($customProperties->createCDATASection('newsRouteCheck'));
         $customProperties->appendChild($element);
         $element = $customProperties->createElement('listPage', $this->route->getCurrentMenuItem()->id);
         $customProperties->appendChild($element);
     } elseif ($blockConfig->newsView === 'list') {
         $element = $customProperties->createElement('checkRoute');
         $element->appendChild($customProperties->createCDATASection('newsListRouteCheck'));
         $customProperties->appendChild($element);
         $element = $customProperties->createElement('limit');
         $element->nodeValue = $blockConfig->limit;
         $customProperties->appendChild($element);
         $forceShowOnDetail = property_exists($blockConfig, 'forceShowOnDetail') && $blockConfig->forceShowOnDetail == '1' ? 1 : 0;
         $element = $customProperties->createElement('forceShowOnDetail', $forceShowOnDetail);
         $customProperties->appendChild($element);
         if (isset($blockConfig->detailPage)) {
             $element = $customProperties->createElement('detailPage', intval($blockConfig->detailPage));
             $customProperties->appendChild($element);
         }
         $element = $customProperties->createElement('listItems');
         if (isset($blockConfig->newsListItems)) {
             $element->appendChild($customProperties->createCDATASection(implode(',', $blockConfig->newsListItems)));
         }
         $customProperties->appendChild($element);
         $element = $customProperties->createElement('newsListSort');
         $element->nodeValue = $blockConfig->newsListSort;
         $customProperties->appendChild($element);
     }
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Пример #15
0
 /**
  * @param $xml
  * @param $blockHtml
  * @return mixed|\SimpleXMLElement|string
  */
 protected function processBlockAttributes($xml, $blockHtml)
 {
     $blockType = strtolower($this->getXmlAttr($xml, 'type'));
     if ($this->block->inEditMode() && in_array($blockType, $this->editModeTypes)) {
         $block = null;
         if (($this->getXmlAttr($xml, 'type') === 'extension' || $this->getXmlAttr($xml, 'type') === null) && ($id = $this->getXmlAttr($xml, 'id'))) {
             $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($id);
         }
         $editable = $this->getXmlAttr($xml, 'editable');
         if ($editable === true || $editable === null) {
             $blockHtml = $this->blockController->addBlockInfo($block, $blockHtml, $xml, true);
         }
     }
     // interleaved unique content elements -> pop last element
     if (end($this->parsingBlockIds) == $this->getXmlAttr($xml, 'id')) {
         array_pop($this->parsingBlockIds);
     }
     // Disable cache on block attribute or on element level
     if ($this->getXmlAttr($xml, 'cached') != '1' && ($this->getXmlAttr($xml, 'cache') === false || isset($xml->cache) && $xml->cache == 0 && !$this->request->isPost() && GLOBAL_CACHING_ENABLED === true && $this->route->getCurrentMenuItem()->caching === true)) {
         $blockHtml = $this->disableBlockCaching($xml);
     } else {
         // add block state to check permission or end/start date on caching
         $blockHtml = $this->addBlockCacheState($xml, $blockHtml);
     }
     if ($this->getXmlAttr($xml, 'placeholder') !== null) {
         return $this->addPlaceholderReplacement($xml, $blockHtml);
     }
     return $blockHtml;
 }
Пример #16
0
 /**
  * @param \Fraym\Menu\Entity\MenuItemTranslation $page404
  * @return bool|void
  */
 private function render404Site(\Fraym\Menu\Entity\MenuItemTranslation $page404)
 {
     $this->setupPage($page404);
     $this->response->sendHTTPStatusCode(404);
     if ($this->request->isXmlHttpRequest() === true) {
         return false;
     }
     $this->siteManager->addAdminPanel();
     return $this->template->renderString($this->currentMenuItem->template->html);
 }
Пример #17
0
 /**
  * Callback function to clear the cache if a block element is created or changed
  */
 public function clearCache()
 {
     $location = $this->request->post('location', false);
     $this->cache->deleteCache($location);
 }