aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README16
-rw-r--r--languages/en.php6
-rw-r--r--manifest.xml24
-rw-r--r--start.php19
-rw-r--r--views/default/opensearch/includes.php7
-rw-r--r--views/opensearch_rss/page/default.php (renamed from views/opensearch_rss/page_shells/default.php)14
-rw-r--r--views/opensearch_rss/page/layouts/default.php5
-rw-r--r--views/opensearch_rss/pageshells/pageshell.php6
-rw-r--r--views/opensearch_rss/search/layout.php3
-rw-r--r--views/opensearch_rss/search/list.php (renamed from views/opensearch_rss/search/listing.php)3
-rw-r--r--views/xml/opensearch/description.php20
11 files changed, 73 insertions, 50 deletions
diff --git a/README b/README
index 1725196a6..236ce9da2 100644
--- a/README
+++ b/README
@@ -1,14 +1,22 @@
OpenSearch endpoint for Elgg
+OVERVIEW
+-------------
+OpenSearch is a standard for exposing the data in your website for search
+to browsers and other web sites. For more information on this technology, visit
+the Wikipedia page on OpenSearch at http://en.wikipedia.org/wiki/OpenSearch
+
INSTALL
-Rename config.ini.sample to config.ini
-Edit config.ini to reflect your site
-Activate the plugin
+-------------
+ * Rename config.ini.sample to config.ini
+ * Edit config.ini to reflect your site
+ * Activate the plugin
USAGE
+-------------
Adds an OpenSearch description definition to the html head. Browsers
will pick this up and allow you to add site specific search to your
search bar.
The plugin also provides an RSS 2.0 feed that conforms to the OpenSearch
-standard.
+standard.
diff --git a/languages/en.php b/languages/en.php
index c0b3e5bf5..011e5d0b5 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -1,9 +1,11 @@
<?php
+/**
+ * OpenSearch English language file
+ */
$english = array(
'opensearch:title' => "Search: %s",
- 'opensearch:description' => "Search results for \"%s\"",
-
+ 'opensearch:description' => "Search results for \"%s\"",
);
add_translation("en", $english);
diff --git a/manifest.xml b/manifest.xml
index a8733595b..525027c63 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -1,10 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
-<plugin_manifest>
- <field key="author" value="Cash Costello" />
- <field key="version" value="1.0" />
- <field key="description" value="OpenSearch plugin" />
- <field key="website" value="http://cashcostello.com/blog/" />
- <field key="copyright" value="Cash Costello 2010" />
- <field key="licence" value="GNU Public License version 2" />
- <field key="elgg_version" value="2010030101" />
-</plugin_manifest>
+<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
+ <name>OpenSearch</name>
+ <author>Cash Costello</author>
+ <version>1.1</version>
+ <category>utility</category>
+ <category>search</category>
+ <description>OpenSearch integration</description>
+ <website>https://github.com/cash/opensearch</website>
+ <copyright>Cash Costello 2010-2011</copyright>
+ <license>GNU Public License version 2</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+</plugin_manifest> \ No newline at end of file
diff --git a/start.php b/start.php
index 7adc0f733..88329c8d1 100644
--- a/start.php
+++ b/start.php
@@ -8,31 +8,26 @@
* @license http://opensource.org/licenses/gpl-2.0.php GPL 2
*/
-register_elgg_event_handler('init', 'system', 'opensearch_init');
+elgg_register_event_handler('init', 'system', 'opensearch_init');
function opensearch_init() {
- global $CONFIG;
-
- register_page_handler('opensearch', 'opensearch_handler');
-
- elgg_extend_view('metatags', 'opensearch/includes');
+ elgg_register_page_handler('opensearch', 'opensearch_handler');
+ elgg_extend_view('page/elements/head', 'opensearch/includes');
}
/**
* Handles OpenSearch requests
*
* @param array $page An array of URL elements
- * @return boolean
+ * @return bool
*/
function opensearch_handler($page) {
- global $CONFIG;
-
switch ($page[0]) {
case 'osd.xml':
elgg_set_viewtype('xml');
- page_draw('', elgg_view('opensearch/description'));
- return TRUE;
+ echo elgg_view_page('', elgg_view('opensearch/description'));
+ return true;
break;
}
-
+ return false;
}
diff --git a/views/default/opensearch/includes.php b/views/default/opensearch/includes.php
index 57e56723f..6aceb45c2 100644
--- a/views/default/opensearch/includes.php
+++ b/views/default/opensearch/includes.php
@@ -1,7 +1,10 @@
<?php
+/**
+ * OpenSearch head include
+ */
-$url = "{$vars['url']}pg/opensearch/osd.xml";
-$title = $vars['config']->sitename;
+$url = elgg_normalize_url('opensearch/osd.xml');
+$title = elgg_get_site_entity()->name;
?>
<link rel="search" type="application/opensearchdescription+xml" href="<?php echo $url; ?>" title="<?php echo $title; ?>" />
diff --git a/views/opensearch_rss/page_shells/default.php b/views/opensearch_rss/page/default.php
index e9510e9da..79cd544c4 100644
--- a/views/opensearch_rss/page_shells/default.php
+++ b/views/opensearch_rss/page/default.php
@@ -1,4 +1,7 @@
<?php
+/**
+ * Page shell for OpenSearch RSS feed
+ */
global $OPEN_SEARCH_COUNT;
@@ -11,16 +14,15 @@ echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
// Set title
$search_terms = get_input('q');
-$title = $vars['config']->sitename;
-$title .= ' ' . sprintf(elgg_echo('opensearch:title'), $search_terms);
+$title = elgg_get_site_entity()->name;
+$title .= ' ' . elgg_echo('opensearch:title', array($search_terms));
-$description = sprintf(elgg_echo('opensearch:description'), $search_terms);
+$description = elgg_echo('opensearch:description', array($search_terms));
// Remove viewtype from URL
-$search_url = str_replace('&view=opensearch_rss','', full_url());
-
-$os_url = "{$vars['url']}pg/opensearch/osd.xml";
+$search_url = str_replace('&view=opensearch_rss', '', full_url());
+$os_url = elgg_normalize_url('opensearch/osd.xml');
?>
<rss version="2.0" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
diff --git a/views/opensearch_rss/page/layouts/default.php b/views/opensearch_rss/page/layouts/default.php
new file mode 100644
index 000000000..488734f84
--- /dev/null
+++ b/views/opensearch_rss/page/layouts/default.php
@@ -0,0 +1,5 @@
+<?php
+/**
+ * OpenSearch RSS layout shell
+ */
+echo $vars['content']; \ No newline at end of file
diff --git a/views/opensearch_rss/pageshells/pageshell.php b/views/opensearch_rss/pageshells/pageshell.php
deleted file mode 100644
index f883f236a..000000000
--- a/views/opensearch_rss/pageshells/pageshell.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * To support Elgg 1.7
- */
-
-require_once(dirname(dirname(__FILE__)) . "/page_shells/default.php");
diff --git a/views/opensearch_rss/search/layout.php b/views/opensearch_rss/search/layout.php
index 4cd2ff050..d5bb9fe57 100644
--- a/views/opensearch_rss/search/layout.php
+++ b/views/opensearch_rss/search/layout.php
@@ -1,2 +1,5 @@
<?php
+/**
+ * OpenSearch search layout
+ */
echo $vars['body']; \ No newline at end of file
diff --git a/views/opensearch_rss/search/listing.php b/views/opensearch_rss/search/list.php
index 219462976..bc7b5574e 100644
--- a/views/opensearch_rss/search/listing.php
+++ b/views/opensearch_rss/search/list.php
@@ -1,4 +1,7 @@
<?php
+/**
+ * OpenSearch serach results list
+ */
global $OPEN_SEARCH_COUNT;
if (!isset($OPEN_SEARCH_COUNT)) {
diff --git a/views/xml/opensearch/description.php b/views/xml/opensearch/description.php
index 221cb768e..78aadc699 100644
--- a/views/xml/opensearch/description.php
+++ b/views/xml/opensearch/description.php
@@ -5,23 +5,25 @@
*/
// reset cache headers because IE8 is stupid
-header('Pragma: public', TRUE);
-header('Cache-Control: public', TRUE);
+header('Pragma: public', true);
+header('Cache-Control: public', true);
$config_ini = dirname(dirname(dirname(dirname(__FILE__)))) . '/config.ini';
$config = parse_ini_file($config_ini);
-if ($config == FALSE) {
+if ($config == false) {
elgg_log("Unable to parse OpenSearch config file", 'ERROR');
- return TRUE;
+ return true;
}
extract($config);
-$site = get_entity($CONFIG->site_guid);
+$site = elgg_get_site_entity();
$email = $site->email;
-$rss_url = "{$vars['url']}pg/search/?q={searchTerms}&amp;view=opensearch_rss";
-$html_url = "{$vars['url']}pg/search/?q={searchTerms}";
+$rss_url = elgg_normalize_url('search/?q={searchTerms}&view=opensearch_rss');
+$rss_url = elgg_format_url($rss_url);
+$html_url = elgg_normalize_url('search/?q={searchTerms}');
+$site_url = elgg_get_site_url();
?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
@@ -34,10 +36,10 @@ $html_url = "{$vars['url']}pg/search/?q={searchTerms}";
<Url type="text/html" template="<?php echo $html_url; ?>"/>
<Url type="application/rss+xml" template="<?php echo $rss_url; ?>"/>
<?php if (isset($ico)): ?>
- <Image height="16" width="16" type="image/vnd.microsoft.icon"><?php echo "{$vars['url']}$ico"; ?></Image>
+ <Image height="16" width="16" type="image/vnd.microsoft.icon"><?php echo "{$site_url}$ico"; ?></Image>
<?php endif; ?>
<?php if (isset($png)): ?>
- <Image height="64" width="64" type="image/png"><?php echo "{$vars['url']}$png"; ?></Image>
+ <Image height="64" width="64" type="image/png"><?php echo "{$site_url}$png"; ?></Image>
<?php endif; ?>
<?php if (isset($tags)): ?>
<Tags><?php echo $tags; ?></Tags>