Fixed issue 7, filter the downloads by label.
This commit is contained in:
parent
7070e8a13a
commit
3b5251c1b4
@ -42,6 +42,8 @@ class IDF_Views_Download
|
||||
{
|
||||
$prj = $request->project;
|
||||
$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.
|
||||
$pag = new Pluf_Paginator(new IDF_Upload());
|
||||
$pag->class = 'recent-issues';
|
||||
@ -186,6 +188,46 @@ class IDF_Views_Download
|
||||
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.
|
||||
*
|
||||
@ -210,7 +252,9 @@ function IDF_Views_Download_SummaryAndLabels($field, $down, $extra='')
|
||||
{
|
||||
$tags = array();
|
||||
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 = '';
|
||||
if (count($tags)) {
|
||||
|
@ -147,12 +147,20 @@ $ctl[] = array('regex' => '#^/p/(\w+)/source/download/(\w+)/$#',
|
||||
'model' => 'IDF_Views_Source',
|
||||
'method' => 'download');
|
||||
|
||||
// ---------- Downloads ------------------------------------
|
||||
|
||||
$ctl[] = array('regex' => '#^/p/(\w+)/downloads/$#',
|
||||
'base' => $base,
|
||||
'priority' => 4,
|
||||
'model' => 'IDF_Views_Download',
|
||||
'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+)/$#',
|
||||
'base' => $base,
|
||||
'priority' => 4,
|
||||
|
@ -2,8 +2,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: InDefero\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2008-08-06 14:49+0200\n"
|
||||
"PO-Revision-Date: 2008-08-06 14:51+0100\n"
|
||||
"POT-Creation-Date: 2008-08-06 21:49+0200\n"
|
||||
"PO-Revision-Date: 2008-08-06 21:51+0100\n"
|
||||
"Last-Translator: Loïc d'Anterroches <titoo@users.sourceforge.net>\n"
|
||||
"Language-Team: Translation team <titoo@users.sourceforge.net>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -227,12 +227,15 @@ msgid "%s Downloads"
|
||||
msgstr "Téléchargements de %s"
|
||||
|
||||
#: IDF/Views/Download.php:50
|
||||
#: IDF/Views/Download.php:52
|
||||
msgid "This table shows the files to download."
|
||||
msgstr "Ce tableau présente la liste des fichiers en téléchargement."
|
||||
|
||||
#: IDF/Views/Download.php:54
|
||||
#: IDF/gettexttemplates/source/tree.html.php:6
|
||||
#: IDF/Form/Upload.php:49
|
||||
#: IDF/Views/Download.php:56
|
||||
#: IDF/Views/Download.php:212
|
||||
msgid "File"
|
||||
msgstr "Fichier"
|
||||
|
||||
@ -245,28 +248,38 @@ msgstr "Fichier"
|
||||
#: IDF/Form/IssueCreate.php:50
|
||||
#: IDF/Form/UpdateUpload.php:42
|
||||
#: IDF/Form/IssueUpdate.php:45
|
||||
#: IDF/Views/Download.php:57
|
||||
#: IDF/Views/Download.php:213
|
||||
msgid "Summary"
|
||||
msgstr "Résumé"
|
||||
|
||||
#: IDF/Views/Download.php:56
|
||||
#: IDF/gettexttemplates/source/tree.html.php:9
|
||||
#: IDF/Views/Download.php:58
|
||||
#: IDF/Views/Download.php:214
|
||||
msgid "Size"
|
||||
msgstr "Taille"
|
||||
|
||||
#: IDF/Views/Download.php:57
|
||||
#: IDF/Views/Download.php:59
|
||||
#: IDF/Views/Download.php:215
|
||||
msgid "Uploaded"
|
||||
msgstr "Mis en ligne"
|
||||
|
||||
#: IDF/Views/Download.php:61
|
||||
#: IDF/Views/Download.php:63
|
||||
#: IDF/Views/Download.php:219
|
||||
msgid "No downloads were found."
|
||||
msgstr "Aucun fichier n'a été trouvé."
|
||||
|
||||
#: IDF/Views/Download.php:81
|
||||
#: IDF/Views/Download.php:83
|
||||
#, php-format
|
||||
msgid "Download %s"
|
||||
msgstr "Télécharger %s"
|
||||
|
||||
#: IDF/Views/Download.php:94
|
||||
#: IDF/Views/Download.php:96
|
||||
#, php-format
|
||||
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."
|
||||
@ -274,10 +287,12 @@ msgstr "Le fichier <a href=\"%1$s\">%2$s</a> a été mis à jour."
|
||||
#: IDF/Views/Download.php:135
|
||||
#: IDF/gettexttemplates/downloads/base.html.php:4
|
||||
#: IDF/gettexttemplates/downloads/index.html.php:3
|
||||
#: IDF/Views/Download.php:137
|
||||
msgid "New Download"
|
||||
msgstr "Nouveau téléchargement"
|
||||
|
||||
#: IDF/Views/Download.php:144
|
||||
#: IDF/Views/Download.php:146
|
||||
#, php-format
|
||||
msgid "The <a href=\"%s\">file</a> has been uploaded."
|
||||
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"
|
||||
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."
|
||||
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\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"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -217,50 +217,54 @@ msgstr ""
|
||||
msgid "%s Downloads"
|
||||
msgstr ""
|
||||
|
||||
#: IDF/Views/Download.php:50
|
||||
#: IDF/Views/Download.php:50 IDF/Views/Download.php:52
|
||||
msgid "This table shows the files to download."
|
||||
msgstr ""
|
||||
|
||||
#: 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"
|
||||
msgstr ""
|
||||
|
||||
#: 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/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"
|
||||
msgstr ""
|
||||
|
||||
#: IDF/Views/Download.php:56 IDF/gettexttemplates/source/tree.html.php:9
|
||||
#: IDF/Views/Download.php:58 IDF/Views/Download.php:214
|
||||
msgid "Size"
|
||||
msgstr ""
|
||||
|
||||
#: IDF/Views/Download.php:57
|
||||
#: IDF/Views/Download.php:57 IDF/Views/Download.php:59
|
||||
#: IDF/Views/Download.php:215
|
||||
msgid "Uploaded"
|
||||
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."
|
||||
msgstr ""
|
||||
|
||||
#: IDF/Views/Download.php:81
|
||||
#: IDF/Views/Download.php:81 IDF/Views/Download.php:83
|
||||
#, php-format
|
||||
msgid "Download %s"
|
||||
msgstr ""
|
||||
|
||||
#: IDF/Views/Download.php:94
|
||||
#: IDF/Views/Download.php:94 IDF/Views/Download.php:96
|
||||
#, php-format
|
||||
msgid "The file <a href=\"%1$s\">%2$s</a> has been updated."
|
||||
msgstr ""
|
||||
|
||||
#: 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"
|
||||
msgstr ""
|
||||
|
||||
#: IDF/Views/Download.php:144
|
||||
#: IDF/Views/Download.php:144 IDF/Views/Download.php:146
|
||||
#, php-format
|
||||
msgid "The <a href=\"%s\">file</a> has been uploaded."
|
||||
msgstr ""
|
||||
@ -1153,3 +1157,13 @@ msgstr ""
|
||||
#, php-format
|
||||
msgid "%s Commit Details - %s"
|
||||
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 ""
|
||||
|
@ -55,8 +55,8 @@
|
||||
{assign $tags = $file.get_tags_list()}{if $tags.count()}
|
||||
<p>
|
||||
<strong>{trans 'Labels:'}</strong><br />
|
||||
{foreach $tags as $tag}
|
||||
<span class="label"><strong>{$tag.class}:</strong>{$tag.name}</span><br />
|
||||
{foreach $tags as $tag}{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $tag.id)}
|
||||
<span class="label"><a href="{$url}" class="label"><strong>{$tag.class}:</strong>{$tag.name}</a></span><br />
|
||||
{/foreach}
|
||||
</p>{/if}
|
||||
{/block}
|
||||
|
Loading…
Reference in New Issue
Block a user