示例#1
0
 private function _parse()
 {
     $this->_iteration++;
     $replacement = '';
     $widgets = $this->_findWidgets();
     if (empty($widgets) || $this->_iteration >= self::PARSE_DEEP) {
         return;
     }
     foreach ($widgets as $widgetData) {
         try {
             $widget = Tools_Factory_WidgetFactory::createWidget($widgetData['name'], $widgetData['options'], array_merge($this->_pageData, $this->_options));
             $replacement = is_object($widget) ? $widget->render() : $widget;
         } catch (Exceptions_SeotoasterException $se) {
             $replacement = $se->getMessage() . ' Can not load widget: <b>' . $widgetData['name'] . '</b>';
         }
         $this->_replace($replacement, $widgetData['name'], $widgetData['options']);
     }
     $this->_parse();
 }
 /**
  * Method return form for editing css files for current theme
  * and saves css file content
  */
 public function editcssAction()
 {
     $cssFiles = $this->_buildCssFileList();
     $defaultCss = $this->_websiteConfig['path'] . $this->_themeConfig['path'] . array_search(self::DEFAULT_CSS_NAME, current($cssFiles));
     $editcssForm = new Application_Form_Css();
     $editcssForm->getElement('cssname')->setMultiOptions($cssFiles);
     $editcssForm->getElement('cssname')->setValue(self::DEFAULT_CSS_NAME);
     //checking, if form was submited via POST then
     if ($this->getRequest()->isPost()) {
         $postParams = $this->getRequest()->getParams();
         if (isset($postParams['getcss']) && !empty($postParams['getcss'])) {
             $cssName = $postParams['getcss'];
             try {
                 $content = Tools_Filesystem_Tools::getFile($this->_websiteConfig['path'] . $this->_themeConfig['path'] . $cssName);
                 $this->_helper->response->response($content, false);
             } catch (Exceptions_SeotoasterException $e) {
                 $this->_helper->response->response($e->getMessage(), true);
             }
         } else {
             if (is_string($postParams['content']) && empty($postParams['content'])) {
                 $editcssForm->getElement('content')->setRequired(false);
             }
             if ($editcssForm->isValid($postParams)) {
                 $cssName = $postParams['cssname'];
                 try {
                     Tools_Filesystem_Tools::saveFile($this->_websiteConfig['path'] . $this->_themeConfig['path'] . $cssName, $postParams['content']);
                     $params = array('websiteUrl' => $this->_helper->website->getUrl(), 'themePath' => $this->_websiteConfig['path'] . $this->_themeConfig['path'], 'currentTheme' => $this->_helper->config->getConfig('currentTheme'));
                     $concatCss = Tools_Factory_WidgetFactory::createWidget('Concatcss', array('refresh' => true), $params);
                     $concatCss->render();
                     $this->_helper->response->response($this->_translator->translate('CSS saved'), false);
                 } catch (Exceptions_SeotoasterException $e) {
                     $this->_helper->response->response($e->getMessage(), true);
                 }
             }
         }
         $this->_helper->response->response($this->_translator->translate('Undefined error'), true);
     } else {
         try {
             $editcssForm->getElement('content')->setValue(Tools_Filesystem_Tools::getFile($defaultCss));
             $editcssForm->getElement('cssname')->setValue(array_search(self::DEFAULT_CSS_NAME, current($cssFiles)));
         } catch (Exceptions_SeotoasterException $e) {
             $this->view->errorMessage = $e->getMessage();
         }
     }
     $this->view->helpSection = 'editcss';
     $this->view->editcssForm = $editcssForm;
 }