diff -r de56132c008d -r bdac73ed481e plugins/SpecialPageFuncs.php --- a/plugins/SpecialPageFuncs.php Sun Mar 28 21:49:26 2010 -0400 +++ b/plugins/SpecialPageFuncs.php Sun Mar 28 23:10:46 2010 -0400 @@ -1,12 +1,12 @@ _ function page_Special_CreatePage() { - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - - $whitelist_ns = array('Article', 'User', 'Help', 'Template', 'Category', 'Project'); - if ( $session->user_level >= USER_LEVEL_ADMIN ) - { - $whitelist_ns[] = 'System'; - } - $code = $plugins->setHook('page_create_ns_whitelist'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - - $errors = array(); - - switch ( isset($_POST['page_title']) ) - { - case true: - // "Create page" was clicked - - // - // VALIDATION CODE - // - - // Check namespace - $namespace = ( isset($_POST['namespace']) ) ? $_POST['namespace'] : 'Article'; - if ( !in_array($namespace, $whitelist_ns) ) - { - $errors[] = $lang->get('pagetools_create_err_invalid_namespace'); - } - - // Check title and figure out urlname - $title = $_POST['page_title']; - $urlname = $_POST['page_title']; - if ( @$_POST['custom_url'] === 'yes' && isset($_POST['urlname']) ) - { - $urlname = $_POST['urlname']; - } - $urlname = sanitize_page_id($urlname); - if ( $urlname == '.00' || empty($urlname) ) - { - $errors[] = $lang->get('pagetools_create_err_invalid_urlname'); - } - - // Validate page existence - $pathskey = $paths->nslist[$namespace] . $urlname; - if ( isPage($pathskey) ) - { - $errors[] = $lang->get('pagetools_create_err_already_exists'); - } - - // Validate permissions - $perms = $session->fetch_page_acl($urlname, $namespace); - if ( !$perms->get_permissions('create_page') ) - { - $errors[] = $lang->get('pagetools_create_err_no_permission'); - } - - // Run hooks - $code = $plugins->setHook('page_create_request'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - - // Create the page - if ( count($errors) < 1 ) - { - $page = new PageProcessor($urlname, $namespace); - $page->create_page($title); - if ( $error = $page->pop_error() ) - { - do - { - $errors[] = $error; - } - while ( $error = $page->pop_error() ); - } - else - { - redirect(makeUrlNS($namespace, $urlname) . '#do:edit', '', '', 0); - return true; - } - } - - break; - } - - $template->header(); - - echo $lang->get('pagetools_create_blurb'); - - if ( count($errors) > 0 ) - { - echo '
' . implode("
\n ", $errors) . '
'; - } - - ?> - - - - '; - - echo '

'; - echo $lang->get('pagetools_create_field_title'); - echo ' '; - echo '

'; - - echo '

'; - echo $lang->get('pagetools_create_field_namespace'); - echo ' '; - echo '

'; - - echo '
'; - echo '' . $lang->get('pagetools_create_group_advanced') . ''; - - echo '

'; - echo ''; - echo '

'; - - echo '

'; - echo ''; - echo '

'; - - echo ''; - - echo '

'; - echo $lang->get('pagetools_create_field_preview') . '
'; - echo '' . $lang->get('pagetools_create_field_preview_hint') . ''; - echo '

'; - - echo '
'; - - echo '

'; - echo ''; - echo '

'; - - echo ''; - - echo ''; - - $template->footer(); + global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + + $whitelist_ns = array('Article', 'User', 'Help', 'Template', 'Category', 'Project'); + if ( $session->user_level >= USER_LEVEL_ADMIN ) + { + $whitelist_ns[] = 'System'; + } + $code = $plugins->setHook('page_create_ns_whitelist'); + foreach ( $code as $cmd ) + { + eval($cmd); + } + + $errors = array(); + + switch ( isset($_POST['page_title']) ) + { + case true: + // "Create page" was clicked + + // + // VALIDATION CODE + // + + // Check namespace + $namespace = ( isset($_POST['namespace']) ) ? $_POST['namespace'] : 'Article'; + if ( !in_array($namespace, $whitelist_ns) ) + { + $errors[] = $lang->get('pagetools_create_err_invalid_namespace'); + } + + // Check title and figure out urlname + $title = $_POST['page_title']; + $urlname = $_POST['page_title']; + if ( @$_POST['custom_url'] === 'yes' && isset($_POST['urlname']) ) + { + $urlname = $_POST['urlname']; + } + $urlname = sanitize_page_id($urlname); + if ( $urlname == '.00' || empty($urlname) ) + { + $errors[] = $lang->get('pagetools_create_err_invalid_urlname'); + } + + // Validate page existence + $pathskey = $paths->nslist[$namespace] . $urlname; + if ( isPage($pathskey) ) + { + $errors[] = $lang->get('pagetools_create_err_already_exists'); + } + + // Validate permissions + $perms = $session->fetch_page_acl($urlname, $namespace); + if ( !$perms->get_permissions('create_page') ) + { + $errors[] = $lang->get('pagetools_create_err_no_permission'); + } + + // Run hooks + $code = $plugins->setHook('page_create_request'); + foreach ( $code as $cmd ) + { + eval($cmd); + } + + // Create the page + if ( count($errors) < 1 ) + { + $page = new PageProcessor($urlname, $namespace); + $page->create_page($title); + if ( $error = $page->pop_error() ) + { + do + { + $errors[] = $error; + } + while ( $error = $page->pop_error() ); + } + else + { + redirect(makeUrlNS($namespace, $urlname) . '#do:edit', '', '', 0); + return true; + } + } + + break; + } + + $template->header(); + + echo $lang->get('pagetools_create_blurb'); + + if ( count($errors) > 0 ) + { + echo '
' . implode("
\n ", $errors) . '
'; + } + + ?> + + + + '; + + echo '

'; + echo $lang->get('pagetools_create_field_title'); + echo ' '; + echo '

'; + + echo '

'; + echo $lang->get('pagetools_create_field_namespace'); + echo ' '; + echo '

'; + + echo '
'; + echo '' . $lang->get('pagetools_create_group_advanced') . ''; + + echo '

'; + echo ''; + echo '

'; + + echo '

'; + echo ''; + echo '

'; + + echo ''; + + echo '

'; + echo $lang->get('pagetools_create_field_preview') . '
'; + echo '' . $lang->get('pagetools_create_field_preview_hint') . ''; + echo '

'; + + echo '
'; + + echo '

'; + echo ''; + echo '

'; + + echo ''; + + echo ''; + + $template->footer(); } function PagelistingFormatter($id, $row) { - global $db, $session, $paths, $template, $plugins; // Common objects - static $rowtracker = 0; - static $tdclass = 'row2'; - static $per_row = 2; - static $first = true; - $return = ''; - if ( $id === false && $row === false ) - { - $rowtracker = 0; - $first = true; - return false; - } - $rowtracker++; - if ( $rowtracker == $per_row || $first ) - { - $rowtracker = 0; - $tdclass = ( $tdclass == 'row2' ) ? 'row1' : 'row2'; - } - if ( $rowtracker == 0 && !$first ) - $return .= "\n"; - - $first = false; - - preg_match('/^ns=(' . implode('|', array_keys($paths->nslist)) . ');pid=(.*?)$/i', $id, $match); - $namespace =& $match[1]; - $page_id =& $match[2]; - $page_id = sanitize_page_id($page_id); - - $url = makeUrlNS($namespace, $page_id); - $url = htmlspecialchars($url); - - $link = '' . htmlspecialchars($row['name']) . ''; - $td = '' . $link . ''; - - $return .= $td; - - return $return; + global $db, $session, $paths, $template, $plugins; // Common objects + static $rowtracker = 0; + static $tdclass = 'row2'; + static $per_row = 2; + static $first = true; + $return = ''; + if ( $id === false && $row === false ) + { + $rowtracker = 0; + $first = true; + return false; + } + $rowtracker++; + if ( $rowtracker == $per_row || $first ) + { + $rowtracker = 0; + $tdclass = ( $tdclass == 'row2' ) ? 'row1' : 'row2'; + } + if ( $rowtracker == 0 && !$first ) + $return .= "\n"; + + $first = false; + + preg_match('/^ns=(' . implode('|', array_keys($paths->nslist)) . ');pid=(.*?)$/i', $id, $match); + $namespace =& $match[1]; + $page_id =& $match[2]; + $page_id = sanitize_page_id($page_id); + + $url = makeUrlNS($namespace, $page_id); + $url = htmlspecialchars($url); + + $link = '' . htmlspecialchars($row['name']) . ''; + $td = '' . $link . ''; + + $return .= $td; + + return $return; } function page_Special_AllPages() { - // This should be an easy one - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - - $template->header(); - echo '

' . $lang->get('pagetools_allpages_blurb') . '

'; - - $q = $db->sql_query('SELECT COUNT(urlname) FROM '.table_prefix.'pages WHERE visible!=0;'); - if ( !$q ) - $db->_die(); - $row = $db->fetchrow_num(); - $count = $row[0]; - $sz =& $count; - - switch($count % 4) - { - case 0: - case 2: - // even number of results; do nothing - $last_cell = ''; - break; - case 1: - // odd number of results and odd number of rows, use row1 - $last_cell = ''; - break; - case 3: - // odd number of results and even number of rows, use row2 - $last_cell = ''; - break; - } - - $db->free_result(); - - // This query needs to be generated based on the DBMS - $concat_column = ENANO_DBLAYER == 'MYSQL' - ? 'CONCAT("ns=",namespace,";pid=",urlname)' - : "'ns=' || namespace || ';pid=' || urlname"; - - $q = $db->sql_unbuffered_query("SELECT $concat_column AS identifier, name FROM " . table_prefix . "pages WHERE visible != 0 ORDER BY name ASC;"); - if ( !$q ) - $db->_die(); - - $offset = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0; - - // reset formatter - PagelistingFormatter(false, false); - - $result = paginate( - $q, // result resource - '{identifier}', // formatting template - $count, // # of results - makeUrlNS('Special', 'AllPages', 'offset=%s'), // result URL - $offset, // start offset - 40, // results per page - array( 'identifier' => 'PagelistingFormatter' ), // hooks - '
- - ', // print at start - ' ' . $last_cell . ' -
-
' // print at end - ); - - echo $result; - - $template->footer(); + // This should be an easy one + global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + + $template->header(); + echo '

' . $lang->get('pagetools_allpages_blurb') . '

'; + + $q = $db->sql_query('SELECT COUNT(urlname) FROM '.table_prefix.'pages WHERE visible!=0;'); + if ( !$q ) + $db->_die(); + $row = $db->fetchrow_num(); + $count = $row[0]; + $sz =& $count; + + switch($count % 4) + { + case 0: + case 2: + // even number of results; do nothing + $last_cell = ''; + break; + case 1: + // odd number of results and odd number of rows, use row1 + $last_cell = ''; + break; + case 3: + // odd number of results and even number of rows, use row2 + $last_cell = ''; + break; + } + + $db->free_result(); + + // This query needs to be generated based on the DBMS + $concat_column = ENANO_DBLAYER == 'MYSQL' + ? 'CONCAT("ns=",namespace,";pid=",urlname)' + : "'ns=' || namespace || ';pid=' || urlname"; + + $q = $db->sql_unbuffered_query("SELECT $concat_column AS identifier, name FROM " . table_prefix . "pages WHERE visible != 0 ORDER BY name ASC;"); + if ( !$q ) + $db->_die(); + + $offset = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0; + + // reset formatter + PagelistingFormatter(false, false); + + $result = paginate( + $q, // result resource + '{identifier}', // formatting template + $count, // # of results + makeUrlNS('Special', 'AllPages', 'offset=%s'), // result URL + $offset, // start offset + 40, // results per page + array( 'identifier' => 'PagelistingFormatter' ), // hooks + '
+ + ', // print at start + ' ' . $last_cell . ' +
+
' // print at end + ); + + echo $result; + + $template->footer(); } function page_Special_SpecialPages() { - // This should be an easy one - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - - $template->header(); - echo '

' . $lang->get('pagetools_specialpages_blurb') . '

'; - $cclass = 'row1'; - $i = -1; - foreach ( $paths->pages as $cdata ) - { - if ( $cdata['namespace'] != 'Special' ) - continue; - - $i++; - if ( $i % 2 == 0 && $i > 0 ) - { - echo ''; - $cclass = ( $cclass == 'row1' ) ? 'row3' : 'row1'; - } - echo ''; - } - // close up the table if necessary - if ( $i % 2 > 0 ) - { - echo ""; - } - echo '
'; - echo ''; - echo htmlspecialchars($cdata['name']); - echo ''; - echo '
'; - $template->footer(); + // This should be an easy one + global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + + $template->header(); + echo '

' . $lang->get('pagetools_specialpages_blurb') . '

'; + $cclass = 'row1'; + $i = -1; + foreach ( $paths->pages as $cdata ) + { + if ( $cdata['namespace'] != 'Special' ) + continue; + + $i++; + if ( $i % 2 == 0 && $i > 0 ) + { + echo ''; + $cclass = ( $cclass == 'row1' ) ? 'row3' : 'row1'; + } + echo ''; + } + // close up the table if necessary + if ( $i % 2 > 0 ) + { + echo ""; + } + echo '
'; + echo ''; + echo htmlspecialchars($cdata['name']); + echo ''; + echo '
'; + $template->footer(); } function page_Special_About_Enano() { - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - - $platform = 'Unknown'; - $uname = @file_get_contents('/proc/sys/kernel/ostype'); - if($uname == "Linux\n") - $platform = 'Linux'; - else if(@file_exists('/hurd/pfinet')) // I have a little experience with GNU/Hurd :-) http://hurdvm.enanocms.org/ - $platform = 'GNU/Hurd'; - else if(strtolower(PHP_OS) == 'winnt') - $platform = 'Windows NT'; - else if(strtolower(PHP_OS) == 'win32') - $platform = 'Windows 9x/DOS'; - else if(@file_exists('/System/Library/CoreServices/SystemVersion.plist')) - $platform = 'Mac OS X'; - else if(@file_exists('/bin/bash')) - $platform = 'Other GNU'; - else if(@is_dir('/bin')) - $platform = 'Other POSIX'; - $template->header(); - ?> -
-
- - - - - - - - - - - - - _conn); - $pg_version = $pg_serverdata['server']; - ?> - - -
get('meta_enano_about_th'); ?>
- get('meta_enano_about_poweredby', array( - 'year' => date('Y') - )); - $subst = array( - 'gpl_link' => makeUrlNS('Special', 'GNU_General_Public_License') - ); - echo $lang->get('meta_enano_about_gpl', $subst); - if ( $lang->lang_code != 'eng' ): - // Do not remove this block of code. Doing so is a violation of the GPL. (A copy of the GPL in other languages - // must be accompanied by a copy of the English GPL.) - ?> -

(English)

-

- This website is powered by Enano, the lightweight and open source CMS that everyone can use. - Enano is copyright © 2006- Dan Fuhry. For legal information, along with a list of libraries that - Enano uses, please see Legal Information. -

-

- The developers and maintainers of Enano strongly believe that software should not only be free to use, but free to be modified, - distributed, and used to create derivative works. To help achieve this goal, we use licensing terms that require you to pass on - the freedoms we give you when you share Enano. For more information about Free Software, check out the - Wikipedia page or - the Free Software Foundation's homepage. -

-

- This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -

-

- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. -

-

- You should have received a copy of - the GNU General Public License along with this program; if not, write to: -

-

- Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor
- Boston, MA 02110-1301, USA -

-

- Alternatively, you can read it online. -

- -
- - - - - - -
- fading_button; ?> - - - Written in PHP - - - - - Database engine powered by MySQL - - - - Database engine powered by PostgreSQL - - -
-
get('meta_enano_about_lbl_enanoversion'); ?>
get('meta_enano_about_lbl_webserver'); ?>
get('meta_enano_about_lbl_serverplatform'); ?>
get('meta_enano_about_lbl_phpversion'); ?>
get('meta_enano_about_lbl_mysqlversion'); ?>_conn); ?>
get('meta_enano_about_lbl_pgsqlversion'); ?>
-
- footer(); + global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + + $platform = 'Unknown'; + $uname = @file_get_contents('/proc/sys/kernel/ostype'); + if($uname == "Linux\n") + $platform = 'Linux'; + else if(@file_exists('/hurd/pfinet')) // I have a little experience with GNU/Hurd :-) http://hurdvm.enanocms.org/ + $platform = 'GNU/Hurd'; + else if(strtolower(PHP_OS) == 'winnt') + $platform = 'Windows NT'; + else if(strtolower(PHP_OS) == 'win32') + $platform = 'Windows 9x/DOS'; + else if(@file_exists('/System/Library/CoreServices/SystemVersion.plist')) + $platform = 'Mac OS X'; + else if(@file_exists('/bin/bash')) + $platform = 'Other GNU'; + else if(@is_dir('/bin')) + $platform = 'Other POSIX'; + $template->header(); + ?> +
+
+ + + + + + + + + + + + + _conn); + $pg_version = $pg_serverdata['server']; + ?> + + +
get('meta_enano_about_th'); ?>
+ get('meta_enano_about_poweredby', array( + 'year' => date('Y') + )); + $subst = array( + 'gpl_link' => makeUrlNS('Special', 'GNU_General_Public_License') + ); + echo $lang->get('meta_enano_about_gpl', $subst); + if ( $lang->lang_code != 'eng' ): + // Do not remove this block of code. Doing so is a violation of the GPL. (A copy of the GPL in other languages + // must be accompanied by a copy of the English GPL.) + ?> +

(English)

+

+ This website is powered by Enano, the lightweight and open source CMS that everyone can use. + Enano is copyright © 2006- Dan Fuhry. For legal information, along with a list of libraries that + Enano uses, please see Legal Information. +

+

+ The developers and maintainers of Enano strongly believe that software should not only be free to use, but free to be modified, + distributed, and used to create derivative works. To help achieve this goal, we use licensing terms that require you to pass on + the freedoms we give you when you share Enano. For more information about Free Software, check out the + Wikipedia page or + the Free Software Foundation's homepage. +

+

+ This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. +

+

+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. +

+

+ You should have received a copy of + the GNU General Public License along with this program; if not, write to: +

+

+ Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor
+ Boston, MA 02110-1301, USA +

+

+ Alternatively, you can read it online. +

+ +
+ + + + + + +
+ fading_button; ?> + + + Written in PHP + + + + + Database engine powered by MySQL + + + + Database engine powered by PostgreSQL + + +
+
get('meta_enano_about_lbl_enanoversion'); ?>
get('meta_enano_about_lbl_webserver'); ?>
get('meta_enano_about_lbl_serverplatform'); ?>
get('meta_enano_about_lbl_phpversion'); ?>
get('meta_enano_about_lbl_mysqlversion'); ?>_conn); ?>
get('meta_enano_about_lbl_pgsqlversion'); ?>
+
+ footer(); } function page_Special_GNU_General_Public_License() { - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - - $template->header(); - if(file_exists(ENANO_ROOT . '/GPL')) - { - echo '

' . $lang->get('pagetools_gpl_blurb', array('about_url' => makeUrlNS('Special', 'About_Enano'))) . '

'; - - if ( $lang->lang_code != 'eng' ): - // Do not remove this block of code. Doing so is a violation of the GPL. (A copy of the GPL in other languages - // must be accompanied by a copy of the English GPL.) - echo '

The following text represents the license that the Enano content management system is under. To make it easier to read, the text has been wiki-formatted; in no other way has it been changed.

'; - endif; - - if ( file_exists(ENANO_ROOT . "/GPL_{$lang->lang_code}") ) - { - echo '

' . $lang->get('pagetools_gpl_title_native') . '

'; - echo '

' . $lang->get('pagetools_gpl_link_to_english') . ' / View the license in English' . '

'; - echo RenderMan::render( file_get_contents ( ENANO_ROOT . "/GPL_{$lang->lang_code}" ) ); - echo '

' . $lang->get('pagetools_gpl_title_english') . ' / English version

'; - } - - echo RenderMan::render( file_get_contents ( ENANO_ROOT . '/GPL' ) ); - } - else - { - echo '

' . $lang->get('pagetools_gpl_err_file_missing') . '

'; - if ( $lang->lang_code != 'eng') - // Also print out English version - // Do not remove the following line of code; doing so would be a violation of the GPL. - echo '

It appears that the file "GPL" is missing from your Enano installation. You may find a wiki-formatted copy of the GPL at: http://enanocms.org/GPL. In the mean time, you may wish to contact the site administration and ask them to replace the GPL file.

'; - } - $template->footer(); + global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + + $template->header(); + if(file_exists(ENANO_ROOT . '/GPL')) + { + echo '

' . $lang->get('pagetools_gpl_blurb', array('about_url' => makeUrlNS('Special', 'About_Enano'))) . '

'; + + if ( $lang->lang_code != 'eng' ): + // Do not remove this block of code. Doing so is a violation of the GPL. (A copy of the GPL in other languages + // must be accompanied by a copy of the English GPL.) + echo '

The following text represents the license that the Enano content management system is under. To make it easier to read, the text has been wiki-formatted; in no other way has it been changed.

'; + endif; + + if ( file_exists(ENANO_ROOT . "/GPL_{$lang->lang_code}") ) + { + echo '

' . $lang->get('pagetools_gpl_title_native') . '

'; + echo '

' . $lang->get('pagetools_gpl_link_to_english') . ' / View the license in English' . '

'; + echo RenderMan::render( file_get_contents ( ENANO_ROOT . "/GPL_{$lang->lang_code}" ) ); + echo '

' . $lang->get('pagetools_gpl_title_english') . ' / English version

'; + } + + echo RenderMan::render( file_get_contents ( ENANO_ROOT . '/GPL' ) ); + } + else + { + echo '

' . $lang->get('pagetools_gpl_err_file_missing') . '

'; + if ( $lang->lang_code != 'eng') + // Also print out English version + // Do not remove the following line of code; doing so would be a violation of the GPL. + echo '

It appears that the file "GPL" is missing from your Enano installation. You may find a wiki-formatted copy of the GPL at: http://enanocms.org/GPL. In the mean time, you may wish to contact the site administration and ask them to replace the GPL file.

'; + } + $template->footer(); } function page_Special_TagCloud() { - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - - $template->header(); - - if ( $tag = $paths->getParam(0) ) - { - $tag = sanitize_tag($tag); - $q = $db->sql_query('SELECT page_id, namespace FROM '.table_prefix.'tags WHERE tag_name=\'' . $db->escape($tag) . '\';'); - if ( !$q ) - $db->_die(); - if ( $row = $db->fetchrow() ) - { - echo '
- '; - echo ''; - echo ''; - $i = 0; - $td_class = 'row1'; - do - { - if ( $i % 2 == 0 && $i > 1 ) - { - $td_class = ( $td_class == 'row2' ) ? 'row1' : 'row2'; - echo ''; - } - $i++; - $title = get_page_title_ns($row['page_id'], $row['namespace']); - if ( $row['namespace'] != 'Article' && isset($paths->nslist[$row['namespace']]) ) - $title = $paths->nslist[$row['namespace']] . $title; - $url = makeUrlNS($row['namespace'], $row['page_id']); - $class = ( isPage( $paths->nslist[$row['namespace']] . $row['page_id'] ) ) ? '' : ' class="wikilink-nonexistent"'; - $link = '' . htmlspecialchars($title) . ''; - echo ""; - // " workaround for jEdit highlighting bug - } - while ( $row = $db->fetchrow() ); - while ( $i % 2 > 0 ) - { - $i++; - echo ""; - } - // " workaround for jEdit highlighting bug - echo ' - - '; - echo '
' . $lang->get('pagetools_tagcloud_pagelist_th', array('tag' => htmlspecialchars($tag))) . '
$link
« ' . $lang->get('pagetools_tagcloud_btn_return') . '
'; - echo '
'; - } - } - else - { - $cloud = new TagCloud(); - - $q = $db->sql_query('SELECT tag_name FROM '.table_prefix.'tags;'); - if ( !$q ) - $db->_die(); - if ( $db->numrows() < 1 ) - { - echo '

' . $lang->get('pagetools_tagcloud_msg_no_tags') . '

'; - } - else - { - echo '

' . $lang->get('pagetools_tagcloud_blurb') . '

'; - while ( $row = $db->fetchrow() ) - { - $cloud->add_word($row['tag_name']); - } - echo $cloud->make_html('normal'); - echo '

' . $lang->get('pagetools_tagcloud_instructions') . '

'; - } - } - - $template->footer(); + global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + + $template->header(); + + if ( $tag = $paths->getParam(0) ) + { + $tag = sanitize_tag($tag); + $q = $db->sql_query('SELECT page_id, namespace FROM '.table_prefix.'tags WHERE tag_name=\'' . $db->escape($tag) . '\';'); + if ( !$q ) + $db->_die(); + if ( $row = $db->fetchrow() ) + { + echo '
+ '; + echo ''; + echo ''; + $i = 0; + $td_class = 'row1'; + do + { + if ( $i % 2 == 0 && $i > 1 ) + { + $td_class = ( $td_class == 'row2' ) ? 'row1' : 'row2'; + echo ''; + } + $i++; + $title = get_page_title_ns($row['page_id'], $row['namespace']); + if ( $row['namespace'] != 'Article' && isset($paths->nslist[$row['namespace']]) ) + $title = $paths->nslist[$row['namespace']] . $title; + $url = makeUrlNS($row['namespace'], $row['page_id']); + $class = ( isPage( $paths->nslist[$row['namespace']] . $row['page_id'] ) ) ? '' : ' class="wikilink-nonexistent"'; + $link = '' . htmlspecialchars($title) . ''; + echo ""; + // " workaround for jEdit highlighting bug + } + while ( $row = $db->fetchrow() ); + while ( $i % 2 > 0 ) + { + $i++; + echo ""; + } + // " workaround for jEdit highlighting bug + echo ' + + '; + echo '
' . $lang->get('pagetools_tagcloud_pagelist_th', array('tag' => htmlspecialchars($tag))) . '
$link
« ' . $lang->get('pagetools_tagcloud_btn_return') . '
'; + echo '
'; + } + } + else + { + $cloud = new TagCloud(); + + $q = $db->sql_query('SELECT tag_name FROM '.table_prefix.'tags;'); + if ( !$q ) + $db->_die(); + if ( $db->numrows() < 1 ) + { + echo '

' . $lang->get('pagetools_tagcloud_msg_no_tags') . '

'; + } + else + { + echo '

' . $lang->get('pagetools_tagcloud_blurb') . '

'; + while ( $row = $db->fetchrow() ) + { + $cloud->add_word($row['tag_name']); + } + echo $cloud->make_html('normal'); + echo '

' . $lang->get('pagetools_tagcloud_instructions') . '

'; + } + } + + $template->footer(); } function page_Special_Autofill() { - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - - require_once(ENANO_ROOT . '/includes/search.php'); - - header('Content-type: text/javascript'); - - $dataset = array(); - if ( isset($_GET['type']) ) - { - switch($_GET['type']) - { - case 'username': - if ( isset($_GET['userinput']) && strlen($_GET['userinput']) >= 3 ) - { - $search = '%' . escape_string_like($_GET['userinput']) . '%'; - $min_id = ( isset($_GET['allow_anon']) && $_GET['allow_anon'] == '1' ) ? '1' : '2'; - $q = $db->sql_query('SELECT username FROM ' . table_prefix . "users WHERE " . ENANO_SQLFUNC_LOWERCASE . "(username) LIKE '$search' AND user_id >= $min_id"); - if ( !$q ) - $db->die_json(); - - while ( $row = $db->fetchrow($q) ) - { - $key = array( - 'name' => $row['username'], - 'name_highlight' => highlight_term($_GET['userinput'], $row['username'], '', '') - ); - $key = array_merge($key, $session->get_user_rank($row['username'])); - $key['rank_title'] = $lang->get($key['rank_title']); - $key[0] = $row['username']; - $dataset[] = $key; - // $dataset[] = array($row['username'], $row['username']); - // echo "{$row['username']}|{$row['username']}\n"; - } - } - // return; - break; - case 'page': - if ( isset($_GET['userinput']) && strlen($_GET['userinput']) >= 3 ) - { - $search = '%' . escape_string_like($_GET['userinput']) . '%'; - $q = $db->sql_query('SELECT urlname, namespace, name FROM ' . table_prefix . "pages\n" - . " WHERE (\n" - . " " . ENANO_SQLFUNC_LOWERCASE . "(urlname) LIKE '$search'\n" - . " OR " . ENANO_SQLFUNC_LOWERCASE . "(name) LIKE '$search'\n" - . " );"); - if ( !$q ) - $db->die_json(); - - while ( $row = $db->fetchrow() ) - { - $pathskey = ( isset($paths->nslist[$row['namespace']]) ? $paths->nslist[$row['namespace']] : $row['namespace'] . substr($paths->nslist['Special'], -1) ) . $row['urlname']; - - $key = array( - 0 => $pathskey, - 'pid_highlight' => highlight_term($_GET['userinput'], dirtify_page_id($pathskey), '', ''), - 'name_highlight' => highlight_term($_GET['userinput'], $row['name'], '', '') - ); - $dataset[] = $key; - } - } - break; - default: - $code = $plugins->setHook('autofill_json_request'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - break; - } - } - - echo enano_json_encode($dataset); + global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + + require_once(ENANO_ROOT . '/includes/search.php'); + + header('Content-type: text/javascript'); + + $dataset = array(); + if ( isset($_GET['type']) ) + { + switch($_GET['type']) + { + case 'username': + if ( isset($_GET['userinput']) && strlen($_GET['userinput']) >= 3 ) + { + $search = '%' . escape_string_like($_GET['userinput']) . '%'; + $min_id = ( isset($_GET['allow_anon']) && $_GET['allow_anon'] == '1' ) ? '1' : '2'; + $q = $db->sql_query('SELECT username FROM ' . table_prefix . "users WHERE " . ENANO_SQLFUNC_LOWERCASE . "(username) LIKE '$search' AND user_id >= $min_id"); + if ( !$q ) + $db->die_json(); + + while ( $row = $db->fetchrow($q) ) + { + $key = array( + 'name' => $row['username'], + 'name_highlight' => highlight_term($_GET['userinput'], $row['username'], '', '') + ); + $key = array_merge($key, $session->get_user_rank($row['username'])); + $key['rank_title'] = $lang->get($key['rank_title']); + $key[0] = $row['username']; + $dataset[] = $key; + // $dataset[] = array($row['username'], $row['username']); + // echo "{$row['username']}|{$row['username']}\n"; + } + } + // return; + break; + case 'page': + if ( isset($_GET['userinput']) && strlen($_GET['userinput']) >= 3 ) + { + $search = '%' . escape_string_like($_GET['userinput']) . '%'; + $q = $db->sql_query('SELECT urlname, namespace, name FROM ' . table_prefix . "pages\n" + . " WHERE (\n" + . " " . ENANO_SQLFUNC_LOWERCASE . "(urlname) LIKE '$search'\n" + . " OR " . ENANO_SQLFUNC_LOWERCASE . "(name) LIKE '$search'\n" + . " );"); + if ( !$q ) + $db->die_json(); + + while ( $row = $db->fetchrow() ) + { + $pathskey = ( isset($paths->nslist[$row['namespace']]) ? $paths->nslist[$row['namespace']] : $row['namespace'] . substr($paths->nslist['Special'], -1) ) . $row['urlname']; + + $key = array( + 0 => $pathskey, + 'pid_highlight' => highlight_term($_GET['userinput'], dirtify_page_id($pathskey), '', ''), + 'name_highlight' => highlight_term($_GET['userinput'], $row['name'], '', '') + ); + $dataset[] = $key; + } + } + break; + default: + $code = $plugins->setHook('autofill_json_request'); + foreach ( $code as $cmd ) + { + eval($cmd); + } + break; + } + } + + echo enano_json_encode($dataset); } ?>