Skip to content

Commit

Permalink
[Code Style] administrator/components/com_finder
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdavenport committed Oct 12, 2014
1 parent e98d26f commit 3e7c31b
Show file tree
Hide file tree
Showing 23 changed files with 89 additions and 15 deletions.
Expand Up @@ -32,6 +32,7 @@ class FinderControllerFilters extends JControllerAdmin
public function getModel($name = 'Filter', $prefix = 'FinderModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);

return $model;
}
}
3 changes: 3 additions & 0 deletions administrator/components/com_finder/controllers/index.php
Expand Up @@ -32,6 +32,7 @@ class FinderControllerIndex extends JControllerAdmin
public function getModel($name = 'Index', $prefix = 'FinderModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);

return $model;
}

Expand All @@ -58,12 +59,14 @@ public function purge()
{
$message = JText::_('COM_FINDER_INDEX_PURGE_FAILED', $model->getError());
$this->setRedirect('index.php?option=com_finder&view=index', $message);

return false;
}
else
{
$message = JText::_('COM_FINDER_INDEX_PURGE_SUCCESS');
$this->setRedirect('index.php?option=com_finder&view=index', $message);

return true;
}
}
Expand Down
Expand Up @@ -145,7 +145,7 @@ public function batch()
* in order to work around some plugins that don't do proper environment
* checks before trying to use HTML document functions.
*/
$raw = clone(JFactory::getDocument());
$raw = clone JFactory::getDocument();
$lang = JFactory::getLanguage();

// Get the document properties.
Expand All @@ -165,7 +165,7 @@ public function batch()
$doc = $html;

// Get the admin application.
$admin = clone(JFactory::getApplication());
$admin = clone JFactory::getApplication();

// Get the site app.
$site = JApplication::getInstance('site');
Expand Down
1 change: 1 addition & 0 deletions administrator/components/com_finder/controllers/maps.php
Expand Up @@ -32,6 +32,7 @@ class FinderControllerMaps extends JControllerAdmin
public function getModel($name = 'Maps', $prefix = 'FinderModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);

return $model;
}
}
13 changes: 6 additions & 7 deletions administrator/components/com_finder/helpers/indexer/adapter.php
Expand Up @@ -167,7 +167,6 @@ public function __construct(&$subject, $config)
*/
public function onStartIndex()
{

// Get the indexer state.
$iState = FinderIndexer::getState();

Expand Down Expand Up @@ -392,7 +391,7 @@ abstract protected function setup();
*/
protected function categoryAccessChange($row)
{
$query = clone($this->getStateQuery());
$query = clone $this->getStateQuery();
$query->where('c.id = ' . (int) $row->id);

// Get the access level.
Expand Down Expand Up @@ -432,7 +431,7 @@ protected function categoryStateChange($pks, $value)
*/
foreach ($pks as $pk)
{
$query = clone($this->getStateQuery());
$query = clone $this->getStateQuery();
$query->where('c.id = ' . (int) $pk);

// Get the published states.
Expand Down Expand Up @@ -520,7 +519,7 @@ protected function getContentCount()
// Tweak the SQL query to make the total lookup faster.
if ($query instanceof JDatabaseQuery)
{
$query = clone($query);
$query = clone $query;
$query->clear('select')
->select('COUNT(*)')
->clear('order');
Expand Down Expand Up @@ -812,7 +811,7 @@ protected function getItemMenuTitle($url)
*/
protected function itemAccessChange($row)
{
$query = clone($this->getStateQuery());
$query = clone $this->getStateQuery();
$query->where('a.id = ' . (int) $row->id);

// Get the access level.
Expand Down Expand Up @@ -845,7 +844,7 @@ protected function itemStateChange($pks, $value)
*/
foreach ($pks as $pk)
{
$query = clone($this->getStateQuery());
$query = clone $this->getStateQuery();
$query->where('a.id = ' . (int) $pk);

// Get the published states.
Expand Down Expand Up @@ -881,7 +880,7 @@ protected function pluginDisable($pks)
if ($this->getPluginType($pk) == strtolower($this->context))
{
// Get all of the items to unindex them
$query = clone($this->getStateQuery());
$query = clone $this->getStateQuery();
$this->db->setQuery($query);
$items = $this->db->loadColumn();

Expand Down
Expand Up @@ -605,6 +605,7 @@ protected function addTokensToDB($tokens, $context = '')
);
$values++;
}

$db->setQuery($query);
$db->execute();

Expand Down
Expand Up @@ -328,6 +328,7 @@ public function index($item, $format = 'html')
' FROM ' . $db->quoteName('#__finder_tokens_aggregate') . ' AS ta' .
' WHERE ta.term_id = 0'
);

if ($db->loadRow() == null)
{
$db->setQuery(
Expand Down Expand Up @@ -610,6 +611,7 @@ protected function addTokensToDB($tokens, $context = '')
);
$values++;
}

$db->setQuery($query);
$db->execute();

Expand Down
Expand Up @@ -121,6 +121,7 @@ public static function tokenize($input, $lang, $phrase = false)
for ($j = 0; $j < $charCount; $j++)
{
$tSplit = JString::str_ireplace($charMatches[0][$j], '', $terms[$i], false);

if (!empty($tSplit))
{
$terms[$i] = $tSplit;
Expand Down Expand Up @@ -190,6 +191,7 @@ public static function tokenize($input, $lang, $phrase = false)
if ($store)
{
$cache[$store] = count($tokens) > 1 ? $tokens : array_shift($tokens);

return $cache[$store];
}
else
Expand Down
Expand Up @@ -111,6 +111,7 @@ public static function getInstance()
{
$format = 'sqlsrv';
}

$path = __DIR__ . '/driver/' . $format . '.php';
$class = 'FinderIndexerDriver' . ucfirst($format);

Expand All @@ -119,6 +120,7 @@ public static function getInstance()
{
// Instantiate the parser.
include_once $path;

return new $class;
}
else
Expand Down
12 changes: 9 additions & 3 deletions administrator/components/com_finder/helpers/indexer/query.php
Expand Up @@ -190,14 +190,17 @@ public function __construct($options)
{
$this->dates->set('date1', $options['date1']);
}

if (isset($options['date2']) && !empty($options['date1']))
{
$this->dates->set('date2', $options['date2']);
}

if (isset($options['when1']) && !empty($options['date1']))
{
$this->dates->set('when1', $options['when1']);
}

if (isset($options['when2']) && !empty($options['date1']))
{
$this->dates->set('when2', $options['when2']);
Expand Down Expand Up @@ -300,6 +303,7 @@ public function toURI($base = null)
{
continue;
}

$uri->setVar('t[]', $node);
}
}
Expand Down Expand Up @@ -1023,6 +1027,7 @@ protected function processString($input, $lang, $mode)
{
unset($phrases[$pk]);
}

if (($pk = array_search($terms[$i + 2], $phrases)) !== false)
{
unset($phrases[$pk]);
Expand Down Expand Up @@ -1084,6 +1089,7 @@ protected function processString($input, $lang, $mode)
{
unset($phrases[$pk]);
}

if (($pk = array_search($terms[$i + 2], $phrases)) !== false)
{
unset($phrases[$pk]);
Expand Down Expand Up @@ -1134,7 +1140,7 @@ protected function processString($input, $lang, $mode)
unset($terms[$i + 1]);

// Adjust the loop.
$i += 1;
$i++;
continue;
}
// Handle the NOT operator.
Expand Down Expand Up @@ -1171,7 +1177,7 @@ protected function processString($input, $lang, $mode)
unset($terms[$i + 1]);

// Adjust the loop.
$i += 1;
$i++;
continue;
}
}
Expand Down Expand Up @@ -1286,7 +1292,7 @@ protected function getTokenData($token)
->where('t.phrase = 0');

// Clone the query, replace the WHERE clause.
$sub = clone($query);
$sub = clone $query;
$sub->clear('where');
$sub->where('t.stem = ' . $db->quote($token->stem));
$sub->where('t.phrase = 0');
Expand Down
Expand Up @@ -85,13 +85,15 @@ protected static function getStemRules()
$vars = array();

// French accented letters in ISO-8859-1 encoding
$vars['accents'] = chr(224) . chr(226) . chr(232) . chr(233) . chr(234) . chr(235) . chr(238) . chr(239) . chr(244) . chr(251) . chr(249) . chr(231);
$vars['accents'] = chr(224) . chr(226) . chr(232) . chr(233) . chr(234) . chr(235) . chr(238) . chr(239)
. chr(244) . chr(251) . chr(249) . chr(231);

// The rule patterns include all accented words for french language
$vars['rule_pattern'] = "/^([a-z" . $vars['accents'] . "]*)(\*){0,1}(\d)([a-z" . $vars['accents'] . "]*)([.|>])/";

// French vowels (including y) in ISO-8859-1 encoding
$vars['vowels'] = chr(97) . chr(224) . chr(226) . chr(101) . chr(232) . chr(233) . chr(234) . chr(235) . chr(105) . chr(238) . chr(239) . chr(111) . chr(244) . chr(117) . chr(251) . chr(249) . chr(121);
$vars['vowels'] = chr(97) . chr(224) . chr(226) . chr(101) . chr(232) . chr(233) . chr(234) . chr(235)
. chr(105) . chr(238) . chr(239) . chr(111) . chr(244) . chr(117) . chr(251) . chr(249) . chr(121);

// The French rules in ISO-8859-1 encoding
$vars['rules'] = array(
Expand Down Expand Up @@ -230,6 +232,7 @@ private static function _getStem($input)
// No other rule can be applied => the stem has been found
break;
}

$rule = $vars['rules'][$rule_number];
preg_match($vars['rule_pattern'], $rule, $matches);

Expand Down
Expand Up @@ -81,6 +81,7 @@ public static function addBranch($title, $state = 1, $access = 1)
* out which case is true and deal with it.
*/
$branch = new JObject;

if (empty($result))
{
// Prepare the branch object.
Expand Down Expand Up @@ -160,6 +161,7 @@ public static function addNode($branch, $title, $state = 1, $access = 1)
* out which case is true and deal with it.
*/
$node = new JObject;

if (empty($result))
{
// Prepare the node object.
Expand Down
1 change: 1 addition & 0 deletions administrator/components/com_finder/helpers/language.php
Expand Up @@ -86,6 +86,7 @@ public static function loadPluginLanguage()
{
return;
}

$loaded = true;

// Get array of all the enabled Smart Search plug-in names.
Expand Down
2 changes: 2 additions & 0 deletions administrator/components/com_finder/models/filter.php
Expand Up @@ -70,6 +70,7 @@ public function getFilter()
if ($return === false && $filter->getError())
{
$this->setError($filter->getError());

return false;
}

Expand All @@ -87,6 +88,7 @@ public function getFilter()
if ($this->_db->getErrorNum())
{
$this->setError($this->_db->getErrorMsg());

return false;
}

Expand Down
11 changes: 11 additions & 0 deletions administrator/components/com_finder/models/index.php
Expand Up @@ -70,6 +70,7 @@ public function __construct($config = array())
protected function canDelete($record)
{
$user = JFactory::getUser();

return $user->authorise('core.delete', $this->option);
}

Expand All @@ -85,6 +86,7 @@ protected function canDelete($record)
protected function canEditState($record)
{
$user = JFactory::getUser();

return $user->authorise('core.edit.state', $this->option);
}

Expand Down Expand Up @@ -117,15 +119,18 @@ public function delete(&$pks)

// Trigger the onContentBeforeDelete event.
$result = $dispatcher->trigger($this->event_before_delete, array($context, $table));

if (in_array(false, $result, true))
{
$this->setError($table->getError());

return false;
}

if (!$table->delete($pk))
{
$this->setError($table->getError());

return false;
}

Expand All @@ -137,6 +142,7 @@ public function delete(&$pks)
// Prune items that you can't change.
unset($pks[$i]);
$error = $this->getError();

if ($error)
{
$this->setError($error);
Expand All @@ -150,6 +156,7 @@ public function delete(&$pks)
else
{
$this->setError($table->getError());

return false;
}
}
Expand Down Expand Up @@ -198,6 +205,7 @@ protected function getListQuery()
// Handle the list ordering.
$ordering = $this->getState('list.ordering');
$direction = $this->getState('list.direction');

if (!empty($ordering))
{
$query->order($db->escape($ordering) . ' ' . $db->escape($direction));
Expand Down Expand Up @@ -376,6 +384,7 @@ public function publish(&$pks, $value = 1)
// Prune items that you can't change.
unset($pks[$i]);
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));

return false;
}
}
Expand All @@ -385,6 +394,7 @@ public function publish(&$pks, $value = 1)
if (!$table->publish($pks, $value, $user->get('id')))
{
$this->setError($table->getError());

return false;
}

Expand All @@ -396,6 +406,7 @@ public function publish(&$pks, $value = 1)
if (in_array(false, $result, true))
{
$this->setError($table->getError());

return false;
}

Expand Down

0 comments on commit 3e7c31b

Please sign in to comment.