]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Pulling in MITRE's search core. Fo'rizzle this time. Yo.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 22 Oct 2009 18:20:10 +0000 (18:20 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 22 Oct 2009 18:20:10 +0000 (18:20 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3572 36083f99-b078-4883-b0ff-0f9b5a30f544

24 files changed:
engine/lib/elgglib.php
engine/lib/entities.php
engine/lib/search.php [deleted file]
mod/search/index.php [new file with mode: 0644]
mod/search/languages/en.php [new file with mode: 0644]
mod/search/manifest.xml [new file with mode: 0644]
mod/search/start.php [new file with mode: 0644]
mod/search/views/default/page_elements/searchbox.php [new file with mode: 0644]
mod/search/views/default/search/css.php [new file with mode: 0644]
mod/search/views/default/search/entity_list.php [moved from views/default/search/entity_list.php with 58% similarity]
mod/search/views/default/search/gallery.php [new file with mode: 0644]
mod/search/views/default/search/gallery_listing.php [new file with mode: 0644]
mod/search/views/default/search/listing.php [new file with mode: 0644]
mod/search/views/default/search/startblurb.php [moved from views/default/search/startblurb.php with 91% similarity]
search/groups.php [deleted file]
search/index.php [deleted file]
search/users.php [deleted file]
views/default/css.php
views/default/entities/entity_list.php [new file with mode: 0644]
views/default/entities/entity_listing.php [new file with mode: 0644]
views/default/entities/gallery.php [moved from views/default/search/gallery.php with 80% similarity]
views/default/entities/gallery_listing.php [moved from views/default/search/gallery_listing.php with 54% similarity]
views/default/page_elements/elgg_topbar.php
views/default/search/listing.php [deleted file]

index 7a10cd809d8071a40791c5ce676f04154b08e7e9..2b2180532980ae3df069d794aa2348be87152563 100644 (file)
@@ -724,7 +724,7 @@ function elgg_view_entity_list($entities, $count, $offset, $limit, $fullview = t
 
        $context = get_context();
 
-       $html = elgg_view('search/entity_list',array(
+       $html = elgg_view('entities/entity_list',array(
                'entities' => $entities,
                'count' => $count,
                'offset' => $offset,
@@ -992,7 +992,7 @@ function elgg_count_comments($entity) {
  * @return string The HTML (etc) representing the listing
  */
 function elgg_view_listing($icon, $info) {
-       return elgg_view('search/listing',array('icon' => $icon, 'info' => $info));
+       return elgg_view('entities/entity_listing',array('icon' => $icon, 'info' => $info));
 }
 
 /**
index 373654431d42d60972262028c515dd36eadabd44..7fe849421b12795da4ca7857a09b52983751e37e 100644 (file)
@@ -63,6 +63,13 @@ abstract class ElggEntity implements
         */
        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.
@@ -84,6 +91,9 @@ abstract class ElggEntity implements
                if (!is_array($this->temp_annotations)) {
                        $this->temp_annotations = array();
                }
+               if (!is_array($this->volatile)) {
+                       $this->volatile = array();
+               }
 
                $this->attributes['guid'] = "";
                $this->attributes['type'] = "";
@@ -325,6 +335,35 @@ abstract class ElggEntity implements
                }
        }
 
+       
+       /**
+        * 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;
+               }                       
+       }
+       
+
+       /**
+        * Set 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;
+       }
+
+
        /**
         * Remove all entities associated with this entity
         *
diff --git a/engine/lib/search.php b/engine/lib/search.php
deleted file mode 100644 (file)
index 0f6c0a1..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/**
- * Elgg search helper functions.
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd <info@elgg.com>
- * @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');
\ No newline at end of file
diff --git a/mod/search/index.php b/mod/search/index.php
new file mode 100644 (file)
index 0000000..7cbf612
--- /dev/null
@@ -0,0 +1,146 @@
+<?php
+
+  /** Main search page */
+
+global $CONFIG;
+
+$tag = get_input('tag');
+$offset = get_input('offset', 0);
+$viewtype = get_input('search_viewtype','list');
+if ($viewtype == 'gallery') {
+    $limit = get_input('limit', 12); // 10 items in list view
+} else {
+    $limit = get_input('limit', 10); // 12 items in gallery view
+}
+$searchtype = get_input('searchtype', 'all');
+$object_type = get_input('object_type', '');
+$subtype = get_input('subtype', '');
+$owner_guid = get_input('owner_guid', '');
+$tagtype = get_input('tagtype', '');
+$friends = (int)get_input('friends', 0);
+
+
+$title = sprintf(elgg_echo('searchtitle'), $tag); 
+
+
+if (substr_count($owner_guid,',')) {
+       $owner_guid_array = explode(",",$owner_guid);
+} else {
+       $owner_guid_array = $owner_guid;
+}
+if ($friends > 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;
+
+       // do the actual search
+       $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);
+
+       /* // this piece is for future work, to setup submenus for searchtypes
+        $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));
+
+       // call the old (now-deprecated) search hook here
+       $body .= trigger_plugin_hook('search','',$tag, '');
+
+       $body .= elgg_view('search/startblurb', array('tag' => $tag));
+
+       if ($results->total > 0) {
+    
+
+           $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
+                                                          ));
+       } else {
+           $body .= elgg_view('page_elements/contentwrapper', array('body' => elgg_echo('search:noresults')));
+       }
+
+
+
+
+       elgg_view_entity_list($results->entities, count($results->entities), 0, count($results->entities), false);
+} else {
+       // if no tag was given, give the user a box to input a search term
+       $body .= elgg_view_title(elgg_echo('search:enterterm'));
+       $body .= elgg_view('page_elements/contentwrapper', array('body' => '<div>' . elgg_view('page_elements/searchbox') . '</div>'));
+
+
+}
+$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
new file mode 100644 (file)
index 0000000..52c29c7
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+    $language_array = array('search:enterterm' => 'Enter a search term:',
+                           'search:noresults' => 'No results.',
+                           'search:matched' => 'Matched: '
+       );
+
+add_translation('en', $language_array);
+
+?>
diff --git a/mod/search/manifest.xml b/mod/search/manifest.xml
new file mode 100644 (file)
index 0000000..1f84154
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+       <field key="author" value="Curverider Ltd, The MITRE Corporation" />
+       <field key="version" value="1.7" />
+       <field key="description" value="Allow search across entities of the site" />
+       <field key="website" value="http://www.elgg.org/" />
+       <field key="copyright" value="(C) Curverider 2008-2009, MITRE 2009" />
+       <field key="licence" value="GNU Public License version 2" />
+       <field key="elgg_version" value="2009030702" />
+</plugin_manifest>
\ No newline at end of file
diff --git a/mod/search/start.php b/mod/search/start.php
new file mode 100644 (file)
index 0000000..24b038c
--- /dev/null
@@ -0,0 +1,116 @@
+<?php
+
+  /**
+   * Elgg core search.
+   * 
+   * @package Elgg
+   * @subpackage Core
+   * @author Curverider Ltd <info@elgg.com>, The MITRE Corporation <http://www.mitre.org>
+   * @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, FALSE); 
+       $ents =  get_entities_from_metadata($tagtype, elgg_strtolower($tag), $object_type, $subtype, $owner_guid, $limit, $offset, "", 0, FALSE, 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 (right now, we have none)
+ */
+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
new file mode 100644 (file)
index 0000000..4bab36b
--- /dev/null
@@ -0,0 +1,4 @@
+<form id="searchform" action="<?php echo $vars['url']; ?>pg/search/" method="get">
+       <input type="text" size="21" name="tag" value="<?php echo elgg_echo('search'); ?>" onclick="if (this.value=='<?php echo elgg_echo('search'); ?>') { this.value='' }" class="search_input" />
+       <input type="submit" value="<?php echo elgg_echo('search:go'); ?>" class="search_submit_button" />
+</form>
diff --git a/mod/search/views/default/search/css.php b/mod/search/views/default/search/css.php
new file mode 100644 (file)
index 0000000..27b5327
--- /dev/null
@@ -0,0 +1,67 @@
+.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;
+}
+
+.entity_gallery_item .search_listing {
+       background: none;
+       text-align: center;
+}
+
+/* override the entity container piece */
+.search_listing .entity_listing {
+       -webkit-border-radius: 0px; 
+       -moz-border-radius: 0px;
+       background: transparent;
+       margin: 0;
+       padding: 0;
+}
+
similarity index 58%
rename from views/default/search/entity_list.php
rename to mod/search/views/default/search/entity_list.php
index 07e76e955278e5959193dfd7465d60cbd45a3de2..d709210df699927d909e192f10d20290cb2775fc 100644 (file)
@@ -1,64 +1,66 @@
-<?php\r
-/**\r
- * @package Elgg\r
- * @author Curverider\r
- * @link http://elgg.com/\r
- */\r
-\r
-$context = $vars['context'];\r
-$offset = $vars['offset'];\r
-$entities = $vars['entities'];\r
-$limit = $vars['limit'];\r
-$count = $vars['count'];\r
-$baseurl = $vars['baseurl'];\r
-$context = $vars['context'];\r
-$viewtype = $vars['viewtype'];\r
-$pagination = $vars['pagination'];\r
-$fullview = $vars['fullview'];\r
-\r
-$html = "";\r
-$nav = "";\r
-\r
-if (isset($vars['viewtypetoggle'])) {\r
-       $viewtypetoggle = $vars['viewtypetoggle'];\r
-} else {\r
-       $viewtypetoggle = true;\r
-}\r
-\r
-if ($context == "search" && $count > 0 && $viewtypetoggle) {\r
-       $nav .= elgg_view("navigation/viewtype",array(\r
-               'baseurl' => $baseurl,\r
-               'offset' => $offset,\r
-               'count' => $count,\r
-               'viewtype' => $viewtype,\r
-       ));\r
-}\r
-\r
-if ($pagination) {\r
-       $nav .= elgg_view('navigation/pagination',array(\r
-               'baseurl' => $baseurl,\r
-               'offset' => $offset,\r
-               'count' => $count,\r
-               'limit' => $limit,\r
-       ));\r
-}\r
-\r
-$html .= $nav;\r
-\r
-if ($viewtype == "list") {\r
-       if (is_array($entities) && sizeof($entities) > 0) {\r
-               foreach($entities as $entity) {\r
-                       $html .= elgg_view_entity($entity, $fullview);\r
-               }\r
-       }\r
-} else {\r
-       if (is_array($entities) && sizeof($entities) > 0) {\r
-               $html .= elgg_view("search/gallery",array('entities' => $entities));\r
-       }\r
-}\r
-\r
-if ($count) {\r
-       $html .= $nav;\r
-}\r
-\r
-echo $html;
\ No newline at end of file
+<?php
+$context = $vars['context'];
+$offset = $vars['offset'];
+$entities = $vars['entities'];
+$limit = $vars['limit'];
+$count = $vars['count'];
+$baseurl = $vars['baseurl'];
+$context = $vars['context'];
+$viewtype = $vars['viewtype'];
+$pagination = $vars['pagination'];
+$fullview = $vars['fullview']; 
+               
+$html = "";
+$nav = "";
+if (isset($vars['viewtypetoggle'])) {
+       $viewtypetoggle = $vars['viewtypetoggle'];
+} else {
+       $viewtypetoggle = true;
+}
+
+if ($context == "search" && $count > 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) {
+                       // print out the entity
+                       $ev = elgg_view_entity($entity, $fullview);
+                       // then add the search decorations around it
+                       $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
new file mode 100644 (file)
index 0000000..753a386
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+       /**
+        * Elgg gallery view
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               $entities = $vars['entities'];
+               if (is_array($entities) && sizeof($entities) > 0) {
+                       
+?>
+
+               <table class="entity_gallery">
+
+<?php
+                       
+                       $col = 0;
+                       foreach($entities as $entity) {
+                               if ($col == 0) {
+                                       
+                                       echo "<tr>";
+                                       
+                               }
+                               echo "<td class=\"entity_gallery_item\">";
+                               
+                               $ev = elgg_view_entity($entity, $fullview);
+                                               
+                               echo elgg_view('search/listing', array('entity_view' => $ev,
+                                                                          'search_types' => $entity->getVolatileData('search')));
+                               
+                               
+                               echo "</td>";
+                               $col++;
+                               if ($col > 3) {
+                                       echo "</tr>";
+                                       $col = 0;
+                               }                                       
+                       }
+                       if ($col > 0) echo "</tr>";
+                       
+?>
+
+               </table>
+
+<?php
+                       
+               }
+               
+?>
\ No newline at end of file
diff --git a/mod/search/views/default/search/gallery_listing.php b/mod/search/views/default/search/gallery_listing.php
new file mode 100644 (file)
index 0000000..bbecaf2
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Elgg search listing: gallery view
+ *
+ * DEPRECATED VIEW: use entities/gallery_listing instead
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ */
+
+
+    echo elgg_view('entities/gallery_listing', $vars);
+
+?>
\ No newline at end of file
diff --git a/mod/search/views/default/search/listing.php b/mod/search/views/default/search/listing.php
new file mode 100644 (file)
index 0000000..e3ad91b
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+       /**
+        * Elgg search listing
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+?>
+
+       <div class="search_listing">
+       
+<?php 
+               
+echo $vars['entity_view'];
+
+if ($vars['search_types'] && is_array($vars['search_types'])) {
+       echo '<div class="searchtypes">' . elgg_echo('search:matched');
+       foreach ($vars['search_types'] as $st) {
+               echo '<span class="searchtype">' . elgg_echo($st) . '</span> ';
+       }
+       echo '</div>';
+               
+}
+           
+           
+           
+
+?>
+       </div>
similarity index 91%
rename from views/default/search/startblurb.php
rename to mod/search/views/default/search/startblurb.php
index 7c78cbf169893873fae0389f0a4dfe7fb938e0ee..0115438f29ddbf049f920589be76455e4a2d6a0d 100644 (file)
@@ -1,15 +1,15 @@
-<?php\r
-/**\r
- * @package Elgg\r
- * @subpackage Core\r
- * @author Curverider Ltd\r
- * @link http://elgg.org/\r
- */\r
-?>\r
-<div class="contentWrapper">\r
-       <?php\r
-\r
-               echo sprintf(elgg_echo("tag:search:startblurb"),$vars['tag']);\r
-\r
-       ?>\r
+<?php
+/**
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ */
+?>
+<div class="contentWrapper">
+       <?php
+
+               echo sprintf(elgg_echo("tag:search:startblurb"),$vars['tag']);
+
+       ?>
 </div>
\ No newline at end of file
diff --git a/search/groups.php b/search/groups.php
deleted file mode 100644 (file)
index c31e421..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php\r
-/**\r
- * Generic search viewer\r
- * Given a GUID, this page will try and display any entity\r
- *\r
- * @package Elgg\r
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/\r
- */\r
-\r
-// Load Elgg engine\r
-require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-\r
-// Set context\r
-set_context('search');\r
-\r
-// Get input\r
-$tag = stripslashes(get_input('tag'));\r
-\r
-if (!empty($tag)) {\r
-       $title = sprintf(elgg_echo('groups:searchtitle'),$tag);\r
-       $body = "";\r
-       $body .= elgg_view_title($title); // elgg_view_title(sprintf(elgg_echo('searchtitle'),$tag));\r
-       $body .= elgg_view('group/search/startblurb',array('tag' => $tag));\r
-       $body .= list_group_search($tag);\r
-       //$body = elgg_view_layout('two_column_left_sidebar','',$body);\r
-} else {\r
-       $title = elgg_echo('item:group');\r
-       $body .= elgg_view_title($title);\r
-       $body .= list_entities('groups');\r
-}\r
-\r
-$body = elgg_view_layout('two_column_left_sidebar','',$body);\r
-page_draw($title,$body);
\ No newline at end of file
diff --git a/search/index.php b/search/index.php
deleted file mode 100644 (file)
index 9ae3533..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php\r
-/**\r
- * Generic search viewer\r
- * Given a GUID, this page will try and display any entity\r
- *\r
- * @package Elgg\r
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/\r
- */\r
-\r
-// Load Elgg engine\r
-require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-\r
-// Set context\r
-set_context('search');\r
-\r
-// Get input\r
-$tag = stripslashes(get_input('tag'));\r
-$subtype = stripslashes(get_input('subtype'));\r
-if (!$objecttype = stripslashes(get_input('object'))) {\r
-       $objecttype = "";\r
-}\r
-if (!$md_type = stripslashes(get_input('tagtype'))) {\r
-       $md_type = "";\r
-}\r
-$owner_guid = (int)get_input('owner_guid',0);\r
-if (substr_count($owner_guid,',')) {\r
-       $owner_guid_array = explode(",",$owner_guid);\r
-} else {\r
-       $owner_guid_array = $owner_guid;\r
-}\r
-$friends = (int) get_input('friends',0);\r
-if ($friends > 0) {\r
-       if ($friends = get_user_friends($friends,'',9999)) {\r
-               $owner_guid_array = array();\r
-               foreach($friends as $friend) {\r
-                       $owner_guid_array[] = $friend->guid;\r
-               }\r
-       } else {\r
-               $owner_guid = -1;\r
-       }\r
-}\r
-\r
-// Set up submenus\r
-if ($object_types = get_registered_entity_types()) {\r
-       foreach($object_types as $object_type => $subtype_array) {\r
-               if (is_array($subtype_array) && sizeof($subtype_array))\r
-                       foreach($subtype_array as $object_subtype) {\r
-                               $label = 'item:' . $object_type;\r
-                               if (!empty($object_subtype)) {\r
-                                       $label .= ':' . $object_subtype;\r
-                               }\r
-                               global $CONFIG;\r
-                               add_submenu_item(elgg_echo($label), $CONFIG->wwwroot . "pg/search/?tag=". urlencode($tag) ."&subtype=" . $object_subtype . "&object=". urlencode($object_type) ."&tagtype=" . urlencode($md_type) . "&owner_guid=" . urlencode($owner_guid));\r
-                       }\r
-       }\r
-       add_submenu_item(elgg_echo('all'), $CONFIG->wwwroot . "pg/search/?tag=". urlencode($tag) ."&owner_guid=" . urlencode($owner_guid));\r
-\r
-}\r
-\r
-if (empty($objecttype) && empty($subtype)) {\r
-       $title = sprintf(elgg_echo('searchtitle'),$tag);\r
-} else {\r
-       if (empty($objecttype)) {\r
-               $objecttype = 'object';\r
-       }\r
-       $itemtitle = 'item:' . $objecttype;\r
-       if (!empty($subtype)) {\r
-               $itemtitle .= ':' . $subtype;\r
-       }\r
-       $itemtitle = elgg_echo($itemtitle);\r
-       $title = sprintf(elgg_echo('advancedsearchtitle'),$itemtitle,$tag);\r
-}\r
-\r
-if (!empty($tag)) {\r
-       $body = "";\r
-       $body .= elgg_view_title($title); // elgg_view_title(sprintf(elgg_echo('searchtitle'),$tag));\r
-       $body .= trigger_plugin_hook('search','',$tag,"");\r
-       $body .= elgg_view('search/startblurb',array('tag' => $tag));\r
-       $body .= list_entities_from_metadata($md_type, elgg_strtolower($tag), $objecttype, $subtype, $owner_guid_array, 10, false, false);\r
-       $body = elgg_view_layout('two_column_left_sidebar','',$body);\r
-}\r
-\r
-page_draw($title,$body);
\ No newline at end of file
diff --git a/search/users.php b/search/users.php
deleted file mode 100644 (file)
index 62296e7..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php\r
-/**\r
- * Generic search viewer\r
- * Given a GUID, this page will try and display any entity\r
- *\r
- * @package Elgg\r
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/\r
- */\r
-\r
-// Load Elgg engine\r
-require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
-\r
-// Set context\r
-set_context('search');\r
-\r
-// Get input\r
-$tag = stripslashes(get_input('tag'));\r
-\r
-if (!empty($tag)) {\r
-       $title = sprintf(elgg_echo('users:searchtitle'),$tag);\r
-       $body = "";\r
-       $body .= elgg_view_title($title); // elgg_view_title(sprintf(elgg_echo('searchtitle'),$tag));\r
-       $body .= elgg_view('user/search/startblurb',array('tag' => $tag));\r
-       $body .= list_user_search($tag);\r
-       //$body = elgg_view_layout('two_column_left_sidebar','',$body);\r
-} else {\r
-       $title = elgg_echo('item:user');\r
-       $body .= elgg_view_title($title);\r
-       $body .= list_entities('user');\r
-}\r
-\r
-$body = elgg_view_layout('two_column_left_sidebar','',$body);\r
-page_draw($title,$body);
\ No newline at end of file
index feca462165adf8afd30610aa13246145fa978c5c..da91e07a896bcbe89edf8a1759721605ce3aca14 100644 (file)
@@ -560,37 +560,6 @@ HORIZONTAL ELGG TOPBAR
        display:none;
        position:relative;
 }
-#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;
-}
 
 
 /* ***************************************
@@ -1274,9 +1243,9 @@ p.user_menu_friends_of {
 }
 
 /* ***************************************
-       SEARCH LISTINGS
+       ENTITY LISTINGS
 *************************************** */
-.search_listing {
+.entity_listing {
        display: block;
        -webkit-border-radius: 8px;
        -moz-border-radius: 8px;
@@ -1284,80 +1253,80 @@ p.user_menu_friends_of {
        margin:0 10px 5px 10px;
        padding:5px;
 }
-.search_listing_icon {
+.entity_listing_icon {
        float:left;
 }
-.search_listing_icon img {
+.entity_listing_icon img {
        width: 40px;
 }
-.search_listing_icon .avatar_menu_button img {
+.entity_listing_icon .avatar_menu_button img {
        width: 15px;
 }
-.search_listing_info {
+.entity_listing_info {
        margin-left: 50px;
        min-height: 40px;
 }
 /* IE 6 fix */
-* html .search_listing_info {
+* html .entity_listing_info {
        height:40px;
 }
-.search_listing_info p {
+.entity_listing_info p {
        margin:0 0 3px 0;
        line-height:1.2em;
 }
-.search_listing_info p.owner_timestamp {
+.entity_listing_info p.owner_timestamp {
        margin:0;
        padding:0;
        color:#666666;
        font-size: 90%;
 }
-table.search_gallery {
+table.entity_gallery {
        border-spacing: 10px;
        margin:0 0 0 0;
 }
-.search_gallery td {
+.entity_gallery td {
        padding: 5px;
 }
-.search_gallery_item {
+.entity_gallery_item {
        background: white;
        -webkit-border-radius: 8px;
        -moz-border-radius: 8px;
        width:170px;
 }
-.search_gallery_item:hover {
+.entity_gallery_item:hover {
        background: black;
        color:white;
 }
-.search_gallery_item .search_listing {
+.entity_gallery_item .entity_listing {
        background: none;
        text-align: center;
 }
-.search_gallery_item .search_listing_header {
+.entity_gallery_item .entity_listing_header {
        text-align: center;
 }
-.search_gallery_item .search_listing_icon {
+.entity_gallery_item .entity_listing_icon {
        position: relative;
        text-align: center;
 }
-.search_gallery_item .search_listing_info {
+.entity_gallery_item .entity_listing_info {
        margin: 5px;
 }
-.search_gallery_item .search_listing_info p {
+.entity_gallery_item .entity_listing_info p {
        margin: 5px;
        margin-bottom: 10px;
 }
-.search_gallery_item .search_listing {
+.entity_gallery_item .entity_listing {
        background: none;
        text-align: center;
 }
-.search_gallery_item .search_listing_icon {
+.entity_gallery_item .entity_listing_icon {
        position: absolute;
        margin-bottom: 20px;
 }
-.search_gallery_item .search_listing_info {
+.entity_gallery_item .entity_listing_info {
        margin: 5px;
 }
-.search_gallery_item .search_listing_info p {
+.entity_gallery_item .entity_listing_info p {
        margin: 5px;
        margin-bottom: 10px;
 }
@@ -2376,7 +2345,7 @@ h3.settings {
 .admin_statistics table tr:hover {
        background: #E4E4E4;
 }
-.admin_users_online .search_listing {
+.admin_users_online .entity_listing {
        margin:0 0 5px 0;
        padding:5px;
        border:2px solid #cccccc;
diff --git a/views/default/entities/entity_list.php b/views/default/entities/entity_list.php
new file mode 100644 (file)
index 0000000..81fd102
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+               $context = $vars['context'];
+               $offset = $vars['offset'];
+               $entities = $vars['entities'];
+               $limit = $vars['limit'];
+               $count = $vars['count'];
+               $baseurl = $vars['baseurl'];
+               $context = $vars['context'];
+               $viewtype = $vars['viewtype'];
+               $pagination = $vars['pagination'];
+               $fullview = $vars['fullview']; 
+               
+               $html = "";
+               $nav = "";
+               
+               if (isset($vars['viewtypetoggle'])) {
+                       $viewtypetoggle = $vars['viewtypetoggle'];
+               } else {
+                       $viewtypetoggle = true;
+               }
+
+                       if ($context == "search" && $count > 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("entities/gallery",array('entities' => $entities));
+                       }
+                       
+                       if ($count)
+                               $html .= $nav;
+                               
+                       echo $html;
+
+?>
diff --git a/views/default/entities/entity_listing.php b/views/default/entities/entity_listing.php
new file mode 100644 (file)
index 0000000..dd07e7d
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+       /**
+        * Elgg search listing
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+?>
+
+       <div class="entity_listing">
+       
+               <div class="entity_listing_icon">
+                       <?php
+
+                               echo $vars['icon'];
+                       
+                       ?>
+               </div>
+               <div class="entity_listing_info">
+                       <?php
+
+                               echo $vars['info'];
+                       
+                       ?>
+               </div>          
+       
+       </div>
+       
+<?php
+
+?>
\ No newline at end of file
similarity index 80%
rename from views/default/search/gallery.php
rename to views/default/entities/gallery.php
index 52c4d0b92aa8aa3c273d53281f9873ecfa46b820..a2701ed0c13c20f0d838ea9cab4d4e4a60be4ac9 100644 (file)
@@ -1,44 +1,44 @@
-<?php\r
-/**\r
- * Elgg gallery view\r
- *\r
- * @package Elgg\r
+<?php
+/**
+ * Elgg gallery view
+ *
+ * @package Elgg
  * @subpackage Core
  * @author Curverider Ltd
- * @link http://elgg.org/\r
- */\r
-\r
-$entities = $vars['entities'];\r
-if (is_array($entities) && sizeof($entities) > 0) {\r
-\r
-?>\r
-\r
-<table class="search_gallery">\r
-\r
-<?php\r
-\r
-       $col = 0;\r
-       foreach($entities as $entity) {\r
-               if ($col == 0) {\r
-\r
-                       echo "<tr>";\r
-\r
-               }\r
-               echo "<td class=\"search_gallery_item\">";\r
-               echo elgg_view_entity($entity);\r
-               echo "</td>";\r
-               $col++;\r
-               if ($col > 3) {\r
-                       echo "</tr>";\r
-                       $col = 0;\r
-               }\r
-       }\r
-       if ($col > 0) echo "</tr>";\r
-\r
-?>\r
-\r
-</table>\r
-\r
-<?php\r
-\r
+ * @link http://elgg.org/
+ */
+
+$entities = $vars['entities'];
+if (is_array($entities) && sizeof($entities) > 0) {
+
+?>
+
+<table class="entity_gallery">
+
+<?php
+
+       $col = 0;
+       foreach($entities as $entity) {
+               if ($col == 0) {
+
+                       echo "<tr>";
+
+               }
+               echo "<td class=\"entity_gallery_item\">";
+               echo elgg_view_entity($entity);
+               echo "</td>";
+               $col++;
+               if ($col > 3) {
+                       echo "</tr>";
+                       $col = 0;
+               }
+       }
+       if ($col > 0) echo "</tr>";
+
+?>
+
+</table>
+
+<?php
+
 }
\ No newline at end of file
similarity index 54%
rename from views/default/search/gallery_listing.php
rename to views/default/entities/gallery_listing.php
index 900b228326b341b70b06153949e6453b9eda4f64..5421bcecb75b5554ee0fce61dbcc98b52e99843a 100644 (file)
@@ -1,32 +1,32 @@
-<?php\r
-/**\r
- * Elgg search listing: gallery view\r
- *\r
- * @package Elgg\r
+<?php
+/**
+ * Elgg entity listing: gallery view
+ *
+ * @package Elgg
  * @subpackage Core
  * @author Curverider Ltd
- * @link http://elgg.org/\r
- */\r
-\r
-?>\r
-\r
-<div class="search_listing">\r
-\r
-       <div class="search_listing_header">\r
-\r
-                       <?php\r
-\r
-                               echo $vars['icon'];\r
-\r
-                       ?>\r
-\r
-       </div>\r
-       <div class="search_listing_info">\r
-               <?php\r
-\r
-                       echo $vars['info'];\r
-\r
-               ?>\r
-       </div>\r
-\r
+ * @link http://elgg.org/
+ */
+
+?>
+
+<div class="entity_listing">
+
+       <div class="entity_listing_header">
+
+                       <?php
+
+                               echo $vars['icon'];
+
+                       ?>
+
+       </div>
+       <div class="entity_listing_info">
+               <?php
+
+                       echo $vars['info'];
+
+               ?>
+       </div>
+
 </div>
\ No newline at end of file
index b9609910c5f82f79314be9a65a07e643071ddb30..00240f35ea49ee6ab97a66f0df8b8df46738fa27 100644 (file)
 </div>
 
 <div id="elgg_topbar_container_search">
-<form id="searchform" action="<?php echo $vars['url']; ?>pg/search/" method="get">
-       <input type="text" size="21" name="tag" value="<?php echo elgg_echo('search'); ?>" onclick="if (this.value=='<?php echo elgg_echo('search'); ?>') { this.value='' }" class="search_input" />
-       <input type="submit" value="<?php echo elgg_echo('search:go'); ?>" class="search_submit_button" />
-</form>
+<?php echo elgg_view('page_elements/searchbox'); ?>
 </div>
 
 </div><!-- /#elgg_topbar -->
diff --git a/views/default/search/listing.php b/views/default/search/listing.php
deleted file mode 100644 (file)
index fa17190..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php\r
-/**\r
- * Elgg search listing\r
- *\r
- * @package Elgg\r
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/\r
- */\r
-\r
-if (isset($vars['search_viewtype']) && $vars['search_viewtype'] == "gallery") {\r
-       echo elgg_view("search/gallery_listing",$vars);\r
-} else {\r
-\r
-?>\r
-\r
-<div class="search_listing">\r
-\r
-       <div class="search_listing_icon">\r
-               <?php\r
-\r
-                       echo $vars['icon'];\r
-\r
-               ?>\r
-       </div>\r
-       <div class="search_listing_info">\r
-               <?php\r
-\r
-                       echo $vars['info'];\r
-\r
-               ?>\r
-       </div>\r
-\r
-</div>\r
-\r
-<?php\r
-\r
-}
\ No newline at end of file