32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2025-04-01 11:31:52 +00:00

Move to namespaces (#384)

* Make it joomla 4 compatible

* Joomla 4 compatibility

* Move to dispatcher

* Move controller.php to DisplayController

* Define default view for DisplayController

* Move the model weblinks.php to WeblinksModel

* Move the view weblinks list view view.html.php to HtmlView.php

* Move the view templates like default.php to the right position

* Move the weblinks controller weblins.php to WeblinksController.php

* Move the weblink model weblink.php to WeblinkModel.php

* Remove the get table function in the WeblinkModel

* Moved the table weblink.php to WeblinkTable.php

* Moved the controller weblink.php to WeblinkController.php

* Moved the web link form view view.html.php to HtmlView.php

* Move the weblink layouts to the right folder

* Convert list template to Bootstrap 4

* Convert form layout to Bootstrap 4

* Move forms to root folder

* Namespace field

* Calling the parent check function in the table

* Adapt travis file

* Pass factory to parent class
This commit is contained in:
Allon Moritz 2018-02-19 10:44:55 +01:00 committed by Yves Hoppe
parent 8574a4f3cf
commit 2247d9ba4d
24 changed files with 227 additions and 191 deletions

View File

@ -8,14 +8,13 @@ env:
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
- php: 5.5
- php: 5.6
env: RUN_PHPCS="yes"
- php: 7.0 - php: 7.0
env: RUN_PHPCS="yes"
sudo: true sudo: true
addons: addons:
firefox: "47.0.1" firefox: "47.0.1"
- php: 7.1 - php: 7.1
- php: 7.2
- php: hhvm - php: hhvm
sudo: true sudo: true
dist: trusty dist: trusty
@ -66,5 +65,5 @@ script:
# System tests (Codeception) # System tests (Codeception)
- mv tests/acceptance.suite.dist.yml tests/acceptance.suite.yml - mv tests/acceptance.suite.dist.yml tests/acceptance.suite.yml
- vendor/bin/robo run:tests --use-htaccess - vendor/bin/robo run:tests --use-htaccess
# Run phpcs on PHP 5.6 against weblinks source # Run phpcs on PHP 7.0 against weblinks source
- if [[ $RUN_PHPCS == "yes" ]]; then vendor/bin/phpcs --report=full --extensions=php -p --standard=tests/joomla/build/phpcs/Joomla ./src; fi - if [[ $RUN_PHPCS == "yes" ]]; then vendor/bin/phpcs --report=full --extensions=php -p --standard=tests/joomla/build/phpcs/Joomla ./src; fi

View File

@ -7,15 +7,29 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace Joomla\Component\Weblinks\Administrator\Controller;
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Router\Route;
/** /**
* Weblinks Main Controller * Weblinks Main Controller
* *
* @since 1.5 * @since 1.5
*/ */
class WeblinksController extends JControllerLegacy class DisplayController extends BaseController
{ {
/**
* The default view.
*
* @var string
* @since 1.6
*/
protected $default_view = 'weblinks';
/** /**
* Method to display a view. * Method to display a view.
* *
@ -39,9 +53,9 @@ class WeblinksController extends JControllerLegacy
if ($view == 'weblink' && $layout == 'edit' && !$this->checkEditId('com_weblinks.edit.weblink', $id)) if ($view == 'weblink' && $layout == 'edit' && !$this->checkEditId('com_weblinks.edit.weblink', $id))
{ {
// Somehow the person just went to the form - we don't allow that. // Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error'); $this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks', false)); $this->setRedirect(Route::_('index.php?option=com_weblinks&view=weblinks', false));
return false; return false;
} }

View File

@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace Joomla\Component\Weblinks\Administrator\Controller;
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper; use Joomla\Utilities\ArrayHelper;
@ -16,7 +18,7 @@ use Joomla\Utilities\ArrayHelper;
* *
* @since 1.6 * @since 1.6
*/ */
class WeblinksControllerWeblink extends JControllerForm class WeblinkController extends \JControllerForm
{ {
/** /**
* Method override to check if you can add a new record. * Method override to check if you can add a new record.
@ -35,7 +37,7 @@ class WeblinksControllerWeblink extends JControllerForm
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 = JFactory::getUser()->authorise('core.create', $this->option . '.category.' . $categoryId); $allow = \JFactory::getUser()->authorise('core.create', $this->option . '.category.' . $categoryId);
} }
if ($allow !== null) if ($allow !== null)
@ -76,7 +78,7 @@ class WeblinksControllerWeblink extends JControllerForm
return false; return false;
} }
$user = JFactory::getUser(); $user = \JFactory::getUser();
// Check if can edit own core.edit.own. // Check if can edit own core.edit.own.
$canEditOwn = $user->authorise('core.edit.own', $this->option . '.category.' . (int) $item->catid) && $item->created_by == $user->id; $canEditOwn = $user->authorise('core.edit.own', $this->option . '.category.' . (int) $item->catid) && $item->created_by == $user->id;
@ -96,13 +98,13 @@ class WeblinksControllerWeblink extends JControllerForm
*/ */
public function batch($model = null) public function batch($model = null)
{ {
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); \JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN'));
// Set the model // Set the model
$model = $this->getModel('Weblink', '', array()); $model = $this->getModel('Weblink', '', array());
// Preset the redirect // Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks' . $this->getRedirectToListAppend(), false)); $this->setRedirect(\JRoute::_('index.php?option=com_weblinks&view=weblinks' . $this->getRedirectToListAppend(), false));
return parent::batch($model); return parent::batch($model);
} }
@ -117,13 +119,13 @@ class WeblinksControllerWeblink extends JControllerForm
* *
* @since 1.6 * @since 1.6
*/ */
protected function postSaveHook(JModelLegacy $model, $validData = array()) protected function postSaveHook(\JModelLegacy $model, $validData = array())
{ {
$task = $this->getTask(); $task = $this->getTask();
if ($task == 'save') if ($task == 'save')
{ {
$this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks', false)); $this->setRedirect(\JRoute::_('index.php?option=com_weblinks&view=weblinks', false));
} }
} }
} }

View File

@ -7,14 +7,18 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace Joomla\Component\Weblinks\Administrator\Controller;
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\AdminController;
/** /**
* Weblinks list controller class. * Weblinks list controller class.
* *
* @since 1.6 * @since 1.6
*/ */
class WeblinksControllerWeblinks extends JControllerAdmin class WeblinksController extends AdminController
{ {
/** /**
* Proxy for getModel * Proxy for getModel
@ -27,7 +31,7 @@ class WeblinksControllerWeblinks extends JControllerAdmin
* *
* @since 1.6 * @since 1.6
*/ */
public function getModel($name = 'Weblink', $prefix = 'WeblinksModel', $config = array('ignore_request' => true)) public function getModel($name = 'Weblink', $prefix = 'Administrator', $config = array('ignore_request' => true))
{ {
return parent::getModel($name, $prefix, $config); return parent::getModel($name, $prefix, $config);
} }

View File

@ -6,13 +6,17 @@
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace Joomla\Component\Weblinks\Administrator\Field\Modal;
defined('JPATH_BASE') or die; defined('JPATH_BASE') or die;
/** /**
* Supports a modal weblink picker. * Supports a modal weblink picker.
* *
* @since __DEPLOY_VERSION__ * @since __DEPLOY_VERSION__
*/ */
class JFormFieldModal_Weblink extends JFormField class WeblinkField extends \JFormField
{ {
/** /**
* The form field type. * The form field type.
@ -37,7 +41,7 @@ class JFormFieldModal_Weblink extends JFormField
$allowSelect = ((string) $this->element['select'] != 'false'); $allowSelect = ((string) $this->element['select'] != 'false');
// Load language // Load language
JFactory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR); \JFactory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR);
// The active weblink id field. // The active weblink id field.
$value = (int) $this->value > 0 ? (int) $this->value : ''; $value = (int) $this->value > 0 ? (int) $this->value : '';
@ -46,8 +50,8 @@ class JFormFieldModal_Weblink extends JFormField
$modalId = 'Weblink_' . $this->id; $modalId = 'Weblink_' . $this->id;
// Add the modal field script to the document head. // Add the modal field script to the document head.
JHtml::_('jquery.framework'); \JHtml::_('jquery.framework');
JHtml::_('script', 'system/modal-fields.js', array('version' => 'auto', 'relative' => true)); \JHtml::_('script', 'system/modal-fields.js', array('version' => 'auto', 'relative' => true));
// Script to proxy the select modal function to the modal-fields.js file. // Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect) if ($allowSelect)
@ -61,7 +65,7 @@ class JFormFieldModal_Weblink extends JFormField
if (!isset($scriptSelect[$this->id])) if (!isset($scriptSelect[$this->id]))
{ {
JFactory::getDocument()->addScriptDeclaration(" \JFactory::getDocument()->addScriptDeclaration("
function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, language) { function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, language) {
window.processModalSelect('Weblink', '" . $this->id . "', id, title, catid, object, url, language); window.processModalSelect('Weblink', '" . $this->id . "', id, title, catid, object, url, language);
} }
@ -71,9 +75,9 @@ class JFormFieldModal_Weblink extends JFormField
} }
// Setup variables for display. // Setup variables for display.
$linkWeblinks = 'index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; $linkWeblinks = 'index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&' . \JSession::getFormToken() . '=1';
$linkWeblink = 'index.php?option=com_weblinks&view=weblink&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; $linkWeblink = 'index.php?option=com_weblinks&view=weblink&layout=modal&tmpl=component&' . \JSession::getFormToken() . '=1';
$modalTitle = JText::_('COM_WEBLINKS_CHANGE_WEBLINK'); $modalTitle = \JText::_('COM_WEBLINKS_CHANGE_WEBLINK');
if (isset($this->element['language'])) if (isset($this->element['language']))
{ {
@ -88,7 +92,7 @@ class JFormFieldModal_Weblink extends JFormField
if ($value) if ($value)
{ {
$db = JFactory::getDbo(); $db = \JFactory::getDbo();
$query = $db->getQuery(true) $query = $db->getQuery(true)
->select($db->quoteName('title')) ->select($db->quoteName('title'))
->from($db->quoteName('#__weblinks')) ->from($db->quoteName('#__weblinks'))
@ -98,12 +102,12 @@ class JFormFieldModal_Weblink extends JFormField
{ {
$title = $db->loadResult(); $title = $db->loadResult();
} }
catch (RuntimeException $e) catch (\RuntimeException $e)
{ {
JError::raiseWarning(500, $e->getMessage()); \JError::raiseWarning(500, $e->getMessage());
} }
} }
$title = empty($title) ? JText::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); $title = empty($title) ? \JText::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// The current weblink display field. // The current weblink display field.
$html = '<span class="input-append">'; $html = '<span class="input-append">';
@ -118,8 +122,8 @@ class JFormFieldModal_Weblink extends JFormField
. ' data-toggle="modal"' . ' data-toggle="modal"'
. ' role="button"' . ' role="button"'
. ' href="#ModalSelect' . $modalId . '"' . ' href="#ModalSelect' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_WEBLINKS_CHANGE_WEBLINK') . '">' . ' title="' . \JHtml::tooltipText('COM_WEBLINKS_CHANGE_WEBLINK') . '">'
. '<span class="icon-file" aria-hidden="true"></span> ' . JText::_('JSELECT') . '<span class="icon-file" aria-hidden="true"></span> ' . \JText::_('JSELECT')
. '</a>'; . '</a>';
} }
// New weblink button // New weblink button
@ -131,8 +135,8 @@ class JFormFieldModal_Weblink extends JFormField
. ' data-toggle="modal"' . ' data-toggle="modal"'
. ' role="button"' . ' role="button"'
. ' href="#ModalNew' . $modalId . '"' . ' href="#ModalNew' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_WEBLINKS_NEW_WEBLINK') . '">' . ' title="' . \JHtml::tooltipText('COM_WEBLINKS_NEW_WEBLINK') . '">'
. '<span class="icon-new" aria-hidden="true"></span> ' . JText::_('JACTION_CREATE') . '<span class="icon-new" aria-hidden="true"></span> ' . \JText::_('JACTION_CREATE')
. '</a>'; . '</a>';
} }
// Edit weblink button // Edit weblink button
@ -144,8 +148,8 @@ class JFormFieldModal_Weblink extends JFormField
. ' data-toggle="modal"' . ' data-toggle="modal"'
. ' role="button"' . ' role="button"'
. ' href="#ModalEdit' . $modalId . '"' . ' href="#ModalEdit' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT_WEBLINK') . '">' . ' title="' . \JHtml::tooltipText('COM_WEBLINKS_EDIT_WEBLINK') . '">'
. '<span class="icon-edit" aria-hidden="true"></span> ' . JText::_('JACTION_EDIT') . '<span class="icon-edit" aria-hidden="true"></span> ' . \JText::_('JACTION_EDIT')
. '</a>'; . '</a>';
} }
// Clear weblink button // Clear weblink button
@ -156,7 +160,7 @@ class JFormFieldModal_Weblink extends JFormField
. ' id="' . $this->id . '_clear"' . ' id="' . $this->id . '_clear"'
. ' href="#"' . ' href="#"'
. ' onclick="window.processModalParent(\'' . $this->id . '\'); return false;">' . ' onclick="window.processModalParent(\'' . $this->id . '\'); return false;">'
. '<span class="icon-remove" aria-hidden="true"></span>' . JText::_('JCLEAR') . '<span class="icon-remove" aria-hidden="true"></span>' . \JText::_('JCLEAR')
. '</a>'; . '</a>';
} }
$html .= '</span>'; $html .= '</span>';
@ -164,7 +168,7 @@ class JFormFieldModal_Weblink extends JFormField
// Select weblink modal // Select weblink modal
if ($allowSelect) if ($allowSelect)
{ {
$html .= JHtml::_( $html .= \JHtml::_(
'bootstrap.renderModal', 'bootstrap.renderModal',
'ModalSelect' . $modalId, 'ModalSelect' . $modalId,
array( array(
@ -174,7 +178,7 @@ class JFormFieldModal_Weblink extends JFormField
'width' => '800px', 'width' => '800px',
'bodyHeight' => '70', 'bodyHeight' => '70',
'modalWidth' => '80', 'modalWidth' => '80',
'footer' => '<a role="button" class="btn" data-dismiss="modal" aria-hidden="true">' . JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>', 'footer' => '<a role="button" class="btn" data-dismiss="modal" aria-hidden="true">' . \JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>',
) )
); );
} }
@ -182,7 +186,7 @@ class JFormFieldModal_Weblink extends JFormField
// New weblink modal // New weblink modal
if ($allowNew) if ($allowNew)
{ {
$html .= JHtml::_( $html .= \JHtml::_(
'bootstrap.renderModal', 'bootstrap.renderModal',
'ModalNew' . $modalId, 'ModalNew' . $modalId,
array( array(
@ -197,13 +201,13 @@ class JFormFieldModal_Weblink extends JFormField
'modalWidth' => '80', 'modalWidth' => '80',
'footer' => '<a role="button" class="btn" aria-hidden="true"' 'footer' => '<a role="button" class="btn" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">' . ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>' . \JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>'
. '<a role="button" class="btn btn-primary" aria-hidden="true"' . '<a role="button" class="btn btn-primary" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'save\', \'weblink-form\'); return false;">' . ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'save\', \'weblink-form\'); return false;">'
. JText::_('JSAVE') . '</a>' . \JText::_('JSAVE') . '</a>'
. '<a role="button" class="btn btn-success" aria-hidden="true"' . '<a role="button" class="btn btn-success" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'apply\', \'weblink-form\'); return false;">' . ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'apply\', \'weblink-form\'); return false;">'
. JText::_('JAPPLY') . '</a>', . \JText::_('JAPPLY') . '</a>',
) )
); );
} }
@ -211,11 +215,11 @@ class JFormFieldModal_Weblink extends JFormField
// Edit weblink modal // Edit weblink modal
if ($allowEdit) if ($allowEdit)
{ {
$html .= JHtml::_( $html .= \JHtml::_(
'bootstrap.renderModal', 'bootstrap.renderModal',
'ModalEdit' . $modalId, 'ModalEdit' . $modalId,
array( array(
'title' => JText::_('COM_WEBLINKS_EDIT_WEBLINK'), 'title' => \JText::_('COM_WEBLINKS_EDIT_WEBLINK'),
'backdrop' => 'static', 'backdrop' => 'static',
'keyboard' => false, 'keyboard' => false,
'closeButton' => false, 'closeButton' => false,
@ -226,20 +230,20 @@ class JFormFieldModal_Weblink extends JFormField
'modalWidth' => '80', 'modalWidth' => '80',
'footer' => '<a role="button" class="btn" aria-hidden="true"' 'footer' => '<a role="button" class="btn" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">' . ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>' . \JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>'
. '<a role="button" class="btn btn-primary" aria-hidden="true"' . '<a role="button" class="btn btn-primary" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'save\', \'weblink-form\'); return false;">' . ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'save\', \'weblink-form\'); return false;">'
. JText::_('JSAVE') . '</a>' . \JText::_('JSAVE') . '</a>'
. '<a role="button" class="btn btn-success" aria-hidden="true"' . '<a role="button" class="btn btn-success" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'apply\', \'weblink-form\'); return false;">' . ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'apply\', \'weblink-form\'); return false;">'
. JText::_('JAPPLY') . '</a>', . \JText::_('JAPPLY') . '</a>',
) )
); );
} }
// Note: class='required' for client side validation. // Note: class='required' for client side validation.
$class = $this->required ? ' class="required modal-value"' : ''; $class = $this->required ? ' class="required modal-value"' : '';
$html .= '<input type="hidden" id="' . $this->id . '_id" ' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name $html .= '<input type="hidden" id="' . $this->id . '_id" ' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
. '" data-text="' . htmlspecialchars(JText::_('COM_WEBLINKS_SELECT_A_WEBLINK', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />'; . '" data-text="' . htmlspecialchars(\JText::_('COM_WEBLINKS_SELECT_A_WEBLINK', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';
return $html; return $html;
} }

View File

@ -7,18 +7,20 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace Joomla\Component\Weblinks\Administrator\Model;
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php'); \JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
/** /**
* Weblinks model. * Weblinks model.
* *
* @since 1.5 * @since 1.5
*/ */
class WeblinksModelWeblink extends JModelAdmin class WeblinkModel extends \JModelAdmin
{ {
/** /**
* The type alias for this content type. * The type alias for this content type.
@ -64,7 +66,7 @@ class WeblinksModelWeblink extends JModelAdmin
if ($record->catid) if ($record->catid)
{ {
return JFactory::getUser()->authorise('core.delete', 'com_weblinks.category.' . (int) $record->catid); return \JFactory::getUser()->authorise('core.delete', 'com_weblinks.category.' . (int) $record->catid);
} }
return parent::canDelete($record); return parent::canDelete($record);
@ -84,28 +86,12 @@ class WeblinksModelWeblink extends JModelAdmin
{ {
if (!empty($record->catid)) if (!empty($record->catid))
{ {
return JFactory::getUser()->authorise('core.edit.state', 'com_weblinks.category.' . (int) $record->catid); return \JFactory::getUser()->authorise('core.edit.state', 'com_weblinks.category.' . (int) $record->catid);
} }
return parent::canEditState($record); return parent::canEditState($record);
} }
/**
* Method to get a table object, load it if necessary.
*
* @param string $type The table name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A JTable object
*
* @since 1.6
*/
public function getTable($type = 'Weblink', $prefix = 'WeblinksTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/** /**
* Abstract method for getting the form from the model. * Abstract method for getting the form from the model.
* *
@ -168,7 +154,7 @@ class WeblinksModelWeblink extends JModelAdmin
protected function loadFormData() protected function loadFormData()
{ {
// Check the session for previously entered form data. // Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_weblinks.edit.weblink.data', array()); $data = \JFactory::getApplication()->getUserState('com_weblinks.edit.weblink.data', array());
if (empty($data)) if (empty($data))
{ {
@ -177,7 +163,7 @@ class WeblinksModelWeblink extends JModelAdmin
// Prime some default values. // Prime some default values.
if ($this->getState('weblink.id') == 0) if ($this->getState('weblink.id') == 0)
{ {
$app = JFactory::getApplication(); $app = \JFactory::getApplication();
$data->set('catid', $app->input->get('catid', $app->getUserState('com_weblinks.weblinks.filter.category_id'), 'int')); $data->set('catid', $app->input->get('catid', $app->getUserState('com_weblinks.weblinks.filter.category_id'), 'int'));
} }
} }
@ -211,7 +197,7 @@ class WeblinksModelWeblink extends JModelAdmin
$item->images = $registry->toArray(); $item->images = $registry->toArray();
// Load associated web links items // Load associated web links items
$assoc = JLanguageAssociations::isEnabled(); $assoc = \JLanguageAssociations::isEnabled();
if ($assoc) if ($assoc)
{ {
@ -219,7 +205,7 @@ class WeblinksModelWeblink extends JModelAdmin
if ($item->id != null) if ($item->id != null)
{ {
$associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $item->id); $associations = \JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $item->id);
foreach ($associations as $tag => $association) foreach ($associations as $tag => $association)
{ {
@ -230,7 +216,7 @@ class WeblinksModelWeblink extends JModelAdmin
if (!empty($item->id)) if (!empty($item->id))
{ {
$item->tags = new JHelperTags; $item->tags = new \JHelperTags;
$item->tags->getTagIds($item->id, 'com_weblinks.weblink'); $item->tags->getTagIds($item->id, 'com_weblinks.weblink');
$item->metadata['tags'] = $item->tags; $item->metadata['tags'] = $item->tags;
} }
@ -250,15 +236,15 @@ class WeblinksModelWeblink extends JModelAdmin
*/ */
protected function prepareTable($table) protected function prepareTable($table)
{ {
$date = JFactory::getDate(); $date = \JFactory::getDate();
$user = JFactory::getUser(); $user = \JFactory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = JApplicationHelper::stringURLSafe($table->alias); $table->alias = \JApplicationHelper::stringURLSafe($table->alias);
if (empty($table->alias)) if (empty($table->alias))
{ {
$table->alias = JApplicationHelper::stringURLSafe($table->title); $table->alias = \JApplicationHelper::stringURLSafe($table->title);
} }
if (empty($table->id)) if (empty($table->id))
@ -318,9 +304,9 @@ class WeblinksModelWeblink extends JModelAdmin
*/ */
public function save($data) public function save($data)
{ {
$app = JFactory::getApplication(); $app = \JFactory::getApplication();
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php'); \JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');
// Cast catid to integer for comparison // Cast catid to integer for comparison
$catid = (int) $data['catid']; $catid = (int) $data['catid'];
@ -328,7 +314,7 @@ class WeblinksModelWeblink extends JModelAdmin
// Check if New Category exists // Check if New Category exists
if ($catid > 0) if ($catid > 0)
{ {
$catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_weblinks'); $catid = \CategoriesHelper::validateCategoryId($data['catid'], 'com_weblinks');
} }
// Save New Category // Save New Category
@ -342,7 +328,7 @@ class WeblinksModelWeblink extends JModelAdmin
$table['published'] = 1; $table['published'] = 1;
// Create new category and get catid back // Create new category and get catid back
$data['catid'] = CategoriesHelper::createCategory($table); $data['catid'] = \CategoriesHelper::createCategory($table);
} }
// Alter the title for save as copy // Alter the title for save as copy
@ -377,10 +363,10 @@ class WeblinksModelWeblink extends JModelAdmin
{ {
if ($name == $table->title) if ($name == $table->title)
{ {
$name = JString::increment($name); $name = \JString::increment($name);
} }
$alias = JString::increment($alias, 'dash'); $alias = \JString::increment($alias, 'dash');
} }
return array($name, $alias); return array($name, $alias);
@ -397,7 +383,7 @@ class WeblinksModelWeblink extends JModelAdmin
* *
* @since 3.6.0 * @since 3.6.0
*/ */
protected function preprocessForm(JForm $form, $data, $group = 'content') protected function preprocessForm(\JForm $form, $data, $group = 'content')
{ {
if ($this->canCreateCategory()) if ($this->canCreateCategory())
{ {
@ -405,13 +391,13 @@ class WeblinksModelWeblink extends JModelAdmin
} }
// Association weblinks items // Association weblinks items
if (JLanguageAssociations::isEnabled()) if (\JLanguageAssociations::isEnabled())
{ {
$languages = JLanguageHelper::getContentLanguages(false, true, null, 'ordering', 'asc'); $languages = \JLanguageHelper::getContentLanguages(false, true, null, 'ordering', 'asc');
if (count($languages) > 1) if (count($languages) > 1)
{ {
$addform = new SimpleXMLElement('<form />'); $addform = new \SimpleXMLElement('<form />');
$fields = $addform->addChild('fields'); $fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations'); $fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset'); $fieldset = $fields->addChild('fieldset');
@ -429,6 +415,7 @@ class WeblinksModelWeblink extends JModelAdmin
$field->addAttribute('new', 'true'); $field->addAttribute('new', 'true');
$field->addAttribute('edit', 'true'); $field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true'); $field->addAttribute('clear', 'true');
$field->addAttribute('addfieldprefix', 'Joomla\\Component\\Weblinks\\Administrator\\Field');
} }
$form->load($addform, false); $form->load($addform, false);
@ -447,6 +434,6 @@ class WeblinksModelWeblink extends JModelAdmin
*/ */
private function canCreateCategory() private function canCreateCategory()
{ {
return JFactory::getUser()->authorise('core.create', 'com_weblinks'); return \JFactory::getUser()->authorise('core.create', 'com_weblinks');
} }
} }

View File

@ -7,24 +7,30 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace Joomla\Component\Weblinks\Administrator\Model;
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
/** /**
* Methods supporting a list of weblink records. * Methods supporting a list of weblink records.
* *
* @since 1.6 * @since 1.6
*/ */
class WeblinksModelWeblinks extends JModelList class WeblinksModel extends ListModel
{ {
/** /**
* Constructor. * Constructor.
* *
* @param array $config An optional associative array of configuration settings. * @param array $config An optional associative array of configuration settings.
* @param MVCFactoryInterface $factory The factory.
* *
* @see JControllerLegacy * @see JControllerLegacy
* @since 1.6 * @since 1.6
*/ */
public function __construct($config = array()) public function __construct($config = array(), MVCFactoryInterface $factory = null)
{ {
if (empty($config['filter_fields'])) if (empty($config['filter_fields']))
{ {
@ -53,7 +59,7 @@ class WeblinksModelWeblinks extends JModelList
'level', 'c.level', 'level', 'c.level',
); );
$assoc = JLanguageAssociations::isEnabled(); $assoc = \JLanguageAssociations::isEnabled();
if ($assoc) if ($assoc)
{ {
@ -61,7 +67,7 @@ class WeblinksModelWeblinks extends JModelList
} }
} }
parent::__construct($config); parent::__construct($config, $factory);
} }
/** /**
@ -77,7 +83,7 @@ class WeblinksModelWeblinks extends JModelList
*/ */
protected function populateState($ordering = 'a.title', $direction = 'asc') protected function populateState($ordering = 'a.title', $direction = 'asc')
{ {
$app = JFactory::getApplication(); $app = \JFactory::getApplication();
$forcedLanguage = $app->input->get('forcedLanguage', '', 'cmd'); $forcedLanguage = $app->input->get('forcedLanguage', '', 'cmd');
@ -103,7 +109,7 @@ class WeblinksModelWeblinks extends JModelList
$this->setState('filter.level', $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level', '', 'cmd')); $this->setState('filter.level', $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level', '', 'cmd'));
// Load the parameters. // Load the parameters.
$params = JComponentHelper::getParams('com_weblinks'); $params = \JComponentHelper::getParams('com_weblinks');
$this->setState('params', $params); $this->setState('params', $params);
// Force a language. // Force a language.
@ -155,7 +161,7 @@ class WeblinksModelWeblinks extends JModelList
// Create a new query object. // Create a new query object.
$db = $this->getDbo(); $db = $this->getDbo();
$query = $db->getQuery(true); $query = $db->getQuery(true);
$user = JFactory::getUser(); $user = \JFactory::getUser();
// Select the required fields from the table. // Select the required fields from the table.
$query->select( $query->select(
@ -185,7 +191,7 @@ class WeblinksModelWeblinks extends JModelList
->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON ' . $db->qn('c.id') . ' = ' . $db->qn('a.catid')); ->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON ' . $db->qn('c.id') . ' = ' . $db->qn('a.catid'));
// Join over the associations. // Join over the associations.
$assoc = JLanguageAssociations::isEnabled(); $assoc = \JLanguageAssociations::isEnabled();
if ($assoc) if ($assoc)
{ {

View File

@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace Joomla\Component\Weblinks\Administrator\Table;
defined('_JEXEC') or die; defined('_JEXEC') or die;
/** /**
@ -14,7 +16,7 @@ defined('_JEXEC') or die;
* *
* @since 1.5 * @since 1.5
*/ */
class WeblinksTableWeblink extends JTable class WeblinkTable extends \JTable
{ {
/** /**
* Ensure the params and metadata in json encoded in the bind method * Ensure the params and metadata in json encoded in the bind method
@ -38,8 +40,11 @@ class WeblinksTableWeblink extends JTable
// Set the published column alias // Set the published column alias
$this->setColumnAlias('published', 'state'); $this->setColumnAlias('published', 'state');
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_weblinks.weblink')); if (version_compare(JVERSION, '4.0', '<' ) == 1)
JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_weblinks.weblink')); {
\JTableObserverTags::createObserver($this, array('typeAlias' => 'com_weblinks.weblink'));
\JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_weblinks.weblink'));
}
} }
/** /**
@ -53,8 +58,8 @@ class WeblinksTableWeblink extends JTable
*/ */
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();
@ -91,17 +96,17 @@ class WeblinksTableWeblink extends JTable
} }
// Verify that the alias is unique // Verify that the alias is unique
$table = JTable::getInstance('Weblink', 'WeblinksTable'); $table = new WeblinkTable($this->getDbo());
if ($table->load(array('language' => $this->language, 'alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) if ($table->load(array('language' => $this->language, '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;
} }
// Convert IDN urls to punycode // Convert IDN urls to punycode
$this->url = JStringPunycode::urlToPunycode($this->url); $this->url = \JStringPunycode::urlToPunycode($this->url);
return parent::store($updateNulls); return parent::store($updateNulls);
} }
@ -115,9 +120,9 @@ class WeblinksTableWeblink extends JTable
*/ */
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;
} }
@ -125,7 +130,7 @@ class WeblinksTableWeblink extends JTable
// Check for valid name // Check for valid name
if (trim($this->title) == '') if (trim($this->title) == '')
{ {
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE')); $this->setError(\JText::_('COM_WEBLINKS_ERR_TABLES_TITLE'));
return false; return false;
} }
@ -144,7 +149,7 @@ class WeblinksTableWeblink extends JTable
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;
} }
@ -154,17 +159,17 @@ class WeblinksTableWeblink extends JTable
$this->alias = $this->title; $this->alias = $this->title;
} }
$this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language); $this->alias = \JApplicationHelper::stringURLSafe($this->alias, $this->language);
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 > $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;
} }
@ -177,7 +182,7 @@ class WeblinksTableWeblink extends JTable
{ {
// Array of characters to remove // Array of characters to remove
$bad_characters = array("\n", "\r", "\"", "<", ">"); $bad_characters = array("\n", "\r", "\"", "<", ">");
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey); $after_clean = \JString::str_ireplace($bad_characters, "", $this->metakey);
$keys = explode(',', $after_clean); $keys = explode(',', $after_clean);
$clean_keys = array(); $clean_keys = array();
@ -194,6 +199,6 @@ class WeblinksTableWeblink extends JTable
$this->metakey = implode(", ", $clean_keys); $this->metakey = implode(", ", $clean_keys);
} }
return true; return parent::check();
} }
} }

View File

@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace Joomla\Component\Weblinks\Administrator\View\Weblink;
defined('_JEXEC') or die; defined('_JEXEC') or die;
/** /**
@ -14,7 +16,7 @@ defined('_JEXEC') or die;
* *
* @since 1.5 * @since 1.5
*/ */
class WeblinksViewWeblink extends JViewLegacy class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
{ {
protected $state; protected $state;
@ -38,13 +40,13 @@ class WeblinksViewWeblink extends JViewLegacy
// Check for errors. // Check for errors.
if (count($errors = $this->get('Errors'))) if (count($errors = $this->get('Errors')))
{ {
JError::raiseError(500, implode("\n", $errors)); \JError::raiseError(500, implode("\n", $errors));
return false; return false;
} }
// If we are forcing a language in modal (used for associations). // If we are forcing a language in modal (used for associations).
if ($this->getLayout() === 'modal' && $forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) if ($this->getLayout() === 'modal' && $forcedLanguage = \JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd'))
{ {
// Set the language field to the forcedLanguage and disable changing it. // Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage); $this->form->setValue('language', null, $forcedLanguage);
@ -71,47 +73,47 @@ class WeblinksViewWeblink extends JViewLegacy
*/ */
protected function addToolbar() protected function addToolbar()
{ {
JFactory::getApplication()->input->set('hidemainmenu', true); \JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser(); $user = \JFactory::getUser();
$isNew = ($this->item->id == 0); $isNew = ($this->item->id == 0);
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
// Since we don't track these assets at the item level, use the category id. // Since we don't track these assets at the item level, use the category id.
$canDo = JHelperContent::getActions('com_weblinks', 'category', $this->item->catid); $canDo = \JHelperContent::getActions('com_weblinks', 'category', $this->item->catid);
JToolbarHelper::title($isNew ? JText::_('COM_WEBLINKS_MANAGER_WEBLINK_NEW') : JText::_('COM_WEBLINKS_MANAGER_WEBLINK_EDIT'), 'link weblinks'); \JToolbarHelper::title($isNew ? \JText::_('COM_WEBLINKS_MANAGER_WEBLINK_NEW') : \JText::_('COM_WEBLINKS_MANAGER_WEBLINK_EDIT'), 'link weblinks');
// If not checked out, can save the item. // If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit')||(count($user->getAuthorisedCategories('com_weblinks', 'core.create'))))) if (!$checkedOut && ($canDo->get('core.edit')||(count($user->getAuthorisedCategories('com_weblinks', 'core.create')))))
{ {
JToolbarHelper::apply('weblink.apply'); \JToolbarHelper::apply('weblink.apply');
JToolbarHelper::save('weblink.save'); \JToolbarHelper::save('weblink.save');
} }
if (!$checkedOut && (count($user->getAuthorisedCategories('com_weblinks', 'core.create')))) if (!$checkedOut && (count($user->getAuthorisedCategories('com_weblinks', 'core.create'))))
{ {
JToolbarHelper::save2new('weblink.save2new'); \JToolbarHelper::save2new('weblink.save2new');
} }
// If an existing item, can save to a copy. // If an existing item, can save to a copy.
if (!$isNew && (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)) if (!$isNew && (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0))
{ {
JToolbarHelper::save2copy('weblink.save2copy'); \JToolbarHelper::save2copy('weblink.save2copy');
} }
if (empty($this->item->id)) if (empty($this->item->id))
{ {
JToolbarHelper::cancel('weblink.cancel'); \JToolbarHelper::cancel('weblink.cancel');
} }
else else
{ {
if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit')) if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit'))
{ {
JToolbarHelper::versions('com_weblinks.weblink', $this->item->id); \JToolbarHelper::versions('com_weblinks.weblink', $this->item->id);
} }
JToolbarHelper::cancel('weblink.cancel', 'JTOOLBAR_CLOSE'); \JToolbarHelper::cancel('weblink.cancel', 'JTOOLBAR_CLOSE');
} }
JToolbarHelper::divider(); \JToolbarHelper::divider();
JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS_EDIT'); \JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS_EDIT');
} }
} }

View File

@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
namespace Joomla\Component\Weblinks\Administrator\View\Weblinks;
defined('_JEXEC') or die; defined('_JEXEC') or die;
/** /**
@ -14,7 +16,7 @@ defined('_JEXEC') or die;
* *
* @since 1.5 * @since 1.5
*/ */
class WeblinksViewWeblinks extends JViewLegacy class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
{ {
protected $items; protected $items;
@ -40,13 +42,13 @@ class WeblinksViewWeblinks extends JViewLegacy
// Modal layout doesn't need the submenu. // Modal layout doesn't need the submenu.
if ($this->getLayout() !== 'modal') if ($this->getLayout() !== 'modal')
{ {
WeblinksHelper::addSubmenu('weblinks'); \WeblinksHelper::addSubmenu('weblinks');
} }
// Check for errors. // Check for errors.
if (count($errors = $this->get('Errors'))) if (count($errors = $this->get('Errors')))
{ {
JError::raiseError(500, implode("\n", $errors)); \JError::raiseError(500, implode("\n", $errors));
return false; return false;
} }
@ -54,16 +56,16 @@ class WeblinksViewWeblinks extends JViewLegacy
if ($this->getLayout() !== 'modal') if ($this->getLayout() !== 'modal')
{ {
$this->addToolbar(); $this->addToolbar();
$this->sidebar = JHtmlSidebar::render(); $this->sidebar = \JHtmlSidebar::render();
} }
else else
{ {
// In article associations modal we need to remove language filter if forcing a language. // In article associations modal we need to remove language filter if forcing a language.
// We also need to change the category filter to show show categories with All or the forced language. // We also need to change the category filter to show show categories with All or the forced language.
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'CMD')) if ($forcedLanguage = \JFactory::getApplication()->input->get('forcedLanguage', '', 'CMD'))
{ {
// If the language is forced we can't allow to select the language, so transform the language selector filter into an hidden field. // If the language is forced we can't allow to select the language, so transform the language selector filter into an hidden field.
$languageXml = new SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />'); $languageXml = new \SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
$this->filterForm->setField($languageXml, 'filter', true); $this->filterForm->setField($languageXml, 'filter', true);
// Also, unset the active language filter so the search tools is not open by default with this filter. // Also, unset the active language filter so the search tools is not open by default with this filter.
@ -89,51 +91,50 @@ 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') || $canDo->get('core.edit.own')) if ($canDo->get('core.edit') || $canDo->get('core.edit.own'))
{ {
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.published') == -2 && $canDo->get('core.delete')) if ($state->get('filter.published') == -2 && $canDo->get('core.delete'))
{ {
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'weblinks.delete', 'JTOOLBAR_EMPTY_TRASH'); \JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', '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') if ($user->authorise('core.create', 'com_weblinks') && $user->authorise('core.edit', 'com_weblinks')
&& $user->authorise('core.edit.state', 'com_weblinks')) && $user->authorise('core.edit.state', 'com_weblinks'))
{ {
JHtml::_('bootstrap.modal', 'collapseModal'); $title = \JText::_('JTOOLBAR_BATCH');
$title = JText::_('JTOOLBAR_BATCH');
// Instantiate a new JLayoutFile instance and render the batch button // Instantiate a new JLayoutFile instance and render the batch button
$layout = new JLayoutFile('joomla.toolbar.batch'); $layout = new \JLayoutFile('joomla.toolbar.batch');
$dhtml = $layout->render(array('title' => $title)); $dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch'); $bar->appendButton('Custom', $dhtml, 'batch');
@ -141,10 +142,10 @@ class WeblinksViewWeblinks extends JViewLegacy
if ($user->authorise('core.admin', 'com_weblinks') || $user->authorise('core.options', 'com_weblinks')) if ($user->authorise('core.admin', 'com_weblinks') || $user->authorise('core.options', 'com_weblinks'))
{ {
JToolbarHelper::preferences('com_weblinks'); \JToolbarHelper::preferences('com_weblinks');
} }
JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS'); \JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS');
} }
/** /**
@ -157,13 +158,13 @@ class WeblinksViewWeblinks extends JViewLegacy
protected function getSortFields() protected function getSortFields()
{ {
return array( return array(
'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), 'a.ordering' => \JText::_('JGRID_HEADING_ORDERING'),
'a.state' => JText::_('JSTATUS'), 'a.state' => \JText::_('JSTATUS'),
'a.title' => JText::_('JGLOBAL_TITLE'), 'a.title' => \JText::_('JGLOBAL_TITLE'),
'a.access' => JText::_('JGRID_HEADING_ACCESS'), 'a.access' => \JText::_('JGRID_HEADING_ACCESS'),
'a.hits' => JText::_('JGLOBAL_HITS'), 'a.hits' => \JText::_('JGLOBAL_HITS'),
'a.language' => JText::_('JGRID_HEADING_LANGUAGE'), 'a.language' => \JText::_('JGRID_HEADING_LANGUAGE'),
'a.id' => JText::_('JGRID_HEADING_ID') 'a.id' => \JText::_('JGRID_HEADING_ID')
); );
} }
} }

View File

@ -0,0 +1,29 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Dispatcher\Dispatcher;
/**
* Dispatcher class for com_weblinks
*
* @since __DEPLOY_VERSION__
*/
class WeblinksDispatcher extends Dispatcher
{
/**
* The extension namespace
*
* @var string
*
* @since __DEPLOY_VERSION__
*/
protected $namespace = 'Joomla\\Component\\Weblinks';
}

View File

@ -38,6 +38,7 @@
label="JCATEGORY" label="JCATEGORY"
description="COM_WEBLINKS_FIELD_CATEGORY_DESC" description="COM_WEBLINKS_FIELD_CATEGORY_DESC"
extension="com_weblinks" extension="com_weblinks"
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
required="true" required="true"
default="" default=""
/> />

View File

@ -46,22 +46,22 @@ $tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=c
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?> <?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', empty($this->item->id) ? JText::_('COM_WEBLINKS_NEW_WEBLINK', true) : JText::_('COM_WEBLINKS_EDIT_WEBLINK', true)); ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', empty($this->item->id) ? JText::_('COM_WEBLINKS_NEW_WEBLINK', true) : JText::_('COM_WEBLINKS_EDIT_WEBLINK', true)); ?>
<div class="row-fluid"> <div class="row">
<div class="span9"> <div class="col-md-9">
<div class="form-vertical"> <div class="form-vertical">
<?php echo $this->form->getControlGroup('url'); ?> <?php echo $this->form->getControlGroup('url'); ?>
<?php echo $this->form->getControlGroup('description'); ?> <?php echo $this->form->getControlGroup('description'); ?>
</div> </div>
</div> </div>
<div class="span3"> <div class="col-md-3">
<?php echo JLayoutHelper::render('joomla.edit.global', $this); ?> <?php echo JLayoutHelper::render('joomla.edit.global', $this); ?>
</div> </div>
</div> </div>
<?php echo JHtml::_('bootstrap.endTab'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'images', JText::_('JGLOBAL_FIELDSET_IMAGE_OPTIONS', true)); ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'images', JText::_('JGLOBAL_FIELDSET_IMAGE_OPTIONS', true)); ?>
<div class="row-fluid"> <div class="row">
<div class="span6"> <div class="col-md-6">
<?php echo $this->form->getControlGroup('images'); ?> <?php echo $this->form->getControlGroup('images'); ?>
<?php foreach ($this->form->getGroup('images') as $field) : ?> <?php foreach ($this->form->getGroup('images') as $field) : ?>
<?php echo $field->getControlGroup(); ?> <?php echo $field->getControlGroup(); ?>
@ -72,18 +72,18 @@ $tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=c
<?php echo JHtml::_('bootstrap.endTab'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'publishing', JText::_('JGLOBAL_FIELDSET_PUBLISHING', true)); ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'publishing', JText::_('JGLOBAL_FIELDSET_PUBLISHING', true)); ?>
<div class="row-fluid form-horizontal-desktop"> <div class="row form-horizontal-desktop">
<div class="span6"> <div class="col-md-6">
<?php echo JLayoutHelper::render('joomla.edit.publishingdata', $this); ?> <?php echo JLayoutHelper::render('joomla.edit.publishingdata', $this); ?>
</div> </div>
<div class="span6"> <div class="col-md-6">
<?php echo JLayoutHelper::render('joomla.edit.metadata', $this); ?> <?php echo JLayoutHelper::render('joomla.edit.metadata', $this); ?>
</div> </div>
</div> </div>
<?php echo JHtml::_('bootstrap.endTab'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?> <?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
<?php if (!$isModal && $assoc) : ?> <?php if (!$isModal && $assoc) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'associations', JText::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'associations', JText::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?>
<?php echo $this->loadTemplate('associations'); ?> <?php echo $this->loadTemplate('associations'); ?>

View File

@ -30,11 +30,12 @@ if ($saveOrder)
} }
?> ?>
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=weblinks'); ?>" method="post" name="adminForm" id="adminForm"> <form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=weblinks'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
<?php if (!empty($this->sidebar)) : ?> <?php if (!empty($this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2"> <div id="j-sidebar-container" class="col-md-2">
<?php echo $this->sidebar; ?> <?php echo $this->sidebar; ?>
</div> </div>
<div id="j-main-container" class="span10"> <div id="j-main-container" class="col-md-10">
<?php else : ?> <?php else : ?>
<div id="j-main-container"> <div id="j-main-container">
<?php endif;?> <?php endif;?>
@ -184,4 +185,5 @@ if ($saveOrder)
<input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="boxchecked" value="0" />
<?php echo JHtml::_('form.token'); ?> <?php echo JHtml::_('form.token'); ?>
</div> </div>
</div>
</form> </form>

View File

@ -1,20 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.tabstate');
if (!JFactory::getUser()->authorise('core.manage', 'com_weblinks'))
{
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
$controller = JControllerLegacy::getInstance('Weblinks');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();