Exemple #1
0
 public function editAction()
 {
     $this->view->title = "Modification d'un texte";
     if ($this->view->aclIsAllowed('text', 'edit', true)) {
         $_blockID = $this->_getParam('blockID');
         $_pageid = $this->_getParam('pageID');
         $_id = $this->_getParam('ID');
         $base_dir = $this->getFrontController()->getBaseUrl();
         $blockText = new Text();
         $select = $blockText->select();
         $select->where('TD_BlockID = ?', $_blockID);
         $select->where('TD_LanguageID = ?', $this->_currentEditLanguage);
         $block = $blockText->fetchRow($select);
         $blockSelect = new Blocks();
         $selectBloc = $blockSelect->select()->setIntegrityCheck(false)->from('Blocks')->where('B_ID = ?', $_blockID)->join('PagesIndex', 'PI_PageID = B_PageID')->where('PI_LanguageID = ?', $block['TD_LanguageID']);
         // If block doesn't exist, creates it.
         if (empty($block)) {
             $block = $blockText->createRow(array('TD_BlockID' => $_blockID, 'TD_LanguageID' => $this->_currentEditLanguage));
             $block->save();
             // load it
             $block = $blockText->fetchRow($select);
         }
         if ($_id) {
             $returnLink = "{$base_dir}/text/index/list-approbation-request/";
         } else {
             $returnLink = "{$base_dir}/page/index/index/ID/{$_pageid}";
         }
         $form = new FormText(array('baseDir' => $base_dir, 'pageID' => $_pageid, 'cancelUrl' => $returnLink, 'toApprove' => $block["TD_ToApprove"]));
         if (!$this->_request->isPost()) {
             $block_data = empty($block) ? array() : $block->toArray();
             $blockData = $blockSelect->fetchRow($selectBloc);
             $block_data['PI_PageTitle'] = $blockData['PI_PageTitle'];
             $form->populate($block_data);
         } else {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 if (isset($_POST['submitSaveSubmit'])) {
                     $block['TD_ToApprove'] = 1;
                     //header("location:".$returnLink);
                 } elseif (isset($_POST['submitSaveReturnWriting'])) {
                     $block['TD_ToApprove'] = 0;
                     //header("location:".$returnLink);
                 } elseif (isset($_POST['submitSaveOnline'])) {
                     $block['TD_OnlineTitle'] = $formData['TD_DraftTitle'];
                     $block['TD_OnlineText'] = $formData['TD_DraftText'];
                     $block['TD_ToApprove'] = 0;
                     //header("location:".$returnLink);
                     // index the new text if block online
                     $blockData = $blockSelect->fetchRow($selectBloc);
                     if ($blockData['B_Online'] == 1 && $blockData['PI_Status'] == 1) {
                         $indexData['pageID'] = $blockData['B_PageID'];
                         $indexData['moduleID'] = $blockData['B_ModuleID'];
                         $indexData['contentID'] = $block['TD_ID'];
                         $indexData['languageID'] = $block['TD_LanguageID'];
                         $indexData['title'] = $blockData['PI_PageTitle'];
                         $indexData['text'] = '';
                         $indexData['link'] = '';
                         $indexData['contents'] = $blockData['PI_PageTitle'] . " " . $block['TD_OnlineText'];
                         $indexData['action'] = 'update';
                         Cible_FunctionsIndexation::indexation($indexData);
                     }
                 } else {
                     $returnLink = "";
                 }
                 $block['TD_DraftTitle'] = $formData['TD_DraftTitle'];
                 $block['TD_DraftText'] = $formData['TD_DraftText'];
                 $block->save();
                 $oPage = new PagesObject();
                 $pageData['P_ID'] = $_pageid;
                 $pageData['PI_PageTitle'] = $formData['PI_PageTitle'];
                 $oPage->save($_pageid, $pageData, $this->_currentEditLanguage);
                 //if($returnLink <> "")
                 //$this->_redirect("/page/index/index/ID/$_pageid");
             }
         }
         $this->view->assign('form', $form);
         $this->view->assign('pageId', $_pageid);
         $this->view->assign('onlineTitle', isset($block['TD_OnlineTitle']) ? $block['TD_OnlineTitle'] : '');
         $this->view->assign('onlineText', isset($block['TD_OnlineText']) ? $block['TD_OnlineText'] : '');
     }
 }
Exemple #2
0
 /**
  * Set default values and the first level container (ul)
  *
  * @param Mixed $menu    If String: Fecth menu data according its name.<br/>
  *                       If Array: It must contain the menu tree.
  *
  * @param array $options Options to manage menu behaviour<br />
  *                       Ex: disable_nesting => true, parentAltId => (string)
  *
  * @return string html code to display the menu and is children
  */
 public function menu($menu, $options = array())
 {
     $this->_addSeparator = "";
     $menuItem = array();
     $_menu = "";
     if (isset($options['addEnclosure'])) {
         $this->_addEnclosure = $options['addEnclosure'];
     }
     if (isset($options['class']) && $options['class'] == 'sitemap') {
         $this->_isSiteMap = true;
     } else {
         $this->_isSiteMap = false;
     }
     if ($this->view->selectedPage) {
         $this->_selectedPage = $this->view->selectedPage;
     } elseif (Zend_Registry::isRegistered('selectedPage')) {
         $this->_selectedPage = Zend_Registry::get('selectedPage');
     } else {
         $params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
         $this->_selectedPage = $params['controller'];
         if ($params['controller'] == 'index') {
             $this->_selectedPage = Cible_FunctionsPages::getPageNameByID(1);
         }
     }
     if (isset($options['addSeparator'])) {
         $this->_addSeparator = $options['addSeparator'];
     }
     $oPages = new PagesObject();
     $pageData = $oPages->pageIdByController($this->_selectedPage);
     $this->_selectedPageId = $pageData['P_ID'];
     if (!is_array($menu)) {
         $_menu = new MenuObject($menu);
         $parentId = isset($options['parentId']) ? $options['parentId'] : 0;
         $tree = $_menu->populate($parentId);
     } elseif (count($menu) > 1 && empty($menu['MID_MenuID'])) {
         $tree = $menu;
     } else {
         $_menu = new MenuObject($menu['MID_MenuID']);
         unset($menu['MID_MenuID'], $menu['MID_ParentId']);
         $tree = $menu;
         if (Zend_Registry::isRegistered('selectedCatalogPage')) {
             $currentUrl = preg_replace('#\\/page\\/[0-9]*#', '', substr($this->view->request->getPathInfo(), 1));
             if (strrpos($currentUrl, '/') == 1) {
                 $currentUrl = substr($currentUrl, -1);
             }
             $nbParts = substr_count($currentUrl, '/');
             if ($nbParts >= 3) {
                 $lastPos = strrpos($currentUrl, '/');
                 $currentUrl = substr($this->view->request->getPathInfo(), 1, $lastPos);
             } elseif ($nbParts == 0) {
                 $currentUrl = $tree[0]['Link'];
             }
             $this->_selectedPage = $currentUrl;
         }
     }
     if (is_object($_menu) && $_menu->getId()) {
         $menuItem = $_menu->getMenuItemByPageId($this->_selectedPageId);
     }
     if ($menuItem) {
         $this->_getParentsMenuId($menuItem, $_menu);
         $this->view->assign('menuId', $menuItem['MID_MenuID']);
     }
     if (is_array($options)) {
         $parentId = isset($options['parentId']) ? $options['parentId'] : 0;
         $this->_parent_alt_id = isset($options['parentIdAlt']) ? $options['parentIdAlt'] : "parentid-";
     }
     if (!empty($options['startLevel'])) {
         $this->_startLevel = $options['startLevel'];
     }
     $this->_disable_nesting = isset($options['disable_nesting']) && $options['disable_nesting'] == true ? true : false;
     parent::tree($tree, $options);
     // var_dump($tree);
     if ($tree) {
         return "<ul id='{$this->_ul_id}' class='{$this->_class}' {$this->_attribs}>" . $this->generateList($tree, true) . "</ul>";
     }
 }
Exemple #3
0
 /**
  * Set default values and the first level container (ul)
  *
  * @param Mixed $menu    If String: Fecth menu data according its name.<br/>
  *                       If Array: It must contain the menu tree.
  *
  * @param array $options Options to manage menu behaviour<br />
  *                       Ex: disable_nesting => true, parentAltId => (string)
  *
  * @return string html code to display the menu and is children
  */
 public function subMenu($options = array())
 {
     if (isset($options['addEnclosure'])) {
         $this->_addEnclosure = $options['addEnclosure'];
     }
     if ($this->view->selectedPage) {
         $this->_selectedPage = $this->view->selectedPage;
     } elseif (Zend_Registry::isRegistered('selectedPage')) {
         $this->_selectedPage = Zend_Registry::get('selectedPage');
     } else {
         $params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
         $this->_selectedPage = $params['controller'];
         if ($params['controller'] == 'index') {
             $this->_selectedPage = Cible_FunctionsPages::getPageNameByID(1);
         }
     }
     $oPages = new PagesObject();
     $pageData = $oPages->pageIdByController($this->_selectedPage);
     $this->_selectedPageId = $pageData['P_ID'];
     $menuData = $oPages->getRelatedMenu($this->_selectedPageId);
     $parentId = 0;
     if (!$menuData) {
         $parentId = $oPages->getParentRelatedID($this->_selectedPageId);
         $parentName = $oPages->getParentRelatedName($parentId);
         $menuData = $oPages->getRelatedMenu($parentId);
         $this->_selectedPageId = $parentId;
         $parentId = $menuData['MID_ParentID'];
         $this->view->assign('selectedPage', $parentName);
         //echo $parentName;
     }
     $_menu = new MenuObject($menuData['MID_MenuId']);
     if ($menuData['MID_ParentID'] == 0) {
         $parentId = $menuData['MID_ID'];
     } else {
         $menuItem = $_menu->getMenuItemByPageId($this->_selectedPageId);
         if ($menuItem) {
             $this->_getParentsMenuId($menuItem, $_menu);
         }
         if ($parentId == 0) {
             $parentId = $this->_parentsMenuId[0];
         }
     }
     if (!empty($options['parentId'])) {
         $parentId = $options['parentId'];
     }
     if (preg_match('/useCatalog/', $menuData['MID_Style'])) {
         $menu_item['Placeholder'] = 2;
         $collections = new SubCategoriesObject();
         //                $menuCatalog = $this->getMenuItemByPageId( null, 'collections');
         $catalogMenu = $collections->buildCatalogMenu($menu_item, array('nesting' => 1));
         $tree = $catalogMenu['child'];
         //               $first = $this->populate($menuCatalog['MID_ID']);
         //               $childCombined = array();
         //                   $childCombined = array_merge($catalogMenu['child'], $first);
         //                   $catalog['child'] = $childCombined;
     } elseif (!empty($parentId)) {
         $tree = $_menu->populate($parentId);
     }
     $tree['MID_MenuID'] = $menuData['MID_MenuId'];
     $tree['MID_ParentId'] = $parentId;
     return $tree;
 }