<?php

/**
 * This file is part of Opensearch
 * Copyright by algebre - http://www.saharama.net
 *
 * Module web_search is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Opensearch is only running within
 * pragmaMx - Web Content Management System.
 * Copyright by pragmaMx Developer Team - http://www.pragmamx.org
 *
 * @author  algebre
 * @version 1.1
 * date 05/11/2010
 */
include ('mainfile.php');

/**
 * -------------MODIFY HERE TO CUSTOMIZE THE OPENSEARCH------
 */

/**
 * Select the target MODULE where "OpenSearch" perform the  search
 * Select one module from this list
 * 
 * Downloads
 * Web_Links
 * My_eGallery
 * Forum {SMF} if installed
 * eBoard
 * Content (default)
 * News 
 */
 $mod = "News"; // Put here your selected module.
 
 /**
 * The OpenSearch Suggestions extension by GOOGLE
 * Default : activated
 */
 $suggest = true; //recomanded
 /**
 * -------------END MODIFY HERE TO CUSTOMIZE THE OPENSEARCH------
 */
 if (!mxModuleAllowed($mod)) return ;
 $op_config = array('Forum' => array(
                           'link' => 'modules.php?name=Forum&amp;action=search2&amp;search={searchTerms}',
                           'name' => 'Forum'
                           ),
                    'Content' => array(
                           'link' => 'modules.php?name=Search&amp;type=content&amp;query={searchTerms}',
                           'name' => _CONTENT
                           ),
                    'Downloads' => array(
                           'link' => 'modules.php?name=Downloads&amp;op=search&amp;query={searchTerms}',
                           'name' => _DOWNLOADS
                           ),
                    'Web_Links' => array(
                           'link' => 'modules.php?name=Web_Links&amp;op=search&amp;query={searchTerms}',
                           'name' => _WEBLINKS 
                           ),
                    'My_eGallery' => array(
                           'link' => 'modules.php?name=Search&amp;type=galerie&amp;query={searchTerms}',
                           'name' => _GALLERY
                           ),
                    'eBoard' => array(
                           'link' => 'modules.php?name=Search&amp;type=forum&amp;query={searchTerms}',
                           'name' => _FORUM
                           ),
                    'News' => array(
                           'link' => 'modules.php?name=Search&amp;type=stories&amp;query={searchTerms}',
                           'name' => _NEWSARTICLES
                           ),
 );
$suggest_url ='';
if ($suggest) $suggest_url ='xmlns:suggestions="http://www.opensearch.org/specifications/opensearch/extensions/suggestions/1.1">
    <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&amp;client=firefox&amp;qu={searchTerms}"/>';
    
if (!defined('BR'))
    define('BR', "\n");
    
$favicon = (file_exists(MX_BASE_URL . 'favicon.ico') ? '' :
    '<Image width="16" height="16" type="image/x-icon">' . MX_BASE_URL . 'favicon.ico</Image>');
    
// Output  
#######################################################################################################################  
$out = '<?xml version="1.0" encoding="' . _CHARSET . '"?>
    <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
	<ShortName>' . htmlspecialchars($sitename) . '</ShortName>
	<Description>' . htmlspecialchars($sitename) . '-' . _SEARCH . '-' . $op_config[$mod]['name'] . '</Description>
	<Contact>' . htmlspecialchars($adminmail) . '</Contact>';
    $out .= $suggest_url;
    $out .= '
	<Url type="text/html" method="GET" template="' . MX_BASE_URL . $op_config[$mod]['link'] . '" />
    <LongName>' . htmlspecialchars($slogan) . '</LongName>' . BR;
     $out .= $favicon;
$out .= '
    <Developer>pragmaMx Developer Team - http://www.pragmamx.org</Developer>
	<SyndicationRight>open</SyndicationRight>
	<AdultContent>false</AdultContent>
	<Language>' . _LOCALE . '</Language>
	<OutputEncoding>' . _CHARSET . '</OutputEncoding>
	<InputEncoding>' . _CHARSET . '</InputEncoding>
</OpenSearchDescription>';

#######################################################################################################################
if (mxModuleAllowed('Search'))
{
    //header( 'Content-type: application/xml' );
    header('Content-Type: application/opensearchdescription+xml; charset=' ._CHARSET . '');
    echo $out;
}

?>
