From 30bc167c9e15f7ca90151e1a00e9f8beb0856d43 Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 28 May 2008 22:39:06 +0000 Subject: [PATCH] feature 828 added: display tags by letters. Users can switch from "cloud" to "letters" with a button in the top bar. git-svn-id: http://piwigo.org/svn/trunk@2362 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/config_default.inc.php | 7 ++ tags.php | 100 ++++++++++++++++++++++++++++- template/yoga/default-layout.css | 35 ++++++++++ template/yoga/icon/tag_cloud.png | Bin 0 -> 1165 bytes template/yoga/icon/tag_letters.png | Bin 0 -> 882 bytes template/yoga/tags.tpl | 38 ++++++++++- 6 files changed, 176 insertions(+), 4 deletions(-) create mode 100644 template/yoga/icon/tag_cloud.png create mode 100644 template/yoga/icon/tag_letters.png 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 0000000000000000000000000000000000000000..79d7bc250afc03969ebb2a1ad1c5c37689613351 GIT binary patch literal 1165 zcmV;81akX{P)WFU8GbZ8({Xk{QrNlj4iWF>9@00Z$!L_t(I%f*%7Z&XDT z$3JuDZntjtM-fz7=nG{jwgp3f&_K)r0)jCyF~;~tVhRt&H&P1;zHYKzN%Vz~m>B*9 z!Nd@rR7j){)R3SOnwG90u=I!B?cLtFckaF8Lw`sM#`<79FO$ri^UawvpK}KOZwt=n z2rlGS?Qi{C&*00|iHl`fEd<$bU#3vZw@4|^7-RMV2qC@=!|+4fw(kW&0Kmz?Q%}YH zt?=oQLjW6NvDmHLt9#N-%^QU0DN3dB@P{97IAIue#$vJi#u$PiU|{Pd2zj<}p_s1+ zK9Eu#2TT-2)z|hNXwPoW3RfwVa#60!*xk|S=U;C9DzGvLVWKEJ?biIyKkoWQ*>8Qf ztQ7Xb+W*S-9Yb9^x?-+!86LiBnwpw~)*1mA13J(&G$gH#j_vI|T|L58F4wPL`(*6y zm?ku5pZO$G$`jpP-7(9uz(99bw@9Zl^W_NwjES&qn|NIvJA3=YqF;7%w$8TY!0C}g z6pH!f85fHAL=;77r&gmOk)UzS8f@D}`#xH0eC;Ep&HDAtq>^a@tZc`%Fzu^Yz8A*wwe2J$v@z zc^>1XacB3F@pf!G# z!v@aX9UqgW-^NcwQPct;EylXNPB=cyHx#OUbT#X@J&*0#0o{_pn& zfU`@TS19I*$K!aOmk^fq;N5rL%QPes#Ov#qC~;jE*$R&Hm*~o=X|LP~!*FQ$>i3_uZGAbeeIMn`H#%Rhr4V03KM55sUstQ0O3^Ksy)Wm!v=S2d00000NkvXXu0mjfx0Ek@ literal 0 HcmV?d00001 diff --git a/template/yoga/icon/tag_letters.png b/template/yoga/icon/tag_letters.png new file mode 100644 index 0000000000000000000000000000000000000000..d452db7ec861327ab09a23bf9af33e69161b3892 GIT binary patch literal 882 zcmV-&1C9KNP);R>eh8I(4E=qg}M94~h%vvRTwZ7wW1Y zqos>1N*88`x^XuhyAdl=Xu1(b-40!35%L6KA|fS(mv_5(NzBhgsPw?)-g~(3yXW^l zp(-2Ces~Og1K2!F_Eh!f@4o&1FB+ilzdU$h9H(F&Dvnby&okTR$DcMo1_)Hy$qycX zi0f9!=ko}H2pACr5WrU$4B%`1wJ`>&yQiPT$m~A<3iw^CU^^Us1c0c32qKD#AS!n{ z6;u@w5D|Z9bw;Q%YyfQxl8T@R+3cUB(`jO{7_p}@UcEZ=tu?-d2JnpG;^G3Y;$e&- z7z{QAT$^_SDvXVdv0yK;&R65HF`3=R%bDwXg&uQON?RD`p$ zGv;Pz+1=R%AQFkxfi-w8mt$&bit+Jrip3%#a-YQtC~IqL?CtF_GcyB#Wm$D_ZPa4C zzP?U497eSn6=>Xu+}&i`emQS$ZgPHpPN7gB9*_GKU`!o6Iyy==n`K~N;6AWlT*t@9 zcUc#~wr%qHJc&f24o)VMq*5ss7Z-^}qix;N3`Xj1HoEJ&E|p3JRmE`}EX!hHVS)Mi zc|6and(b(?4HZzEYwO$FTP7wZh(@FI_4ScVCfm+-1WSXJtsmraIVLA3xw*Mvd3l+1 zI?c(+Nz>WR;D)5Mj_&SmR##UE27|1utN?I&dfIfR6jK0 z%Wc3~?iA>`OJ2LwE-9DGY;0`cx-MH=TL6rVjJ(xapr;9JIy|(YP>7+SA@=w8>Fw<$ zlgSW|$C;jm%^sT9}O*F+)_4i69M@9$@Lc(|o$mCH+q z;+x`8-JsdI&%XFS9{QIDFU;KMi7$bWRFn5^Jn`w1X!O0WEzA1oA^)YTtE)d=zyAA| zgI|9;0
    +{if $display_mode == 'letters'} +
  • {'cloud'|@translate}
  • +{/if} + +{if $display_mode == 'cloud'} +
  • {'letters'|@translate}
  • +{/if} +
  • {'home'|@translate}

{'Tags'|@translate}

- {if isset($tags)} +{if isset($tags)} + {if $display_mode == 'cloud'}
    {foreach from=$tags item=tag}
  • {$tag.NAME}
  • @@ -16,4 +25,31 @@
{/if} + {if $display_mode == 'letters'} + + + + + +
+ {foreach from=$letters item=letter} +
+ {$letter.TITLE} + + {foreach from=$letter.tags item=tag} + + + + + {/foreach} +
{$tag.NAME}{$tag.COUNTER} {'photos'|@translate}
+
+ {if $letter.CHANGE_COLUMN} +
+ {/if} + {/foreach} +
+ {/if} +{/if} +