--- a/includes/clientside/css/enano-shared.css Sun Aug 05 17:10:17 2007 -0400
+++ b/includes/clientside/css/enano-shared.css Mon Aug 06 10:09:48 2007 -0400
@@ -422,3 +422,83 @@
td.diff-context { background: #eee; font-size: smaller; }
span.diffchange { color: red; font-weight: bold; }
+/* Tag cloud */
+span.tc_word_normal {
+ font-family: Arial, helvetica, sans-serif;
+ font-size: 10pt;
+ letter-spacing: 3px;
+ padding: 4px 4px 4px 4px;
+}
+span.tc_word_small {
+ font-family: Arial, helvetica, sans-serif;
+ font-size: 8pt;
+}
+span.tc_word_normal a, span.tc_word_small a {
+ color: inherit !important;
+ text-decoration: none !important;
+}
+/* These are from http://www.lotsofcode.com/php/tutorials/tag-cloud */
+span.tc_normal_index_1 {
+ color: #000;
+ font-size: 2.4em;
+}
+span.tc_normal_index_2 {
+ color: #333;
+ font-size: 2.2em;
+}
+span.tc_normal_index_3 {
+ color: #666;
+ font-size: 2.0em;
+}
+span.tc_normal_index_4 {
+ color: #999;
+ font-size: 1em;
+}
+span.tc_normal_index_5 {
+ color: #aaa;
+ font-size: 1.6em;
+}
+span.tc_normal_index_6 {
+ color: #bbb;
+ font-size: 1.4em;
+}
+span.tc_normal_index_7 {
+ color: #ccc;
+ font-size: 1.2em;
+}
+span.tc_normal_index_8 {
+ color: #ddd;
+ font-size: 0.8em;
+}
+span.tc_small_index_1 {
+ color: #000;
+ font-size: 1.4em;
+}
+span.tc_small_index_2 {
+ color: #333;
+ font-size: 1.3em;
+}
+span.tc_small_index_3 {
+ color: #666;
+ font-size: 1.2em;
+}
+span.tc_small_index_4 {
+ color: #999;
+ font-size: 1em;
+}
+span.tc_small_index_5 {
+ color: #aaa;
+ font-size: 1.3em;
+}
+span.tc_small_index_6 {
+ color: #bbb;
+ font-size: 1.1em;
+}
+span.tc_small_index_7 {
+ color: #ccc;
+ font-size: 0.9em;
+}
+span.tc_small_index_8 {
+ color: #ddd;
+ font-size: 0.7em;
+}
--- a/includes/pageprocess.php Sun Aug 05 17:10:17 2007 -0400
+++ b/includes/pageprocess.php Mon Aug 06 10:09:48 2007 -0400
@@ -753,7 +753,7 @@
$parser->assign_bool(array(
'page_exists' => true
));
- $page_title = $paths->pages[ $c_page_id ]['name'];
+ $page_title = htmlspecialchars($paths->pages[ $c_page_id ]['name']);
}
else
{
--- a/includes/tagcloud.php Sun Aug 05 17:10:17 2007 -0400
+++ b/includes/tagcloud.php Mon Aug 06 10:09:48 2007 -0400
@@ -51,7 +51,7 @@
function add_word($word)
{
- $word = strtolower($word);
+ $word = sanitize_tag($word);
if ( isset($this->words[$word]) )
$this->words[$word] += 1;
@@ -125,25 +125,33 @@
/**
* Generates and returns HTML for the cloud.
+ * @param string Optional. The CSS class applied to all <span> tags. Can be "normal" or "small". Defaults to "normal".
+ * @param string Optional. The alignment for the div. Defaults to "center".
* @return string
*/
- function make_html()
+ function make_html($span_class = 'normal', $div_align = 'center')
{
$html = array();
$max = max($this->words);
$size = $this->get_cloud_size();
+ $inc = 0;
if ( count($this->words) > 0 )
{
foreach ( $this->words as $word => $popularity )
{
+ $inc++;
$word = htmlspecialchars($word);
$percent = ( $popularity / $max ) * 100;
$index = $this->get_scale_class($percent);
- $html[] = "<span class='tc_word tc_index_$index'>$word</span>";
+ $newline = ( $inc == 5 ) ? "<br />" : '';
+ ( $inc == 5 ) ? $inc = 0 : null;
+ $url = makeUrlNS('Special', 'TagCloud/' . htmlspecialchars($word));
+ $s = ( $popularity != 1 ) ? 's' : '';
+ $html[] = "<span class='tc_word_{$span_class} tc_{$span_class}_index_{$index}'><a href='$url' title='$popularity page$s'>$word</a></span>"; // $newline";
}
}
- $html = implode("\n", $html);
+ $html = '<div style="text-align: ' . $div_align . '; margin: 0 auto; max-width: 400px;">' . implode("\n", $html) . '</div>';
return $html;
}
--- 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_<namespace ID>_<page URLname, without namespace>
@@ -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 '<div class="tblholder">
+ <table border="0" cellspacing="1" cellpadding="4">';
+ echo '<tr><th colspan="2">Pages tagged "' . htmlspecialchars($tag) . '"</th></tr>';
+ echo '<tr>';
+ $i = 0;
+ $td_class = 'row1';
+ do
+ {
+ if ( $i % 2 == 0 && $i > 1 )
+ {
+ $td_class = ( $td_class == 'row2' ) ? 'row1' : 'row2';
+ echo '</tr><tr>';
+ }
+ $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 = '<a href="' . htmlspecialchars($url) . '"' . $class . '>' . htmlspecialchars($title) . '</a>';
+ echo "<td class=\"$td_class\" style=\"width: 50%;\">$link</td>";
+ // " workaround for jEdit highlighting bug
+ }
+ while ( $row = $db->fetchrow() );
+ while ( $i % 2 > 0 )
+ {
+ $i++;
+ echo "<td class=\"$td_class\" style=\"width: 50%;\"></td>";
+ }
+ // " workaround for jEdit highlighting bug
+ echo '<tr>
+ <th colspan="2" class="subhead"><a href="' . makeUrlNS('Special', 'TagCloud') . '" style="color: white;">« Return to tag cloud</a></th>
+ </tr>';
+ echo '</table>';
+ echo '</div>';
+ }
+ }
+ else
+ {
+ $cloud = new TagCloud();
+
+ $q = $db->sql_query('SELECT tag_name FROM '.table_prefix.'tags;');
+ if ( !$q )
+ $db->_die();
+ if ( $db->numrows() < 1 )
+ {
+ echo '<p>No pages are tagged yet.</p>';
+ }
+ else
+ {
+ echo '<h3>Summary of page tagging</h3>';
+ while ( $row = $db->fetchrow() )
+ {
+ $cloud->add_word($row['tag_name']);
+ }
+ echo $cloud->make_html('normal');
+ echo '<p>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.</p>';
+ }
+ }
+
+ $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') . '<br /><a style="text-align: center;" href="' . makeUrlNS('Special', 'TagCloud') . '">Larger version</a>';
+ }
+ $template->sidebar_widget('Tag cloud', "<div style='padding: 5px;'>$sb_html</div>");
+}
+
+$plugins->attachHook('compile_template', 'sidebar_add_tag_cloud();');
+
?>
\ No newline at end of file