primo commit
This commit is contained in:
30
modules/mod_search/helper.php
Normal file
30
modules/mod_search/helper.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_search
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Helper for mod_search
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class ModSearchHelper
|
||||
{
|
||||
/**
|
||||
* Display the search button as an image.
|
||||
*
|
||||
* @return string The HTML for the image.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getSearchImage()
|
||||
{
|
||||
return JHtml::_('image', 'searchButton.gif', '', null, true, true);
|
||||
}
|
||||
}
|
||||
51
modules/mod_search/mod_search.php
Normal file
51
modules/mod_search/mod_search.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_search
|
||||
*
|
||||
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Include the search functions only once
|
||||
JLoader::register('ModSearchHelper', __DIR__ . '/helper.php');
|
||||
|
||||
$lang = JFactory::getLanguage();
|
||||
$app = JFactory::getApplication();
|
||||
$set_Itemid = (int) $params->get('set_itemid', 0);
|
||||
$mitemid = $set_Itemid > 0 ? $set_Itemid : $app->input->getInt('Itemid');
|
||||
|
||||
if ($params->get('opensearch', 1))
|
||||
{
|
||||
$doc = JFactory::getDocument();
|
||||
|
||||
$ostitle = $params->get('opensearch_title', JText::_('MOD_SEARCH_SEARCHBUTTON_TEXT') . ' ' . $app->get('sitename'));
|
||||
$doc->addHeadLink(
|
||||
JUri::getInstance()->toString(array('scheme', 'host', 'port'))
|
||||
. JRoute::_('&option=com_search&format=opensearch&Itemid=' . $mitemid), 'search', 'rel',
|
||||
array(
|
||||
'title' => htmlspecialchars($ostitle, ENT_COMPAT, 'UTF-8'),
|
||||
'type' => 'application/opensearchdescription+xml'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$upper_limit = $lang->getUpperLimitSearchWord();
|
||||
$button = $params->get('button', 0);
|
||||
$imagebutton = $params->get('imagebutton', 0);
|
||||
$button_pos = $params->get('button_pos', 'left');
|
||||
$button_text = htmlspecialchars($params->get('button_text', JText::_('MOD_SEARCH_SEARCHBUTTON_TEXT')), ENT_COMPAT, 'UTF-8');
|
||||
$width = (int) $params->get('width');
|
||||
$maxlength = $upper_limit;
|
||||
$text = htmlspecialchars($params->get('text', JText::_('MOD_SEARCH_SEARCHBOX_TEXT')), ENT_COMPAT, 'UTF-8');
|
||||
$label = htmlspecialchars($params->get('label', JText::_('MOD_SEARCH_LABEL_TEXT')), ENT_COMPAT, 'UTF-8');
|
||||
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx', ''), ENT_COMPAT, 'UTF-8');
|
||||
|
||||
if ($imagebutton)
|
||||
{
|
||||
$img = ModSearchHelper::getSearchImage();
|
||||
}
|
||||
|
||||
require JModuleHelper::getLayoutPath('mod_search', $params->get('layout', 'default'));
|
||||
176
modules/mod_search/mod_search.xml
Normal file
176
modules/mod_search/mod_search.xml
Normal file
@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="module" version="3.1" client="site" method="upgrade">
|
||||
<name>mod_search</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>July 2004</creationDate>
|
||||
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>MOD_SEARCH_XML_DESCRIPTION</description>
|
||||
<files>
|
||||
<filename module="mod_search">mod_search.php</filename>
|
||||
<folder>tmpl</folder>
|
||||
<filename>helper.php</filename>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">en-GB.mod_search.ini</language>
|
||||
<language tag="en-GB">en-GB.mod_search.sys.ini</language>
|
||||
</languages>
|
||||
<help key="JHELP_EXTENSIONS_MODULE_MANAGER_SEARCH" />
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="label"
|
||||
type="label"
|
||||
label="MOD_SEARCH_FIELD_LABEL_TEXT_LABEL"
|
||||
description="MOD_SEARCH_FIELD_LABEL_TEXT_DESC"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="width"
|
||||
type="number"
|
||||
label="MOD_SEARCH_FIELD_BOXWIDTH_LABEL"
|
||||
description="MOD_SEARCH_FIELD_BOXWIDTH_DESC"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="text"
|
||||
type="text"
|
||||
label="MOD_SEARCH_FIELD_TEXT_LABEL"
|
||||
description="MOD_SEARCH_FIELD_TEXT_DESC"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="button"
|
||||
type="radio"
|
||||
label="MOD_SEARCH_FIELD_BUTTON_LABEL"
|
||||
description="MOD_SEARCH_FIELD_BUTTON_DESC"
|
||||
default="0"
|
||||
filter="integer"
|
||||
class="btn-group btn-group-yesno"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="button_pos"
|
||||
type="list"
|
||||
label="MOD_SEARCH_FIELD_BUTTONPOS_LABEL"
|
||||
description="MOD_SEARCH_FIELD_BUTTONPOS_DESC"
|
||||
default="left"
|
||||
showon="button:1"
|
||||
>
|
||||
<option value="right">MOD_SEARCH_FIELD_VALUE_RIGHT</option>
|
||||
<option value="left">MOD_SEARCH_FIELD_VALUE_LEFT</option>
|
||||
<option value="top">MOD_SEARCH_FIELD_VALUE_TOP</option>
|
||||
<option value="bottom">MOD_SEARCH_FIELD_VALUE_BOTTOM</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="imagebutton"
|
||||
type="radio"
|
||||
label="MOD_SEARCH_FIELD_IMAGEBUTTON_LABEL"
|
||||
description="MOD_SEARCH_FIELD_IMAGEBUTTON_DESC"
|
||||
default="0"
|
||||
filter="integer"
|
||||
class="btn-group btn-group-yesno"
|
||||
showon="button:1"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="button_text"
|
||||
type="text"
|
||||
label="MOD_SEARCH_FIELD_BUTTONTEXT_LABEL"
|
||||
description="MOD_SEARCH_FIELD_BUTTONTEXT_DESC"
|
||||
showon="button:1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="opensearch"
|
||||
type="radio"
|
||||
label="MOD_SEARCH_FIELD_OPENSEARCH_LABEL"
|
||||
description="MOD_SEARCH_FIELD_OPENSEARCH_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="opensearch_title"
|
||||
type="text"
|
||||
label="MOD_SEARCH_FIELD_OPENSEARCH_TEXT_LABEL"
|
||||
description="MOD_SEARCH_FIELD_OPENSEARCH_TEXT_DESC"
|
||||
showon="opensearch:1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="set_itemid"
|
||||
type="menuitem"
|
||||
label="MOD_SEARCH_FIELD_SETITEMID_LABEL"
|
||||
description="MOD_SEARCH_FIELD_SETITEMID_DESC"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">MOD_SEARCH_SELECT_MENU_ITEMID</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="advanced">
|
||||
<field
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
description="JFIELD_ALT_MODULE_LAYOUT_DESC"
|
||||
validate="moduleLayout"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="moduleclass_sfx"
|
||||
type="textarea"
|
||||
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
|
||||
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC"
|
||||
rows="3"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cache"
|
||||
type="list"
|
||||
label="COM_MODULES_FIELD_CACHING_LABEL"
|
||||
description="COM_MODULES_FIELD_CACHING_DESC"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="1">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="cache_time"
|
||||
type="number"
|
||||
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
|
||||
description="COM_MODULES_FIELD_CACHE_TIME_DESC"
|
||||
default="900"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cachemode"
|
||||
type="hidden"
|
||||
default="itemid"
|
||||
>
|
||||
<option value="itemid"></option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
68
modules/mod_search/tmpl/default.php
Normal file
68
modules/mod_search/tmpl/default.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_search
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Including fallback code for the placeholder attribute in the search field.
|
||||
JHtml::_('jquery.framework');
|
||||
JHtml::_('script', 'system/html5fallback.js', array('version' => 'auto', 'relative' => true, 'conditional' => 'lt IE 9'));
|
||||
|
||||
if ($width)
|
||||
{
|
||||
$moduleclass_sfx .= ' ' . 'mod_search' . $module->id;
|
||||
$css = 'div.mod_search' . $module->id . ' input[type="search"]{ width:auto; }';
|
||||
JFactory::getDocument()->addStyleDeclaration($css);
|
||||
$width = ' size="' . $width . '"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$width = '';
|
||||
}
|
||||
?>
|
||||
<div class="search<?php echo $moduleclass_sfx; ?>">
|
||||
<form action="<?php echo JRoute::_('index.php'); ?>" method="post" class="form-inline" role="search">
|
||||
<?php
|
||||
$output = '<label for="mod-search-searchword' . $module->id . '" class="element-invisible">' . $label . '</label> ';
|
||||
$output .= '<input name="searchword" id="mod-search-searchword' . $module->id . '" maxlength="' . $maxlength . '" class="inputbox search-query input-medium" type="search"' . $width;
|
||||
$output .= ' placeholder="' . $text . '" />';
|
||||
|
||||
if ($button) :
|
||||
if ($imagebutton) :
|
||||
$btn_output = ' <input type="image" alt="' . $button_text . '" class="button" src="' . $img . '" onclick="this.form.searchword.focus();"/>';
|
||||
else :
|
||||
$btn_output = ' <button class="button btn btn-primary" onclick="this.form.searchword.focus();">' . $button_text . '</button>';
|
||||
endif;
|
||||
|
||||
switch ($button_pos) :
|
||||
case 'top' :
|
||||
$output = $btn_output . '<br />' . $output;
|
||||
break;
|
||||
|
||||
case 'bottom' :
|
||||
$output .= '<br />' . $btn_output;
|
||||
break;
|
||||
|
||||
case 'right' :
|
||||
$output .= $btn_output;
|
||||
break;
|
||||
|
||||
case 'left' :
|
||||
default :
|
||||
$output = $btn_output . $output;
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
|
||||
echo $output;
|
||||
?>
|
||||
<input type="hidden" name="task" value="search" />
|
||||
<input type="hidden" name="option" value="com_search" />
|
||||
<input type="hidden" name="Itemid" value="<?php echo $mitemid; ?>" />
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user