Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/search
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-04-24 18:09:07 +0400
committerRobin Appelman <icewind1991@gmail.com>2011-04-24 18:09:27 +0400
commitb7aba15f179125455298aaee411864ebf4ed86f9 (patch)
tree781cd833dfb6fa18eeb89967f3094dcf0fa5a33e /search
parent8d52fdb7faf4be4ed4282ecdd3e3a08af1fbf150 (diff)
add search functionality, for now only searches files but plugins/apps can extend that
Diffstat (limited to 'search')
-rw-r--r--search/appinfo/app.php5
-rw-r--r--search/css/search.css17
-rw-r--r--search/index.php55
-rw-r--r--search/templates/index.php17
4 files changed, 94 insertions, 0 deletions
diff --git a/search/appinfo/app.php b/search/appinfo/app.php
new file mode 100644
index 00000000000..44834498fec
--- /dev/null
+++ b/search/appinfo/app.php
@@ -0,0 +1,5 @@
+<?php
+
+OC_APP::register( array( 'order' => 2, "id" => 'search', 'name' => 'Search' ));
+
+?>
diff --git a/search/css/search.css b/search/css/search.css
new file mode 100644
index 00000000000..df0712be03f
--- /dev/null
+++ b/search/css/search.css
@@ -0,0 +1,17 @@
+#searchresults{
+ margin: 2em;
+ list-style:none;
+ border: solid 1px #CCC;
+}
+
+#searchresults li.resultHeader{
+ font-size:1.2em;
+ font-weight:bold;
+ border-bottom: solid 1px #CCC;
+ padding:0.2em;
+ background-color:#eee;
+}
+
+#searchresults li.result{
+ margin-left:2em;
+} \ No newline at end of file
diff --git a/search/index.php b/search/index.php
new file mode 100644
index 00000000000..e6f41528ea3
--- /dev/null
+++ b/search/index.php
@@ -0,0 +1,55 @@
+<?php
+
+/**
+* ownCloud - ajax frontend
+*
+* @author Robin Appelman
+* @copyright 2010 Robin Appelman icewind1991@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library 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 AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+
+// Init owncloud
+require_once('../lib/base.php');
+require( 'template.php' );
+
+// Check if we are a user
+if( !OC_USER::isLoggedIn()){
+ header( "Location: ".OC_HELPER::linkTo( '', 'index.php' ));
+ exit();
+}
+
+// Load the files we need
+OC_UTIL::addStyle( 'search', 'search' );
+
+$query=(isset($_POST['query']))?$_POST['query']:'';
+if($query){
+ $results=OC_SEARCH::search($query);
+}
+
+$resultTypes=array();
+foreach($results as $result){
+ if(!isset($resultTypes[$result->type])){
+ $resultTypes[$result->type]=array();
+ }
+ $resultTypes[$result->type][]=$result;
+}
+
+$tmpl = new OC_TEMPLATE( 'search', 'index', 'user' );
+$tmpl->assign('resultTypes',$resultTypes);
+$tmpl->printPage();
+
+?>
diff --git a/search/templates/index.php b/search/templates/index.php
new file mode 100644
index 00000000000..7241553e7fc
--- /dev/null
+++ b/search/templates/index.php
@@ -0,0 +1,17 @@
+<ul id='searchresults'>
+ <?php foreach($_['resultTypes'] as $resultType):?>
+ <li class='resultHeader'>
+ <p><?php echo $resultType[0]->type?></p>
+ </li>
+ <?php foreach($resultType as $result):?>
+ <li class='result'>
+ <p>
+ <a href='<?php echo $result->link?>' title='<?php echo $result->name?>'><?php echo $result->name?></a>
+ </p>
+ <p>
+ <?php echo $result->text?>
+ </p>
+ </li>
+ <?php endforeach;?>
+ <?php endforeach;?>
+</ul>