Exemplo n.º 1
0
 public function delete()
 {
     $cID = $this->getCollectionID();
     if ($this->isAlias() && !$this->isExternalLink()) {
         $this->removeThisAlias();
         return;
     }
     if ($cID <= 1) {
         return false;
     }
     $db = Database::get();
     // run any internal event we have for page deletion
     $pe = new DeletePageEvent($this);
     Events::dispatch('on_page_delete', $pe);
     if (!$pe->proceed()) {
         return false;
     }
     Log::addEntry(t('Page "%s" at path "%s" deleted', $this->getCollectionName(), $this->getCollectionPath()), t('Page Action'));
     parent::delete();
     $cID = $this->getCollectionID();
     // Now that all versions are gone, we can delete the collection information
     $q = "delete from PagePaths where cID = '{$cID}'";
     $r = $db->query($q);
     // remove all pages where the pointer is this cID
     $r = $db->query('select cID from Pages where cPointerID = ?', array($cID));
     while ($row = $r->fetchRow()) {
         PageStatistics::decrementParents($row['cID']);
         $db->Execute('DELETE FROM PagePaths WHERE cID=?', array($row['cID']));
     }
     // Update cChildren for cParentID
     PageStatistics::decrementParents($cID);
     $q = "delete from PagePermissionAssignments where cID = '{$cID}'";
     $r = $db->query($q);
     $q = "delete from Pages where cID = '{$cID}'";
     $r = $db->query($q);
     $q = "delete from Pages where cPointerID = '{$cID}'";
     $r = $db->query($q);
     $q = "delete from Areas WHERE cID = '{$cID}'";
     $r = $db->query($q);
     $db->query('delete from PageSearchIndex where cID = ?', array($cID));
     $q = "select cID from Pages where cParentID = '{$cID}'";
     $r = $db->query($q);
     if ($r) {
         while ($row = $r->fetchRow()) {
             if ($row['cID'] > 0) {
                 $nc = Page::getByID($row['cID']);
                 $nc->delete();
             }
         }
     }
     if (\Core::make('multilingual/detector')->isEnabled()) {
         Section::unregisterPage($this);
     }
     $cache = PageCache::getLibrary();
     $cache->purge($this);
 }
Exemplo n.º 2
0
 function delete()
 {
     $cID = $this->getCollectionID();
     if ($cID <= 1) {
         return false;
     }
     $db = Loader::db();
     // run any internal event we have for page deletion
     $pe = new Event($this);
     Events::dispatch('on_page_delete', $pe);
     if ($ret < 0) {
         return false;
     }
     Log::addEntry(t('Page "%s" at path "%s" deleted', $this->getCollectionName(), $this->getCollectionPath()), t('Page Action'));
     parent::delete();
     $cID = $this->getCollectionID();
     $cParentID = $this->getCollectionParentID();
     // Now that all versions are gone, we can delete the collection information
     $q = "delete from PagePaths where cID = '{$cID}'";
     $r = $db->query($q);
     // remove all pages where the pointer is this cID
     $r = $db->query("select cID from Pages where cPointerID = ?", array($cID));
     while ($row = $r->fetchRow()) {
         PageStatistics::decrementParents($row['cID']);
         $db->Execute('DELETE FROM PagePaths WHERE cID=?', array($row['cID']));
     }
     // Update cChildren for cParentID
     PageStatistics::decrementParents($cID);
     $q = "delete from PagePermissionAssignments where cID = '{$cID}'";
     $r = $db->query($q);
     $q = "delete from Pages where cID = '{$cID}'";
     $r = $db->query($q);
     $q = "delete from Pages where cPointerID = '{$cID}'";
     $r = $db->query($q);
     $q = "delete from Areas WHERE cID = '{$cID}'";
     $r = $db->query($q);
     $db->query('delete from PageSearchIndex where cID = ?', array($cID));
     $q = "select cID from Pages where cParentID = '{$cID}'";
     $r = $db->query($q);
     if ($r) {
         while ($row = $r->fetchRow()) {
             if ($row['cID'] > 0) {
                 $nc = Page::getByID($row['cID']);
                 if ($nc->isAlias()) {
                     $nc->removeThisAlias();
                 } else {
                     $nc->delete();
                 }
             }
         }
     }
     $cache = PageCache::getLibrary();
     $cache->purge($this);
 }