From a8699db26800e6ecf96bea7747507c042d4fcbed Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Wed, 6 Aug 2008 22:19:46 +0200 Subject: [PATCH] Improved the style for the labels in the context column. --- src/IDF/Project.php | 29 ++++++++++++++++++-------- src/IDF/Views/Download.php | 6 +++++- src/IDF/templates/downloads/index.html | 6 ++++++ src/IDF/templates/issues/index.html | 6 +++--- www/media/idf/css/style.css | 4 ++++ 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/IDF/Project.php b/src/IDF/Project.php index 641ad79..f1d946e 100644 --- a/src/IDF/Project.php +++ b/src/IDF/Project.php @@ -263,22 +263,33 @@ class IDF_Project extends Pluf_Model * * Return an array of tags sorted class, then name. Each tag get * the extra property 'nb_use' for the number of use in the - * project. Only open issues are used to generate the cloud. + * project. For issues, only open issues are used to generate the + * cloud. * + * @param string ('issues') or 'downloads' * @return ArrayObject of IDF_Tag */ - public function getTagCloud() + public function getTagCloud($what='issues') { $tag_t = Pluf::factory('IDF_Tag')->getSqlTable(); - $issue_t = Pluf::factory('IDF_Issue')->getSqlTable(); - $asso_t = $this->_con->pfx.'idf_issue_idf_tag_assoc'; - $ostatus = $this->getTagIdsByStatus('open'); - if (count($ostatus) == 0) $ostatus[] = 0; - $sql = sprintf('SELECT '.$tag_t.'.id AS id, COUNT(*) AS nb_use FROM '.$tag_t.' '."\n". + if ($what == 'issues') { + $what_t = Pluf::factory('IDF_Issue')->getSqlTable(); + $asso_t = $this->_con->pfx.'idf_issue_idf_tag_assoc'; + $ostatus = $this->getTagIdsByStatus('open'); + if (count($ostatus) == 0) $ostatus[] = 0; + $sql = sprintf('SELECT '.$tag_t.'.id AS id, COUNT(*) AS nb_use FROM '.$tag_t.' '."\n". 'LEFT JOIN '.$asso_t.' ON idf_tag_id='.$tag_t.'.id '."\n". - 'LEFT JOIN '.$issue_t.' ON idf_issue_id='.$issue_t.'.id '."\n". - 'WHERE idf_tag_id IS NOT NULL AND '.$issue_t.'.status IN (%s) AND '.$issue_t.'.project='.$this->id.' GROUP BY '.$tag_t.'.id, '.$tag_t.'.class, '.$tag_t.'.name ORDER BY '.$tag_t.'.class ASC, '.$tag_t.'.name ASC', + 'LEFT JOIN '.$what_t.' ON idf_issue_id='.$what_t.'.id '."\n". + 'WHERE idf_tag_id IS NOT NULL AND '.$what_t.'.status IN (%s) AND '.$what_t.'.project='.$this->id.' GROUP BY '.$tag_t.'.id, '.$tag_t.'.class, '.$tag_t.'.name ORDER BY '.$tag_t.'.class ASC, '.$tag_t.'.name ASC', implode(', ', $ostatus)); + } else { + $what_t = Pluf::factory('IDF_Upload')->getSqlTable(); + $asso_t = $this->_con->pfx.'idf_tag_idf_upload_assoc'; + $sql = 'SELECT '.$tag_t.'.id AS id, COUNT(*) AS nb_use FROM '.$tag_t.' '."\n". + 'LEFT JOIN '.$asso_t.' ON idf_tag_id='.$tag_t.'.id '."\n". + 'LEFT JOIN '.$what_t.' ON idf_upload_id='.$what_t.'.id '."\n". + 'WHERE idf_tag_id IS NOT NULL AND '.$what_t.'.project='.$this->id.' GROUP BY '.$tag_t.'.id, '.$tag_t.'.class, '.$tag_t.'.name ORDER BY '.$tag_t.'.class ASC, '.$tag_t.'.name ASC'; + } $tags = array(); foreach ($this->_con->select($sql) as $idc) { $tag = new IDF_Tag($idc['id']); diff --git a/src/IDF/Views/Download.php b/src/IDF/Views/Download.php index f09528e..edc4fb2 100644 --- a/src/IDF/Views/Download.php +++ b/src/IDF/Views/Download.php @@ -63,10 +63,12 @@ class IDF_Views_Download $pag->no_results_text = __('No downloads were found.'); $pag->sort_order = array('file', 'ASC'); $pag->setFromRequest($request); + $tags = $prj->getTagCloud('downloads'); return Pluf_Shortcuts_RenderToResponse('downloads/index.html', - array('project' => $prj, + array( 'page_title' => $title, 'downloads' => $pag, + 'tags' => $tags, ), $request); @@ -219,11 +221,13 @@ class IDF_Views_Download $pag->no_results_text = __('No downloads were found.'); $pag->sort_order = array('file', 'ASC'); $pag->setFromRequest($request); + $tags = $prj->getTagCloud('downloads'); return Pluf_Shortcuts_RenderToResponse('downloads/index.html', array( 'page_title' => $title, 'label' => $tag, 'downloads' => $pag, + 'tags' => $tags, ), $request); } diff --git a/src/IDF/templates/downloads/index.html b/src/IDF/templates/downloads/index.html index 4ac7e82..3363052 100644 --- a/src/IDF/templates/downloads/index.html +++ b/src/IDF/templates/downloads/index.html @@ -9,5 +9,11 @@ {/block} {block context}

{trans 'Number of files:'} {$downloads.nb_items}

+{assign $class = ''}{assign $i = 0} +

{foreach $tags as $label} +{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $label.id)} +{if $class != $label.class}{if $i != 0}
{/if}{$label.class}: {/if} +{$label.name},{assign $i = $i + 1}{assign $class = $label.class}{/foreach}

+ {/block} diff --git a/src/IDF/templates/issues/index.html b/src/IDF/templates/issues/index.html index 2fb493d..40ec183 100644 --- a/src/IDF/templates/issues/index.html +++ b/src/IDF/templates/issues/index.html @@ -12,9 +12,9 @@ {aurl 'closed_url', 'IDF_Views_Issue::listStatus', array($project.shortname, 'closed')} {blocktrans}

Open issues: {$open}

Closed issues: {$closed}

{/blocktrans} - +{assign $class = ''}{assign $i = 0}

{foreach $project.getTagCloud() as $label} {aurl 'url', 'IDF_Views_Issue::listLabel', array($project.shortname, $label.id, 'open')} -{$label.class}:{$label.name}{/foreach}

- +{if $class != $label.class}{if $i != 0}
{/if}{$label.class}: {/if} +{$label.name},{assign $class = $label.class}{assign $i = $i + 1}{/foreach}

{/block} diff --git a/www/media/idf/css/style.css b/www/media/idf/css/style.css index d9450f4..e0a085b 100644 --- a/www/media/idf/css/style.css +++ b/www/media/idf/css/style.css @@ -188,6 +188,10 @@ a.label { text-decoration: none; } +.label { + color: #204a87; +} + span.nobrk { white-space: nowrap; }