]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
No more config file. Cofiguration is now set by settings.
authorSem <sembrestels@riseup.net>
Fri, 30 Dec 2011 03:50:08 +0000 (04:50 +0100)
committerSem <sembrestels@riseup.net>
Fri, 30 Dec 2011 03:50:08 +0000 (04:50 +0100)
README
config.ini.sample [deleted file]
languages/en.php
views/default/plugins/opensearch/settings.php [new file with mode: 0644]
views/xml/opensearch/description.php

diff --git a/README b/README
index 236ce9da22308f6cf8b9191e811f2b6c3a002656..a25a00c932f4af9de1f0e011b2ab9ddfd057bd20 100644 (file)
--- a/README
+++ b/README
@@ -8,9 +8,8 @@ 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
+ * Edit OpenSearch settings in administration pages to reflect your site
 
 USAGE
 -------------
diff --git a/config.ini.sample b/config.ini.sample
deleted file mode 100644 (file)
index 7700231..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-; OpenSearch configuration
-
-; ShortName
-; Contains a brief human-readable title that identifies this search engine.
-; 16 characters or less of plain text.
-; Required
-shortname = "Elgg"
-
-; Description
-; Contains a human-readable text description of the search engine.
-; 1024 characters or less of plain text.
-; Required
-description    = "Elgg search engine"
-
-; LongName
-; Contains an extended human-readable title that identifies this search engine.
-; 48 characters or less of plain text.
-;longname = ""
-
-; Image
-; Contains a URL that identifies the location of an image that can be used
-; in association with this search content. Can be either a 16x16 ico or
-; 64x64 png or both. Clients will choose the image that best fits the
-; display area. The value should be relative to your Elgg root.
-ico = "_graphics/favicon.ico"
-;png = ""
-
-; Tags
-; Contains a set of words that are used as keywords to identify and categorize
-; this search content. Tags must be a single word and are delimited by the
-; space character (' ').
-; 256 characters or less, space delimited tags
-;tags = "test search elgg"
-
-; Language
-; Contains a string that indicates that the search engine supports search
-; results in the specified language.
-; * or codes according to XML 1.0 Language Identification
-lang[] = "en-us"
-
-; Query
-; Test query available to clients.
-; Clients can submit this as a test query to ensure that the OpenSearch
-; interface works.
-;query = "test"
index 011e5d0b5b06315db70fe00a4f6d00fd828700a8..9a77f362b174e4db54bf46f695130092f567769f 100644 (file)
@@ -5,7 +5,24 @@
 
 $english = array(
        'opensearch:title' => "Search: %s",
-       'opensearch:description' => "Search results for \"%s\"",        
+       'opensearch:description' => "Search results for \"%s\"",
+       'opensearch:engine' => "%s Search Engine",
+       
+       'opensearh:settings:shortname' => "Short name",
+       'opensearh:settings:desc' => "Description",
+       'opensearh:settings:longname' => "Long name",
+       'opensearh:settings:icon' => "Icon",
+       'opensearh:settings:tags' => "Tags",
+       'opensearh:settings:lang' => "Language",
+       'opensearh:settings:query' => "Query",
+       'opensearh:settings:shortname:description' => "Contains a brief human-readable title that identifies this search engine. 16 characters or less of plain text. <strong>Required</strong>",
+       'opensearh:settings:desc:description' => "Contains a human-readable text description of the search engine. 1024 characters or less of plain text. <strong>Required</strong>",
+       'opensearh:settings:longname:description' => "Contains an extended human-readable title that identifies this search engine. 48 characters or less of plain text.",
+       'opensearh:settings:icon:description' => "Contains a URL that identifies the location of an image that can be used in association with this search content. Can be either a 16x16 ico or 64x64 png or both. Clients will choose the image that best fits the display area. The value should be relative to your Elgg root.",
+       'opensearh:settings:tags:description' => "Contains a set of words that are used as keywords to identify and categorize this search content. Tags must be a single word and are delimited by the space character (' '). 256 characters or less, space delimited tags",
+       'opensearh:settings:lang:description' => "Contains a string that indicates that the search engine supports search results in the specified language. * or codes according to XML 1.0 Language Identification",
+       'opensearh:settings:query:description' => "Test query available to clients. Clients can submit this as a test query to ensure that the OpenSearch interface works.",
+       
 );
 
 add_translation("en", $english);
diff --git a/views/default/plugins/opensearch/settings.php b/views/default/plugins/opensearch/settings.php
new file mode 100644 (file)
index 0000000..23ba195
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+/**
+ * Opensearch plugin settings
+ */
+
+// set default value
+if (!isset($vars['entity']->shortname)) {
+       $vars['entity']->shortname = elgg_get_site_entity()->name;
+}
+if (!isset($vars['entity']->desc)) {
+       $vars['entity']->desc = elgg_echo('opensearch:engine', array(elgg_get_site_entity()->name));
+}
+if (!isset($vars['entity']->longname)) {
+       $vars['entity']->longname = elgg_get_site_entity()->description;
+}
+if (!isset($vars['entity']->icon)) {
+       $vars['entity']->icon = '_graphics/favicon.ico';
+}
+if (!isset($vars['entity']->tags)) {
+       $vars['entity']->tags = '';
+}
+if (!isset($vars['entity']->lang)) {
+       $vars['entity']->lang = 'en-us';
+}
+if (!isset($vars['entity']->query)) {
+       $vars['entity']->query = '';
+}
+
+echo '<div>';
+echo '<label>'.elgg_echo('opensearh:settings:shortname').'</label> ';
+echo elgg_echo('opensearh:settings:shortname:description');
+echo ' ';
+echo elgg_view('input/text', array(
+       'name' => 'params[shortname]',
+       'value' => $vars['entity']->shortname,
+));
+echo '</div>';
+
+echo '<div>';
+echo '<label>'.elgg_echo('opensearh:settings:desc').'</label> ';
+echo elgg_echo('opensearh:settings:desc:description');
+echo ' ';
+echo elgg_view('input/text', array(
+       'name' => 'params[desc]',
+       'value' => $vars['entity']->desc,
+));
+echo '</div>';
+
+echo '<div>';
+echo '<label>'.elgg_echo('opensearh:settings:longname').'</label> ';
+echo elgg_echo('opensearh:settings:longname:description');
+echo ' ';
+echo elgg_view('input/text', array(
+       'name' => 'params[longname]',
+       'value' => $vars['entity']->longname,
+));
+echo '</div>';
+
+echo '<div>';
+echo '<label>'.elgg_echo('opensearh:settings:icon').'</label> ';
+echo elgg_echo('opensearh:settings:icon:description');
+echo ' ';
+echo elgg_view('input/text', array(
+       'name' => 'params[icon]',
+       'value' => $vars['entity']->icon,
+));
+echo '</div>';
+
+echo '<div>';
+echo '<label>'.elgg_echo('opensearh:settings:tags').'</label> ';
+echo elgg_echo('opensearh:settings:tags:description');
+echo ' ';
+echo elgg_view('input/text', array(
+       'name' => 'params[tags]',
+       'value' => $vars['entity']->tags,
+));
+echo '</div>';
+
+echo '<div>';
+echo '<label>'.elgg_echo('opensearh:settings:lang').'</label> ';
+echo elgg_echo('opensearh:settings:lang:description');
+echo ' ';
+echo elgg_view('input/text', array(
+       'name' => 'params[lang]',
+       'value' => $vars['entity']->lang,
+));
+echo '</div>';
+
+echo '<div>';
+echo '<label>'.elgg_echo('opensearh:settings:query').'</label> ';
+echo elgg_echo('opensearh:settings:query:description');
+echo ' ';
+echo elgg_view('input/text', array(
+       'name' => 'params[query]',
+       'value' => $vars['entity']->query,
+));
+echo '</div>';
index 78aadc6992636808b17ffad53d30bf792db4d3d0..586cadf83f4ca0fbd36cf6e5a4633ca3a1a1ef01 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Creates an OpenSearch description document from config.ini
+ * Creates an OpenSearch description document from plugin settings
  * http://www.opensearch.org/Specifications/OpenSearch/1.1
  */
 
@@ -8,18 +8,31 @@
 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) {
-       elgg_log("Unable to parse OpenSearch config file", 'ERROR');
-       return true;
-}
-
-extract($config);
-
 $site = elgg_get_site_entity();
 $email = $site->email;
 
+$shortname = elgg_get_plugin_setting('shortname', 'opensearch');
+$description = elgg_get_plugin_setting('desc', 'opensearch');
+$longname = elgg_get_plugin_setting('longname', 'opensearch');
+$icon = elgg_get_plugin_setting('icon', 'opensearch');
+$tags = elgg_get_plugin_setting('tags', 'opensearch');
+$lang = string_to_tag_array(elgg_get_plugin_setting('lang', 'opensearch'));
+$query = elgg_get_plugin_setting('query', 'opensearch');
+
+if (empty($shortname)) {
+       $shortname = $site->name;
+}
+if (empty($description)) {
+       $description = elgg_echo('opensearch:engine', array(elgg_get_site_entity()->name));
+}
+if (empty($icon)) {
+       $icon = '_graphics/favicon.ico';
+}
+if (empty($lang)) {
+       $lang = 'en-us';
+}
+
+
 $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}');
@@ -35,11 +48,10 @@ $site_url = elgg_get_site_url();
    <Contact><?php echo $site->email; ?></Contact>
    <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 "{$site_url}$ico"; ?></Image>
-<?php endif; ?>
-<?php if (isset($png)): ?>
-   <Image height="64" width="64" type="image/png"><?php echo "{$site_url}$png"; ?></Image>
+<?php if (preg_match("/.ico$/", $icon)): ?>
+   <Image height="16" width="16" type="image/vnd.microsoft.icon"><?php echo "{$site_url}$icon"; ?></Image>
+<?php elseif (preg_match("/.png$/", $icon)): ?>
+   <Image height="64" width="64" type="image/png"><?php echo "{$site_url}$icon"; ?></Image>
 <?php endif; ?>
 <?php if (isset($tags)): ?>
    <Tags><?php echo $tags; ?></Tags>