32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-11-10 15:20:57 +00:00

Optimization and cleanup

This commit is contained in:
Michael Babker 2015-02-17 20:20:59 -05:00
parent 5ceb760b54
commit 58ec6fef01
21 changed files with 270 additions and 221 deletions

View File

@ -10,7 +10,7 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
/** /**
* Weblinks Weblink Controller * Weblinks Main Controller
* *
* @since 1.5 * @since 1.5
*/ */
@ -22,7 +22,7 @@ class WeblinksController extends JControllerLegacy
* @param boolean $cachable If true, the view output will be cached * @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
* *
* @return JController This object to support chaining. * @return JControllerLegacy This object to support chaining.
* *
* @since 1.5 * @since 1.5
*/ */
@ -45,8 +45,6 @@ class WeblinksController extends JControllerLegacy
return false; return false;
} }
parent::display(); return parent::display();
return $this;
} }
} }

View File

@ -37,15 +37,13 @@ class WeblinksControllerWeblink extends JControllerForm
$allow = $user->authorise('core.create', $this->option . '.category.' . $categoryId); $allow = $user->authorise('core.create', $this->option . '.category.' . $categoryId);
} }
if ($allow === null) if ($allow !== null)
{
// In the absense of better information, revert to the component permissions.
return parent::allowAdd($data);
}
else
{ {
return $allow; return $allow;
} }
// In the absense of better information, revert to the component permissions.
return parent::allowAdd($data);
} }
/** /**
@ -73,11 +71,9 @@ class WeblinksControllerWeblink extends JControllerForm
// The category has been set. Check the category permissions. // The category has been set. Check the category permissions.
return JFactory::getUser()->authorise('core.edit', $this->option . '.category.' . $categoryId); return JFactory::getUser()->authorise('core.edit', $this->option . '.category.' . $categoryId);
} }
else
{ // Since there is no asset tracking, revert to the component permissions.
// Since there is no asset tracking, revert to the component permissions. return parent::allowEdit($data, $key);
return parent::allowEdit($data, $key);
}
} }
/** /**

View File

@ -29,22 +29,6 @@ class WeblinksControllerWeblinks extends JControllerAdmin
*/ */
public function getModel($name = 'Weblink', $prefix = 'WeblinksModel', $config = array('ignore_request' => true)) public function getModel($name = 'Weblink', $prefix = 'WeblinksModel', $config = array('ignore_request' => true))
{ {
$model = parent::getModel($name, $prefix, $config); return parent::getModel($name, $prefix, $config);
return $model;
}
/**
* Method to provide child classes the opportunity to process after the delete task.
*
* @param JModelLegacy $model The model for the component
* @param mixed $ids array of ids deleted.
*
* @return void
*
* @since 3.1
*/
protected function postDeleteHook(JModelLegacy $model, $ids = null)
{
} }
} }

View File

@ -10,6 +10,7 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
use Joomla\String\String;
/** /**
* Weblinks model. * Weblinks model.
@ -18,12 +19,11 @@ use Joomla\Registry\Registry;
*/ */
class WeblinksModelWeblink extends JModelAdmin class WeblinksModelWeblink extends JModelAdmin
{ {
/** /**
* The type alias for this content type. * The type alias for this content type.
* *
* @var string * @var string
* @since 3.2 * @since 3.2
*/ */
public $typeAlias = 'com_weblinks.weblink'; public $typeAlias = 'com_weblinks.weblink';
@ -52,16 +52,13 @@ class WeblinksModelWeblink extends JModelAdmin
{ {
return; return;
} }
$user = JFactory::getUser();
if ($record->catid) if ($record->catid)
{ {
return $user->authorise('core.delete', 'com_weblinks.category.'.(int) $record->catid); return JFactory::getUser()->authorise('core.delete', 'com_weblinks.category.' . (int) $record->catid);
}
else
{
return parent::canDelete($record);
} }
return parent::canDelete($record);
} }
} }
@ -76,16 +73,12 @@ class WeblinksModelWeblink extends JModelAdmin
*/ */
protected function canEditState($record) protected function canEditState($record)
{ {
$user = JFactory::getUser();
if (!empty($record->catid)) if (!empty($record->catid))
{ {
return $user->authorise('core.edit.state', 'com_weblinks.category.'.(int) $record->catid); return JFactory::getUser()->authorise('core.edit.state', 'com_weblinks.category.' . (int) $record->catid);
}
else
{
return parent::canEditState($record);
} }
return parent::canEditState($record);
} }
/** /**
@ -234,11 +227,11 @@ class WeblinksModelWeblink extends JModelAdmin
$user = JFactory::getUser(); $user = JFactory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = JApplication::stringURLSafe($table->alias); $table->alias = JApplicationHelper::stringURLSafe($table->alias);
if (empty($table->alias)) if (empty($table->alias))
{ {
$table->alias = JApplication::stringURLSafe($table->title); $table->alias = JApplicationHelper::stringURLSafe($table->title);
} }
if (empty($table->id)) if (empty($table->id))
@ -262,7 +255,7 @@ class WeblinksModelWeblink extends JModelAdmin
{ {
// Set the values // Set the values
$table->modified = $date->toSql(); $table->modified = $date->toSql();
$table->modified_by = $user->get('id'); $table->modified_by = $user->id;
} }
} }
@ -332,10 +325,10 @@ class WeblinksModelWeblink extends JModelAdmin
{ {
if ($name == $table->title) if ($name == $table->title)
{ {
$name = JString::increment($name); $name = String::increment($name);
} }
$alias = JString::increment($alias, 'dash'); $alias = String::increment($alias, 'dash');
} }
return array($name, $alias); return array($name, $alias);

View File

@ -20,7 +20,8 @@ class WeblinksModelWeblinks extends JModelList
* Constructor. * Constructor.
* *
* @param array An optional associative array of configuration settings. * @param array An optional associative array of configuration settings.
* @see JController *
* @see JControllerLegacy
* @since 1.6 * @since 1.6
*/ */
public function __construct($config = array()) public function __construct($config = array())
@ -54,8 +55,9 @@ class WeblinksModelWeblinks extends JModelList
/** /**
* Method to auto-populate the model state. * Method to auto-populate the model state.
* *
* Note. Calling getState in this method will result in recursion. * @return void
* *
* @note Calling getState in this method will result in recursion.
* @since 1.6 * @since 1.6
*/ */
protected function populateState($ordering = null, $direction = null) protected function populateState($ordering = null, $direction = null)
@ -94,8 +96,10 @@ class WeblinksModelWeblinks extends JModelList
* different modules that might need different sets of data or different * different modules that might need different sets of data or different
* ordering requirements. * ordering requirements.
* *
* @param string $id A prefix for the store id. * @param string $id A prefix for the store id.
*
* @return string A store id. * @return string A store id.
*
* @since 1.6 * @since 1.6
*/ */
protected function getStoreId($id = '') protected function getStoreId($id = '')
@ -114,6 +118,7 @@ class WeblinksModelWeblinks extends JModelList
* Build an SQL query to load the list data. * Build an SQL query to load the list data.
* *
* @return JDatabaseQuery * @return JDatabaseQuery
*
* @since 1.6 * @since 1.6
*/ */
protected function getListQuery() protected function getListQuery()
@ -128,9 +133,7 @@ class WeblinksModelWeblinks extends JModelList
$this->getState( $this->getState(
'list.select', 'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid,' . 'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid,' .
'a.hits,' . 'a.hits, a.state, a.access, a.ordering, a.language, a.publish_up, a.publish_down'
'a.state, a.access, a.ordering,' .
'a.language, a.publish_up, a.publish_down'
) )
); );
$query->from($db->quoteName('#__weblinks') . ' AS a'); $query->from($db->quoteName('#__weblinks') . ' AS a');
@ -166,6 +169,7 @@ class WeblinksModelWeblinks extends JModelList
// Filter by published state // Filter by published state
$published = $this->getState('filter.state'); $published = $this->getState('filter.state');
if (is_numeric($published)) if (is_numeric($published))
{ {
$query->where('a.state = ' . (int) $published); $query->where('a.state = ' . (int) $published);
@ -177,6 +181,7 @@ class WeblinksModelWeblinks extends JModelList
// Filter by category. // Filter by category.
$categoryId = $this->getState('filter.category_id'); $categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId)) if (is_numeric($categoryId))
{ {
$query->where('a.catid = ' . (int) $categoryId); $query->where('a.catid = ' . (int) $categoryId);
@ -184,6 +189,7 @@ class WeblinksModelWeblinks extends JModelList
// Filter by search in title // Filter by search in title
$search = $this->getState('filter.search'); $search = $this->getState('filter.search');
if (!empty($search)) if (!empty($search))
{ {
if (stripos($search, 'id:') === 0) if (stripos($search, 'id:') === 0)
@ -204,6 +210,7 @@ class WeblinksModelWeblinks extends JModelList
} }
$tagId = $this->getState('filter.tag'); $tagId = $this->getState('filter.tag');
// Filter by a single tag. // Filter by a single tag.
if (is_numeric($tagId)) if (is_numeric($tagId))
{ {
@ -218,13 +225,14 @@ class WeblinksModelWeblinks extends JModelList
// Add the list ordering clause. // Add the list ordering clause.
$orderCol = $this->state->get('list.ordering'); $orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction'); $orderDirn = $this->state->get('list.direction');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') if ($orderCol == 'a.ordering' || $orderCol == 'category_title')
{ {
$orderCol = 'c.title ' . $orderDirn . ', a.ordering'; $orderCol = 'c.title ' . $orderDirn . ', a.ordering';
} }
$query->order($db->escape($orderCol . ' ' . $orderDirn)); $query->order($db->escape($orderCol . ' ' . $orderDirn));
//echo nl2br(str_replace('#__','jos_',$query));
return $query; return $query;
} }
} }

View File

@ -21,7 +21,7 @@ class Com_WeblinksInstallerScript
/** /**
* Function to perform changes during install * Function to perform changes during install
* *
* @param JInstallerComponent $parent The class calling this method * @param JInstallerAdapterComponent $parent The class calling this method
* *
* @return void * @return void
* *

View File

@ -9,6 +9,8 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\String\String;
/** /**
* Weblink Table class * Weblink Table class
* *
@ -28,6 +30,8 @@ class WeblinksTableWeblink extends JTable
* Constructor * Constructor
* *
* @param JDatabaseDriver &$db A database connector object * @param JDatabaseDriver &$db A database connector object
*
* @since 1.5
*/ */
public function __construct(&$db) public function __construct(&$db)
{ {
@ -44,20 +48,22 @@ class WeblinksTableWeblink extends JTable
* Overload the store method for the Weblinks table. * Overload the store method for the Weblinks table.
* *
* @param boolean Toggle whether null values should be updated. * @param boolean Toggle whether null values should be updated.
*
* @return boolean True on success, false on failure. * @return boolean True on success, false on failure.
*
* @since 1.6 * @since 1.6
*/ */
public function store($updateNulls = false) public function store($updateNulls = false)
{ {
$date = JFactory::getDate(); $date = JFactory::getDate();
$user = JFactory::getUser(); $user = JFactory::getUser();
$this->modified = $date->toSql(); $this->modified = $date->toSql();
if ($this->id) if ($this->id)
{ {
// Existing item // Existing item
$this->modified_by = $user->get('id'); $this->modified_by = $user->id;
} }
else else
{ {
@ -67,22 +73,23 @@ class WeblinksTableWeblink extends JTable
{ {
$this->created = $date->toSql(); $this->created = $date->toSql();
} }
if (empty($this->created_by)) if (empty($this->created_by))
{ {
$this->created_by = $user->get('id'); $this->created_by = $user->id;
} }
} }
// Set publish_up to null date if not set // Set publish_up to null date if not set
if (!$this->publish_up) if (!$this->publish_up)
{ {
$this->publish_up = $this->_db->getNullDate(); $this->publish_up = $this->getDbo()->getNullDate();
} }
// Set publish_down to null date if not set // Set publish_down to null date if not set
if (!$this->publish_down) if (!$this->publish_down)
{ {
$this->publish_down = $this->_db->getNullDate(); $this->publish_down = $this->getDbo()->getNullDate();
} }
// Verify that the alias is unique // Verify that the alias is unique
@ -91,6 +98,7 @@ class WeblinksTableWeblink extends JTable
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
{ {
$this->setError(JText::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS')); $this->setError(JText::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS'));
return false; return false;
} }
@ -104,12 +112,15 @@ class WeblinksTableWeblink extends JTable
* Overloaded check method to ensure data integrity. * Overloaded check method to ensure data integrity.
* *
* @return boolean True on success. * @return boolean True on success.
*
* @since 1.5
*/ */
public function check() public function check()
{ {
if (JFilterInput::checkAttribute(array ('href', $this->url))) if (JFilterInput::checkAttribute(array('href', $this->url)))
{ {
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_PROVIDE_URL')); $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_PROVIDE_URL'));
return false; return false;
} }
@ -121,17 +132,21 @@ class WeblinksTableWeblink extends JTable
} }
// Check for existing name // Check for existing name
$query = $this->_db->getQuery(true) $db = $this->getDbo();
->select($this->_db->quoteName('id'))
->from($this->_db->quoteName('#__weblinks')) $query = $db->getQuery(true)
->where($this->_db->quoteName('title') . ' = ' . $this->_db->quote($this->title)) ->select($db->quoteName('id'))
->where($this->_db->quoteName('catid') . ' = ' . (int) $this->catid); ->from($db->quoteName('#__weblinks'))
$this->_db->setQuery($query); ->where($db->quoteName('title') . ' = ' . $db->quote($this->title))
->where($db->quoteName('catid') . ' = ' . (int) $this->catid);
$db->setQuery($query);
$xid = (int) $db->loadResult();
$xid = (int) $this->_db->loadResult();
if ($xid && $xid != (int) $this->id) if ($xid && $xid != (int) $this->id)
{ {
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_NAME')); $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_NAME'));
return false; return false;
} }
@ -139,36 +154,45 @@ class WeblinksTableWeblink extends JTable
{ {
$this->alias = $this->title; $this->alias = $this->title;
} }
$this->alias = JApplication::stringURLSafe($this->alias);
$this->alias = JApplicationHelper::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
} }
// Check the publish down date is not earlier than publish up. // Check the publish down date is not earlier than publish up.
if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up) if ($this->publish_down > $db->getNullDate() && $this->publish_down < $this->publish_up)
{ {
$this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH')); $this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false; return false;
} }
// clean up keywords -- eliminate extra spaces between phrases /*
// and cr (\r) and lf (\n) characters from string * Clean up keywords -- eliminate extra spaces between phrases
* and cr (\r) and lf (\n) characters from string
*/
if (!empty($this->metakey)) if (!empty($this->metakey))
{ {
// only process if not empty // Array of characters to remove
$bad_characters = array("\n", "\r", "\"", "<", ">"); // array of characters to remove $bad_characters = array("\n", "\r", "\"", "<", ">");
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey); // remove bad characters $after_clean = String::str_ireplace($bad_characters, "", $this->metakey);
$keys = explode(',', $after_clean); // create array using commas as delimiter $keys = explode(',', $after_clean);
$clean_keys = array(); $clean_keys = array();
foreach ($keys as $key) foreach ($keys as $key)
{ {
if (trim($key)) { // ignore blank keywords // Ignore blank keywords
if (trim($key))
{
$clean_keys[] = trim($key); $clean_keys[] = trim($key);
} }
} }
$this->metakey = implode(", ", $clean_keys); // put array back together delimited by ", "
// Put array back together delimited by ", "
$this->metakey = implode(", ", $clean_keys);
} }
return true; return true;

View File

@ -29,9 +29,9 @@ class WeblinksViewWeblinks extends JViewLegacy
*/ */
public function display($tpl = null) public function display($tpl = null)
{ {
$this->state = $this->get('State'); $this->state = $this->get('State');
$this->items = $this->get('Items'); $this->items = $this->get('Items');
$this->pagination = $this->get('Pagination'); $this->pagination = $this->get('Pagination');
WeblinksHelper::addSubmenu('weblinks'); WeblinksHelper::addSubmenu('weblinks');
@ -56,39 +56,46 @@ class WeblinksViewWeblinks extends JViewLegacy
{ {
require_once JPATH_COMPONENT . '/helpers/weblinks.php'; require_once JPATH_COMPONENT . '/helpers/weblinks.php';
$state = $this->get('State'); $state = $this->get('State');
$canDo = JHelperContent::getActions('com_weblinks', 'category', $state->get('filter.category_id')); $canDo = JHelperContent::getActions('com_weblinks', 'category', $state->get('filter.category_id'));
$user = JFactory::getUser(); $user = JFactory::getUser();
// Get the toolbar object instance // Get the toolbar object instance
$bar = JToolBar::getInstance('toolbar'); $bar = JToolBar::getInstance('toolbar');
JToolbarHelper::title(JText::_('COM_WEBLINKS_MANAGER_WEBLINKS'), 'link weblinks'); JToolbarHelper::title(JText::_('COM_WEBLINKS_MANAGER_WEBLINKS'), 'link weblinks');
if (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0) if (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)
{ {
JToolbarHelper::addNew('weblink.add'); JToolbarHelper::addNew('weblink.add');
} }
if ($canDo->get('core.edit')) if ($canDo->get('core.edit'))
{ {
JToolbarHelper::editList('weblink.edit'); JToolbarHelper::editList('weblink.edit');
} }
if ($canDo->get('core.edit.state')) {
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::publish('weblinks.publish', 'JTOOLBAR_PUBLISH', true); JToolbarHelper::publish('weblinks.publish', 'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('weblinks.unpublish', 'JTOOLBAR_UNPUBLISH', true); JToolbarHelper::unpublish('weblinks.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolbarHelper::archiveList('weblinks.archive'); JToolbarHelper::archiveList('weblinks.archive');
JToolbarHelper::checkin('weblinks.checkin'); JToolbarHelper::checkin('weblinks.checkin');
} }
if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) if ($state->get('filter.state') == -2 && $canDo->get('core.delete'))
{ {
JToolbarHelper::deleteList('', 'weblinks.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolbarHelper::deleteList('', 'weblinks.delete', 'JTOOLBAR_EMPTY_TRASH');
} elseif ($canDo->get('core.edit.state')) }
elseif ($canDo->get('core.edit.state'))
{ {
JToolbarHelper::trash('weblinks.trash'); JToolbarHelper::trash('weblinks.trash');
} }
// Add a batch button // Add a batch button
if ($user->authorise('core.create', 'com_weblinks') && $user->authorise('core.edit', 'com_weblinks') && $user->authorise('core.edit.state', 'com_weblinks')) if ($user->authorise('core.create', 'com_weblinks') && $user->authorise('core.edit', 'com_weblinks')
&& $user->authorise('core.edit.state', 'com_weblinks'))
{ {
JHtml::_('bootstrap.modal', 'collapseModal'); JHtml::_('bootstrap.modal', 'collapseModal');
$title = JText::_('JTOOLBAR_BATCH'); $title = JText::_('JTOOLBAR_BATCH');
@ -99,6 +106,7 @@ class WeblinksViewWeblinks extends JViewLegacy
$dhtml = $layout->render(array('title' => $title)); $dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch'); $bar->appendButton('Custom', $dhtml, 'batch');
} }
if ($user->authorise('core.admin', 'com_weblinks')) if ($user->authorise('core.admin', 'com_weblinks'))
{ {
JToolbarHelper::preferences('com_weblinks'); JToolbarHelper::preferences('com_weblinks');
@ -133,9 +141,9 @@ class WeblinksViewWeblinks extends JViewLegacy
); );
JHtmlSidebar::addFilter( JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_TAG'), JText::_('JOPTION_SELECT_TAG'),
'filter_tag', 'filter_tag',
JHtml::_('select.options', JHtml::_('tag.options', true, true), 'value', 'text', $this->state->get('filter.tag')) JHtml::_('select.options', JHtml::_('tag.options', true, true), 'value', 'text', $this->state->get('filter.tag'))
); );
} }

View File

@ -19,10 +19,12 @@ class WeblinksController extends JControllerLegacy
/** /**
* Method to display a view. * Method to display a view.
* *
* @param boolean If true, the view output will be cached * @param boolean $cachable If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * @param array $urlparams An array of safe url parameters and their variable types,
* for valid values see {@link JFilterInput::clean()}.
*
* @return WeblinksController This object to support chaining.
* *
* @return JController This object to support chaining.
* @since 1.5 * @since 1.5
*/ */
public function display($cachable = false, $urlparams = false) public function display($cachable = false, $urlparams = false)
@ -37,7 +39,7 @@ class WeblinksController extends JControllerLegacy
$vName = $this->input->get('view', 'categories'); $vName = $this->input->get('view', 'categories');
$this->input->set('view', $vName); $this->input->set('view', $vName);
if ($user->get('id') ||($this->input->getMethod() == 'POST' && $vName = 'categories')) if (JFactory::getUser()->id ||($this->input->getMethod() == 'POST' && $vName = 'categories'))
{ {
$cachable = false; $cachable = false;
} }

View File

@ -9,6 +9,8 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/** /**
* Weblinks class. * Weblinks class.
* *
@ -17,12 +19,18 @@ defined('_JEXEC') or die;
class WeblinksControllerWeblink extends JControllerForm class WeblinksControllerWeblink extends JControllerForm
{ {
/** /**
* @since 1.6 * The URL view item variable.
*
* @var string
* @since 1.6
*/ */
protected $view_item = 'form'; protected $view_item = 'form';
/** /**
* @since 1.6 * The URL view list variable.
*
* @var string
* @since 1.6
*/ */
protected $view_list = 'categories'; protected $view_list = 'categories';
@ -38,6 +46,7 @@ class WeblinksControllerWeblink extends JControllerForm
* Method to add a new record. * Method to add a new record.
* *
* @return boolean True if the article can be added, false if not. * @return boolean True if the article can be added, false if not.
*
* @since 1.6 * @since 1.6
*/ */
public function add() public function add()
@ -60,25 +69,22 @@ class WeblinksControllerWeblink extends JControllerForm
*/ */
protected function allowAdd($data = array()) protected function allowAdd($data = array())
{ {
$user = JFactory::getUser(); $categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('id'), 'int');
$categoryId = JArrayHelper::getValue($data, 'catid', $this->input->getInt('id'), 'int'); $allow = null;
$allow = null;
if ($categoryId) if ($categoryId)
{ {
// If the category has been passed in the URL check it. // If the category has been passed in the URL check it.
$allow = $user->authorise('core.create', $this->option . '.category.' . $categoryId); $allow = JFactory::getUser()->authorise('core.create', $this->option . '.category.' . $categoryId);
} }
if ($allow === null) if ($allow !== null)
{
// In the absense of better information, revert to the component permissions.
return parent::allowAdd($data);
}
else
{ {
return $allow; return $allow;
} }
// In the absense of better information, revert to the component permissions.
return parent::allowAdd($data);
} }
/** /**
@ -106,11 +112,9 @@ class WeblinksControllerWeblink extends JControllerForm
// The category has been set. Check the category permissions. // The category has been set. Check the category permissions.
return JFactory::getUser()->authorise('core.edit', $this->option . '.category.' . $categoryId); return JFactory::getUser()->authorise('core.edit', $this->option . '.category.' . $categoryId);
} }
else
{ // Since there is no asset tracking, revert to the component permissions.
// Since there is no asset tracking, revert to the component permissions. return parent::allowEdit($data, $key);
return parent::allowEdit($data, $key);
}
} }
/** /**
@ -124,10 +128,12 @@ class WeblinksControllerWeblink extends JControllerForm
*/ */
public function cancel($key = 'w_id') public function cancel($key = 'w_id')
{ {
parent::cancel($key); $return = parent::cancel($key);
// Redirect to the return page. // Redirect to the return page.
$this->setRedirect($this->getReturnPage()); $this->setRedirect($this->getReturnPage());
return $return;
} }
/** /**
@ -142,9 +148,7 @@ class WeblinksControllerWeblink extends JControllerForm
*/ */
public function edit($key = null, $urlVar = 'w_id') public function edit($key = null, $urlVar = 'w_id')
{ {
$result = parent::edit($key, $urlVar); return parent::edit($key, $urlVar);
return $result;
} }
/** /**
@ -160,9 +164,7 @@ class WeblinksControllerWeblink extends JControllerForm
*/ */
public function getModel($name = 'form', $prefix = '', $config = array('ignore_request' => true)) public function getModel($name = 'form', $prefix = '', $config = array('ignore_request' => true))
{ {
$model = parent::getModel($name, $prefix, $config); return parent::getModel($name, $prefix, $config);
return $model;
} }
/** /**
@ -195,9 +197,7 @@ class WeblinksControllerWeblink extends JControllerForm
} }
/** /**
* Get the return URL. * Get the return URL if a "return" variable has been passed in the request
*
* If a "return" variable has been passed in the request
* *
* @return string The return URL. * @return string The return URL.
* *
@ -211,24 +211,8 @@ class WeblinksControllerWeblink extends JControllerForm
{ {
return JUri::base(); return JUri::base();
} }
else
{
return base64_decode($return);
}
}
/** return base64_decode($return);
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
* @since 1.6
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
return;
} }
/** /**
@ -267,11 +251,11 @@ class WeblinksControllerWeblink extends JControllerForm
$id = $this->input->getInt('id'); $id = $this->input->getInt('id');
// Get the model, requiring published items // Get the model, requiring published items
$modelLink = $this->getModel('Weblink', '', array('ignore_request' => true)); $modelLink = $this->getModel('Weblink', '', array('ignore_request' => true));
$modelLink->setState('filter.published', 1); $modelLink->setState('filter.published', 1);
// Get the item // Get the item
$link = $modelLink->getItem($id); $link = $modelLink->getItem($id);
// Make sure the item was found. // Make sure the item was found.
if (empty($link)) if (empty($link))
@ -280,8 +264,7 @@ class WeblinksControllerWeblink extends JControllerForm
} }
// Check whether item access level allows access. // Check whether item access level allows access.
$user = JFactory::getUser(); $groups = JFactory::getUser()->getAuthorisedViewLevels();
$groups = $user->getAuthorisedViewLevels();
if (!in_array($link->access, $groups)) if (!in_array($link->access, $groups))
{ {
@ -314,9 +297,7 @@ class WeblinksControllerWeblink extends JControllerForm
$modelLink->hit($id); $modelLink->hit($id);
JFactory::getApplication()->redirect($link->url); JFactory::getApplication()->redirect($link->url);
} }
else
{ return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_URL_INVALID'));
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_URL_INVALID'));
}
} }
} }

View File

@ -27,15 +27,13 @@ abstract class WeblinksHelperAssociation extends CategoryHelperAssociation
* *
* @return array Array of associations for the item * @return array Array of associations for the item
* *
* @since 3.0 * @since 3.0
*/ */
public static function getAssociations($id = 0, $view = null) public static function getAssociations($id = 0, $view = null)
{ {
jimport('helper.route', JPATH_COMPONENT_SITE); jimport('helper.route', JPATH_COMPONENT_SITE);
$app = JFactory::getApplication(); $jinput = JFactory::getApplication()->input;
$jinput = $app->input;
$view = is_null($view) ? $jinput->get('view') : $view; $view = is_null($view) ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id; $id = empty($id) ? $jinput->getInt('id') : $id;
@ -45,6 +43,5 @@ abstract class WeblinksHelperAssociation extends CategoryHelperAssociation
} }
return array(); return array();
} }
} }

View File

@ -16,10 +16,18 @@ defined('_JEXEC') or die;
*/ */
class WeblinksCategories extends JCategories class WeblinksCategories extends JCategories
{ {
/**
* Constructor
*
* @param array $options Array of options
*
* @since 1.6
*/
public function __construct($options = array()) public function __construct($options = array())
{ {
$options['table'] = '#__weblinks'; $options['table'] = '#__weblinks';
$options['extension'] = 'com_weblinks'; $options['extension'] = 'com_weblinks';
parent::__construct($options); parent::__construct($options);
} }
} }

View File

@ -16,6 +16,14 @@ defined('_JEXEC') or die;
*/ */
class JHtmlIcon class JHtmlIcon
{ {
/**
* Create a link to create a new weblink
*
* @param mixed $weblink Unused
* @param mixed $params Unused
*
* @return string
*/
public static function create($weblink, $params) public static function create($weblink, $params)
{ {
JHtml::_('bootstrap.tooltip'); JHtml::_('bootstrap.tooltip');
@ -24,10 +32,19 @@ class JHtmlIcon
$url = JRoute::_(WeblinksHelperRoute::getFormRoute(0, base64_encode($uri))); $url = JRoute::_(WeblinksHelperRoute::getFormRoute(0, base64_encode($uri)));
$text = JHtml::_('image', 'system/new.png', JText::_('JNEW'), null, true); $text = JHtml::_('image', 'system/new.png', JText::_('JNEW'), null, true);
$button = JHtml::_('link', $url, $text); $button = JHtml::_('link', $url, $text);
$output = '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_FORM_CREATE_WEBLINK') . '">' . $button . '</span>';
return $output; return '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_FORM_CREATE_WEBLINK') . '">' . $button . '</span>';
} }
/**
* Create a link to edit an existing weblink
*
* @param object $weblink Weblink data
* @param \Joomla\Registry\Registry $params Item params
* @param array $attribs Unused
*
* @return string
*/
public static function edit($weblink, $params, $attribs = array()) public static function edit($weblink, $params, $attribs = array())
{ {
$uri = JUri::getInstance(); $uri = JUri::getInstance();
@ -67,8 +84,6 @@ class JHtmlIcon
$button = JHtml::_('link', JRoute::_($url), $text); $button = JHtml::_('link', JRoute::_($url), $text);
$output = '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT') . ' :: ' . $overlib . '">' . $button . '</span>'; return '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT') . ' :: ' . $overlib . '">' . $button . '</span>';
return $output;
} }
} }

View File

@ -22,6 +22,8 @@ abstract class WeblinksHelperRoute
/** /**
* @param integer The route of the weblink * @param integer The route of the weblink
*
* @return string
*/ */
public static function getWeblinkRoute($id, $catid, $language = 0) public static function getWeblinkRoute($id, $catid, $language = 0)
{ {
@ -29,7 +31,7 @@ abstract class WeblinksHelperRoute
'weblink' => array((int) $id) 'weblink' => array((int) $id)
); );
//Create the link // Create the link
$link = 'index.php?option=com_weblinks&view=weblink&id='. $id; $link = 'index.php?option=com_weblinks&view=weblink&id='. $id;
if ($catid > 1) if ($catid > 1)
@ -65,8 +67,10 @@ abstract class WeblinksHelperRoute
} }
/** /**
* @param integer $id The id of the weblink. * @param integer $id The id of the weblink.
* @param string $return The return page variable. * @param string $return The return page variable.
*
* @return string
*/ */
public static function getFormRoute($id, $return = null) public static function getFormRoute($id, $return = null)
{ {
@ -88,6 +92,12 @@ abstract class WeblinksHelperRoute
return $link; return $link;
} }
/**
* @param JCategoryNode|string|integer $catid JCategoryNode object or category ID
* @param integer $language Language code
*
* @return string
*/
public static function getCategoryRoute($catid, $language = 0) public static function getCategoryRoute($catid, $language = 0)
{ {
if ($catid instanceof JCategoryNode) if ($catid instanceof JCategoryNode)
@ -136,6 +146,9 @@ abstract class WeblinksHelperRoute
return $link; return $link;
} }
/**
* @return void
*/
protected static function buildLanguageLookup() protected static function buildLanguageLookup()
{ {
if (count(self::$lang_lookup) == 0) if (count(self::$lang_lookup) == 0)
@ -158,9 +171,9 @@ abstract class WeblinksHelperRoute
protected static function _findItem($needles = null) protected static function _findItem($needles = null)
{ {
$app = JFactory::getApplication(); $app = JFactory::getApplication();
$menus = $app->getMenu('site'); $menus = $app->getMenu('site');
$language = isset($needles['language']) ? $needles['language'] : '*'; $language = isset($needles['language']) ? $needles['language'] : '*';
// Prepare the reverse lookup array. // Prepare the reverse lookup array.
if (!isset(self::$lookup[$language])) if (!isset(self::$lookup[$language]))
@ -187,13 +200,14 @@ abstract class WeblinksHelperRoute
if (isset($item->query) && isset($item->query['view'])) if (isset($item->query) && isset($item->query['view']))
{ {
$view = $item->query['view']; $view = $item->query['view'];
if (!isset(self::$lookup[$language][$view])) if (!isset(self::$lookup[$language][$view]))
{ {
self::$lookup[$language][$view] = array(); self::$lookup[$language][$view] = array();
} }
if (isset($item->query['id'])) if (isset($item->query['id']))
{ {
// here it will become a bit tricky // here it will become a bit tricky
// language != * can override existing entries // language != * can override existing entries
// language == * cannot override existing entries // language == * cannot override existing entries
@ -226,6 +240,7 @@ abstract class WeblinksHelperRoute
// Check if the active menuitem matches the requested language // Check if the active menuitem matches the requested language
$active = $menus->getActive(); $active = $menus->getActive();
if ($active && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled())) if ($active && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled()))
{ {
return $active->id; return $active->id;
@ -233,6 +248,7 @@ abstract class WeblinksHelperRoute
// If not found, return language specific home link // If not found, return language specific home link
$default = $menus->getDefault($language); $default = $menus->getDefault($language);
return !empty($default->id) ? $default->id : null; return !empty($default->id) ? $default->id : null;
} }
} }

View File

@ -17,16 +17,17 @@ defined('_JEXEC') or die;
class WeblinksModelCategories extends JModelList class WeblinksModelCategories extends JModelList
{ {
/** /**
* Model context string. * Context string for the model type. This is used to handle uniqueness
* when dealing with the getStoreId() method and caching data structures.
* *
* @var string * @var string
*/ */
public $_context = 'com_weblinks.categories'; protected $context = 'com_weblinks.categories';
/** /**
* The category context (allows other extensions to derived from this model). * The category context (allows other extensions to derived from this model).
* *
* @var string * @var string
*/ */
protected $_extension = 'com_weblinks'; protected $_extension = 'com_weblinks';

View File

@ -9,6 +9,8 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/** /**
* Weblinks Component Weblink Model * Weblinks Component Weblink Model
* *
@ -35,7 +37,8 @@ class WeblinksModelCategory extends JModelList
* Constructor. * Constructor.
* *
* @param array An optional associative array of configuration settings. * @param array An optional associative array of configuration settings.
* @see JController *
* @see JControllerLegacy
* @since 1.6 * @since 1.6
*/ */
public function __construct($config = array()) public function __construct($config = array())
@ -56,16 +59,14 @@ class WeblinksModelCategory extends JModelList
/** /**
* The category that applies. * The category that applies.
* *
* @access protected * @var object
* @var object
*/ */
protected $_category = null; protected $_category = null;
/** /**
* The list of other weblink categories. * The list of other weblink categories.
* *
* @access protected * @var array
* @var array
*/ */
protected $_categories = null; protected $_categories = null;
@ -84,10 +85,11 @@ class WeblinksModelCategory extends JModelList
{ {
if (!isset($this->_params)) if (!isset($this->_params))
{ {
$params = new JRegistry; $params = new Registry;
$params->loadString($item->params); $params->loadString($item->params);
$item->params = $params; $item->params = $params;
} }
// Get the tags // Get the tags
$item->tags = new JHelperTags; $item->tags = new JHelperTags;
$item->tags->getItemTags('com_weblinks.weblink', $item->id); $item->tags->getItemTags('com_weblinks.weblink', $item->id);
@ -97,15 +99,15 @@ class WeblinksModelCategory extends JModelList
} }
/** /**
* Method to build an SQL query to load the list data. * Method to get a JDatabaseQuery object for retrieving the data set from a database.
*
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set.
* *
* @return string An SQL query
* @since 1.6 * @since 1.6
*/ */
protected function getListQuery() protected function getListQuery()
{ {
$user = JFactory::getUser(); $groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
$groups = implode(',', $user->getAuthorisedViewLevels());
// Create a new query object. // Create a new query object.
$db = $this->getDbo(); $db = $this->getDbo();
@ -123,8 +125,9 @@ class WeblinksModelCategory extends JModelList
->join('LEFT', '#__categories AS c ON c.id = a.catid') ->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' . $groups . ')'); ->where('c.access IN (' . $groups . ')');
//Filter by published category // Filter by published category
$cpublished = $this->getState('filter.c.published'); $cpublished = $this->getState('filter.c.published');
if (is_numeric($cpublished)) if (is_numeric($cpublished))
{ {
$query->where('c.published = ' . (int) $cpublished); $query->where('c.published = ' . (int) $cpublished);
@ -134,24 +137,24 @@ class WeblinksModelCategory extends JModelList
// Join over the users for the author and modified_by names. // Join over the users for the author and modified_by names.
$query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author") $query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author")
->select("ua.email AS author_email") ->select("ua.email AS author_email")
->join('LEFT', '#__users AS ua ON ua.id = a.created_by') ->join('LEFT', '#__users AS ua ON ua.id = a.created_by')
->join('LEFT', '#__users AS uam ON uam.id = a.modified_by'); ->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
// Filter by state // Filter by state
$state = $this->getState('filter.state'); $state = $this->getState('filter.state');
if (is_numeric($state)) if (is_numeric($state))
{ {
$query->where('a.state = ' . (int) $state); $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'); $query->where('a.state != -2');
// Filter by start and end dates. // Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate()); $nullDate = $db->quote($db->getNullDate());
$date = JFactory::getDate(); $nowDate = $db->quote(JFactory::getDate()->toSql());
$nowDate = $db->quote($date->toSql());
if ($this->getState('filter.publish_date')) if ($this->getState('filter.publish_date'))
{ {
@ -167,6 +170,7 @@ class WeblinksModelCategory extends JModelList
// Filter by search in title // Filter by search in title
$search = $this->getState('list.filter'); $search = $this->getState('list.filter');
if (!empty($search)) if (!empty($search))
{ {
$search = $db->quote('%' . $db->escape($search, true) . '%'); $search = $db->quote('%' . $db->escape($search, true) . '%');
@ -174,7 +178,12 @@ class WeblinksModelCategory extends JModelList
} }
// Add the list ordering clause. // Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))); $query->order(
$db->escape(
$this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')
)
);
return $query; return $query;
} }
@ -201,23 +210,28 @@ class WeblinksModelCategory extends JModelList
$this->setState('list.filter', $app->input->getString('filter-search')); $this->setState('list.filter', $app->input->getString('filter-search'));
$orderCol = $app->input->get('filter_order', 'ordering'); $orderCol = $app->input->get('filter_order', 'ordering');
if (!in_array($orderCol, $this->filter_fields)) if (!in_array($orderCol, $this->filter_fields))
{ {
$orderCol = 'ordering'; $orderCol = 'ordering';
} }
$this->setState('list.ordering', $orderCol); $this->setState('list.ordering', $orderCol);
$listOrder = $app->input->get('filter_order_Dir', 'ASC'); $listOrder = $app->input->get('filter_order_Dir', 'ASC');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{ {
$listOrder = 'ASC'; $listOrder = 'ASC';
} }
$this->setState('list.direction', $listOrder); $this->setState('list.direction', $listOrder);
$id = $app->input->get('id', 0, 'int'); $id = $app->input->get('id', 0, 'int');
$this->setState('category.id', $id); $this->setState('category.id', $id);
$user = JFactory::getUser(); $user = JFactory::getUser();
if ((!$user->authorise('core.edit.state', 'com_weblinks')) && (!$user->authorise('core.edit', 'com_weblinks'))) 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.
@ -236,9 +250,8 @@ class WeblinksModelCategory extends JModelList
/** /**
* Method to get category data for the current category * Method to get category data for the current category
* *
* @param integer An optional ID
*
* @return object * @return object
*
* @since 1.5 * @since 1.5
*/ */
public function getCategory() public function getCategory()
@ -248,7 +261,7 @@ class WeblinksModelCategory extends JModelList
$app = JFactory::getApplication(); $app = JFactory::getApplication();
$menu = $app->getMenu(); $menu = $app->getMenu();
$active = $menu->getActive(); $active = $menu->getActive();
$params = new JRegistry; $params = new Registry;
if ($active) if ($active)
{ {
@ -256,17 +269,22 @@ class WeblinksModelCategory extends JModelList
} }
$options = array(); $options = array();
$options['countItems'] = $params->get('show_cat_num_links_cat', 1) || $params->get('show_empty_categories', 0); $options['countItems'] = $params->get('show_cat_num_links_cat', 1)
|| $params->get('show_empty_categories', 0);
$categories = JCategories::getInstance('Weblinks', $options); $categories = JCategories::getInstance('Weblinks', $options);
$this->_item = $categories->get($this->getState('category.id', 'root')); $this->_item = $categories->get($this->getState('category.id', 'root'));
if (is_object($this->_item)) if (is_object($this->_item))
{ {
$this->_children = $this->_item->getChildren(); $this->_children = $this->_item->getChildren();
$this->_parent = false; $this->_parent = false;
if ($this->_item->getParent()) if ($this->_item->getParent())
{ {
$this->_parent = $this->_item->getParent(); $this->_parent = $this->_item->getParent();
} }
$this->_rightsibling = $this->_item->getSibling(); $this->_rightsibling = $this->_item->getSibling();
$this->_leftsibling = $this->_item->getSibling(false); $this->_leftsibling = $this->_item->getSibling(false);
} }
@ -339,20 +357,19 @@ class WeblinksModelCategory extends JModelList
/** /**
* Increment the hit counter for the category. * Increment the hit counter for the category.
* *
* @param int $pk Optional primary key of the category to increment. * @param integer $pk Optional primary key of the category to increment.
* *
* @return boolean True if successful; false otherwise and internal error set. * @return boolean True if successful; false otherwise and internal error set.
* *
* @since 3.2 * @since 3.2
*/ */
public function hit($pk = 0) public function hit($pk = 0)
{ {
$input = JFactory::getApplication()->input; $hitcount = JFactory::getApplication()->input->getInt('hitcount', 1);
$hitcount = $input->getInt('hitcount', 1);
if ($hitcount) if ($hitcount)
{ {
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id'); $pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
$table = JTable::getInstance('Category', 'JTable'); $table = JTable::getInstance('Category', 'JTable');
$table->load($pk); $table->load($pk);
$table->hit($pk); $table->hit($pk);

View File

@ -9,7 +9,7 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
require_once JPATH_COMPONENT_ADMINISTRATOR.'/models/weblink.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/weblink.php';
/** /**
* Weblinks model. * Weblinks model.
@ -21,14 +21,16 @@ class WeblinksModelForm extends WeblinksModelWeblink
/** /**
* Model typeAlias string. Used for version history. * Model typeAlias string. Used for version history.
* *
* @var string * @var string
* @since 3.2
*/ */
public $typeAlias = 'com_weblinks.weblink'; public $typeAlias = 'com_weblinks.weblink';
/** /**
* Get the return URL. * Get the return URL.
* *
* @return string The return URL. * @return string The return URL.
*
* @since 1.6 * @since 1.6
*/ */
public function getReturnPage() public function getReturnPage()
@ -50,10 +52,11 @@ class WeblinksModelForm extends WeblinksModelWeblink
// Load state from the request. // Load state from the request.
$pk = $app->input->getInt('w_id'); $pk = $app->input->getInt('w_id');
$this->setState('weblink.id', $pk); $this->setState('weblink.id', $pk);
// Add compatibility variable for default naming conventions. // Add compatibility variable for default naming conventions.
$this->setState('form.id', $pk); $this->setState('form.id', $pk);
$categoryId = $app->input->getInt('catid'); $categoryId = $app->input->getInt('catid');
$this->setState('weblink.catid', $categoryId); $this->setState('weblink.catid', $categoryId);
$return = $app->input->get('return', null, 'base64'); $return = $app->input->get('return', null, 'base64');
@ -66,7 +69,7 @@ class WeblinksModelForm extends WeblinksModelWeblink
$this->setState('return_page', base64_decode($return)); $this->setState('return_page', base64_decode($return));
// Load the parameters. // Load the parameters.
$params = $app->getParams(); $params = $app->getParams();
$this->setState('params', $params); $this->setState('params', $params);
$this->setState('layout', $app->input->getString('layout')); $this->setState('layout', $app->input->getString('layout'));

View File

@ -21,8 +21,7 @@ class WeblinksModelWeblink extends JModelItem
/** /**
* Model context string. * Model context string.
* *
* @access protected * @var string
* @var string
*/ */
protected $_context = 'com_weblinks.weblink'; protected $_context = 'com_weblinks.weblink';
@ -98,7 +97,9 @@ class WeblinksModelWeblink extends JModelItem
* @param type The table type to instantiate * @param type The table type to instantiate
* @param string A prefix for the table class name. Optional. * @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional. * @param array Configuration array for model. Optional.
*
* @return JTable A database object * @return JTable A database object
*
* @since 1.6 * @since 1.6
*/ */
public function getTable($type = 'Weblink', $prefix = 'WeblinksTable', $config = array()) public function getTable($type = 'Weblink', $prefix = 'WeblinksTable', $config = array())
@ -121,6 +122,7 @@ class WeblinksModelWeblink extends JModelItem
} }
$weblink = $this->getTable('Weblink', 'WeblinksTable'); $weblink = $this->getTable('Weblink', 'WeblinksTable');
return $weblink->hit($id); return $weblink->hit($id);
} }
} }

View File

@ -17,9 +17,7 @@ JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_weblinks/models', 'We
/** /**
* Helper for mod_weblinks * Helper for mod_weblinks
* *
* @package Joomla.Site * @since 1.5
* @subpackage mod_weblinks
* @since 1.5.0
*/ */
class ModWeblinksHelper class ModWeblinksHelper
{ {
@ -30,7 +28,7 @@ class ModWeblinksHelper
* *
* @return mixed Null if no weblinks based on input parameters else an array containing all the weblinks. * @return mixed Null if no weblinks based on input parameters else an array containing all the weblinks.
* *
* @since 1.5.0 * @since 1.5
**/ **/
public static function getList(&$params) public static function getList(&$params)
{ {
@ -108,9 +106,7 @@ class ModWeblinksHelper
return $items; return $items;
} }
else
{ return;
return;
}
} }
} }

View File

@ -9,6 +9,8 @@
defined('JPATH_BASE') or die; defined('JPATH_BASE') or die;
use Joomla\Registry\Registry;
// Load the base adapter. // Load the base adapter.
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php'; require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
@ -251,11 +253,11 @@ class PlgFinderWeblinks extends FinderIndexerAdapter
$item->setLanguage(); $item->setLanguage();
// Initialise the item parameters. // Initialise the item parameters.
$registry = new JRegistry; $registry = new Registry;
$registry->loadString($item->params); $registry->loadString($item->params);
$item->params = $registry; $item->params = $registry;
$registry = new JRegistry; $registry = new Registry;
$registry->loadString($item->metadata); $registry->loadString($item->metadata);
$item->metadata = $registry; $item->metadata = $registry;

View File

@ -60,9 +60,7 @@ class PlgSearchWeblinks extends JPlugin
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{ {
$db = JFactory::getDbo(); $db = JFactory::getDbo();
$app = JFactory::getApplication(); $groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$searchText = $text; $searchText = $text;
@ -185,7 +183,7 @@ class PlgSearchWeblinks extends JPlugin
->order($order); ->order($order);
// Filter by language. // Filter by language.
if ($app->isSite() && JLanguageMultilang::isEnabled()) if (JFactory::getApplication()->isSite() && JLanguageMultilang::isEnabled())
{ {
$tag = JFactory::getLanguage()->getTag(); $tag = JFactory::getLanguage()->getTag();
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')') $query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')