From 34e28b1ccb73cb488f36cec692c854f9502cdd18 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 9 Oct 2009 20:43:39 +0000 Subject: Reverted back to previous copy removing Justin's search because of views problems in plugins. git-svn-id: http://code.elgg.org/elgg/trunk@3521 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 4 +- engine/lib/entities.php | 34 ------ engine/lib/search.php | 50 ++++++++ engine/schema/upgrades/2009093001.sql | 11 -- mod/search/index.php | 132 --------------------- mod/search/languages/en.php | 8 -- mod/search/manifest.xml | 10 -- mod/search/start.php | 117 ------------------ .../views/default/page_elements/searchbox.php | 4 - mod/search/views/default/search/css.php | 61 ---------- mod/search/views/default/search/entity_list.php | 66 ----------- mod/search/views/default/search/gallery.php | 55 --------- mod/search/views/default/search/listing.php | 35 ------ views/default/page_elements/elgg_topbar.php | 7 +- views/default/search/entity_list.php | 62 ++++++++++ views/default/search/gallery.php | 49 ++++++++ views/default/search/gallery_listing.php | 35 ++++++ views/default/search/listing.php | 45 +++++++ views/default/search/startblurb.php | 8 ++ 19 files changed, 256 insertions(+), 537 deletions(-) create mode 100644 engine/lib/search.php delete mode 100644 engine/schema/upgrades/2009093001.sql delete mode 100644 mod/search/index.php delete mode 100644 mod/search/languages/en.php delete mode 100644 mod/search/manifest.xml delete mode 100644 mod/search/start.php delete mode 100644 mod/search/views/default/page_elements/searchbox.php delete mode 100644 mod/search/views/default/search/css.php delete mode 100644 mod/search/views/default/search/entity_list.php delete mode 100644 mod/search/views/default/search/gallery.php delete mode 100644 mod/search/views/default/search/listing.php create mode 100644 views/default/search/entity_list.php create mode 100644 views/default/search/gallery.php create mode 100644 views/default/search/gallery_listing.php create mode 100644 views/default/search/listing.php create mode 100644 views/default/search/startblurb.php diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index b2a157155..fc87c1dc1 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -719,7 +719,7 @@ $context = get_context(); - $html = elgg_view('entities/entity_list',array( + $html = elgg_view('search/entity_list',array( 'entities' => $entities, 'count' => $count, 'offset' => $offset, @@ -1000,7 +1000,7 @@ * @return string The HTML (etc) representing the listing */ function elgg_view_listing($icon, $info) { - return elgg_view('entities/entity_listing',array('icon' => $icon, 'info' => $info)); + return elgg_view('search/listing',array('icon' => $icon, 'info' => $info)); } /** diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 55a675154..b72eb6ff0 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -63,13 +63,6 @@ */ protected $temp_annotations; - - /** - * Volatile data structure for this object, allows for storage of data - * in-memory that isn't sync'd back to the metadata table. - */ - protected $volatile; - /** * Initialise the attributes array. * This is vital to distinguish between metadata and base parameters. @@ -86,7 +79,6 @@ if (!is_array($this->attributes)) $this->attributes = array(); if (!is_array($this->temp_metadata)) $this->temp_metadata = array(); if (!is_array($this->temp_annotations)) $this->temp_annotations = array(); - if (!is_array($this->volatile)) $this->volatile = array(); $this->attributes['guid'] = ""; $this->attributes['type'] = ""; @@ -182,31 +174,6 @@ return true; } - - /** - * Get a piece of volatile (non-persisted) data on this entity - */ - public function getVolatileData($name) { - if (!is_array($this->volatile)) $this->volatile = array(); - - if (array_key_exists($name, $this->volatile)) { - return $this->volatile[$name]; - } else { - return NULL; - } - } - - - /** - * Get a piece of volatile (non-persisted) data on this entity - */ - public function setVolatileData($name, $value) { - if (!is_array($this->volatile)) $this->volatile = array(); - - $this->volatile[$name] = $value; - } - - /** * Get a given piece of metadata. * @@ -719,7 +686,6 @@ { // Create the array if necessary - all subclasses should test before creating if (!is_array($this->attributes)) $this->attributes = array(); - if (!is_array($this->volatile)) $this->volatile = array(); // Now put these into the attributes array as core values $objarray = (array) $row; diff --git a/engine/lib/search.php b/engine/lib/search.php new file mode 100644 index 000000000..222c0b6e9 --- /dev/null +++ b/engine/lib/search.php @@ -0,0 +1,50 @@ + + * @link http://elgg.org/ + */ + + /** + * Initialise search helper functions. + * + */ + function search_init() + { + register_page_handler('search','search_page_handler'); + } + + /** + * Page handler for search + * + * @param array $page Page elements from pain page handler + */ + function search_page_handler($page) + { + global $CONFIG; + + if(!get_input('tag')) { + set_input('tag', $page[0]); + } + + if (isset($page[0])) { + switch ($page[0]) { + case 'user' : + case 'users' : include_once($CONFIG->path . "search/users.php"); break; + + case 'group' : + case 'groups' : include_once($CONFIG->path . "search/groups.php"); break; + + default: include_once($CONFIG->path . "search/index.php"); + } + } + else + include_once($CONFIG->path . "search/index.php"); + } + + /** Register init system event **/ + register_elgg_event_handler('init','system','search_init'); +?> diff --git a/engine/schema/upgrades/2009093001.sql b/engine/schema/upgrades/2009093001.sql deleted file mode 100644 index ce7bf96e4..000000000 --- a/engine/schema/upgrades/2009093001.sql +++ /dev/null @@ -1,11 +0,0 @@ ---Search Index -CREATE TABLE IF NOT EXISTS `prefix_search_index`( - `guid` INT NOT NULL, - `subtype` VARCHAR( 32 ) NOT NULL, - `string` TEXT NOT NULL, - PRIMARY KEY (`guid`,`subtype`), - KEY `guid` (`guid`), - KEY `subtype` (`subtype`), - FULLTEXT KEY `string` (`string`) -) ENGINE = MYISAM DEFAULT CHARSET=utf8; - diff --git a/mod/search/index.php b/mod/search/index.php deleted file mode 100644 index c6283d2f3..000000000 --- a/mod/search/index.php +++ /dev/null @@ -1,132 +0,0 @@ - 0) { - if ($friends = get_user_friends($friends,'',9999)) { - $owner_guid_array = array(); - foreach($friends as $friend) { - $owner_guid_array[] = $friend->guid; - } - } else { - $owner_guid = -1; - } -} - -// Set up submenus -if ($object_types = get_registered_entity_types()) { - - foreach($object_types as $ot => $subtype_array) { - if (is_array($subtype_array) && sizeof($subtype_array)) - foreach($subtype_array as $object_subtype) { - $label = 'item:' . $ot; - if (!empty($object_subtype)) $label .= ':' . $object_subtype; - add_submenu_item(elgg_echo($label), $CONFIG->wwwroot . "pg/search/?tag=". urlencode($tag) ."&subtype=" . $object_subtype . "&object_type=". urlencode($ot) ."&tagtype=" . urlencode($md_type) . "&owner_guid=" . urlencode($owner_guid)); - } - } - add_submenu_item(elgg_echo('all'), $CONFIG->wwwroot . "pg/search/?tag=". urlencode($tag) ."&owner_guid=" . urlencode($owner_guid)); - -} - -$body = ''; -if (!empty($tag)) { - - // blank the results to start off - $results = new stdClass(); - $results->entities = array(); - $results->total = 0; - - $results = trigger_plugin_hook('search:entities', '', array('tag' => $tag, - 'offset' => $offset, - 'limit' => $limit, - 'searchtype' => $searchtype, - 'object_type' => $object_type, - 'subtype' => $subtype, - 'tagtype' => $tagtype, - 'owner_guid' => $owner_guid_array - ), - $results); - - /* - $searchtypes = trigger_plugin_hook('search:types', '', NULL, array()); - add_submenu_item(elgg_echo('search:type:all'), - $CONFIG->wwwroot . "pg/search/?tag=". urlencode($tag) ."&searchtype=all"); - - foreach ($searchtypes as $st) { - add_submenu_item(elgg_echo('search:type:' . $st), - $CONFIG->wwwroot . "pg/search/?tag=". urlencode($tag) ."&searchtype=" . $st); - } - */ - - - if (empty($objecttype) && empty($subtype)) { - $title = sprintf(elgg_echo('searchtitle'),$tag); - } else { - if (empty($objecttype)) $objecttype = 'object'; - $itemtitle = 'item:' . $objecttype; - if (!empty($subtype)) $itemtitle .= ':' . $subtype; - $itemtitle = elgg_echo($itemtitle); - $title = sprintf(elgg_echo('advancedsearchtitle'),$itemtitle,$tag); - } - - - - - //print_r($results); - - $body .= elgg_view_title($title); // elgg_view_title(sprintf(elgg_echo('searchtitle'),$tag)); - $body .= elgg_view('search/startblurb',array('tag' => $tag)); - - - $body .= elgg_view('search/entity_list',array('entities' => $results->entities, - 'count' => $results->total, - 'offset' => $offset, - 'limit' => $limit, - 'baseurl' => $_SERVER['REQUEST_URI'], - 'fullview' => false, - 'context' => 'search', - 'viewtypetoggle' => true, - 'viewtype' => $viewtype, - 'pagination' => true - )); - - - - -elgg_view_entity_list($results->entities, count($results->entities), 0, count($results->entities), false); -} else { - - $body .= elgg_view_title(elgg_echo('search:enterterm')); - $body .= elgg_view('page_elements/contentwrapper', array('body' => '
' . elgg_view('page_elements/searchbox') . '
')); - - -} -$layout = elgg_view_layout('two_column_left_sidebar','',$body); - - -page_draw($title, $layout); - - -?> \ No newline at end of file diff --git a/mod/search/languages/en.php b/mod/search/languages/en.php deleted file mode 100644 index 17796860f..000000000 --- a/mod/search/languages/en.php +++ /dev/null @@ -1,8 +0,0 @@ - 'Enter a search term:' - ); - -add_translation('en', $language_array); - -?> diff --git a/mod/search/manifest.xml b/mod/search/manifest.xml deleted file mode 100644 index 1f8415445..000000000 --- a/mod/search/manifest.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/mod/search/start.php b/mod/search/start.php deleted file mode 100644 index a434fc2b5..000000000 --- a/mod/search/start.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @link http://elgg.org/ - */ - - /** - * Initialise search helper functions. - * - */ - function search_init() { - global $CONFIG; - - // page handler for search actions and results - register_page_handler('search','search_page_handler'); - - // hook into the search callback to use the metadata system (this is the part that will go away!) - register_plugin_hook('search:entities', 'all', 'search_original_hook'); - - // list of available search types should include our base parts - register_plugin_hook('searchtypes', 'all', 'search_base_search_types_hook'); - - // add in CSS for search elements - extend_view('css', 'search/css'); - } - - /** - * Page handler for search - * - * @param array $page Page elements from pain page handler - */ - function search_page_handler($page) { - global $CONFIG; - - if(!get_input('tag')) { - set_input('tag', $page[0]); - } - - include_once($CONFIG->path . "mod/search/index.php"); - } - - /** - * Core search hook. - * Returns an object with two parts: - * ->entities: an array of instantiated entities that have been decorated with - * volatile "search" data indicating what they matched. These are - * the entities to be displayed to the user on this page. - * ->total: total number of entities overall. This function can update this - * limit to ask for more pages in the pagination. - */ - function search_original_hook($hook, $type, $returnvalue, $params) { - $tag = $params['tag']; - $offset = $params['offset']; // starting page - $limit = $params['limit']; // number per page - $searchtype = $params['searchtype']; // the search type we're looking for - $object_type = $params['object_type']; - $subtype = $params['subtype']; - $owner_guid = $params['owner_guid']; - $tagtype = $params['tagtype']; - - $count = get_entities_from_metadata($tagtype, elgg_strtolower($tag), $object_type, $subtype, $owner_guid, $limit, $offset, "", 0, true); - $ents = get_entities_from_metadata($tagtype, elgg_strtolower($tag), $object_type, $subtype, $owner_guid, $limit, $offset, "", 0, false); - - - /* - * Foreach entity - * get the metadata keys - * If the value matches, hang onto the key - * add all the matched keys to VolatileData - * This tells us *why* each entity matched - */ - foreach ($ents as $ent) { - $metadata = get_metadata_for_entity($ent->getGUID()); - $matched = array(); - if ($metadata) { - foreach ($metadata as $tuple) { - if ($tag === $tuple->value) { - // This is one of the matching elements - $matched[] = $tuple->name; - } - } - $ent->setVolatileData("search", $matched); - } - } - - // merge in our entities with any coming in from elsewhere - $returnvalue->entities = array_merge($returnvalue->entities, $ents); - - // expand the total entity count if necessary - if ($count > $returnvalue->total) { - $returnvalue->total = $count; - } - - return $returnvalue; - } - - /** - * return our base search types - */ - function search_base_search_types_hook($hook, $type, $returnvalue, $params) { - if (!is_array($returnvalue)) { - $returnvalue = array(); - } - - return $returnvalue; - } - - /** Register init system event **/ - - register_elgg_event_handler('init','system','search_init'); - -?> diff --git a/mod/search/views/default/page_elements/searchbox.php b/mod/search/views/default/page_elements/searchbox.php deleted file mode 100644 index 4bab36be9..000000000 --- a/mod/search/views/default/page_elements/searchbox.php +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
diff --git a/mod/search/views/default/search/css.php b/mod/search/views/default/search/css.php deleted file mode 100644 index 08c681f63..000000000 --- a/mod/search/views/default/search/css.php +++ /dev/null @@ -1,61 +0,0 @@ -.searchtype { -background: #FFFACD; -color: black; -} - -.searchtypes { -border: 1px #EEEEEE solid; -padding: 4px; -margin: 6px; -} - -#searchform input.search_input { - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - background-color:#FFFFFF; - border:1px solid #BBBBBB; - color:#999999; - font-size:12px; - font-weight:bold; - margin:0pt; - padding:2px; - width:180px; - height:12px; -} -#searchform input.search_submit_button { - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - color:#333333; - background: #cccccc; - border:none; - font-size:12px; - font-weight:bold; - margin:0px; - padding:2px; - width:auto; - height:18px; - cursor:pointer; -} -#searchform input.search_submit_button:hover { - color:#ffffff; - background: #4690d6; -} - - -.search_listing { - display: block; - -webkit-border-radius: 8px; - -moz-border-radius: 8px; - background:white; - margin:0 10px 5px 10px; - padding:5px; -} - -/* override the entity container piece */ -.search_listing .entity_listing { - -webkit-border-radius: 0px; - -moz-border-radius: 0px; - background: transparent; - margin: 0; - padding: 0; -} \ No newline at end of file diff --git a/mod/search/views/default/search/entity_list.php b/mod/search/views/default/search/entity_list.php deleted file mode 100644 index 56291ba3a..000000000 --- a/mod/search/views/default/search/entity_list.php +++ /dev/null @@ -1,66 +0,0 @@ - 0 && $viewtypetoggle) { - $nav .= elgg_view("navigation/viewtype",array( - - 'baseurl' => $baseurl, - 'offset' => $offset, - 'count' => $count, - 'viewtype' => $viewtype, - - )); - } - - if ($pagination) - $nav .= elgg_view('navigation/pagination',array( - - 'baseurl' => $baseurl, - 'offset' => $offset, - 'count' => $count, - 'limit' => $limit, - - )); - - $html .= $nav; - - if ($viewtype == "list") { - if (is_array($entities) && sizeof($entities) > 0) { - foreach($entities as $entity) { - $ev = elgg_view_entity($entity, $fullview); - - $html .= elgg_view('search/listing', array('entity_view' => $ev, - 'search_types' => $entity->getVolatileData('search'))); - - } - } - } else if ($viewtype == "gallery") { - if (is_array($entities) && sizeof($entities) > 0) { - $html .= elgg_view("search/gallery",array('entities' => $entities)); - } - } - - if ($count) - $html .= $nav; - - echo $html; - -?> diff --git a/mod/search/views/default/search/gallery.php b/mod/search/views/default/search/gallery.php deleted file mode 100644 index 753a38684..000000000 --- a/mod/search/views/default/search/gallery.php +++ /dev/null @@ -1,55 +0,0 @@ - 0) { - -?> - - - -"; - - } - echo ""; - $col++; - if ($col > 3) { - echo ""; - $col = 0; - } - } - if ($col > 0) echo ""; - -?> - - - - \ No newline at end of file diff --git a/mod/search/views/default/search/listing.php b/mod/search/views/default/search/listing.php deleted file mode 100644 index f27116a9f..000000000 --- a/mod/search/views/default/search/listing.php +++ /dev/null @@ -1,35 +0,0 @@ - - -
- -Matched: '; - foreach ($vars['search_types'] as $st) { - echo '' . elgg_echo($st) . ' '; - } - echo '
'; - - } - - - - -?> - diff --git a/views/default/page_elements/elgg_topbar.php b/views/default/page_elements/elgg_topbar.php index 2908cbd95..46314f2ad 100644 --- a/views/default/page_elements/elgg_topbar.php +++ b/views/default/page_elements/elgg_topbar.php @@ -68,7 +68,10 @@ @@ -77,4 +80,4 @@ +?> \ No newline at end of file diff --git a/views/default/search/entity_list.php b/views/default/search/entity_list.php new file mode 100644 index 000000000..f0438fa11 --- /dev/null +++ b/views/default/search/entity_list.php @@ -0,0 +1,62 @@ + 0 && $viewtypetoggle) { + $nav .= elgg_view("navigation/viewtype",array( + + 'baseurl' => $baseurl, + 'offset' => $offset, + 'count' => $count, + 'viewtype' => $viewtype, + + )); + } + + if ($pagination) + $nav .= elgg_view('navigation/pagination',array( + + 'baseurl' => $baseurl, + 'offset' => $offset, + 'count' => $count, + 'limit' => $limit, + + )); + + $html .= $nav; + + if ($viewtype == "list") { + if (is_array($entities) && sizeof($entities) > 0) { + foreach($entities as $entity) { + $html .= elgg_view_entity($entity, $fullview); + } + } + } else { + if (is_array($entities) && sizeof($entities) > 0) + $html .= elgg_view("search/gallery",array('entities' => $entities)); + } + + if ($count) + $html .= $nav; + + echo $html; + +?> diff --git a/views/default/search/gallery.php b/views/default/search/gallery.php new file mode 100644 index 000000000..366cd713b --- /dev/null +++ b/views/default/search/gallery.php @@ -0,0 +1,49 @@ + 0) { + +?> + + + +"; + + } + echo ""; + $col++; + if ($col > 3) { + echo ""; + $col = 0; + } + } + if ($col > 0) echo ""; + +?> + + + + \ No newline at end of file diff --git a/views/default/search/gallery_listing.php b/views/default/search/gallery_listing.php new file mode 100644 index 000000000..4c0f40643 --- /dev/null +++ b/views/default/search/gallery_listing.php @@ -0,0 +1,35 @@ + + +
+ +
+ + + +
+
+ +
+ +
\ No newline at end of file diff --git a/views/default/search/listing.php b/views/default/search/listing.php new file mode 100644 index 000000000..0a9d01fee --- /dev/null +++ b/views/default/search/listing.php @@ -0,0 +1,45 @@ + + +
+ +
+ +
+
+ +
+ +
+ + \ No newline at end of file diff --git a/views/default/search/startblurb.php b/views/default/search/startblurb.php new file mode 100644 index 000000000..82b4aef8c --- /dev/null +++ b/views/default/search/startblurb.php @@ -0,0 +1,8 @@ + +
+ +
\ No newline at end of file -- cgit v1.2.3