diff --git a/src/IDF/Views/Issue.php b/src/IDF/Views/Issue.php index 03f3fec..bc0689c 100644 --- a/src/IDF/Views/Issue.php +++ b/src/IDF/Views/Issue.php @@ -197,7 +197,7 @@ class IDF_Views_Issue return new Pluf_HTTP_Response_Redirect($url); } $q = $request->REQUEST['q']; - $title = sprintf(__('Search Issues - %s'), Pluf_esc($q)); + $title = sprintf(__('Search Issues - %s'), $q); $issues = new Pluf_Search_ResultSet(IDF_Search::mySearch($q, $prj, 'IDF_Issue')); if (count($issues) > 100) { // no more than 100 results as we do not care diff --git a/src/IDF/Views/Wiki.php b/src/IDF/Views/Wiki.php index 11c5078..b6eded4 100644 --- a/src/IDF/Views/Wiki.php +++ b/src/IDF/Views/Wiki.php @@ -78,6 +78,48 @@ class IDF_Views_Wiki $request); } + public $search_precond = array('IDF_Precondition::accessWiki',); + public function search($request, $match) + { + $prj = $request->project; + if (!isset($request->REQUEST['q']) or trim($request->REQUEST['q']) == '') { + $url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::index', + array($prj->shortname)); + return new Pluf_HTTP_Response_Redirect($url); + } + $q = $request->REQUEST['q']; + $title = sprintf(__('Documentation Search - %s'), $q); + $pages = new Pluf_Search_ResultSet(IDF_Search::mySearch($q, $prj, 'IDF_WikiPage')); + if (count($pages) > 100) { + $pages->results = array_slice($pages->results, 0, 100); + } + $pag = new Pluf_Paginator(); + $pag->items = $pages; + $pag->class = 'recent-issues'; + $pag->item_extra_props = array('project_m' => $prj, + 'shortname' => $prj->shortname, + 'current_user' => $request->user); + $pag->summary = __('This table shows the pages found.'); + $pag->action = array('IDF_Views_Wiki::search', array($prj->shortname), array('q'=> $q)); + $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); + $pag->items_per_page = 100; + $pag->no_results_text = __('No pages were found.'); + $pag->setFromRequest($request); + $params = array('page_title' => $title, + 'pages' => $pag, + 'q' => $q, + ); + return Pluf_Shortcuts_RenderToResponse('idf/wiki/search.html', $params, $request); + + } + + /** * Create a new documentation page. */ diff --git a/src/IDF/WikiPage.php b/src/IDF/WikiPage.php index 40f8770..6d17a11 100644 --- a/src/IDF/WikiPage.php +++ b/src/IDF/WikiPage.php @@ -131,7 +131,7 @@ class IDF_WikiPage extends Pluf_Model function _toIndex() { $rev = $this->get_current_revision()->_toIndex(); - $str = str_repeat($this->summary.' ', 4).' '.$rev; + $str = str_repeat($this->title.' '.$this->summary.' ', 4).' '.$rev; return Pluf_Text::cleanString(html_entity_decode($str, ENT_QUOTES, 'UTF-8')); } diff --git a/src/IDF/conf/urls.php b/src/IDF/conf/urls.php index f08d462..0a13e95 100644 --- a/src/IDF/conf/urls.php +++ b/src/IDF/conf/urls.php @@ -215,6 +215,12 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/create/$#', 'model' => 'IDF_Views_Wiki', 'method' => 'create'); +$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/search/$#', + 'base' => $base, + 'priority' => 4, + 'model' => 'IDF_Views_Wiki', + 'method' => 'search'); + $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/update/(.*)/$#', 'base' => $base, 'priority' => 4, diff --git a/src/IDF/templates/idf/wiki/base.html b/src/IDF/templates/idf/wiki/base.html index 0219876..7a4fe0f 100644 --- a/src/IDF/templates/idf/wiki/base.html +++ b/src/IDF/templates/idf/wiki/base.html @@ -5,6 +5,11 @@ {trans 'List Pages'} {if !$user.isAnonymous()} | {trans 'New Page'} {/if} {if !$user.isAnonymous() and $inView} | {trans 'Update This Page'} {/if} + | +
{superblock} {/block} diff --git a/src/IDF/templates/idf/wiki/search.html b/src/IDF/templates/idf/wiki/search.html new file mode 100644 index 0000000..08edbe3 --- /dev/null +++ b/src/IDF/templates/idf/wiki/search.html @@ -0,0 +1,13 @@ +{extends "idf/wiki/base.html"} +{block docclass}yui-t1{assign $inWiki=true}{/block} +{block body} +{$pages.render} +{if !$user.isAnonymous()} +{aurl 'url', 'IDF_Views_Wiki::create', array($project.shortname)} +{/if} + +{/block} +{block context} +{trans 'Pages found:'} {$pages.nb_items}
+{/block} +