Fixed issue 7, filter the downloads by label.

This commit is contained in:
Loic d'Anterroches 2008-08-06 21:54:45 +02:00
parent 7070e8a13a
commit 3b5251c1b4
5 changed files with 106 additions and 15 deletions

View File

@ -42,6 +42,8 @@ class IDF_Views_Download
{ {
$prj = $request->project; $prj = $request->project;
$title = sprintf(__('%s Downloads'), (string) $prj); $title = sprintf(__('%s Downloads'), (string) $prj);
$tags = self::getDownloadTags($prj);
$dtag = array_pop($tags); // The last tag is the deprecated tag.
// Paginator to paginate the files to download. // Paginator to paginate the files to download.
$pag = new Pluf_Paginator(new IDF_Upload()); $pag = new Pluf_Paginator(new IDF_Upload());
$pag->class = 'recent-issues'; $pag->class = 'recent-issues';
@ -186,6 +188,46 @@ class IDF_Views_Download
return substr($auto, 0, -1); return substr($auto, 0, -1);
} }
/**
* View list of downloads with a given label.
*/
public function listLabel($request, $match)
{
$prj = $request->project;
$tag = Pluf_Shortcuts_GetObjectOr404('IDF_Tag', $match[2]);
$prj->inOr404($tag);
$title = sprintf(__('%1$s Downloads with Label %2$s'), (string) $prj,
(string) $tag);
// Paginator to paginate the downloads
$pag = new Pluf_Paginator(new IDF_Upload());
$pag->model_view = 'join_tags';
$pag->class = 'recent-issues';
$pag->item_extra_props = array('project_m' => $prj,
'shortname' => $prj->shortname);
$pag->summary = sprintf(__('This table shows the downloads with label %s.'), (string) $tag);
$pag->forced_where = new Pluf_SQL('project=%s AND idf_tag_id=%s', array($prj->id, $tag->id));
$pag->action = array('IDF_Views_Download::index', array($prj->shortname));
$pag->edit_action = array('IDF_Views_Download::view', 'shortname', 'id');
$list_display = array(
'file' => __('File'),
array('summary', 'IDF_Views_Download_SummaryAndLabels', __('Summary')),
array('filesize', 'IDF_Views_Download_Size', __('Size')),
array('modif_dtime', 'Pluf_Paginator_DateYMD', __('Uploaded')),
);
$pag->configure($list_display, array(), array('file', 'filesize', 'modif_dtime'));
$pag->items_per_page = 10;
$pag->no_results_text = __('No downloads were found.');
$pag->sort_order = array('file', 'ASC');
$pag->setFromRequest($request);
return Pluf_Shortcuts_RenderToResponse('downloads/index.html',
array(
'page_title' => $title,
'label' => $tag,
'downloads' => $pag,
),
$request);
}
/** /**
* Get the download tags. * Get the download tags.
* *
@ -210,7 +252,9 @@ function IDF_Views_Download_SummaryAndLabels($field, $down, $extra='')
{ {
$tags = array(); $tags = array();
foreach ($down->get_tags_list() as $tag) { foreach ($down->get_tags_list() as $tag) {
$tags[] = sprintf('<span class="label">%s</span>', Pluf_esc((string) $tag)); $url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::listLabel',
array($down->shortname, $tag->id));
$tags[] = sprintf('<a href="%s" class="label">%s</a>', $url, Pluf_esc((string) $tag));
} }
$out = ''; $out = '';
if (count($tags)) { if (count($tags)) {

View File

@ -147,12 +147,20 @@ $ctl[] = array('regex' => '#^/p/(\w+)/source/download/(\w+)/$#',
'model' => 'IDF_Views_Source', 'model' => 'IDF_Views_Source',
'method' => 'download'); 'method' => 'download');
// ---------- Downloads ------------------------------------
$ctl[] = array('regex' => '#^/p/(\w+)/downloads/$#', $ctl[] = array('regex' => '#^/p/(\w+)/downloads/$#',
'base' => $base, 'base' => $base,
'priority' => 4, 'priority' => 4,
'model' => 'IDF_Views_Download', 'model' => 'IDF_Views_Download',
'method' => 'index'); 'method' => 'index');
$ctl[] = array('regex' => '#^/p/(\w+)/downloads/label/(\d+)/$#',
'base' => $base,
'priority' => 4,
'model' => 'IDF_Views_Download',
'method' => 'listLabel');
$ctl[] = array('regex' => '#^/p/(\w+)/downloads/(\d+)/$#', $ctl[] = array('regex' => '#^/p/(\w+)/downloads/(\d+)/$#',
'base' => $base, 'base' => $base,
'priority' => 4, 'priority' => 4,

View File

@ -2,8 +2,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: InDefero\n" "Project-Id-Version: InDefero\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-08-06 14:49+0200\n" "POT-Creation-Date: 2008-08-06 21:49+0200\n"
"PO-Revision-Date: 2008-08-06 14:51+0100\n" "PO-Revision-Date: 2008-08-06 21:51+0100\n"
"Last-Translator: Loïc d'Anterroches <titoo@users.sourceforge.net>\n" "Last-Translator: Loïc d'Anterroches <titoo@users.sourceforge.net>\n"
"Language-Team: Translation team <titoo@users.sourceforge.net>\n" "Language-Team: Translation team <titoo@users.sourceforge.net>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -227,12 +227,15 @@ msgid "%s Downloads"
msgstr "Téléchargements de %s" msgstr "Téléchargements de %s"
#: IDF/Views/Download.php:50 #: IDF/Views/Download.php:50
#: IDF/Views/Download.php:52
msgid "This table shows the files to download." msgid "This table shows the files to download."
msgstr "Ce tableau présente la liste des fichiers en téléchargement." msgstr "Ce tableau présente la liste des fichiers en téléchargement."
#: IDF/Views/Download.php:54 #: IDF/Views/Download.php:54
#: IDF/gettexttemplates/source/tree.html.php:6 #: IDF/gettexttemplates/source/tree.html.php:6
#: IDF/Form/Upload.php:49 #: IDF/Form/Upload.php:49
#: IDF/Views/Download.php:56
#: IDF/Views/Download.php:212
msgid "File" msgid "File"
msgstr "Fichier" msgstr "Fichier"
@ -245,28 +248,38 @@ msgstr "Fichier"
#: IDF/Form/IssueCreate.php:50 #: IDF/Form/IssueCreate.php:50
#: IDF/Form/UpdateUpload.php:42 #: IDF/Form/UpdateUpload.php:42
#: IDF/Form/IssueUpdate.php:45 #: IDF/Form/IssueUpdate.php:45
#: IDF/Views/Download.php:57
#: IDF/Views/Download.php:213
msgid "Summary" msgid "Summary"
msgstr "Résumé" msgstr "Résumé"
#: IDF/Views/Download.php:56 #: IDF/Views/Download.php:56
#: IDF/gettexttemplates/source/tree.html.php:9 #: IDF/gettexttemplates/source/tree.html.php:9
#: IDF/Views/Download.php:58
#: IDF/Views/Download.php:214
msgid "Size" msgid "Size"
msgstr "Taille" msgstr "Taille"
#: IDF/Views/Download.php:57 #: IDF/Views/Download.php:57
#: IDF/Views/Download.php:59
#: IDF/Views/Download.php:215
msgid "Uploaded" msgid "Uploaded"
msgstr "Mis en ligne" msgstr "Mis en ligne"
#: IDF/Views/Download.php:61 #: IDF/Views/Download.php:61
#: IDF/Views/Download.php:63
#: IDF/Views/Download.php:219
msgid "No downloads were found." msgid "No downloads were found."
msgstr "Aucun fichier n'a été trouvé." msgstr "Aucun fichier n'a été trouvé."
#: IDF/Views/Download.php:81 #: IDF/Views/Download.php:81
#: IDF/Views/Download.php:83
#, php-format #, php-format
msgid "Download %s" msgid "Download %s"
msgstr "Télécharger %s" msgstr "Télécharger %s"
#: IDF/Views/Download.php:94 #: IDF/Views/Download.php:94
#: IDF/Views/Download.php:96
#, php-format #, php-format
msgid "The file <a href=\"%1$s\">%2$s</a> has been updated." msgid "The file <a href=\"%1$s\">%2$s</a> has been updated."
msgstr "Le fichier <a href=\"%1$s\">%2$s</a> a été mis à jour." msgstr "Le fichier <a href=\"%1$s\">%2$s</a> a été mis à jour."
@ -274,10 +287,12 @@ msgstr "Le fichier <a href=\"%1$s\">%2$s</a> a été mis à jour."
#: IDF/Views/Download.php:135 #: IDF/Views/Download.php:135
#: IDF/gettexttemplates/downloads/base.html.php:4 #: IDF/gettexttemplates/downloads/base.html.php:4
#: IDF/gettexttemplates/downloads/index.html.php:3 #: IDF/gettexttemplates/downloads/index.html.php:3
#: IDF/Views/Download.php:137
msgid "New Download" msgid "New Download"
msgstr "Nouveau téléchargement" msgstr "Nouveau téléchargement"
#: IDF/Views/Download.php:144 #: IDF/Views/Download.php:144
#: IDF/Views/Download.php:146
#, php-format #, php-format
msgid "The <a href=\"%s\">file</a> has been uploaded." msgid "The <a href=\"%s\">file</a> has been uploaded."
msgstr "Le <a href=\"%s\">fichier</a> a été mis en ligne." msgstr "Le <a href=\"%s\">fichier</a> a été mis en ligne."
@ -1211,3 +1226,13 @@ msgstr "Détails d'un commit de %s"
msgid "%s Commit Details - %s" msgid "%s Commit Details - %s"
msgstr "Détails d'un commit de %s - %s" msgstr "Détails d'un commit de %s - %s"
#: IDF/Views/Download.php:199
#, php-format
msgid "%1$s Downloads with Label %2$s"
msgstr "Téléchargements avec l'étiquette %2$s de %1$s"
#: IDF/Views/Download.php:207
#, php-format
msgid "This table shows the downloads with label %s."
msgstr "Ce tableau montre les téléchargements avec l'étiquette %s."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-08-06 14:49+0200\n" "POT-Creation-Date: 2008-08-06 21:49+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -217,50 +217,54 @@ msgstr ""
msgid "%s Downloads" msgid "%s Downloads"
msgstr "" msgstr ""
#: IDF/Views/Download.php:50 #: IDF/Views/Download.php:50 IDF/Views/Download.php:52
msgid "This table shows the files to download." msgid "This table shows the files to download."
msgstr "" msgstr ""
#: IDF/Views/Download.php:54 IDF/gettexttemplates/source/tree.html.php:6 #: IDF/Views/Download.php:54 IDF/gettexttemplates/source/tree.html.php:6
#: IDF/Form/Upload.php:49 #: IDF/Form/Upload.php:49 IDF/Views/Download.php:56 IDF/Views/Download.php:212
msgid "File" msgid "File"
msgstr "" msgstr ""
#: IDF/Views/Download.php:55 IDF/Views/Issue.php:57 IDF/Views/Issue.php:109 #: IDF/Views/Download.php:55 IDF/Views/Issue.php:57 IDF/Views/Issue.php:109
#: IDF/Views/Issue.php:228 IDF/Views/Issue.php:281 IDF/Form/Upload.php:40 #: IDF/Views/Issue.php:228 IDF/Views/Issue.php:281 IDF/Form/Upload.php:40
#: IDF/Form/IssueCreate.php:50 IDF/Form/UpdateUpload.php:42 #: IDF/Form/IssueCreate.php:50 IDF/Form/UpdateUpload.php:42
#: IDF/Form/IssueUpdate.php:45 #: IDF/Form/IssueUpdate.php:45 IDF/Views/Download.php:57
#: IDF/Views/Download.php:213
msgid "Summary" msgid "Summary"
msgstr "" msgstr ""
#: IDF/Views/Download.php:56 IDF/gettexttemplates/source/tree.html.php:9 #: IDF/Views/Download.php:56 IDF/gettexttemplates/source/tree.html.php:9
#: IDF/Views/Download.php:58 IDF/Views/Download.php:214
msgid "Size" msgid "Size"
msgstr "" msgstr ""
#: IDF/Views/Download.php:57 #: IDF/Views/Download.php:57 IDF/Views/Download.php:59
#: IDF/Views/Download.php:215
msgid "Uploaded" msgid "Uploaded"
msgstr "" msgstr ""
#: IDF/Views/Download.php:61 #: IDF/Views/Download.php:61 IDF/Views/Download.php:63
#: IDF/Views/Download.php:219
msgid "No downloads were found." msgid "No downloads were found."
msgstr "" msgstr ""
#: IDF/Views/Download.php:81 #: IDF/Views/Download.php:81 IDF/Views/Download.php:83
#, php-format #, php-format
msgid "Download %s" msgid "Download %s"
msgstr "" msgstr ""
#: IDF/Views/Download.php:94 #: IDF/Views/Download.php:94 IDF/Views/Download.php:96
#, php-format #, php-format
msgid "The file <a href=\"%1$s\">%2$s</a> has been updated." msgid "The file <a href=\"%1$s\">%2$s</a> has been updated."
msgstr "" msgstr ""
#: IDF/Views/Download.php:135 IDF/gettexttemplates/downloads/base.html.php:4 #: IDF/Views/Download.php:135 IDF/gettexttemplates/downloads/base.html.php:4
#: IDF/gettexttemplates/downloads/index.html.php:3 #: IDF/gettexttemplates/downloads/index.html.php:3 IDF/Views/Download.php:137
msgid "New Download" msgid "New Download"
msgstr "" msgstr ""
#: IDF/Views/Download.php:144 #: IDF/Views/Download.php:144 IDF/Views/Download.php:146
#, php-format #, php-format
msgid "The <a href=\"%s\">file</a> has been uploaded." msgid "The <a href=\"%s\">file</a> has been uploaded."
msgstr "" msgstr ""
@ -1153,3 +1157,13 @@ msgstr ""
#, php-format #, php-format
msgid "%s Commit Details - %s" msgid "%s Commit Details - %s"
msgstr "" msgstr ""
#: IDF/Views/Download.php:199
#, php-format
msgid "%1$s Downloads with Label %2$s"
msgstr ""
#: IDF/Views/Download.php:207
#, php-format
msgid "This table shows the downloads with label %s."
msgstr ""

View File

@ -55,8 +55,8 @@
{assign $tags = $file.get_tags_list()}{if $tags.count()} {assign $tags = $file.get_tags_list()}{if $tags.count()}
<p> <p>
<strong>{trans 'Labels:'}</strong><br /> <strong>{trans 'Labels:'}</strong><br />
{foreach $tags as $tag} {foreach $tags as $tag}{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $tag.id)}
<span class="label"><strong>{$tag.class}:</strong>{$tag.name}</span><br /> <span class="label"><a href="{$url}" class="label"><strong>{$tag.class}:</strong>{$tag.name}</a></span><br />
{/foreach} {/foreach}
</p>{/if} </p>{/if}
{/block} {/block}