Skip to content

Loading…

Code style #3667

Closed
wants to merge 1 commit into from

1 participant

@wilsonge
Joomla! member

No description provided.

@phproberto phproberto added a commit that closed this pull request
@wilsonge wilsonge [imp] Code style fixes. Fixes #3664. Fixes #3665. Fixes #3666. Fixes #…
…3667. Fixes #3668. Fixes #3670

The last administrator/modules code style issue :D

Code Style

Code Style

Code style

Code Style

Code Style
ce339f1
@wilsonge wilsonge deleted the wilsonge:patch-29 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 28, 2014
  1. @wilsonge

    Code style

    wilsonge committed
This page is out of date. Refresh to see the latest.
Showing with 28 additions and 14 deletions.
  1. +28 −14 administrator/components/com_modules/models/positions.php
View
42 administrator/components/com_modules/models/positions.php
@@ -22,6 +22,7 @@ class ModulesModelPositions extends JModelList
* Constructor.
*
* @param array An optional associative array of configuration settings.
+ *
* @see JController
* @since 1.6
*/
@@ -50,19 +51,19 @@ protected function populateState($ordering = null, $direction = null)
$app = JFactory::getApplication('administrator');
// Load the filter state.
- $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
+ $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
- $state = $this->getUserStateFromRequest($this->context.'.filter.state', 'filter_state', '', 'string');
+ $state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $state);
$clientId = $app->input->getInt('client_id', 0);
$this->setState('filter.client_id', $clientId);
- $template = $this->getUserStateFromRequest($this->context.'.filter.template', 'filter_template', '', 'string');
+ $template = $this->getUserStateFromRequest($this->context . '.filter.template', 'filter_template', '', 'string');
$this->setState('filter.template', $template);
- $type = $this->getUserStateFromRequest($this->context.'.filter.type', 'filter_type', '', 'string');
+ $type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string');
$this->setState('filter.type', $type);
// Load the parameters.
@@ -77,6 +78,7 @@ protected function populateState($ordering = null, $direction = null)
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
+ *
* @since 1.6
*/
public function getItems()
@@ -101,10 +103,10 @@ public function getItems()
$query = $this->_db->getQuery(true)
->select('DISTINCT(position) as value')
->from('#__modules')
- ->where($this->_db->quoteName('client_id').' = '.(int) $clientId);
+ ->where($this->_db->quoteName('client_id') . ' = ' . (int) $clientId);
if ($search)
{
- $query->where('position LIKE '.$this->_db->quote('%'.$this->_db->escape($search, true).'%'));
+ $query->where('position LIKE ' . $this->_db->quote('%' . $this->_db->escape($search, true) . '%'));
}
$this->_db->setQuery($query);
@@ -116,8 +118,10 @@ public function getItems()
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
+
return false;
}
+
foreach ($positions as $value => $position)
{
$positions[$value] = array();
@@ -131,24 +135,26 @@ public function getItems()
// Load the positions from the installed templates.
foreach (ModulesHelper::getTemplates($clientId) as $template)
{
- $path = JPath::clean($client->path.'/templates/'.$template->element.'/templateDetails.xml');
+ $path = JPath::clean($client->path . '/templates/' . $template->element . '/templateDetails.xml');
if (file_exists($path))
{
$xml = simplexml_load_file($path);
if (isset($xml->positions[0]))
{
- $lang->load('tpl_'.$template->element.'.sys', $client->path, null, false, true)
- || $lang->load('tpl_'.$template->element.'.sys', $client->path.'/templates/'.$template->element, null, false, true);
+ $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, true)
+ || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, true);
foreach ($xml->positions[0] as $position)
{
$value = (string) $position['value'];
$label = (string) $position;
+
if (!$value)
{
$value = $label;
- $label = preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'TPL_'.$template->element.'_POSITION_'.$value);
- $altlabel = preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'COM_MODULES_POSITION_'.$value);
+ $label = preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'TPL_' . $template->element . '_POSITION_' . $value);
+ $altlabel = preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'COM_MODULES_POSITION_' . $value);
+
if (!$lang->hasKey($label) && $lang->hasKey($altlabel))
{
$label = $altlabel;
@@ -171,32 +177,38 @@ public function getItems()
}
}
$this->total = count($positions);
+
if ($limitstart >= $this->total)
{
$limitstart = $limitstart < $limit ? 0 : $limitstart - $limit;
$this->setState('list.start', $limitstart);
}
+
if ($ordering == 'value')
{
if ($direction == 'asc')
{
ksort($positions);
}
- else {
+ else
+ {
krsort($positions);
}
}
- else {
+ else
+ {
if ($direction == 'asc')
{
asort($positions);
}
- else {
+ else
+ {
arsort($positions);
}
}
$this->items = array_slice($positions, $limitstart, $limit ? $limit : null);
}
+
return $this->items;
}
@@ -204,6 +216,7 @@ public function getItems()
* Method to get the total number of items.
*
* @return int The total number of items.
+ *
* @since 1.6
*/
public function getTotal()
@@ -212,6 +225,7 @@ public function getTotal()
{
$this->getItems();
}
+
return $this->total;
}
}
Something went wrong with that request. Please try again.