Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[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
  • Loading branch information...
commit ce339f1088025980a4f37a1fca80df60a182a75f 1 parent 824ecf7
@wilsonge wilsonge authored phproberto committed
View
36 administrator/components/com_contact/models/contact.php
@@ -54,6 +54,7 @@ public function batch($commands, $pks, $contexts)
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
+
return false;
}
@@ -300,6 +301,7 @@ protected function batchUser($value, $pks, $contexts)
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
+ *
* @since 1.6
*/
protected function canDelete($record)
@@ -318,9 +320,10 @@ protected function canDelete($record)
/**
* Method to test whether a record can have its state edited.
*
- * @param object $record A record object.
+ * @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
+ *
* @since 1.6
*/
protected function canEditState($record)
@@ -342,11 +345,12 @@ protected function canEditState($record)
/**
* Returns a Table object, always creating it
*
- * @param type $type The table type to instantiate
- * @param string $prefix A prefix for the table class name. Optional.
- * @param array $config Configuration array for model. Optional.
+ * @param type $type The table type to instantiate
+ * @param string $prefix A prefix for the table class name. Optional.
+ * @param array $config Configuration array for model. Optional.
+ *
+ * @return JTable A database object
*
- * @return JTable A database object
* @since 1.6
*/
public function getTable($type = 'Contact', $prefix = 'ContactTable', $config = array())
@@ -357,10 +361,11 @@ public function getTable($type = 'Contact', $prefix = 'ContactTable', $config =
/**
* Method to get the row form.
*
- * @param array $data Data for the form.
- * @param boolean $loadData True if the form is to load its own data (default case), false if not.
+ * @param array $data Data for the form.
+ * @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return mixed A JForm object on success, false on failure
+ *
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
@@ -395,9 +400,10 @@ public function getForm($data = array(), $loadData = true)
/**
* Method to get a single record.
*
- * @param integer $pk The id of the primary key.
+ * @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
+ *
* @since 1.6
*/
public function getItem($pk = null)
@@ -443,6 +449,7 @@ public function getItem($pk = null)
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
+ *
* @since 1.6
*/
protected function loadFormData()
@@ -473,6 +480,7 @@ protected function loadFormData()
* @param array The form data.
*
* @return boolean True on success.
+ *
* @since 3.0
*/
public function save($data)
@@ -575,9 +583,10 @@ public function save($data)
/**
* Prepare and sanitise the table prior to saving.
*
- * @param JTable $table
+ * @param JTable $table The JTable object
*
* @return void
+ *
* @since 1.6
*/
protected function prepareTable($table)
@@ -620,9 +629,10 @@ protected function prepareTable($table)
/**
* A protected method to get a set of ordering conditions.
*
- * @param JTable $table A record object.
+ * @param JTable $table A record object.
*
* @return array An array of conditions to add to add to ordering queries.
+ *
* @since 1.6
*/
protected function getReorderConditions($table)
@@ -679,10 +689,11 @@ protected function preprocessForm(JForm $form, $data, $group = 'content')
/**
* Method to toggle the featured setting of contacts.
*
- * @param array $pks The ids of the items to toggle.
- * @param integer $value The value to toggle to.
+ * @param array $pks The ids of the items to toggle.
+ * @param integer $value The value to toggle to.
*
* @return boolean True on success.
+ *
* @since 1.6
*/
public function featured($pks, $value = 0)
@@ -746,6 +757,7 @@ protected function generateNewTitle($category_id, $alias, $name)
{
$name = JString::increment($name);
}
+
$alias = JString::increment($alias, 'dash');
}
View
26 administrator/components/com_content/models/fields/modal/article.php
@@ -47,18 +47,18 @@ protected function getInput()
$script = array();
// Select button script
- $script[] = ' function jSelectArticle_'.$this->id.'(id, title, catid, object) {';
- $script[] = ' document.getElementById("'.$this->id.'_id").value = id;';
- $script[] = ' document.getElementById("'.$this->id.'_name").value = title;';
+ $script[] = ' function jSelectArticle_' . $this->id . '(id, title, catid, object) {';
+ $script[] = ' document.getElementById("' . $this->id . '_id").value = id;';
+ $script[] = ' document.getElementById("' . $this->id . '_name").value = title;';
if ($allowEdit)
{
- $script[] = ' jQuery("#'.$this->id.'_edit").removeClass("hidden");';
+ $script[] = ' jQuery("#' . $this->id . '_edit").removeClass("hidden");';
}
if ($allowClear)
{
- $script[] = ' jQuery("#'.$this->id.'_clear").removeClass("hidden");';
+ $script[] = ' jQuery("#' . $this->id . '_clear").removeClass("hidden");';
}
$script[] = ' SqueezeBox.close();';
@@ -73,7 +73,7 @@ protected function getInput()
$script[] = ' function jClearArticle(id) {';
$script[] = ' document.getElementById(id + "_id").value = "";';
- $script[] = ' document.getElementById(id + "_name").value = "'.htmlspecialchars(JText::_('COM_CONTENT_SELECT_AN_ARTICLE', true), ENT_COMPAT, 'UTF-8').'";';
+ $script[] = ' document.getElementById(id + "_name").value = "' . htmlspecialchars(JText::_('COM_CONTENT_SELECT_AN_ARTICLE', true), ENT_COMPAT, 'UTF-8') . '";';
$script[] = ' jQuery("#"+id + "_clear").addClass("hidden");';
$script[] = ' if (document.getElementById(id + "_edit")) {';
$script[] = ' jQuery("#"+id + "_edit").addClass("hidden");';
@@ -87,11 +87,11 @@ protected function getInput()
// Setup variables for display.
$html = array();
- $link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&function=jSelectArticle_'.$this->id;
+ $link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&function=jSelectArticle_' . $this->id;
if (isset($this->element['language']))
{
- $link .= '&forcedLanguage='.$this->element['language'];
+ $link .= '&forcedLanguage=' . $this->element['language'];
}
if ((int) $this->value > 0)
@@ -131,19 +131,19 @@ protected function getInput()
// The current article display field.
$html[] = '<span class="input-append">';
- $html[] = '<input type="text" class="input-medium" id="'.$this->id.'_name" value="'.$title.'" disabled="disabled" size="35" />';
- $html[] = '<a class="modal btn hasTooltip" title="'.JHtml::tooltipText('COM_CONTENT_CHANGE_ARTICLE').'" href="'.$link.'&amp;'.JSession::getFormToken().'=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> '.JText::_('JSELECT').'</a>';
+ $html[] = '<input type="text" class="input-medium" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />';
+ $html[] = '<a class="modal btn hasTooltip" title="' . JHtml::tooltipText('COM_CONTENT_CHANGE_ARTICLE') . '" href="' . $link . '&amp;' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> ' . JText::_('JSELECT') . '</a>';
// Edit article button
if ($allowEdit)
{
- $html[] = '<a class="btn hasTooltip'.($value ? '' : ' hidden').'" href="index.php?option=com_content&layout=modal&tmpl=component&task=article.edit&id=' . $value. '" target="_blank" title="'.JHtml::tooltipText('COM_CONTENT_EDIT_ARTICLE').'" ><span class="icon-edit"></span> ' . JText::_('JACTION_EDIT') . '</a>';
+ $html[] = '<a class="btn hasTooltip' . ($value ? '' : ' hidden') . '" href="index.php?option=com_content&layout=modal&tmpl=component&task=article.edit&id=' . $value . '" target="_blank" title="' . JHtml::tooltipText('COM_CONTENT_EDIT_ARTICLE') . '" ><span class="icon-edit"></span> ' . JText::_('JACTION_EDIT') . '</a>';
}
// Clear article button
if ($allowClear)
{
- $html[] = '<button id="'.$this->id.'_clear" class="btn'.($value ? '' : ' hidden').'" onclick="return jClearArticle(\''.$this->id.'\')"><span class="icon-remove"></span> ' . JText::_('JCLEAR') . '</button>';
+ $html[] = '<button id="' . $this->id . '_clear" class="btn' . ($value ? '' : ' hidden') . '" onclick="return jClearArticle(\'' . $this->id . '\')"><span class="icon-remove"></span> ' . JText::_('JCLEAR') . '</button>';
}
$html[] = '</span>';
@@ -155,7 +155,7 @@ protected function getInput()
$class = ' class="required modal-value"';
}
- $html[] = '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
+ $html[] = '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />';
return implode("\n", $html);
}
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;
}
}
View
2  administrator/modules/mod_feed/tmpl/default.php
@@ -57,7 +57,7 @@
?>
<div style="direction: <?php echo $rssrtl ? 'rtl' :'ltr'; ?>; text-align: <?php echo $rssrtl ? 'right' :'left'; ?> ! important" class="feed<?php echo $moduleclass_sfx; ?>">
<?php
- // feed description
+ // Feed description
if (!is_null($feed->title) && $params->get('rsstitle', 1))
{
?>
View
5 components/com_tags/views/tags/tmpl/default_items.php
@@ -9,7 +9,7 @@
defined('_JEXEC') or die;
-JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
+JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
JHtml::_('behavior.framework');
JHtml::_('formbehavior.chosen', 'select');
@@ -23,12 +23,15 @@
$canEditState = $user->authorise('core.edit.state', 'com_tags');
$columns = $this->params->get('tag_columns', 1);
+
// Avoid division by 0 and negative columns.
if ($columns < 1)
{
$columns = 1;
}
+
$bsspans = floor(12 / $columns);
+
if ($bsspans < 1)
{
$bsspans = 1;
View
34 components/com_users/models/reset.php
@@ -30,6 +30,7 @@ public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.reset_request', 'reset_request', array('control' => 'jform', 'load_data' => $loadData));
+
if (empty($form))
{
return false;
@@ -50,6 +51,7 @@ public function getResetCompleteForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.reset_complete', 'reset_complete', $options = array('control' => 'jform'));
+
if (empty($form))
{
return false;
@@ -70,6 +72,7 @@ public function getResetConfirmForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.reset_confirm', 'reset_confirm', $options = array('control' => 'jform'));
+
if (empty($form))
{
return false;
@@ -110,7 +113,7 @@ protected function populateState()
/**
* @since 1.6
*/
- function processResetComplete($data)
+ public function processResetComplete($data)
{
// Get the form.
$form = $this->getResetCompleteForm();
@@ -140,6 +143,7 @@ function processResetComplete($data)
{
$this->setError($formError->getMessage());
}
+
return false;
}
@@ -161,6 +165,7 @@ function processResetComplete($data)
if (empty($user) || $user->activation !== $token)
{
$this->setError(JText::_('COM_USERS_USER_NOT_FOUND'));
+
return false;
}
@@ -168,6 +173,7 @@ function processResetComplete($data)
if ($user->block)
{
$this->setError(JText::_('COM_USERS_USER_BLOCKED'));
+
return false;
}
@@ -175,6 +181,7 @@ function processResetComplete($data)
if ($user->requireReset == 1 && JUserHelper::verifyPassword($data['password1'], $user->password))
{
$this->setError(JText::_('JLIB_USER_ERROR_CANNOT_REUSE_PASSWORD'));
+
return false;
}
@@ -199,7 +206,7 @@ function processResetComplete($data)
/**
* @since 1.6
*/
- function processResetConfirm($data)
+ public function processResetConfirm($data)
{
// Get the form.
$form = $this->getResetConfirmForm();
@@ -229,6 +236,7 @@ function processResetConfirm($data)
{
$this->setError($formError->getMessage());
}
+
return false;
}
@@ -257,16 +265,19 @@ function processResetConfirm($data)
if (empty($user))
{
$this->setError(JText::_('COM_USERS_USER_NOT_FOUND'));
+
return false;
}
$parts = explode(':', $user->activation);
$crypt = $parts[0];
+
if (!isset($parts[1]))
{
$this->setError(JText::_('COM_USERS_USER_NOT_FOUND'));
return false;
}
+
$salt = $parts[1];
$testcrypt = JUserHelper::getCryptedPassword($data['token'], $salt, 'md5-hex');
@@ -274,6 +285,7 @@ function processResetConfirm($data)
if (!($crypt == $testcrypt))
{
$this->setError(JText::_('COM_USERS_USER_NOT_FOUND'));
+
return false;
}
@@ -281,6 +293,7 @@ function processResetConfirm($data)
if ($user->block)
{
$this->setError(JText::_('COM_USERS_USER_BLOCKED'));
+
return false;
}
@@ -330,6 +343,7 @@ public function processResetRequest($data)
{
$this->setError($formError->getMessage());
}
+
return false;
}
@@ -350,6 +364,7 @@ public function processResetRequest($data)
catch (RuntimeException $e)
{
$this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
+
return false;
}
@@ -357,6 +372,7 @@ public function processResetRequest($data)
if (empty($userId))
{
$this->setError(JText::_('COM_USERS_INVALID_EMAIL'));
+
return false;
}
@@ -367,6 +383,7 @@ public function processResetRequest($data)
if ($user->block)
{
$this->setError(JText::_('COM_USERS_USER_BLOCKED'));
+
return false;
}
@@ -374,6 +391,7 @@ public function processResetRequest($data)
if ($user->authorise('core.admin'))
{
$this->setError(JText::_('COM_USERS_REMIND_SUPERADMIN_ERROR'));
+
return false;
}
@@ -382,13 +400,14 @@ public function processResetRequest($data)
{
$resetLimit = (int) JFactory::getApplication()->getParams()->get('reset_time');
$this->setError(JText::plural('COM_USERS_REMIND_LIMIT_ERROR_N_HOURS', $resetLimit));
+
return false;
}
+
// Set the confirmation token.
$token = JApplication::getHash(JUserHelper::genRandomPassword());
$salt = JUserHelper::getSalt('crypt-md5');
$hashedToken = md5($token . $salt) . ':' . $salt;
-
$user->activation = $hashedToken;
// Save the user to the database.
@@ -454,24 +473,23 @@ public function checkResetLimit($user)
$lastResetTime = strtotime($user->lastResetTime) ? strtotime($user->lastResetTime) : 0;
$hoursSinceLastReset = (strtotime(JFactory::getDate()->toSql()) - $lastResetTime) / 3600;
- // If it's been long enough, start a new reset count
if ($hoursSinceLastReset > $resetHours)
{
+ // If it's been long enough, start a new reset count
$user->lastResetTime = JFactory::getDate()->toSql();
$user->resetCount = 1;
}
-
- // If we are under the max count, just increment the counter
elseif ($user->resetCount < $maxCount)
{
+ // If we are under the max count, just increment the counter
$user->resetCount;
}
-
- // At this point, we know we have exceeded the maximum resets for the time period
else
{
+ // At this point, we know we have exceeded the maximum resets for the time period
$result = false;
}
+
return $result;
}
}
View
2  plugins/search/tags/tags.php
@@ -171,7 +171,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu
if ($tagged_items)
{
- foreach($tagged_items as $k => $item)
+ foreach ($tagged_items as $k => $item)
{
$new_item = new stdClass;
$new_item->href = $item->link;
Please sign in to comment.
Something went wrong with that request. Please try again.