- md5
- c471e42c06841bd69bd838a9bfa394be
- sha1
- b76e24602ead31a241bee8e9a808acea2f6f3bd0
- sha256
- 40ca0c42d2df70e32a33e3d2961d845666ac0d4986f343eb3d58595adc07ee75
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
<?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @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\Contact\Administrator\Extension;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Association\AssociationServiceInterface;
use Joomla\CMS\Association\AssociationServiceTrait;
use Joomla\CMS\Categories\CategoryServiceInterface;
use Joomla\CMS\Categories\CategoryServiceTrait;
use Joomla\CMS\Extension\BootableExtensionInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Factory;
use Joomla\CMS\Fields\FieldsServiceInterface;
use Joomla\CMS\Form\Form;
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
use Joomla\CMS\Language\Text;
use Joomla\Component\Contact\Administrator\Service\HTML\AdministratorService;
use Psr\Container\ContainerInterface;
/**
* Component class for com_contact
*
* @since 4.0.0
*/
class ContactComponent extends MVCComponent implements
BootableExtensionInterface, CategoryServiceInterface, FieldsServiceInterface, AssociationServiceInterface
{
use CategoryServiceTrait;
use AssociationServiceTrait;
use HTMLRegistryAwareTrait;
/**
* 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('contactadministrator', new AdministratorService);
}
/**
* 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') && $section == 'contact' && $item instanceof Form)
{
// The contact form needs to be the mail section
$section = 'mail';
}
if (Factory::getApplication()->isClient('site') && $section == 'category')
{
// The contact form needs to be the mail section
$section = 'contact';
}
if ($section !== 'mail' && $section !== 'contact')
{
// 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_contact', JPATH_ADMINISTRATOR);
$contexts = array(
'com_contact.contact' => Text::_('COM_CONTACT_FIELDS_CONTEXT_CONTACT'),
'com_contact.mail' => Text::_('COM_CONTACT_FIELDS_CONTEXT_MAIL'),
'com_contact.categories' => Text::_('JCATEGORY')
);
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' : 'contact_details');
}
/**
* 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 'published';
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha11 to 4.0.0-alpha12. See them all, or every version of this file.