public function addBlockAction() { $_pageID = $this->getRequest()->getParam('ID'); $_moduleID = $this->_moduleID; $_baseUrl = $this->getFrontController()->getBaseUrl(); $_success = false; $this->view->assign('isXmlHttpRequest', $this->_isXmlHttpRequest); $this->view->assign('success', $_success); $_options = array('baseDir' => $_baseUrl, 'pageID' => $_pageID, 'blockID' => '0', 'addAction' => true); $form = $this->getForm($_options); if (Cible_ACL::hasAccess($_pageID)) { // get page informations $page = $this->view->page = Cible_FunctionsPages::getPageDetails($_pageID); $page_info = $page->toArray(); //get position of all pages on the same level of the current page $position = Cible_FunctionsBlocks::getAllPositions($_pageID, 1); // fill select zone $form = Cible_FunctionsBlocks::fillSelectZone($form, $page_info['V_ZoneCount']); // fill select position $form = Cible_FunctionsBlocks::fillSelectPosition($form, $position, "add"); // action if the user add block if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { // add block $blockID = $this->addBlock($formData, $_pageID, $_moduleID); $parameterGroup = $form->getDisplayGroup('parameters'); if ($parameterGroup) { $params = $parameterGroup->getElements(); foreach ($params as $param) { $parameters = new Parameters(); $parameter = $parameters->createRow(); $parameter->P_BlockID = $blockID; $parameter->P_Number = str_replace('Param', '', $param->getID()); $parameter->P_Value = $_POST[$param->getID()]; $parameter->save(); } } if (method_exists($this, 'add')) { $this->add($blockID); } if ($this->_isXmlHttpRequest) { $_success = true; $this->view->assign('success', $_success); $this->view->assign('blockID', $blockID); } else { // redirect $this->_redirect('/page/manage/index/ID/' . $_pageID); } } else { $form->populate($formData); } } // send the form to the view $this->view->form = $form; $this->view->jQuery()->enable(); } }