Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
c3b93a47
Commit
c3b93a47
authored
Feb 15, 2007
by
Martyn Smith
Committed by
Martyn Smith
Feb 15, 2007
Browse files
Work on self search
parent
4a0c666a
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/json/selfsearch.php
0 → 100644
View file @
c3b93a47
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
define
(
'JSON'
,
1
);
require
(
dirname
(
dirname
(
__FILE__
))
.
'/init.php'
);
require
(
'searchlib.php'
);
try
{
$query
=
param_variable
(
'query'
);
}
catch
(
ParameterException
$e
)
{
json_reply
(
'missingparameter'
,
'Missing parameter \'query\''
);
}
$type
=
param_variable
(
'type'
,
'user'
);
$limit
=
param_integer
(
'limit'
,
20
);
$offset
=
param_integer
(
'offset'
,
0
);
switch
(
$type
)
{
case
'community'
:
$data
=
search_community
(
$query
,
$limit
,
$offset
,
true
);
$data
[
'type'
]
=
'community'
;
break
;
default
:
$data
=
search_user
(
$query
,
$limit
,
$offset
);
$data
[
'type'
]
=
'user'
;
break
;
}
json_headers
();
$data
[
'error'
]
=
false
;
$data
[
'message'
]
=
false
;
echo
json_encode
(
$data
);
?>
htdocs/search/internal/lib.php
View file @
c3b93a47
...
...
@@ -325,6 +325,26 @@ class PluginSearchInternal extends PluginSearch {
'data'
=>
$data
,
);
}
/**
* Given a query string and limits, return an array of matching objects
* owned by the current user. Possible return types are ...
* - artefact
* - view
*
* Implementations of this search should search across tags for artefacts
* and views at a minimum. Ideally the search would also index
* title/description and other metadata for these objects.
*
* @param string The query string
* @param integer How many results to return
* @param integer What result to start at (0 == first result)
* @param string Type to search for (either 'all' or one of the types above).
*
*/
public
static
function
self_search
(
$query_string
,
$limit
,
$offset
,
$type
=
'all'
)
{
throw
new
Exception
(
'TODO: implement me!'
);
}
}
?>
htdocs/search/lib.php
View file @
c3b93a47
...
...
@@ -161,7 +161,7 @@ abstract class PluginSearch extends Plugin {
* @param string Type to search for (either 'all' or one of the types above).
*
*/
//
public static abstract function self_search($query_string, $limit, $offset, $type = 'all');
public
static
abstract
function
self_search
(
$query_string
,
$limit
,
$offset
,
$type
=
'all'
);
}
?>
htdocs/search/solr/lib.php
View file @
c3b93a47
...
...
@@ -161,7 +161,38 @@ END;
return
$results
;
}
public
static
function
self_search
(
$query_string
,
$limit
,
$offset
)
{
/**
* Given a query string and limits, return an array of matching objects
* owned by the current user. Possible return types are ...
* - artefact
* - view
*
* Implementations of this search should search across tags for artefacts
* and views at a minimum. Ideally the search would also index
* title/description and other metadata for these objects.
*
* @param string The query string
* @param integer How many results to return
* @param integer What result to start at (0 == first result)
* @param string Type to search for (either 'all' or one of the types above).
*
*/
public
static
function
self_search
(
$query_string
,
$limit
,
$offset
,
$type
=
'all'
)
{
if
(
$type
!=
'artefact'
&&
$type
!=
'view'
)
{
$type
=
'artefact OR view'
;
}
$results
=
self
::
send_query
(
$query_string
,
$limit
,
$offset
,
array
(
'type'
=>
$type
));
if
(
is_array
(
$results
[
'data'
]))
{
foreach
(
$results
[
'data'
]
as
&
$result
)
{
$new_result
=
array
();
foreach
(
$result
as
$key
=>
&
$value
)
{
if
(
$key
==
'id'
||
$key
==
'title'
||
$key
==
'description'
||
$key
==
'type'
)
{
$new_result
[
$key
]
=
$value
;
}
}
$result
=
$new_result
;
}
}
}
// This function will rebuild the solr indexes
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment