Commit 442ffc6f authored by Nigel McNie's avatar Nigel McNie
Browse files

Added basic workings for the search, so that the search tab sort of works....

Added basic workings for the search, so that the search tab sort of works. It's not scalable yet though - table scan of artefact using ILIKE.
parent dd1039c7
......@@ -576,6 +576,7 @@ class View {
}
break;
case 'configureblockinstance': // requires action_configureblockinstance_id_\d_column_\d_order_\d
case 'acsearch': // requires action_acsearch_id_\d
if (!defined('JSON')) {
$this->blockinstance_currently_being_configured = $values['id'];
// And we're done here for now
......@@ -1139,7 +1140,7 @@ class View {
* Makes a URL for a view block editing page
*/
public static function make_base_url() {
static $allowed_keys = array('id', 'change', 'c', 'new');
static $allowed_keys = array('id', 'change', 'c', 'new', 'search');
$baseurl = '?';
foreach (array_merge($_POST, $_GET) as $key => $value) {
if (in_array($key, $allowed_keys) || preg_match('/^action_.*_x$/', $key)/* || preg_match('/^cb_\d+_[a-z_]+_o$/', $key)*/) {
......@@ -1162,6 +1163,11 @@ class View {
public static function build_artefactchooser_data($data) {
global $USER;
$search = param_variable('search', '');
//if (strlen($search) < 3) {
// $search = '';
//}
$artefacttypes = $data['artefacttypes'];
$offset = $data['offset'];
$limit = $data['limit'];
......@@ -1179,6 +1185,10 @@ class View {
if (!empty($artefacttypes)) {
$select .= ' AND artefacttype IN(' . implode(',', array_map('db_quote', $artefacttypes)) . ')';
}
if ($search != '') {
$search = db_quote('%' . str_replace('%', '%%', $search) . '%');
$select .= 'AND (title ILIKE(' . $search . ') OR description ILIKE(' . $search . ') )';
}
$sortorder = 'title';
if (method_exists($blocktypeclass, 'artefactchooser_get_sort_order')) {
$sortorder = call_static_method($blocktypeclass, 'artefactchooser_get_sort_order');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment