changeset 1099 | 73abd46f5148 |
parent 1081 | 745200a9cc2a |
child 1121 | bf5adc446018 |
1098:be6cfe79128c | 1099:73abd46f5148 |
---|---|
16 * @see http://enanocms.org/Help:API_Documentation |
16 * @see http://enanocms.org/Help:API_Documentation |
17 */ |
17 */ |
18 |
18 |
19 class pathManager |
19 class pathManager |
20 { |
20 { |
21 public $pages, $custom_page, $cpage, $page, $fullpage, $page_exists, $page_id, $namespace, $nslist, $admin_tree, $wiki_mode, $page_protected, $template_cache, $external_api_page; |
21 public $title, $pages, $custom_page, $cpage, $page, $fullpage, $page_exists, $page_id, $namespace, $nslist, $admin_tree, $wiki_mode, $page_protected, $template_cache, $external_api_page; |
22 |
22 |
23 /** |
23 /** |
24 * List of custom processing functions for namespaces. This is protected so trying to do anything with it will throw an error. |
24 * List of custom processing functions for namespaces. This is protected so trying to do anything with it will throw an error. |
25 * @access private |
25 * @access private |
26 * @var array |
26 * @var array |
116 |
116 |
117 $this->wiki_mode = ( getConfig('wiki_mode') == '1' ) ? 1 : 0; |
117 $this->wiki_mode = ( getConfig('wiki_mode') == '1' ) ? 1 : 0; |
118 $this->template_cache = Array(); |
118 $this->template_cache = Array(); |
119 } |
119 } |
120 |
120 |
121 function parse_url($sanitize = true) |
121 function init($title) |
122 { |
|
123 $title = ''; |
|
124 if ( isset($_GET['title']) ) |
|
125 { |
|
126 $title = $_GET['title']; |
|
127 } |
|
128 else if ( isset($_SERVER['PATH_INFO']) ) |
|
129 { |
|
130 // fix for apache + CGI (occurred on a GoDaddy server, thanks mm3) |
|
131 if ( @substr(@$_SERVER['GATEWAY_INTERFACE'], 0, 3) === 'CGI' && $_SERVER['PATH_INFO'] == scriptPath . '/index.php' ) |
|
132 { |
|
133 // do nothing; ignore PATH_INFO |
|
134 } |
|
135 else |
|
136 { |
|
137 $title = substr($_SERVER['PATH_INFO'], ( strpos($_SERVER['PATH_INFO'], '/') ) + 1 ); |
|
138 } |
|
139 } |
|
140 else |
|
141 { |
|
142 // This method really isn't supported because apache has a habit of passing dots as underscores, thus corrupting the request |
|
143 // If you really want to try it, the URI format is yoursite.com/?/Page_title |
|
144 if ( !empty($_SERVER['QUERY_STRING']) && substr($_SERVER['QUERY_STRING'], 0, 1) == '/' ) |
|
145 { |
|
146 $pos = ( ($_ = strpos($_SERVER['QUERY_STRING'], '&')) !== false ) ? $_ - 1: 0x7FFFFFFF; |
|
147 $title = substr($_SERVER['QUERY_STRING'], 1, $pos); |
|
148 } |
|
149 } |
|
150 return ( $sanitize ) ? sanitize_page_id($title) : $title; |
|
151 } |
|
152 |
|
153 function init() |
|
154 { |
122 { |
155 global $db, $session, $paths, $template, $plugins; // Common objects |
123 global $db, $session, $paths, $template, $plugins; // Common objects |
156 global $lang; |
124 global $lang; |
157 global $cache; |
125 global $cache; |
158 |
126 |
162 eval($cmd); |
130 eval($cmd); |
163 } |
131 } |
164 |
132 |
165 if ( defined('ENANO_INTERFACE_INDEX') || defined('ENANO_INTERFACE_AJAX') || defined('IN_ENANO_UPGRADE') ) |
133 if ( defined('ENANO_INTERFACE_INDEX') || defined('ENANO_INTERFACE_AJAX') || defined('IN_ENANO_UPGRADE') ) |
166 { |
134 { |
167 $title = $this->parse_url(false); |
135 if ( empty($title) ) |
136 $title = get_title(); |
|
137 |
|
168 if ( empty($title) && get_main_page() != '' ) |
138 if ( empty($title) && get_main_page() != '' ) |
169 { |
139 { |
170 $this->main_page(); |
140 $this->main_page(); |
171 } |
141 } |
172 if ( strstr($title, ' ') || strstr($title, '+') || strstr($title, '%20') ) |
142 if ( strstr($title, ' ') || strstr($title, '+') || strstr($title, '%20') ) |
468 |
438 |
469 return $message; |
439 return $message; |
470 } |
440 } |
471 function get_pageid_from_url() |
441 function get_pageid_from_url() |
472 { |
442 { |
473 $url = $this->parse_url(); |
443 return get_title(true, true); |
474 if ( substr($url, 0, strlen($this->nslist['Special'])) == $this->nslist['Special'] || |
|
475 substr($url, 0, strlen($this->nslist['Admin'])) == $this->nslist['Admin']) |
|
476 { |
|
477 list(, $ns) = RenderMan::strToPageID($url); |
|
478 $upart = substr($url, strlen($this->nslist[$ns])); |
|
479 list($upart) = explode('/', $upart); |
|
480 $url = $this->nslist[$ns] . $upart; |
|
481 } |
|
482 return $url; |
|
483 } |
444 } |
484 // Parses a (very carefully formed) array into Javascript code compatible with the Tigra Tree Menu used in the admin menu |
445 // Parses a (very carefully formed) array into Javascript code compatible with the Tigra Tree Menu used in the admin menu |
485 function parseAdminTree() |
446 function parseAdminTree() |
486 { |
447 { |
487 global $lang; |
448 global $lang; |
588 'icon' => $icon |
549 'icon' => $icon |
589 ); |
550 ); |
590 } |
551 } |
591 function getParam($id = 0) |
552 function getParam($id = 0) |
592 { |
553 { |
593 $title = $this->parse_url(false); |
554 $title = $this->fullpage; |
594 list(, $ns) = RenderMan::strToPageID($title); |
555 list(, $ns) = RenderMan::strToPageID($title); |
595 $title = substr($title, strlen($this->nslist[$ns])); |
556 $title = substr($title, strlen($this->nslist[$ns])); |
596 $regex = '/^' . str_replace('/', '\\/', preg_quote($this->nslist[$ns])) . '\\/?/'; |
557 $regex = '/^' . str_replace('/', '\\/', preg_quote($this->nslist[$ns])) . '\\/?/'; |
597 $title = preg_replace($regex, '', $title); |
558 $title = preg_replace($regex, '', $title); |
598 $title = explode('/', $title); |
559 $title = explode('/', $title); |
600 return ( isset($title[$id]) ) ? $title[$id] : false; |
561 return ( isset($title[$id]) ) ? $title[$id] : false; |
601 } |
562 } |
602 |
563 |
603 function getAllParams() |
564 function getAllParams() |
604 { |
565 { |
605 $title = $this->parse_url(false); |
566 $title = $this->fullpage; |
606 $regex = '/^' . str_replace('/', '\\/', preg_quote($this->nslist[$this->namespace])) . '\\/?/'; |
567 $regex = '/^' . str_replace('/', '\\/', preg_quote($this->nslist[$this->namespace])) . '\\/?/'; |
607 $title = preg_replace($regex, '', $title); |
568 $title = preg_replace($regex, '', $title); |
608 $title = explode('/', $title); |
569 $title = explode('/', $title); |
609 unset($title[0]); |
570 unset($title[0]); |
610 return implode('/', $title); |
571 return implode('/', $title); |