These are modifications on search in flexicontent files came from 1.5.6 - RC1a r979
#3 Modification on default_form.php came from com_flexicontent/views/search/tmpl:
Code:
<?php defined('_JEXEC') or die('Restricted access');
$autodisplayextrafields = $this->params->get('autodisplayextrafields', 1);
if(!$autodisplayextrafields) {
$this->document->addScriptDeclaration('
window.addEvent("domready", function() {
var status = {
"true": "open",
"false": "close"
};
// -- vertical
var myVerticalSlide = new Fx.Slide("extrafields").hide();
/*$("advancedsearchtext").addEvent("click", function(event){
event.stop();
myVerticalSlide.slideIn();
});*/
$("advancedsearchtext").addEvent("click", function(event){
//event.stop();
//myVerticalSlide.slideOut();
myVerticalSlide.toggle();
});
});
');
}
?>
<form id="searchForm" action="index.php" method="get" name="searchForm">
<fieldset id='fc_search_set_advsearch' class='fc_search_set'>
<legend><?php echo JText::_('FLEXI_BASIC_SEARCH'); ?></legend>
<table id="basicfields" class="basicfields <?php echo $this->escape($this->params->get('pageclass_sfx')); ?>" cellspacing="1">
<tr class="fc_search_row_<?php echo (($r++)%2);?>">
<td nowrap="nowrap" class='fc_search_label_cell'>
<label for="search_searchword" class='hasTip' title='<?php echo JText::_('FLEXI_SEARCH_KEYWORD'); ?>::<?php echo JText::_('FLEXI_SEARCH_KEYWORD_TIP'); ?>'>
<?php echo JText::_('FLEXI_SEARCH_KEYWORD'); ?>:
</label>
</td>
<td nowrap="nowrap" class="fc_search_option_cell">
<input type="text" name="searchword" id="search_searchword" size="30" maxlength="50" value="<?php echo $this->escape($this->searchword); ?>" class="inputbox" />
</td>
<td width="100%" nowrap="nowrap">
<button name="Search" onclick="this.form.submit()" class="button"><?php echo JText::_( 'FLEXI_SEARCH' );?></button>
</td>
</tr>
<?php if ($show_searchphrase = $this->params->get('show_searchphrase', 1)) : ?>
<tr class="fc_search_row_<?php echo (($r++)%2);?>">
<td nowrap="nowrap" class='fc_search_label_cell'>
<label class='hasTip' title='<?php echo JText::_('FLEXI_SEARCH_KEYWORD_REQUIREMENT'); ?>::<?php echo JText::_('FLEXI_SEARCH_KEYWORD_REQUIREMENT_TIP'); ?>'>
<?php echo JText::_('FLEXI_SEARCH_KEYWORD_REQUIREMENT'); ?>:
</label>
</td>
<td colspan="2" class="fc_search_option_cell">
<?php echo $this->lists['searchphrase']; ?>
</td>
</tr>
<?php endif; ?>
<?php if ($this->params->get('cantypes', 1) && (count($this->fieldtypes)>0)) : ?>
<tr class="fc_search_row_<?php echo (($r++)%2);?>">
<td nowrap="nowrap" class='fc_search_label_cell' valign='top'>
<label for="fieldtypes" class='hasTip' title='<?php echo JText::_('FLEXI_SEARCH_CONTENT_TYPE'); ?>::<?php echo JText::_('FLEXI_SEARCH_CONTENT_TYPE_TIP'); ?>'>
<?php echo JText::_('FLEXI_SEARCH_CONTENT_TYPE'); ?>:
</label>
</td>
<td colspan="2" class="fc_search_option_cell">
<?php echo $this->lists['fieldtypes'];?>
</td>
</tr>
<?php endif; ?>
<?php if (!$autodisplayextrafields) : ?>
<tr class="fc_search_row_<?php echo (($r++)%2);?>">
<td colspan="3" class="fc_search_option_cell">
[url=javascript:;" id="advancedsearchtext]<?php echo JText::_('FLEXI_ADVANCED_SEARCH'); ?>[/url]
</td>
</tr>
<?php endif; ?>
</table>
</fieldset>
<fieldset id='fc_search_set_advsearch' class='fc_search_set'>
<legend><?php echo JText::_('FLEXI_ADVANCED_SEARCH'); ?></legend>
<table id="extrafields" class="extrafields <?php echo $this->escape($this->params->get('pageclass_sfx')); ?>" cellspacing="1">
<?php
//params[search_fields]
$search_fields = $this->params->get('search_fields', '');
$search_fields = explode(",", $search_fields);
$fields = &$this->fields;
foreach($search_fields as $f) {
if(!isset($fields[$f])) continue;
?>
<tr class="fc_search_row_<?php echo (($r++)%2);?>">
<td class='fc_search_label_cell' valign='top'>
<?php if ($fields[$f]->description) : ?>
<label for="<?php echo $fields[$f]->name; ?>" class="hasTip" title="<?php echo $fields[$f]->label; ?>::<?php echo $fields[$f]->description; ?>">
<?php echo $fields[$f]->label; ?>:
</label>
<?php else : ?>
<label for="<?php echo $fields[$f]->name; ?>" class="hasTip" title="<?php echo JText::_('FLEXI_SEARCH_MISSING_FIELD_DESCR'); ?>::<?php echo JText::sprintf('FLEXI_SEARCH_MISSING_FIELD_DESCR_TIP', $fields[$f]->label ); ?>">
<?php echo $fields[$f]->label; ?>:
</label>
<?php endif; ?>
</td>
<td colspan="2" class="fc_search_option_cell">
<?php
$noplugin = '<div id="fc-change-error" class="fc-error">'. JText::_( 'FLEXI_PLEASE_PUBLISH_PLUGIN' ) .'</div>';
if(isset($fields[$f]->html)) {
echo $fields[$f]->html;
} else {
echo $noplugin;
}
?>
</td>
</tr>
<?php
//}
}
?>
</table>
</fieldset>
<fieldset id='fc_search_set_search_behavior' class='fc_search_set'>
<legend><?php echo JText::_('FLEXI_SEARCH_BEHAVIOR'); ?></legend>
<table id="resultoptions" class="resultoptions <?php echo $this->escape($this->params->get('pageclass_sfx')); ?>" cellspacing="1">
<?php
if($show_operator = $this->params->get('show_operator', 1)) :
$operator_desc = $this->params->get('operator_desc', 'FLEXI_OPERATOR_DESC');
$operator_desc = ($operator_desc=='FLEXI_OPERATOR_DESC')?JText::_('FLEXI_OPERATOR_DESC'):$operator_desc;
?>
<tr class="fc_search_row_<?php echo (($r++)%2);?>">
<td class='fc_search_label_cell' valign='top'>
<label for="operator" class="hasTip" title='<?php echo JText::_('FLEXI_BASIC_ADVANCED_COMBINATION'); ?>::<?php echo JText::_('FLEXI_BASIC_ADVANCED_COMBINATION_TIP'); ?>'>
<?php echo JText::_("FLEXI_BASIC_ADVANCED_COMBINATION"); ?>:
</label>
</td>
<td colspan="2" class="fc_search_option_cell">
<?php echo $this->lists['operator']; ?>:
</td>
</tr>
<?php endif; ?>
<?php if($show_searchordering = $this->params->get('show_searchordering', 1)) : ?>
<tr class="fc_search_row_<?php echo (($r++)%2);?>">
<td class='fc_search_label_cell' valign='top'>
<label for="ordering" class="hasTip" title='<?php echo JText::_('FLEXI_SEARCH_ORDERING'); ?>::<?php echo JText::_('FLEXI_SEARCH_ORDERING_TIP'); ?>'>
<?php echo JText::_( 'FLEXI_SEARCH_ORDERING' );?>:
</label>
</td>
<td colspan="2" class="fc_search_option_cell">
<?php echo $this->lists['ordering'];?>
</td>
</tr>
<?php endif; ?>
<?php if ($this->params->get( 'show_searchareas', 0 )) : ?>
<tr class="fc_search_row_<?php echo (($r++)%2);?>">
<td class='fc_search_label_cell' valign='top'>
<label class="hasTip" title='<?php echo JText::_('FLEXI_SEARCH_OTHER_CONTENT'); ?>::<?php echo JText::_('FLEXI_SEARCH_OTHER_CONTENT_TIP'); ?>'>
<?php echo JText::_( 'FLEXI_SEARCH_OTHER_CONTENT' );?>:
</label>
<td colspan="2" class="fc_search_option_cell">
<?php // DISABLE search areas 'content' and old 'flexisearch' ?>
<?php unset($this->searchareas['search']['content']); unset($this->searchareas['search']['flexisearch']); ?>
<?php foreach ($this->searchareas['search'] as $val => $txt) :
$checked = is_array( $this->searchareas['active'] ) && in_array( $val, $this->searchareas['active'] ) ? 'checked="checked"' : '';
?>
<input type="checkbox" name="areas[]" value="<?php echo $val;?>" id="area_<?php echo $val;?>" <?php echo $checked;?> />
<label for="area_<?php echo $val;?>">
<?php echo JText::_($txt); ?>
</label>
<?php endforeach; ?>
</td>
</tr>
<?php else:?>
<tr>
<td colspan="3">
<input type="hidden" name="areas[]" value="flexicontent" id="area_flexicontent" />
</td>
</tr>
<?php endif; ?>
</table>
</fieldset>
<table class="searchintro<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>" cellspacing="1">
<tr>
<td colspan="3" >
<br />
<?php echo JText::_( 'FLEXI_SEARCH_KEYWORD' ) .' <b>'. $this->escape($this->searchword) .'</b>'; ?>
</td>
</tr>
<tr>
<td>
<br />
<?php echo $this->result; ?>
</td>
</tr>
</table>
<br />
<?php if($this->total > 0) : ?>
<div align="center">
<div style="float: right;">
<label for="limit">
<?php echo JText::_( 'Display Num' ); ?>
</label>
<?php echo $this->pagination->getLimitBox( ); ?>
</div>
<div>
<?php //echo $this->pagination->getPagesCounter(); ?>
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
</div>
<?php endif; ?>
<?php if(!$show_searchphrase) {
$default_searchphrase = $this->params->get('default_searchphrase', 'all');
?>
<input type="hidden" name="searchphrase" value="<?php echo $default_searchphrase;?>" />
<?php } ?>
<?php if(!$show_operator) {
$default_operator = $this->params->get('default_operator', 'OR');
?>
<input type="hidden" name="operator" value="<?php echo $default_operator;?>" />
<?php } ?>
<?php if(!$show_searchordering) {
$default_searchordering = $this->params->get('default_searchordering', 'newest');
?>
<input type="hidden" name="ordering" value="<?php echo $default_searchordering;?>" />
<?php } ?>
<input type="hidden" name="option" value="com_flexicontent" />
<input type="hidden" name="task" value="search" />
<input type="hidden" name="Itemid" value="<?php echo JRequest::getVar("Itemid");?>" />
</form>
Code:
<?php
/**
* @version 1.5 stable $Id$
* @package Joomla
* @subpackage FLEXIcontent
* @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
* @license GNU/GPL v2
*
* FLEXIcontent is a derivative work of the excellent QuickFAQ component
* @copyright (C) 2008 Christoph Lukes
* see www.schlu.net for more information
*
* FLEXIcontent is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
/**
* HTML View class for the FLEXIcontent component
*
* @static
* @package Joomla
* @subpackage Weblinks
* @since 1.0
*/
class FLEXIcontentViewSearch extends JView
{
function display($tpl = null)
{
$mainframe = &JFactory::getApplication();
require_once(JPATH_COMPONENT.DS.'helpers'.DS.'search.php' );
// Initialize some variables
$pathway =& $mainframe->getPathway();
$uri =& JFactory::getURI();
$dispatcher = & JDispatcher::getInstance();
$document = & JFactory::getDocument();
$error = '';
$rows = null;
$total = 0;
// Get some data from the model
$areas = &$this->get('areas');
$state = &$this->get('state');
$searchword = $state->get('keyword');
//$params = &$mainframe->getParams();
$params = JComponentHelper::getParams('com_flexicontent');
//$params->bind($params->_raw);
//$typeid_for_advsearch = $params->get('typeid_for_advsearch');
if (!$params->get('disablecss', '')) {
$document->addStyleSheet($this->baseurl.'/components/com_flexicontent/assets/css/flexicontent.css');
$document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
}
$searchkeywordlabel = $params->get('searchkeywordlabel', 'Search Keyword');
//require_once(JPATH_COMPONENT.DS.'classes'.DS.'flexicontent.fields.php');
//JRequest::setVar('typeid', $typeid_for_advsearch, '', 'int');
if(!($itemmodel = $this->getModel('items'))) {
require_once(JPATH_COMPONENT.DS.'models'.DS.'items.php');
$itemmodel = new FlexicontentModelItems();
}
//$item = &$itemmodel->getItem();
$item = new stdClass;
$item->version = 0;
$search_fields = $params->get('search_fields', '');
$search_fields = "'".str_replace(",", "','", $search_fields)."'";
$fields = & $itemmodel->getAdvSearchFields($search_fields);
//Import fields
JPluginHelper::importPlugin('flexicontent_fields');
// Add html to field object trought plugins
//$custom = JRequest::getVar('custom', array());
foreach ($fields as $field) {
$field->parameters->set( 'use_html', 0 );
$field->parameters->set( 'allow_multiple', 0 );
if( ($field->field_type == 'title') || ($field->field_type == 'maintext') || ($field->field_type == 'textarea')) {
$field->field_type = 'text';
}
$label = $field->label;
$fieldsearch = JRequest::getVar($field->name, array());
//$fieldsearch = $mainframe->getUserStateFromRequest( 'flexicontent.serch.'.$field->name, $field->name, array(), 'array' );
$field->value = isset($fieldsearch[0])?$fieldsearch:array();
//$results = $dispatcher->trigger('onAdvSearchDisplayField', array( &$field, &$item ));
$fieldname = $field->iscore ? 'core' : $field->field_type;
FLEXIUtilities::call_FC_Field_Func($fieldname, 'onAdvSearchDisplayField', array( &$field, &$item ));
$field->label = $label;
}
//FlexicontentFields::getItemFields();
$menus = &JSite::getMenu();
$menu = $menus->getActive();
// because the application sets a default page title, we need to get it
// right from the menu item itself
if (is_object( $menu )) {
$menu_params = new JParameter( $menu->params );
if (!$menu_params->get( 'page_title')) {
$params->set('page_title', JText::_( 'FLEXI_SEARCH' ));
}
} else {
$params->set('page_title', JText::_( 'FLEXI_SEARCH' ));
}
$document = &JFactory::getDocument();
$document->setTitle( $params->get( 'page_title' ) );
// Get the parameters of the active menu item
$params = &$mainframe->getParams();
$lists = array();
$fieldtypes_a = $params->get('fieldtypes', array());
if((count($fieldtypes_a)>0) && !is_array($fieldtypes_a)) $fieldtypes_a = array($fieldtypes_a);
if($params->get('cantypes', 1) && (count($fieldtypes_a)>0)) {
$db =& JFactory::getDBO();
$fieldtypes = "'".implode("','", $fieldtypes_a)."'";
$query = 'SELECT id AS value, name AS text'
. ' FROM #__flexicontent_types'
. ' WHERE published = 1 AND id IN ('.$fieldtypes.')'
. ' ORDER BY name ASC, id ASC'
;
$db->setQuery($query);
$types = $db->loadObjectList();
$lists['fieldtypes'] = JHTML::_('select.genericlist', $types, 'fieldtypes[]', 'multiple="true" size="5" style="min-width:186px;" ', 'value', 'text', $fieldtypes_a, 'fieldtypes');
}
if($show_searchordering = $params->get('show_searchordering', 1)) {
$default_searchordering = $params->get('default_searchordering', 'newest');
// built select lists
$orders = array();
$orders[] = JHTML::_('select.option', 'newest', JText::_( 'FLEXI_ADV_NEWEST_FIRST' ) );
$orders[] = JHTML::_('select.option', 'oldest', JText::_( 'FLEXI_ADV_OLDEST_FIRST' ) );
$orders[] = JHTML::_('select.option', 'popular', JText::_( 'FLEXI_ADV_MOST_POP' ) );
$orders[] = JHTML::_('select.option', 'alpha', JText::_( 'FLEXI_ADV_ALPHA' ) );
$orders[] = JHTML::_('select.option', 'category', JText::_( 'FLEXI_ADV_SEARCH_SEC_CAT' ) );
$lists['ordering'] = JHTML::_('select.genericlist', $orders, 'ordering', 'class="inputbox"', 'value', 'text', $state->get('ordering', $default_searchordering) );
}
if($show_searchphrase = $params->get('show_searchphrase', 1)) {
$default_searchphrase = $params->get('default_searchphrase', 'all');
$searchphrases = array();
$searchphrases[] = JHTML::_('select.option', 'all', JText::_( 'FLEXI_ALL_WORDS' ) );
$searchphrases[] = JHTML::_('select.option', 'any', JText::_( 'FLEXI_ANY_WORDS' ) );
$searchphrases[] = JHTML::_('select.option', 'exact', JText::_( 'FLEXI_EXACT_SENTENCE' ) );
$lists['searchphrase' ]= JHTML::_('select.radiolist', $searchphrases, 'searchphrase', '', 'value', 'text', $state->get('match', $default_searchphrase) );
}
if($show_operator = $params->get('show_operator', 1)) {
$default_operator = $params->get('default_operator', 'OR');
$operator = JRequest::getVar('operator', $default_operator);
$operators = array();
$operators[] = JHTML::_('select.option', 'OR', JText::_( 'FLEXI_SEARCH_COMBINATION_OR' ) );
$operators[] = JHTML::_('select.option', 'AND', JText::_( 'FLEXI_SEARCH_COMBINATION_AND' ) );
$lists['operator']= JHTML::_('select.radiolist', $operators, 'operator', '', 'value', 'text', $operator );
}
// log the search
FLEXIadvsearchHelper::logSearch( $searchword);
//limit searchword
$min = $params->get('minchars', 3);
$max = $params->get('maxchars', 20);
if(FLEXIadvsearchHelper::limitSearchWord($searchword, $min, $max)) {
$error = JText::sprintf( 'FLEXI_SEARCH_MESSAGE', $min, $max );
}
//sanatise searchword
if(FLEXIadvsearchHelper::santiseSearchWord($searchword, $state->get('match'), $min)) {
$error = JText::_( 'IGNOREKEYWORD' );
}
if (!$searchword && count( JRequest::get('post') ) ) {
//$error = JText::_( 'Enter a search keyword' );
}
// put the filtered results back into the model
// for next release, the checks should be done in the model perhaps...
$state->set('keyword', $searchword);
if(!$error)
{
$results = &$this->get('data' );
$total = &$this->get('total');
$pagination = &$this->get('pagination');
//require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'helpers'.DS.'route.php');
for ($i=0; $i < count($results); $i++) {
$row = &$results[$i]->text;
if($searchword) {
if ($state->get('match') == 'exact') {
$searchwords = array($searchword);
$needle = $searchword;
}else{
$searchwords = preg_split("/\s+/u", $searchword);
$needle = $searchwords[0];
}
$row = FLEXIadvsearchHelper::prepareSearchContent( $row, 200, $needle );
$searchwords = array_unique( $searchwords );
$searchRegex = '#(';
$x = 0;
foreach ($searchwords as $k => $hlword) {
$searchRegex .= ($x == 0 ? '' : '|');
$searchRegex .= preg_quote($hlword, '#');
$x++;
}
$searchRegex .= ')#iu';
$row = preg_replace($searchRegex, '<span class="highlight">\0</span>', $row );
}
$results[$i]->text = str_replace('[span=highlight]', '<span class="highlight">', $results[$i]->text);
$results[$i]->text = str_replace('[/span]', '</span>', $results[$i]->text);
$results[$i]->text = str_replace('[br /]', '<br />', $results[$i]->text);
$result =& $results[$i];
if ($result->created) {
$created = JHTML::Date( $result->created );
}else {
$created = '';
}
$result->created = $created;
$result->count = $i + 1;
}
}
$this->result = JText::sprintf( 'FLEXI_TOTALRESULTSFOUND', $total );
$this->assignRef('pagination', $pagination);
$this->assignRef('fields', $fields);
$this->assignRef('results', $results);
$this->assignRef('lists', $lists);
$this->assignRef('params', $params);
$this->assign('ordering', $state->get('ordering'));
$this->assign('searchword', $searchword);
$this->assign('searchphrase', $state->get('match'));
$this->assign('searchareas', $areas);
$this->assign('total', $total);
$this->assign('error', $error);
$this->assign('action', $uri->toString());
$this->assign('searchkeywordlabel', $searchkeywordlabel);
$this->assignRef('fieldtypes', $fieldtypes_a);
$this->assignRef('document', $document);
parent::display($tpl);
}
}
Have a nice day.
Regards.