Switch to PSR-12
This commit is contained in:
parent
9f6606a8a4
commit
4292a06af6
|
@ -0,0 +1,20 @@
|
|||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style end of lines and a blank line at the end of the file
|
||||
[*]
|
||||
indent_style = tab
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.php]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.{js,json,scss,css,yml,vue}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
10
ruleset.xml
10
ruleset.xml
|
@ -19,13 +19,22 @@
|
|||
|
||||
<rule ref="PSR1.Classes.ClassDeclaration">
|
||||
<exclude-pattern type="relative">src/administrator/components/com_weblinks/script\.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">src/administrator/manifests/packages/weblinks/script\.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">src/administrator/components/com_weblinks/helpers/weblinks\.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">src/components/com_weblinks/helpers/icon\.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">src/components/com_weblinks/helpers/route\.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
|
||||
<exclude-pattern type="relative">src/components/com_weblinks/src/Model/CategoriesModel\.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">src/components/com_weblinks/src/Model/CategoryModel\.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">src/components/com_weblinks/src/Model/WeblinkModel\.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">src/administrator/components/com_weblinks/src/Table/*\.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
|
||||
<exclude-pattern type="relative">src/administrator/components/com_weblinks/script\.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">src/administrator/manifests/packages/weblinks/script\.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
|
||||
|
@ -34,5 +43,6 @@
|
|||
|
||||
<rule ref="Squiz.Classes.ValidClassName">
|
||||
<exclude-pattern type="relative">src/administrator/components/com_weblinks/script\.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">src/administrator/manifests/packages/weblinks/script\.php</exclude-pattern>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -7,7 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Weblinks helper.
|
||||
|
@ -16,5 +19,4 @@ defined('_JEXEC') or die;
|
|||
*/
|
||||
class WeblinksHelper extends \Joomla\Component\Weblinks\Administrator\Helper\WeblinksHelper
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -7,7 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
|
@ -60,18 +63,14 @@ class Com_WeblinksInstallerScript
|
|||
'/administrator/components/com_weblinks/sql/updates/sqlsrv',
|
||||
];
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (File::exists(JPATH_ROOT . $file))
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
if (File::exists(JPATH_ROOT . $file)) {
|
||||
File::delete(JPATH_ROOT . $file);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
if (Folder::exists(JPATH_ROOT . $folder))
|
||||
{
|
||||
foreach ($folders as $folder) {
|
||||
if (Folder::exists(JPATH_ROOT . $folder)) {
|
||||
Folder::delete(JPATH_ROOT . $folder);
|
||||
}
|
||||
}
|
||||
|
@ -95,8 +94,7 @@ class Com_WeblinksInstallerScript
|
|||
$category = Table::getInstance('Category', 'Joomla\\CMS\\Table\\');
|
||||
|
||||
// Check if the Uncategorised category exists before adding it
|
||||
if (!$category->load(array('extension' => 'com_weblinks', 'title' => 'Uncategorised')))
|
||||
{
|
||||
if (!$category->load(['extension' => 'com_weblinks', 'title' => 'Uncategorised'])) {
|
||||
$category->extension = 'com_weblinks';
|
||||
$category->title = 'Uncategorised';
|
||||
$category->description = '';
|
||||
|
@ -117,16 +115,14 @@ class Com_WeblinksInstallerScript
|
|||
$category->setLocation(1, 'last-child');
|
||||
|
||||
// Check to make sure our data is valid
|
||||
if (!$category->check())
|
||||
{
|
||||
if (!$category->check()) {
|
||||
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Now store the category
|
||||
if (!$category->store(true))
|
||||
{
|
||||
if (!$category->store(true)) {
|
||||
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
|
||||
|
||||
return;
|
||||
|
@ -152,8 +148,7 @@ class Com_WeblinksInstallerScript
|
|||
// Only execute database changes on MySQL databases
|
||||
$dbName = Factory::getDbo()->name;
|
||||
|
||||
if (strpos($dbName, 'mysql') !== false)
|
||||
{
|
||||
if (strpos($dbName, 'mysql') !== false) {
|
||||
// Add Missing Table Columns if needed
|
||||
$this->addColumnsIfNeeded();
|
||||
|
||||
|
@ -194,7 +189,7 @@ class Com_WeblinksInstallerScript
|
|||
$categoryTypeId = $db->loadResult();
|
||||
|
||||
// Set the table columns to insert table to
|
||||
$columnsArray = array(
|
||||
$columnsArray = [
|
||||
$db->quoteName('type_title'),
|
||||
$db->quoteName('type_alias'),
|
||||
$db->quoteName('table'),
|
||||
|
@ -202,11 +197,10 @@ class Com_WeblinksInstallerScript
|
|||
$db->quoteName('field_mappings'),
|
||||
$db->quoteName('router'),
|
||||
$db->quoteName('content_history_options'),
|
||||
);
|
||||
];
|
||||
|
||||
// If we have no type id for com_weblinks.weblink insert it
|
||||
if (!$weblinkTypeId)
|
||||
{
|
||||
if (!$weblinkTypeId) {
|
||||
// Insert the data.
|
||||
$query->clear();
|
||||
$query->insert($db->quoteName('#__content_types'));
|
||||
|
@ -244,8 +238,7 @@ class Com_WeblinksInstallerScript
|
|||
}
|
||||
|
||||
// If we have no type id for com_weblinks.category insert it
|
||||
if (!$categoryTypeId)
|
||||
{
|
||||
if (!$categoryTypeId) {
|
||||
// Insert the data.
|
||||
$query->clear();
|
||||
$query->insert($db->quoteName('#__content_types'));
|
||||
|
@ -255,8 +248,7 @@ class Com_WeblinksInstallerScript
|
|||
. $db->quote('com_weblinks.category') . ', '
|
||||
. $db->quote('
|
||||
{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},
|
||||
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'
|
||||
) . ', '
|
||||
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', '
|
||||
. $db->quote('') . ', '
|
||||
. $db->quote('
|
||||
{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias",
|
||||
|
@ -265,8 +257,7 @@ class Com_WeblinksInstallerScript
|
|||
"core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language",
|
||||
"core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey",
|
||||
"core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"},
|
||||
"special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'
|
||||
) . ', '
|
||||
"special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}') . ', '
|
||||
. $db->quote('WeblinksHelperRoute::getCategoryRoute') . ', '
|
||||
. $db->quote('
|
||||
{"formFile":"administrator\\/components\\/com_categories\\/models\\/forms\\/category.xml",
|
||||
|
@ -277,8 +268,7 @@ class Com_WeblinksInstallerScript
|
|||
"displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id",
|
||||
"displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id",
|
||||
"displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id",
|
||||
"displayColumn":"title"}]}'
|
||||
)
|
||||
"displayColumn":"title"}]}')
|
||||
);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
@ -295,20 +285,19 @@ class Com_WeblinksInstallerScript
|
|||
*/
|
||||
private function dropColumnsIfNeeded()
|
||||
{
|
||||
$oldColumns = array(
|
||||
$oldColumns = [
|
||||
'sid',
|
||||
'date',
|
||||
'archived',
|
||||
'approved',
|
||||
);
|
||||
];
|
||||
|
||||
$db = Factory::getDbo();
|
||||
$table = $db->getTableColumns('#__weblinks');
|
||||
|
||||
$columns = array_intersect($oldColumns, array_keys($table));
|
||||
|
||||
foreach ($columns as $column)
|
||||
{
|
||||
foreach ($columns as $column) {
|
||||
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' DROP COLUMN ' . $db->quoteName($column);
|
||||
$db->setQuery($sql);
|
||||
$db->execute();
|
||||
|
@ -327,15 +316,13 @@ class Com_WeblinksInstallerScript
|
|||
$db = Factory::getDbo();
|
||||
$table = $db->getTableColumns('#__weblinks');
|
||||
|
||||
if (!array_key_exists('version', $table))
|
||||
{
|
||||
if (!array_key_exists('version', $table)) {
|
||||
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' ADD COLUMN ' . $db->quoteName('version') . " int unsigned NOT NULL DEFAULT '1'";
|
||||
$db->setQuery($sql);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
if (!array_key_exists('images', $table))
|
||||
{
|
||||
if (!array_key_exists('images', $table)) {
|
||||
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' ADD COLUMN ' . $db->quoteName('images') . ' text NOT NULL';
|
||||
$db->setQuery($sql);
|
||||
$db->execute();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -6,8 +7,10 @@
|
|||
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Association\AssociationExtensionInterface;
|
||||
use Joomla\CMS\Categories\CategoryFactoryInterface;
|
||||
use Joomla\CMS\Component\Router\RouterFactoryInterface;
|
||||
|
@ -29,8 +32,7 @@ use Joomla\DI\ServiceProviderInterface;
|
|||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
return new class implements ServiceProviderInterface
|
||||
{
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
|
@ -42,28 +44,20 @@ return new class implements ServiceProviderInterface
|
|||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(AssociationExtensionInterface::class, new AssociationsHelper);
|
||||
|
||||
$container->set(AssociationExtensionInterface::class, new AssociationsHelper());
|
||||
$componentNamespace = '\\Joomla\\Component\\Weblinks';
|
||||
|
||||
$container->registerServiceProvider(new CategoryFactory($componentNamespace));
|
||||
$container->registerServiceProvider(new MVCFactory($componentNamespace));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory($componentNamespace));
|
||||
$container->registerServiceProvider(new RouterFactory($componentNamespace));
|
||||
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
function (Container $container) {
|
||||
$container->set(ComponentInterface::class, function (Container $container) {
|
||||
$component = new WeblinksComponent($container->get(ComponentDispatcherFactoryInterface::class));
|
||||
|
||||
$component->setRegistry($container->get(Registry::class));
|
||||
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
|
||||
$component->setCategoryFactory($container->get(CategoryFactoryInterface::class));
|
||||
$component->setAssociationExtension($container->get(AssociationExtensionInterface::class));
|
||||
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
|
||||
|
||||
return $component;
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Controller;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
@ -29,7 +31,6 @@ class DisplayController extends BaseController
|
|||
* @since 1.6
|
||||
*/
|
||||
protected $default_view = 'weblinks';
|
||||
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
|
@ -46,18 +47,14 @@ class DisplayController extends BaseController
|
|||
$view = $this->input->get('view', 'weblinks');
|
||||
$layout = $this->input->get('layout', 'default');
|
||||
$id = $this->input->getInt('id');
|
||||
|
||||
// Check for edit form.
|
||||
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.
|
||||
if (!\count($this->app->getMessageQueue()))
|
||||
{
|
||||
if (!\count($this->app->getMessageQueue())) {
|
||||
$this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');
|
||||
}
|
||||
|
||||
$this->setRedirect(Route::_('index.php?option=com_weblinks&view=weblinks', false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Controller;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
|
@ -35,12 +38,11 @@ class WeblinkController extends FormController
|
|||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowAdd($data = array())
|
||||
protected function allowAdd($data = [])
|
||||
{
|
||||
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
|
||||
|
||||
if ($categoryId)
|
||||
{
|
||||
if ($categoryId) {
|
||||
// If the category has been passed in the URL check it.
|
||||
return $this->app->getIdentity()->authorise('core.create', $this->option . '.category.' . $categoryId);
|
||||
}
|
||||
|
@ -59,13 +61,12 @@ class WeblinkController extends FormController
|
|||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowEdit($data = array(), $key = 'id')
|
||||
protected function allowEdit($data = [], $key = 'id')
|
||||
{
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
|
||||
// Since there is no asset tracking, fallback to the component permissions.
|
||||
if (!$recordId)
|
||||
{
|
||||
if (!$recordId) {
|
||||
return parent::allowEdit($data, $key);
|
||||
}
|
||||
|
||||
|
@ -73,8 +74,7 @@ class WeblinkController extends FormController
|
|||
$item = $this->getModel()->getItem($recordId);
|
||||
|
||||
// Since there is no item, return false.
|
||||
if (empty($item))
|
||||
{
|
||||
if (empty($item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ class WeblinkController extends FormController
|
|||
$this->checkToken();
|
||||
|
||||
// Set the model
|
||||
$model = $this->getModel('Weblink', 'Administrator', array());
|
||||
$model = $this->getModel('Weblink', 'Administrator', []);
|
||||
|
||||
// Preset the redirect
|
||||
$this->setRedirect(Route::_('index.php?option=com_weblinks&view=weblinks' . $this->getRedirectToListAppend(), false));
|
||||
|
@ -123,8 +123,7 @@ class WeblinkController extends FormController
|
|||
{
|
||||
$task = $this->getTask();
|
||||
|
||||
if ($task == 'save')
|
||||
{
|
||||
if ($task == 'save') {
|
||||
$this->setRedirect(Route::_('index.php?option=com_weblinks&view=weblinks', false));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Controller;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\MVC\Controller\AdminController;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +33,7 @@ class WeblinksController extends AdminController
|
|||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Weblink', $prefix = 'Administrator', $config = array('ignore_request' => true))
|
||||
public function getModel($name = 'Weblink', $prefix = 'Administrator', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Extension;
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Application\SiteApplication;
|
||||
use Joomla\CMS\Association\AssociationServiceInterface;
|
||||
use Joomla\CMS\Association\AssociationServiceTrait;
|
||||
|
@ -35,15 +37,19 @@ use Psr\Container\ContainerInterface;
|
|||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class WeblinksComponent extends MVCComponent implements CategoryServiceInterface, AssociationServiceInterface,
|
||||
TagServiceInterface, RouterServiceInterface, BootableExtensionInterface, FieldsServiceInterface
|
||||
class WeblinksComponent extends MVCComponent implements
|
||||
CategoryServiceInterface,
|
||||
AssociationServiceInterface,
|
||||
TagServiceInterface,
|
||||
RouterServiceInterface,
|
||||
BootableExtensionInterface,
|
||||
FieldsServiceInterface
|
||||
{
|
||||
use CategoryServiceTrait;
|
||||
use AssociationServiceTrait;
|
||||
use HTMLRegistryAwareTrait;
|
||||
use RouterServiceTrait;
|
||||
use CategoryServiceTrait, TagServiceTrait
|
||||
{
|
||||
use CategoryServiceTrait, TagServiceTrait {
|
||||
CategoryServiceTrait::getTableNameForSection insteadof TagServiceTrait;
|
||||
CategoryServiceTrait::getStateColumnForSection insteadof TagServiceTrait;
|
||||
}
|
||||
|
@ -61,9 +67,11 @@ class WeblinksComponent extends MVCComponent implements CategoryServiceInterface
|
|||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
|
||||
|
||||
public function boot(ContainerInterface $container)
|
||||
{
|
||||
$this->getRegistry()->register('weblinksadministrator', new AdministratorService);
|
||||
$this->getRegistry()->register('weblinksadministrator', new AdministratorService());
|
||||
$this->getRegistry()->register('weblinkicon', new Icon($container->get(SiteApplication::class)));
|
||||
}
|
||||
|
||||
|
@ -80,8 +88,7 @@ class WeblinksComponent extends MVCComponent implements CategoryServiceInterface
|
|||
*/
|
||||
public function validateSection($section, $item = null)
|
||||
{
|
||||
if ($section != 'weblink')
|
||||
{
|
||||
if ($section != 'weblink') {
|
||||
// We don't know other sections
|
||||
return null;
|
||||
}
|
||||
|
@ -99,11 +106,9 @@ class WeblinksComponent extends MVCComponent implements CategoryServiceInterface
|
|||
public function getContexts(): array
|
||||
{
|
||||
Factory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR);
|
||||
|
||||
$contexts = array(
|
||||
$contexts = [
|
||||
'com_weblinks.weblink' => Text::_('COM_WEBLINKS'),
|
||||
);
|
||||
|
||||
];
|
||||
return $contexts;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -16,8 +17,9 @@ use Joomla\CMS\Language\Text;
|
|||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* Supports a modal weblink picker.
|
||||
*
|
||||
|
@ -32,7 +34,6 @@ class WeblinkField extends FormField
|
|||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
protected $type = 'Modal_Weblink';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
|
@ -46,44 +47,33 @@ class WeblinkField extends FormField
|
|||
$allowEdit = ((string) $this->element['edit'] == 'true');
|
||||
$allowClear = ((string) $this->element['clear'] != 'false');
|
||||
$allowSelect = ((string) $this->element['select'] != 'false');
|
||||
|
||||
// Load language
|
||||
Factory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR);
|
||||
|
||||
// The active weblink id field.
|
||||
$value = (int) $this->value > 0 ? (int) $this->value : '';
|
||||
|
||||
// Create the modal id.
|
||||
$modalId = 'Weblink_' . $this->id;
|
||||
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
|
||||
|
||||
// Add the modal field script to the document head.
|
||||
$wa->useScript('field.modal-fields');
|
||||
|
||||
// Script to proxy the select modal function to the modal-fields.js file.
|
||||
if ($allowSelect)
|
||||
{
|
||||
if ($allowSelect) {
|
||||
static $scriptSelect = null;
|
||||
|
||||
if (is_null($scriptSelect))
|
||||
{
|
||||
$scriptSelect = array();
|
||||
if (is_null($scriptSelect)) {
|
||||
$scriptSelect = [];
|
||||
}
|
||||
|
||||
if (!isset($scriptSelect[$this->id]))
|
||||
{
|
||||
$wa->addInlineScript("
|
||||
if (!isset($scriptSelect[$this->id])) {
|
||||
$wa->addInlineScript(
|
||||
"
|
||||
window.jSelectWeblink_" . $this->id . " = function (id, title, catid, object, url, language) {
|
||||
window.processModalSelect('Article', '" . $this->id . "', id, title, catid, object, url, language);
|
||||
}",
|
||||
[],
|
||||
['type' => 'module']
|
||||
);
|
||||
|
||||
Text::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
|
||||
|
||||
$scriptSelect[$this->id] = true;
|
||||
}
|
||||
}
|
||||
|
@ -92,9 +82,7 @@ class WeblinkField extends FormField
|
|||
$linkWeblinks = 'index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
$linkWeblink = 'index.php?option=com_weblinks&view=weblink&layout=modal&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
$modalTitle = Text::_('COM_WEBLINKS_CHANGE_WEBLINK');
|
||||
|
||||
if (isset($this->element['language']))
|
||||
{
|
||||
if (isset($this->element['language'])) {
|
||||
$linkWeblinks .= '&forcedLanguage=' . $this->element['language'];
|
||||
$linkWeblink .= '&forcedLanguage=' . $this->element['language'];
|
||||
$modalTitle .= ' — ' . $this->element['label'];
|
||||
|
@ -103,9 +91,7 @@ class WeblinkField extends FormField
|
|||
$urlSelect = $linkWeblinks . '&function=jSelectWeblink_' . $this->id;
|
||||
$urlEdit = $linkWeblink . '&task=weblink.edit&id=\' + document.getElementById("' . $this->id . '_id").value + \'';
|
||||
$urlNew = $linkWeblink . '&task=weblink.add';
|
||||
|
||||
if ($value)
|
||||
{
|
||||
if ($value) {
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('title'))
|
||||
|
@ -113,32 +99,23 @@ class WeblinkField extends FormField
|
|||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $value, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$title = $db->loadResult();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
$title = empty($title) ? Text::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
// The current weblink display field.
|
||||
$html = '';
|
||||
|
||||
if ($allowSelect || $allowNew || $allowEdit || $allowClear)
|
||||
{
|
||||
if ($allowSelect || $allowNew || $allowEdit || $allowClear) {
|
||||
$html .= '<span class="input-group">';
|
||||
}
|
||||
|
||||
$html .= '<input class="form-control" id="' . $this->id . '_name" type="text" value="' . $title . '" readonly size="35">';
|
||||
|
||||
// Select weblink button
|
||||
if ($allowSelect)
|
||||
{
|
||||
if ($allowSelect) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-primary' . ($value ? ' hidden' : '') . '"'
|
||||
. ' id="' . $this->id . '_select"'
|
||||
|
@ -150,8 +127,7 @@ class WeblinkField extends FormField
|
|||
}
|
||||
|
||||
// New weblink button
|
||||
if ($allowNew)
|
||||
{
|
||||
if ($allowNew) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-secondary' . ($value ? ' hidden' : '') . '"'
|
||||
. ' id="' . $this->id . '_new"'
|
||||
|
@ -163,8 +139,7 @@ class WeblinkField extends FormField
|
|||
}
|
||||
|
||||
// Edit weblink button
|
||||
if ($allowEdit)
|
||||
{
|
||||
if ($allowEdit) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-primary' . ($value ? '' : ' hidden') . '"'
|
||||
. ' id="' . $this->id . '_edit"'
|
||||
|
@ -176,8 +151,7 @@ class WeblinkField extends FormField
|
|||
}
|
||||
|
||||
// Clear weblink button
|
||||
if ($allowClear)
|
||||
{
|
||||
if ($allowClear) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
|
||||
. ' id="' . $this->id . '_clear"'
|
||||
|
@ -187,18 +161,13 @@ class WeblinkField extends FormField
|
|||
. '</button>';
|
||||
}
|
||||
|
||||
if ($allowSelect || $allowNew || $allowEdit || $allowClear)
|
||||
{
|
||||
if ($allowSelect || $allowNew || $allowEdit || $allowClear) {
|
||||
$html .= '</span>';
|
||||
}
|
||||
|
||||
// Select weblink modal
|
||||
if ($allowSelect)
|
||||
{
|
||||
$html .= HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'ModalSelect' . $modalId,
|
||||
array(
|
||||
if ($allowSelect) {
|
||||
$html .= HTMLHelper::_('bootstrap.renderModal', 'ModalSelect' . $modalId, [
|
||||
'title' => $modalTitle,
|
||||
'url' => $urlSelect,
|
||||
'height' => '400px',
|
||||
|
@ -207,21 +176,15 @@ class WeblinkField extends FormField
|
|||
'modalWidth' => 80,
|
||||
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'
|
||||
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>',
|
||||
)
|
||||
);
|
||||
]);
|
||||
}
|
||||
|
||||
$closeButtonClick = "window.processModalEdit(this, '$this->id', 'add', 'weblink', 'cancel', 'weblink-form'); return false;";
|
||||
$saveButtonClick = "window.processModalEdit(this, '$this->id', 'add', 'weblink', 'save', 'weblink-form'); return false;";
|
||||
$applyButtonClick = "window.processModalEdit(this, '$this->id', 'add', 'weblink', 'apply', 'weblink-form'); return false;";
|
||||
|
||||
// New weblink modal
|
||||
if ($allowNew)
|
||||
{
|
||||
$html .= HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'ModalNew' . $modalId,
|
||||
array(
|
||||
if ($allowNew) {
|
||||
$html .= HTMLHelper::_('bootstrap.renderModal', 'ModalNew' . $modalId, [
|
||||
'title' => Text::_('COM_WEBLINKS_NEW_WEBLINK'),
|
||||
'backdrop' => 'static',
|
||||
'keyboard' => false,
|
||||
|
@ -240,17 +203,12 @@ class WeblinkField extends FormField
|
|||
. '<a role="button" class="btn btn-success" aria-hidden="true"'
|
||||
. ' onclick="' . $applyButtonClick . '">'
|
||||
. Text::_('JAPPLY') . '</a>',
|
||||
)
|
||||
);
|
||||
]);
|
||||
}
|
||||
|
||||
// Edit weblink modal
|
||||
if ($allowEdit)
|
||||
{
|
||||
$html .= HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'ModalEdit' . $modalId,
|
||||
array(
|
||||
if ($allowEdit) {
|
||||
$html .= HTMLHelper::_('bootstrap.renderModal', 'ModalEdit' . $modalId, [
|
||||
'title' => Text::_('COM_WEBLINKS_EDIT_WEBLINK'),
|
||||
'backdrop' => 'static',
|
||||
'keyboard' => false,
|
||||
|
@ -269,15 +227,13 @@ class WeblinkField extends FormField
|
|||
. '<a role="button" class="btn btn-success" aria-hidden="true"'
|
||||
. ' onclick="' . $applyButtonClick . '">'
|
||||
. Text::_('JAPPLY') . '</a>',
|
||||
)
|
||||
);
|
||||
]);
|
||||
}
|
||||
|
||||
// Note: class='required' for client side validation.
|
||||
$class = $this->required ? ' class="required modal-value"' : '';
|
||||
$html .= '<input type="hidden" id="' . $this->id . '_id" ' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
|
||||
. '" data-text="' . htmlspecialchars(Text::_('COM_WEBLINKS_SELECT_A_WEBLINK', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Helper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Association\AssociationExtensionHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
@ -39,7 +41,7 @@ class AssociationsHelper extends AssociationExtensionHelper
|
|||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
protected $itemTypes = array('weblink', 'category');
|
||||
protected $itemTypes = ['weblink', 'category'];
|
||||
|
||||
/**
|
||||
* Has the extension association support
|
||||
|
@ -78,27 +80,15 @@ class AssociationsHelper extends AssociationExtensionHelper
|
|||
public function getAssociations($typeName, $id)
|
||||
{
|
||||
$type = $this->getType($typeName);
|
||||
|
||||
$context = $this->extension . '.item';
|
||||
$catidField = 'catid';
|
||||
|
||||
if ($typeName === 'category')
|
||||
{
|
||||
if ($typeName === 'category') {
|
||||
$context = 'com_categories.item';
|
||||
$catidField = '';
|
||||
}
|
||||
|
||||
// Get the associations.
|
||||
$associations = Associations::getAssociations(
|
||||
$this->extension,
|
||||
$type['tables']['a'],
|
||||
$context,
|
||||
$id,
|
||||
'id',
|
||||
'alias',
|
||||
$catidField
|
||||
);
|
||||
|
||||
$associations = Associations::getAssociations($this->extension, $type['tables']['a'], $context, $id, 'id', 'alias', $catidField);
|
||||
return $associations;
|
||||
}
|
||||
|
||||
|
@ -114,31 +104,27 @@ class AssociationsHelper extends AssociationExtensionHelper
|
|||
*/
|
||||
public function getItem($typeName, $id)
|
||||
{
|
||||
if (empty($id))
|
||||
{
|
||||
if (empty($id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$table = null;
|
||||
|
||||
switch ($typeName)
|
||||
{
|
||||
switch ($typeName) {
|
||||
case 'weblink':
|
||||
$table = Table::getInstance('WeblinkTable', 'Joomla\\Component\\Weblinks\\Administrator\\Table\\');
|
||||
break;
|
||||
|
||||
break;
|
||||
case 'category':
|
||||
$table = Table::getInstance('Category', 'Joomla\\CMS\\Table\\');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($table))
|
||||
{
|
||||
if (empty($table)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$table->load($id);
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -154,57 +140,49 @@ class AssociationsHelper extends AssociationExtensionHelper
|
|||
public function getType($typeName = '')
|
||||
{
|
||||
$fields = $this->getFieldsTemplate();
|
||||
$tables = array();
|
||||
$joins = array();
|
||||
$tables = [];
|
||||
$joins = [];
|
||||
$support = $this->getSupportTemplate();
|
||||
$title = '';
|
||||
|
||||
if (in_array($typeName, $this->itemTypes))
|
||||
{
|
||||
switch ($typeName)
|
||||
{
|
||||
if (in_array($typeName, $this->itemTypes)) {
|
||||
switch ($typeName) {
|
||||
case 'weblink':
|
||||
|
||||
$support['state'] = true;
|
||||
$support['acl'] = true;
|
||||
$support['checkout'] = true;
|
||||
$support['category'] = true;
|
||||
$support['save2copy'] = true;
|
||||
|
||||
$tables = array(
|
||||
$tables = [
|
||||
'a' => '#__weblinks',
|
||||
);
|
||||
|
||||
];
|
||||
$title = 'weblink';
|
||||
break;
|
||||
|
||||
break;
|
||||
case 'category':
|
||||
$fields['created_user_id'] = 'a.created_user_id';
|
||||
$fields['ordering'] = 'a.lft';
|
||||
$fields['level'] = 'a.level';
|
||||
$fields['catid'] = '';
|
||||
$fields['state'] = 'a.published';
|
||||
|
||||
$support['state'] = true;
|
||||
$support['acl'] = true;
|
||||
$support['checkout'] = true;
|
||||
$support['level'] = true;
|
||||
|
||||
$tables = array(
|
||||
$tables = [
|
||||
'a' => '#__categories',
|
||||
);
|
||||
|
||||
];
|
||||
$title = 'category';
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'fields' => $fields,
|
||||
'support' => $support,
|
||||
'tables' => $tables,
|
||||
'joins' => $joins,
|
||||
'title' => $title,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Helper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
|
||||
/**
|
||||
|
@ -20,5 +22,4 @@ use Joomla\CMS\Helper\ContentHelper;
|
|||
*/
|
||||
class WeblinksHelper extends ContentHelper
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Model;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
|
@ -66,8 +69,7 @@ class WeblinkModel extends AdminModel
|
|||
*/
|
||||
protected function canDelete($record)
|
||||
{
|
||||
if (empty($record->id) || $record->state != -2)
|
||||
{
|
||||
if (empty($record->id) || $record->state != -2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -85,8 +87,7 @@ class WeblinkModel extends AdminModel
|
|||
*/
|
||||
protected function canEditState($record)
|
||||
{
|
||||
if (!empty($record->catid))
|
||||
{
|
||||
if (!empty($record->catid)) {
|
||||
return $this->getCurrentUser()->authorise('core.edit.state', 'com_weblinks.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
|
@ -103,31 +104,26 @@ class WeblinkModel extends AdminModel
|
|||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = array(), $loadData = true)
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_weblinks.weblink', 'weblink', array('control' => 'jform', 'load_data' => $loadData));
|
||||
$form = $this->loadForm('com_weblinks.weblink', 'weblink', ['control' => 'jform', 'load_data' => $loadData]);
|
||||
|
||||
if (empty($form))
|
||||
{
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine correct permissions to check.
|
||||
if ($this->getState('weblink.id'))
|
||||
{
|
||||
if ($this->getState('weblink.id')) {
|
||||
// Existing record. Can only edit in selected categories.
|
||||
$form->setFieldAttribute('catid', 'action', 'core.edit');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// New record. Can only create in selected categories.
|
||||
$form->setFieldAttribute('catid', 'action', 'core.create');
|
||||
}
|
||||
|
||||
// Modify the form based on access controls.
|
||||
if (!$this->canEditState((object) $data))
|
||||
{
|
||||
if (!$this->canEditState((object) $data)) {
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('ordering', 'disabled', 'true');
|
||||
$form->setFieldAttribute('state', 'disabled', 'true');
|
||||
|
@ -143,8 +139,7 @@ class WeblinkModel extends AdminModel
|
|||
}
|
||||
|
||||
// Don't allow to change the created_by user if not allowed to access com_users.
|
||||
if (!$this->getCurrentUser()->authorise('core.manage', 'com_users'))
|
||||
{
|
||||
if (!$this->getCurrentUser()->authorise('core.manage', 'com_users')) {
|
||||
$form->setFieldAttribute('created_by', 'filter', 'unset');
|
||||
}
|
||||
|
||||
|
@ -163,15 +158,13 @@ class WeblinkModel extends AdminModel
|
|||
$app = Factory::getApplication();
|
||||
|
||||
// Check the session for previously entered form data.
|
||||
$data = $app->getUserState('com_weblinks.edit.weblink.data', array());
|
||||
$data = $app->getUserState('com_weblinks.edit.weblink.data', []);
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
if (empty($data)) {
|
||||
$data = $this->getItem();
|
||||
|
||||
// Prime some default values.
|
||||
if ($this->getState('weblink.id') == 0)
|
||||
{
|
||||
if ($this->getState('weblink.id') == 0) {
|
||||
$data->set('catid', $app->input->get('catid', $app->getUserState('com_weblinks.weblinks.filter.category_id'), 'int'));
|
||||
}
|
||||
}
|
||||
|
@ -192,8 +185,7 @@ class WeblinkModel extends AdminModel
|
|||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
if ($item = parent::getItem($pk))
|
||||
{
|
||||
if ($item = parent::getItem($pk)) {
|
||||
// Convert the metadata field to an array.
|
||||
$registry = new Registry($item->metadata ?? '');
|
||||
$item->metadata = $registry->toArray();
|
||||
|
@ -205,24 +197,20 @@ class WeblinkModel extends AdminModel
|
|||
// Load associated web links items
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
if ($assoc)
|
||||
{
|
||||
$item->associations = array();
|
||||
if ($assoc) {
|
||||
$item->associations = [];
|
||||
|
||||
if ($item->id != null)
|
||||
{
|
||||
if ($item->id != null) {
|
||||
$associations = Associations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $item->id);
|
||||
|
||||
foreach ($associations as $tag => $association)
|
||||
{
|
||||
foreach ($associations as $tag => $association) {
|
||||
$item->associations[$tag] = $association->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item->id))
|
||||
{
|
||||
$item->tags = new TagsHelper;
|
||||
if (!empty($item->id)) {
|
||||
$item->tags = new TagsHelper();
|
||||
$item->tags->getTagIds($item->id, 'com_weblinks.weblink');
|
||||
$item->metadata['tags'] = $item->tags;
|
||||
}
|
||||
|
@ -248,18 +236,15 @@ class WeblinkModel extends AdminModel
|
|||
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
|
||||
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
|
||||
|
||||
if (empty($table->alias))
|
||||
{
|
||||
if (empty($table->alias)) {
|
||||
$table->alias = ApplicationHelper::stringURLSafe($table->title);
|
||||
}
|
||||
|
||||
if (empty($table->id))
|
||||
{
|
||||
if (empty($table->id)) {
|
||||
// Set the values
|
||||
|
||||
// Set ordering to the last item if not set
|
||||
if (empty($table->ordering))
|
||||
{
|
||||
if (empty($table->ordering)) {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select('MAX(ordering)')
|
||||
|
@ -269,9 +254,7 @@ class WeblinkModel extends AdminModel
|
|||
$max = $db->loadResult();
|
||||
|
||||
$table->ordering = $max + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Set the values
|
||||
$table->modified = $date->toSql();
|
||||
$table->modified_by = $user->id;
|
||||
|
@ -293,7 +276,7 @@ class WeblinkModel extends AdminModel
|
|||
*/
|
||||
protected function getReorderConditions($table)
|
||||
{
|
||||
$condition = array();
|
||||
$condition = [];
|
||||
$condition[] = 'catid = ' . (int) $table->catid;
|
||||
|
||||
return $condition;
|
||||
|
@ -316,15 +299,13 @@ class WeblinkModel extends AdminModel
|
|||
$catid = (int) $data['catid'];
|
||||
|
||||
// Check if New Category exists
|
||||
if ($catid > 0)
|
||||
{
|
||||
if ($catid > 0) {
|
||||
$catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_weblinks');
|
||||
}
|
||||
|
||||
// Save New Category
|
||||
if ($catid == 0 && $this->canCreateCategory())
|
||||
{
|
||||
$table = array();
|
||||
if ($catid == 0 && $this->canCreateCategory()) {
|
||||
$table = [];
|
||||
$table['title'] = $data['catid'];
|
||||
$table['parent_id'] = 1;
|
||||
$table['extension'] = 'com_weblinks';
|
||||
|
@ -336,8 +317,7 @@ class WeblinkModel extends AdminModel
|
|||
}
|
||||
|
||||
// Alter the title for save as copy
|
||||
if ($app->input->get('task') == 'save2copy')
|
||||
{
|
||||
if ($app->input->get('task') == 'save2copy') {
|
||||
[$name, $alias] = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
|
||||
$data['title'] = $name;
|
||||
$data['alias'] = $alias;
|
||||
|
@ -363,17 +343,15 @@ class WeblinkModel extends AdminModel
|
|||
// Alter the title & alias
|
||||
$table = $this->getTable();
|
||||
|
||||
while ($table->load(array('alias' => $alias, 'catid' => $category_id)))
|
||||
{
|
||||
if ($name == $table->title)
|
||||
{
|
||||
while ($table->load(['alias' => $alias, 'catid' => $category_id])) {
|
||||
if ($name == $table->title) {
|
||||
$name = StringHelper::increment($name);
|
||||
}
|
||||
|
||||
$alias = StringHelper::increment($alias, 'dash');
|
||||
}
|
||||
|
||||
return array($name, $alias);
|
||||
return [$name, $alias];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -389,26 +367,22 @@ class WeblinkModel extends AdminModel
|
|||
*/
|
||||
protected function preprocessForm(\JForm $form, $data, $group = 'content')
|
||||
{
|
||||
if ($this->canCreateCategory())
|
||||
{
|
||||
if ($this->canCreateCategory()) {
|
||||
$form->setFieldAttribute('catid', 'allowAdd', 'true');
|
||||
}
|
||||
|
||||
// Association weblinks items
|
||||
if (Associations::isEnabled())
|
||||
{
|
||||
if (Associations::isEnabled()) {
|
||||
$languages = LanguageHelper::getContentLanguages(false, false, null, 'ordering', 'asc');
|
||||
|
||||
if (count($languages) > 1)
|
||||
{
|
||||
if (count($languages) > 1) {
|
||||
$addform = new \SimpleXMLElement('<form />');
|
||||
$fields = $addform->addChild('fields');
|
||||
$fields->addAttribute('name', 'associations');
|
||||
$fieldset = $fields->addChild('fieldset');
|
||||
$fieldset->addAttribute('name', 'item_associations');
|
||||
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
foreach ($languages as $language) {
|
||||
$field = $fieldset->addChild('field');
|
||||
$field->addAttribute('name', $language->lang_code);
|
||||
$field->addAttribute('type', 'modal_weblink');
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Model;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
|
@ -34,11 +37,10 @@ class WeblinksModel extends ListModel
|
|||
* @see JControllerLegacy
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = array(), MVCFactoryInterface $factory = null)
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null)
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'title', 'a.title',
|
||||
'alias', 'a.alias',
|
||||
|
@ -61,12 +63,11 @@ class WeblinksModel extends ListModel
|
|||
'url', 'a.url',
|
||||
'tag',
|
||||
'level', 'c.level',
|
||||
);
|
||||
];
|
||||
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
if ($assoc)
|
||||
{
|
||||
if ($assoc) {
|
||||
$config['filter_fields'][] = 'association';
|
||||
}
|
||||
}
|
||||
|
@ -92,14 +93,12 @@ class WeblinksModel extends ListModel
|
|||
$forcedLanguage = $app->input->get('forcedLanguage', '', 'cmd');
|
||||
|
||||
// Adjust the context to support modal layouts.
|
||||
if ($layout = $app->input->get('layout'))
|
||||
{
|
||||
if ($layout = $app->input->get('layout')) {
|
||||
$this->context .= '.' . $layout;
|
||||
}
|
||||
|
||||
// Adjust the context to support forced languages.
|
||||
if ($forcedLanguage)
|
||||
{
|
||||
if ($forcedLanguage) {
|
||||
$this->context .= '.' . $forcedLanguage;
|
||||
}
|
||||
|
||||
|
@ -108,8 +107,7 @@ class WeblinksModel extends ListModel
|
|||
$this->setState('params', $params);
|
||||
|
||||
// Force a language.
|
||||
if (!empty($forcedLanguage))
|
||||
{
|
||||
if (!empty($forcedLanguage)) {
|
||||
$this->setState('filter.language', $forcedLanguage);
|
||||
}
|
||||
|
||||
|
@ -188,8 +186,7 @@ class WeblinksModel extends ListModel
|
|||
// Join over the associations.
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
if ($assoc)
|
||||
{
|
||||
if ($assoc) {
|
||||
$query->select('COUNT(asso2.id)>1 AS association')
|
||||
->join('LEFT', $db->quoteName('#__associations', 'asso') . ' ON asso.id = a.id AND asso.context = ' . $db->quote('com_weblinks.item'))
|
||||
->join('LEFT', $db->quoteName('#__associations', 'asso2') . ' ON asso2.key = asso.key')
|
||||
|
@ -197,43 +194,36 @@ class WeblinksModel extends ListModel
|
|||
}
|
||||
|
||||
// Filter by access level.
|
||||
if ($access = $this->getState('filter.access'))
|
||||
{
|
||||
if ($access = $this->getState('filter.access')) {
|
||||
$query->where($db->quoteName('a.access') . ' = :access')
|
||||
->bind(':access', $access, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.admin'))
|
||||
{
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->whereIn($db->quoteName('a.access'), $user->getAuthorisedViewLevels());
|
||||
}
|
||||
|
||||
// Filter by published state
|
||||
$published = (string) $this->getState('filter.published');
|
||||
|
||||
if (is_numeric($published))
|
||||
{
|
||||
if (is_numeric($published)) {
|
||||
$query->where($db->quoteName('a.state') . ' = :state')
|
||||
->bind(':state', $published, ParameterType::INTEGER);
|
||||
}
|
||||
elseif ($published === '')
|
||||
{
|
||||
} elseif ($published === '') {
|
||||
$query->whereIn($db->quoteName('a.state'), [0, 1]);
|
||||
}
|
||||
|
||||
// Filter by category.
|
||||
$categoryId = $this->getState('filter.category_id');
|
||||
|
||||
if (is_numeric($categoryId))
|
||||
{
|
||||
if (is_numeric($categoryId)) {
|
||||
$query->where($db->quoteName('a.catid') . ' = :catid')
|
||||
->bind(':catid', $categoryId, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter on the level.
|
||||
if ($level = $this->getState('filter.level'))
|
||||
{
|
||||
if ($level = $this->getState('filter.level')) {
|
||||
$query->where($db->quoteName('c.level') . ' <= :level')
|
||||
->bind(':level', $level, ParameterType::INTEGER);
|
||||
}
|
||||
|
@ -241,16 +231,12 @@ class WeblinksModel extends ListModel
|
|||
// Filter by search in title
|
||||
$search = $this->getState('filter.search');
|
||||
|
||||
if (!empty($search))
|
||||
{
|
||||
if (stripos($search, 'id:') === 0)
|
||||
{
|
||||
if (!empty($search)) {
|
||||
if (stripos($search, 'id:') === 0) {
|
||||
$search = substr($search, 3);
|
||||
$query->where($db->quoteName('a.id') . ' = :id')
|
||||
->bind(':id', $search, ParameterType::INTEGER);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$search = '%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%');
|
||||
$query->where('(' . $db->quoteName('a.title') . ' LIKE :title OR ' . $db->quoteName('a.alias') . ' LIKE :alias)')
|
||||
->bind(':title', $search)
|
||||
|
@ -259,8 +245,7 @@ class WeblinksModel extends ListModel
|
|||
}
|
||||
|
||||
// Filter on the language.
|
||||
if ($language = $this->getState('filter.language'))
|
||||
{
|
||||
if ($language = $this->getState('filter.language')) {
|
||||
$query->where($db->quoteName('a.language') . ' = :language')
|
||||
->bind(':language', $language);
|
||||
}
|
||||
|
@ -268,12 +253,12 @@ class WeblinksModel extends ListModel
|
|||
$tagId = $this->getState('filter.tag');
|
||||
|
||||
// Filter by a single tag.
|
||||
if (is_numeric($tagId))
|
||||
{
|
||||
if (is_numeric($tagId)) {
|
||||
$query->where($db->quoteName('tagmap.tag_id') . ' = :tagId')
|
||||
->bind(':tagId', $tagId, ParameterType::INTEGER)
|
||||
->join(
|
||||
'LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
|
||||
'LEFT',
|
||||
$db->quoteName('#__contentitem_tag_map', 'tagmap')
|
||||
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
|
||||
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_weblinks.weblink')
|
||||
);
|
||||
|
@ -283,8 +268,7 @@ class WeblinksModel extends ListModel
|
|||
$orderCol = $this->state->get('list.ordering', 'a.title');
|
||||
$orderDirn = $this->state->get('list.direction', 'ASC');
|
||||
|
||||
if ($orderCol == 'a.ordering' || $orderCol == 'category_title')
|
||||
{
|
||||
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
|
||||
$orderCol = 'c.title ' . $orderDirn . ', a.ordering';
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Service\HTML;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
|
@ -39,20 +41,16 @@ class AdministratorService
|
|||
{
|
||||
// Defaults
|
||||
$html = '';
|
||||
|
||||
// Get the associations
|
||||
if ($associations = Associations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $weblinkid))
|
||||
{
|
||||
foreach ($associations as $tag => $associated)
|
||||
{
|
||||
if ($associations = Associations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $weblinkid)) {
|
||||
foreach ($associations as $tag => $associated) {
|
||||
$associations[$tag] = (int) $associated->id;
|
||||
}
|
||||
|
||||
// Get the associated contact items
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(
|
||||
[
|
||||
->select([
|
||||
$db->quoteName('c.id'),
|
||||
$db->quoteName('c.title', 'title'),
|
||||
$db->quoteName('l.sef', 'lang_sef'),
|
||||
|
@ -60,8 +58,7 @@ class AdministratorService
|
|||
$db->quoteName('cat.title', 'category_title'),
|
||||
$db->quoteName('l.image'),
|
||||
$db->quoteName('l.title', 'language_title'),
|
||||
]
|
||||
)
|
||||
])
|
||||
->from($db->quoteName('#__weblinks', 'c'))
|
||||
->join('LEFT', $db->quoteName('#__categories', 'cat'), $db->quoteName('cat.id') . ' = ' . $db->quoteName('c.catid'))
|
||||
->join('LEFT', $db->quoteName('#__languages', 'l'), $db->quoteName('c.language') . ' = ' . $db->quoteName('l.lang_code'))
|
||||
|
@ -69,38 +66,27 @@ class AdministratorService
|
|||
->where($db->quoteName('c.id') . ' != :id')
|
||||
->bind(':id', $weblinkid, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$items = $db->loadObjectList('id');
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new \Exception($e->getMessage(), 500, $e);
|
||||
}
|
||||
|
||||
if ($items)
|
||||
{
|
||||
if ($items) {
|
||||
$app = Factory::getApplication();
|
||||
$languages = LanguageHelper::getContentLanguages(array(0, 1));
|
||||
$languages = LanguageHelper::getContentLanguages([0, 1]);
|
||||
$content_languages = array_column($languages, 'lang_code');
|
||||
|
||||
foreach ($items as &$item)
|
||||
{
|
||||
if (in_array($item->lang_code, $content_languages))
|
||||
{
|
||||
foreach ($items as &$item) {
|
||||
if (in_array($item->lang_code, $content_languages)) {
|
||||
$text = $item->lang_code;
|
||||
$url = Route::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id);
|
||||
$tooltip = '<strong>' . htmlspecialchars($item->language_title, ENT_QUOTES, 'UTF-8') . '</strong><br>'
|
||||
. htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8')
|
||||
. '<br>' . Text::sprintf('JCATEGORY_SPRINTF', $item->category_title);
|
||||
$classes = 'badge bg-secondary';
|
||||
|
||||
$item->link = '<a href="' . $url . '" class="' . $classes . '">' . $text . '</a>'
|
||||
. '<div role="tooltip" id="tip-' . (int) $weblinkid . '-' . (int) $item->id . '">' . $tooltip . '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Display warning if Content Language is trashed or deleted
|
||||
$app->enqueueMessage(Text::sprintf('JGLOBAL_ASSOCIATIONS_CONTENTLANGUAGE_WARNING', $item->lang_code), 'warning');
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\Service\HTML;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
|
@ -36,7 +38,6 @@ class Icon
|
|||
* @since 4.0.0
|
||||
*/
|
||||
private $application;
|
||||
|
||||
/**
|
||||
* Service constructor
|
||||
*
|
||||
|
@ -60,28 +61,20 @@ class Icon
|
|||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public static function create($category, $params, $attribs = array())
|
||||
public static function create($category, $params, $attribs = [])
|
||||
{
|
||||
$uri = Uri::getInstance();
|
||||
|
||||
$url = 'index.php?option=com_weblinks&task=weblink.add&return=' . base64_encode($uri) . '&w_id=0&catid=' . $category->id;
|
||||
|
||||
$text = LayoutHelper::render('joomla.content.icons.create', array('params' => $params, 'legacy' => false));
|
||||
|
||||
$text = LayoutHelper::render('joomla.content.icons.create', ['params' => $params, 'legacy' => false]);
|
||||
// Add the button classes to the attribs array
|
||||
if (isset($attribs['class']))
|
||||
{
|
||||
if (isset($attribs['class'])) {
|
||||
$attribs['class'] .= ' btn btn-primary';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$attribs['class'] = 'btn btn-primary';
|
||||
}
|
||||
|
||||
$button = HTMLHelper::_('link', Route::_($url), $text, $attribs);
|
||||
|
||||
$output = '<span class="hasTooltip" title="' . HTMLHelper::_('tooltipText', 'COM_WEBLINKS_FORM_CREATE_WEBLINK') . '">' . $button . '</span>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@ -100,73 +93,62 @@ class Icon
|
|||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public static function edit($weblink, $params, $attribs = array(), $legacy = false)
|
||||
public static function edit($weblink, $params, $attribs = [], $legacy = false)
|
||||
{
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
$uri = Uri::getInstance();
|
||||
|
||||
// Ignore if in a popup window.
|
||||
if ($params && $params->get('popup'))
|
||||
{
|
||||
if ($params && $params->get('popup')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Ignore if the state is negative (trashed).
|
||||
if ($weblink->state < 0)
|
||||
{
|
||||
if ($weblink->state < 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Show checked_out icon if the contact is checked out by a different user
|
||||
if (property_exists($weblink, 'checked_out')
|
||||
if (
|
||||
property_exists($weblink, 'checked_out')
|
||||
&& property_exists($weblink, 'checked_out_time')
|
||||
&& $weblink->checked_out
|
||||
&& $weblink->checked_out !== $user->get('id'))
|
||||
{
|
||||
&& $weblink->checked_out !== $user->get('id')
|
||||
) {
|
||||
$checkoutUser = Factory::getUser($weblink->checked_out);
|
||||
$date = HTMLHelper::_('date', $weblink->checked_out_time);
|
||||
$tooltip = Text::sprintf('COM_WEBLINKS_CHECKED_OUT_BY', $checkoutUser->name)
|
||||
. ' <br> ' . $date;
|
||||
|
||||
$text = LayoutHelper::render('joomla.content.icons.edit_lock', array('contact' => $weblink, 'tooltip' => $tooltip, 'legacy' => $legacy));
|
||||
|
||||
$text = LayoutHelper::render('joomla.content.icons.edit_lock', ['contact' => $weblink, 'tooltip' => $tooltip, 'legacy' => $legacy]);
|
||||
$attribs['aria-describedby'] = 'editweblink-' . (int) $weblink->id;
|
||||
$output = HTMLHelper::_('link', '#', $text, $attribs);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
$weblinkUrl = RouteHelper::getWeblinkRoute($weblink->slug, $weblink->catid, $weblink->language);
|
||||
$url = $weblinkUrl . '&task=weblink.edit&w_id=' . $weblink->id . '&return=' . base64_encode($uri);
|
||||
|
||||
if ((int) $weblink->state === 0)
|
||||
{
|
||||
if ((int) $weblink->state === 0) {
|
||||
$tooltip = Text::_('COM_WEBLINKS_EDIT_UNPUBLISHED_WEBLINK');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$tooltip = Text::_('COM_WEBLINKS_EDIT_PUBLISHED_WEBLINK');
|
||||
}
|
||||
|
||||
$nowDate = strtotime(Factory::getDate());
|
||||
$icon = $weblink->state ? 'edit' : 'eye-slash';
|
||||
|
||||
if (($weblink->publish_up !== null && strtotime($weblink->publish_up) > $nowDate)
|
||||
if (
|
||||
($weblink->publish_up !== null && strtotime($weblink->publish_up) > $nowDate)
|
||||
|| ($weblink->publish_down !== null && strtotime($weblink->publish_down) < $nowDate
|
||||
&& $weblink->publish_down !== Factory::getDbo()->getNullDate()))
|
||||
{
|
||||
&& $weblink->publish_down !== Factory::getDbo()->getNullDate())
|
||||
) {
|
||||
$icon = 'eye-slash';
|
||||
}
|
||||
|
||||
$aria_described = 'editweblink-' . (int) $weblink->id;
|
||||
|
||||
$text = '<span class="icon-' . $icon . '" aria-hidden="true"></span>';
|
||||
$text .= Text::_('JGLOBAL_EDIT');
|
||||
$text .= '<div role="tooltip" id="' . $aria_described . '">' . $tooltip . '</div>';
|
||||
|
||||
$attribs['aria-describedby'] = $aria_described;
|
||||
$output = HTMLHelper::_('link', Route::_($url), $text, $attribs);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -21,8 +22,9 @@ use Joomla\CMS\Versioning\VersionableTableInterface;
|
|||
use Joomla\Database\ParameterType;
|
||||
use Joomla\String\StringHelper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* Weblink Table class
|
||||
*
|
||||
|
@ -38,16 +40,16 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
|||
* @var boolean
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
protected $_supportNullValue = true;
|
||||
|
||||
|
||||
protected $_supportNullValue = true;
|
||||
/**
|
||||
* Ensure the params and metadata in json encoded in the bind method
|
||||
*
|
||||
* @var array
|
||||
* @since 3.4
|
||||
*/
|
||||
protected $_jsonEncode = array('params', 'metadata', 'images');
|
||||
|
||||
protected $_jsonEncode = ['params', 'metadata', 'images'];
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -58,9 +60,7 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
|||
public function __construct($db)
|
||||
{
|
||||
$this->typeAlias = 'com_weblinks.weblink';
|
||||
|
||||
parent::__construct('#__weblinks', 'id', $db);
|
||||
|
||||
// Set the published column alias
|
||||
$this->setColumnAlias('published', 'state');
|
||||
}
|
||||
|
@ -78,71 +78,58 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
|||
{
|
||||
$date = Factory::getDate()->toSql();
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
|
||||
$this->modified = $date;
|
||||
|
||||
if ($this->id)
|
||||
{
|
||||
if ($this->id) {
|
||||
// Existing item
|
||||
$this->modified_by = $user->id;
|
||||
$this->modified = $date;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// New weblink. A weblink created and created_by field can be set by the user,
|
||||
// so we don't touch either of these if they are set.
|
||||
if (!(int) $this->created)
|
||||
{
|
||||
if (!(int) $this->created) {
|
||||
$this->created = $date;
|
||||
}
|
||||
|
||||
if (empty($this->created_by))
|
||||
{
|
||||
if (empty($this->created_by)) {
|
||||
$this->created_by = $user->id;
|
||||
}
|
||||
|
||||
if (!(int) $this->modified)
|
||||
{
|
||||
if (!(int) $this->modified) {
|
||||
$this->modified = $date;
|
||||
}
|
||||
|
||||
if (empty($this->modified_by))
|
||||
{
|
||||
if (empty($this->modified_by)) {
|
||||
$this->modified_by = $user->id;
|
||||
}
|
||||
|
||||
if (empty($this->hits))
|
||||
{
|
||||
if (empty($this->hits)) {
|
||||
$this->hits = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Set publish_up to null if not set
|
||||
if (!$this->publish_up)
|
||||
{
|
||||
if (!$this->publish_up) {
|
||||
$this->publish_up = null;
|
||||
}
|
||||
|
||||
// Set publish_down to null if not set
|
||||
if (!$this->publish_down)
|
||||
{
|
||||
if (!$this->publish_down) {
|
||||
$this->publish_down = null;
|
||||
}
|
||||
|
||||
// Verify that the alias is unique
|
||||
$table = new WeblinkTable($this->getDbo());
|
||||
|
||||
if ($table->load(array('language' => $this->language, 'alias' => $this->alias, 'catid' => (int) $this->catid))
|
||||
&& ($table->id != $this->id || $this->id == 0))
|
||||
{
|
||||
if (
|
||||
$table->load(['language' => $this->language, 'alias' => $this->alias, 'catid' => (int) $this->catid])
|
||||
&& ($table->id != $this->id || $this->id == 0)
|
||||
) {
|
||||
$this->setError(Text::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert IDN urls to punycode
|
||||
$this->url = PunycodeHelper::urlToPunycode($this->url);
|
||||
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
|
||||
|
@ -155,24 +142,19 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
|||
*/
|
||||
public function check()
|
||||
{
|
||||
if (InputFilter::checkAttribute(array('href', $this->url)))
|
||||
{
|
||||
if (InputFilter::checkAttribute(['href', $this->url])) {
|
||||
$this->setError(Text::_('COM_WEBLINKS_ERR_TABLES_PROVIDE_URL'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for valid name
|
||||
if (trim($this->title) == '')
|
||||
{
|
||||
if (trim($this->title) == '') {
|
||||
$this->setError(Text::_('COM_WEBLINKS_ERR_TABLES_TITLE'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for existing name
|
||||
$db = $this->getDbo();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('id'))
|
||||
->from($db->quoteName('#__weblinks'))
|
||||
|
@ -183,33 +165,24 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
|||
->bind(':language', $this->language)
|
||||
->bind(':catid', $this->catid, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
$xid = (int) $db->loadResult();
|
||||
|
||||
if ($xid && $xid != (int) $this->id)
|
||||
{
|
||||
if ($xid && $xid != (int) $this->id) {
|
||||
$this->setError(Text::_('COM_WEBLINKS_ERR_TABLES_NAME'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->alias))
|
||||
{
|
||||
if (empty($this->alias)) {
|
||||
$this->alias = $this->title;
|
||||
}
|
||||
|
||||
$this->alias = ApplicationHelper::stringURLSafe($this->alias, $this->language);
|
||||
|
||||
if (trim(str_replace('-', '', $this->alias)) == '')
|
||||
{
|
||||
if (trim(str_replace('-', '', $this->alias)) == '') {
|
||||
$this->alias = Factory::getDate()->format("Y-m-d-H-i-s");
|
||||
}
|
||||
|
||||
// Check the publish down date is not earlier than publish up.
|
||||
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up)
|
||||
{
|
||||
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up) {
|
||||
$this->setError(Text::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -217,19 +190,15 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
|||
* 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)) {
|
||||
// Array of characters to remove
|
||||
$bad_characters = array("\n", "\r", "\"", "<", ">");
|
||||
$bad_characters = ["\n", "\r", "\"", "<", ">"];
|
||||
$after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey);
|
||||
$keys = explode(',', $after_clean);
|
||||
$clean_keys = array();
|
||||
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
$clean_keys = [];
|
||||
foreach ($keys as $key) {
|
||||
// Ignore blank keywords
|
||||
if (trim($key))
|
||||
{
|
||||
if (trim($key)) {
|
||||
$clean_keys[] = trim($key);
|
||||
}
|
||||
}
|
||||
|
@ -242,35 +211,28 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
|||
* Ensure any new items have compulsory fields set. This is needed for things like
|
||||
* frontend editing where we don't show all the fields or using some kind of API
|
||||
*/
|
||||
if (!$this->id)
|
||||
{
|
||||
if (!isset($this->xreference))
|
||||
{
|
||||
if (!$this->id) {
|
||||
if (!isset($this->xreference)) {
|
||||
$this->xreference = '';
|
||||
}
|
||||
|
||||
if (!isset($this->metakey))
|
||||
{
|
||||
if (!isset($this->metakey)) {
|
||||
$this->metakey = '';
|
||||
}
|
||||
|
||||
if (!isset($this->metadesc))
|
||||
{
|
||||
if (!isset($this->metadesc)) {
|
||||
$this->metadesc = '';
|
||||
}
|
||||
|
||||
if (!isset($this->images))
|
||||
{
|
||||
if (!isset($this->images)) {
|
||||
$this->images = '{}';
|
||||
}
|
||||
|
||||
if (!isset($this->metadata))
|
||||
{
|
||||
if (!isset($this->metadata)) {
|
||||
$this->metadata = '{}';
|
||||
}
|
||||
|
||||
if (!isset($this->params))
|
||||
{
|
||||
if (!isset($this->params)) {
|
||||
$this->params = '{}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\View\Weblink;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
|
@ -62,14 +65,12 @@ class HtmlView extends BaseHtmlView
|
|||
$this->form = $this->get('Form');
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
if (count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
// If we are forcing a language in modal (used for associations).
|
||||
if ($this->getLayout() === 'modal' && $forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'cmd'))
|
||||
{
|
||||
if ($this->getLayout() === 'modal' && $forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
|
||||
// Set the language field to the forcedLanguage and disable changing it.
|
||||
$this->form->setValue('language', null, $forcedLanguage);
|
||||
$this->form->setFieldAttribute('language', 'readonly', 'true');
|
||||
|
@ -108,48 +109,41 @@ class HtmlView extends BaseHtmlView
|
|||
ToolbarHelper::title($isNew ? Text::_('COM_WEBLINKS_MANAGER_WEBLINK_NEW') : Text::_('COM_WEBLINKS_MANAGER_WEBLINK_EDIT'), 'link weblinks');
|
||||
|
||||
// Build the actions for new and existing records.
|
||||
if ($isNew)
|
||||
{
|
||||
if ($isNew) {
|
||||
// For new records, check the create permission.
|
||||
if (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)
|
||||
{
|
||||
if (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0) {
|
||||
ToolbarHelper::apply('weblink.apply');
|
||||
|
||||
ToolbarHelper::saveGroup(
|
||||
[
|
||||
['save', 'weblink.save'],
|
||||
['save2new', 'weblink.save2new']
|
||||
['save2new', 'weblink.save2new'],
|
||||
],
|
||||
'btn-success'
|
||||
);
|
||||
}
|
||||
|
||||
ToolbarHelper::cancel('weblink.cancel');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
|
||||
$itemEditable = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $user->id);
|
||||
|
||||
$toolbarButtons = [];
|
||||
|
||||
// Can't save the record if it's checked out and editable
|
||||
if (!$checkedOut && $itemEditable)
|
||||
{
|
||||
if (!$checkedOut && $itemEditable) {
|
||||
ToolbarHelper::apply('weblink.apply');
|
||||
|
||||
$toolbarButtons[] = ['save', 'weblink.save'];
|
||||
|
||||
// We can save this record, but check the create permission to see if we can return to make a new one.
|
||||
if ($canDo->get('core.create'))
|
||||
{
|
||||
if ($canDo->get('core.create')) {
|
||||
$toolbarButtons[] = ['save2new', 'weblink.save2new'];
|
||||
}
|
||||
}
|
||||
|
||||
// If checked out, we can still save
|
||||
if ($canDo->get('core.create'))
|
||||
{
|
||||
if ($canDo->get('core.create')) {
|
||||
$toolbarButtons[] = ['save2copy', 'weblink.save2copy'];
|
||||
}
|
||||
|
||||
|
@ -160,13 +154,11 @@ class HtmlView extends BaseHtmlView
|
|||
|
||||
ToolbarHelper::cancel('weblink.cancel', 'JTOOLBAR_CLOSE');
|
||||
|
||||
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $itemEditable)
|
||||
{
|
||||
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $itemEditable) {
|
||||
ToolbarHelper::versions('com_weblinks.weblink', $this->item->id);
|
||||
}
|
||||
|
||||
if (Associations::isEnabled() && ComponentHelper::isEnabled('com_associations'))
|
||||
{
|
||||
if (Associations::isEnabled() && ComponentHelper::isEnabled('com_associations')) {
|
||||
ToolbarHelper::custom('weblink.editAssociations', 'contract', '', 'JTOOLBAR_ASSOCIATIONS', false, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Administrator\View\Weblinks;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
|
@ -85,27 +88,21 @@ class HtmlView extends BaseHtmlView
|
|||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
if (count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState'))
|
||||
{
|
||||
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
|
||||
$this->setLayout('emptystate');
|
||||
}
|
||||
|
||||
// We don't need toolbar in the modal layout.
|
||||
if ($this->getLayout() !== 'modal')
|
||||
{
|
||||
if ($this->getLayout() !== 'modal') {
|
||||
$this->addToolbar();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// 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.
|
||||
if ($forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'CMD'))
|
||||
{
|
||||
if ($forcedLanguage = Factory::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.
|
||||
$languageXml = new \SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
|
||||
$this->filterForm->setField($languageXml, 'filter', true);
|
||||
|
@ -138,13 +135,11 @@ class HtmlView extends BaseHtmlView
|
|||
|
||||
ToolbarHelper::title(Text::_('COM_WEBLINKS_MANAGER_WEBLINKS'), 'link weblinks');
|
||||
|
||||
if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)
|
||||
{
|
||||
if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0) {
|
||||
ToolbarHelper::addNew('weblink.add');
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && $canDo->get('core.edit.state'))
|
||||
{
|
||||
if (!$this->isEmptyState && $canDo->get('core.edit.state')) {
|
||||
$dropdown = $toolbar->dropdownButton('status-group')
|
||||
->text('JTOOLBAR_CHANGE_STATUS')
|
||||
->toggleSplit(false)
|
||||
|
@ -160,21 +155,20 @@ class HtmlView extends BaseHtmlView
|
|||
|
||||
$childBar->archive('weblinks.archive')->listCheck(true);
|
||||
|
||||
if ($user->authorise('core.admin'))
|
||||
{
|
||||
if ($user->authorise('core.admin')) {
|
||||
$childBar->checkin('weblinks.checkin')->listCheck(true);
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') != -2)
|
||||
{
|
||||
if ($this->state->get('filter.published') != -2) {
|
||||
$childBar->trash('weblinks.trash')->listCheck(true);
|
||||
}
|
||||
|
||||
// Add a batch button
|
||||
if ($user->authorise('core.create', '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')
|
||||
) {
|
||||
$childBar->popupButton('batch')
|
||||
->text('JTOOLBAR_BATCH')
|
||||
->selector('collapseModal')
|
||||
|
@ -182,16 +176,14 @@ class HtmlView extends BaseHtmlView
|
|||
}
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && $this->state->get('filter.published') == -2 && $canDo->get('core.delete'))
|
||||
{
|
||||
if (!$this->isEmptyState && $this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
|
||||
$toolbar->delete('weblinks.delete')
|
||||
->text('JTOOLBAR_EMPTY_TRASH')
|
||||
->message('JGLOBAL_CONFIRM_DELETE')
|
||||
->listCheck(true);
|
||||
}
|
||||
|
||||
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')) {
|
||||
ToolbarHelper::preferences('com_weblinks');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -7,26 +8,22 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
HTMLHelper::_('behavior.formvalidator');
|
||||
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->input;
|
||||
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
// Fieldsets to not automatically render by /layouts/joomla/edit/params.php
|
||||
$this->ignore_fieldsets = array('details', 'images', 'item_associations', 'jmetadata');
|
||||
$this->useCoreUI = true;
|
||||
|
||||
// In case of modal
|
||||
$isModal = $input->get('layout') == 'modal' ? true : false;
|
||||
$layout = $isModal ? 'modal' : 'edit';
|
||||
|
@ -65,9 +62,11 @@ $tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=c
|
|||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_IMAGE_OPTIONS'); ?></legend>
|
||||
<div>
|
||||
<?php echo $this->form->renderField('imaJGLOBAL_FIELDSET_IMAGE_OPTIONSges'); ?>
|
||||
<?php foreach ($this->form->getGroup('images') as $field) : ?>
|
||||
<?php foreach ($this->form->getGroup('images') as $field) :
|
||||
?>
|
||||
<?php echo $field->renderField(); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
@ -94,16 +93,20 @@ $tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=c
|
|||
|
||||
<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>
|
||||
|
||||
<?php if (!$isModal && $assoc) : ?>
|
||||
<?php if (!$isModal && $assoc) :
|
||||
?>
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'associations', Text::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?>
|
||||
<fieldset id="fieldset-associations" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_ASSOCIATIONS'); ?></legend>
|
||||
<?php echo LayoutHelper::render('joomla.edit.associations', $this); ?>
|
||||
</fieldset>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
<?php elseif ($isModal && $assoc) : ?>
|
||||
<?php
|
||||
elseif ($isModal && $assoc) :
|
||||
?>
|
||||
<div class="hidden"><?php echo $this->loadTemplate('associations'); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,8 +8,8 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
echo LayoutHelper::render('joomla.edit.associations', $this);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -7,8 +8,8 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
echo LayoutHelper::render('joomla.edit.metadata', $this);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -7,21 +8,27 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$fieldSets = $this->form->getFieldsets('params'); ?>
|
||||
<?php foreach ($fieldSets as $name => $fieldSet) : ?>
|
||||
<?php foreach ($fieldSets as $name => $fieldSet) :
|
||||
?>
|
||||
<div class="tab-pane" id="params-<?php echo $name; ?>">
|
||||
<?php if (isset($fieldSet->description) && trim($fieldSet->description)) : ?>
|
||||
<?php if (isset($fieldSet->description) && trim($fieldSet->description)) :
|
||||
?>
|
||||
<?php echo '<p class="alert alert-info">' . $this->escape(Text::_($fieldSet->description)) . '</p>'; ?>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php foreach ($this->form->getFieldset($name) as $field) :
|
||||
?>
|
||||
<div class="control-group">
|
||||
<div class="control-label"><?php echo $field->label; ?></div>
|
||||
<div class="controls"><?php echo $field->input; ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -6,16 +7,15 @@
|
|||
* @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;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
|
||||
HTMLHelper::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
|
||||
|
||||
// @deprecated 4.0 the function parameter, the inline js and the buttons are not needed since 3.7.0.
|
||||
$function = Factory::getApplication()->input->getCmd('function', 'jEditWeblink_' . (int) $this->item->id);
|
||||
|
||||
// Function to update input title when changed
|
||||
Factory::getDocument()->addScriptDeclaration('
|
||||
function jEditWeblinkModal() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,8 +8,8 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
echo LayoutHelper::render('joomla.edit.associations', $this);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,8 +8,8 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
echo LayoutHelper::render('joomla.edit.metadata', $this);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,21 +8,27 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$fieldSets = $this->form->getFieldsets('params'); ?>
|
||||
<?php foreach ($fieldSets as $name => $fieldSet) : ?>
|
||||
<?php foreach ($fieldSets as $name => $fieldSet) :
|
||||
?>
|
||||
<div class="tab-pane" id="params-<?php echo $name; ?>">
|
||||
<?php if (isset($fieldSet->description) && trim($fieldSet->description)) : ?>
|
||||
<?php if (isset($fieldSet->description) && trim($fieldSet->description)) :
|
||||
?>
|
||||
<?php echo '<p class="alert alert-info">' . $this->escape(Text::_($fieldSet->description)) . '</p>'; ?>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php foreach ($this->form->getFieldset($name) as $field) :
|
||||
?>
|
||||
<div class="control-group">
|
||||
<div class="control-label"><?php echo $field->label; ?></div>
|
||||
<div class="controls"><?php echo $field->input; ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -7,8 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
|
@ -16,20 +18,16 @@ use Joomla\CMS\Language\Multilanguage;
|
|||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var \Joomla\Component\Weblinks\Administrator\View\Weblinks\HtmlView $this */
|
||||
|
||||
HTMLHelper::_('behavior.multiselect');
|
||||
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
$userId = $user->get('id');
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$saveOrder = $listOrder == 'a.ordering';
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
if ($saveOrder && !empty($this->items))
|
||||
{
|
||||
if ($saveOrder && !empty($this->items)) {
|
||||
$saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component';
|
||||
HTMLHelper::_('draggablelist.draggable');
|
||||
}
|
||||
|
@ -42,12 +40,15 @@ if ($saveOrder && !empty($this->items))
|
|||
// Search tools bar
|
||||
echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]);
|
||||
?>
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<?php if (empty($this->items)) :
|
||||
?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<table class="table" id="weblinkList">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_WEBLINKS_WEBLINKS_TABLE_CAPTION'); ?>,
|
||||
|
@ -74,23 +75,30 @@ if ($saveOrder && !empty($this->items))
|
|||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php if ($assoc) : ?>
|
||||
<?php if ($assoc) :
|
||||
?>
|
||||
<th scope="col" class="w-10">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_WEBLINKS_HEADING_ASSOCIATION', 'association', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php if (Multilanguage::isEnabled()) :
|
||||
?>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<th scope="col" class="w-5 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody <?php if ($saveOrder) :?> class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="<?php echo strtolower($listDirn); ?>" data-nested="true"<?php endif; ?>>
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<tbody <?php if ($saveOrder) :
|
||||
?> class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="<?php echo strtolower($listDirn); ?>" data-nested="true"<?php
|
||||
endif; ?>>
|
||||
<?php foreach ($this->items as $i => $item) :
|
||||
?>
|
||||
<?php $item->cat_link = Route::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]=' . $item->catid); ?>
|
||||
<?php $canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid); ?>
|
||||
<?php $canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid); ?>
|
||||
|
@ -104,37 +112,42 @@ if ($saveOrder && !empty($this->items))
|
|||
<td class="text-center d-none d-md-table-cell">
|
||||
<?php
|
||||
$iconClass = '';
|
||||
if (!$canChange)
|
||||
{
|
||||
if (!$canChange) {
|
||||
$iconClass = ' inactive';
|
||||
}
|
||||
elseif (!$saveOrder)
|
||||
{
|
||||
} elseif (!$saveOrder) {
|
||||
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
|
||||
}
|
||||
?>
|
||||
<span class="sortable-handler<?php echo $iconClass; ?>">
|
||||
<span class="icon-ellipsis-v" aria-hidden="true"></span>
|
||||
</span>
|
||||
<?php if ($canChange && $saveOrder) : ?>
|
||||
<?php if ($canChange && $saveOrder) :
|
||||
?>
|
||||
<input type="text" name="order[]" size="5"
|
||||
value="<?php echo $item->ordering; ?>" class="width-20 text-area-order hidden">
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
|
||||
</td>
|
||||
<th scope="row" class="has-context">
|
||||
<div>
|
||||
<?php if ($item->checked_out) : ?>
|
||||
<?php if ($item->checked_out) :
|
||||
?>
|
||||
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($canEdit || $canEditOwn) : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php if ($canEdit || $canEditOwn) :
|
||||
?>
|
||||
<a href="<?php echo Route::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->title); ?>">
|
||||
<?php echo $this->escape($item->title); ?></a>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<?php echo $this->escape($item->title); ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<span class="small">
|
||||
<?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
|
||||
</span>
|
||||
|
@ -149,23 +162,30 @@ if ($saveOrder && !empty($this->items))
|
|||
<td class="d-none d-md-table-cell">
|
||||
<?php echo $item->hits; ?>
|
||||
</td>
|
||||
<?php if ($assoc) : ?>
|
||||
<?php if ($assoc) :
|
||||
?>
|
||||
<td class="hidden-phone hidden-tablet">
|
||||
<?php if ($item->association) : ?>
|
||||
<?php if ($item->association) :
|
||||
?>
|
||||
<?php echo HTMLHelper::_('weblinksadministrator.association', $item->id); ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php if (Multilanguage::isEnabled()) :
|
||||
?>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo (int) $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -173,20 +193,20 @@ if ($saveOrder && !empty($this->items))
|
|||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
|
||||
<?php // Load the batch processing form. ?>
|
||||
<?php if ($user->authorise('core.create', 'com_weblinks')
|
||||
<?php if (
|
||||
$user->authorise('core.create', 'com_weblinks')
|
||||
&& $user->authorise('core.edit', 'com_weblinks')
|
||||
&& $user->authorise('core.edit.state', 'com_weblinks')) : ?>
|
||||
<?php echo HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'collapseModal',
|
||||
[
|
||||
&& $user->authorise('core.edit.state', 'com_weblinks')
|
||||
) :
|
||||
?>
|
||||
<?php echo HTMLHelper::_('bootstrap.renderModal', 'collapseModal', [
|
||||
'title' => Text::_('COM_WEBLINKS_BATCH_OPTIONS'),
|
||||
'footer' => $this->loadTemplate('batch_footer')
|
||||
],
|
||||
$this->loadTemplate('batch_body')
|
||||
); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
], $this->loadTemplate('batch_body')); ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<input type="hidden" name="boxchecked" value="0">
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -6,23 +7,26 @@
|
|||
* @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;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
$published = $this->state->get('filter.published');
|
||||
?>
|
||||
|
||||
<div class="p-3">
|
||||
<div class="row">
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<?php if (Multilanguage::isEnabled()) :
|
||||
?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.language', []); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.access', []); ?>
|
||||
|
@ -30,13 +34,15 @@ $published = $this->state->get('filter.published');
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php if ($published >= 0) : ?>
|
||||
<?php if ($published >= 0) :
|
||||
?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.item', ['extension' => 'com_weblinks']); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.tag', []); ?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -6,8 +7,10 @@
|
|||
* @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;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -7,22 +8,19 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
$displayData = [
|
||||
'textPrefix' => 'COM_WEBLINKS',
|
||||
'formURL' => 'index.php?option=com_weblinks',
|
||||
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help4.x:Weblinks',
|
||||
'icon' => 'icon-globe weblink',
|
||||
];
|
||||
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
|
||||
if ($user->authorise('core.create', 'com_weblinks') || count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)
|
||||
{
|
||||
if ($user->authorise('core.create', 'com_weblinks') || count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0) {
|
||||
$displayData['createURL'] = 'index.php?option=com_weblinks&task=weblink.add';
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,8 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
|
@ -17,29 +19,22 @@ use Joomla\CMS\Layout\LayoutHelper;
|
|||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
|
||||
|
||||
$app = Factory::getApplication();
|
||||
|
||||
if ($app->isClient('site'))
|
||||
{
|
||||
if ($app->isClient('site')) {
|
||||
Session::checkToken('get') or die(Text::_('JINVALID_TOKEN'));
|
||||
}
|
||||
|
||||
HTMLHelper::_('behavior.multiselect');
|
||||
|
||||
$this->document->getWebAssetManager()
|
||||
->registerAndUseScript('com_weblinks.admin-weblinks-modal', 'media/com_weblinks/js/admin-weblinks-modal.js', [], ['defer' => true], ['core']);
|
||||
|
||||
$function = $app->input->getCmd('function', 'jSelectWeblink');
|
||||
$editor = $app->input->getCmd('editor', '');
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$onclick = $this->escape($function);
|
||||
$multilang = Multilanguage::isEnabled();
|
||||
|
||||
if (!empty($editor))
|
||||
{
|
||||
// This view is used also in com_menus. Load the xtd script only if the editor is set!
|
||||
if (!empty($editor)) {
|
||||
// This view is used also in com_menus. Load the xtd script only if the editor is set!
|
||||
$this->document->addScriptOptions('xtd-weblinks', array('editor' => $editor));
|
||||
$onclick = "jSelectWeblink";
|
||||
}
|
||||
|
@ -58,11 +53,14 @@ $iconStates = array(
|
|||
|
||||
<?php echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
|
||||
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<?php if (empty($this->items)) :
|
||||
?>
|
||||
<div class="alert alert-no-items">
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<table class="table table-sm">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_WEBLINKS_WEBLINKS_TABLE_CAPTION'); ?>,
|
||||
|
@ -80,11 +78,13 @@ $iconStates = array(
|
|||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php if ($multilang) : ?>
|
||||
<?php if ($multilang) :
|
||||
?>
|
||||
<th scope="col" class="w-15">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JDATE', 'a.created', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
|
@ -94,16 +94,23 @@ $iconStates = array(
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<?php foreach ($this->items as $i => $item) :
|
||||
?>
|
||||
<?php $lang = ''; ?>
|
||||
<?php if ($item->language && $multilang) : ?>
|
||||
<?php if ($item->language && $multilang) :
|
||||
?>
|
||||
<?php $tag = strlen($item->language); ?>
|
||||
<?php if ($tag == 5) : ?>
|
||||
<?php if ($tag == 5) :
|
||||
?>
|
||||
<?php $lang = substr($item->language, 0, 2); ?>
|
||||
<?php elseif ($tag == 6) : ?>
|
||||
<?php
|
||||
elseif ($tag == 6) :
|
||||
?>
|
||||
<?php $lang = substr($item->language, 0, 3); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<tr class="row<?php echo $i % 2; ?>">
|
||||
<td class="center">
|
||||
<span class="<?php echo $iconStates[$this->escape($item->state)]; ?>"></span>
|
||||
|
@ -126,11 +133,13 @@ $iconStates = array(
|
|||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $this->escape($item->access_level); ?>
|
||||
</td>
|
||||
<?php if ($multilang) : ?>
|
||||
<?php if ($multilang) :
|
||||
?>
|
||||
<td class="small">
|
||||
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('date', $item->created, Text::_('DATE_FORMAT_LC4')); ?>
|
||||
</td>
|
||||
|
@ -138,10 +147,12 @@ $iconStates = array(
|
|||
<?php echo (int) $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php // load the pagination. ?>
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -7,8 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* Installation class to perform additional changes during install/uninstall/update
|
||||
*
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,8 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* Weblink Component HTML Helper.
|
||||
*
|
||||
|
@ -38,7 +40,7 @@ class JHtmlIcon
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function edit($weblink, $params, $attribs = array())
|
||||
public static function edit($weblink, $params, $attribs = [])
|
||||
{
|
||||
return self::getIcon()->edit($weblink, $params, $attribs);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,8 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
|
||||
|
||||
/**
|
||||
|
@ -18,5 +20,4 @@ use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
|
|||
*/
|
||||
abstract class WeblinksHelperRoute extends RouteHelper
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Site\Controller;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
|
||||
|
@ -36,7 +38,6 @@ class DisplayController extends BaseController
|
|||
{
|
||||
// Huh? Why not just put that in the constructor?
|
||||
$cacheable = true;
|
||||
|
||||
/**
|
||||
* Set the default view name and format from the Request.
|
||||
* Note we are using w_id to avoid collisions with the router and the return page.
|
||||
|
@ -45,24 +46,20 @@ class DisplayController extends BaseController
|
|||
$id = $this->input->getInt('w_id');
|
||||
$vName = $this->input->get('view', 'categories');
|
||||
$this->input->set('view', $vName);
|
||||
|
||||
if ($this->app->getIdentity()->id ||($this->input->getMethod() == 'POST' && $vName == 'categories'))
|
||||
{
|
||||
if ($this->app->getIdentity()->id || ($this->input->getMethod() == 'POST' && $vName == 'categories')) {
|
||||
$cacheable = false;
|
||||
}
|
||||
|
||||
$safeurlparams = array(
|
||||
$safeurlparams = [
|
||||
'id' => 'INT',
|
||||
'limit' => 'UINT',
|
||||
'limitstart' => 'UINT',
|
||||
'filter_order' => 'CMD',
|
||||
'filter_order_Dir' => 'CMD',
|
||||
'lang' => 'CMD'
|
||||
);
|
||||
|
||||
'lang' => 'CMD',
|
||||
];
|
||||
// Check for edit form.
|
||||
if ($vName == 'form' && !$this->checkEditId('com_weblinks.edit.weblink', $id))
|
||||
{
|
||||
if ($vName == 'form' && !$this->checkEditId('com_weblinks.edit.weblink', $id)) {
|
||||
// Somehow the person just went to the form - we don't allow that.
|
||||
throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 403);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Site\Controller;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
@ -30,7 +32,6 @@ class WeblinkController extends FormController
|
|||
* @since 1.6
|
||||
*/
|
||||
protected $view_item = 'form';
|
||||
|
||||
/**
|
||||
* The URL view list variable.
|
||||
*
|
||||
|
@ -38,7 +39,6 @@ class WeblinkController extends FormController
|
|||
* @since 1.6
|
||||
*/
|
||||
protected $view_list = 'categories';
|
||||
|
||||
/**
|
||||
* The URL edit variable.
|
||||
*
|
||||
|
@ -46,7 +46,6 @@ class WeblinkController extends FormController
|
|||
* @since 3.2
|
||||
*/
|
||||
protected $urlVar = 'a.id';
|
||||
|
||||
/**
|
||||
* Method to add a new record.
|
||||
*
|
||||
|
@ -56,11 +55,9 @@ class WeblinkController extends FormController
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
if (!parent::add())
|
||||
{
|
||||
if (!parent::add()) {
|
||||
// Redirect to the return page.
|
||||
$this->setRedirect($this->getReturnPage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -76,12 +73,10 @@ class WeblinkController extends FormController
|
|||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowAdd($data = array())
|
||||
protected function allowAdd($data = [])
|
||||
{
|
||||
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('id'), 'int');
|
||||
|
||||
if ($categoryId)
|
||||
{
|
||||
if ($categoryId) {
|
||||
// If the category has been passed in the URL check it.
|
||||
return $this->app->getIdentity()->authorise('core.create', $this->option . '.category.' . $categoryId);
|
||||
}
|
||||
|
@ -100,32 +95,25 @@ class WeblinkController extends FormController
|
|||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowEdit($data = array(), $key = 'id')
|
||||
protected function allowEdit($data = [], $key = 'id')
|
||||
{
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
|
||||
if (!$recordId)
|
||||
{
|
||||
if (!$recordId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$record = $this->getModel()->getItem($recordId);
|
||||
$categoryId = (int) $record->catid;
|
||||
|
||||
if ($categoryId)
|
||||
{
|
||||
if ($categoryId) {
|
||||
// The category has been set. Check the category permissions.
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
// First, check edit permission
|
||||
if ($user->authorise('core.edit', $this->option . '.category.' . $categoryId))
|
||||
{
|
||||
if ($user->authorise('core.edit', $this->option . '.category.' . $categoryId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fallback on edit.own
|
||||
if ($user->authorise('core.edit.own', $this->option . '.category.' . $categoryId) && $record->created_by == $user->id)
|
||||
{
|
||||
if ($user->authorise('core.edit.own', $this->option . '.category.' . $categoryId) && $record->created_by == $user->id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -148,10 +136,8 @@ class WeblinkController extends FormController
|
|||
public function cancel($key = 'w_id')
|
||||
{
|
||||
$return = parent::cancel($key);
|
||||
|
||||
// Redirect to the return page.
|
||||
$this->setRedirect($this->getReturnPage());
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -181,7 +167,7 @@ class WeblinkController extends FormController
|
|||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getModel($name = 'form', $prefix = 'Site', $config = array('ignore_request' => true))
|
||||
public function getModel($name = 'form', $prefix = 'Site', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
@ -201,14 +187,11 @@ class WeblinkController extends FormController
|
|||
$append = parent::getRedirectToItemAppend($recordId, $urlVar);
|
||||
$itemId = $this->input->getInt('Itemid');
|
||||
$return = $this->getReturnPage();
|
||||
|
||||
if ($itemId)
|
||||
{
|
||||
if ($itemId) {
|
||||
$append .= '&Itemid=' . $itemId;
|
||||
}
|
||||
|
||||
if ($return)
|
||||
{
|
||||
if ($return) {
|
||||
$append .= '&return=' . base64_encode($return);
|
||||
}
|
||||
|
||||
|
@ -225,9 +208,7 @@ class WeblinkController extends FormController
|
|||
protected function getReturnPage()
|
||||
{
|
||||
$return = $this->input->get('return', null, 'base64');
|
||||
|
||||
if (empty($return) || !Uri::isInternal(base64_decode($return)))
|
||||
{
|
||||
if (empty($return) || !Uri::isInternal(base64_decode($return))) {
|
||||
return Uri::base();
|
||||
}
|
||||
|
||||
|
@ -248,17 +229,13 @@ class WeblinkController extends FormController
|
|||
{
|
||||
// Get the application
|
||||
$app = $this->app;
|
||||
|
||||
// Get the data from POST
|
||||
$data = $this->input->post->get('jform', array(), 'array');
|
||||
|
||||
$data = $this->input->post->get('jform', [], 'array');
|
||||
// Save the data in the session.
|
||||
$app->setUserState('com_weblinks.edit.weblink.data', $data);
|
||||
$result = parent::save($key, $urlVar);
|
||||
|
||||
// If ok, redirect to the return page.
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
// Flush the data from the session
|
||||
$app->setUserState('com_weblinks.edit.weblink.data', null);
|
||||
$this->setRedirect($this->getReturnPage());
|
||||
|
@ -280,50 +257,39 @@ class WeblinkController extends FormController
|
|||
{
|
||||
// Get the ID from the request
|
||||
$id = $this->input->getInt('id');
|
||||
|
||||
// Get the model, requiring published items
|
||||
$modelLink = $this->getModel('Weblink');
|
||||
$modelLink->setState('filter.published', 1);
|
||||
|
||||
// Get the item
|
||||
$link = $modelLink->getItem($id);
|
||||
|
||||
// Make sure the item was found.
|
||||
if (empty($link))
|
||||
{
|
||||
if (empty($link)) {
|
||||
throw new \Exception(Text::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
// Check whether item access level allows access.
|
||||
$groups = $this->app->getIdentity()->getAuthorisedViewLevels();
|
||||
|
||||
if (!in_array($link->access, $groups))
|
||||
{
|
||||
if (!in_array($link->access, $groups)) {
|
||||
throw new \Exception(Text::_('JERROR_ALERTNOAUTHOR'), 403);
|
||||
}
|
||||
|
||||
// Check whether category access level allows access.
|
||||
$modelCat = $this->getModel('Category', 'Site', array('ignore_request' => true));
|
||||
$modelCat = $this->getModel('Category', 'Site', ['ignore_request' => true]);
|
||||
$modelCat->setState('filter.published', 1);
|
||||
|
||||
// Get the category
|
||||
$category = $modelCat->getCategory($link->catid);
|
||||
|
||||
// Make sure the category was found.
|
||||
if (empty($category))
|
||||
{
|
||||
if (empty($category)) {
|
||||
throw new \Exception(Text::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
// Check whether item access level allows access.
|
||||
if (!in_array($category->access, $groups))
|
||||
{
|
||||
if (!in_array($category->access, $groups)) {
|
||||
throw new \Exception(Text::_('JERROR_ALERTNOAUTHOR'), 403);
|
||||
}
|
||||
|
||||
// Redirect to the URL
|
||||
if ($link->url)
|
||||
{
|
||||
if ($link->url) {
|
||||
$modelLink->hit($id);
|
||||
$this->app->redirect($link->url, 301);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Site\Helper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\Component\Categories\Administrator\Helper\CategoryAssociationHelper;
|
||||
|
@ -37,17 +39,11 @@ abstract class AssociationHelper extends CategoryAssociationHelper
|
|||
$input = Factory::getApplication()->input;
|
||||
$view = is_null($view) ? $input->get('view') : $view;
|
||||
$id = empty($id) ? $input->getInt('id') : $id;
|
||||
|
||||
if ($view === 'weblink')
|
||||
{
|
||||
if ($id)
|
||||
{
|
||||
if ($view === 'weblink') {
|
||||
if ($id) {
|
||||
$associations = Associations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $id);
|
||||
|
||||
$return = array();
|
||||
|
||||
foreach ($associations as $tag => $item)
|
||||
{
|
||||
$return = [];
|
||||
foreach ($associations as $tag => $item) {
|
||||
$return[$tag] = RouteHelper::getWeblinkRoute($item->id, (int) $item->catid, $item->language);
|
||||
}
|
||||
|
||||
|
@ -55,11 +51,10 @@ abstract class AssociationHelper extends CategoryAssociationHelper
|
|||
}
|
||||
}
|
||||
|
||||
if ($view == 'category' || $view == 'categories')
|
||||
{
|
||||
if ($view == 'category' || $view == 'categories') {
|
||||
return self::getCategoryAssociations($id, 'com_weblinks');
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -12,8 +13,9 @@ namespace Joomla\Component\Weblinks\Site\Helper;
|
|||
use Joomla\CMS\Categories\CategoryNode;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* Weblinks Component Route Helper.
|
||||
*
|
||||
|
@ -34,14 +36,11 @@ abstract class RouteHelper
|
|||
{
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_weblinks&view=weblink&id=' . $id;
|
||||
|
||||
if ($catid > 1)
|
||||
{
|
||||
if ($catid > 1) {
|
||||
$link .= '&catid=' . $catid;
|
||||
}
|
||||
|
||||
if ($language && $language !== '*' && Multilanguage::isEnabled())
|
||||
{
|
||||
if ($language && $language !== '*' && Multilanguage::isEnabled()) {
|
||||
$link .= '&lang=' . $language;
|
||||
}
|
||||
|
||||
|
@ -59,17 +58,13 @@ abstract class RouteHelper
|
|||
public static function getFormRoute($id, $return = null)
|
||||
{
|
||||
// Create the link.
|
||||
if ($id)
|
||||
{
|
||||
if ($id) {
|
||||
$link = 'index.php?option=com_weblinks&task=weblink.edit&w_id=' . $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$link = 'index.php?option=com_weblinks&task=weblink.add&w_id=0';
|
||||
}
|
||||
|
||||
if ($return)
|
||||
{
|
||||
if ($return) {
|
||||
$link .= '&return=' . $return;
|
||||
}
|
||||
|
||||
|
@ -86,26 +81,18 @@ abstract class RouteHelper
|
|||
*/
|
||||
public static function getCategoryRoute($catid, $language = 0)
|
||||
{
|
||||
if ($catid instanceof CategoryNode)
|
||||
{
|
||||
if ($catid instanceof CategoryNode) {
|
||||
$id = $catid->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$id = (int) $catid;
|
||||
}
|
||||
|
||||
if ($id < 1)
|
||||
{
|
||||
if ($id < 1) {
|
||||
$link = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_weblinks&view=category&id=' . $id;
|
||||
|
||||
if ($language && $language !== '*' && Multilanguage::isEnabled())
|
||||
{
|
||||
if ($language && $language !== '*' && Multilanguage::isEnabled()) {
|
||||
$link .= '&lang=' . $language;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -15,8 +16,9 @@ use Joomla\CMS\Factory;
|
|||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* This models supports retrieving lists of article categories.
|
||||
*
|
||||
|
@ -31,28 +33,24 @@ class CategoriesModel extends ListModel
|
|||
* @var string
|
||||
*/
|
||||
protected $context = 'com_weblinks.categories';
|
||||
|
||||
/**
|
||||
* The category context (allows other extensions to derived from this model).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_extension = 'com_weblinks';
|
||||
|
||||
/**
|
||||
* Parent category
|
||||
*
|
||||
* @var CategoryNode|null
|
||||
*/
|
||||
private $_parent = null;
|
||||
|
||||
/**
|
||||
* Categories data
|
||||
*
|
||||
* @var false|array
|
||||
*/
|
||||
private $_items = null;
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
|
@ -69,14 +67,11 @@ class CategoriesModel extends ListModel
|
|||
{
|
||||
$app = Factory::getApplication();
|
||||
$this->setState('filter.extension', $this->_extension);
|
||||
|
||||
// Get the parent id if defined.
|
||||
$parentId = $app->input->getInt('id');
|
||||
$this->setState('filter.parentId', $parentId);
|
||||
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
$this->setState('filter.published', 1);
|
||||
$this->setState('filter.access', true);
|
||||
}
|
||||
|
@ -99,7 +94,6 @@ class CategoriesModel extends ListModel
|
|||
$id .= ':' . $this->getState('filter.published');
|
||||
$id .= ':' . $this->getState('filter.access');
|
||||
$id .= ':' . $this->getState('filter.parentId');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
|
@ -110,23 +104,17 @@ class CategoriesModel extends ListModel
|
|||
*/
|
||||
public function getItems()
|
||||
{
|
||||
if ($this->_items === null)
|
||||
{
|
||||
$params = $this->getState('params', new Registry);
|
||||
|
||||
$options = array();
|
||||
if ($this->_items === null) {
|
||||
$params = $this->getState('params', new Registry());
|
||||
$options = [];
|
||||
$options['access'] = $this->getState('filter.access');
|
||||
$options['published'] = $this->getState('filter.published');
|
||||
$options['countItems'] = $params->get('show_cat_num_links', 1) || !$params->get('show_empty_categories_cat', 0);
|
||||
$categories = Categories::getInstance('Weblinks', $options);
|
||||
$this->_parent = $categories->get($this->getState('filter.parentId', 'root'));
|
||||
|
||||
if (is_object($this->_parent))
|
||||
{
|
||||
if (is_object($this->_parent)) {
|
||||
$this->_items = $this->_parent->getChildren();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->_items = false;
|
||||
}
|
||||
}
|
||||
|
@ -141,8 +129,7 @@ class CategoriesModel extends ListModel
|
|||
*/
|
||||
public function getParent()
|
||||
{
|
||||
if (!is_object($this->_parent))
|
||||
{
|
||||
if (!is_object($this->_parent)) {
|
||||
$this->getItems();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Site\Model;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
use Joomla\CMS\Categories\CategoryNode;
|
||||
|
@ -71,16 +74,15 @@ class CategoryModel extends ListModel
|
|||
* @see JControllerLegacy
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'title', 'a.title',
|
||||
'hits', 'a.hits',
|
||||
'ordering', 'a.ordering',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
|
@ -100,29 +102,24 @@ class CategoryModel extends ListModel
|
|||
$taggedItems = [];
|
||||
|
||||
// Convert the params field into an object, saving original in _params
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if (!isset($this->_params))
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
if (!isset($this->_params)) {
|
||||
$item->params = new Registry($item->params);
|
||||
}
|
||||
|
||||
// Some contexts may not use tags data at all, so we allow callers to disable loading tag data
|
||||
if ($this->getState('load_tags', true))
|
||||
{
|
||||
$item->tags = new TagsHelper;
|
||||
if ($this->getState('load_tags', true)) {
|
||||
$item->tags = new TagsHelper();
|
||||
$taggedItems[$item->id] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
// Load tags of all items.
|
||||
if ($taggedItems)
|
||||
{
|
||||
if ($taggedItems) {
|
||||
$tagsHelper = new TagsHelper();
|
||||
$itemIds = \array_keys($taggedItems);
|
||||
|
||||
foreach ($tagsHelper->getMultipleItemTags('com_weblinks.weblink', $itemIds) as $id => $tags)
|
||||
{
|
||||
foreach ($tagsHelper->getMultipleItemTags('com_weblinks.weblink', $itemIds) as $id => $tags) {
|
||||
$taggedItems[$id]->tags->itemTags = $tags;
|
||||
}
|
||||
}
|
||||
|
@ -151,19 +148,15 @@ class CategoryModel extends ListModel
|
|||
->whereIn($db->quoteName('a.access'), $viewLevels);
|
||||
|
||||
// Filter by category.
|
||||
if ($categoryId = $this->getState('category.id'))
|
||||
{
|
||||
if ($categoryId = $this->getState('category.id')) {
|
||||
// Group by subcategory
|
||||
if ($this->getState('category.group', 0))
|
||||
{
|
||||
if ($this->getState('category.group', 0)) {
|
||||
$query->select('c.title AS category_title')
|
||||
->where('c.parent_id = :parent_id')
|
||||
->bind(':parent_id', $categoryId, ParameterType::INTEGER)
|
||||
->join('LEFT', '#__categories AS c ON c.id = a.catid')
|
||||
->whereIn($db->quoteName('c.access'), $viewLevels);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$query->where('a.catid = :catid')
|
||||
->bind(':catid', $categoryId, ParameterType::INTEGER)
|
||||
->join('LEFT', '#__categories AS c ON c.id = a.catid')
|
||||
|
@ -173,8 +166,7 @@ class CategoryModel extends ListModel
|
|||
// Filter by published category
|
||||
$cpublished = $this->getState('filter.c.published');
|
||||
|
||||
if (is_numeric($cpublished))
|
||||
{
|
||||
if (is_numeric($cpublished)) {
|
||||
$query->where('c.published = :published')
|
||||
->bind(':published', $cpublished, ParameterType::INTEGER);
|
||||
}
|
||||
|
@ -189,8 +181,7 @@ class CategoryModel extends ListModel
|
|||
// Filter by state
|
||||
$state = $this->getState('filter.state');
|
||||
|
||||
if (is_numeric($state))
|
||||
{
|
||||
if (is_numeric($state)) {
|
||||
$query->where('a.state = :state')
|
||||
->bind(':state', $state, ParameterType::INTEGER);
|
||||
}
|
||||
|
@ -199,38 +190,32 @@ class CategoryModel extends ListModel
|
|||
$query->where('a.state != -2');
|
||||
|
||||
// Filter by start and end dates.
|
||||
if ($this->getState('filter.publish_date'))
|
||||
{
|
||||
if ($this->getState('filter.publish_date')) {
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
$query->where('(' . $db->quoteName('a.publish_up')
|
||||
. ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publish_up)'
|
||||
)
|
||||
. ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publish_up)')
|
||||
->where('(' . $db->quoteName('a.publish_down')
|
||||
. ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)'
|
||||
)
|
||||
. ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)')
|
||||
->bind(':publish_up', $nowDate)
|
||||
->bind(':publish_down', $nowDate);
|
||||
}
|
||||
|
||||
// Filter by language
|
||||
if ($this->getState('filter.language'))
|
||||
{
|
||||
if ($this->getState('filter.language')) {
|
||||
$query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
|
||||
}
|
||||
|
||||
// Filter by search in title
|
||||
$search = $this->getState('list.filter');
|
||||
|
||||
if (!empty($search))
|
||||
{
|
||||
if (!empty($search)) {
|
||||
$search = '%' . trim($search) . '%';
|
||||
$query->where('(a.title LIKE :search)')
|
||||
->bind(':search', $search);
|
||||
}
|
||||
|
||||
// If grouping by subcategory, add the subcategory list ordering clause.
|
||||
if ($this->getState('category.group', 0))
|
||||
{
|
||||
if ($this->getState('category.group', 0)) {
|
||||
$query->order(
|
||||
$db->escape($this->getState('category.ordering', 'c.lft')) . ' ' .
|
||||
$db->escape($this->getState('category.direction', 'ASC'))
|
||||
|
@ -277,8 +262,7 @@ class CategoryModel extends ListModel
|
|||
|
||||
$orderCol = $app->input->get('filter_order', 'ordering');
|
||||
|
||||
if (!in_array($orderCol, $this->filter_fields))
|
||||
{
|
||||
if (!in_array($orderCol, $this->filter_fields)) {
|
||||
$orderCol = 'ordering';
|
||||
}
|
||||
|
||||
|
@ -286,8 +270,7 @@ class CategoryModel extends ListModel
|
|||
|
||||
$listOrder = $app->input->get('filter_order_Dir', 'ASC');
|
||||
|
||||
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
|
||||
{
|
||||
if (!in_array(strtoupper($listOrder), ['ASC', 'DESC', ''])) {
|
||||
$listOrder = 'ASC';
|
||||
}
|
||||
|
||||
|
@ -298,8 +281,7 @@ class CategoryModel extends ListModel
|
|||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
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.
|
||||
$this->setState('filter.state', 1);
|
||||
|
||||
|
@ -319,32 +301,27 @@ class CategoryModel extends ListModel
|
|||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
if (!is_object($this->_item))
|
||||
{
|
||||
$params = $this->getState('params', new Registry);
|
||||
if (!is_object($this->_item)) {
|
||||
$params = $this->getState('params', new Registry());
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
$options['countItems'] = $params->get('show_cat_num_links_cat', 1)
|
||||
|| $params->get('show_empty_categories', 0);
|
||||
|
||||
$categories = Categories::getInstance('Weblinks', $options);
|
||||
$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->_parent = false;
|
||||
|
||||
if ($this->_item->getParent())
|
||||
{
|
||||
if ($this->_item->getParent()) {
|
||||
$this->_parent = $this->_item->getParent();
|
||||
}
|
||||
|
||||
$this->_rightsibling = $this->_item->getSibling();
|
||||
$this->_leftsibling = $this->_item->getSibling(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->_children = false;
|
||||
$this->_parent = false;
|
||||
}
|
||||
|
@ -360,8 +337,7 @@ class CategoryModel extends ListModel
|
|||
*/
|
||||
public function getParent()
|
||||
{
|
||||
if (!is_object($this->_item))
|
||||
{
|
||||
if (!is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
|
@ -375,8 +351,7 @@ class CategoryModel extends ListModel
|
|||
*/
|
||||
public function &getLeftSibling()
|
||||
{
|
||||
if (!is_object($this->_item))
|
||||
{
|
||||
if (!is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
|
@ -390,8 +365,7 @@ class CategoryModel extends ListModel
|
|||
*/
|
||||
public function &getRightSibling()
|
||||
{
|
||||
if (!is_object($this->_item))
|
||||
{
|
||||
if (!is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
|
@ -405,8 +379,7 @@ class CategoryModel extends ListModel
|
|||
*/
|
||||
public function &getChildren()
|
||||
{
|
||||
if (!is_object($this->_item))
|
||||
{
|
||||
if (!is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
|
@ -426,8 +399,7 @@ class CategoryModel extends ListModel
|
|||
{
|
||||
$hitcount = Factory::getApplication()->input->getInt('hitcount', 1);
|
||||
|
||||
if ($hitcount)
|
||||
{
|
||||
if ($hitcount) {
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
|
||||
$table = Table::getInstance('Category', 'Joomla\\CMS\\Table\\');
|
||||
$table->load($pk);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Site\Model;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
@ -68,8 +71,7 @@ class FormModel extends WeblinkModel
|
|||
|
||||
$return = $app->input->get('return', '', 'base64');
|
||||
|
||||
if ($return && !Uri::isInternal(base64_decode($return)))
|
||||
{
|
||||
if ($return && !Uri::isInternal(base64_decode($return))) {
|
||||
$return = '';
|
||||
}
|
||||
|
||||
|
@ -92,13 +94,12 @@ class FormModel extends WeblinkModel
|
|||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
public function getForm($data = array(), $loadData = true)
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
$form = $this->loadForm('com_weblinks.form', 'weblink', array('control' => 'jform', 'load_data' => $loadData));
|
||||
$form = $this->loadForm('com_weblinks.form', 'weblink', ['control' => 'jform', 'load_data' => $loadData]);
|
||||
|
||||
// Disable the buttons and just allow editor none for not authenticated users
|
||||
if ($this->getCurrentUser()->guest)
|
||||
{
|
||||
if ($this->getCurrentUser()->guest) {
|
||||
$form->setFieldAttribute('description', 'editor', 'none');
|
||||
$form->setFieldAttribute('description', 'buttons', 'no');
|
||||
}
|
||||
|
@ -118,7 +119,7 @@ class FormModel extends WeblinkModel
|
|||
* @since 4.0.0
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getTable($name = 'Weblink', $prefix = 'Administrator', $options = array())
|
||||
public function getTable($name = 'Weblink', $prefix = 'Administrator', $options = [])
|
||||
{
|
||||
return parent::getTable($name, $prefix, $options);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Site\Model;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
|
@ -65,8 +68,7 @@ class WeblinkModel extends ItemModel
|
|||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
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')) {
|
||||
$this->setState('filter.published', 1);
|
||||
$this->setState('filter.archived', 2);
|
||||
}
|
||||
|
@ -87,15 +89,12 @@ class WeblinkModel extends ItemModel
|
|||
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('weblink.id');
|
||||
|
||||
if ($this->_item === null)
|
||||
{
|
||||
$this->_item = array();
|
||||
if ($this->_item === null) {
|
||||
$this->_item = [];
|
||||
}
|
||||
|
||||
if (!isset($this->_item[$pk]))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!isset($this->_item[$pk])) {
|
||||
try {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select($this->getState('item.select', 'a.*'))
|
||||
|
@ -113,8 +112,7 @@ class WeblinkModel extends ItemModel
|
|||
->join('LEFT', '#__users AS u on u.id = a.created_by');
|
||||
|
||||
// Filter by language
|
||||
if ($this->getState('filter.language'))
|
||||
{
|
||||
if ($this->getState('filter.language')) {
|
||||
$query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
|
||||
}
|
||||
|
||||
|
@ -122,16 +120,13 @@ class WeblinkModel extends ItemModel
|
|||
$query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
|
||||
->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
|
||||
|
||||
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')) {
|
||||
// Filter by start and end dates.
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
$query->where('(' . $db->quoteName('a.publish_up')
|
||||
. ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publish_up)'
|
||||
)
|
||||
. ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publish_up)')
|
||||
->where('(' . $db->quoteName('a.publish_down')
|
||||
. ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)'
|
||||
)
|
||||
. ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)')
|
||||
->bind(':publish_up', $nowDate)
|
||||
->bind(':publish_down', $nowDate);
|
||||
}
|
||||
|
@ -140,8 +135,7 @@ class WeblinkModel extends ItemModel
|
|||
$published = $this->getState('filter.published');
|
||||
$archived = $this->getState('filter.archived');
|
||||
|
||||
if (is_numeric($published))
|
||||
{
|
||||
if (is_numeric($published)) {
|
||||
$query->whereIn($db->quoteName('a.state'), [$published, $archived]);
|
||||
}
|
||||
|
||||
|
@ -149,14 +143,12 @@ class WeblinkModel extends ItemModel
|
|||
|
||||
$data = $db->loadObject();
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
if (empty($data)) {
|
||||
throw new \Exception(Text::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
// Check for published state if filter set.
|
||||
if ((is_numeric($published) || is_numeric($archived)) && (($data->state != $published) && ($data->state != $archived)))
|
||||
{
|
||||
if ((is_numeric($published) || is_numeric($archived)) && (($data->state != $published) && ($data->state != $archived))) {
|
||||
throw new \Exception(Text::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
|
@ -165,29 +157,23 @@ class WeblinkModel extends ItemModel
|
|||
$data->metadata = new Registry($data->metadata);
|
||||
|
||||
// Some contexts may not use tags data at all, so we allow callers to disable loading tag data
|
||||
if ($this->getState('load_tags', true))
|
||||
{
|
||||
$data->tags = new TagsHelper;
|
||||
if ($this->getState('load_tags', true)) {
|
||||
$data->tags = new TagsHelper();
|
||||
$data->tags->getItemTags('com_weblinks.weblink', $data->id);
|
||||
}
|
||||
|
||||
// Compute access permissions.
|
||||
if ($access = $this->getState('filter.access'))
|
||||
{
|
||||
if ($access = $this->getState('filter.access')) {
|
||||
// If the access filter has been set, we already know this user can view.
|
||||
$data->params->set('access-view', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// If no access filter is set, the layout takes some responsibility for display of limited information.
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
$data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups));
|
||||
}
|
||||
|
||||
$this->_item[$pk] = $data;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$this->setError($e);
|
||||
$this->_item[$pk] = false;
|
||||
}
|
||||
|
@ -207,7 +193,7 @@ class WeblinkModel extends ItemModel
|
|||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getTable($type = 'Weblink', $prefix = 'Administrator', $config = array())
|
||||
public function getTable($type = 'Weblink', $prefix = 'Administrator', $config = [])
|
||||
{
|
||||
return parent::getTable($type, $prefix, $config);
|
||||
}
|
||||
|
@ -221,8 +207,7 @@ class WeblinkModel extends ItemModel
|
|||
*/
|
||||
public function hit($pk = null)
|
||||
{
|
||||
if (empty($pk))
|
||||
{
|
||||
if (empty($pk)) {
|
||||
$pk = $this->getState('weblink.id');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Site\Service;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
|
||||
/**
|
||||
|
@ -27,11 +29,10 @@ class Category extends Categories
|
|||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
public function __construct($options = [])
|
||||
{
|
||||
$options['table'] = '#__weblinks';
|
||||
$options['extension'] = 'com_weblinks';
|
||||
|
||||
parent::__construct($options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,8 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Site\Service;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Application\SiteApplication;
|
||||
use Joomla\CMS\Categories\CategoryFactoryInterface;
|
||||
use Joomla\CMS\Categories\CategoryInterface;
|
||||
|
@ -37,7 +39,6 @@ class Router extends RouterView
|
|||
* @var boolean
|
||||
*/
|
||||
protected $noIDs = false;
|
||||
|
||||
/**
|
||||
* The category factory
|
||||
*
|
||||
|
@ -46,7 +47,6 @@ class Router extends RouterView
|
|||
* @since 4.0.0
|
||||
*/
|
||||
private $categoryFactory;
|
||||
|
||||
/**
|
||||
* The category cache
|
||||
*
|
||||
|
@ -55,7 +55,6 @@ class Router extends RouterView
|
|||
* @since 4.0.0
|
||||
*/
|
||||
private $categoryCache = [];
|
||||
|
||||
/**
|
||||
* The db
|
||||
*
|
||||
|
@ -64,7 +63,6 @@ class Router extends RouterView
|
|||
* @since 4.0.0
|
||||
*/
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* Weblinks Component router constructor
|
||||
*
|
||||
|
@ -77,7 +75,6 @@ class Router extends RouterView
|
|||
{
|
||||
$this->categoryFactory = $categoryFactory;
|
||||
$this->db = $db;
|
||||
|
||||
$params = ComponentHelper::getParams('com_weblinks');
|
||||
$this->noIDs = (bool) $params->get('sef_ids');
|
||||
$categories = new RouterViewConfiguration('categories');
|
||||
|
@ -92,9 +89,7 @@ class Router extends RouterView
|
|||
$form = new RouterViewConfiguration('form');
|
||||
$form->setKey('w_id');
|
||||
$this->registerView($form);
|
||||
|
||||
parent::__construct($app, $menu);
|
||||
|
||||
$this->attachRule(new MenuRules($this));
|
||||
$this->attachRule(new StandardRules($this));
|
||||
$this->attachRule(new NomenuRules($this));
|
||||
|
@ -111,16 +106,11 @@ class Router extends RouterView
|
|||
public function getCategorySegment($id, $query)
|
||||
{
|
||||
$category = $this->getCategories()->get($id);
|
||||
|
||||
if ($category)
|
||||
{
|
||||
if ($category) {
|
||||
$path = array_reverse($category->getPath(), true);
|
||||
$path[0] = '1:root';
|
||||
|
||||
if ($this->noIDs)
|
||||
{
|
||||
foreach ($path as &$segment)
|
||||
{
|
||||
if ($this->noIDs) {
|
||||
foreach ($path as &$segment) {
|
||||
list($id, $segment) = explode(':', $segment, 2);
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +118,7 @@ class Router extends RouterView
|
|||
return $path;
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,8 +144,7 @@ class Router extends RouterView
|
|||
*/
|
||||
public function getWeblinkSegment($id, $query)
|
||||
{
|
||||
if (!strpos($id, ':'))
|
||||
{
|
||||
if (!strpos($id, ':')) {
|
||||
$id = (int) $id;
|
||||
$dbquery = $this->db->getQuery(true);
|
||||
$dbquery->select($this->db->quoteName('alias'))
|
||||
|
@ -163,18 +152,15 @@ class Router extends RouterView
|
|||
->where($this->db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
$this->db->setQuery($dbquery);
|
||||
|
||||
$id .= ':' . $this->db->loadResult();
|
||||
}
|
||||
|
||||
if ($this->noIDs)
|
||||
{
|
||||
if ($this->noIDs) {
|
||||
list($void, $segment) = explode(':', $id, 2);
|
||||
|
||||
return array($void => $segment);
|
||||
return [$void => $segment];
|
||||
}
|
||||
|
||||
return array((int) $id => $id);
|
||||
return [(int) $id => $id];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,25 +188,16 @@ class Router extends RouterView
|
|||
*/
|
||||
public function getCategoryId($segment, $query)
|
||||
{
|
||||
if (isset($query['id']))
|
||||
{
|
||||
if (isset($query['id'])) {
|
||||
$category = $this->getCategories(['access' => false])->get($query['id']);
|
||||
|
||||
if ($category)
|
||||
{
|
||||
foreach ($category->getChildren() as $child)
|
||||
{
|
||||
if ($this->noIDs)
|
||||
{
|
||||
if ($child->alias == $segment)
|
||||
{
|
||||
if ($category) {
|
||||
foreach ($category->getChildren() as $child) {
|
||||
if ($this->noIDs) {
|
||||
if ($child->alias == $segment) {
|
||||
return $child->id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($child->id == (int) $segment)
|
||||
{
|
||||
} else {
|
||||
if ($child->id == (int) $segment) {
|
||||
return $child->id;
|
||||
}
|
||||
}
|
||||
|
@ -254,21 +231,17 @@ class Router extends RouterView
|
|||
*/
|
||||
public function getWeblinkId($segment, $query)
|
||||
{
|
||||
if ($this->noIDs)
|
||||
{
|
||||
if ($this->noIDs) {
|
||||
$dbquery = $this->db->getQuery(true);
|
||||
$dbquery->select($this->db->quoteName('id'))
|
||||
->from($this->db->quoteName('#__weblinks'))
|
||||
->where(
|
||||
[
|
||||
->where([
|
||||
$this->db->quoteName('alias') . ' = :alias',
|
||||
$this->db->quoteName('catid') . ' = :catid',
|
||||
]
|
||||
)
|
||||
])
|
||||
->bind(':alias', $segment)
|
||||
->bind(':catid', $query['id'], ParameterType::INTEGER);
|
||||
$this->db->setQuery($dbquery);
|
||||
|
||||
return (int) $this->db->loadResult();
|
||||
}
|
||||
|
||||
|
@ -287,9 +260,7 @@ class Router extends RouterView
|
|||
private function getCategories(array $options = []): CategoryInterface
|
||||
{
|
||||
$key = serialize($options);
|
||||
|
||||
if (!isset($this->categoryCache[$key]))
|
||||
{
|
||||
if (!isset($this->categoryCache[$key])) {
|
||||
$this->categoryCache[$key] = $this->categoryFactory->createCategory($options);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -11,8 +12,9 @@ namespace Joomla\Component\Weblinks\Site\View\Categories;
|
|||
|
||||
use Joomla\CMS\MVC\View\CategoriesView;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* Weblinks categories view.
|
||||
*
|
||||
|
@ -25,7 +27,6 @@ class HtmlView extends CategoriesView
|
|||
* @since 3.2
|
||||
*/
|
||||
protected $pageHeading = 'COM_WEBLINKS_DEFAULT_PAGE_TITLE';
|
||||
|
||||
/**
|
||||
* @var string The name of the extension for the category
|
||||
* @since 3.2
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -11,8 +12,9 @@ namespace Joomla\Component\Weblinks\Site\View\Category;
|
|||
|
||||
use Joomla\CMS\MVC\View\CategoryFeedView;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* HTML View class for the WebLinks component
|
||||
*
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -13,8 +14,9 @@ use Joomla\CMS\MVC\View\CategoryView;
|
|||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* HTML View class for the WebLinks component
|
||||
*
|
||||
|
@ -27,7 +29,6 @@ class HtmlView extends CategoryView
|
|||
* @since 3.2
|
||||
*/
|
||||
protected $extension = 'com_weblinks';
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
|
@ -38,22 +39,16 @@ class HtmlView extends CategoryView
|
|||
public function display($tpl = null)
|
||||
{
|
||||
parent::commonCategoryDisplay();
|
||||
|
||||
// Prepare the data.
|
||||
// Compute the weblink slug & link url.
|
||||
foreach ($this->items as $item)
|
||||
{
|
||||
foreach ($this->items as $item) {
|
||||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
|
||||
$temp = $item->params;
|
||||
$item->params = clone $this->params;
|
||||
$item->params->merge($temp);
|
||||
|
||||
if ($item->params->get('count_clicks', 1) == 1)
|
||||
{
|
||||
if ($item->params->get('count_clicks', 1) == 1) {
|
||||
$item->link = Route::_('index.php?option=com_weblinks&task=weblink.go&id=' . $item->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$item->link = $item->url;
|
||||
}
|
||||
}
|
||||
|
@ -69,11 +64,8 @@ class HtmlView extends CategoryView
|
|||
protected function prepareDocument()
|
||||
{
|
||||
parent::prepareDocument();
|
||||
|
||||
parent::addFeed();
|
||||
|
||||
if ($this->menuItemMatchCategory)
|
||||
{
|
||||
if ($this->menuItemMatchCategory) {
|
||||
// If the active menu item is linked directly to the category being displayed, no further process is needed
|
||||
return;
|
||||
}
|
||||
|
@ -81,29 +73,24 @@ class HtmlView extends CategoryView
|
|||
// Get ID of the category from active menu item
|
||||
$menu = $this->menu;
|
||||
|
||||
if ($menu && $menu->component == 'com_weblinks' && isset($menu->query['view'])
|
||||
&& in_array($menu->query['view'], ['categories', 'category']))
|
||||
{
|
||||
if (
|
||||
$menu && $menu->component == 'com_weblinks' && isset($menu->query['view'])
|
||||
&& in_array($menu->query['view'], ['categories', 'category'])
|
||||
) {
|
||||
$id = $menu->query['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$id = 0;
|
||||
}
|
||||
|
||||
$path = [['title' => $this->category->title, 'link' => '']];
|
||||
$category = $this->category->getParent();
|
||||
|
||||
while ($category !== null && $category->id != $id && $category->id !== 'root')
|
||||
{
|
||||
while ($category !== null && $category->id != $id && $category->id !== 'root') {
|
||||
$path[] = ['title' => $category->title, 'link' => RouteHelper::getCategoryRoute($category->id, $category->language)];
|
||||
$category = $category->getParent();
|
||||
}
|
||||
|
||||
$path = array_reverse($path);
|
||||
|
||||
foreach ($path as $item)
|
||||
{
|
||||
foreach ($path as $item) {
|
||||
$this->pathway->addItem($item['title'], $item['link']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Component\Weblinks\Site\View\Form;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
@ -76,27 +79,21 @@ class HtmlView extends BaseHtmlView
|
|||
$this->form = $this->get('Form');
|
||||
$this->return_page = $this->get('ReturnPage');
|
||||
|
||||
if (empty($this->item->id))
|
||||
{
|
||||
if (empty($this->item->id)) {
|
||||
$authorised = $user->authorise('core.create', 'com_weblinks') || count($user->getAuthorisedCategories('com_weblinks', 'core.create'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$authorised = $user->authorise('core.edit', 'com_weblinks.category.' . $this->item->catid);
|
||||
}
|
||||
|
||||
if ($authorised !== true)
|
||||
{
|
||||
if ($authorised !== true) {
|
||||
throw new \Exception(Text::_('JERROR_ALERTNOAUTHOR'), 403);
|
||||
}
|
||||
|
||||
if (!empty($this->item))
|
||||
{
|
||||
if (!empty($this->item)) {
|
||||
// Override the base weblink data with any data in the session.
|
||||
$temp = (array) Factory::getApplication()->getUserState('com_weblinks.edit.weblink.data', array());
|
||||
$temp = (array) Factory::getApplication()->getUserState('com_weblinks.edit.weblink.data', []);
|
||||
|
||||
foreach ($temp as $k => $v)
|
||||
{
|
||||
foreach ($temp as $k => $v) {
|
||||
$this->item->$k = $v;
|
||||
}
|
||||
|
||||
|
@ -104,8 +101,7 @@ class HtmlView extends BaseHtmlView
|
|||
}
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
if (count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
|
@ -118,7 +114,7 @@ class HtmlView extends BaseHtmlView
|
|||
$this->params = $params;
|
||||
$this->user = $user;
|
||||
|
||||
$this->_prepareDocument();
|
||||
$this->prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
@ -128,7 +124,7 @@ class HtmlView extends BaseHtmlView
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
protected function prepareDocument()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
|
@ -136,21 +132,15 @@ class HtmlView extends BaseHtmlView
|
|||
// we need to get it from the menu item itself
|
||||
$menu = $app->getMenu()->getActive();
|
||||
|
||||
if (empty($this->item->id))
|
||||
{
|
||||
if (empty($this->item->id)) {
|
||||
$head = Text::_('COM_WEBLINKS_FORM_SUBMIT_WEBLINK');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$head = Text::_('COM_WEBLINKS_FORM_EDIT_WEBLINK');
|
||||
}
|
||||
|
||||
if ($menu)
|
||||
{
|
||||
if ($menu) {
|
||||
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->params->def('page_heading', $head);
|
||||
}
|
||||
|
||||
|
@ -158,18 +148,15 @@ class HtmlView extends BaseHtmlView
|
|||
|
||||
$this->setDocumentTitle($title);
|
||||
|
||||
if ($this->params->get('menu-meta_description'))
|
||||
{
|
||||
if ($this->params->get('menu-meta_description')) {
|
||||
$this->document->setDescription($this->params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($this->params->get('menu-meta_keywords'))
|
||||
{
|
||||
if ($this->params->get('menu-meta_keywords')) {
|
||||
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
|
||||
}
|
||||
|
||||
if ($this->params->get('robots'))
|
||||
{
|
||||
if ($this->params->get('robots')) {
|
||||
$this->document->setMetadata('robots', $this->params->get('robots'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -12,8 +13,9 @@ namespace Joomla\Component\Weblinks\Site\View\Weblink;
|
|||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
/**
|
||||
* HTML Weblink View class for the Weblinks component
|
||||
*
|
||||
|
@ -27,14 +29,12 @@ class HtmlView extends BaseHtmlView
|
|||
* @var \JObject
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* The page parameters
|
||||
*
|
||||
* @var \Joomla\Registry\Registry|null
|
||||
*/
|
||||
protected $params;
|
||||
|
||||
/**
|
||||
* The item model state
|
||||
*
|
||||
|
@ -42,7 +42,6 @@ class HtmlView extends BaseHtmlView
|
|||
* @since 1.6
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
|
@ -55,35 +54,24 @@ class HtmlView extends BaseHtmlView
|
|||
public function display($tpl = null)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
$this->item = $this->get('Item');
|
||||
$this->state = $this->get('State');
|
||||
$this->params = $this->state->get('params');
|
||||
|
||||
// Create a shortcut for $item.
|
||||
$item = $this->item;
|
||||
|
||||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
|
||||
|
||||
$temp = $item->params;
|
||||
$item->params = clone $app->getParams();
|
||||
$item->params->merge($temp);
|
||||
|
||||
$offset = $this->state->get('list.offset');
|
||||
|
||||
$app->triggerEvent('onContentPrepare', array('com_weblinks.weblink', &$item, &$item->params, $offset));
|
||||
|
||||
$item->event = new \stdClass;
|
||||
|
||||
$results = $app->triggerEvent('onContentAfterTitle', array('com_weblinks.weblink', &$item, &$item->params, $offset));
|
||||
$app->triggerEvent('onContentPrepare', ['com_weblinks.weblink', &$item, &$item->params, $offset]);
|
||||
$item->event = new \stdClass();
|
||||
$results = $app->triggerEvent('onContentAfterTitle', ['com_weblinks.weblink', &$item, &$item->params, $offset]);
|
||||
$item->event->afterDisplayTitle = trim(implode("\n", $results));
|
||||
|
||||
$results = $app->triggerEvent('onContentBeforeDisplay', array('com_weblinks.weblink', &$item, &$item->params, $offset));
|
||||
$results = $app->triggerEvent('onContentBeforeDisplay', ['com_weblinks.weblink', &$item, &$item->params, $offset]);
|
||||
$item->event->beforeDisplayContent = trim(implode("\n", $results));
|
||||
|
||||
$results = $app->triggerEvent('onContentAfterDisplay', array('com_weblinks.weblink', &$item, &$item->params, $offset));
|
||||
$results = $app->triggerEvent('onContentAfterDisplay', ['com_weblinks.weblink', &$item, &$item->params, $offset]);
|
||||
$item->event->afterDisplayContent = trim(implode("\n", $results));
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,15 +8,14 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
// Add strings for translations in Javascript.
|
||||
Text::script('JGLOBAL_EXPAND_CATEGORIES');
|
||||
Text::script('JGLOBAL_COLLAPSE_CATEGORIES');
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->getRegistry()->addExtensionRegistryFile('com_categories');
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,29 +8,35 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
|
||||
|
||||
if ($this->maxLevelcat != 0 && count($this->items[$this->parent->id]) > 0) :
|
||||
?>
|
||||
?>
|
||||
<div class="com-content-categories__items">
|
||||
<?php foreach ($this->items[$this->parent->id] as $id => $item) : ?>
|
||||
<?php if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) : ?>
|
||||
<?php foreach ($this->items[$this->parent->id] as $id => $item) :
|
||||
?>
|
||||
<?php if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) :
|
||||
?>
|
||||
<div class="com-content-categories__item">
|
||||
<div class="w-100">
|
||||
<a href="<?php echo Route::_(RouteHelper::getCategoryRoute($item->id, $item->language)); ?>">
|
||||
<?php echo $this->escape($item->title); ?></a>
|
||||
<?php if ($this->params->get('show_cat_num_links_cat') == 1) :?>
|
||||
<?php if ($this->params->get('show_cat_num_links_cat') == 1) :
|
||||
?>
|
||||
<span class="badge bg-info ">
|
||||
<?php echo Text::_('COM_WEBLINKS_NUM_ITEMS'); ?>
|
||||
<?php echo $item->numitems; ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->maxLevelcat > 1 && count($item->getChildren()) > 0) : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php if ($this->maxLevelcat > 1 && count($item->getChildren()) > 0) :
|
||||
?>
|
||||
<button
|
||||
type="button"
|
||||
id="category-btn-<?php echo $item->id; ?>"
|
||||
|
@ -40,16 +47,20 @@ if ($this->maxLevelcat != 0 && count($this->items[$this->parent->id]) > 0) :
|
|||
>
|
||||
<span class="icon-plus" aria-hidden="true"></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($this->params->get('show_subcat_desc_cat') == 1 && !empty($item->description)) : ?>
|
||||
<?php if ($this->params->get('show_subcat_desc_cat') == 1 && !empty($item->description)) :
|
||||
?>
|
||||
<div class="category-desc">
|
||||
<?php echo HTMLHelper::_('content.prepare', $item->description, '', 'com_weblinks.categories'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_description_image') && !empty($item->getParams()->get('image'))) : ?>
|
||||
<?php if ($this->params->get('show_description_image') && !empty($item->getParams()->get('image'))) :
|
||||
?>
|
||||
<?php
|
||||
$params = $item->getParams();
|
||||
$img = HTMLHelper::cleanImageURL($params->get('image'));
|
||||
|
@ -61,10 +72,12 @@ if ($this->maxLevelcat != 0 && count($this->items[$this->parent->id]) > 0) :
|
|||
endif;
|
||||
?>
|
||||
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"<?php echo $alt; ?>>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
|
||||
<?php if ($this->maxLevelcat > 1 && count($item->getChildren()) > 0) : ?>
|
||||
<?php if ($this->maxLevelcat > 1 && count($item->getChildren()) > 0) :
|
||||
?>
|
||||
<div class="com-content-categories__children" id="category-<?php echo $item->id; ?>" hidden>
|
||||
<?php
|
||||
$this->items[$item->id] = $item->getChildren();
|
||||
|
@ -75,9 +88,13 @@ if ($this->maxLevelcat != 0 && count($this->items[$this->parent->id]) > 0) :
|
|||
$this->maxLevelcat++;
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,8 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,38 +8,47 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
|
||||
|
||||
if ($this->maxLevel != 0 && count($this->children[$this->category->id]) > 0) :
|
||||
?>
|
||||
?>
|
||||
<ul class="com-weblinks-category__children list-group list-unstyled">
|
||||
<?php foreach ($this->children[$this->category->id] as $id => $child) : ?>
|
||||
<?php if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) : ?>
|
||||
<?php foreach ($this->children[$this->category->id] as $id => $child) :
|
||||
?>
|
||||
<?php if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) :
|
||||
?>
|
||||
<li class="list-group-item">
|
||||
<div class="item-title">
|
||||
<a href="<?php echo Route::_(RouteHelper::getCategoryRoute($child->id, $child->language)); ?>">
|
||||
<?php echo $this->escape($child->title); ?>
|
||||
</a>
|
||||
|
||||
<?php if ($this->params->get('show_cat_num_links') == 1) : ?>
|
||||
<?php if ($this->params->get('show_cat_num_links') == 1) :
|
||||
?>
|
||||
<span class="badge bg-info float-end" title="<?php echo Text::_('COM_WEBLINKS_CAT_NUM'); ?>"><?php echo $child->numitems; ?></span>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($this->params->get('show_subcat_desc') == 1) : ?>
|
||||
<?php if ($child->description) : ?>
|
||||
<?php if ($this->params->get('show_subcat_desc') == 1) :
|
||||
?>
|
||||
<?php if ($child->description) :
|
||||
?>
|
||||
<div class="category-desc">
|
||||
<?php echo HTMLHelper::_('content.prepare', $child->description, '', 'com_weblinks.category'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if (count($child->getChildren()) > 0 ) :
|
||||
<?php if (count($child->getChildren()) > 0) :
|
||||
$this->children[$child->id] = $child->getChildren();
|
||||
$this->category = $child;
|
||||
$this->maxLevel--;
|
||||
|
@ -47,7 +57,10 @@ if ($this->maxLevel != 0 && count($this->children[$this->category->id]) > 0) :
|
|||
$this->maxLevel++;
|
||||
endif; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,31 +8,29 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
HTMLHelper::_('behavior.core');
|
||||
|
||||
// Get the user object.
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
|
||||
// Check if user is allowed to add/edit based on weblinks permission.
|
||||
$canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $this->category->id);
|
||||
$canEditOwn = $user->authorise('core.edit.own', 'com_weblinks.category.' . $this->category->id);
|
||||
$canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $this->category->id);
|
||||
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
?>
|
||||
|
||||
<div class="com-weblinks-category__items">
|
||||
<form action="<?php echo htmlspecialchars(Uri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<?php if ($this->params->get('filter_field')) : ?>
|
||||
<?php if ($this->params->get('filter_field')) :
|
||||
?>
|
||||
<div class="com-weblinks-category__filter btn-group">
|
||||
<label class="filter-search-lbl visually-hidden" for="filter-search">
|
||||
<?php echo Text::_('COM_WEBLINKS_FILTER_SEARCH_DESC'); ?>
|
||||
|
@ -48,49 +47,70 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
|||
<button type="button" name="filter-clear-button" class="btn btn-secondary"
|
||||
onclick="this.form.elements['filter-search'].value = ''; this.form.submit();"><?php echo Text::_('JSEARCH_FILTER_CLEAR'); ?></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->params->get('show_pagination_limit')) : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php if ($this->params->get('show_pagination_limit')) :
|
||||
?>
|
||||
<div class="com-weblinks-category__pagination btn-group float-end">
|
||||
<label for="limit" class="visually-hidden">
|
||||
<?php echo Text::_('JGLOBAL_DISPLAY_NUM'); ?>
|
||||
</label>
|
||||
<?php echo $this->pagination->getLimitBox(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php if (empty($this->items)) :
|
||||
?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('COM_WEBLINKS_NO_WEBLINKS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<ul class="category list-unstyled">
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<?php foreach ($this->items as $i => $item) :
|
||||
?>
|
||||
<?php
|
||||
// Shouldn't this be only for users with admin rights?
|
||||
// @ToDo: what is the difference -class system-unbublished?
|
||||
if ($item->state == 0) : ?>
|
||||
if ($item->state == 0) :
|
||||
?>
|
||||
<li class="system-unpublished list-group mt-3">
|
||||
<?php else : ?>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<li class="list-group mt-3">
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if ($canEdit || ($canEditOwn && $item->created_by == $userId)) : ?>
|
||||
<?php if ($canEdit || ($canEditOwn && $item->created_by == $userId)) :
|
||||
?>
|
||||
<div class="icons list-group-item">
|
||||
<?php echo HTMLHelper::_('weblinkicon.edit', $item, $item->params); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<div class="list-title list-group-item ">
|
||||
<?php if ($this->params->get('icons', 1) == 0) : ?>
|
||||
<?php if ($this->params->get('icons', 1) == 0) :
|
||||
?>
|
||||
<?php echo Text::_('COM_WEBLINKS_LINK'); ?>
|
||||
<?php elseif ($this->params->get('icons', 1) == 1) : ?>
|
||||
<?php
|
||||
elseif ($this->params->get('icons', 1) == 1) :
|
||||
?>
|
||||
<?php // ToDo css icons as variables ?>
|
||||
<?php if (!$this->params->get('link_icons')) : ?>
|
||||
<?php if (!$this->params->get('link_icons')) :
|
||||
?>
|
||||
<span class="icon-globe" aria-hidden="true"></span>
|
||||
<?php else: ?>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<?php echo '<img src="' . $this->params->get('link_icons') . '" alt="' . Text::_('COM_WEBLINKS_LINK') . '" />'; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php // Compute the correct link ?>
|
||||
<?php $menuclass = 'category' . $this->pageclass_sfx; ?>
|
||||
|
@ -98,24 +118,26 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
|||
<?php $width = $item->params->get('width', 600); ?>
|
||||
<?php $height = $item->params->get('height', 500); ?>
|
||||
|
||||
<?php if ($item->state == 0) : ?>
|
||||
<?php if ($item->state == 0) :
|
||||
?>
|
||||
<span class="badge bg-warning"><?php echo Text::_('JUNPUBLISHED'); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php
|
||||
switch ($item->params->get('target', $this->params->get('target')))
|
||||
{
|
||||
switch ($item->params->get('target', $this->params->get('target'))) {
|
||||
case 1:
|
||||
// Open in a new window
|
||||
echo '<a href="' . $link . '" target="_blank" class="' . $menuclass . '" rel="nofollow">' .
|
||||
$this->escape($item->title) . '</a>';
|
||||
break;
|
||||
|
||||
break;
|
||||
case 2:
|
||||
// Open in a popup window
|
||||
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $this->escape($width) . ',height=' . $this->escape($height) . '';
|
||||
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
|
||||
$this->escape($item->title) . '</a>';
|
||||
|
||||
break;
|
||||
case 3:
|
||||
// Open in a modal window
|
||||
|
@ -130,34 +152,44 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
|||
echo '<button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#' . $modalId . '">
|
||||
' . $item->title . '
|
||||
</button>';
|
||||
|
||||
break;
|
||||
default:
|
||||
// Open in parent window
|
||||
echo '<a href="' . $link . '" class="' . $menuclass . '" rel="nofollow">' .
|
||||
$this->escape($item->title) . ' </a>';
|
||||
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<?php if ($this->params->get('show_link_hits', 1)) : ?>
|
||||
<?php if ($this->params->get('show_link_hits', 1)) :
|
||||
?>
|
||||
<div class="list-hits badge bg-info float-end">
|
||||
<?php echo Text::sprintf('JGLOBAL_HITS_COUNT', $item->hits); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_tags', 1) && !empty($item->tags->itemTags)) : ?>
|
||||
<?php if ($this->params->get('show_tags', 1) && !empty($item->tags->itemTags)) :
|
||||
?>
|
||||
<div class="mt-2 mb-2">
|
||||
<?php echo LayoutHelper::render('joomla.content.tags', $item->tags->itemTags); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_link_description') && ($item->description != '')) : ?>
|
||||
<?php if ($this->params->get('show_link_description') && ($item->description != '')) :
|
||||
?>
|
||||
<div class="mt-2 mb-2">
|
||||
<?php $images = json_decode($item->images); ?>
|
||||
<?php if (!empty($images->image_first)) : ?>
|
||||
<?php if (!empty($images->image_first)) :
|
||||
?>
|
||||
<?php $imgFloat = '';?>
|
||||
<?php if (!empty($images->float_first)) : ?>
|
||||
<?php if (!empty($images->float_first)) :
|
||||
?>
|
||||
<?php $imgFloat = $images->float_first == 'right' ? 'float-end' : 'float-start'; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php $img = HTMLHelper::cleanImageURL($images->image_first); ?>
|
||||
<?php $alt = empty($images->image_first_alt) && empty($images->image_first_alt_empty)
|
||||
? ''
|
||||
|
@ -165,17 +197,23 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
|||
<figure class="item-image <?php echo $imgFloat; ?>">
|
||||
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo $alt; ?> itemprop="thumbnail" />
|
||||
<?php if (!empty($images->image_first_caption)) : ?>
|
||||
<?php if (!empty($images->image_first_caption)) :
|
||||
?>
|
||||
<figcaption class="caption"><?php echo htmlspecialchars($images->image_first_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</figure>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if (!empty($images->image_second)) : ?>
|
||||
<?php if (!empty($images->image_second)) :
|
||||
?>
|
||||
<?php $imgFloat = ''; ?>
|
||||
<?php if (!empty($images->float_second)) : ?>
|
||||
<?php if (!empty($images->float_second)) :
|
||||
?>
|
||||
<?php $imgFloat = $images->float_second == 'right' ? 'float-end' : 'float-start'; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php $img = HTMLHelper::cleanImageURL($images->image_second); ?>
|
||||
<?php $alt = empty($images->image_second_alt) && empty($images->image_second_alt_empty)
|
||||
? ''
|
||||
|
@ -183,39 +221,51 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
|||
<figure class="item-image <?php echo $imgFloat; ?>">
|
||||
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo $alt; ?> itemprop="thumbnail" />
|
||||
<?php if (!empty($images->image_second_caption)) : ?>
|
||||
<?php if (!empty($images->image_second_caption)) :
|
||||
?>
|
||||
<figcaption class="caption"><?php echo htmlspecialchars($images->image_second_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</figure>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php echo $item->description; ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php if ($this->params->get('show_pagination')) : ?>
|
||||
<?php if ($this->params->get('show_pagination')) :
|
||||
?>
|
||||
<div class="com-weblinks-category__counter w-100">
|
||||
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
|
||||
<?php if ($this->params->def('show_pagination_results', 1)) :
|
||||
?>
|
||||
<p class="com-weblinks-category__counter counter float-end pt-3 pe-2">
|
||||
<?php echo $this->pagination->getPagesCounter(); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php echo $this->pagination->getPagesLinks(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if ($canCreate) : ?>
|
||||
<?php if ($canCreate) :
|
||||
?>
|
||||
<?php echo HTMLHelper::_('weblinkicon.create', $this->category, $this->category->params); ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,24 +8,20 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
HTMLHelper::_('behavior.keepalive');
|
||||
HTMLHelper::_('behavior.formvalidator');
|
||||
|
||||
$captchaEnabled = false;
|
||||
$captchaSet = $this->params->get('captcha', Factory::getApplication()->get('captcha', '0'));
|
||||
|
||||
foreach (PluginHelper::getPlugin('captcha') as $plugin)
|
||||
{
|
||||
if ($captchaSet === $plugin->name)
|
||||
{
|
||||
foreach (PluginHelper::getPlugin('captcha') as $plugin) {
|
||||
if ($captchaSet === $plugin->name) {
|
||||
$captchaEnabled = true;
|
||||
break;
|
||||
}
|
||||
|
@ -34,13 +31,15 @@ foreach (PluginHelper::getPlugin('captcha') as $plugin)
|
|||
$params = $this->state->get('params');
|
||||
?>
|
||||
<div class="edit item-page<?php echo $this->pageclass_sfx; ?>">
|
||||
<?php if ($this->params->get('show_page_heading')) : ?>
|
||||
<?php if ($this->params->get('show_page_heading')) :
|
||||
?>
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
<?php echo $this->escape($this->params->get('page_heading')); ?>
|
||||
</h1>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_weblinks&view=form&w_id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate form-vertical">
|
||||
|
||||
<?php echo $this->form->renderField('title'); ?>
|
||||
|
@ -49,13 +48,17 @@ $params = $this->state->get('params');
|
|||
<?php echo $this->form->renderField('url'); ?>
|
||||
<?php echo $this->form->renderField('tags'); ?>
|
||||
|
||||
<?php if ($params->get('save_history', 0)) : ?>
|
||||
<?php if ($params->get('save_history', 0)) :
|
||||
?>
|
||||
<?php echo $this->form->renderField('version_note'); ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if ($this->user->authorise('core.edit.state', 'com_weblinks.weblink')) : ?>
|
||||
<?php if ($this->user->authorise('core.edit.state', 'com_weblinks.weblink')) :
|
||||
?>
|
||||
<?php echo $this->form->renderField('state'); ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php echo $this->form->renderField('language'); ?>
|
||||
<?php echo $this->form->renderField('description'); ?>
|
||||
|
||||
|
@ -72,11 +75,13 @@ $params = $this->state->get('params');
|
|||
<?php echo $this->form->renderField('image_second_caption', 'images'); ?>
|
||||
|
||||
|
||||
<?php if ($captchaEnabled) : ?>
|
||||
<?php if ($captchaEnabled) :
|
||||
?>
|
||||
<div class="btn-group">
|
||||
<?php echo $this->form->renderField('captcha'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<div class="mb-2">
|
||||
<button type="button" class="btn btn-primary" onclick="Joomla.submitbutton('weblink.save')">
|
||||
|
@ -87,9 +92,11 @@ $params = $this->state->get('params');
|
|||
<span class="icon-times" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JCANCEL'); ?>
|
||||
</button>
|
||||
<?php if ($this->params->get('save_history', 0) && $this->item->id) : ?>
|
||||
<?php if ($this->params->get('save_history', 0) && $this->item->id) :
|
||||
?>
|
||||
<?php echo $this->form->getInput('contenthistory'); ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="return" value="<?php echo $this->return_page;?>" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
|
@ -7,20 +8,17 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\String\PunycodeHelper;
|
||||
|
||||
$weblinkUrl = PunycodeHelper::urlToUTF8($this->item->url);
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
|
||||
$canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $this->item->catid);
|
||||
|
||||
if (!$canEdit)
|
||||
{
|
||||
if (!$canEdit) {
|
||||
$canEditOwn = $user->authorise('core.edit.own', 'com_weblinks.category.' . $this->item->catid);
|
||||
$canEdit = $canEditOwn && $this->item->created_by == $user->id;
|
||||
}
|
||||
|
@ -32,7 +30,8 @@ if (!$canEdit)
|
|||
<?php echo $this->escape($this->item->title); ?>
|
||||
</h2>
|
||||
</div>
|
||||
<?php if ($canEdit) : ?>
|
||||
<?php if ($canEdit) :
|
||||
?>
|
||||
<div class="icons">
|
||||
<div class="float-end">
|
||||
<div>
|
||||
|
@ -40,7 +39,8 @@ if (!$canEdit)
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php // Content is generated by content plugin event "onContentAfterTitle" ?>
|
||||
<?php echo $this->item->event->afterDisplayTitle; ?>
|
||||
|
@ -55,19 +55,24 @@ if (!$canEdit)
|
|||
</a>
|
||||
</div>
|
||||
|
||||
<?php if ($this->params->get('show_tags', 1) && !empty($this->item->tags->itemTags)) : ?>
|
||||
<?php if ($this->params->get('show_tags', 1) && !empty($this->item->tags->itemTags)) :
|
||||
?>
|
||||
<div class="p-2">
|
||||
<?php echo LayoutHelper::render('joomla.content.tags', $this->item->tags->itemTags); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<div class="p-3">
|
||||
<?php $images = json_decode($this->item->images); ?>
|
||||
<?php if (!empty($images->image_first)) : ?>
|
||||
<?php if (!empty($images->image_first)) :
|
||||
?>
|
||||
<?php $imgFloat = '';?>
|
||||
<?php if (!empty($images->float_first)) : ?>
|
||||
<?php if (!empty($images->float_first)) :
|
||||
?>
|
||||
<?php $imgFloat = $images->float_first == 'right' ? 'float-end' : 'float-start'; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php $img = HTMLHelper::cleanImageURL($images->image_first); ?>
|
||||
<?php $alt = empty($images->image_first_alt) && empty($images->image_first_alt_empty)
|
||||
? ''
|
||||
|
@ -75,17 +80,23 @@ if (!$canEdit)
|
|||
<figure class="item-image <?php echo $imgFloat; ?>">
|
||||
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo $alt; ?> itemprop="thumbnail" />
|
||||
<?php if (!empty($images->image_first_caption)) : ?>
|
||||
<?php if (!empty($images->image_first_caption)) :
|
||||
?>
|
||||
<figcaption class="caption"><?php echo htmlspecialchars($images->image_first_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</figure>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if (!empty($images->image_second)) : ?>
|
||||
<?php if (!empty($images->image_second)) :
|
||||
?>
|
||||
<?php $imgFloat = ''; ?>
|
||||
<?php if (!empty($images->float_second)) : ?>
|
||||
<?php if (!empty($images->float_second)) :
|
||||
?>
|
||||
<?php $imgFloat = $images->float_second == 'right' ? 'float-end' : 'float-start'; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php $img = HTMLHelper::cleanImageURL($images->image_second); ?>
|
||||
<?php $alt = empty($images->image_second_alt) && empty($images->image_second_alt_empty)
|
||||
? ''
|
||||
|
@ -93,15 +104,20 @@ if (!$canEdit)
|
|||
<figure class="item-image <?php echo $imgFloat; ?>">
|
||||
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"
|
||||
<?php echo $alt; ?> itemprop="thumbnail" />
|
||||
<?php if (!empty($images->image_second_caption)) : ?>
|
||||
<?php if (!empty($images->image_second_caption)) :
|
||||
?>
|
||||
<figcaption class="caption"><?php echo htmlspecialchars($images->image_second_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</figure>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php if (!empty($this->item->description)) : ?>
|
||||
<?php if (!empty($this->item->description)) :
|
||||
?>
|
||||
<?php echo $this->item->description; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Extension\Service\Provider\HelperFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\Module;
|
||||
|
|
|
@ -14,9 +14,11 @@ use Joomla\CMS\Dispatcher\AbstractModuleDispatcher;
|
|||
use Joomla\CMS\Helper\HelperFactoryAwareInterface;
|
||||
use Joomla\CMS\Helper\HelperFactoryAwareTrait;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Dispatcher class for mod_weblinks
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Module\Weblinks\Site\Helper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Application\CMSApplicationInterface;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
|
@ -96,20 +99,15 @@ class WeblinksHelper
|
|||
|
||||
$items = $model->getItems();
|
||||
|
||||
if ($items)
|
||||
{
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if ($items) {
|
||||
foreach ($items as $item) {
|
||||
$temp = $item->params;
|
||||
$item->params = clone $cParams;
|
||||
$item->params->merge($temp);
|
||||
|
||||
if ($item->params->get('count_clicks', 1) == 1)
|
||||
{
|
||||
if ($item->params->get('count_clicks', 1) == 1) {
|
||||
$item->link = Route::_('index.php?option=com_weblinks&task=weblink.go&catid=' . $item->catslug . '&id=' . $item->slug);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$item->link = $item->url;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -7,47 +8,61 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
|
||||
<?php if ($params->get('groupby', 0)) : ?>
|
||||
<?php if ($params->get('groupby', 0)) :
|
||||
?>
|
||||
<?php $cats = [] ?>
|
||||
<?php $cols = $params->get('groupby_columns', 3); ?>
|
||||
<?php foreach ($list as $l) : ?>
|
||||
<?php foreach ($list as $l) :
|
||||
?>
|
||||
<?php $cats[] = array('catid' => $l->catid, 'title' => $l->category_title); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
<?php $cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats)))); ?>
|
||||
<?php foreach ($cats as $k => $cat) : ?>
|
||||
<?php foreach ($cats as $k => $cat) :
|
||||
?>
|
||||
<?php $items = []; ?>
|
||||
<?php foreach ($list as $item) : ?>
|
||||
<?php if ($item->catid == $cat['catid']) : ?>
|
||||
<?php foreach ($list as $item) :
|
||||
?>
|
||||
<?php if ($item->catid == $cat['catid']) :
|
||||
?>
|
||||
<?php $items[] = $item; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($cols > 1) :?>
|
||||
<?php if ($k % $cols == 0) : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
<?php if ($cols > 1) :
|
||||
?>
|
||||
<?php if ($k % $cols == 0) :
|
||||
?>
|
||||
<div class="row row-fluid">
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<div class="col-' . 12 / $cols . '">
|
||||
<?php endif; ?>
|
||||
<?php if ($params->get('groupby_showtitle', 1)) :?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php if ($params->get('groupby_showtitle', 1)) :
|
||||
?>
|
||||
<strong> <?php echo htmlspecialchars($cat['title'], ENT_COMPAT, 'UTF-8'); ?></strong>
|
||||
<?php endif; ?>;
|
||||
<?php
|
||||
endif; ?>;
|
||||
<ul class="weblinks<?php echo $moduleclass_sfx; ?>">
|
||||
<?php foreach ($items as $item) : ?>
|
||||
<?php foreach ($items as $item) :
|
||||
?>
|
||||
<li><div class="d-flex flex-wrap">
|
||||
<div class="col flex-sm-grow-1">
|
||||
<?php
|
||||
$link = $item->link;
|
||||
$width = (int) $item->params->get('width', 600);
|
||||
$height = (int) $item->params->get('height', 500);
|
||||
|
||||
switch ($item->params->get('target'))
|
||||
{
|
||||
switch ($item->params->get('target')) {
|
||||
case 1:
|
||||
// Open in a new window
|
||||
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
|
||||
|
@ -58,6 +73,7 @@ use Joomla\CMS\Language\Text;
|
|||
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $width . ',height=' . $height;
|
||||
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
|
||||
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
|
||||
|
||||
break;
|
||||
case 3:
|
||||
// Open in a modal window
|
||||
|
@ -70,55 +86,67 @@ use Joomla\CMS\Language\Text;
|
|||
$modalParams['modalWidth'] = 80;
|
||||
echo HTMLHelper::_('bootstrap.renderModal', $modalId, $modalParams);
|
||||
echo '<button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#' . $modalId . '">
|
||||
' . $item->title . '
|
||||
</button>';
|
||||
' . $item->title . '</button>';
|
||||
|
||||
break;
|
||||
default:
|
||||
// Open in parent window
|
||||
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
|
||||
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
|
||||
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php echo $params->get('description', 0) ? '<div class="col flex-sm-grow-1">' . $item->description . '</div>' : ''; ?>
|
||||
<?php if ($params->get('hits', 0)) : ?>
|
||||
<?php if ($params->get('hits', 0)) :
|
||||
?>
|
||||
<div class="col flex-sm-grow-1">
|
||||
<span class="badge bg-info float-md-end"> <?php echo $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS'); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</ul>
|
||||
<?php if ($cols > 1) :?>
|
||||
<?php if ($cols > 1) :
|
||||
?>
|
||||
</div>
|
||||
<?php if (($k + 1) % $cols == 0 || $k == count($cats) - 1) : ?>
|
||||
<?php if (($k + 1) % $cols == 0 || $k == count($cats) - 1) :
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<ul class="weblinks<?php echo $moduleclass_sfx; ?>">
|
||||
<?php foreach ($list as $item) :?>
|
||||
<?php foreach ($list as $item) :
|
||||
?>
|
||||
<li><div class="d-flex flex-wrap">
|
||||
<div class="col flex-sm-grow-1">
|
||||
<?php
|
||||
$link = $item->link;
|
||||
$width = (int) $item->params->get('width', 600);
|
||||
$height = (int) $item->params->get('height', 500);
|
||||
|
||||
switch ($item->params->get('target'))
|
||||
{
|
||||
switch ($item->params->get('target')) {
|
||||
case 1:
|
||||
// Open in a new window
|
||||
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
|
||||
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
|
||||
|
||||
break;
|
||||
case 2:
|
||||
// Open in a popup window
|
||||
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $width . ',height=' . $height;
|
||||
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
|
||||
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
|
||||
|
||||
break;
|
||||
case 3:
|
||||
// Open in a modal window
|
||||
|
@ -133,22 +161,28 @@ use Joomla\CMS\Language\Text;
|
|||
echo '<button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#' . $modalId . '">
|
||||
' . $item->title . '
|
||||
</button>';
|
||||
|
||||
break;
|
||||
default:
|
||||
// Open in parent window
|
||||
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
|
||||
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
|
||||
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php echo $params->get('description', 0) ? '<div class="col flex-sm-grow-1">' . $item->description . '</div>' : ''; ?>
|
||||
<?php if ($params->get('hits', 0)) : ?>
|
||||
<?php if ($params->get('hits', 0)) :
|
||||
?>
|
||||
<div class="col flex-sm-grow-1">
|
||||
<span class="badge bg-info float-md-end"><?php echo $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS'); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.weblink
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Plugin\EditorsXtd\Weblink\Extension;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Application\CMSApplicationInterface;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
@ -62,24 +65,26 @@ final class Weblink extends CMSPlugin
|
|||
{
|
||||
$user = $this->getApplication()->getIdentity();
|
||||
|
||||
if ($user->authorise('core.create', 'com_weblinks')
|
||||
if (
|
||||
$user->authorise('core.create', 'com_weblinks')
|
||||
|| $user->authorise('core.edit', 'com_weblinks')
|
||||
|| $user->authorise('core.edit.own', 'com_weblinks'))
|
||||
{
|
||||
|| $user->authorise('core.edit.own', 'com_weblinks')
|
||||
) {
|
||||
// The URL for the weblinks list
|
||||
$link = 'index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&'
|
||||
. Session::getFormToken() . '=1&editor=' . $name;
|
||||
|
||||
$button = new CMSObject;
|
||||
$button = new CMSObject();
|
||||
$button->modal = true;
|
||||
$button->link = $link;
|
||||
$button->text = Text::_('PLG_EDITORS-XTD_WEBLINK_BUTTON_WEBLINK');
|
||||
$button->name = $this->_type . '_' . $this->_name;
|
||||
$button->icon = 'globe';
|
||||
// phpcs:disable Generic.Files.LineLength
|
||||
$button->iconSVG = '<svg xmlns="http://www.w3.org/2000/svg" width="24 height="24" fill="currentColor" class="bi bi-globe" viewBox="0 0 16 16">
|
||||
<path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm7.5-6.923c-.67.204-1.335.82-1.887 1.855A7.97 7.97 0 0 0 5.145 4H7.5V1.077zM4.09 4a9.267 9.267 0 0 1 .64-1.539 6.7 6.7 0 0 1 .597-.933A7.025 7.025 0 0 0 2.255 4H4.09zm-.582 3.5c.03-.877.138-1.718.312-2.5H1.674a6.958 6.958 0 0 0-.656 2.5h2.49zM4.847 5a12.5 12.5 0 0 0-.338 2.5H7.5V5H4.847zM8.5 5v2.5h2.99a12.495 12.495 0 0 0-.337-2.5H8.5zM4.51 8.5a12.5 12.5 0 0 0 .337 2.5H7.5V8.5H4.51zm3.99 0V11h2.653c.187-.765.306-1.608.338-2.5H8.5zM5.145 12c.138.386.295.744.468 1.068.552 1.035 1.218 1.65 1.887 1.855V12H5.145zm.182 2.472a6.696 6.696 0 0 1-.597-.933A9.268 9.268 0 0 1 4.09 12H2.255a7.024 7.024 0 0 0 3.072 2.472zM3.82 11a13.652 13.652 0 0 1-.312-2.5h-2.49c.062.89.291 1.733.656 2.5H3.82zm6.853 3.472A7.024 7.024 0 0 0 13.745 12H11.91a9.27 9.27 0 0 1-.64 1.539 6.688 6.688 0 0 1-.597.933zM8.5 12v2.923c.67-.204 1.335-.82 1.887-1.855.173-.324.33-.682.468-1.068H8.5zm3.68-1h2.146c.365-.767.594-1.61.656-2.5h-2.49a13.65 13.65 0 0 1-.312 2.5zm2.802-3.5a6.959 6.959 0 0 0-.656-2.5H12.18c.174.782.282 1.623.312 2.5h2.49zM11.27 2.461c.247.464.462.98.64 1.539h1.835a7.024 7.024 0 0 0-3.072-2.472c.218.284.418.598.597.933zM10.855 4a7.966 7.966 0 0 0-.468-1.068C9.835 1.897 9.17 1.282 8.5 1.077V4h2.355z"/>
|
||||
</svg>';
|
||||
|
||||
// phpcs:enable Generic.Files.LineLength
|
||||
$button->options = [
|
||||
'height' => '300px',
|
||||
'width' => '800px',
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -9,7 +10,9 @@
|
|||
|
||||
namespace Joomla\Plugin\Finder\Weblinks\Extension;
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
|
@ -112,8 +115,7 @@ final class Weblinks extends Adapter
|
|||
public function onFinderCategoryChangeState($extension, $pks, $value)
|
||||
{
|
||||
// Make sure we're handling com_weblinks categories.
|
||||
if ($extension == 'com_weblinks')
|
||||
{
|
||||
if ($extension == 'com_weblinks') {
|
||||
$this->categoryStateChange($pks, $value);
|
||||
}
|
||||
}
|
||||
|
@ -131,16 +133,11 @@ final class Weblinks extends Adapter
|
|||
*/
|
||||
public function onFinderAfterDelete($context, $table)
|
||||
{
|
||||
if ($context == 'com_weblinks.weblink')
|
||||
{
|
||||
if ($context == 'com_weblinks.weblink') {
|
||||
$id = $table->id;
|
||||
}
|
||||
elseif ($context == 'com_finder.index')
|
||||
{
|
||||
} elseif ($context == 'com_finder.index') {
|
||||
$id = $table->link_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -166,11 +163,9 @@ final class Weblinks extends Adapter
|
|||
public function onFinderAfterSave($context, $row, $isNew)
|
||||
{
|
||||
// We only want to handle web links here. We need to handle front end and back end editing.
|
||||
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form')
|
||||
{
|
||||
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form') {
|
||||
// Check if the access levels are different.
|
||||
if (!$isNew && $this->old_access != $row->access)
|
||||
{
|
||||
if (!$isNew && $this->old_access != $row->access) {
|
||||
// Process the change.
|
||||
$this->itemAccessChange($row);
|
||||
}
|
||||
|
@ -180,11 +175,9 @@ final class Weblinks extends Adapter
|
|||
}
|
||||
|
||||
// Check for access changes in the category.
|
||||
if ($context == 'com_categories.category')
|
||||
{
|
||||
if ($context == 'com_categories.category') {
|
||||
// Check if the access levels are different.
|
||||
if (!$isNew && $this->old_cataccess != $row->access)
|
||||
{
|
||||
if (!$isNew && $this->old_cataccess != $row->access) {
|
||||
$this->categoryAccessChange($row);
|
||||
}
|
||||
}
|
||||
|
@ -208,21 +201,17 @@ final class Weblinks extends Adapter
|
|||
public function onFinderBeforeSave($context, $row, $isNew)
|
||||
{
|
||||
// We only want to handle web links here.
|
||||
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form')
|
||||
{
|
||||
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form') {
|
||||
// Query the database for the old access level if the item isn't new.
|
||||
if (!$isNew)
|
||||
{
|
||||
if (!$isNew) {
|
||||
$this->checkItemAccess($row);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for access levels from the category.
|
||||
if ($context == 'com_categories.category')
|
||||
{
|
||||
if ($context == 'com_categories.category') {
|
||||
// Query the database for the old access level if the item isn't new.
|
||||
if (!$isNew)
|
||||
{
|
||||
if (!$isNew) {
|
||||
$this->checkCategoryAccess($row);
|
||||
}
|
||||
}
|
||||
|
@ -246,14 +235,12 @@ final class Weblinks extends Adapter
|
|||
public function onFinderChangeState($context, $pks, $value)
|
||||
{
|
||||
// We only want to handle web links here.
|
||||
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form')
|
||||
{
|
||||
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form') {
|
||||
$this->itemStateChange($pks, $value);
|
||||
}
|
||||
|
||||
// Handle when the plugin is disabled.
|
||||
if ($context == 'com_plugins.plugin' && $value === 0)
|
||||
{
|
||||
if ($context == 'com_plugins.plugin' && $value === 0) {
|
||||
$this->pluginDisable($pks);
|
||||
}
|
||||
}
|
||||
|
@ -271,8 +258,7 @@ final class Weblinks extends Adapter
|
|||
protected function index(Result $item)
|
||||
{
|
||||
// Check if the extension is enabled
|
||||
if (ComponentHelper::isEnabled($this->extension) == false)
|
||||
{
|
||||
if (ComponentHelper::isEnabled($this->extension) == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -312,8 +298,7 @@ final class Weblinks extends Adapter
|
|||
$category = $categories->get($item->catid);
|
||||
|
||||
// Category does not exist, stop here
|
||||
if (!$category)
|
||||
{
|
||||
if (!$category) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -19,7 +20,9 @@ use Joomla\Database\DatabaseInterface;
|
|||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Weblinks search plugin.
|
||||
|
@ -93,9 +96,10 @@ final class Weblinks extends CMSPlugin
|
|||
|
||||
$searchText = $text;
|
||||
|
||||
if (is_array($areas)
|
||||
&& !array_intersect($areas, array_keys($this->onContentSearchAreas())))
|
||||
{
|
||||
if (
|
||||
is_array($areas)
|
||||
&& !array_intersect($areas, array_keys($this->onContentSearchAreas()))
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -104,32 +108,27 @@ final class Weblinks extends CMSPlugin
|
|||
$limit = $this->params->def('search_limit', 50);
|
||||
$state = [];
|
||||
|
||||
if ($sContent)
|
||||
{
|
||||
if ($sContent) {
|
||||
$state[] = 1;
|
||||
}
|
||||
|
||||
if ($sArchived)
|
||||
{
|
||||
if ($sArchived) {
|
||||
$state[] = 2;
|
||||
}
|
||||
|
||||
if (empty($state))
|
||||
{
|
||||
if (empty($state)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$text = trim($text);
|
||||
|
||||
if ($text == '')
|
||||
{
|
||||
if ($text == '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$searchWeblinks = Text::_('PLG_SEARCH_WEBLINKS');
|
||||
|
||||
switch ($phrase)
|
||||
{
|
||||
switch ($phrase) {
|
||||
case 'exact':
|
||||
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
|
||||
$wheres2 = [];
|
||||
|
@ -145,8 +144,7 @@ final class Weblinks extends CMSPlugin
|
|||
$words = explode(' ', $text);
|
||||
$wheres = [];
|
||||
|
||||
foreach ($words as $word)
|
||||
{
|
||||
foreach ($words as $word) {
|
||||
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
|
||||
$wheres2 = [];
|
||||
$wheres2[] = 'a.url LIKE ' . $word;
|
||||
|
@ -159,8 +157,7 @@ final class Weblinks extends CMSPlugin
|
|||
break;
|
||||
}
|
||||
|
||||
switch ($ordering)
|
||||
{
|
||||
switch ($ordering) {
|
||||
case 'oldest':
|
||||
$order = 'a.created ASC';
|
||||
break;
|
||||
|
@ -214,8 +211,7 @@ final class Weblinks extends CMSPlugin
|
|||
|
||||
// Filter by language.
|
||||
|
||||
if ($app->isClient('site') && Multilanguage::isEnabled())
|
||||
{
|
||||
if ($app->isClient('site') && Multilanguage::isEnabled()) {
|
||||
$languages = [$app->getLanguage()->getTag(), '*'];
|
||||
$query->whereIn($db->quoteName('a.language'), $languages, ParameterType::STRING)
|
||||
->whereIn($db->quoteName('c.language'), $languages, ParameterType::STRING);
|
||||
|
@ -226,17 +222,13 @@ final class Weblinks extends CMSPlugin
|
|||
|
||||
$return = [];
|
||||
|
||||
if ($rows)
|
||||
{
|
||||
foreach ($rows as $key => $row)
|
||||
{
|
||||
if ($rows) {
|
||||
foreach ($rows as $key => $row) {
|
||||
$rows[$key]->href = RouteHelper::getWeblinkRoute($row->slug, $row->catslug);
|
||||
}
|
||||
|
||||
foreach ($rows as $weblink)
|
||||
{
|
||||
if (\searchHelper::checkNoHTML($weblink, $searchText, ['url', 'text', 'title']))
|
||||
{
|
||||
foreach ($rows as $weblink) {
|
||||
if (\searchHelper::checkNoHTML($weblink, $searchText, ['url', 'text', 'title'])) {
|
||||
$return[] = $weblink;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage Weblinks
|
||||
|
@ -18,7 +19,9 @@ use Joomla\Event\DispatcherInterface;
|
|||
use Joomla\Event\Event;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* System plugin for Joomla Web Links.
|
||||
|
@ -87,15 +90,13 @@ final class Weblinks extends CMSPlugin implements SubscriberInterface
|
|||
*/
|
||||
public function onGetStats(Event $event)
|
||||
{
|
||||
if (!ComponentHelper::isEnabled('com_weblinks'))
|
||||
{
|
||||
if (!ComponentHelper::isEnabled('com_weblinks')) {
|
||||
return;
|
||||
}
|
||||
|
||||
[$extension] = $event->getArguments();
|
||||
|
||||
if (!in_array($extension, $this->supportedExtensions))
|
||||
{
|
||||
if (!in_array($extension, $this->supportedExtensions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -106,8 +107,7 @@ final class Weblinks extends CMSPlugin implements SubscriberInterface
|
|||
->where('state = 1');
|
||||
$webLinks = $db->setQuery($query)->loadResult();
|
||||
|
||||
if (!$webLinks)
|
||||
{
|
||||
if (!$webLinks) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue