aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/config_default.inc.php7
-rw-r--r--tags.php100
-rw-r--r--template/yoga/default-layout.css35
-rw-r--r--template/yoga/icon/tag_cloud.pngbin0 -> 1165 bytes
-rw-r--r--template/yoga/icon/tag_letters.pngbin0 -> 882 bytes
-rw-r--r--template/yoga/tags.tpl38
6 files changed, 176 insertions, 4 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index cb78729ef..f5c9d64c8 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -567,6 +567,13 @@ $conf['content_tag_cloud_items_number'] = 12;
// CSS class tagLevelX.
$conf['tags_levels'] = 5;
+// tags_default_display_mode: group tags by letter or display a tag cloud by
+// default? 'letters' or 'cloud'.
+$conf['tags_default_display_mode'] = 'cloud';
+
+// tag_letters_column_number: how many columns to display tags by letter
+$conf['tag_letters_column_number'] = 4;
+
// +-----------------------------------------------------------------------+
// | Notification by mail |
// +-----------------------------------------------------------------------+
diff --git a/tags.php b/tags.php
index 60c575121..28ce3177c 100644
--- a/tags.php
+++ b/tags.php
@@ -58,13 +58,107 @@ $page['body_id'] = 'theTagsPage';
$template->set_filenames(array('tags'=>'tags.tpl'));
-// +-----------------------------------------------------------------------+
-// | tag cloud construction |
-// +-----------------------------------------------------------------------+
+$page['display_mode'] = $conf['tags_default_display_mode'];
+if (isset($_GET['display_mode']))
+{
+ if (in_array($_GET['display_mode'], array('cloud', 'letters')))
+ {
+ $page['display_mode'] = $_GET['display_mode'];
+ }
+}
+
+$template->assign(
+ array(
+ 'U_CLOUD' => get_root_url().'tags.php?display_mode=cloud',
+ 'U_LETTERS' => get_root_url().'tags.php?display_mode=letters',
+ 'display_mode' => $page['display_mode'],
+ )
+ );
// find all tags available for the current user
$tags = get_available_tags();
+// +-----------------------------------------------------------------------+
+// | letter groups construction |
+// +-----------------------------------------------------------------------+
+
+if ($page['display_mode'] == 'letters') {
+ // we want tags diplayed in alphabetic order
+ usort($tags, 'name_compare');
+
+ $current_letter = null;
+ $is_first_tag = true;
+ $nb_tags = count($tags);
+ $current_column_tags = 0;
+
+ $letter = array(
+ 'tags' => array()
+ );
+
+ foreach ($tags as $tag)
+ {
+ $tag_letter = strtoupper(substr($tag['name'], 0, 1));
+
+ if ($is_first_tag) {
+ $current_letter = $tag_letter;
+ $letter['TITLE'] = $tag_letter;
+ $is_first_tag = false;
+ }
+
+ //lettre precedente differente de la lettre suivante
+ if ($tag_letter !== $current_letter)
+ {
+ if ($current_column_tags > $nb_tags/$conf['tag_letters_column_number'])
+ {
+ $letter['CHANGE_COLUMN'] = true;
+ $current_column_tags = 0;
+ }
+
+ $letter['TITLE'] = $current_letter;
+
+ $template->append(
+ 'letters',
+ $letter
+ );
+
+ $current_letter = $tag_letter;
+ $letter = array(
+ 'tags' => array()
+ );
+ }
+
+ array_push(
+ $letter['tags'],
+ array(
+ 'URL' => make_index_url(
+ array(
+ 'tags' => array($tag),
+ )
+ ),
+ 'NAME' => $tag['name'],
+ 'COUNTER' => $tag['counter'],
+ )
+ );
+
+ $current_column_tags++;
+ }
+
+ // flush last letter
+ if (count($letter['tags']) > 0)
+ {
+ $letter['CHANGE_COLUMN'] = false;
+ $letter['TITLE'] = $current_letter;
+ $template->append(
+ 'letters',
+ $letter
+ );
+ }
+}
+
+// +-----------------------------------------------------------------------+
+// | tag cloud construction |
+// +-----------------------------------------------------------------------+
+
// we want only the first most represented tags, so we sort them by counter
// and take the first tags
usort($tags, 'counter_compare');
diff --git a/template/yoga/default-layout.css b/template/yoga/default-layout.css
index c6b229481..a81263471 100644
--- a/template/yoga/default-layout.css
+++ b/template/yoga/default-layout.css
@@ -268,3 +268,38 @@ BODY#thePopuphelpPage .content UL LI
BODY#thePopuphelpPage P#pageBottomActions A {
border: none;
}
+
+TR.tagLine {
+ border-bottom: 1px solid #ddd;
+ text-align: left;
+}
+TR.tagLine:hover {
+ background-color: #fff;
+}
+TD.nbEntries {
+ text-align: right;
+ font-style: italic;
+ font-size: 90%;
+}
+
+FIELDSET.tagLetter {
+ border: 1px solid #d3d3d3;
+ width: 200px;
+ margin: 0.5em;
+ padding: 10px;
+}
+
+LEGEND.tagLetterLegend {
+ border: 1px solid #d3d3d3;
+ font-size:120%;
+ font-weight: bold;
+ padding: 0 5px;
+ color: #555;
+ font-style: normal;
+}
+
+TABLE.tagLetterContent {
+ width:100%;
+ font-size:80%;
+ border-collapse : collapse;
+}
diff --git a/template/yoga/icon/tag_cloud.png b/template/yoga/icon/tag_cloud.png
new file mode 100644
index 000000000..79d7bc250
--- /dev/null
+++ b/template/yoga/icon/tag_cloud.png
Binary files differ
diff --git a/template/yoga/icon/tag_letters.png b/template/yoga/icon/tag_letters.png
new file mode 100644
index 000000000..d452db7ec
--- /dev/null
+++ b/template/yoga/icon/tag_letters.png
Binary files differ
diff --git a/template/yoga/tags.tpl b/template/yoga/tags.tpl
index 98a49cd06..56b72bdfb 100644
--- a/template/yoga/tags.tpl
+++ b/template/yoga/tags.tpl
@@ -3,12 +3,21 @@
<div class="titrePage">
<ul class="categoryActions">
+{if $display_mode == 'letters'}
+ <li><a href="{$U_CLOUD}" title="{'show tag cloud'|@translate}"><img src="{$themeconf.icon_dir}/tag_cloud.png" class="button" alt="{'cloud'|@translate}"/></a></li>
+{/if}
+
+{if $display_mode == 'cloud'}
+ <li><a href="{$U_LETTERS}" title="{'group by letters'|@translate}"><img src="{$themeconf.icon_dir}/tag_letters.png" class="button" alt="{'letters'|@translate}"/></a></li>
+{/if}
+
<li><a href="{$U_HOME}" title="{'return to homepage'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'home'|@translate}"/></a></li>
</ul>
<h2>{'Tags'|@translate}</h2>
</div>
- {if isset($tags)}
+{if isset($tags)}
+ {if $display_mode == 'cloud'}
<ul id="fullTagCloud">
{foreach from=$tags item=tag}
<li><a href="{$tag.URL}" class="{$tag.CLASS}" title="{$tag.TITLE}">{$tag.NAME}</a></li>
@@ -16,4 +25,31 @@
</ul>
{/if}
+ {if $display_mode == 'letters'}
+ <table>
+ <tr>
+ <td valign="top">
+ {foreach from=$letters item=letter}
+ <fieldset class="tagLetter">
+ <legend class="tagLetterLegend">{$letter.TITLE}</legend>
+ <table class="tagLetterContent">
+ {foreach from=$letter.tags item=tag}
+ <tr class="tagLine">
+ <td><a href="{$tag.URL}">{$tag.NAME}</a></td>
+ <td class="nbEntries"><strong>{$tag.COUNTER}</strong> {'photos'|@translate}</td>
+ </tr>
+ {/foreach}
+ </table>
+ </fieldset>
+ {if $letter.CHANGE_COLUMN}
+ </td>
+ <td valign="top">
+ {/if}
+ {/foreach}
+ </td>
+ </tr>
+ </table>
+ {/if}
+{/if}
+
</div> <!-- content -->