changeset 1103 | 90225c988124 |
parent 1099 | 73abd46f5148 |
child 1121 | bf5adc446018 |
1102:faef5e62e1e0 | 1103:90225c988124 |
---|---|
1 <?php |
1 <?php |
2 |
2 |
3 /** |
3 /** |
4 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
4 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
5 * Version 1.1.6 (Caoineag beta 1) |
5 * Copyright (C) 2006-2009 Dan Fuhry |
6 * Copyright (C) 2006-2008 Dan Fuhry |
|
7 * paths.php - The part of Enano that actually manages content. Everything related to page handling and namespaces is in here. |
6 * paths.php - The part of Enano that actually manages content. Everything related to page handling and namespaces is in here. |
8 * |
7 * |
9 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
8 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
10 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
9 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
11 * |
10 * |
17 * @see http://enanocms.org/Help:API_Documentation |
16 * @see http://enanocms.org/Help:API_Documentation |
18 */ |
17 */ |
19 |
18 |
20 class pathManager |
19 class pathManager |
21 { |
20 { |
22 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; |
23 |
22 |
24 /** |
23 /** |
25 * 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. |
26 * @access private |
25 * @access private |
27 * @var array |
26 * @var array |
117 |
116 |
118 $this->wiki_mode = ( getConfig('wiki_mode') == '1' ) ? 1 : 0; |
117 $this->wiki_mode = ( getConfig('wiki_mode') == '1' ) ? 1 : 0; |
119 $this->template_cache = Array(); |
118 $this->template_cache = Array(); |
120 } |
119 } |
121 |
120 |
122 function parse_url($sanitize = true) |
121 function init($title) |
123 { |
|
124 $title = ''; |
|
125 if ( isset($_GET['title']) ) |
|
126 { |
|
127 $title = $_GET['title']; |
|
128 } |
|
129 else if ( isset($_SERVER['PATH_INFO']) ) |
|
130 { |
|
131 // fix for apache + CGI (occurred on a GoDaddy server, thanks mm3) |
|
132 if ( @substr(@$_SERVER['GATEWAY_INTERFACE'], 0, 3) === 'CGI' && $_SERVER['PATH_INFO'] == scriptPath . '/index.php' ) |
|
133 { |
|
134 // do nothing; ignore PATH_INFO |
|
135 } |
|
136 else |
|
137 { |
|
138 $title = substr($_SERVER['PATH_INFO'], ( strpos($_SERVER['PATH_INFO'], '/') ) + 1 ); |
|
139 } |
|
140 } |
|
141 else |
|
142 { |
|
143 // This method really isn't supported because apache has a habit of passing dots as underscores, thus corrupting the request |
|
144 // If you really want to try it, the URI format is yoursite.com/?/Page_title |
|
145 if ( !empty($_SERVER['QUERY_STRING']) && substr($_SERVER['QUERY_STRING'], 0, 1) == '/' ) |
|
146 { |
|
147 $pos = ( ($_ = strpos($_SERVER['QUERY_STRING'], '&')) !== false ) ? $_ - 1: 0x7FFFFFFF; |
|
148 $title = substr($_SERVER['QUERY_STRING'], 1, $pos); |
|
149 } |
|
150 } |
|
151 return ( $sanitize ) ? sanitize_page_id($title) : $title; |
|
152 } |
|
153 |
|
154 function init() |
|
155 { |
122 { |
156 global $db, $session, $paths, $template, $plugins; // Common objects |
123 global $db, $session, $paths, $template, $plugins; // Common objects |
157 global $lang; |
124 global $lang; |
158 global $cache; |
125 global $cache; |
159 |
126 |
163 eval($cmd); |
130 eval($cmd); |
164 } |
131 } |
165 |
132 |
166 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') ) |
167 { |
134 { |
168 $title = $this->parse_url(false); |
135 if ( empty($title) ) |
136 $title = get_title(); |
|
137 |
|
169 if ( empty($title) && get_main_page() != '' ) |
138 if ( empty($title) && get_main_page() != '' ) |
170 { |
139 { |
171 $this->main_page(); |
140 $this->main_page(); |
172 } |
141 } |
173 if ( strstr($title, ' ') || strstr($title, '+') || strstr($title, '%20') ) |
142 if ( strstr($title, ' ') || strstr($title, '+') || strstr($title, '%20') ) |
469 |
438 |
470 return $message; |
439 return $message; |
471 } |
440 } |
472 function get_pageid_from_url() |
441 function get_pageid_from_url() |
473 { |
442 { |
474 $url = $this->parse_url(); |
443 return get_title(true, true); |
475 if ( substr($url, 0, strlen($this->nslist['Special'])) == $this->nslist['Special'] || |
|
476 substr($url, 0, strlen($this->nslist['Admin'])) == $this->nslist['Admin']) |
|
477 { |
|
478 list(, $ns) = RenderMan::strToPageID($url); |
|
479 $upart = substr($url, strlen($this->nslist[$ns])); |
|
480 list($upart) = explode('/', $upart); |
|
481 $url = $this->nslist[$ns] . $upart; |
|
482 } |
|
483 return $url; |
|
484 } |
444 } |
485 // 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 |
486 function parseAdminTree() |
446 function parseAdminTree() |
487 { |
447 { |
488 global $lang; |
448 global $lang; |
589 'icon' => $icon |
549 'icon' => $icon |
590 ); |
550 ); |
591 } |
551 } |
592 function getParam($id = 0) |
552 function getParam($id = 0) |
593 { |
553 { |
594 $title = $this->parse_url(false); |
554 $title = $this->fullpage; |
595 list(, $ns) = RenderMan::strToPageID($title); |
555 list(, $ns) = RenderMan::strToPageID($title); |
596 $title = substr($title, strlen($this->nslist[$ns])); |
556 $title = substr($title, strlen($this->nslist[$ns])); |
597 $regex = '/^' . str_replace('/', '\\/', preg_quote($this->nslist[$ns])) . '\\/?/'; |
557 $regex = '/^' . str_replace('/', '\\/', preg_quote($this->nslist[$ns])) . '\\/?/'; |
598 $title = preg_replace($regex, '', $title); |
558 $title = preg_replace($regex, '', $title); |
599 $title = explode('/', $title); |
559 $title = explode('/', $title); |
601 return ( isset($title[$id]) ) ? $title[$id] : false; |
561 return ( isset($title[$id]) ) ? $title[$id] : false; |
602 } |
562 } |
603 |
563 |
604 function getAllParams() |
564 function getAllParams() |
605 { |
565 { |
606 $title = $this->parse_url(false); |
566 $title = $this->fullpage; |
607 $regex = '/^' . str_replace('/', '\\/', preg_quote($this->nslist[$this->namespace])) . '\\/?/'; |
567 $regex = '/^' . str_replace('/', '\\/', preg_quote($this->nslist[$this->namespace])) . '\\/?/'; |
608 $title = preg_replace($regex, '', $title); |
568 $title = preg_replace($regex, '', $title); |
609 $title = explode('/', $title); |
569 $title = explode('/', $title); |
610 unset($title[0]); |
570 unset($title[0]); |
611 return implode('/', $title); |
571 return implode('/', $title); |