Ejemplo n.º 1
0
 function deleteAction()
 {
     $this->view->title = "Supprimer une page";
     // retrieve the ID of the parent page
     $PageID = $this->_getParam('ID');
     if (Cible_ACL::hasAccess($PageID)) {
         // generates tree by Language and send the result to the view
         Zend_Registry::set('baseUrl', $this->view->baseUrl());
         $this->view->TreeView = $this->view->getTreeView();
         if ($this->_request->isPost()) {
             //$PageID = (int)$this->_request->getPost('PageID');
             // if is set delete, then delete
             $delete = isset($_POST['delete']);
             if ($delete && $PageID > 0) {
                 Cible_FunctionsPages::deleteAllChildPage($PageID);
                 Cible_FunctionsPages::deleteAllBlock($PageID);
                 $pageSelect = new PagesIndex();
                 $select = $pageSelect->select()->where('PI_PageID = ?', $PageID);
                 $pageData = $pageSelect->fetchAll($select)->toArray();
                 foreach ($pageData as $page) {
                     $indexData['moduleID'] = 0;
                     $indexData['contentID'] = $PageID;
                     $indexData['languageID'] = $page['PI_LanguageID'];
                     $indexData['action'] = 'delete';
                     Cible_FunctionsIndexation::indexation($indexData);
                 }
                 $Page = new Pages();
                 $Where = 'P_ID = ' . $PageID;
                 $Page->delete($Where);
                 $PageIndex = new PagesIndex();
                 $Where = 'PI_PageID = ' . $PageID;
                 $PageIndex->delete($Where);
                 if (!$this->_request->isXmlHttpRequest()) {
                     $this->_redirect('/');
                 }
             } else {
                 if (!$this->_isXmlHttpRequest) {
                     $this->_redirect('/page/edit/ID/' . $PageID);
                 }
             }
         } else {
             if ($PageID > 0) {
                 $Page = new Pages();
                 $this->view->page = $Page->fetchRow('P_ID=' . $PageID);
                 $PageIndex = new PagesIndex();
                 $Select = $PageIndex->select()->where("PI_PageID = ?", $PageID)->where("PI_LanguageID = ?", $this->_defaultEditLanguage);
                 $this->view->pageindex = $PageIndex->fetchRow($Select);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public static function deleteAllChildPage($ParentID)
 {
     if ($ParentID != 0) {
         $Pages = new Pages();
         $Select = $Pages->select()->where("P_ParentID = ?", $ParentID);
         $PageArray = $Pages->fetchAll($Select);
         foreach ($PageArray as $Page) {
             $PageID = $Page["P_ID"];
             Cible_FunctionsPages::deleteAllChildPage($PageID);
             Cible_FunctionsPages::deleteAllBlock($PageID);
             $pageSelect = new PagesIndex();
             $select = $pageSelect->select()->where('PI_PageID = ?', $PageID);
             $pageData = $pageSelect->fetchAll($select)->toArray();
             foreach ($pageData as $page) {
                 $indexData['moduleID'] = 0;
                 $indexData['contentID'] = $PageID;
                 $indexData['languageID'] = $page['PI_LanguageID'];
                 $indexData['action'] = 'delete';
                 Cible_FunctionsIndexation::indexation($indexData);
             }
             $PageObj = new Pages();
             $Where = 'P_ID = ' . $PageID;
             $PageObj->delete($Where);
             $PageIndex = new PagesIndex();
             $Where = 'PI_PageID = ' . $PageID;
             $PageIndex->delete($Where);
             //echo("DELETE PAGE : ".$Page["P_ID"]."<br/>");
             //echo("DELETE PAGEINDEX : ".$Page["P_ID"]."<br/>");
         }
     }
 }