changeset 326 | ab66d6d1f1f4 |
parent 313 | 854eecfada20 |
parent 325 | e17cc42d77cf |
child 334 | c72b545f1304 |
314:474f8be55943 | 326:ab66d6d1f1f4 |
---|---|
16 * @subpackage PathManager |
16 * @subpackage PathManager |
17 * @see http://enanocms.org/Help:API_Documentation |
17 * @see http://enanocms.org/Help:API_Documentation |
18 */ |
18 */ |
19 |
19 |
20 class pathManager { |
20 class pathManager { |
21 var $pages, $custom_page, $cpage, $page, $fullpage, $page_exists, $namespace, $nslist, $admin_tree, $wiki_mode, $page_protected, $template_cache, $anonymous_page; |
21 var $pages, $custom_page, $cpage, $page, $fullpage, $page_exists, $page_id, $namespace, $nslist, $admin_tree, $wiki_mode, $page_protected, $template_cache, $anonymous_page; |
22 function __construct() |
22 function __construct() |
23 { |
23 { |
24 global $db, $session, $paths, $template, $plugins; // Common objects |
24 global $db, $session, $paths, $template, $plugins; // Common objects |
25 |
25 |
26 $GLOBALS['paths'] =& $this; |
26 $GLOBALS['paths'] =& $this; |
291 |
291 |
292 if(isset($this->pages[$this->page])) |
292 if(isset($this->pages[$this->page])) |
293 { |
293 { |
294 $this->page_exists = true; |
294 $this->page_exists = true; |
295 $this->cpage = $this->pages[$this->page]; |
295 $this->cpage = $this->pages[$this->page]; |
296 $this->page_id =& $this->cpage['urlname_nons']; |
|
296 $this->namespace = $this->cpage['namespace']; |
297 $this->namespace = $this->cpage['namespace']; |
297 if(!isset($this->cpage['wiki_mode'])) $this->cpage['wiki_mode'] = 2; |
298 if(!isset($this->cpage['wiki_mode'])) $this->cpage['wiki_mode'] = 2; |
298 |
299 |
299 // Determine the wiki mode for this page, now that we have this->cpage established |
300 // Determine the wiki mode for this page, now that we have this->cpage established |
300 if($this->cpage['wiki_mode'] == 2) |
301 if($this->cpage['wiki_mode'] == 2) |
339 $page_name = str_replace('_', ' ', $page_name); |
340 $page_name = str_replace('_', ' ', $page_name); |
340 |
341 |
341 $pid_cleaned = sanitize_page_id($this->page); |
342 $pid_cleaned = sanitize_page_id($this->page); |
342 if ( $pid_cleaned != $this->page ) |
343 if ( $pid_cleaned != $this->page ) |
343 { |
344 { |
344 redirect($pid_cleaned, 'Sanitizer message', 'page id sanitized', 0); |
345 redirect(makeUrl($pid_cleaned), 'Sanitizer message', 'page id sanitized', 0); |
345 } |
346 } |
346 |
347 |
347 if ( !is_array($this->cpage) ) |
348 if ( !is_array($this->cpage) ) |
348 { |
349 { |
349 $this->cpage = Array( |
350 $this->cpage = Array( |
373 $this->cpage['wiki_mode'] = 2; |
374 $this->cpage['wiki_mode'] = 2; |
374 } |
375 } |
375 } |
376 } |
376 } |
377 } |
377 $this->namespace = $this->cpage['namespace']; |
378 $this->namespace = $this->cpage['namespace']; |
379 $this->page_id =& $this->cpage['urlname_nons']; |
|
378 |
380 |
379 if($this->namespace=='System') |
381 if($this->namespace=='System') |
380 { |
382 { |
381 $this->cpage['protected'] = 1; |
383 $this->cpage['protected'] = 1; |
382 } |
384 } |
699 |
701 |
700 function fetch_page_search_resource() |
702 function fetch_page_search_resource() |
701 { |
703 { |
702 global $db, $session, $paths, $template, $plugins; // Common objects |
704 global $db, $session, $paths, $template, $plugins; // Common objects |
703 // sha1('') returns "da39a3ee5e6b4b0d3255bfef95601890afd80709" |
705 // sha1('') returns "da39a3ee5e6b4b0d3255bfef95601890afd80709" |
704 $texts = 'SELECT t.page_text, CONCAT(\'ns=\',t.namespace,\';pid=\',t.page_id) AS page_idstring, t.page_id, t.namespace FROM '.table_prefix.'page_text AS t |
706 |
707 $concat_column = ( ENANO_DBLAYER == 'MYSQL' ) ? |
|
708 'CONCAT(\'ns=\',t.namespace,\';pid=\',t.page_id)' : |
|
709 "'ns=' || t.namespace || ';pid=' || t.page_id"; |
|
710 |
|
711 $texts = 'SELECT t.page_text, ' . $concat_column . ' AS page_idstring, t.page_id, t.namespace FROM '.table_prefix.'page_text AS t |
|
705 LEFT JOIN '.table_prefix.'pages AS p |
712 LEFT JOIN '.table_prefix.'pages AS p |
706 ON ( t.page_id=p.urlname AND t.namespace=p.namespace ) |
713 ON ( t.page_id=p.urlname AND t.namespace=p.namespace ) |
707 WHERE p.namespace=t.namespace |
714 WHERE p.namespace=t.namespace |
708 AND ( p.password=\'\' OR p.password=\'da39a3ee5e6b4b0d3255bfef95601890afd80709\' ) |
715 AND ( p.password=\'\' OR p.password=\'da39a3ee5e6b4b0d3255bfef95601890afd80709\' ) |
709 AND p.visible=1;'; // Only indexes "visible" pages |
716 AND p.visible=1;'; // Only indexes "visible" pages |
813 $db->free_result(); |
820 $db->free_result(); |
814 $search = new Searcher(); |
821 $search = new Searcher(); |
815 $search->buildIndex(Array("ns={$namespace};pid={$page_id}"=>$row['page_text'] . ' ' . $this->pages[$idstring]['name'])); |
822 $search->buildIndex(Array("ns={$namespace};pid={$page_id}"=>$row['page_text'] . ' ' . $this->pages[$idstring]['name'])); |
816 $new_index = $search->index; |
823 $new_index = $search->index; |
817 |
824 |
818 $keys = array_keys($search->index); |
825 if ( ENANO_DBLAYER == 'MYSQL' ) |
819 foreach($keys as $i => $k) |
826 { |
820 { |
827 $keys = array_keys($search->index); |
821 $c =& $keys[$i]; |
828 foreach($keys as $i => $k) |
822 $c = hexencode($c, '', ''); |
829 { |
823 } |
830 $c =& $keys[$i]; |
824 $keys = "word=0x" . implode ( " OR word=0x", $keys ) . ""; |
831 $c = hexencode($c, '', ''); |
832 } |
|
833 $keys = "word=0x" . implode ( " OR word=0x", $keys ) . ""; |
|
834 } |
|
835 else |
|
836 { |
|
837 $keys = array_keys($search->index); |
|
838 foreach($keys as $i => $k) |
|
839 { |
|
840 $c =& $keys[$i]; |
|
841 $c = $db->escape($c); |
|
842 } |
|
843 $keys = "word='" . implode ( "' OR word='", $keys ) . "'"; |
|
844 } |
|
825 |
845 |
826 $query = $db->sql_query('SELECT word,page_names FROM '.table_prefix.'search_index WHERE '.$keys.';'); |
846 $query = $db->sql_query('SELECT word,page_names FROM '.table_prefix.'search_index WHERE '.$keys.';'); |
827 |
847 |
828 while($row = $db->fetchrow()) |
848 while($row = $db->fetchrow()) |
829 { |
849 { |
993 return $group_list; |
1013 return $group_list; |
994 |
1014 |
995 } |
1015 } |
996 |
1016 |
997 } |
1017 } |
998 |
1018 |
999 ?> |
1019 ?> |