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

github.com/nextcloud/apps.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/search
diff options
context:
space:
mode:
authorAndrew Brown <andrew@casabrown.com>2012-12-25 17:35:59 +0400
committerAndrew Brown <andrew@casabrown.com>2012-12-25 17:35:59 +0400
commit8e2725dabf7fb1d83277e82ffea472ad4d089b91 (patch)
treea9da0ca7ede2773c9f980d4186b3f56dbc6d4c0b /search
parent78ba55468e50fe915f68af10deb1fe9a5048d837 (diff)
Create Advanced Search app
Allows users to interact with search results (e.g. delete, share) using the same view available in the Files app. Much like iTunes, you can interact with your search results in a file list. It uses the current search providers available ownCloud (i.e. they only search by file name) but I plan to start building more search providers soon. This project is still in beta testing; please submit all bugs or feature requests to https://github.com/andrewsbrown/owncloud-core/issues.
Diffstat (limited to 'search')
-rw-r--r--search/appinfo/app.php9
-rw-r--r--search/appinfo/info.xml15
-rw-r--r--search/appinfo/version1
-rw-r--r--search/css/search.css6
-rw-r--r--search/index.php76
-rw-r--r--search/templates/index.php43
6 files changed, 150 insertions, 0 deletions
diff --git a/search/appinfo/app.php b/search/appinfo/app.php
new file mode 100644
index 000000000..dd8779c75
--- /dev/null
+++ b/search/appinfo/app.php
@@ -0,0 +1,9 @@
+<?php
+
+OCP\App::addNavigationEntry(array(
+ 'id' => 'search',
+ 'href' => OCP\Util::linkTo('search', 'index.php'),
+ 'icon' => OCP\Util::imagePath('', 'actions/search.svg'),
+ 'name' => 'Adv. Search',
+ 'order' => 50
+));
diff --git a/search/appinfo/info.xml b/search/appinfo/info.xml
new file mode 100644
index 000000000..14252b855
--- /dev/null
+++ b/search/appinfo/info.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<info>
+ <id>search</id>
+ <name>Advanced Search</name>
+ <description>Allows users to interact with search results (e.g. delete, share) using the same view available in the Files app. Much like iTunes, you can interact with your search results in a file list. It uses the current search providers available ownCloud (i.e. they only search by file name) but I plan to start building more search providers soon. This project is still in beta testing; please submit all bugs or feature requests to https://github.com/andrewsbrown/owncloud-core/issues.</description>
+ <licence>AGPL</licence>
+ <author>Andrew Brown</author>
+ <require>4.9</require>
+ <shipped>false</shipped>
+ <standalone/>
+ <default_enable/>
+ <types>
+ <filesystem/>
+ </types>
+</info>
diff --git a/search/appinfo/version b/search/appinfo/version
new file mode 100644
index 000000000..ea2303bc0
--- /dev/null
+++ b/search/appinfo/version
@@ -0,0 +1 @@
+0.5 \ No newline at end of file
diff --git a/search/css/search.css b/search/css/search.css
new file mode 100644
index 000000000..dbdaaf27f
--- /dev/null
+++ b/search/css/search.css
@@ -0,0 +1,6 @@
+.search_button, .search_button:hover{
+ background-image: url('%webroot%/core/img/actions/search.svg');
+ background-repeat: no-repeat;
+ background-position: .4em center;
+ text-indent: 1.4em;
+} \ No newline at end of file
diff --git a/search/index.php b/search/index.php
new file mode 100644
index 000000000..18d1b6185
--- /dev/null
+++ b/search/index.php
@@ -0,0 +1,76 @@
+<?php
+
+// check if we are a user
+OCP\User::checkLoggedIn();
+
+// load files
+OCP\Util::addStyle('files', 'files');
+OCP\Util::addStyle('search', 'search');
+OCP\Util::addscript('files', 'jquery.iframe-transport');
+OCP\Util::addscript('files', 'jquery.fileupload');
+OCP\Util::addscript('files', 'files');
+OCP\Util::addscript('files', 'filelist');
+OCP\Util::addscript('files', 'fileactions');
+OCP\Util::addscript('files', 'keyboardshortcuts');
+
+// activate link
+OCP\App::setActiveNavigationEntry('search');
+
+// get results
+$query = (isset($_GET['query'])) ? $_GET['query'] : '';
+$results = null;
+if ($query) {
+ $results = OC_Search::search($query);
+}
+
+// create HTML table
+$files = array();
+if (is_array($results)) {
+ foreach ($results as $result) {
+ // create file
+ $_file = $result->fileData;
+ // discard versions
+ if (strpos($_file['path'], '_versions') === 0) {
+ continue;
+ }
+ // get basename and extension
+ $fileinfo = pathinfo($_file['name']);
+ $_file['basename'] = $fileinfo['filename'];
+ if (!empty($fileinfo['extension'])) {
+ $_file['extension'] = '.' . $fileinfo['extension'];
+ } else {
+ $_file['extension'] = '';
+ }
+ // get date
+ $_file['date'] = OCP\Util::formatDate($_file['mtime']);
+ // get directory
+ $_file['directory'] = str_replace('/' . $_file['name'], '', $_file['path']);
+ // get permissions
+ $_file['type'] = ($_file['mimetype'] == 'httpd/unix-directory') ? 'dir' : 'file';
+ $permissions = OCP\PERMISSION_READ;
+ if (!$_file['encrypted']) {
+ $permissions |= OCP\PERMISSION_SHARE;
+ }
+ if ($_file['type'] == 'dir' && $_file['writable']) {
+ $permissions |= OCP\PERMISSION_CREATE;
+ }
+ if ($_file['writable']) {
+ $permissions |= OCP\PERMISSION_UPDATE | OCP\PERMISSION_DELETE;
+ }
+ $_file['permissions'] = $permissions;
+ // add file
+ $files[] = $_file;
+ }
+}
+$list = new OCP\Template('files', 'part.list', '');
+$list->assign('files', $files, false);
+$list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
+$list->assign('downloadURL', OCP\Util::linkTo('files', 'download.php') . '?file=', false);
+
+// populate main template
+$tmpl = new OCP\Template('search', 'index', 'user');
+$tmpl->assign('files', $files);
+$tmpl->assign('fileList', $list->fetchPage(), false);
+$tmpl->assign('breadcrumb', $query, true);
+$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
+$tmpl->printPage(); \ No newline at end of file
diff --git a/search/templates/index.php b/search/templates/index.php
new file mode 100644
index 000000000..2f728ac2c
--- /dev/null
+++ b/search/templates/index.php
@@ -0,0 +1,43 @@
+<!--[if IE 8]><style>input[type="checkbox"]{padding:0;}table td{position:static !important;}</style><![endif]-->
+
+<!-- search form -->
+<div id="controls">
+ <form id="search-form" action="<?php echo OCP\Util::linkTo('search', 'index.php'); ?>" method="get">
+ <input type="text" name="query" id="search_query" value="<?php echo $_['breadcrumb']; ?>">
+ <button class="button search_button">Search</button>
+ </form>
+</div>
+<div id="file_action_panel"></div>
+<div id='notification'></div>
+
+<?php if (empty($_['files'])): ?>
+ <div id="emptyfolder"><?php echo $l->t('Nothing found.') ?></div>
+<?php endif; ?>
+
+<!-- results list -->
+<table class="resultsList">
+ <thead>
+ <tr>
+ <th id='headerName'>
+ <input type="checkbox" id="select_all" />
+ <span class='name'><?php echo $l->t('Name'); ?></span>
+ <span class='selectedActions'>
+ <?php if ($_['allowZipDownload']) : ?>
+ <a href="" class="download"><img class='svg' alt="Download" src="<?php echo OCP\image_path("core", "actions/download.svg"); ?>" /> <?php echo $l->t('Download') ?></a>
+ <?php endif; ?>
+ </span>
+ </th>
+ <th id="headerSize"><?php echo $l->t('Size'); ?></th>
+ <th id="headerDate">
+ <span id="modified"><?php echo $l->t('Modified'); ?></span>
+ </th>
+ </tr>
+ </thead>
+ <tbody id="fileList">
+ <?php echo($_['fileList']); ?>
+ </tbody>
+</table>
+<div id="editor"></div>
+
+<!-- config hints for javascript -->
+<input type="hidden" name="allowZipDownload" id="allowZipDownload" value="<?php echo $_['allowZipDownload']; ?>" />