Permalink
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...
wilsonge authored and phproberto committed May 28, 2014
1 parent 824ecf7 commit ce339f1088025980a4f37a1fca80df60a182a75f
@@ -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');
}
@@ -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);
}
@@ -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,39 +177,46 @@ 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;
}
/**
* 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;
}
}
@@ -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))
{
?>
Oops, something went wrong.

0 comments on commit ce339f1

Please sign in to comment.