Example #1
0
 /**
  * Make an alias to a page
  * @param Collection $c
  * @return int $newCID
  */
 function addCollectionAlias($c)
 {
     $db = Loader::db();
     // the passed collection is the parent collection
     $cParentID = $c->getCollectionID();
     $u = new User();
     $uID = $u->getUserID();
     $ctID = 0;
     $dh = Loader::helper('date');
     $cDate = $dh->getSystemDateTime();
     $cDatePublic = $dh->getSystemDateTime();
     $handle = $this->getCollectionHandle();
     $cDisplayOrder = $c->getNextSubPageDisplayOrder();
     $_cParentID = $c->getCollectionID();
     $q = "select PagePaths.cPath from PagePaths where cID = '{$_cParentID}'";
     if ($_cParentID > 1) {
         $q .= " and ppIsCanonical = 1";
     }
     $cPath = $db->getOne($q);
     $data['handle'] = $this->getCollectionHandle();
     $data['name'] = $this->getCollectionName();
     $cobj = parent::add($data);
     $newCID = $cobj->getCollectionID();
     $v = array($newCID, $cParentID, $uID, $this->getCollectionID(), $cDisplayOrder);
     $q = "insert into Pages (cID, cParentID, uID, cPointerID, cDisplayOrder) values (?, ?, ?, ?, ?)";
     $r = $db->prepare($q);
     $res = $db->execute($r, $v);
     Loader::model('page_statistics');
     PageStatistics::incrementParents($newCID);
     $q2 = "insert into PagePaths (cID, cPath) values (?, ?)";
     $v2 = array($newCID, $cPath . '/' . $handle);
     $db->query($q2, $v2);
     return $newCID;
 }