Example #1
0
 /** 
  * Returns a link to a page
  * @param Page $cObj
  * @return string $link
  */
 public function getLinkToCollection(&$cObj, $appendBaseURL = false, $ignoreUrlRewriting = false)
 {
     // basically returns a link to a collection, based on whether or we have
     // mod_rewrite enabled, and the collection has a path
     $dispatcher = '';
     if (!defined('URL_REWRITING_ALL') || URL_REWRITING_ALL == false) {
         if (!URL_REWRITING || $ignoreUrlRewriting) {
             $dispatcher = '/' . DISPATCHER_FILENAME;
         }
     }
     if ($cObj->isExternalLink() && $appendBaseURL == false) {
         $link = $cObj->getCollectionPointerExternalLink();
         return $link;
     }
     if ($cObj->getCollectionPath() != null) {
         $link = DIR_REL . $dispatcher . $cObj->getCollectionPath() . '/';
     } else {
         $_cID = $cObj->getCollectionPointerID() > 0 ? $cObj->getCollectionPointerOriginalID() : $cObj->getCollectionID();
         if ($_cID > 1) {
             $link = DIR_REL . $dispatcher . '?cID=' . $_cID;
         } else {
             $link = DIR_REL . '/';
         }
     }
     if ($appendBaseURL) {
         $link = BASE_URL . $link;
     }
     return $link;
 }
Example #2
0
 /** Returns the cID for the page. If $page is an alias it returns the cID of the original page.
  * @param Page $page The Page instance for which you want the original Page.
  * @param int $aliasLevel [out] Will be set to: 0 if $page is not an alias, 1 if $page is an alias (but not the current page), 2 if $page is an alias and it's the current page.
  * @return int Returns the cID of the original page.
  */
 private static function getOriginal_cID($page, &$aliasLevel = null)
 {
     $cID = (int) $page->cID;
     if ($page->isAlias()) {
         $aliasOf = (int) $page->getCollectionPointerID();
         if ($aliasOf != $cID) {
             $aliasLevel = 1;
             return $aliasOf;
         } else {
             // This happens if $page is an alias and it's the current page.
             $aliasLevel = 2;
         }
     } else {
         $aliasLevel = 0;
     }
     return $cID;
 }