Example #1
0
 /**
  * Iterator
  * Get all the blocks and attach the content within the view called 
  * @param array $blocks
  * @param string $side
  */
 private function Iterator($blocks, $side)
 {
     $ns = new Zend_Session_Namespace('Admin');
     $languageID = Languages::get_language_id($ns->lang);
     if (!empty($blocks['side'])) {
         if ($blocks['side'] == $side) {
             $blocks = $blocks['block'];
             if (count($blocks) > 1) {
                 foreach ($blocks as $block) {
                     $block = CmsBlocks::findbyvar($block['name'], $languageID);
                     if (!empty($block[0]['body'])) {
                         echo $block[0]['body'];
                     }
                 }
             } else {
                 $block = CmsBlocks::findbyvar($blocks['name'], $languageID);
                 if (!empty($block[0]['body'])) {
                     echo $block[0]['body'];
                 } else {
                     echo $blocks['name'] . " block not found.";
                 }
             }
         }
     }
 }
Example #2
0
 /**
  * chkCmsBlocks
  * Replace all the blocks with the cms blocks found
  * 
  * In the cms page you have to write in this way within the text body
  * {block name="homepage"}
  * 
  * @param string $text
  * @return string
  */
 public static function chkCmsBlocks($text, $locale = "en")
 {
     $languageID = Languages::get_language_id($locale);
     // Get all the blocks in the whole text
     $blocks = self::getAllBlocks($text);
     if (!empty($blocks[0])) {
         // For each block do ...
         foreach ($blocks[0] as $block) {
             // Get the information from the block
             preg_match_all('(([a-zA-Z0-9]+)=\\"(.+)\\")Ui', $block, $matches);
             // If the information are correct we get the name of the cms block to load
             if (!empty($matches[2][0])) {
                 // This is the name of the cms block to load from the db
                 $blockname = str_replace("\"", "", $matches[2][0]);
                 // Get the block information
                 $rsblock = CmsBlocks::findbyvar($blockname, $languageID);
                 // Replace the block placeholder with the cmsblock body
                 if (!empty($rsblock[0])) {
                     $text = str_replace($block, $rsblock[0]['body'], $text);
                 } else {
                     $text = str_replace($block, "[ERROR Cms block: {$blockname} doesn't exist.]", $text);
                 }
             }
         }
     }
     return $text;
 }
Example #3
0
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/admin/cmsblocks/process");
     $request = $this->getRequest();
     // Create the buttons in the edit form
     $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/cmsblocks/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/cmsblocks/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('list', 'cmsblocks', 'admin');
     }
     if ($form->isValid($request->getPost())) {
         // Get the id
         $id = $this->getRequest()->getParam('block_id');
         CmsBlocks::saveAll($id, $form->getValues());
         $redirector->gotoUrl("/admin/cmsblocks/edit/id/{$id}");
     } else {
         $this->view->form = $form;
         $this->view->title = $this->translator->translate("CMS Page Details");
         $this->view->description = $this->translator->translate("Here you can reply to all the customers requests");
         return $this->render('applicantform');
     }
 }
Example #4
0
 /**
  * 
  * Save the Cms Block data
  */
 public static function saveAll($id, $params, $locale = 1)
 {
     $i = 0;
     // Set the new values
     if (is_numeric($id)) {
         $cmsblock = Doctrine::getTable('CmsBlocks')->find($id);
     } else {
         $cmsblock = new CmsBlocks();
         $cmsblock->publishedat = date('Y-m-d H:i:s');
     }
     $cmsblock->title = $params['title'];
     $cmsblock->body = $params['body'];
     $cmsblock->var = Shineisp_Commons_UrlRewrites::format($params['var']);
     if ($cmsblock->trySave()) {
         if (is_numeric($cmsblock['block_id'])) {
             // Clear old reference records by page_id
             CmsBlocksData::deleteItems($cmsblock['block_id']);
             // Save the page translation references
             $PageData = new Doctrine_Collection('CmsBlocksData');
             foreach ($params['language_id'] as $idlang) {
                 $PageData[$i]->block_id = $cmsblock['block_id'];
                 $PageData[$i]->language_id = $idlang;
                 $i++;
             }
             $PageData->save();
         }
     }
 }