Fix CS for com_weblinks frontend models (#229)

* Update category.php

* Update weblink.php

* Update form.php

* Update categories.php

* Update category.php

* Update categories.php
This commit is contained in:
zero-24 2016-07-08 20:55:07 +02:00 committed by Chris Davenport
parent c2b4bd1dc7
commit 353300bc2f
4 changed files with 53 additions and 32 deletions

View File

@ -40,6 +40,11 @@ class WeblinksModelCategories extends JModelList
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
@ -54,8 +59,8 @@ class WeblinksModelCategories extends JModelList
$params = $app->getParams();
$this->setState('params', $params);
$this->setState('filter.published', 1);
$this->setState('filter.access', true);
$this->setState('filter.published', 1);
$this->setState('filter.access', true);
}
/**
@ -72,18 +77,18 @@ class WeblinksModelCategories extends JModelList
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.extension');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.parentId');
$id .= ':' . $this->getState('filter.extension');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.parentId');
return parent::getStoreId($id);
}
/**
* redefine the function an add some properties to make the styling more easy
* Redefine the function and add some properties to make the styling more easy
*
* @return mixed An array of data items on success, false on failure.
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
@ -117,12 +122,18 @@ class WeblinksModelCategories extends JModelList
return $this->_items;
}
/**
* Get the parent
*
* @return mixed An array of data items on success, false on failure.
*/
public function getParent()
{
if (!is_object($this->_parent))
{
$this->getItems();
}
return $this->_parent;
}
}

View File

@ -36,7 +36,7 @@ class WeblinksModelCategory extends JModelList
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @param array $config An optional associative array of configuration settings.
*
* @see JControllerLegacy
* @since 1.6
@ -121,8 +121,8 @@ class WeblinksModelCategory extends JModelList
// Filter by category.
if ($categoryId = $this->getState('category.id'))
{
// Group by subcategory
if($this->getState('category.group', 0))
// Group by subcategory
if ($this->getState('category.group', 0))
{
$query->select('c.title AS category_title')
->where('c.parent_id = ' . (int) $categoryId)
@ -152,7 +152,6 @@ class WeblinksModelCategory extends JModelList
->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
// Filter by state
$state = $this->getState('filter.state');
if (is_numeric($state))
@ -160,7 +159,7 @@ class WeblinksModelCategory extends JModelList
$query->where('a.state = ' . (int) $state);
}
// do not show trashed links on the front-end
// Do not show trashed links on the front-end
$query->where('a.state != -2');
// Filter by start and end dates.
@ -192,17 +191,15 @@ class WeblinksModelCategory extends JModelList
if($this->getState('category.group', 0))
{
$query->order(
$db->escape(
$this->getState('category.ordering', 'c.lft')) . ' ' . $db->escape($this->getState('category.direction', 'ASC')
)
$db->escape($this->getState('category.ordering', 'c.lft')) . ' ' .
$db->escape($this->getState('category.direction', 'ASC'))
);
}
// Add the list ordering clause.
$query->order(
$db->escape(
$this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')
)
$db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' .
$db->escape($this->getState('list.direction', 'ASC'))
);
return $query;
@ -213,6 +210,11 @@ class WeblinksModelCategory extends JModelList
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
@ -255,7 +257,7 @@ class WeblinksModelCategory extends JModelList
if ((!$user->authorise('core.edit.state', 'com_weblinks')) && (!$user->authorise('core.edit', 'com_weblinks')))
{
// limit to published for people who can't edit or edit.state.
// Limit to published for people who can't edit or edit.state.
$this->setState('filter.state', 1);
// Filter by start and end dates.
@ -322,8 +324,6 @@ class WeblinksModelCategory extends JModelList
/**
* Get the parent category
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function getParent()
@ -332,40 +332,46 @@ class WeblinksModelCategory extends JModelList
{
$this->getCategory();
}
return $this->_parent;
}
/**
* Get the sibling (adjacent) categories.
* Get the leftsibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
function &getLeftSibling()
public function &getLeftSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_leftsibling;
}
function &getRightSibling()
/**
* Get the rightsibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function &getRightSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_rightsibling;
}
/**
* Get the child categories.
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @return mixed An array of categories or false if an error occurs.
*/
function &getChildren()
public function &getChildren()
{
if (!is_object($this->_item))
{

View File

@ -43,6 +43,8 @@ class WeblinksModelForm extends WeblinksModelWeblink
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()

View File

@ -32,6 +32,8 @@ class WeblinksModelWeblink extends JModelItem
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
@ -50,7 +52,7 @@ class WeblinksModelWeblink extends JModelItem
/**
* Method to get an object.
*
* @param integer The id of the object to get.
* @param integer $id The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
@ -96,9 +98,9 @@ class WeblinksModelWeblink extends JModelItem
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
* @param string $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
*