Fixed issue 9, do not show the deprecated files by default.

dev
Loic d'Anterroches 2008-09-02 23:31:43 +02:00
parent ee88dbed86
commit 14811beeba
3 changed files with 53 additions and 7 deletions

View File

@ -287,13 +287,21 @@ class IDF_Project extends Pluf_Model
'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 {
} elseif ($what == 'downloads') {
$dep_ids = IDF_Views_Download::getDeprecatedFilesIds($this);
$extra = '';
if (count($dep_ids) and $what == 'downloads') {
$extra = ' AND idf_upload_id NOT IN ('.implode(', ', $dep_ids).') ';
}
if (count($dep_ids) and $what != 'downloads') {
$extra = ' AND idf_upload_id IN ('.implode(', ', $dep_ids).') ';
}
$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';
'WHERE idf_tag_id IS NOT NULL '.$extra.' 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) {

View File

@ -51,7 +51,15 @@ class IDF_Views_Download
$pag->summary = __('This table shows the files to download.');
$pag->action = array('IDF_Views_Download::index', array($prj->shortname));
$pag->edit_action = array('IDF_Views_Download::view', 'shortname', 'id');
$pag->forced_where = new Pluf_SQL('project=%s', array($prj->id));
$sql = 'project=%s';
$ptags = self::getDownloadTags($prj);
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
$ids = self::getDeprecatedFilesIds($prj);
if (count($ids)) {
$sql .= ' AND id NOT IN ('.implode(',', $ids).')';
}
$pag->forced_where = new Pluf_SQL($sql, array($prj->id));
$list_display = array(
'file' => __('File'),
array('summary', 'IDF_Views_Download_SummaryAndLabels', __('Summary')),
@ -69,6 +77,8 @@ class IDF_Views_Download
'page_title' => $title,
'downloads' => $pag,
'tags' => $tags,
'deprecated' => count($ids),
'dlabel' => $dtag,
),
$request);
@ -246,6 +256,8 @@ class IDF_Views_Download
$title = sprintf(__('%1$s Downloads with Label %2$s'), (string) $prj,
(string) $tag);
// Paginator to paginate the downloads
$ptags = self::getDownloadTags($prj);
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
$pag = new Pluf_Paginator(new IDF_Upload());
$pag->model_view = 'join_tags';
$pag->class = 'recent-issues';
@ -273,6 +285,7 @@ class IDF_Views_Download
'label' => $tag,
'downloads' => $pag,
'tags' => $tags,
'dlabel' => $dtag,
),
$request);
}
@ -289,6 +302,25 @@ class IDF_Views_Download
IDF_Form_UploadConf::init_predefined);
}
/**
* Get deprecated file ids.
*
* @return array Ids of the deprecated files.
*/
public static function getDeprecatedFilesIds($project)
{
$ptags = self::getDownloadTags($project);
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
$sql = new Pluf_SQL('project=%s AND idf_tag_id=%s', array($project->id,
$dtag->id));
$ids = array();
foreach (Pluf::factory('IDF_Upload')->getList(array('filter' => $sql->gen(), 'view' => 'join_tags'))
as $file) {
$ids[] = (int) $file->id;
}
return $ids;
}
}
/**

View File

@ -10,10 +10,16 @@
{block context}
<p><strong>{trans 'Number of files:'}</strong> {$downloads.nb_items}</p>
{assign $class = ''}{assign $i = 0}
<p class="smaller">{foreach $tags as $label}
{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $label.id)}
{if $class != $label.class}{if $i != 0}<br />{/if}<strong class="label">{$label.class}:</strong> {/if}
<a href="{$url}" class="label">{$label.name}</a>,{assign $i = $i + 1}{assign $class = $label.class}{/foreach}</p>
{if !$label or $label.id != $dlabel.id}
<p class="smaller">{foreach $tags as $lab}
{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $lab.id)}
{if $class != $lab.class}{if $i != 0}<br />{/if}<strong class="label">{$lab.class}:</strong> {/if}
<a href="{$url}" class="label">{$lab.name}</a>,{assign $i = $i + 1}{assign $class = $lab.class}{/foreach}</p>
{/if}
{if $deprecated > 0}
{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $dlabel.id)}
<p class="helptext">{blocktrans}See <a href="{$url}">the deprecated files</a>.{/blocktrans}</p>
{/if}
{/block}