• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

cms/parseurl.lib.php

Go to the documentation of this file.
00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 { 
00004         header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005         echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006         echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007         exit(1);
00008 }
00025  function parseUrlReal($url, &$pageids) { 
00026         $url = rtrim($url, '/');
00027         $urlPieces = explode('/', $url); 
00028         //$printer = print_r($pageids,true);
00029         //$printer2 = print_r($urlPieces,true);
00030         $pagesTable = MYSQL_DATABASE_PREFIX."pages";
00031 
00040         $selectString = "SELECT node0.page_id AS pageid0";
00041   $fromString=" FROM `$pagesTable` AS node0";
00042   $whereString=" WHERE node0.page_id=node0.page_parentid";
00043   for($i = 1; $i < count($urlPieces); $i++) {
00044                 if($urlPieces[$i] != "") {
00045                         $selectString.=", node".$i.".page_id AS pageid".$i;
00046                         $fromString.=", `$pagesTable` as node".$i;
00047                         $whereString.=" and node".$i.".page_parentid = IF(node".($i - 1).".page_module = 'link', node".($i - 1).".page_modulecomponentid, node".($i - 1).".page_id) and node".$i.".page_name='".$urlPieces[$i]."'";
00048           }
00049         }
00050         $pageid_query = $selectString.$fromString.$whereString;
00051         if($pageid_result = mysql_query($pageid_query)) {
00052                 if(!($pageids = mysql_fetch_row($pageid_result))) {
00053                         displayerror("The requested page does not exist.");
00054                         return false;
00055                 }
00056         }
00057         return $pageids[count($pageids) - 1];
00058 }
00059 
00060  /* The following fails to work in Mysql 4.1.10 : theyaga's mysql account*/
00061  /* (The AS node0 gives an error)
00062 function parseUrlReal($url, &$pageIdArray) {
00063         $url = trim($url, '/');
00064         $urlPieces = array();
00065         if($url != '') {
00066         $urlPieces = explode('/', $url);
00067         }
00068         $pieceCount = count($urlPieces);
00069 
00070         $pages[] = '`node0`.`page_id` AS `pageid0`';
00071         $nodes[] = '(SELECT `page_id`, `page_parentid`, `page_module`, `page_modulecomponentid` FROM `'.MYSQL_DATABASE_PREFIX.'pages` WHERE `page_id` = `page_parentid`) AS `node0`';
00072         $conditions = array();
00073         
00074         for($i = 1; $i <= $pieceCount; $i++) {
00075                 $pages[] = '`node'.$i.'`.`page_id` AS `pageid'.$i.'`';
00076                 $nodes[] = '(SELECT `page_id`, `page_parentid`, `page_module`, `page_modulecomponentid` FROM `'.MYSQL_DATABASE_PREFIX.'pages` WHERE `page_name` = \''.$urlPieces[$i - 1].'\') AS `node'.$i.'`';
00077                 $conditions[] = 'IF(`node'.($i - 1).'`.`page_module` = \'link\', `node'.($i - 1).'`.`page_modulecomponentid`, `node'.($i - 1).'`.`page_id`) = `node'.$i.'`.`page_parentid`';
00078         }
00079 
00080         $pageIdQuery = 'SELECT ' . join($pages, ', ') . ' FROM (' . join($nodes, ', ') . ')';
00081         if(count($conditions) > 0)
00082                 $pageIdQuery .= ' WHERE ' . join($conditions, ' AND ');
00083 
00084         $pageIdResult = mysql_query($pageIdQuery);
00085 
00086         if(!$pageIdResult || !($pageIdArray = mysql_fetch_row($pageIdResult))) {
00087                 displayerror("The requested page does not exist.");
00088                 return false;
00089         }
00090 
00091         return $pageIdArray[count($pageIdArray) - 1];
00092 }
00093 */
00094 
00095 
00102 function parseUrlDereferenced($pageid, &$pageids) {
00103         $dereferencedPageId = getDereferencedPageId($pageid);
00104         $parentId = getParentPage($dereferencedPageId);
00105         $pageids = array($dereferencedPageId);
00106 
00107         while($parentId != $dereferencedPageId) {
00108                 $pageids[] = $parentId;
00109                 $dereferencedPageId = getDereferencedPageId($parentId);
00110                 $parentId = getParentPage($dereferencedPageId);
00111                 if($dereferencedPageId==0)      break;
00112         }
00113         if($parentId != 0)
00114                 displayerror("Looping condition detected!!");
00115         $pageids = array_reverse($pageids);
00116 }
00117 
00118  /*
00119   * If there is a link /events/dalalstreet/information at /events/dalalinfo
00120   * And a page /events/dalalstreet/information/a exists, then even /events/dalalinfo exists
00121   *
00122   * For parseUrl :
00123   *     For breadcrumb and menubar: (Real)
00124   *             will follow the actual textual path ids. But children of all links will be found out from the
00125   *             linked page. i.e. while going from root to child page, if we encounter any links, to find
00126   *             its children we look for children of "linked" page and not the "link" page.
00127   *
00128   *     For permissions : (Dereferenced)
00129   *             we need a path array to find permission of a page. To find the permission of a page,
00130   *             first we dereference all links to actual page and then find the permissions. One way of
00131   *             doing it is to find the target page id and keep recursively going up until we reach root.
00132   */
00133 
00134 

Generated on Sun Jan 2 2011 04:55:32 for Pragyan CMS by  doxygen 1.7.1