Added documentation wiki search.
This commit is contained in:
parent
4dc0747769
commit
fd9cb62946
@ -197,7 +197,7 @@ class IDF_Views_Issue
|
|||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
$q = $request->REQUEST['q'];
|
$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'));
|
$issues = new Pluf_Search_ResultSet(IDF_Search::mySearch($q, $prj, 'IDF_Issue'));
|
||||||
if (count($issues) > 100) {
|
if (count($issues) > 100) {
|
||||||
// no more than 100 results as we do not care
|
// no more than 100 results as we do not care
|
||||||
|
@ -78,6 +78,48 @@ class IDF_Views_Wiki
|
|||||||
$request);
|
$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.
|
* Create a new documentation page.
|
||||||
*/
|
*/
|
||||||
|
@ -131,7 +131,7 @@ class IDF_WikiPage extends Pluf_Model
|
|||||||
function _toIndex()
|
function _toIndex()
|
||||||
{
|
{
|
||||||
$rev = $this->get_current_revision()->_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'));
|
return Pluf_Text::cleanString(html_entity_decode($str, ENT_QUOTES, 'UTF-8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +215,12 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/create/$#',
|
|||||||
'model' => 'IDF_Views_Wiki',
|
'model' => 'IDF_Views_Wiki',
|
||||||
'method' => 'create');
|
'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/(.*)/$#',
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/update/(.*)/$#',
|
||||||
'base' => $base,
|
'base' => $base,
|
||||||
'priority' => 4,
|
'priority' => 4,
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
<a {if $inWiki}class="active" {/if}href="{url 'IDF_Views_Wiki::index', array($project.shortname)}">{trans 'List Pages'}</a>
|
<a {if $inWiki}class="active" {/if}href="{url 'IDF_Views_Wiki::index', array($project.shortname)}">{trans 'List Pages'}</a>
|
||||||
{if !$user.isAnonymous()} | <a {if $inCreate}class="active" {/if}href="{url 'IDF_Views_Wiki::create', array($project.shortname)}">{trans 'New Page'}</a> {/if}
|
{if !$user.isAnonymous()} | <a {if $inCreate}class="active" {/if}href="{url 'IDF_Views_Wiki::create', array($project.shortname)}">{trans 'New Page'}</a> {/if}
|
||||||
{if !$user.isAnonymous() and $inView} | <a href="{url 'IDF_Views_Wiki::update', array($project.shortname, $page.title)}">{trans 'Update This Page'}</a> {/if}
|
{if !$user.isAnonymous() and $inView} | <a href="{url 'IDF_Views_Wiki::update', array($project.shortname, $page.title)}">{trans 'Update This Page'}</a> {/if}
|
||||||
|
|
|
||||||
|
<form class="star" action="{url 'IDF_Views_Wiki::search', array($project.shortname)}" method="get">
|
||||||
|
<input accesskey="4" type="text" value="{$q}" name="q" size="20" />
|
||||||
|
<input type="submit" name="s" value="{trans 'Search'}" />
|
||||||
|
</form>
|
||||||
{superblock}
|
{superblock}
|
||||||
</div>
|
</div>
|
||||||
{/block}
|
{/block}
|
||||||
|
13
src/IDF/templates/idf/wiki/search.html
Normal file
13
src/IDF/templates/idf/wiki/search.html
Normal file
@ -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)}
|
||||||
|
<p><a href="{$url}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/add.png'}" alt="+" align="bottom" /></a> <a href="{$url}">{trans 'New Page'}</a></p>{/if}
|
||||||
|
|
||||||
|
{/block}
|
||||||
|
{block context}
|
||||||
|
<p><strong>{trans 'Pages found:'}</strong> {$pages.nb_items}</p>
|
||||||
|
{/block}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user