diff --git a/src/IDF/Project.php b/src/IDF/Project.php index f8581d1..1284fbc 100644 --- a/src/IDF/Project.php +++ b/src/IDF/Project.php @@ -287,7 +287,7 @@ class IDF_Project extends Pluf_Model * get the extra property 'nb_use' for the number of use in the * project. * - * @param string ('issues') 'closed_issues' or 'downloads' + * @param string ('issues') 'closed_issues', 'wiki' or 'downloads' * @return ArrayObject of IDF_Tag */ 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". '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)); + } 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') { $dep_ids = IDF_Views_Download::getDeprecatedFilesIds($this); $extra = ''; - if (count($dep_ids) and $what == 'downloads') { + if (count($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(); $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". diff --git a/src/IDF/Views/Wiki.php b/src/IDF/Views/Wiki.php index b6eded4..fb5bcb9 100644 --- a/src/IDF/Views/Wiki.php +++ b/src/IDF/Views/Wiki.php @@ -66,12 +66,12 @@ class IDF_Views_Wiki $pag->no_results_text = __('No documentation pages were found.'); $pag->sort_order = array('title', 'ASC'); $pag->setFromRequest($request); - //$tags = $prj->getTagCloud('downloads'); + $tags = $prj->getTagCloud('wiki'); return Pluf_Shortcuts_RenderToResponse('idf/wiki/index.html', array( 'page_title' => $title, 'pages' => $pag, - //'tags' => $tags, + 'tags' => $tags, 'deprecated' => count($ids), '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. @@ -317,7 +360,7 @@ class IDF_Views_Wiki public static function getDeprecatedPagesIds($project, $dtag=null) { if (is_null($dtag)) { - $ptags = self::getDownloadTags($project); + $ptags = self::getWikiTags($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, @@ -355,7 +398,6 @@ class IDF_Views_Wiki } return substr($auto, 0, -1); } - } /** diff --git a/src/IDF/conf/urls.php b/src/IDF/conf/urls.php index 0a13e95..9a69c51 100644 --- a/src/IDF/conf/urls.php +++ b/src/IDF/conf/urls.php @@ -221,6 +221,12 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/search/$#', 'model' => 'IDF_Views_Wiki', '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/(.*)/$#', 'base' => $base, 'priority' => 4, diff --git a/src/IDF/templates/idf/wiki/index.html b/src/IDF/templates/idf/wiki/index.html index b6f5212..d6dee59 100644 --- a/src/IDF/templates/idf/wiki/index.html +++ b/src/IDF/templates/idf/wiki/index.html @@ -9,5 +9,16 @@ {/block} {block context}

{trans 'Number of pages:'} {$pages.nb_items}

+{assign $class = ''}{assign $i = 0} +{if !$label or $label.id != $dlabel.id} +

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

+{/if} +{if $deprecated > 0} +{aurl 'url', 'IDF_Views_Wiki::listLabel', array($project.shortname, $dlabel.id)} +

{blocktrans}See the deprecated pages.{/blocktrans}

+{/if} {/block}