diff options
author | pete <pete@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-12 18:10:54 +0000 |
---|---|---|
committer | pete <pete@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-12 18:10:54 +0000 |
commit | f46bd9269d84f35e809cb6fddb72264adfbb0904 (patch) | |
tree | de421898a3162d5b58837b039c94b4c2908cd389 /mod | |
parent | 73ed4ae8513af1cc6e795b125cc1f319a965bfb4 (diff) | |
download | elgg-f46bd9269d84f35e809cb6fddb72264adfbb0904.tar.gz elgg-f46bd9269d84f35e809cb6fddb72264adfbb0904.tar.bz2 |
Added updated tagcloud plugin and added to core mods.
git-svn-id: http://code.elgg.org/elgg/trunk@5379 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod')
-rw-r--r-- | mod/blog/views/default/blog/sidebar_menu.php | 9 | ||||
-rw-r--r-- | mod/tagcloud/languages/de.php | 12 | ||||
-rw-r--r-- | mod/tagcloud/languages/en.php | 14 | ||||
-rw-r--r-- | mod/tagcloud/manifest.xml | 10 | ||||
-rw-r--r-- | mod/tagcloud/start.php | 18 | ||||
-rw-r--r-- | mod/tagcloud/tagcloud.php | 16 | ||||
-rw-r--r-- | mod/tagcloud/views/default/output/tagcloud.php | 47 | ||||
-rw-r--r-- | mod/tagcloud/views/default/tagcloud/css.php | 16 | ||||
-rw-r--r-- | mod/tagcloud/views/default/widgets/tagcloud/edit.php | 20 | ||||
-rw-r--r-- | mod/tagcloud/views/default/widgets/tagcloud/view.php | 9 |
10 files changed, 169 insertions, 2 deletions
diff --git a/mod/blog/views/default/blog/sidebar_menu.php b/mod/blog/views/default/blog/sidebar_menu.php index 1a6124dbd..b910b420b 100644 --- a/mod/blog/views/default/blog/sidebar_menu.php +++ b/mod/blog/views/default/blog/sidebar_menu.php @@ -34,9 +34,14 @@ $page_owner = page_owner_entity(); if ($loggedin_user) { } - ?> <ul class="submenu"> <li><a href="">Drafts</a></li> -</ul>
\ No newline at end of file +</ul> + +<?php // temporarily force tag-cloud display + echo "<h3>Tagcloud</h3>"; + echo "<div class='tagcloud sidebar'>".display_tagcloud(0, 100, 'tags')."</div>"; + echo "<a href=\"{$vars['url']}mod/tagcloud/tagcloud.php\">All site tags</a>"; +?> diff --git a/mod/tagcloud/languages/de.php b/mod/tagcloud/languages/de.php new file mode 100644 index 000000000..1192202b3 --- /dev/null +++ b/mod/tagcloud/languages/de.php @@ -0,0 +1,12 @@ +<?php + + $german = array( + "tagcloud:widget:title" => "Schlagworte", + "tagcloud:widget:description" => "Schlagworte", + "tagcloud:widget:notags" => "Anzahl anzeigen", + "item:object" => "Alle Einträge", + ); + + add_translation("de",$german); + +?> diff --git a/mod/tagcloud/languages/en.php b/mod/tagcloud/languages/en.php new file mode 100644 index 000000000..749a86434 --- /dev/null +++ b/mod/tagcloud/languages/en.php @@ -0,0 +1,14 @@ +<?php + + $english = array( + 'tagcloud:widget:title' => 'Tag Cloud', + 'tagcloud:site:title' => 'Site Tag Cloud', + 'tagcloud:widget:description' => 'Tag cloud', + 'tagcloud:widget:numtags' => 'Number of tags to show', + 'item:object' => 'Items', + 'advancedsearchtitle' => '%s with tags matching %s', + ); + + add_translation('en',$english); + +?> diff --git a/mod/tagcloud/manifest.xml b/mod/tagcloud/manifest.xml new file mode 100644 index 000000000..7f08072b9 --- /dev/null +++ b/mod/tagcloud/manifest.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin_manifest> + <field key="author" value="Curverider, Cash Costello" /> + <field key="version" value="1.0" /> + <field key="description" value="Site-wide and widget-based tag clouds." /> + <field key="website" value="http://www.elgg.org/" /> + <field key="copyright" value="(C) Curverider 2008-2010" /> + <field key="licence" value="GNU Public License version 2" /> + <field key="elgg_version" value="2010030101" /> +</plugin_manifest> diff --git a/mod/tagcloud/start.php b/mod/tagcloud/start.php new file mode 100644 index 000000000..cb397d7e9 --- /dev/null +++ b/mod/tagcloud/start.php @@ -0,0 +1,18 @@ +<?php + function tagcloud_init() { + add_widget_type('tagcloud', elgg_echo('tagcloud:widget:title'), elgg_echo('tagcloud:widget:description')); + + // Extend CSS + extend_view('css','tagcloud/css'); + + if(is_plugin_enabled('blog')) { + // extend blog sidebar with a tag-cloud + } + if(is_plugin_enabled('bookmarks')) { + // extend bkmrks sidebar with a tag-cloud + } + + } + + register_elgg_event_handler('init', 'system', 'tagcloud_init'); +?> diff --git a/mod/tagcloud/tagcloud.php b/mod/tagcloud/tagcloud.php new file mode 100644 index 000000000..564e839e3 --- /dev/null +++ b/mod/tagcloud/tagcloud.php @@ -0,0 +1,16 @@ +<?php +/** + * Display site tagcloud + **/ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +$title = elgg_view_title(elgg_echo('tagcloud:site:title')); +$tags = "<div class='tagcloud site'>".display_tagcloud(0, 100, 'tags')."</div>"; + +//select the correct canvas area +$body = elgg_view_layout("one_column_with_sidebar", $title . $tags, $sidebar); + +// Display page +page_draw(sprintf(elgg_echo('tagcloud:site:title'),$page_owner->name),$body);
\ No newline at end of file diff --git a/mod/tagcloud/views/default/output/tagcloud.php b/mod/tagcloud/views/default/output/tagcloud.php new file mode 100644 index 000000000..aa3d84081 --- /dev/null +++ b/mod/tagcloud/views/default/output/tagcloud.php @@ -0,0 +1,47 @@ +<?php + + /** + * Elgg tagcloud + * Displays a tagcloud + */ + + if (!empty($vars['subtype'])) { + $subtype = "&subtype=" . urlencode($vars['subtype']); + } else { + $subtype = ""; + } + if (!empty($vars['object'])) { + $object = "&object=" . urlencode($vars['object']); + } else { + $object = ""; + } + + if (empty($vars['tagcloud']) && !empty($vars['value'])) + $vars['tagcloud'] = $vars['value']; + + if (!empty($vars['tagcloud']) && is_array($vars['tagcloud'])) { + + if (get_context() === 'random') + shuffle($vars['tagcloud']); + + $counter = 0; + $cloud = ""; + $max = 0; + foreach($vars['tagcloud'] as $tag) { + if ($tag->total > $max) { + $max = $tag->total; + } + } + foreach($vars['tagcloud'] as $tag) { + if (!empty($cloud)) $cloud .= ","; + $size = round((log($tag->total) / log($max)) * 100) + 80; + if ($size < 100) $size = 100; + $cloud .= "<a href=\"" . $vars['url'] . "search/?tag=". urlencode($tag->tag) . $object . $subtype . "\" style=\"font-size: {$size}%\" title=\"".addslashes($tag->tag)." ({$tag->total})\" style=\"text-decoration:none;\">" . htmlentities($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>"; + } + $tags = explode(',', $cloud); + asort($tags); + $tags = implode(',', $tags); + echo str_replace(",", " ", $tags); + } + +?> diff --git a/mod/tagcloud/views/default/tagcloud/css.php b/mod/tagcloud/views/default/tagcloud/css.php new file mode 100644 index 000000000..00e972c8a --- /dev/null +++ b/mod/tagcloud/views/default/tagcloud/css.php @@ -0,0 +1,16 @@ +<?php + /** + * Elgg tagcloud + */ +?> + +.tagcloud { + text-align:justify; + font-size:1.0em; /* default font-size for single page tagcloud */ +} +.tagcloud.site a { + margin-right:0.2em; +} +.tagcloud.sidebar { + font-size:0.7em; /* reset default size for sidebar tagclouds */ +}
\ No newline at end of file diff --git a/mod/tagcloud/views/default/widgets/tagcloud/edit.php b/mod/tagcloud/views/default/widgets/tagcloud/edit.php new file mode 100644 index 000000000..449266f13 --- /dev/null +++ b/mod/tagcloud/views/default/widgets/tagcloud/edit.php @@ -0,0 +1,20 @@ +<p> +<?php + + $num_items = $vars['entity']->num_items; + if (!isset($num_items)) $num_items = 30; + + echo elgg_echo('tagcloud:widget:numtags'); + + echo elgg_view('input/pulldown', array( + 'internalname' => 'params[num_items]', + 'options_values' => array( '10' => '10', + '20' => '20', + '30' => '30', + '50' => '50', + '100' => '100', + ), + 'value' => $num_items + )); +?> +</p> diff --git a/mod/tagcloud/views/default/widgets/tagcloud/view.php b/mod/tagcloud/views/default/widgets/tagcloud/view.php new file mode 100644 index 000000000..dc9666185 --- /dev/null +++ b/mod/tagcloud/views/default/widgets/tagcloud/view.php @@ -0,0 +1,9 @@ +<?php + + $num_items = $vars['entity']->num_items; + if (!isset($num_items)) $num_items = 30; + + $prev_context = get_context(); + echo display_tagcloud(1, $num_items, 'tags', '', '', page_owner()); + set_context($prev_context); +?> |