mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-05-29 04:30:46 +00:00
f6a5e30925
This reverts commit c4b4dfcc6f
.
151 lines
3.9 KiB
PHP
151 lines
3.9 KiB
PHP
<?php
|
|
/**
|
|
* @package Joomla.Administrator
|
|
* @subpackage com_weblinks
|
|
*
|
|
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
*/
|
|
|
|
namespace Joomla\Component\Weblinks\Administrator\Extension;
|
|
|
|
defined('JPATH_PLATFORM') or die;
|
|
|
|
use Joomla\CMS\Application\SiteApplication;
|
|
use Joomla\CMS\Association\AssociationServiceInterface;
|
|
use Joomla\CMS\Association\AssociationServiceTrait;
|
|
use Joomla\CMS\Categories\CategoryServiceInterface;
|
|
use Joomla\CMS\Categories\CategoryServiceTrait;
|
|
use Joomla\CMS\Component\Router\RouterServiceInterface;
|
|
use Joomla\CMS\Component\Router\RouterServiceTrait;
|
|
use Joomla\CMS\Extension\BootableExtensionInterface;
|
|
use Joomla\CMS\Extension\MVCComponent;
|
|
use Joomla\CMS\Factory;
|
|
use Joomla\CMS\Fields\FieldsServiceInterface;
|
|
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
|
|
use Joomla\CMS\Language\Text;
|
|
use Joomla\CMS\Tag\TagServiceInterface;
|
|
use Joomla\CMS\Tag\TagServiceTrait;
|
|
use Joomla\Component\Weblinks\Administrator\Service\HTML\AdministratorService;
|
|
use Joomla\Component\Weblinks\Administrator\Service\HTML\Icon;
|
|
use Psr\Container\ContainerInterface;
|
|
|
|
/**
|
|
* Component class for com_weblinks
|
|
*
|
|
* @since 4.0.0
|
|
*/
|
|
class WeblinksComponent extends MVCComponent implements CategoryServiceInterface, AssociationServiceInterface,
|
|
TagServiceInterface, RouterServiceInterface, BootableExtensionInterface, FieldsServiceInterface
|
|
{
|
|
use CategoryServiceTrait;
|
|
use AssociationServiceTrait;
|
|
use HTMLRegistryAwareTrait;
|
|
use RouterServiceTrait;
|
|
use CategoryServiceTrait, TagServiceTrait
|
|
{
|
|
CategoryServiceTrait::getTableNameForSection insteadof TagServiceTrait;
|
|
CategoryServiceTrait::getStateColumnForSection insteadof TagServiceTrait;
|
|
}
|
|
|
|
/**
|
|
* Booting the extension. This is the function to set up the environment of the extension like
|
|
* registering new class loaders, etc.
|
|
*
|
|
* If required, some initial set up can be done from services of the container, eg.
|
|
* registering HTML services.
|
|
*
|
|
* @param ContainerInterface $container The container
|
|
*
|
|
* @return void
|
|
*
|
|
* @since 4.0.0
|
|
*/
|
|
public function boot(ContainerInterface $container)
|
|
{
|
|
$this->getRegistry()->register('weblinksadministrator', new AdministratorService);
|
|
$this->getRegistry()->register('weblinkicon', new Icon($container->get(SiteApplication::class)));
|
|
}
|
|
|
|
/**
|
|
* Returns a valid section for the given section. If it is not valid then null
|
|
* is returned.
|
|
*
|
|
* @param string $section The section to get the mapping for
|
|
* @param object $item The item
|
|
*
|
|
* @return string|null The new section
|
|
*
|
|
* @since 4.0.0
|
|
*/
|
|
public function validateSection($section, $item = null)
|
|
{
|
|
if (Factory::getApplication()->isClient('site'))
|
|
{
|
|
// On the front end we need to map some sections
|
|
switch ($section)
|
|
{
|
|
// Adding/Editing a weblink
|
|
case 'form':
|
|
$section = 'weblink';
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($section != 'weblink')
|
|
{
|
|
// We don't know other sections
|
|
return null;
|
|
}
|
|
|
|
return $section;
|
|
}
|
|
|
|
/**
|
|
* Returns valid contexts
|
|
*
|
|
* @return array
|
|
*
|
|
* @since 4.0.0
|
|
*/
|
|
public function getContexts(): array
|
|
{
|
|
Factory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR);
|
|
|
|
$contexts = array(
|
|
'com_weblinks.weblink' => Text::_('COM_WEBLINKS'),
|
|
);
|
|
|
|
return $contexts;
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the table for the count items functions for the given section.
|
|
*
|
|
* @param string $section The section
|
|
*
|
|
* @return string|null
|
|
*
|
|
* @since 4.0.0
|
|
*/
|
|
protected function getTableNameForSection(string $section = null)
|
|
{
|
|
return ($section === 'category' ? 'categories' : 'weblinks');
|
|
}
|
|
|
|
/**
|
|
* Returns the state column for the count items functions for the given section.
|
|
*
|
|
* @param string $section The section
|
|
*
|
|
* @return string|null
|
|
*
|
|
* @since 4.0.0
|
|
*/
|
|
protected function getStateColumnForSection(string $section = null)
|
|
{
|
|
return 'state';
|
|
}
|
|
}
|