diff -r 03c7f5ec1e4c -r 80facec76d9f plugins/SpecialPageFuncs.php --- a/plugins/SpecialPageFuncs.php Sun Aug 05 17:10:17 2007 -0400 +++ b/plugins/SpecialPageFuncs.php Mon Aug 06 10:09:48 2007 -0400 @@ -58,6 +58,13 @@ \'namespace\'=>\'Special\', \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', )); + + $paths->add_page(Array( + \'name\'=>\'Tag cloud\', + \'urlname\'=>\'TagCloud\', + \'namespace\'=>\'Special\', + \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', + )); '); // function names are IMPORTANT!!! The name pattern is: page__ @@ -366,4 +373,107 @@ $template->footer(); } +function page_Special_TagCloud() +{ + global $db, $session, $paths, $template, $plugins; // Common objects + + $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 '
Pages tagged "' . htmlspecialchars($tag) . '"
$link
« Return to tag cloud
'; + 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 '

No pages are tagged yet.

'; + } + else + { + echo '

Summary of page tagging

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

Hover your mouse over a tag to see how many pages have the tag. Click on a tag to see a list of the pages that have it.

'; + } + } + + $template->footer(); +} + +// tag cloud sidebar block +function sidebar_add_tag_cloud() +{ + global $db, $session, $paths, $template, $plugins; // Common objects + $cloud = new TagCloud(); + + $q = $db->sql_query('SELECT tag_name FROM '.table_prefix.'tags;'); + if ( !$q ) + $db->_die(); + if ( $db->numrows() < 1 ) + { + $sb_html = 'No pages are tagged yet.'; + } + else + { + while ( $row = $db->fetchrow() ) + { + $cloud->add_word($row['tag_name']); + } + $sb_html = $cloud->make_html('small', 'justify') . '
Larger version'; + } + $template->sidebar_widget('Tag cloud', "
$sb_html
"); +} + +$plugins->attachHook('compile_template', 'sidebar_add_tag_cloud();'); + ?> \ No newline at end of file