blob: b3957781cb2c6ec66654f0eb73d2b6a340a1f415 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<?php
/**
* Part of grauphel
*
* PHP version 5
*
* @category Tools
* @package Grauphel
* @author Christian Weiske <cweiske@cweiske.de>
* @copyright 2014 Christian Weiske
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
* @link http://cweiske.de/grauphel.htm
*/
namespace OCA\Grauphel\Search;
use \OCA\Grauphel\Lib\NoteStorage;
/**
* Hook for the site-wide owncloud search.
*
* @category Tools
* @package Grauphel
* @author Christian Weiske <cweiske@cweiske.de>
* @copyright 2014 Christian Weiske
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
* @version Release: @package_version@
* @link http://cweiske.de/grauphel.htm
*/
class Provider extends \OCP\Search\Provider
{
/**
* Search for notes
*
* @param string $query
*
* @return array list of \OCA\Grauphel\Search\Note
*/
public function search($query)
{
$urlGen = \OC::$server->getURLGenerator();
$notes = new NoteStorage($urlGen);
$notes->setUsername(\OC_User::getUser());
$qp = new QueryParser();
$rows = $notes->search($qp->parse($query));
$results = array();
foreach ($rows as $row) {
$res = new Note();
$res->id = $row['note_guid'];
$res->name = htmlspecialchars_decode($row['note_title']);
$res->link = $urlGen->linkToRoute(
'grauphel.gui.note', array('guid' => $row['note_guid'])
);
$results[] = $res;
}
return $results;
}
}
?>
|