Added view of pages by label.

This commit is contained in:
Loic d'Anterroches 2008-11-25 21:07:51 +01:00
parent 7a0a0b523b
commit 86ab5221a7
4 changed files with 77 additions and 9 deletions

View File

@ -287,7 +287,7 @@ class IDF_Project extends Pluf_Model
* get the extra property 'nb_use' for the number of use in the * get the extra property 'nb_use' for the number of use in the
* project. * project.
* *
* @param string ('issues') 'closed_issues' or 'downloads' * @param string ('issues') 'closed_issues', 'wiki' or 'downloads'
* @return ArrayObject of IDF_Tag * @return ArrayObject of IDF_Tag
*/ */
public function getTagCloud($what='issues') public function getTagCloud($what='issues')
@ -307,15 +307,24 @@ class IDF_Project extends Pluf_Model
'LEFT JOIN '.$what_t.' ON idf_issue_id='.$what_t.'.id '."\n". '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', '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)); implode(', ', $ostatus));
} elseif ($what == 'wiki') {
$dep_ids = IDF_Views_Wiki::getDeprecatedPagesIds($this);
$extra = '';
if (count($dep_ids)) {
$extra = ' AND idf_wikipage_id NOT IN ('.implode(', ', $dep_ids).') ';
}
$what_t = Pluf::factory('IDF_WikiPage')->getSqlTable();
$asso_t = $this->_con->pfx.'idf_tag_idf_wikipage_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_wikipage_id='.$what_t.'.id '."\n".
'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';
} elseif ($what == 'downloads') { } elseif ($what == 'downloads') {
$dep_ids = IDF_Views_Download::getDeprecatedFilesIds($this); $dep_ids = IDF_Views_Download::getDeprecatedFilesIds($this);
$extra = ''; $extra = '';
if (count($dep_ids) and $what == 'downloads') { if (count($dep_ids)) {
$extra = ' AND idf_upload_id NOT IN ('.implode(', ', $dep_ids).') '; $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(); $what_t = Pluf::factory('IDF_Upload')->getSqlTable();
$asso_t = $this->_con->pfx.'idf_tag_idf_upload_assoc'; $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". $sql = 'SELECT '.$tag_t.'.id AS id, COUNT(*) AS nb_use FROM '.$tag_t.' '."\n".

View File

@ -66,12 +66,12 @@ class IDF_Views_Wiki
$pag->no_results_text = __('No documentation pages were found.'); $pag->no_results_text = __('No documentation pages were found.');
$pag->sort_order = array('title', 'ASC'); $pag->sort_order = array('title', 'ASC');
$pag->setFromRequest($request); $pag->setFromRequest($request);
//$tags = $prj->getTagCloud('downloads'); $tags = $prj->getTagCloud('wiki');
return Pluf_Shortcuts_RenderToResponse('idf/wiki/index.html', return Pluf_Shortcuts_RenderToResponse('idf/wiki/index.html',
array( array(
'page_title' => $title, 'page_title' => $title,
'pages' => $pag, 'pages' => $pag,
//'tags' => $tags, 'tags' => $tags,
'deprecated' => count($ids), 'deprecated' => count($ids),
'dlabel' => $dtag, 'dlabel' => $dtag,
), ),
@ -119,6 +119,49 @@ class IDF_Views_Wiki
} }
/**
* View list of pages with a given label.
*/
public $listLabel_precond = array('IDF_Precondition::accessWiki');
public function listLabel($request, $match)
{
$prj = $request->project;
$tag = Pluf_Shortcuts_GetObjectOr404('IDF_Tag', $match[2]);
$prj->inOr404($tag);
$title = sprintf(__('%1$s Documentation Pages with Label %2$s'), (string) $prj,
(string) $tag);
// Paginator to paginate the pages
$ptags = self::getWikiTags($prj);
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
$pag = new Pluf_Paginator(new IDF_WikiPage());
$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 documentation pages 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_Wiki::listLabel', array($prj->shortname, $tag->id));
$pag->edit_action = array('IDF_Views_Wiki::view', 'shortname', 'title');
$list_display = array(
'title' => __('Page Title'),
array('summary', 'IDF_Views_Wiki_SummaryAndLabels', __('Summary')),
array('modif_dtime', 'Pluf_Paginator_DateYMD', __('Updated')),
);
$pag->configure($list_display, array(), array('title', 'modif_dtime'));
$pag->items_per_page = 25;
$pag->no_results_text = __('No documentation pages were found.');
$pag->setFromRequest($request);
$tags = $prj->getTagCloud('wiki');
return Pluf_Shortcuts_RenderToResponse('idf/wiki/index.html',
array(
'page_title' => $title,
'label' => $tag,
'pages' => $pag,
'tags' => $tags,
'dlabel' => $dtag,
),
$request);
}
/** /**
* Create a new documentation page. * Create a new documentation page.
@ -317,7 +360,7 @@ class IDF_Views_Wiki
public static function getDeprecatedPagesIds($project, $dtag=null) public static function getDeprecatedPagesIds($project, $dtag=null)
{ {
if (is_null($dtag)) { if (is_null($dtag)) {
$ptags = self::getDownloadTags($project); $ptags = self::getWikiTags($project);
$dtag = array_pop($ptags); // The last tag is the deprecated tag $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, $sql = new Pluf_SQL('project=%s AND idf_tag_id=%s', array($project->id,
@ -355,7 +398,6 @@ class IDF_Views_Wiki
} }
return substr($auto, 0, -1); return substr($auto, 0, -1);
} }
} }
/** /**

View File

@ -221,6 +221,12 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/search/$#',
'model' => 'IDF_Views_Wiki', 'model' => 'IDF_Views_Wiki',
'method' => 'search'); 'method' => 'search');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/label/(\d+)/$#',
'base' => $base,
'priority' => 4,
'model' => 'IDF_Views_Wiki',
'method' => 'listLabel');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/update/(.*)/$#', $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/update/(.*)/$#',
'base' => $base, 'base' => $base,
'priority' => 4, 'priority' => 4,

View File

@ -9,5 +9,16 @@
{/block} {/block}
{block context} {block context}
<p><strong>{trans 'Number of pages:'}</strong> {$pages.nb_items}</p> <p><strong>{trans 'Number of pages:'}</strong> {$pages.nb_items}</p>
{assign $class = ''}{assign $i = 0}
{if !$label or $label.id != $dlabel.id}
<p class="smaller">{foreach $tags as $lab}
{aurl 'url', 'IDF_Views_Wiki::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_Wiki::listLabel', array($project.shortname, $dlabel.id)}
<p class="helptext">{blocktrans}See <a href="{$url}">the deprecated pages</a>.{/blocktrans}</p>
{/if}
{/block} {/block}