Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Search - move Filters - v2 to correct merge conflict #8140

Closed
wants to merge 11 commits into from
40 changes: 40 additions & 0 deletions administrator/components/com_finder/models/fields/branches.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_BASE') or die();

JFormHelper::loadFieldClass('list');

/**
* Search Filter field for the Finder package.
*
* @since 3.5
*/
class JFormFieldBranches extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
protected $type = 'Branches';

/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.5
*/
public function getOptions()
{
return JHtml::_('finder.mapslist');
}
}
4 changes: 2 additions & 2 deletions administrator/components/com_finder/models/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function getListQuery()
if ($this->getState('filter.search'))
{
$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($this->getState('filter.search')), true) . '%'));
$query->where('( a.title LIKE \'%' . $search . '%\' )');
$query->where('( a.title LIKE ' . $search . ' )');
}

// If the model is set to check item state, add to the query.
Expand All @@ -79,7 +79,7 @@ protected function getListQuery()
}

// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering') . ' ' . $db->escape($this->getState('list.direction'))));
$query->order($db->escape($this->getState('list.ordering', 'a.title') . ' ' . $db->escape($this->getState('list.direction'))));

return $query;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
label="COM_FINDER_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="status"
filter="*,0,1"
label="COM_FINDER_FILTER_PUBLISHED"
description="COM_FINDER_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
</fields>
<fields name="list">
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
label="COM_FINDER_LIST_LIMIT"
description="COM_FINDER_LIST_LIMIT_DESC"
onchange="this.form.submit();"
/>
</fields>
</form>
43 changes: 43 additions & 0 deletions administrator/components/com_finder/models/forms/filter_index.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
label="COM_FINDER_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="status"
filter="*,0,1"
label="COM_FINDER_FILTER_PUBLISHED"
description="COM_FINDER_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="type"
type="sql"
default="0"
query="SELECT id AS value, title AS type FROM #__finder_types ORDER BY title"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
onchange="this.form.submit();"
>
<option value="">COM_FINDER_MAPS_SELECT_TYPE</option>
</field>
</fields>
<fields name="list">
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
label="COM_FINDER_LIST_LIMIT"
description="COM_FINDER_LIST_LIMIT_DESC"
onchange="this.form.submit();"
/>
</fields>
</form>
44 changes: 44 additions & 0 deletions administrator/components/com_finder/models/forms/filter_maps.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_templates/models/fields" />

<fields name="filter">
<field
name="search"
type="text"
label="COM_FINDER_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="status"
filter="*,0,1"
label="COM_FINDER_FILTER_PUBLISHED"
description="COM_FINDER_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>

<field
name="branch"
type="branches"
default="0"
onchange="this.form.submit();"
>
<option value="">COM_FINDER_MAPS_SELECT_BRANCHE</option>
</field>

</fields>
<fields name="list">
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
label="COM_FINDER_LIST_LIMIT"
description="COM_FINDER_LIST_LIMIT_DESC"
onchange="this.form.submit();"
/>
</fields>
</form>
3 changes: 2 additions & 1 deletion administrator/components/com_finder/models/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public function __construct($config = array())
'title', 'l.title',
'type_id', 'l.type_id',
'url', 'l.url',
'indexdate', 'l.indexdate'
'indexdate', 'l.indexdate',
'type'
);
}

Expand Down
5 changes: 3 additions & 2 deletions administrator/components/com_finder/models/maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function __construct($config = array())
{
$config['filter_fields'] = array(
'state', 'a.state',
'title', 'a.title'
'title', 'a.title',
'branch'
);
}

Expand Down Expand Up @@ -263,7 +264,7 @@ protected function populateState($ordering = null, $direction = null)
$state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $state);

$branch = $this->getUserStateFromRequest($this->context . '.filter.branch', 'filter_branch', '1', 'string');
$branch = $this->getUserStateFromRequest($this->context . '.filter.branch', 'filter_branch', '', 'string');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have to put back the default value here?

$this->setState('filter.branch', $branch);

// Load the parameters.
Expand Down
21 changes: 7 additions & 14 deletions administrator/components/com_finder/views/filters/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,17 @@
?>

<form action="<?php echo JRoute::_('index.php?option=com_finder&view=filters');?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_FINDER_FILTER_SEARCH_DESCRIPTION'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><span class="icon-search"></span></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.getElementById('filter_search').value='';this.form.submit();"><span class="icon-remove"></span></button>
</div>
</div>
<div class="clearfix"> </div>
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<?php
// Search tools bar
echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<table class="table table-striped">
<thead>
<tr>
Expand Down
10 changes: 2 additions & 8 deletions administrator/components/com_finder/views/filters/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public function display($tpl = null)
$this->pagination = $this->get('Pagination');
$this->total = $this->get('Total');
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');

FinderHelper::addSubmenu('filters');

Expand Down Expand Up @@ -94,13 +96,5 @@ protected function addToolbar()
JToolbarHelper::deleteList('', 'filters.delete');
JToolbarHelper::divider();
}

JHtmlSidebar::setAction('index.php?option=com_finder&view=filters');

JHtmlSidebar::addFilter(
JText::_('COM_FINDER_INDEX_FILTER_BY_STATE'),
'filter_state',
JHtml::_('select.options', JHtml::_('finder.statelist'), 'value', 'text', $this->state->get('filter.state'))
);
}
}
15 changes: 1 addition & 14 deletions administrator/components/com_finder/views/index/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,7 @@
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_FINDER_FILTER_SEARCH_DESCRIPTION'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><span class="icon-search"></span></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.getElementById('filter_search').value='';this.form.submit();"><span class="icon-remove"></span></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
</div>
<div class="clearfix"> </div>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php if (!$this->pluginState['plg_content_finder']->enabled) : ?>
<div class="alert fade in">
<button class="close" data-dismiss="alert">×</button>
Expand Down
24 changes: 6 additions & 18 deletions administrator/components/com_finder/views/index/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ public function display($tpl = null)
// Load plug-in language files.
FinderHelperLanguage::loadPluginLanguage();

$this->items = $this->get('Items');
$this->total = $this->get('Total');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->total = $this->get('Total');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->pluginState = $this->get('pluginState');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');

FinderHelper::addSubmenu('index');

Expand Down Expand Up @@ -99,19 +101,5 @@ protected function addToolbar()
}

JToolbarHelper::help('JHELP_COMPONENTS_FINDER_MANAGE_INDEXED_CONTENT');

JHtmlSidebar::setAction('index.php?option=com_finder&view=index');

JHtmlSidebar::addFilter(
JText::_('COM_FINDER_INDEX_FILTER_BY_STATE'),
'filter_state',
JHtml::_('select.options', JHtml::_('finder.statelist'), 'value', 'text', $this->state->get('filter.state'))
);

JHtmlSidebar::addFilter(
JText::_('COM_FINDER_INDEX_TYPE_FILTER'),
'filter_type',
JHtml::_('select.options', JHtml::_('finder.typeslist'), 'value', 'text', $this->state->get('filter.type'))
);
}
}
11 changes: 1 addition & 10 deletions administrator/components/com_finder/views/maps/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,7 @@
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_FINDER_FILTER_SEARCH_DESCRIPTION'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><span class="icon-search"></span></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.getElementById('filter_search').value='';this.form.submit();"><span class="icon-remove"></span></button>
</div>
</div>
<div class="clearfix"> </div>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<table class="table table-striped">
<thead>
<tr>
Expand Down
23 changes: 5 additions & 18 deletions administrator/components/com_finder/views/maps/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public function display($tpl = null)
FinderHelperLanguage::loadPluginLanguage();

// Load the view data.
$this->items = $this->get('Items');
$this->total = $this->get('Total');
$this->items = $this->get('Items');
$this->total = $this->get('Total');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');

FinderHelper::addSubmenu('maps');

Expand Down Expand Up @@ -92,20 +94,5 @@ protected function addToolbar()
JToolbarHelper::deleteList('', 'maps.delete');
JToolbarHelper::divider();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pe7er In your old PR this line is still there, should it remain or be removed?


JHtmlSidebar::setAction('index.php?option=com_finder&view=maps');

JHtmlSidebar::addFilter(
'',
'filter_branch',
JHtml::_('select.options', JHtml::_('finder.mapslist'), 'value', 'text', $this->state->get('filter.branch')),
true
);

JHtmlSidebar::addFilter(
JText::_('COM_FINDER_INDEX_FILTER_BY_STATE'),
'filter_state',
JHtml::_('select.options', JHtml::_('finder.statelist'), 'value', 'text', $this->state->get('filter.state'))
);
}
}
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.com_finder.ini
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ COM_FINDER_MAPS_CONFIRM_DELETE_PROMPT="Are you sure you want to delete the selec
COM_FINDER_MAPS_MULTILANG="Note: Language filter system plugin has been enabled, so this branch will not be used."
COM_FINDER_MAPS_NO_CONTENT="No results to display. Either no content has been indexed or no content meets your filter criteria."
COM_FINDER_MAPS_RETURN_TO_BRANCHES="Return to Branches"
COM_FINDER_MAPS_SELECT_BRANCHE="- Select Branch -"
COM_FINDER_MAPS_SELECT_TYPE="- Select Type of Content -"
COM_FINDER_MAPS_TOOLBAR_TITLE="Smart Search: Content Maps"
COM_FINDER_MESSAGE_RETURNED="The following message was returned by the server:"
COM_FINDER_N_ITEMS_CHECKED_IN_0="No item successfully checked in."
Expand Down