public function init() { $this->addElement('text', 'title', array('label' => 'Block Title:', 'required' => true, 'class' => 'title-input-box', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the Block title')))), 'decorators' => $this->elementDecorators)); $this->addElement('text', 'alias', array('label' => 'Alias:', 'class' => 'title-input-box', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the alias')))), 'decorators' => $this->elementDecorators)); $this->addElement('textarea', 'body', array('label' => 'Body:', 'class' => 'title-input-box', 'rows' => '5', 'cols' => '60', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); $this->addElement('radio', 'status', array('label' => 'Staus : ', 'required' => true, 'value' => '1', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must select the status.')))), 'multiOptions' => array('1' => "Publish", '0' => "Unpublish"), 'decorators' => $this->elementDecorators)); $this->getElement('status')->setSeparator(''); $country = new Block_Model_BlockRegion(); $arrCountry = $country->getBlockRegion("--select---"); $this->addElement('select', 'blockRegionId', array('label' => 'Block-Region:', 'class' => 'form', 'TABINDEX' => '6', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrCountry)); $this->addElement('text', 'weight', array('label' => 'Weight:', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the weight')))), 'value' => '0', 'decorators' => $this->elementDecorators)); $this->addElement('textarea', 'visibilityPaths', array('label' => 'Visibility Paths:', 'class' => 'title-input-box', 'rows' => '5', 'cols' => '60', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); $this->addElement('submit', 'cmdSubmit', array('required' => false, 'ignore' => true, 'label' => 'Save', 'decorators' => $this->buttonDecorators)); }
public function addAction() { $request = $this->getRequest(); $form = new Block_Form_BlockRegion(); if ($this->getRequest()->isPost()) { $options = $request->getPost(); if ($form->isValid($options)) { $model = new Block_Model_BlockRegion($options); $id = $model->save(); return $this->_helper->redirector('add', 'block-region', "admin", array('msg' => base64_encode("Block-Region Added successfully!"))); } else { $form->reset(); $form->populate($options); } } $this->view->msg = base64_decode($this->getRequest()->getParam("msg")); // Assign the form to the view $this->view->form = $form; }
public function getBlockRegion($option = null) { $obj = new Block_Model_BlockRegion(); $entries = $obj->fetchAll(); $arrCountry = array(); if (!is_null($option)) { $arrCountry[''] = $option; } foreach ($entries as $entry) { $arrCountry[$entry->getId()] = ucfirst(strtolower($entry->getTitle())); } return $arrCountry; }
public function blocks($region, $path = "/modules/block/views/blocks") { //var_dump ($this->request); $request_uri = $_SERVER['REQUEST_URI']; $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); if ($config->seofriendlyurl == "1") { $seoUrlM = new Application_Model_SeoUrl(); $seoUrl = $seoUrlM->fetchRow("seo_url='{$request_uri}'"); if (false !== $seoUrl) { $request_uri = $seoUrl->getActualUrl(); } } $regionM = new Block_Model_BlockRegion(); $regionO = $regionM->fetchRow("alias='{$region}'"); if ($regionO === false) { return false; } $blockM = new Block_Model_Block(); $where = " (block_region_id='{$regionO->getId()}' || block_region_id='0') and status='1'"; $order = "weight desc"; $blocks = $blockM->fetchAll($where, $order); if (count($blocks) > 0) { $requestUrl = trim($request_uri); $path = APPLICATION_PATH . $path . "/" . $region; $this->view->addScriptPath($path); foreach ($blocks as $_block) { $flag = false; $arrPaths = unserialize($_block->getVisibilityPaths()); foreach ($arrPaths as $_path) { $_path = trim($_path); if ($_path == $requestUrl) { $flag = true; break; //break the path loop } else { if (false !== strpos($_path, "*")) { $_path = substr($_path, 0, -2); if ($_path != "") { if (false !== strpos($requestUrl, $_path)) { $flag = true; break; //break the path loop } } else { $flag = true; break; //break the path loop } } } } //end of path loop if ($flag == true) { if (trim($_block->getBody()) == "") { if ($_block->getAlias() == "recent-blog" && ($requestUrl == "/journal/my-journals" || $requestUrl == "/journal/journal-settings")) { //no need to display the block } else { echo $this->view->render($_block->getAlias() . ".phtml"); } } else { echo $_block->getBody(); } } } } }