first commit
This commit is contained in:
236
components/com_ajax/ajax.php
Normal file
236
components/com_ajax/ajax.php
Normal file
@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_ajax
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Event\Plugin\AjaxEvent;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Log\Log;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
||||
/*
|
||||
* References
|
||||
* Support plugins in your component
|
||||
* - https://docs.joomla.org/Special:MyLanguage/Supporting_plugins_in_your_component
|
||||
*
|
||||
* Best way for JSON output
|
||||
* - https://groups.google.com/d/msg/joomla-dev-cms/WsC0nA9Fixo/Ur-gPqpqh-EJ
|
||||
*/
|
||||
|
||||
/** @var \Joomla\CMS\Application\CMSApplication $app */
|
||||
$app = Factory::getApplication();
|
||||
$app->allowCache(false);
|
||||
|
||||
// Prevent the api url from being indexed
|
||||
$app->setHeader('X-Robots-Tag', 'noindex, nofollow');
|
||||
|
||||
// JInput object
|
||||
$input = $app->getInput();
|
||||
|
||||
// Requested format passed via URL
|
||||
$format = strtolower($input->getWord('format', ''));
|
||||
|
||||
// Initialize default response and module name
|
||||
$results = null;
|
||||
$parts = null;
|
||||
|
||||
// Check for valid format
|
||||
if (!$format) {
|
||||
$results = new InvalidArgumentException(Text::_('COM_AJAX_SPECIFY_FORMAT'), 404);
|
||||
} elseif ($input->get('module')) {
|
||||
/**
|
||||
* Module support.
|
||||
*
|
||||
* modFooHelper::getAjax() is called where 'foo' is the value
|
||||
* of the 'module' variable passed via the URL
|
||||
* (i.e. index.php?option=com_ajax&module=foo).
|
||||
*
|
||||
*/
|
||||
$module = $input->get('module');
|
||||
$table = Table::getInstance('extension');
|
||||
$moduleId = $table->find(['type' => 'module', 'element' => 'mod_' . $module]);
|
||||
|
||||
if ($moduleId && $table->load($moduleId) && $table->enabled) {
|
||||
$helperFile = JPATH_BASE . '/modules/mod_' . $module . '/helper.php';
|
||||
|
||||
if (strpos($module, '_')) {
|
||||
$parts = explode('_', $module);
|
||||
} elseif (strpos($module, '-')) {
|
||||
$parts = explode('-', $module);
|
||||
}
|
||||
|
||||
if ($parts) {
|
||||
$class = 'Mod';
|
||||
|
||||
foreach ($parts as $part) {
|
||||
$class .= ucfirst($part);
|
||||
}
|
||||
|
||||
$class .= 'Helper';
|
||||
} else {
|
||||
$class = 'Mod' . ucfirst($module) . 'Helper';
|
||||
}
|
||||
|
||||
$method = $input->get('method') ?: 'get';
|
||||
|
||||
$moduleInstance = $app->bootModule('mod_' . $module, $app->getName());
|
||||
|
||||
if ($moduleInstance instanceof \Joomla\CMS\Helper\HelperFactoryInterface && $helper = $moduleInstance->getHelper(substr($class, 3))) {
|
||||
$results = method_exists($helper, $method . 'Ajax') ? $helper->{$method . 'Ajax'}() : null;
|
||||
}
|
||||
|
||||
if ($results === null && is_file($helperFile)) {
|
||||
JLoader::register($class, $helperFile);
|
||||
|
||||
if (method_exists($class, $method . 'Ajax')) {
|
||||
// Load language file for module
|
||||
$basePath = JPATH_BASE;
|
||||
$lang = Factory::getLanguage();
|
||||
$lang->load('mod_' . $module, $basePath)
|
||||
|| $lang->load('mod_' . $module, $basePath . '/modules/mod_' . $module);
|
||||
|
||||
try {
|
||||
$results = \call_user_func($class . '::' . $method . 'Ajax');
|
||||
} catch (Exception $e) {
|
||||
$results = $e;
|
||||
}
|
||||
} else {
|
||||
// Method does not exist
|
||||
$results = new LogicException(Text::sprintf('COM_AJAX_METHOD_NOT_EXISTS', $method . 'Ajax'), 404);
|
||||
}
|
||||
} elseif ($results === null) {
|
||||
// The helper file does not exist
|
||||
$results = new RuntimeException(Text::sprintf('COM_AJAX_FILE_NOT_EXISTS', 'mod_' . $module . '/helper.php'), 404);
|
||||
}
|
||||
} else {
|
||||
// Module is not published, you do not have access to it, or it is not assigned to the current menu item
|
||||
$results = new LogicException(Text::sprintf('COM_AJAX_MODULE_NOT_ACCESSIBLE', 'mod_' . $module), 404);
|
||||
}
|
||||
} elseif ($input->get('plugin')) {
|
||||
/**
|
||||
* Plugin support by default is based on the "Ajax" plugin group.
|
||||
* An optional 'group' variable can be passed via the URL.
|
||||
*
|
||||
* The plugin event triggered is onAjaxFoo, where 'foo' is
|
||||
* the value of the 'plugin' variable passed via the URL
|
||||
* (i.e. index.php?option=com_ajax&plugin=foo)
|
||||
*
|
||||
*/
|
||||
try {
|
||||
$dispatcher = $app->getDispatcher();
|
||||
$group = $input->get('group', 'ajax');
|
||||
$eventName = 'onAjax' . ucfirst($input->get('plugin', ''));
|
||||
|
||||
PluginHelper::importPlugin($group, null, true, $dispatcher);
|
||||
|
||||
$results = $dispatcher->dispatch($eventName, new AjaxEvent($eventName, ['subject' => $app]))->getArgument('result', []);
|
||||
} catch (Throwable $e) {
|
||||
$results = $e;
|
||||
}
|
||||
} elseif ($input->get('template')) {
|
||||
/**
|
||||
* Template support.
|
||||
*
|
||||
* tplFooHelper::getAjax() is called where 'foo' is the value
|
||||
* of the 'template' variable passed via the URL
|
||||
* (i.e. index.php?option=com_ajax&template=foo).
|
||||
*
|
||||
*/
|
||||
$template = $input->get('template');
|
||||
$table = Table::getInstance('extension');
|
||||
$templateId = $table->find(['type' => 'template', 'element' => $template]);
|
||||
|
||||
if ($templateId && $table->load($templateId) && $table->enabled) {
|
||||
$basePath = ($table->client_id) ? JPATH_ADMINISTRATOR : JPATH_SITE;
|
||||
$helperFile = $basePath . '/templates/' . $template . '/helper.php';
|
||||
|
||||
if (strpos($template, '_')) {
|
||||
$parts = explode('_', $template);
|
||||
} elseif (strpos($template, '-')) {
|
||||
$parts = explode('-', $template);
|
||||
}
|
||||
|
||||
if ($parts) {
|
||||
$class = 'Tpl';
|
||||
|
||||
foreach ($parts as $part) {
|
||||
$class .= ucfirst($part);
|
||||
}
|
||||
|
||||
$class .= 'Helper';
|
||||
} else {
|
||||
$class = 'Tpl' . ucfirst($template) . 'Helper';
|
||||
}
|
||||
|
||||
$method = $input->get('method') ?: 'get';
|
||||
|
||||
if (is_file($helperFile)) {
|
||||
JLoader::register($class, $helperFile);
|
||||
|
||||
if (method_exists($class, $method . 'Ajax')) {
|
||||
// Load language file for template
|
||||
$lang = Factory::getLanguage();
|
||||
$lang->load('tpl_' . $template, $basePath)
|
||||
|| $lang->load('tpl_' . $template, $basePath . '/templates/' . $template);
|
||||
|
||||
try {
|
||||
$results = \call_user_func($class . '::' . $method . 'Ajax');
|
||||
} catch (Exception $e) {
|
||||
$results = $e;
|
||||
}
|
||||
} else {
|
||||
// Method does not exist
|
||||
$results = new LogicException(Text::sprintf('COM_AJAX_METHOD_NOT_EXISTS', $method . 'Ajax'), 404);
|
||||
}
|
||||
} else {
|
||||
// The helper file does not exist
|
||||
$results = new RuntimeException(Text::sprintf('COM_AJAX_FILE_NOT_EXISTS', 'tpl_' . $template . '/helper.php'), 404);
|
||||
}
|
||||
} else {
|
||||
// Template is not assigned to the current menu item
|
||||
$results = new LogicException(Text::sprintf('COM_AJAX_TEMPLATE_NOT_ACCESSIBLE', 'tpl_' . $template), 404);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the results in the desired format
|
||||
switch ($format) {
|
||||
// JSONinzed
|
||||
case 'json':
|
||||
echo new JsonResponse($results, null, false, $input->get('ignoreMessages', true, 'bool'));
|
||||
|
||||
break;
|
||||
|
||||
// Handle as raw format
|
||||
default:
|
||||
// Output exception
|
||||
if ($results instanceof Exception) {
|
||||
// Log an error
|
||||
Log::add($results->getMessage(), Log::ERROR);
|
||||
|
||||
// Set status header code
|
||||
$app->setHeader('status', $results->getCode(), true);
|
||||
|
||||
// Echo exception type and message
|
||||
$out = \get_class($results) . ': ' . $results->getMessage();
|
||||
} elseif (is_scalar($results)) {
|
||||
// Output string/ null
|
||||
$out = (string) $results;
|
||||
} else {
|
||||
// Output array/ object
|
||||
$out = implode((array) $results);
|
||||
}
|
||||
|
||||
echo $out;
|
||||
|
||||
break;
|
||||
}
|
||||
45
components/com_banners/src/Controller/DisplayController.php
Normal file
45
components/com_banners/src/Controller/DisplayController.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\Site\Controller;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banners Controller
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Method when a banner is clicked on.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function click()
|
||||
{
|
||||
$id = $this->input->getInt('id', 0);
|
||||
|
||||
if ($id) {
|
||||
/** @var \Joomla\Component\Banners\Site\Model\BannerModel $model */
|
||||
$model = $this->getModel('Banner', 'Site', ['ignore_request' => true]);
|
||||
$model->setState('banner.id', $id);
|
||||
$model->click();
|
||||
$this->setRedirect($model->getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
43
components/com_banners/src/Helper/BannerHelper.php
Normal file
43
components/com_banners/src/Helper/BannerHelper.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\Site\Helper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banner Helper Class
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
abstract class BannerHelper
|
||||
{
|
||||
/**
|
||||
* Checks if a URL is an image
|
||||
*
|
||||
* @param string $url The URL path to the potential image
|
||||
*
|
||||
* @return boolean True if an image of type bmp, gif, jp(e)g, png or webp, false otherwise
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function isImage($url)
|
||||
{
|
||||
$urlCheck = explode('?', $url);
|
||||
|
||||
if (preg_match('#\.(?:bmp|gif|jpe?g|png|webp)$#i', $urlCheck[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
223
components/com_banners/src/Model/BannerModel.php
Normal file
223
components/com_banners/src/Model/BannerModel.php
Normal file
@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\Site\Model;
|
||||
|
||||
use Joomla\CMS\Cache\Exception\CacheExceptionInterface;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banner model for the Joomla Banners component.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class BannerModel extends BaseDatabaseModel
|
||||
{
|
||||
/**
|
||||
* Cached item object
|
||||
*
|
||||
* @var object
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $_item;
|
||||
|
||||
/**
|
||||
* Clicks the URL, incrementing the counter
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function click()
|
||||
{
|
||||
$item = $this->getItem();
|
||||
|
||||
if (empty($item)) {
|
||||
throw new \Exception(Text::_('JERROR_PAGE_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
$id = (int) $this->getState('banner.id');
|
||||
|
||||
// Update click count
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->update($db->quoteName('#__banners'))
|
||||
->set($db->quoteName('clicks') . ' = ' . $db->quoteName('clicks') . ' + 1')
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new \Exception($e->getMessage(), 500);
|
||||
}
|
||||
|
||||
// Track clicks
|
||||
$trackClicks = $item->track_clicks;
|
||||
|
||||
if ($trackClicks < 0 && $item->cid) {
|
||||
$trackClicks = $item->client_track_clicks;
|
||||
}
|
||||
|
||||
if ($trackClicks < 0) {
|
||||
$config = ComponentHelper::getParams('com_banners');
|
||||
$trackClicks = $config->get('track_clicks');
|
||||
}
|
||||
|
||||
if ($trackClicks > 0) {
|
||||
$trackDate = Factory::getDate()->format('Y-m-d H:00:00');
|
||||
$trackDate = Factory::getDate($trackDate)->toSql();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select($db->quoteName('count'))
|
||||
->from($db->quoteName('#__banner_tracks'))
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('track_type') . ' = 2',
|
||||
$db->quoteName('banner_id') . ' = :id',
|
||||
$db->quoteName('track_date') . ' = :trackDate',
|
||||
]
|
||||
)
|
||||
->bind(':id', $id, ParameterType::INTEGER)
|
||||
->bind(':trackDate', $trackDate);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new \Exception($e->getMessage(), 500);
|
||||
}
|
||||
|
||||
$count = $db->loadResult();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
if ($count) {
|
||||
// Update count
|
||||
$query->update($db->quoteName('#__banner_tracks'))
|
||||
->set($db->quoteName('count') . ' = ' . $db->quoteName('count') . ' + 1')
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('track_type') . ' = 2',
|
||||
$db->quoteName('banner_id') . ' = :id',
|
||||
$db->quoteName('track_date') . ' = :trackDate',
|
||||
]
|
||||
)
|
||||
->bind(':id', $id, ParameterType::INTEGER)
|
||||
->bind(':trackDate', $trackDate);
|
||||
} else {
|
||||
// Insert new count
|
||||
$query->insert($db->quoteName('#__banner_tracks'))
|
||||
->columns(
|
||||
[
|
||||
$db->quoteName('count'),
|
||||
$db->quoteName('track_type'),
|
||||
$db->quoteName('banner_id'),
|
||||
$db->quoteName('track_date'),
|
||||
]
|
||||
)
|
||||
->values('1, 2 , :id, :trackDate')
|
||||
->bind(':id', $id, ParameterType::INTEGER)
|
||||
->bind(':trackDate', $trackDate);
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new \Exception($e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data for a banner.
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function &getItem()
|
||||
{
|
||||
if (!isset($this->_item)) {
|
||||
/** @var \Joomla\CMS\Cache\Controller\CallbackController $cache */
|
||||
$cache = Factory::getCache('com_banners', 'callback');
|
||||
|
||||
$id = (int) $this->getState('banner.id');
|
||||
|
||||
// For PHP 5.3 compat we can't use $this in the lambda function below, so grab the database driver now to use it
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$loader = function ($id) use ($db) {
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select(
|
||||
[
|
||||
$db->quoteName('a.clickurl'),
|
||||
$db->quoteName('a.cid'),
|
||||
$db->quoteName('a.track_clicks'),
|
||||
$db->quoteName('cl.track_clicks', 'client_track_clicks'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__banners', 'a'))
|
||||
->join('LEFT', $db->quoteName('#__banner_clients', 'cl'), $db->quoteName('cl.id') . ' = ' . $db->quoteName('a.cid'))
|
||||
->where($db->quoteName('a.id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObject();
|
||||
};
|
||||
|
||||
try {
|
||||
$this->_item = $cache->get($loader, [$id], md5(__METHOD__ . $id));
|
||||
} catch (CacheExceptionInterface $e) {
|
||||
$this->_item = $loader($id);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for a banner
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
$item = $this->getItem();
|
||||
$url = $item->clickurl;
|
||||
|
||||
// Check for links
|
||||
if (!preg_match('#http[s]?://|index[2]?\.php#', $url)) {
|
||||
$url = "http://$url";
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
384
components/com_banners/src/Model/BannersModel.php
Normal file
384
components/com_banners/src/Model/BannersModel.php
Normal file
@ -0,0 +1,384 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\Site\Model;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Database\DatabaseQuery;
|
||||
use Joomla\Database\Exception\ExecutionFailureException;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banners model for the Joomla Banners component.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class BannersModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
$id .= ':' . $this->getState('filter.tag_search');
|
||||
$id .= ':' . $this->getState('filter.client_id');
|
||||
$id .= ':' . serialize($this->getState('filter.category_id'));
|
||||
$id .= ':' . serialize($this->getState('filter.keywords'));
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a DatabaseQuery object for retrieving the data set from a database.
|
||||
*
|
||||
* @return DatabaseQuery A DatabaseQuery object to retrieve the data set.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
$ordering = $this->getState('filter.ordering');
|
||||
$tagSearch = $this->getState('filter.tag_search');
|
||||
$cid = (int) $this->getState('filter.client_id');
|
||||
$categoryId = $this->getState('filter.category_id');
|
||||
$keywords = $this->getState('filter.keywords');
|
||||
$randomise = ($ordering === 'random');
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
|
||||
$query->select(
|
||||
[
|
||||
$db->quoteName('a.id'),
|
||||
$db->quoteName('a.type'),
|
||||
$db->quoteName('a.name'),
|
||||
$db->quoteName('a.clickurl'),
|
||||
$db->quoteName('a.sticky'),
|
||||
$db->quoteName('a.cid'),
|
||||
$db->quoteName('a.description'),
|
||||
$db->quoteName('a.params'),
|
||||
$db->quoteName('a.custombannercode'),
|
||||
$db->quoteName('a.track_impressions'),
|
||||
$db->quoteName('cl.track_impressions', 'client_track_impressions'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__banners', 'a'))
|
||||
->join('LEFT', $db->quoteName('#__banner_clients', 'cl'), $db->quoteName('cl.id') . ' = ' . $db->quoteName('a.cid'))
|
||||
->where($db->quoteName('a.state') . ' = 1')
|
||||
->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('a.publish_up') . ' IS NULL',
|
||||
$db->quoteName('a.publish_up') . ' <= :nowDate1',
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('a.publish_down') . ' IS NULL',
|
||||
$db->quoteName('a.publish_down') . ' >= :nowDate2',
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('a.imptotal') . ' = 0',
|
||||
$db->quoteName('a.impmade') . ' < ' . $db->quoteName('a.imptotal'),
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->bind([':nowDate1', ':nowDate2'], $nowDate);
|
||||
|
||||
if ($cid) {
|
||||
$query->where(
|
||||
[
|
||||
$db->quoteName('a.cid') . ' = :clientId',
|
||||
$db->quoteName('cl.state') . ' = 1',
|
||||
]
|
||||
)
|
||||
->bind(':clientId', $cid, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter by a single or group of categories
|
||||
if (is_numeric($categoryId)) {
|
||||
$categoryId = (int) $categoryId;
|
||||
$type = $this->getState('filter.category_id.include', true) ? ' = ' : ' <> ';
|
||||
|
||||
// Add subcategory check
|
||||
if ($this->getState('filter.subcategories', false)) {
|
||||
$levels = (int) $this->getState('filter.max_category_levels', '1');
|
||||
|
||||
// Create a subquery for the subcategory list
|
||||
$subQuery = $db->getQuery(true);
|
||||
$subQuery->select($db->quoteName('sub.id'))
|
||||
->from($db->quoteName('#__categories', 'sub'))
|
||||
->join(
|
||||
'INNER',
|
||||
$db->quoteName('#__categories', 'this'),
|
||||
$db->quoteName('sub.lft') . ' > ' . $db->quoteName('this.lft')
|
||||
. ' AND ' . $db->quoteName('sub.rgt') . ' < ' . $db->quoteName('this.rgt')
|
||||
)
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('this.id') . ' = :categoryId1',
|
||||
$db->quoteName('sub.level') . ' <= ' . $db->quoteName('this.level') . ' + :levels',
|
||||
]
|
||||
);
|
||||
|
||||
// Add the subquery to the main query
|
||||
$query->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('a.catid') . $type . ':categoryId2',
|
||||
$db->quoteName('a.catid') . ' IN (' . $subQuery . ')',
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->bind([':categoryId1', ':categoryId2'], $categoryId, ParameterType::INTEGER)
|
||||
->bind(':levels', $levels, ParameterType::INTEGER);
|
||||
} else {
|
||||
$query->where($db->quoteName('a.catid') . $type . ':categoryId')
|
||||
->bind(':categoryId', $categoryId, ParameterType::INTEGER);
|
||||
}
|
||||
} elseif (\is_array($categoryId) && (\count($categoryId) > 0)) {
|
||||
$categoryId = ArrayHelper::toInteger($categoryId);
|
||||
|
||||
if ($this->getState('filter.category_id.include', true)) {
|
||||
$query->whereIn($db->quoteName('a.catid'), $categoryId);
|
||||
} else {
|
||||
$query->whereNotIn($db->quoteName('a.catid'), $categoryId);
|
||||
}
|
||||
}
|
||||
|
||||
if ($tagSearch) {
|
||||
if (!$keywords) {
|
||||
// No keywords, select nothing.
|
||||
$query->where('0 != 0');
|
||||
} else {
|
||||
$temp = [];
|
||||
$config = ComponentHelper::getParams('com_banners');
|
||||
$prefix = $config->get('metakey_prefix');
|
||||
|
||||
if ($categoryId) {
|
||||
$query->join('LEFT', $db->quoteName('#__categories', 'cat'), $db->quoteName('a.catid') . ' = ' . $db->quoteName('cat.id'));
|
||||
}
|
||||
|
||||
foreach ($keywords as $key => $keyword) {
|
||||
$regexp = '[[:<:]]' . $keyword . '[[:>:]]';
|
||||
$valuesToBind = [$keyword, $keyword, $regexp];
|
||||
|
||||
if ($cid) {
|
||||
$valuesToBind[] = $regexp;
|
||||
}
|
||||
|
||||
if ($categoryId) {
|
||||
$valuesToBind[] = $regexp;
|
||||
}
|
||||
|
||||
// Because values to $query->bind() are passed by reference, using $query->bindArray() here instead to prevent overwriting.
|
||||
$bounded = $query->bindArray($valuesToBind, ParameterType::STRING);
|
||||
|
||||
$condition1 = $db->quoteName('a.own_prefix') . ' = 1'
|
||||
. ' AND ' . $db->quoteName('a.metakey_prefix')
|
||||
. ' = SUBSTRING(' . $bounded[0] . ',1,LENGTH(' . $db->quoteName('a.metakey_prefix') . '))'
|
||||
. ' OR ' . $db->quoteName('a.own_prefix') . ' = 0'
|
||||
. ' AND ' . $db->quoteName('cl.own_prefix') . ' = 1'
|
||||
. ' AND ' . $db->quoteName('cl.metakey_prefix')
|
||||
. ' = SUBSTRING(' . $bounded[1] . ',1,LENGTH(' . $db->quoteName('cl.metakey_prefix') . '))'
|
||||
. ' OR ' . $db->quoteName('a.own_prefix') . ' = 0'
|
||||
. ' AND ' . $db->quoteName('cl.own_prefix') . ' = 0'
|
||||
. ' AND ' . ($prefix == substr($keyword, 0, \strlen($prefix)) ? '0 = 0' : '0 != 0');
|
||||
|
||||
$condition2 = $db->quoteName('a.metakey') . ' ' . $query->regexp($bounded[2]);
|
||||
|
||||
if ($cid) {
|
||||
$condition2 .= ' OR ' . $db->quoteName('cl.metakey') . ' ' . $query->regexp($bounded[3]) . ' ';
|
||||
}
|
||||
|
||||
if ($categoryId) {
|
||||
$condition2 .= ' OR ' . $db->quoteName('cat.metakey') . ' ' . $query->regexp($bounded[4]) . ' ';
|
||||
}
|
||||
|
||||
$temp[] = "($condition1) AND ($condition2)";
|
||||
}
|
||||
|
||||
$query->where('(' . implode(' OR ', $temp) . ')');
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by language
|
||||
if ($this->getState('filter.language')) {
|
||||
$query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
|
||||
}
|
||||
|
||||
$query->order($db->quoteName('a.sticky') . ' DESC, ' . ($randomise ? $query->rand() : $db->quoteName('a.ordering')));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of banners.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
if ($this->getState('filter.tag_search')) {
|
||||
// Filter out empty keywords.
|
||||
$keywords = array_values(array_filter(array_map('trim', $this->getState('filter.keywords')), 'strlen'));
|
||||
|
||||
// Re-set state before running the query.
|
||||
$this->setState('filter.keywords', $keywords);
|
||||
|
||||
// If no keywords are provided, avoid running the query.
|
||||
if (!$keywords) {
|
||||
$this->cache['items'] = [];
|
||||
|
||||
return $this->cache['items'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($this->cache['items'])) {
|
||||
$this->cache['items'] = parent::getItems();
|
||||
|
||||
foreach ($this->cache['items'] as &$item) {
|
||||
$item->params = new Registry($item->params);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->cache['items'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes impressions on a list of banners
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function impress()
|
||||
{
|
||||
$trackDate = Factory::getDate()->format('Y-m-d H:00:00');
|
||||
$trackDate = Factory::getDate($trackDate)->toSql();
|
||||
$items = $this->getItems();
|
||||
$db = $this->getDatabase();
|
||||
$bid = [];
|
||||
|
||||
if (!\count($items)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
$bid[] = (int) $item->id;
|
||||
}
|
||||
|
||||
// Increment impression made
|
||||
$query = $db->getQuery(true);
|
||||
$query->update($db->quoteName('#__banners'))
|
||||
->set($db->quoteName('impmade') . ' = ' . $db->quoteName('impmade') . ' + 1')
|
||||
->whereIn($db->quoteName('id'), $bid);
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (ExecutionFailureException $e) {
|
||||
throw new \Exception($e->getMessage(), 500);
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
// Track impressions
|
||||
$trackImpressions = $item->track_impressions;
|
||||
|
||||
if ($trackImpressions < 0 && $item->cid) {
|
||||
$trackImpressions = $item->client_track_impressions;
|
||||
}
|
||||
|
||||
if ($trackImpressions < 0) {
|
||||
$config = ComponentHelper::getParams('com_banners');
|
||||
$trackImpressions = $config->get('track_impressions');
|
||||
}
|
||||
|
||||
if ($trackImpressions > 0) {
|
||||
// Is track already created?
|
||||
// Update count
|
||||
$query = $db->getQuery(true);
|
||||
$query->update($db->quoteName('#__banner_tracks'))
|
||||
->set($db->quoteName('count') . ' = ' . $db->quoteName('count') . ' + 1')
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('track_type') . ' = 1',
|
||||
$db->quoteName('banner_id') . ' = :id',
|
||||
$db->quoteName('track_date') . ' = :trackDate',
|
||||
]
|
||||
)
|
||||
->bind(':id', $item->id, ParameterType::INTEGER)
|
||||
->bind(':trackDate', $trackDate);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (ExecutionFailureException $e) {
|
||||
throw new \Exception($e->getMessage(), 500);
|
||||
}
|
||||
|
||||
if ($db->getAffectedRows() === 0) {
|
||||
// Insert new count
|
||||
$query = $db->getQuery(true);
|
||||
$query->insert($db->quoteName('#__banner_tracks'))
|
||||
->columns(
|
||||
[
|
||||
$db->quoteName('count'),
|
||||
$db->quoteName('track_type'),
|
||||
$db->quoteName('banner_id'),
|
||||
$db->quoteName('track_date'),
|
||||
]
|
||||
)
|
||||
->values('1, 1, :id, :trackDate')
|
||||
->bind(':id', $item->id, ParameterType::INTEGER)
|
||||
->bind(':trackDate', $trackDate);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (ExecutionFailureException $e) {
|
||||
throw new \Exception($e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
40
components/com_banners/src/Service/Category.php
Normal file
40
components/com_banners/src/Service/Category.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\Site\Service;
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banners Component Category Tree
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class Category extends Categories
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $options Array of options
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
{
|
||||
$options['table'] = '#__banners';
|
||||
$options['extension'] = 'com_banners';
|
||||
|
||||
parent::__construct($options);
|
||||
}
|
||||
}
|
||||
100
components/com_banners/src/Service/Router.php
Normal file
100
components/com_banners/src/Service/Router.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\Site\Service;
|
||||
|
||||
use Joomla\CMS\Component\Router\RouterBase;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Routing class from com_banners
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
class Router extends RouterBase
|
||||
{
|
||||
/**
|
||||
* Build the route for the com_banners component
|
||||
*
|
||||
* @param array $query An array of URL arguments
|
||||
*
|
||||
* @return array The URL arguments to use to assemble the subsequent URL.
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public function build(&$query)
|
||||
{
|
||||
$segments = [];
|
||||
|
||||
if (isset($query['task'])) {
|
||||
$segments[] = $query['task'];
|
||||
unset($query['task']);
|
||||
}
|
||||
|
||||
if (isset($query['id'])) {
|
||||
$segments[] = $query['id'];
|
||||
unset($query['id']);
|
||||
}
|
||||
|
||||
$total = \count($segments);
|
||||
|
||||
for ($i = 0; $i < $total; $i++) {
|
||||
$segments[$i] = str_replace(':', '-', $segments[$i]);
|
||||
}
|
||||
|
||||
return $segments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the segments of a URL.
|
||||
*
|
||||
* @param array $segments The segments of the URL to parse.
|
||||
*
|
||||
* @return array The URL attributes to be used by the application.
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public function parse(&$segments)
|
||||
{
|
||||
$total = \count($segments);
|
||||
$vars = [];
|
||||
|
||||
for ($i = 0; $i < $total; $i++) {
|
||||
$segments[$i] = preg_replace('/-/', ':', $segments[$i], 1);
|
||||
}
|
||||
|
||||
// View is always the first element of the array
|
||||
$count = \count($segments);
|
||||
|
||||
if ($count) {
|
||||
$count--;
|
||||
$segment = array_shift($segments);
|
||||
|
||||
if (is_numeric($segment)) {
|
||||
$vars['id'] = $segment;
|
||||
} else {
|
||||
$vars['task'] = $segment;
|
||||
}
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$segment = array_shift($segments);
|
||||
|
||||
if (is_numeric($segment)) {
|
||||
$vars['id'] = $segment;
|
||||
}
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
121
components/com_config/forms/config.xml
Normal file
121
components/com_config/forms/config.xml
Normal file
@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fieldset
|
||||
name="metadata"
|
||||
label="COM_CONFIG_METADATA_SETTINGS">
|
||||
<field
|
||||
name="MetaDesc"
|
||||
type="textarea"
|
||||
label="COM_CONFIG_FIELD_METADESC_LABEL"
|
||||
filter="string"
|
||||
rows="3"
|
||||
cols="30"
|
||||
maxlength="300"
|
||||
charcounter="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="MetaRights"
|
||||
type="textarea"
|
||||
label="JFIELD_META_RIGHTS_LABEL"
|
||||
description="JFIELD_META_RIGHTS_DESC"
|
||||
filter="string"
|
||||
cols="60"
|
||||
rows="2"
|
||||
/>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="seo"
|
||||
label="CONFIG_SEO_SETTINGS_LABEL">
|
||||
<field
|
||||
name="sef"
|
||||
type="radio"
|
||||
label="COM_CONFIG_FIELD_SEF_URL_LABEL"
|
||||
description="COM_CONFIG_FIELD_SEF_URL_DESC"
|
||||
default="1"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="sitename_pagetitles"
|
||||
type="list"
|
||||
label="COM_CONFIG_FIELD_SITENAME_PAGETITLES_LABEL"
|
||||
default="0"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="2">COM_CONFIG_FIELD_VALUE_AFTER</option>
|
||||
<option value="1">COM_CONFIG_FIELD_VALUE_BEFORE</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="site"
|
||||
label="CONFIG_SITE_SETTINGS_LABEL">
|
||||
|
||||
<field
|
||||
name="sitename"
|
||||
type="text"
|
||||
label="COM_CONFIG_FIELD_SITE_NAME_LABEL"
|
||||
required="true"
|
||||
filter="string"
|
||||
size="50"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="offline"
|
||||
type="radio"
|
||||
label="COM_CONFIG_FIELD_SITE_OFFLINE_LABEL"
|
||||
default="0"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="COM_CONFIG_FIELD_DEFAULT_ACCESS_LEVEL_LABEL"
|
||||
description="COM_CONFIG_FIELD_DEFAULT_ACCESS_LEVEL_DESC"
|
||||
default="1"
|
||||
filter="UINT"
|
||||
validate="options"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="list_limit"
|
||||
type="list"
|
||||
label="COM_CONFIG_FIELD_DEFAULT_LIST_LIMIT_LABEL"
|
||||
default="20"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="5">J5</option>
|
||||
<option value="10">J10</option>
|
||||
<option value="15">J15</option>
|
||||
<option value="20">J20</option>
|
||||
<option value="25">J25</option>
|
||||
<option value="30">J30</option>
|
||||
<option value="50">J50</option>
|
||||
<option value="100">J100</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<field
|
||||
name="asset_id"
|
||||
type="hidden"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
||||
136
components/com_config/forms/modules.xml
Normal file
136
components/com_config/forms/modules.xml
Normal file
@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="id"
|
||||
type="number"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="title"
|
||||
type="text"
|
||||
label="JGLOBAL_TITLE"
|
||||
maxlength="100"
|
||||
required="true"
|
||||
size="35"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="note"
|
||||
type="text"
|
||||
label="COM_MODULES_FIELD_NOTE_LABEL"
|
||||
maxlength="255"
|
||||
size="35"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="module"
|
||||
type="hidden"
|
||||
label="COM_MODULES_FIELD_MODULE_LABEL"
|
||||
readonly="readonly"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="showtitle"
|
||||
type="radio"
|
||||
label="COM_MODULES_FIELD_SHOWTITLE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
size="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="published"
|
||||
type="list"
|
||||
label="JSTATUS"
|
||||
class="form-select-color-state"
|
||||
default="1"
|
||||
size="1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JPUBLISHED</option>
|
||||
<option value="0">JUNPUBLISHED</option>
|
||||
<option value="-2">JTRASHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="publish_up"
|
||||
type="calendar"
|
||||
label="COM_MODULES_FIELD_PUBLISH_UP_LABEL"
|
||||
filter="user_utc"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
size="22"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_down"
|
||||
type="calendar"
|
||||
label="COM_MODULES_FIELD_PUBLISH_DOWN_LABEL"
|
||||
filter="user_utc"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
size="22"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="client_id"
|
||||
type="hidden"
|
||||
label="COM_MODULES_FIELD_CLIENT_ID_LABEL"
|
||||
readonly="true"
|
||||
size="1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="position"
|
||||
type="ModulesPositionedit"
|
||||
label="COM_MODULES_FIELD_POSITION_LABEL"
|
||||
addfieldprefix="Joomla\Component\Modules\Administrator\Field"
|
||||
default=""
|
||||
maxlength="50"
|
||||
client="site"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
filter="UINT"
|
||||
validate="options"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="ordering"
|
||||
type="moduleorder"
|
||||
label="JFIELD_ORDERING_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="content"
|
||||
type="editor"
|
||||
label="COM_MODULES_FIELD_CONTENT_LABEL"
|
||||
buttons="true"
|
||||
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
hide="readmore,pagebreak"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field name="assignment" type="hidden" />
|
||||
|
||||
<field name="assigned" type="hidden" />
|
||||
</fieldset>
|
||||
</form>
|
||||
47
components/com_config/forms/modules_advanced.xml
Normal file
47
components/com_config/forms/modules_advanced.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="params">
|
||||
<fieldset
|
||||
name="advanced">
|
||||
|
||||
<field
|
||||
name="module_tag"
|
||||
type="moduletag"
|
||||
label="COM_MODULES_FIELD_MODULE_TAG_LABEL"
|
||||
default="div"
|
||||
validate="options"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="bootstrap_size"
|
||||
type="integer"
|
||||
label="COM_MODULES_FIELD_BOOTSTRAP_SIZE_LABEL"
|
||||
first="0"
|
||||
last="12"
|
||||
step="1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="header_tag"
|
||||
type="headertag"
|
||||
label="COM_MODULES_FIELD_HEADER_TAG_LABEL"
|
||||
default="h3"
|
||||
validate="options"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="header_class"
|
||||
type="textarea"
|
||||
label="COM_MODULES_FIELD_HEADER_CLASS_LABEL"
|
||||
rows="3"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="style"
|
||||
type="chromestyle"
|
||||
label="COM_MODULES_FIELD_MODULE_STYLE_LABEL"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
42
components/com_config/forms/templates.xml
Normal file
42
components/com_config/forms/templates.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="id"
|
||||
type="number"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
default="0"
|
||||
readonly="true"
|
||||
class="readonly"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="template"
|
||||
type="text"
|
||||
label="COM_TEMPLATES_FIELD_TEMPLATE_LABEL"
|
||||
class="readonly"
|
||||
size="30"
|
||||
readonly="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="client_id"
|
||||
type="hidden"
|
||||
label="COM_TEMPLATES_FIELD_CLIENT_LABEL"
|
||||
class="readonly"
|
||||
default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="title"
|
||||
type="text"
|
||||
label="COM_TEMPLATES_FIELD_TITLE_LABEL"
|
||||
size="50"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field name="assigned" type="hidden" />
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
141
components/com_config/src/Controller/ConfigController.php
Normal file
141
components/com_config/src/Controller/ConfigController.php
Normal file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Controller;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Client\ClientHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Component Controller
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class ConfigController extends BaseController
|
||||
{
|
||||
/**
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* Recognized key values include 'name', 'default_task', 'model_path', and
|
||||
* 'view_path' (this list is not meant to be comprehensive).
|
||||
* @param MVCFactoryInterface|null $factory The factory.
|
||||
* @param CMSApplication|null $app The JApplication for the dispatcher
|
||||
* @param \Joomla\CMS\Input\Input|null $input The Input object for the request
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
|
||||
$this->registerTask('apply', 'save');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to handle cancel
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
// Redirect back to home(base) page
|
||||
$this->setRedirect(Uri::base());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save global configuration.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
$this->checkToken();
|
||||
|
||||
// Check if the user is authorized to do this.
|
||||
if (!$this->app->getIdentity()->authorise('core.admin')) {
|
||||
$this->app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'));
|
||||
$this->app->redirect('index.php');
|
||||
}
|
||||
|
||||
// Set FTP credentials, if given.
|
||||
ClientHelper::setCredentialsFromRequest('ftp');
|
||||
|
||||
$model = $this->getModel();
|
||||
|
||||
$form = $model->getForm();
|
||||
$data = $this->app->getInput()->post->get('jform', [], 'array');
|
||||
|
||||
// Validate the posted data.
|
||||
$return = $model->validate($form, $data);
|
||||
|
||||
// Check for validation errors.
|
||||
if ($return === false) {
|
||||
/*
|
||||
* The validate method enqueued all messages for us, so we just need to redirect back.
|
||||
*/
|
||||
|
||||
// Save the data in the session.
|
||||
$this->app->setUserState('com_config.config.global.data', $data);
|
||||
|
||||
// Redirect back to the edit screen.
|
||||
$this->app->redirect(Route::_('index.php?option=com_config&view=config', false));
|
||||
}
|
||||
|
||||
// Attempt to save the configuration.
|
||||
$data = $return;
|
||||
|
||||
// Access backend com_config
|
||||
$saveClass = $this->factory->createController('Application', 'Administrator', [], $this->app, $this->input);
|
||||
|
||||
// Get a document object
|
||||
$document = $this->app->getDocument();
|
||||
|
||||
// Set backend required params
|
||||
$document->setType('json');
|
||||
|
||||
// Execute backend controller
|
||||
$return = $saveClass->save();
|
||||
|
||||
// Reset params back after requesting from service
|
||||
$document->setType('html');
|
||||
|
||||
// Check the return value.
|
||||
if ($return === false) {
|
||||
/*
|
||||
* The save method enqueued all messages for us, so we just need to redirect back.
|
||||
*/
|
||||
|
||||
// Save the data in the session.
|
||||
$this->app->setUserState('com_config.config.global.data', $data);
|
||||
|
||||
// Save failed, go back to the screen and display a notice.
|
||||
$this->app->redirect(Route::_('index.php?option=com_config&view=config', false));
|
||||
}
|
||||
|
||||
// Redirect back to com_config display
|
||||
$this->app->enqueueMessage(Text::_('COM_CONFIG_SAVE_SUCCESS'));
|
||||
$this->app->redirect(Route::_('index.php?option=com_config&view=config', false));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
39
components/com_config/src/Controller/DisplayController.php
Normal file
39
components/com_config/src/Controller/DisplayController.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Controller;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Component Controller
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Method to handle cancel
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
// Redirect back to home(base) page
|
||||
$this->setRedirect(Uri::base());
|
||||
}
|
||||
}
|
||||
168
components/com_config/src/Controller/ModulesController.php
Normal file
168
components/com_config/src/Controller/ModulesController.php
Normal file
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Controller;
|
||||
|
||||
use Joomla\CMS\Application\AdministratorApplication;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Client\ClientHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\Component\Modules\Administrator\Controller\ModuleController;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Component Controller
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class ModulesController extends BaseController
|
||||
{
|
||||
/**
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* Recognized key values include 'name', 'default_task', 'model_path', and
|
||||
* 'view_path' (this list is not meant to be comprehensive).
|
||||
* @param MVCFactoryInterface|null $factory The factory.
|
||||
* @param CMSApplication|null $app The Application for the dispatcher
|
||||
* @param \Joomla\CMS\Input\Input|null $input The Input object for the request
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
|
||||
$this->registerTask('apply', 'save');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to handle cancel
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
// Redirect back to home(base) page
|
||||
$this->setRedirect(Uri::base());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save module editing.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
$this->checkToken();
|
||||
|
||||
// Check if the user is authorized to do this.
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
if (!$user->authorise('module.edit.frontend', 'com_modules.module.' . $this->input->get('id'))) {
|
||||
$this->app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error');
|
||||
$this->app->redirect('index.php');
|
||||
}
|
||||
|
||||
// Set FTP credentials, if given.
|
||||
ClientHelper::setCredentialsFromRequest('ftp');
|
||||
|
||||
// Get submitted module id
|
||||
$moduleId = '&id=' . $this->input->getInt('id');
|
||||
|
||||
// Get returnUri
|
||||
$returnUri = $this->input->post->get('return', null, 'base64');
|
||||
$redirect = '';
|
||||
|
||||
if (!empty($returnUri)) {
|
||||
$redirect = '&return=' . $returnUri;
|
||||
}
|
||||
|
||||
/** @var AdministratorApplication $app */
|
||||
$app = Factory::getContainer()->get(AdministratorApplication::class);
|
||||
|
||||
// Reset Uri cache.
|
||||
Uri::reset();
|
||||
|
||||
// Get a document object
|
||||
$document = $this->app->getDocument();
|
||||
|
||||
// Load application dependencies.
|
||||
$app->loadLanguage($this->app->getLanguage());
|
||||
$app->loadDocument($document);
|
||||
$app->loadIdentity($user);
|
||||
|
||||
/** @var \Joomla\CMS\Dispatcher\ComponentDispatcher $dispatcher */
|
||||
$dispatcher = $app->bootComponent('com_modules')->getDispatcher($app);
|
||||
|
||||
/** @var ModuleController $controllerClass */
|
||||
$controllerClass = $dispatcher->getController('Module');
|
||||
|
||||
// Set backend required params
|
||||
$document->setType('json');
|
||||
|
||||
// Execute backend controller
|
||||
Form::addFormPath(JPATH_ADMINISTRATOR . '/components/com_modules/forms');
|
||||
$return = $controllerClass->save();
|
||||
|
||||
// Reset params back after requesting from service
|
||||
$document->setType('html');
|
||||
|
||||
// Check the return value.
|
||||
if ($return === false) {
|
||||
// Save the data in the session.
|
||||
$data = $this->input->post->get('jform', [], 'array');
|
||||
|
||||
$this->app->setUserState('com_config.modules.global.data', $data);
|
||||
|
||||
// Save failed, go back to the screen and display a notice.
|
||||
$this->app->enqueueMessage(Text::_('JERROR_SAVE_FAILED'));
|
||||
$this->app->redirect(Route::_('index.php?option=com_config&view=modules' . $moduleId . $redirect, false));
|
||||
}
|
||||
|
||||
// Redirect back to com_config display
|
||||
$this->app->enqueueMessage(Text::_('COM_CONFIG_MODULES_SAVE_SUCCESS'), 'success');
|
||||
|
||||
// Set the redirect based on the task.
|
||||
switch ($this->input->getCmd('task')) {
|
||||
case 'apply':
|
||||
$this->app->redirect(Route::_('index.php?option=com_config&view=modules' . $moduleId . $redirect, false));
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
default:
|
||||
if (!empty($returnUri)) {
|
||||
$redirect = base64_decode(urldecode($returnUri));
|
||||
|
||||
// Don't redirect to an external URL.
|
||||
if (!Uri::isInternal($redirect)) {
|
||||
$redirect = Uri::base();
|
||||
}
|
||||
} else {
|
||||
$redirect = Uri::base();
|
||||
}
|
||||
|
||||
$this->setRedirect($redirect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
121
components/com_config/src/Controller/TemplatesController.php
Normal file
121
components/com_config/src/Controller/TemplatesController.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Controller;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Client\ClientHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Component Controller
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class TemplatesController extends BaseController
|
||||
{
|
||||
/**
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* Recognized key values include 'name', 'default_task', 'model_path', and
|
||||
* 'view_path' (this list is not meant to be comprehensive).
|
||||
* @param MVCFactoryInterface|null $factory The factory.
|
||||
* @param CMSApplication|null $app The Application for the dispatcher
|
||||
* @param \Joomla\CMS\Input\Input|null $input The Input object for the request
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
|
||||
// Apply, Save & New, and Save As copy should be standard on forms.
|
||||
$this->registerTask('apply', 'save');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to handle cancel
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
// Redirect back to home(base) page
|
||||
$this->setRedirect(Uri::base());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save global configuration.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
$this->checkToken();
|
||||
|
||||
// Check if the user is authorized to do this.
|
||||
if (!$this->app->getIdentity()->authorise('core.admin')) {
|
||||
$this->setRedirect('index.php', Text::_('JERROR_ALERTNOAUTHOR'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set FTP credentials, if given.
|
||||
ClientHelper::setCredentialsFromRequest('ftp');
|
||||
|
||||
$app = $this->app;
|
||||
|
||||
// Access backend com_templates
|
||||
$controllerClass = $app->bootComponent('com_templates')
|
||||
->getMVCFactory()->createController('Style', 'Administrator', [], $app, $app->getInput());
|
||||
|
||||
// Get a document object
|
||||
$document = $app->getDocument();
|
||||
|
||||
// Set backend required params
|
||||
$document->setType('json');
|
||||
$this->input->set('id', $app->getTemplate(true)->id);
|
||||
|
||||
// Execute backend controller
|
||||
$return = $controllerClass->save();
|
||||
|
||||
// Reset params back after requesting from service
|
||||
$document->setType('html');
|
||||
|
||||
// Check the return value.
|
||||
if ($return === false) {
|
||||
// Save failed, go back to the screen and display a notice.
|
||||
$this->setMessage(Text::sprintf('JERROR_SAVE_FAILED'), 'error');
|
||||
$this->setRedirect(Route::_('index.php?option=com_config&view=templates', false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the success message.
|
||||
$this->setMessage(Text::_('COM_CONFIG_SAVE_SUCCESS'));
|
||||
|
||||
// Redirect back to com_config display
|
||||
$this->setRedirect(Route::_('index.php?option=com_config&view=templates', false));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
52
components/com_config/src/Dispatcher/Dispatcher.php
Normal file
52
components/com_config/src/Dispatcher/Dispatcher.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Dispatcher;
|
||||
|
||||
use Joomla\CMS\Access\Exception\NotAllowed;
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcher;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* ComponentDispatcher class for com_config
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class Dispatcher extends ComponentDispatcher
|
||||
{
|
||||
/**
|
||||
* Method to check component access permission
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception|NotAllowed
|
||||
*/
|
||||
protected function checkAccess()
|
||||
{
|
||||
parent::checkAccess();
|
||||
|
||||
$task = $this->input->getCmd('task', 'display');
|
||||
$view = $this->input->get('view');
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
if (substr($task, 0, 8) === 'modules.' || $view === 'modules') {
|
||||
if (!$user->authorise('module.edit.frontend', 'com_modules.module.' . $this->input->get('id'))) {
|
||||
throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
|
||||
}
|
||||
} elseif (!$user->authorise('core.admin')) {
|
||||
throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
components/com_config/src/Model/ConfigModel.php
Normal file
45
components/com_config/src/Model/ConfigModel.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Model;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Model for the global configuration
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
class ConfigModel extends FormModel
|
||||
{
|
||||
/**
|
||||
* Method to get a form object.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return mixed A JForm object on success, false on failure
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_config.config', 'config', ['control' => 'jform', 'load_data' => $loadData]);
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
271
components/com_config/src/Model/FormModel.php
Normal file
271
components/com_config/src/Model/FormModel.php
Normal file
@ -0,0 +1,271 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Model\FormModel as BaseForm;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Prototype form model.
|
||||
*
|
||||
* @see JForm
|
||||
* @see \Joomla\CMS\Form\FormField
|
||||
* @see \Joomla\CMS\Form\FormRule
|
||||
* @since 3.2
|
||||
*/
|
||||
abstract class FormModel extends BaseForm
|
||||
{
|
||||
/**
|
||||
* Array of form objects.
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $forms = [];
|
||||
|
||||
/**
|
||||
* Method to checkin a row.
|
||||
*
|
||||
* @param integer $pk The numeric id of the primary key.
|
||||
*
|
||||
* @return boolean False on failure or error, true otherwise.
|
||||
*
|
||||
* @since 3.2
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function checkin($pk = null)
|
||||
{
|
||||
// Only attempt to check the row in if it exists.
|
||||
if ($pk) {
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
// Get an instance of the row to checkin.
|
||||
$table = $this->getTable();
|
||||
|
||||
if (!$table->load($pk)) {
|
||||
throw new \RuntimeException($table->getError());
|
||||
}
|
||||
|
||||
// Check if this is the user has previously checked out the row.
|
||||
if (!\is_null($table->checked_out) && $table->checked_out != $user->get('id') && !$user->authorise('core.admin', 'com_checkin')) {
|
||||
throw new \RuntimeException($table->getError());
|
||||
}
|
||||
|
||||
// Attempt to check the row in.
|
||||
if (!$table->checkIn($pk)) {
|
||||
throw new \RuntimeException($table->getError());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check-out a row for editing.
|
||||
*
|
||||
* @param integer $pk The numeric id of the primary key.
|
||||
*
|
||||
* @return boolean False on failure or error, true otherwise.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function checkout($pk = null)
|
||||
{
|
||||
// Only attempt to check the row in if it exists.
|
||||
if ($pk) {
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
// Get an instance of the row to checkout.
|
||||
$table = $this->getTable();
|
||||
|
||||
if (!$table->load($pk)) {
|
||||
throw new \RuntimeException($table->getError());
|
||||
}
|
||||
|
||||
// Check if this is the user having previously checked out the row.
|
||||
if (!\is_null($table->checked_out) && $table->checked_out != $user->get('id')) {
|
||||
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_CHECKOUT_USER_MISMATCH'));
|
||||
}
|
||||
|
||||
// Attempt to check the row out.
|
||||
if (!$table->checkOut($user->get('id'), $pk)) {
|
||||
throw new \RuntimeException($table->getError());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a form object.
|
||||
*
|
||||
* @param string $name The name of the form.
|
||||
* @param string $source The form source. Can be XML string if file flag is set to false.
|
||||
* @param array $options Optional array of options for the form creation.
|
||||
* @param boolean $clear Optional argument to force load a new form.
|
||||
* @param string $xpath An optional xpath to search for the fields.
|
||||
*
|
||||
* @return mixed JForm object on success, False on error.
|
||||
*
|
||||
* @see JForm
|
||||
* @since 3.2
|
||||
*/
|
||||
protected function loadForm($name, $source = null, $options = [], $clear = false, $xpath = false)
|
||||
{
|
||||
// Handle the optional arguments.
|
||||
$options['control'] = ArrayHelper::getValue($options, 'control', false);
|
||||
|
||||
// Create a signature hash.
|
||||
$hash = sha1($source . serialize($options));
|
||||
|
||||
// Check if we can use a previously loaded form.
|
||||
if (isset($this->_forms[$hash]) && !$clear) {
|
||||
return $this->_forms[$hash];
|
||||
}
|
||||
|
||||
// Register the paths for the form.
|
||||
Form::addFormPath(JPATH_SITE . '/components/com_config/forms');
|
||||
Form::addFormPath(JPATH_ADMINISTRATOR . '/components/com_config/forms');
|
||||
|
||||
try {
|
||||
// Get the form.
|
||||
$form = Form::getInstance($name, $source, $options, false, $xpath);
|
||||
|
||||
if (isset($options['load_data']) && $options['load_data']) {
|
||||
// Get the data for the form.
|
||||
$data = $this->loadFormData();
|
||||
} else {
|
||||
$data = [];
|
||||
}
|
||||
|
||||
// Allow for additional modification of the form, and events to be triggered.
|
||||
// We pass the data because plugins may require it.
|
||||
$this->preprocessForm($form, $data);
|
||||
|
||||
// Load the data into the form after the plugins have operated.
|
||||
$form->bind($data);
|
||||
} catch (\Exception $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the form for later.
|
||||
$this->_forms[$hash] = $form;
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* @return array The default data is an empty array.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to allow derived classes to preprocess the data.
|
||||
*
|
||||
* @param string $context The context identifier.
|
||||
* @param mixed &$data The data to be processed. It gets altered directly.
|
||||
* @param string $group The name of the plugin group to import (defaults to "content").
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
protected function preprocessData($context, &$data, $group = 'content')
|
||||
{
|
||||
// Get the dispatcher and load the users plugins.
|
||||
PluginHelper::importPlugin('content');
|
||||
|
||||
// Trigger the data preparation event.
|
||||
Factory::getApplication()->triggerEvent('onContentPrepareData', [$context, $data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to allow derived classes to preprocess the form.
|
||||
*
|
||||
* @param Form $form A Form object.
|
||||
* @param mixed $data The data expected for the form.
|
||||
* @param string $group The name of the plugin group to import (defaults to "content").
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @see \Joomla\CMS\Form\FormField
|
||||
* @since 3.2
|
||||
* @throws \Exception if there is an error in the form event.
|
||||
*/
|
||||
protected function preprocessForm(Form $form, $data, $group = 'content')
|
||||
{
|
||||
// Import the appropriate plugin group.
|
||||
PluginHelper::importPlugin($group);
|
||||
|
||||
// Trigger the form preparation event.
|
||||
Factory::getApplication()->triggerEvent('onContentPrepareForm', [$form, $data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to validate the form data.
|
||||
*
|
||||
* @param Form $form The form to validate against.
|
||||
* @param array $data The data to validate.
|
||||
* @param string $group The name of the field group to validate.
|
||||
*
|
||||
* @return mixed Array of filtered data if valid, false otherwise.
|
||||
*
|
||||
* @see \Joomla\CMS\Form\FormRule
|
||||
* @see \Joomla\CMS\Filter\InputFilter
|
||||
* @since 3.2
|
||||
*/
|
||||
public function validate($form, $data, $group = null)
|
||||
{
|
||||
// Filter and validate the form data.
|
||||
$data = $form->filter($data);
|
||||
$return = $form->validate($data, $group);
|
||||
|
||||
// Check for an error.
|
||||
if ($return instanceof \Exception) {
|
||||
Factory::getApplication()->enqueueMessage($return->getMessage(), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the validation results.
|
||||
if ($return === false) {
|
||||
// Get the validation messages from the form.
|
||||
foreach ($form->getErrors() as $message) {
|
||||
if ($message instanceof \Exception) {
|
||||
$message = $message->getMessage();
|
||||
}
|
||||
|
||||
Factory::getApplication()->enqueueMessage($message, 'error');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
253
components/com_config/src/Model/ModulesModel.php
Normal file
253
components/com_config/src/Model/ModulesModel.php
Normal file
@ -0,0 +1,253 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Filesystem\Path;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Config Module model.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
class ModulesModel extends FormModel
|
||||
{
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Load the User state.
|
||||
$pk = $app->getInput()->getInt('id');
|
||||
|
||||
$this->setState('module.id', $pk);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return Form A Form object on success, false on failure
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_config.modules', 'modules', ['control' => 'jform', 'load_data' => $loadData]);
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to preprocess the form
|
||||
*
|
||||
* @param Form $form A form object.
|
||||
* @param mixed $data The data expected for the form.
|
||||
* @param string $group The name of the plugin group to import (defaults to "content").
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
* @throws \Exception if there is an error loading the form.
|
||||
*/
|
||||
protected function preprocessForm(Form $form, $data, $group = 'content')
|
||||
{
|
||||
$lang = Factory::getLanguage();
|
||||
$module = $this->getState()->get('module.name');
|
||||
$basePath = JPATH_BASE;
|
||||
|
||||
$formFile = Path::clean($basePath . '/modules/' . $module . '/' . $module . '.xml');
|
||||
|
||||
// Load the core and/or local language file(s).
|
||||
$lang->load($module, $basePath)
|
||||
|| $lang->load($module, $basePath . '/modules/' . $module);
|
||||
|
||||
if (file_exists($formFile)) {
|
||||
// Get the module form.
|
||||
if (!$form->loadFile($formFile, false, '//config')) {
|
||||
throw new \Exception(Text::_('JERROR_LOADFILE_FAILED'));
|
||||
}
|
||||
|
||||
// Attempt to load the xml file.
|
||||
if (!$xml = simplexml_load_file($formFile)) {
|
||||
throw new \Exception(Text::_('JERROR_LOADFILE_FAILED'));
|
||||
}
|
||||
}
|
||||
|
||||
// Load the default advanced params
|
||||
Form::addFormPath(JPATH_BASE . '/components/com_config/model/form');
|
||||
$form->loadFile('modules_advanced', false);
|
||||
|
||||
// Trigger the default form events.
|
||||
parent::preprocessForm($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list of module positions in current template
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function getPositions()
|
||||
{
|
||||
$lang = Factory::getLanguage();
|
||||
$templateName = Factory::getApplication()->getTemplate();
|
||||
|
||||
// Load templateDetails.xml file
|
||||
$path = Path::clean(JPATH_BASE . '/templates/' . $templateName . '/templateDetails.xml');
|
||||
$currentTemplatePositions = [];
|
||||
|
||||
if (file_exists($path)) {
|
||||
$xml = simplexml_load_file($path);
|
||||
|
||||
if (isset($xml->positions[0])) {
|
||||
// Load language files
|
||||
$lang->load('tpl_' . $templateName . '.sys', JPATH_BASE)
|
||||
|| $lang->load('tpl_' . $templateName . '.sys', JPATH_BASE . '/templates/' . $templateName);
|
||||
|
||||
foreach ($xml->positions[0] as $position) {
|
||||
$value = (string) $position;
|
||||
$text = preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'TPL_' . strtoupper($templateName) . '_POSITION_' . strtoupper($value));
|
||||
|
||||
// Construct list of positions
|
||||
$currentTemplatePositions[] = self::createOption($value, Text::_($text) . ' [' . $value . ']');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$templateGroups = [];
|
||||
|
||||
// Add an empty value to be able to deselect a module position
|
||||
$option = self::createOption();
|
||||
$templateGroups[''] = self::createOptionGroup('', [$option]);
|
||||
|
||||
$templateGroups[$templateName] = self::createOptionGroup($templateName, $currentTemplatePositions);
|
||||
|
||||
// Add custom position to options
|
||||
$customGroupText = Text::_('COM_MODULES_CUSTOM_POSITION');
|
||||
|
||||
$editPositions = true;
|
||||
$customPositions = self::getActivePositions(0, $editPositions);
|
||||
$templateGroups[$customGroupText] = self::createOptionGroup($customGroupText, $customPositions);
|
||||
|
||||
return $templateGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of modules positions
|
||||
*
|
||||
* @param integer $clientId Client ID
|
||||
* @param boolean $editPositions Allow to edit the positions
|
||||
*
|
||||
* @return array A list of positions
|
||||
*
|
||||
* @since 3.6.3
|
||||
*/
|
||||
public static function getActivePositions($clientId, $editPositions = false)
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('DISTINCT position')
|
||||
->from($db->quoteName('#__modules'))
|
||||
->where($db->quoteName('client_id') . ' = ' . (int) $clientId)
|
||||
->order($db->quoteName('position'));
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$positions = $db->loadColumn();
|
||||
$positions = \is_array($positions) ? $positions : [];
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Build the list
|
||||
$options = [];
|
||||
|
||||
foreach ($positions as $position) {
|
||||
if (!$position && !$editPositions) {
|
||||
$options[] = HTMLHelper::_('select.option', 'none', ':: ' . Text::_('JNONE') . ' ::');
|
||||
} else {
|
||||
$options[] = HTMLHelper::_('select.option', $position, $position);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a new Option
|
||||
*
|
||||
* @param string $value The option value [optional]
|
||||
* @param string $text The option text [optional]
|
||||
*
|
||||
* @return object The option as an object (stdClass instance)
|
||||
*
|
||||
* @since 3.6.3
|
||||
*/
|
||||
private static function createOption($value = '', $text = '')
|
||||
{
|
||||
if (empty($text)) {
|
||||
$text = $value;
|
||||
}
|
||||
|
||||
$option = new \stdClass();
|
||||
$option->value = $value;
|
||||
$option->text = $text;
|
||||
|
||||
return $option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a new Option Group
|
||||
*
|
||||
* @param string $label Value and label for group [optional]
|
||||
* @param array $options Array of options to insert into group [optional]
|
||||
*
|
||||
* @return array Return the new group as an array
|
||||
*
|
||||
* @since 3.6.3
|
||||
*/
|
||||
private static function createOptionGroup($label = '', $options = [])
|
||||
{
|
||||
$group = [];
|
||||
$group['value'] = $label;
|
||||
$group['text'] = $label;
|
||||
$group['items'] = $options;
|
||||
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
123
components/com_config/src/Model/TemplatesModel.php
Normal file
123
components/com_config/src/Model/TemplatesModel.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Model;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Filesystem\Path;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Template style model.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
class TemplatesModel extends FormModel
|
||||
{
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @return null
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
parent::populateState();
|
||||
|
||||
$this->setState('params', ComponentHelper::getParams('com_templates'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data An optional array of data for the form to interrogate.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return Form|bool A JForm object on success, false on failure
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
try {
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_config.templates', 'templates', ['load_data' => $loadData]);
|
||||
|
||||
$data = [];
|
||||
$this->preprocessForm($form, $data);
|
||||
|
||||
// Load the data into the form
|
||||
$form->bind($data);
|
||||
} catch (\Exception $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to preprocess the form
|
||||
*
|
||||
* @param Form $form A form object.
|
||||
* @param mixed $data The data expected for the form.
|
||||
* @param string $group Plugin group to load
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
* @throws \Exception if there is an error in the form event.
|
||||
*/
|
||||
protected function preprocessForm(Form $form, $data, $group = 'content')
|
||||
{
|
||||
$lang = Factory::getLanguage();
|
||||
|
||||
$template = Factory::getApplication()->getTemplate();
|
||||
|
||||
// Load the core and/or local language file(s).
|
||||
$lang->load('tpl_' . $template, JPATH_BASE)
|
||||
|| $lang->load('tpl_' . $template, JPATH_BASE . '/templates/' . $template);
|
||||
|
||||
// Look for com_config.xml, which contains fields to display
|
||||
$formFile = Path::clean(JPATH_BASE . '/templates/' . $template . '/com_config.xml');
|
||||
|
||||
if (!file_exists($formFile)) {
|
||||
// If com_config.xml not found, fall back to templateDetails.xml
|
||||
$formFile = Path::clean(JPATH_BASE . '/templates/' . $template . '/templateDetails.xml');
|
||||
}
|
||||
|
||||
// Get the template form.
|
||||
if (file_exists($formFile) && !$form->loadFile($formFile, false, '//config')) {
|
||||
throw new \Exception(Text::_('JERROR_LOADFILE_FAILED'));
|
||||
}
|
||||
|
||||
// Attempt to load the xml file.
|
||||
if (!$xml = simplexml_load_file($formFile)) {
|
||||
throw new \Exception(Text::_('JERROR_LOADFILE_FAILED'));
|
||||
}
|
||||
|
||||
// Trigger the default form events.
|
||||
parent::preprocessForm($form, $data, $group);
|
||||
}
|
||||
}
|
||||
49
components/com_config/src/Service/Router.php
Normal file
49
components/com_config/src/Service/Router.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\Service;
|
||||
|
||||
use Joomla\CMS\Application\SiteApplication;
|
||||
use Joomla\CMS\Component\Router\RouterView;
|
||||
use Joomla\CMS\Component\Router\RouterViewConfiguration;
|
||||
use Joomla\CMS\Component\Router\Rules\MenuRules;
|
||||
use Joomla\CMS\Component\Router\Rules\NomenuRules;
|
||||
use Joomla\CMS\Component\Router\Rules\StandardRules;
|
||||
use Joomla\CMS\Menu\AbstractMenu;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Routing class from com_config
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class Router extends RouterView
|
||||
{
|
||||
/**
|
||||
* Config Component router constructor
|
||||
*
|
||||
* @param SiteApplication $app The application object
|
||||
* @param AbstractMenu $menu The menu object to work with
|
||||
*/
|
||||
public function __construct(SiteApplication $app, AbstractMenu $menu)
|
||||
{
|
||||
$this->registerView(new RouterViewConfiguration('config'));
|
||||
$this->registerView(new RouterViewConfiguration('templates'));
|
||||
|
||||
parent::__construct($app, $menu);
|
||||
|
||||
$this->attachRule(new MenuRules($this));
|
||||
$this->attachRule(new StandardRules($this));
|
||||
$this->attachRule(new NomenuRules($this));
|
||||
}
|
||||
}
|
||||
135
components/com_config/src/View/Config/HtmlView.php
Normal file
135
components/com_config/src/View/Config/HtmlView.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\View\Config;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\Component\Config\Administrator\Controller\RequestController;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View for the global configuration
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The form object
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public $form;
|
||||
|
||||
/**
|
||||
* The data to be displayed in the form
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Is the current user a super administrator?
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $userIsSuperAdmin;
|
||||
|
||||
/**
|
||||
* The page class suffix
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $pageclass_sfx = '';
|
||||
|
||||
/**
|
||||
* The page parameters
|
||||
*
|
||||
* @var \Joomla\Registry\Registry|null
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $params = null;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
$this->userIsSuperAdmin = $user->authorise('core.admin');
|
||||
|
||||
// Access backend com_config
|
||||
$requestController = new RequestController();
|
||||
|
||||
// Execute backend controller
|
||||
$serviceData = json_decode($requestController->getJson(), true);
|
||||
|
||||
$form = $this->getForm();
|
||||
|
||||
if ($form) {
|
||||
$form->bind($serviceData);
|
||||
}
|
||||
|
||||
$this->form = $form;
|
||||
$this->data = $serviceData;
|
||||
|
||||
$this->_prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
$params = Factory::getApplication()->getParams();
|
||||
|
||||
// Because the application sets a default page title, we need to get it
|
||||
// right from the menu item itself
|
||||
|
||||
$this->setDocumentTitle($params->get('page_title', ''));
|
||||
|
||||
if ($params->get('menu-meta_description')) {
|
||||
$this->getDocument()->setDescription($params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($params->get('robots')) {
|
||||
$this->getDocument()->setMetaData('robots', $params->get('robots'));
|
||||
}
|
||||
|
||||
// Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx', ''));
|
||||
$this->params = &$params;
|
||||
}
|
||||
}
|
||||
100
components/com_config/src/View/Modules/HtmlView.php
Normal file
100
components/com_config/src/View/Modules/HtmlView.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\View\Modules;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View to edit a module.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The module to be rendered
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public $item;
|
||||
|
||||
/**
|
||||
* The form object
|
||||
*
|
||||
* @var Form
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public $form;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$lang = Factory::getApplication()->getLanguage();
|
||||
$lang->load('', JPATH_ADMINISTRATOR, $lang->getTag());
|
||||
$lang->load('com_modules', JPATH_ADMINISTRATOR, $lang->getTag());
|
||||
|
||||
// @todo Move and clean up
|
||||
$module = (new \Joomla\Component\Modules\Administrator\Model\ModuleModel())->getItem(Factory::getApplication()->getInput()->getInt('id'));
|
||||
|
||||
$moduleData = $module->getProperties();
|
||||
unset($moduleData['xml']);
|
||||
|
||||
/** @var \Joomla\Component\Config\Site\Model\ModulesModel $model */
|
||||
$model = $this->getModel();
|
||||
|
||||
// Need to add module name to the state of model
|
||||
$model->getState()->set('module.name', $moduleData['module']);
|
||||
|
||||
/** @var Form form */
|
||||
$this->form = $this->get('form');
|
||||
$this->positions = $this->get('positions');
|
||||
$this->item = $moduleData;
|
||||
|
||||
if ($this->form) {
|
||||
$this->form->bind($moduleData);
|
||||
}
|
||||
|
||||
$this->_prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
// There is no menu item for this so we have to use the title from the component
|
||||
$this->setDocumentTitle(Text::_('COM_CONFIG_MODULES_SETTINGS_TITLE'));
|
||||
}
|
||||
}
|
||||
158
components/com_config/src/View/Templates/HtmlView.php
Normal file
158
components/com_config/src/View/Templates/HtmlView.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Config\Site\View\Templates;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactory;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\Component\Config\Administrator\Controller\RequestController;
|
||||
use Joomla\Component\Templates\Administrator\View\Style\JsonView;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View to edit a template style.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The data to be displayed in the form
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public $item;
|
||||
|
||||
/**
|
||||
* The form object
|
||||
*
|
||||
* @var Form
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public $form;
|
||||
|
||||
/**
|
||||
* Is the current user a super administrator?
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $userIsSuperAdmin;
|
||||
|
||||
/**
|
||||
* The page class suffix
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $pageclass_sfx = '';
|
||||
|
||||
/**
|
||||
* The page parameters
|
||||
*
|
||||
* @var \Joomla\Registry\Registry|null
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $params = null;
|
||||
|
||||
/**
|
||||
* Method to render the view.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
$this->userIsSuperAdmin = $user->authorise('core.admin');
|
||||
|
||||
$app = Factory::getApplication();
|
||||
|
||||
$app->getInput()->set('id', $app->getTemplate(true)->id);
|
||||
|
||||
/** @var MVCFactory $factory */
|
||||
$factory = $app->bootComponent('com_templates')->getMVCFactory();
|
||||
|
||||
/** @var JsonView $view */
|
||||
$view = $factory->createView('Style', 'Administrator', 'Json');
|
||||
$view->setModel($factory->createModel('Style', 'Administrator'), true);
|
||||
$view->setLanguage($app->getLanguage());
|
||||
|
||||
$view->document = $this->getDocument();
|
||||
|
||||
$json = $view->display();
|
||||
|
||||
// Execute backend controller
|
||||
$serviceData = json_decode($json, true);
|
||||
|
||||
// Access backend com_config
|
||||
$requestController = new RequestController();
|
||||
|
||||
// Execute backend controller
|
||||
$configData = json_decode($requestController->getJson(), true);
|
||||
|
||||
$data = array_merge($configData, $serviceData);
|
||||
|
||||
/** @var Form $form */
|
||||
$form = $this->getForm();
|
||||
|
||||
if ($form) {
|
||||
$form->bind($data);
|
||||
}
|
||||
|
||||
$this->form = $form;
|
||||
|
||||
$this->data = $serviceData;
|
||||
|
||||
$this->_prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
$params = Factory::getApplication()->getParams();
|
||||
|
||||
// Because the application sets a default page title, we need to get it
|
||||
// right from the menu item itself
|
||||
$this->setDocumentTitle($params->get('page_title', ''));
|
||||
|
||||
if ($params->get('menu-meta_description')) {
|
||||
$this->getDocument()->setDescription($params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($params->get('robots')) {
|
||||
$this->getDocument()->setMetaData('robots', $params->get('robots'));
|
||||
}
|
||||
|
||||
// Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx', ''));
|
||||
$this->params = &$params;
|
||||
}
|
||||
}
|
||||
63
components/com_config/tmpl/config/default.php
Normal file
63
components/com_config/tmpl/config/default.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate')
|
||||
->useScript('com_config.config')
|
||||
->useScript('inlinehelp');
|
||||
|
||||
?>
|
||||
<?php if ($this->params->get('show_page_heading')) : ?>
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
<?php if ($this->escape($this->params->get('page_heading'))) : ?>
|
||||
<?php echo $this->escape($this->params->get('page_heading')); ?>
|
||||
<?php else : ?>
|
||||
<?php echo $this->escape($this->params->get('page_title')); ?>
|
||||
<?php endif; ?>
|
||||
</h1>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_config'); ?>" id="application-form" method="post" name="adminForm" class="form-validate">
|
||||
|
||||
<div class="mb-2 d-flex">
|
||||
<button type="button" class="btn btn-sm btn-outline-info button-inlinehelp ms-auto">
|
||||
<span class="fa fa-question-circle" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JINLINEHELP') ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<?php echo $this->loadTemplate('site'); ?>
|
||||
<?php echo $this->loadTemplate('seo'); ?>
|
||||
<?php echo $this->loadTemplate('metadata'); ?>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
|
||||
<div class="mb-2">
|
||||
<button type="button" class="btn btn-primary" data-submit-task="config.apply">
|
||||
<span class="icon-check" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JSAVE') ?>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger" data-submit-task="config.cancel">
|
||||
<span class="icon-times" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JCANCEL') ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
20
components/com_config/tmpl/config/default.xml
Normal file
20
components/com_config/tmpl/config/default.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<layout title="COM_CONFIG_CONFIG_VIEW_DEFAULT_TITLE" option="COM_CONFIG_CONFIG_VIEW_DEFAULT_OPTION">
|
||||
<help
|
||||
key = "Menu_Item:_Site_Configuration_Options"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[COM_CONFIG_CONFIG_VIEW_DEFAULT_DESC]]>
|
||||
</message>
|
||||
</layout>
|
||||
<fields name="request">
|
||||
<fieldset name="request">
|
||||
<field
|
||||
name="controller"
|
||||
type="hidden"
|
||||
default=""
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</metadata>
|
||||
32
components/com_config/tmpl/config/default_metadata.php
Normal file
32
components/com_config/tmpl/config/default_metadata.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
<fieldset>
|
||||
|
||||
<legend><?php echo Text::_('COM_CONFIG_METADATA_SETTINGS'); ?></legend>
|
||||
|
||||
<?php foreach ($this->form->getFieldset('metadata') as $field) : ?>
|
||||
<div class="mb-3">
|
||||
<?php echo $field->label; ?>
|
||||
<?php echo $field->input; ?>
|
||||
<?php if ($field->description) : ?>
|
||||
<div class="form-text hide-aware-inline-help d-none" id="<?php echo $field->id ?>-desc">
|
||||
<?php echo Text::_($field->description) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</fieldset>
|
||||
32
components/com_config/tmpl/config/default_seo.php
Normal file
32
components/com_config/tmpl/config/default_seo.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
<fieldset>
|
||||
|
||||
<legend><?php echo Text::_('COM_CONFIG_SEO_SETTINGS'); ?></legend>
|
||||
|
||||
<?php foreach ($this->form->getFieldset('seo') as $field) : ?>
|
||||
<div class="mb-3">
|
||||
<?php echo $field->label; ?>
|
||||
<?php echo $field->input; ?>
|
||||
<?php if ($field->description) : ?>
|
||||
<div class="form-text hide-aware-inline-help d-none" id="<?php echo $field->id ?>-desc">
|
||||
<?php echo Text::_($field->description) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</fieldset>
|
||||
32
components/com_config/tmpl/config/default_site.php
Normal file
32
components/com_config/tmpl/config/default_site.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
<fieldset>
|
||||
|
||||
<legend><?php echo Text::_('COM_CONFIG_SITE_SETTINGS'); ?></legend>
|
||||
|
||||
<?php foreach ($this->form->getFieldset('site') as $field) : ?>
|
||||
<div class="mb-3">
|
||||
<?php echo $field->label; ?>
|
||||
<?php echo $field->input; ?>
|
||||
<?php if ($field->description) : ?>
|
||||
<div class="form-text hide-aware-inline-help d-none" id="<?php echo $field->id ?>-desc">
|
||||
<?php echo Text::_($field->description) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</fieldset>
|
||||
187
components/com_config/tmpl/modules/default.php
Normal file
187
components/com_config/tmpl/modules/default.php
Normal file
@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
HTMLHelper::_('behavior.combobox');
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate')
|
||||
->useScript('com_config.modules');
|
||||
|
||||
$editorText = false;
|
||||
$moduleXml = JPATH_SITE . '/modules/' . $this->item['module'] . '/' . $this->item['module'] . '.xml';
|
||||
|
||||
if (is_file($moduleXml)) {
|
||||
$xml = simplexml_load_file($moduleXml);
|
||||
|
||||
if (isset($xml->customContent)) {
|
||||
$editorText = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If multi-language site, make language read-only
|
||||
if (Multilanguage::isEnabled()) {
|
||||
$this->form->setFieldAttribute('language', 'readonly', 'true');
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_config'); ?>" method="post" name="adminForm" id="modules-form" class="form-validate">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<legend><?php echo Text::_('COM_CONFIG_MODULES_SETTINGS_TITLE'); ?></legend>
|
||||
|
||||
<div>
|
||||
<?php echo Text::_('COM_CONFIG_MODULES_MODULE_NAME'); ?>
|
||||
<span class="badge bg-secondary"><?php echo $this->item['title']; ?></span>
|
||||
|
||||
<?php echo Text::_('COM_CONFIG_MODULES_MODULE_TYPE'); ?>
|
||||
<span class="badge bg-secondary"><?php echo $this->item['module']; ?></span>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('title'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('title'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('showtitle'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('showtitle'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('position'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('position'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<?php if ($this->getCurrentUser()->authorise('core.edit.state', 'com_modules.module.' . $this->item['id'])) : ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('published'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('published'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('publish_up'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('publish_up'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('publish_down'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('publish_down'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('access'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('access'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('ordering'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('ordering'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('language'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('language'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('note'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('note'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="options">
|
||||
<?php echo $this->loadTemplate('options'); ?>
|
||||
</div>
|
||||
|
||||
<?php if ($editorText) : ?>
|
||||
<div class="mt-2" id="custom">
|
||||
<?php echo $this->form->getInput('content'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $this->item['id']; ?>">
|
||||
<input type="hidden" name="return" value="<?php echo Factory::getApplication()->getInput()->get('return', null, 'base64'); ?>">
|
||||
<input type="hidden" name="task" value="">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<button type="button" class="btn btn-primary" data-submit-task="modules.apply">
|
||||
<span class="icon-check" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JAPPLY'); ?>
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" data-submit-task="modules.save">
|
||||
<span class="icon-check" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JSAVE'); ?>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger" data-submit-task="modules.cancel">
|
||||
<span class="icon-times" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JCANCEL'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
48
components/com_config/tmpl/modules/default_options.php
Normal file
48
components/com_config/tmpl/modules/default_options.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$fieldSets = $this->form->getFieldsets('params');
|
||||
|
||||
echo HTMLHelper::_('bootstrap.startAccordion', 'collapseTypes');
|
||||
$i = 0;
|
||||
|
||||
foreach ($fieldSets as $name => $fieldSet) :
|
||||
$label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MODULES_' . strtoupper($name) . '_FIELDSET_LABEL';
|
||||
$class = isset($fieldSet->class) && !empty($fieldSet->class) ? $fieldSet->class : '';
|
||||
|
||||
|
||||
if (isset($fieldSet->description) && trim($fieldSet->description)) :
|
||||
echo '<p class="tip">' . $this->escape(Text::_($fieldSet->description)) . '</p>';
|
||||
endif;
|
||||
?>
|
||||
<?php echo HTMLHelper::_('bootstrap.addSlide', 'collapseTypes', Text::_($label), 'collapse' . ($i++)); ?>
|
||||
|
||||
<ul class="nav flex-column">
|
||||
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
|
||||
<li>
|
||||
<?php // If multi-language site, make menu-type selection read-only ?>
|
||||
<?php if (Multilanguage::isEnabled() && $this->item['module'] === 'mod_menu' && $field->getAttribute('name') === 'menutype') : ?>
|
||||
<?php $field->readonly = true; ?>
|
||||
<?php endif; ?>
|
||||
<?php echo $field->renderField(); ?>
|
||||
</li>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php echo HTMLHelper::_('bootstrap.endSlide'); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php echo HTMLHelper::_('bootstrap.endAccordion'); ?>
|
||||
61
components/com_config/tmpl/templates/default.php
Normal file
61
components/com_config/tmpl/templates/default.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate')
|
||||
->useScript('com_config.templates');
|
||||
|
||||
?>
|
||||
<?php if ($this->params->get('show_page_heading')) : ?>
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
<?php if ($this->escape($this->params->get('page_heading'))) : ?>
|
||||
<?php echo $this->escape($this->params->get('page_heading')); ?>
|
||||
<?php else : ?>
|
||||
<?php echo $this->escape($this->params->get('page_title')); ?>
|
||||
<?php endif; ?>
|
||||
</h1>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_config'); ?>" method="post" name="adminForm" id="templates-form" class="form-validate">
|
||||
|
||||
<div id="page-site" class="tab-pane active">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<?php echo $this->loadTemplate('options'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
|
||||
<div class="mb-2">
|
||||
<button type="button" class="btn btn-primary " data-submit-task="templates.apply">
|
||||
<span class="icon-check text-white" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JSAVE') ?>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger" data-submit-task="templates.cancel">
|
||||
<span class="icon-times text-white" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JCANCEL') ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
20
components/com_config/tmpl/templates/default.xml
Normal file
20
components/com_config/tmpl/templates/default.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<layout title="COM_CONFIG_TEMPLATES_VIEW_DEFAULT_TITLE" option="COM_CONFIG_TEMPLATES_VIEW_DEFAULT_OPTION">
|
||||
<help
|
||||
key = "Menu_Item:_Display_Template_Options"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[COM_CONFIG_TEMPLATES_VIEW_DEFAULT_DESC]]>
|
||||
</message>
|
||||
</layout>
|
||||
<fields name="request">
|
||||
<fieldset name="request" >
|
||||
<field
|
||||
name="controller"
|
||||
type="hidden"
|
||||
default=""
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</metadata>
|
||||
36
components/com_config/tmpl/templates/default_options.php
Normal file
36
components/com_config/tmpl/templates/default_options.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_config
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$fieldSets = $this->form->getFieldsets('params');
|
||||
?>
|
||||
|
||||
<legend><?php echo Text::_('COM_CONFIG_TEMPLATE_SETTINGS'); ?></legend>
|
||||
|
||||
<?php
|
||||
|
||||
// Search for com_config field set
|
||||
if (!empty($fieldSets['com_config'])) {
|
||||
echo $this->form->renderFieldset('com_config');
|
||||
} else {
|
||||
// Fall-back to display all in params
|
||||
foreach ($fieldSets as $name => $fieldSet) {
|
||||
$label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_CONFIG_' . $name . '_FIELDSET_LABEL';
|
||||
|
||||
if (isset($fieldSet->description) && trim($fieldSet->description)) {
|
||||
echo '<p class="tip">' . $this->escape(Text::_($fieldSet->description)) . '</p>';
|
||||
}
|
||||
|
||||
echo $this->form->renderFieldset($name);
|
||||
}
|
||||
}
|
||||
74
components/com_contact/forms/contact.xml
Normal file
74
components/com_contact/forms/contact.xml
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fieldset name="contact" addruleprefix="Joomla\Component\Contact\Site\Rule" label="COM_CONTACT_CONTACT_DEFAULT_LABEL">
|
||||
<field
|
||||
name="spacer"
|
||||
type="spacer"
|
||||
label="COM_CONTACT_CONTACT_REQUIRED"
|
||||
class="text"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="contact_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_CONTACT_EMAIL_NAME_LABEL"
|
||||
id="contact-name"
|
||||
size="30"
|
||||
filter="string"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="contact_email"
|
||||
type="email"
|
||||
label="COM_CONTACT_EMAIL_LABEL"
|
||||
id="contact-email"
|
||||
size="30"
|
||||
filter="string"
|
||||
validate="ContactEmail"
|
||||
autocomplete="email"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="contact_subject"
|
||||
type="text"
|
||||
label="COM_CONTACT_CONTACT_MESSAGE_SUBJECT_LABEL"
|
||||
id="contact-emailmsg"
|
||||
size="60"
|
||||
filter="string"
|
||||
validate="ContactEmailSubject"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="contact_message"
|
||||
type="textarea"
|
||||
label="COM_CONTACT_CONTACT_ENTER_MESSAGE_LABEL"
|
||||
cols="50"
|
||||
rows="10"
|
||||
id="contact-message"
|
||||
filter="safehtml"
|
||||
validate="ContactEmailMessage"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="contact_email_copy"
|
||||
type="checkbox"
|
||||
label="COM_CONTACT_CONTACT_EMAIL_A_COPY_LABEL"
|
||||
id="contact-email-copy"
|
||||
default="0"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="captcha">
|
||||
<field
|
||||
name="captcha"
|
||||
type="captcha"
|
||||
label="COM_CONTACT_CAPTCHA_LABEL"
|
||||
validate="captcha"
|
||||
namespace="contact"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
||||
126
components/com_contact/forms/filter_contacts.xml
Normal file
126
components/com_contact/forms/filter_contacts.xml
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="filter">
|
||||
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_CONTACT_FILTER_SEARCH_LABEL"
|
||||
description="COM_CONTACT_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="published"
|
||||
type="status"
|
||||
label="JOPTION_SELECT_PUBLISHED"
|
||||
description="JOPTION_SELECT_PUBLISHED_DESC"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_PUBLISHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="category_id"
|
||||
type="category"
|
||||
label="JCATEGORY"
|
||||
multiple="true"
|
||||
extension="com_contact"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
hint="JOPTION_SELECT_CATEGORY"
|
||||
onchange="this.form.submit();"
|
||||
published="0,1,2"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JOPTION_FILTER_ACCESS"
|
||||
description="JOPTION_FILTER_ACCESS_DESC"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_ACCESS</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JOPTION_FILTER_LANGUAGE"
|
||||
description="JOPTION_FILTER_LANGUAGE_DESC"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_LANGUAGE</option>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="tag"
|
||||
type="tag"
|
||||
label="JTAG"
|
||||
multiple="true"
|
||||
mode="nested"
|
||||
custom="false"
|
||||
hint="JOPTION_SELECT_TAG"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="level"
|
||||
type="integer"
|
||||
label="JOPTION_FILTER_LEVEL"
|
||||
description="JOPTION_FILTER_LEVEL_DESC"
|
||||
first="1"
|
||||
last="10"
|
||||
step="1"
|
||||
languages="*"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_MAX_LEVELS</option>
|
||||
</field>
|
||||
</fields>
|
||||
|
||||
<fields name="list">
|
||||
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="COM_CONTACT_LIST_FULL_ORDERING"
|
||||
description="COM_CONTACT_LIST_FULL_ORDERING_DESC"
|
||||
default="a.name ASC"
|
||||
onchange="this.form.submit();"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
|
||||
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
|
||||
<option value="a.published ASC">JSTATUS_ASC</option>
|
||||
<option value="a.published DESC">JSTATUS_DESC</option>
|
||||
<option value="a.featured ASC">JFEATURED_ASC</option>
|
||||
<option value="a.featured DESC">JFEATURED_DESC</option>
|
||||
<option value="a.name ASC">JGLOBAL_NAME_ASC</option>
|
||||
<option value="a.name DESC">JGLOBAL_NAME_DESC</option>
|
||||
<option value="category_title ASC">JCATEGORY_ASC</option>
|
||||
<option value="category_title DESC">JCATEGORY_DESC</option>
|
||||
<option value="ul.name ASC">COM_CONTACT_FIELD_LINKED_USER_LABEL_ASC</option>
|
||||
<option value="ul.name DESC">COM_CONTACT_FIELD_LINKED_USER_LABEL_DESC</option>
|
||||
<option value="access_level ASC">JGRID_HEADING_ACCESS_ASC</option>
|
||||
<option value="access_level DESC">JGRID_HEADING_ACCESS_DESC</option>
|
||||
<option value="association ASC" requires="associations">JASSOCIATIONS_ASC</option>
|
||||
<option value="association DESC" requires="associations">JASSOCIATIONS_DESC</option>
|
||||
<option value="language_title ASC" requires="multilanguage">JGRID_HEADING_LANGUAGE_ASC</option>
|
||||
<option value="language_title DESC" requires="multilanguage">JGRID_HEADING_LANGUAGE_DESC</option>
|
||||
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
|
||||
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="limit"
|
||||
type="limitbox"
|
||||
label="COM_CONTACT_LIST_LIMIT"
|
||||
description="COM_CONTACT_LIST_LIMIT_DESC"
|
||||
default="25"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
||||
348
components/com_contact/forms/form.xml
Normal file
348
components/com_contact/forms/form.xml
Normal file
@ -0,0 +1,348 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="id"
|
||||
type="number"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
default="0"
|
||||
class="readonly"
|
||||
size="10"
|
||||
readonly="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_NAME_LABEL"
|
||||
size="40"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="alias"
|
||||
type="text"
|
||||
label="JFIELD_ALIAS_LABEL"
|
||||
description="JFIELD_ALIAS_DESC"
|
||||
size="45"
|
||||
hint="JFIELD_ALIAS_PLACEHOLDER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="misc"
|
||||
type="editor"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_MISC_LABEL"
|
||||
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
buttons="true"
|
||||
hide="readmore,pagebreak"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by"
|
||||
type="user"
|
||||
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
|
||||
validate="UserId"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created"
|
||||
type="calendar"
|
||||
label="COM_CONTACT_FIELD_CREATED_LABEL"
|
||||
size="22"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="modified"
|
||||
type="calendar"
|
||||
label="JGLOBAL_FIELD_MODIFIED_LABEL"
|
||||
class="readonly"
|
||||
size="22"
|
||||
readonly="true"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="modified_by"
|
||||
type="user"
|
||||
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
validate="UserId"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="checked_out"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="checked_out_time"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="ordering"
|
||||
type="ordering"
|
||||
label="JFIELD_ORDERING_LABEL"
|
||||
content_type="com_contact.contact"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="contenthistory"
|
||||
type="contenthistory"
|
||||
label="JTOOLBAR_VERSIONS"
|
||||
data-typeAlias="com_contact.contact"
|
||||
/>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="details"
|
||||
label="COM_CONTACT_CONTACT_DETAILS"
|
||||
>
|
||||
<field
|
||||
name="image"
|
||||
type="media"
|
||||
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
|
||||
hide_none="1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="con_position"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_POSITION_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="email_to"
|
||||
type="email"
|
||||
label="JGLOBAL_EMAIL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="address"
|
||||
type="textarea"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_ADDRESS_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="suburb"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_SUBURB_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="state"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_STATE_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="postcode"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_POSTCODE_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="country"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_COUNTRY_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="telephone"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_TELEPHONE_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="mobile"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_MOBILE_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="fax"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_FAX_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="webpage"
|
||||
type="url"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_WEBPAGE_LABEL"
|
||||
size="30"
|
||||
filter="url"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="sortname1"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_SORTNAME1_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="sortname2"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_SORTNAME2_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="sortname3"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_SORTNAME3_LABEL"
|
||||
size="30"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="publishing"
|
||||
label="COM_CONTACT_FIELDSET_PUBLISHING"
|
||||
>
|
||||
<field
|
||||
name="catid"
|
||||
type="categoryedit"
|
||||
label="JCATEGORY"
|
||||
extension="com_contact"
|
||||
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
|
||||
required="true"
|
||||
default=""
|
||||
/>
|
||||
|
||||
<field
|
||||
name="tags"
|
||||
type="tag"
|
||||
label="JTAG"
|
||||
multiple="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="version_note"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
|
||||
labelclass="control-label"
|
||||
class=""
|
||||
size="45"
|
||||
maxlength="255"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by_alias"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_CREATED_BY_ALIAS_LABEL"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="published"
|
||||
type="list"
|
||||
label="JSTATUS"
|
||||
default="1"
|
||||
class="form-select-color-state"
|
||||
size="1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JPUBLISHED</option>
|
||||
<option value="0">JUNPUBLISHED</option>
|
||||
<option value="2">JARCHIVED</option>
|
||||
<option value="-2">JTRASHED</option>
|
||||
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="featured"
|
||||
type="list"
|
||||
label="JFEATURED"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="publish_up"
|
||||
type="calendar"
|
||||
label="COM_CONTACT_FIELD_PUBLISH_UP_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
size="22"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_down"
|
||||
type="calendar"
|
||||
label="COM_CONTACT_FIELD_PUBLISH_DOWN_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
size="22"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
filter="UINT"
|
||||
validate="options"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="language"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
>
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="metadata"
|
||||
label="COM_CONTACT_FIELDSET_METADATA"
|
||||
>
|
||||
<field
|
||||
name="metadesc"
|
||||
type="textarea"
|
||||
label="JFIELD_META_DESCRIPTION_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
maxlength="300"
|
||||
charcounter="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="metakey"
|
||||
type="textarea"
|
||||
label="JFIELD_META_KEYWORDS_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
||||
33
components/com_contact/helpers/route.php
Normal file
33
components/com_contact/helpers/route.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
*/
|
||||
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact Component Route Helper
|
||||
*
|
||||
* @static
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
* @since 1.5
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* Use \Joomla\Component\Contact\Site\Helper\RouteHelper instead
|
||||
* Example: RouteHelper::method();
|
||||
*/
|
||||
abstract class ContactHelperRoute extends RouteHelper
|
||||
{
|
||||
}
|
||||
29
components/com_contact/layouts/field/render.php
Normal file
29
components/com_contact/layouts/field/render.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
if (!array_key_exists('field', $displayData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$field = $displayData['field'];
|
||||
|
||||
// Do nothing when not in mail context, like that the default rendering is used
|
||||
if ($field->context !== 'com_contact.mail') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare the value for the contact form mail
|
||||
$value = html_entity_decode($field->value);
|
||||
|
||||
echo ($field->params->get('showlabel') ? Text::_($field->label) . ': ' : '') . $value . "\r\n";
|
||||
57
components/com_contact/layouts/fields/render.php
Normal file
57
components/com_contact/layouts/fields/render.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
|
||||
|
||||
// Check if we have all the data
|
||||
if (!array_key_exists('item', $displayData) || !array_key_exists('context', $displayData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Setting up for display
|
||||
$item = $displayData['item'];
|
||||
|
||||
if (!$item) {
|
||||
return;
|
||||
}
|
||||
|
||||
$context = $displayData['context'];
|
||||
|
||||
if (!$context) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parts = explode('.', $context);
|
||||
$component = $parts[0];
|
||||
$fields = null;
|
||||
|
||||
if (array_key_exists('fields', $displayData)) {
|
||||
$fields = $displayData['fields'];
|
||||
} else {
|
||||
$fields = $item->jcfields ?: FieldsHelper::getFields($context, $item, true);
|
||||
}
|
||||
|
||||
// Do nothing when not in mail context, like that the default rendering is used
|
||||
if (!$fields || reset($fields)->context !== 'com_contact.mail') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Loop through the fields and print them
|
||||
foreach ($fields as $field) {
|
||||
// If the value is empty do nothing
|
||||
if (!strlen($field->value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$layout = $field->params->get('layout', 'render');
|
||||
echo FieldsHelper::render($context, 'field.' . $layout, ['field' => $field]);
|
||||
}
|
||||
457
components/com_contact/src/Controller/ContactController.php
Normal file
457
components/com_contact/src/Controller/ContactController.php
Normal file
@ -0,0 +1,457 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Controller;
|
||||
|
||||
use Joomla\CMS\Event\Contact\SubmitContactEvent;
|
||||
use Joomla\CMS\Event\Contact\ValidateContactEvent;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Log\Log;
|
||||
use Joomla\CMS\Mail\Exception\MailDisabledException;
|
||||
use Joomla\CMS\Mail\MailTemplate;
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\String\PunycodeHelper;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\CMS\User\UserFactoryAwareInterface;
|
||||
use Joomla\CMS\User\UserFactoryAwareTrait;
|
||||
use Joomla\CMS\Versioning\VersionableControllerTrait;
|
||||
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
use PHPMailer\PHPMailer\Exception as phpMailerException;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Controller for single contact view
|
||||
*
|
||||
* @since 1.5.19
|
||||
*/
|
||||
class ContactController extends FormController implements UserFactoryAwareInterface
|
||||
{
|
||||
use UserFactoryAwareTrait;
|
||||
use VersionableControllerTrait;
|
||||
|
||||
/**
|
||||
* The URL view item variable.
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $view_item = 'form';
|
||||
|
||||
/**
|
||||
* The URL view list variable.
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $view_list = 'categories';
|
||||
|
||||
/**
|
||||
* Method to get a model object, loading it if required.
|
||||
*
|
||||
* @param string $name The model name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return \Joomla\CMS\MVC\Model\BaseDatabaseModel The model.
|
||||
*
|
||||
* @since 1.6.4
|
||||
*/
|
||||
public function getModel($name = 'form', $prefix = '', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, ['ignore_request' => false]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to submit the contact form and send an email.
|
||||
*
|
||||
* @return boolean True on success sending the email. False on failure.
|
||||
*
|
||||
* @since 1.5.19
|
||||
*/
|
||||
public function submit()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
$this->checkToken();
|
||||
|
||||
$app = $this->app;
|
||||
$model = $this->getModel('contact');
|
||||
$stub = $this->input->getString('id');
|
||||
$id = (int) $stub;
|
||||
|
||||
// Get the data from POST
|
||||
$data = $this->input->post->get('jform', [], 'array');
|
||||
|
||||
// Get item
|
||||
$model->setState('filter.published', 1);
|
||||
$contact = $model->getItem($id);
|
||||
|
||||
if ($contact === false) {
|
||||
$this->setMessage($model->getError(), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get item params, take menu parameters into account if necessary
|
||||
$active = $app->getMenu()->getActive();
|
||||
$stateParams = clone $model->getState()->get('params');
|
||||
|
||||
// If the current view is the active item and a contact view for this contact, then the menu item params take priority
|
||||
if ($active && strpos($active->link, 'view=contact') && strpos($active->link, '&id=' . (int) $contact->id)) {
|
||||
// $item->params are the contact params, $temp are the menu item params
|
||||
// Merge so that the menu item params take priority
|
||||
$contact->params->merge($stateParams);
|
||||
} else {
|
||||
// Current view is not a single contact, so the contact params take priority here
|
||||
$stateParams->merge($contact->params);
|
||||
$contact->params = $stateParams;
|
||||
}
|
||||
|
||||
// Check if the contact form is enabled
|
||||
if (!$contact->params->get('show_email_form')) {
|
||||
$this->setRedirect(Route::_('index.php?option=com_contact&view=contact&id=' . $stub . '&catid=' . $contact->catid, false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for a valid session cookie
|
||||
if ($contact->params->get('validate_session', 0)) {
|
||||
if (Factory::getSession()->getState() !== 'active') {
|
||||
$this->app->enqueueMessage(Text::_('JLIB_ENVIRONMENT_SESSION_INVALID'), 'warning');
|
||||
|
||||
// Save the data in the session.
|
||||
$this->app->setUserState('com_contact.contact.data', $data);
|
||||
|
||||
// Redirect back to the contact form.
|
||||
$this->setRedirect(Route::_('index.php?option=com_contact&view=contact&id=' . $stub . '&catid=' . $contact->catid, false));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Contact plugins
|
||||
PluginHelper::importPlugin('contact');
|
||||
|
||||
// Validate the posted data.
|
||||
$form = $model->getForm();
|
||||
|
||||
if (!$form) {
|
||||
throw new \Exception($model->getError(), 500);
|
||||
}
|
||||
|
||||
if (!$model->validate($form, $data)) {
|
||||
$errors = $model->getErrors();
|
||||
|
||||
foreach ($errors as $error) {
|
||||
$errorMessage = $error;
|
||||
|
||||
if ($error instanceof \Exception) {
|
||||
$errorMessage = $error->getMessage();
|
||||
}
|
||||
|
||||
$app->enqueueMessage($errorMessage, 'error');
|
||||
}
|
||||
|
||||
$app->setUserState('com_contact.contact.data', $data);
|
||||
|
||||
$this->setRedirect(Route::_('index.php?option=com_contact&view=contact&id=' . $stub . '&catid=' . $contact->catid, false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validation succeeded, continue with custom handlers
|
||||
$results = $this->getDispatcher()->dispatch('onValidateContact', new ValidateContactEvent('onValidateContact', [
|
||||
'subject' => $contact,
|
||||
'data' => &$data, // @todo: Remove reference in Joomla 6, @deprecated: Data modification onValidateContact is not allowed, use onSubmitContact instead
|
||||
]))->getArgument('result', []);
|
||||
|
||||
$passValidation = true;
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result instanceof \Exception) {
|
||||
$passValidation = false;
|
||||
$app->enqueueMessage($result->getMessage(), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$passValidation) {
|
||||
$app->setUserState('com_contact.contact.data', $data);
|
||||
|
||||
$this->setRedirect(Route::_('index.php?option=com_contact&view=contact&id=' . $id . '&catid=' . $contact->catid, false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Passed Validation: Process the contact plugins to integrate with other applications
|
||||
$event = $this->getDispatcher()->dispatch('onSubmitContact', new SubmitContactEvent('onSubmitContact', [
|
||||
'subject' => $contact,
|
||||
'data' => &$data, // @todo: Remove reference in Joomla 6, see SubmitContactEvent::__constructor()
|
||||
]));
|
||||
// Get the final data
|
||||
$data = $event->getArgument('data', $data);
|
||||
|
||||
// Send the email
|
||||
$sent = false;
|
||||
|
||||
if (!$contact->params->get('custom_reply')) {
|
||||
$sent = $this->_sendEmail($data, $contact, $contact->params->get('show_email_copy', 0));
|
||||
}
|
||||
|
||||
$msg = '';
|
||||
|
||||
// Set the success message if it was a success
|
||||
if ($sent) {
|
||||
$msg = Text::_('COM_CONTACT_EMAIL_THANKS');
|
||||
}
|
||||
|
||||
// Flush the data from the session
|
||||
$this->app->setUserState('com_contact.contact.data', null);
|
||||
|
||||
// Redirect if it is set in the parameters, otherwise redirect back to where we came from
|
||||
if ($contact->params->get('redirect')) {
|
||||
$this->setRedirect($contact->params->get('redirect'), $msg);
|
||||
} else {
|
||||
$this->setRedirect(Route::_('index.php?option=com_contact&view=contact&id=' . $stub . '&catid=' . $contact->catid, false), $msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a model object, loading it if required.
|
||||
*
|
||||
* @param array $data The data to send in the email.
|
||||
* @param \stdClass $contact The user information to send the email to
|
||||
* @param boolean $emailCopyToSender True to send a copy of the email to the user.
|
||||
*
|
||||
* @return boolean True on success sending the email, false on failure.
|
||||
*
|
||||
* @since 1.6.4
|
||||
*/
|
||||
private function _sendEmail($data, $contact, $emailCopyToSender)
|
||||
{
|
||||
$app = $this->app;
|
||||
|
||||
if ($contact->email_to == '' && $contact->user_id != 0) {
|
||||
$contact_user = $this->getUserFactory()->loadUserById($contact->user_id);
|
||||
$contact->email_to = $contact_user->get('email');
|
||||
}
|
||||
|
||||
$templateData = [
|
||||
'sitename' => $app->get('sitename'),
|
||||
'name' => $data['contact_name'],
|
||||
'contactname' => $contact->name,
|
||||
'email' => PunycodeHelper::emailToPunycode($data['contact_email']),
|
||||
'subject' => $data['contact_subject'],
|
||||
'body' => stripslashes($data['contact_message']),
|
||||
'url' => Uri::base(),
|
||||
'customfields' => '',
|
||||
];
|
||||
|
||||
// Load the custom fields
|
||||
if (!empty($data['com_fields']) && $fields = FieldsHelper::getFields('com_contact.mail', $contact, true, $data['com_fields'])) {
|
||||
$output = FieldsHelper::render(
|
||||
'com_contact.mail',
|
||||
'fields.render',
|
||||
[
|
||||
'context' => 'com_contact.mail',
|
||||
'item' => $contact,
|
||||
'fields' => $fields,
|
||||
]
|
||||
);
|
||||
|
||||
if ($output) {
|
||||
$templateData['customfields'] = $output;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$mailer = new MailTemplate('com_contact.mail', $app->getLanguage()->getTag());
|
||||
$mailer->addRecipient($contact->email_to);
|
||||
$mailer->setReplyTo($templateData['email'], $templateData['name']);
|
||||
$mailer->addTemplateData($templateData);
|
||||
$sent = $mailer->send();
|
||||
|
||||
// If we are supposed to copy the sender, do so.
|
||||
if ($emailCopyToSender == true && !empty($data['contact_email_copy'])) {
|
||||
$mailer = new MailTemplate('com_contact.mail.copy', $app->getLanguage()->getTag());
|
||||
$mailer->addRecipient($templateData['email']);
|
||||
$mailer->setReplyTo($templateData['email'], $templateData['name']);
|
||||
$mailer->addTemplateData($templateData);
|
||||
$sent = $mailer->send();
|
||||
}
|
||||
} catch (MailDisabledException | phpMailerException $exception) {
|
||||
try {
|
||||
Log::add(Text::_($exception->getMessage()), Log::WARNING, 'jerror');
|
||||
|
||||
$sent = false;
|
||||
} catch (\RuntimeException $exception) {
|
||||
$this->app->enqueueMessage(Text::_($exception->errorMessage()), 'warning');
|
||||
|
||||
$sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $sent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function allowAdd($data = [])
|
||||
{
|
||||
if ($categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('catid'), 'int')) {
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
// If the category has been passed in the data or URL check it.
|
||||
return $user->authorise('core.create', 'com_contact.category.' . $categoryId);
|
||||
}
|
||||
|
||||
// In the absence of better information, revert to the component permissions.
|
||||
return parent::allowAdd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can edit an existing record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key; default is id.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function allowEdit($data = [], $key = 'id')
|
||||
{
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
|
||||
if (!$recordId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Need to do a lookup from the model.
|
||||
$record = $this->getModel()->getItem($recordId);
|
||||
$categoryId = (int) $record->catid;
|
||||
|
||||
if ($categoryId) {
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
// The category has been set. Check the category permissions.
|
||||
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)) {
|
||||
return ($record->created_by === $user->id);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Since there is no asset tracking, revert to the component permissions.
|
||||
return parent::allowEdit($data, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cancel an edit.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
*
|
||||
* @return boolean True if access level checks pass, false otherwise.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function cancel($key = null)
|
||||
{
|
||||
$result = parent::cancel($key);
|
||||
|
||||
$this->setRedirect(Route::_($this->getReturnPage(), false));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL arguments to append to an item redirect.
|
||||
*
|
||||
* @param integer $recordId The primary key id for the item.
|
||||
* @param string $urlVar The name of the URL variable for the id.
|
||||
*
|
||||
* @return string The arguments to append to the redirect URL.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getRedirectToItemAppend($recordId = 0, $urlVar = 'id')
|
||||
{
|
||||
// Need to override the parent method completely.
|
||||
$tmpl = $this->input->get('tmpl');
|
||||
|
||||
$append = '';
|
||||
|
||||
// Setup redirect info.
|
||||
if ($tmpl) {
|
||||
$append .= '&tmpl=' . $tmpl;
|
||||
}
|
||||
|
||||
$append .= '&layout=edit';
|
||||
|
||||
$append .= '&' . $urlVar . '=' . (int) $recordId;
|
||||
|
||||
$itemId = $this->input->getInt('Itemid');
|
||||
$return = $this->getReturnPage();
|
||||
$catId = $this->input->getInt('catid');
|
||||
|
||||
if ($itemId) {
|
||||
$append .= '&Itemid=' . $itemId;
|
||||
}
|
||||
|
||||
if ($catId) {
|
||||
$append .= '&catid=' . $catId;
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
$append .= '&return=' . base64_encode($return);
|
||||
}
|
||||
|
||||
return $append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the return URL.
|
||||
*
|
||||
* If a "return" variable has been passed in the request
|
||||
*
|
||||
* @return string The return URL.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getReturnPage()
|
||||
{
|
||||
$return = $this->input->get('return', null, 'base64');
|
||||
|
||||
if (empty($return) || !Uri::isInternal(base64_decode($return))) {
|
||||
return Uri::base();
|
||||
}
|
||||
|
||||
return base64_decode($return);
|
||||
}
|
||||
}
|
||||
98
components/com_contact/src/Controller/DisplayController.php
Normal file
98
components/com_contact/src/Controller/DisplayController.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Controller;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact Component Controller
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* Recognized key values include 'name', 'default_task', 'model_path', and
|
||||
* 'view_path' (this list is not meant to be comprehensive).
|
||||
* @param MVCFactoryInterface|null $factory The factory.
|
||||
* @param CMSApplication|null $app The Application for the dispatcher
|
||||
* @param \Joomla\CMS\Input\Input|null $input The Input object for the request
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
// Contact frontpage Editor contacts proxying.
|
||||
$input = Factory::getApplication()->getInput();
|
||||
|
||||
if ($input->get('view') === 'contacts' && $input->get('layout') === 'modal') {
|
||||
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
|
||||
}
|
||||
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached
|
||||
* @param array $urlparams An array of safe URL parameters and their variable types.
|
||||
* @see \Joomla\CMS\Filter\InputFilter::clean() for valid values.
|
||||
*
|
||||
* @return DisplayController This object to support chaining.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = [])
|
||||
{
|
||||
if ($this->app->getUserState('com_contact.contact.data') === null) {
|
||||
$cachable = true;
|
||||
}
|
||||
|
||||
// Set the default view name and format from the Request.
|
||||
$vName = $this->input->get('view', 'categories');
|
||||
$this->input->set('view', $vName);
|
||||
|
||||
if ($this->app->getIdentity()->get('id')) {
|
||||
$cachable = false;
|
||||
}
|
||||
|
||||
$safeurlparams = [
|
||||
'catid' => 'INT',
|
||||
'id' => 'INT',
|
||||
'cid' => 'ARRAY',
|
||||
'year' => 'INT',
|
||||
'month' => 'INT',
|
||||
'limit' => 'UINT',
|
||||
'limitstart' => 'UINT',
|
||||
'showall' => 'INT',
|
||||
'return' => 'BASE64',
|
||||
'filter' => 'STRING',
|
||||
'filter_order' => 'CMD',
|
||||
'filter_order_Dir' => 'CMD',
|
||||
'filter-search' => 'STRING',
|
||||
'print' => 'BOOLEAN',
|
||||
'lang' => 'CMD',
|
||||
];
|
||||
|
||||
parent::display($cachable, $safeurlparams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
48
components/com_contact/src/Dispatcher/Dispatcher.php
Normal file
48
components/com_contact/src/Dispatcher/Dispatcher.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Dispatcher;
|
||||
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcher;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* ComponentDispatcher class for com_contact
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class Dispatcher extends ComponentDispatcher
|
||||
{
|
||||
/**
|
||||
* Dispatch a controller task. Redirecting the user if appropriate.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function dispatch()
|
||||
{
|
||||
if ($this->input->get('view') === 'contacts' && $this->input->get('layout') === 'modal') {
|
||||
if (!$this->app->getIdentity()->authorise('core.create', 'com_contact')) {
|
||||
$this->app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'warning');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->app->getLanguage()->load('com_contact', JPATH_ADMINISTRATOR);
|
||||
}
|
||||
|
||||
parent::dispatch();
|
||||
}
|
||||
}
|
||||
64
components/com_contact/src/Helper/AssociationHelper.php
Normal file
64
components/com_contact/src/Helper/AssociationHelper.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Helper;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\Component\Categories\Administrator\Helper\CategoryAssociationHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact Component Association Helper
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
abstract class AssociationHelper extends CategoryAssociationHelper
|
||||
{
|
||||
/**
|
||||
* Method to get the associations for a given item
|
||||
*
|
||||
* @param integer $id Id of the item
|
||||
* @param string $view Name of the view
|
||||
*
|
||||
* @return array Array of associations for the item
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function getAssociations($id = 0, $view = null)
|
||||
{
|
||||
$jinput = Factory::getApplication()->getInput();
|
||||
$view = $view ?? $jinput->get('view');
|
||||
$id = empty($id) ? $jinput->getInt('id') : $id;
|
||||
|
||||
if ($view === 'contact') {
|
||||
if ($id) {
|
||||
$associations = Associations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $id);
|
||||
|
||||
$return = [];
|
||||
|
||||
foreach ($associations as $tag => $item) {
|
||||
$return[$tag] = RouteHelper::getContactRoute($item->id, (int) $item->catid, $item->language);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($view === 'category' || $view === 'categories') {
|
||||
return self::getCategoryAssociations($id, 'com_contact');
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
88
components/com_contact/src/Helper/RouteHelper.php
Normal file
88
components/com_contact/src/Helper/RouteHelper.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Helper;
|
||||
|
||||
use Joomla\CMS\Categories\CategoryNode;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact Component Route Helper
|
||||
*
|
||||
* @static
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
* @since 1.5
|
||||
*/
|
||||
abstract class RouteHelper
|
||||
{
|
||||
/**
|
||||
* Get the URL route for a contact from a contact ID, contact category ID and language
|
||||
*
|
||||
* @param integer $id The id of the contact
|
||||
* @param integer $catid The id of the contact's category
|
||||
* @param mixed $language The id of the language being used.
|
||||
*
|
||||
* @return string The link to the contact
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getContactRoute($id, $catid, $language = 0)
|
||||
{
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_contact&view=contact&id=' . $id;
|
||||
|
||||
if ($catid > 1) {
|
||||
$link .= '&catid=' . $catid;
|
||||
}
|
||||
|
||||
if ($language && $language !== '*' && Multilanguage::isEnabled()) {
|
||||
$link .= '&lang=' . $language;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL route for a contact category from a contact category ID and language
|
||||
*
|
||||
* @param mixed $catid The id of the contact's category either an integer id or an instance of CategoryNode
|
||||
* @param mixed $language The id of the language being used.
|
||||
*
|
||||
* @return string The link to the contact
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getCategoryRoute($catid, $language = 0)
|
||||
{
|
||||
if ($catid instanceof CategoryNode) {
|
||||
$id = $catid->id;
|
||||
} else {
|
||||
$id = (int) $catid;
|
||||
}
|
||||
|
||||
if ($id < 1) {
|
||||
$link = '';
|
||||
} else {
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_contact&view=category&id=' . $id;
|
||||
|
||||
if ($language && $language !== '*' && Multilanguage::isEnabled()) {
|
||||
$link .= '&lang=' . $language;
|
||||
}
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
156
components/com_contact/src/Model/CategoriesModel.php
Normal file
156
components/com_contact/src/Model/CategoriesModel.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Model;
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
use Joomla\CMS\Categories\CategoryNode;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* This models supports retrieving lists of contact categories.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class CategoriesModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_context = 'com_contact.categories';
|
||||
|
||||
/**
|
||||
* The category context (allows other extensions to derived from this model).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_extension = 'com_contact';
|
||||
|
||||
/**
|
||||
* Parent category of the current one
|
||||
*
|
||||
* @var CategoryNode|null
|
||||
*/
|
||||
private $_parent = null;
|
||||
|
||||
/**
|
||||
* Array of child-categories
|
||||
*
|
||||
* @var CategoryNode[]|null
|
||||
*/
|
||||
private $_items = null;
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$this->setState('filter.extension', $this->_extension);
|
||||
|
||||
// Get the parent id if defined.
|
||||
$parentId = $app->getInput()->getInt('id');
|
||||
$this->setState('filter.parentId', $parentId);
|
||||
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
$this->setState('filter.published', 1);
|
||||
$this->setState('filter.access', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.extension');
|
||||
$id .= ':' . $this->getState('filter.published');
|
||||
$id .= ':' . $this->getState('filter.access');
|
||||
$id .= ':' . $this->getState('filter.parentId');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redefine the function and add some properties to make the styling easier
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
if ($this->_items === null) {
|
||||
$app = Factory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
$active = $menu->getActive();
|
||||
|
||||
if ($active) {
|
||||
$params = $active->getParams();
|
||||
} else {
|
||||
$params = new Registry();
|
||||
}
|
||||
|
||||
$options = [];
|
||||
$options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0);
|
||||
$categories = Categories::getInstance('Contact', $options);
|
||||
$this->_parent = $categories->get($this->getState('filter.parentId', 'root'));
|
||||
|
||||
if (\is_object($this->_parent)) {
|
||||
$this->_items = $this->_parent->getChildren();
|
||||
} else {
|
||||
$this->_items = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id of the parent category for the selected list of categories
|
||||
*
|
||||
* @return integer The id of the parent category
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
if (!\is_object($this->_parent)) {
|
||||
$this->getItems();
|
||||
}
|
||||
|
||||
return $this->_parent;
|
||||
}
|
||||
}
|
||||
463
components/com_contact/src/Model/CategoryModel.php
Normal file
463
components/com_contact/src/Model/CategoryModel.php
Normal file
@ -0,0 +1,463 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Model;
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
use Joomla\CMS\Categories\CategoryNode;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Single item model for a contact
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
* @since 1.5
|
||||
*/
|
||||
class CategoryModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Category item data
|
||||
*
|
||||
* @var CategoryNode
|
||||
*/
|
||||
protected $_item;
|
||||
|
||||
/**
|
||||
* Category left and right of this one
|
||||
*
|
||||
* @var CategoryNode[]|null
|
||||
*/
|
||||
protected $_siblings;
|
||||
|
||||
/**
|
||||
* Array of child-categories
|
||||
*
|
||||
* @var CategoryNode[]|null
|
||||
*/
|
||||
protected $_children;
|
||||
|
||||
/**
|
||||
* Parent category of the current one
|
||||
*
|
||||
* @var CategoryNode|null
|
||||
*/
|
||||
protected $_parent;
|
||||
|
||||
/**
|
||||
* The category that applies.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $_category;
|
||||
|
||||
/**
|
||||
* The list of other contact categories.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_categories;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'name', 'a.name',
|
||||
'con_position', 'a.con_position',
|
||||
'suburb', 'a.suburb',
|
||||
'state', 'a.state',
|
||||
'country', 'a.country',
|
||||
'ordering', 'a.ordering',
|
||||
'sortname',
|
||||
'sortname1', 'a.sortname1',
|
||||
'sortname2', 'a.sortname2',
|
||||
'sortname3', 'a.sortname3',
|
||||
'featuredordering', 'a.featured',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of items.
|
||||
*
|
||||
* @return mixed An array of objects on success, false on failure.
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
// Invoke the parent getItems method to get the main list
|
||||
$items = parent::getItems();
|
||||
|
||||
if ($items === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$taggedItems = [];
|
||||
|
||||
// Convert the params field into an object, saving original in _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();
|
||||
$taggedItems[$item->id] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
// Load tags of all items.
|
||||
if ($taggedItems) {
|
||||
$tagsHelper = new TagsHelper();
|
||||
$itemIds = array_keys($taggedItems);
|
||||
|
||||
foreach ($tagsHelper->getMultipleItemTags('com_contact.contact', $itemIds) as $id => $tags) {
|
||||
$taggedItems[$id]->tags->itemTags = $tags;
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build an SQL query to load the list data.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery An SQL query
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
|
||||
/** @var \Joomla\Database\DatabaseQuery $query */
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select($this->getState('list.select', 'a.*'))
|
||||
->select($this->getSlugColumn($query, 'a.id', 'a.alias') . ' AS slug')
|
||||
->select($this->getSlugColumn($query, 'c.id', 'c.alias') . ' AS catslug')
|
||||
/**
|
||||
* @todo: we actually should be doing it but it's wrong this way
|
||||
* . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, '
|
||||
* . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END AS catslug ');
|
||||
*/
|
||||
->from($db->quoteName('#__contact_details', 'a'))
|
||||
->leftJoin($db->quoteName('#__categories', 'c') . ' ON c.id = a.catid')
|
||||
->whereIn($db->quoteName('a.access'), $groups);
|
||||
|
||||
// Filter by category.
|
||||
if ($categoryId = $this->getState('category.id')) {
|
||||
$query->where($db->quoteName('a.catid') . ' = :acatid')
|
||||
->whereIn($db->quoteName('c.access'), $groups);
|
||||
$query->bind(':acatid', $categoryId, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Join over the users for the author and modified_by names.
|
||||
$query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author")
|
||||
->select('ua.email AS author_email')
|
||||
->leftJoin($db->quoteName('#__users', 'ua') . ' ON ua.id = a.created_by')
|
||||
->leftJoin($db->quoteName('#__users', 'uam') . ' ON uam.id = a.modified_by');
|
||||
|
||||
// Filter by state
|
||||
$state = $this->getState('filter.published');
|
||||
|
||||
if (is_numeric($state)) {
|
||||
$query->where($db->quoteName('a.published') . ' = :published');
|
||||
$query->bind(':published', $state, ParameterType::INTEGER);
|
||||
} else {
|
||||
$query->whereIn($db->quoteName('c.published'), [0,1,2]);
|
||||
}
|
||||
|
||||
// Filter by start and end dates.
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
|
||||
if ($this->getState('filter.publish_date')) {
|
||||
$query->where('(' . $db->quoteName('a.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)')
|
||||
->bind(':publish_up', $nowDate)
|
||||
->bind(':publish_down', $nowDate);
|
||||
}
|
||||
|
||||
// Filter by search in title
|
||||
$search = $this->getState('list.filter');
|
||||
|
||||
if (!empty($search)) {
|
||||
$search = '%' . trim($search) . '%';
|
||||
$query->where($db->quoteName('a.name') . ' LIKE :name ');
|
||||
$query->bind(':name', $search);
|
||||
}
|
||||
|
||||
// Filter on the language.
|
||||
if ($this->getState('filter.language')) {
|
||||
$query->whereIn($db->quoteName('a.language'), [Factory::getApplication()->getLanguage()->getTag(), '*'], ParameterType::STRING);
|
||||
}
|
||||
|
||||
// Set sortname ordering if selected
|
||||
if ($this->getState('list.ordering') === 'sortname') {
|
||||
$query->order($db->escape('a.sortname1') . ' ' . $db->escape($this->getState('list.direction', 'ASC')))
|
||||
->order($db->escape('a.sortname2') . ' ' . $db->escape($this->getState('list.direction', 'ASC')))
|
||||
->order($db->escape('a.sortname3') . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
|
||||
} elseif ($this->getState('list.ordering') === 'featuredordering') {
|
||||
$query->order($db->escape('a.featured') . ' DESC')
|
||||
->order($db->escape('a.ordering') . ' ASC');
|
||||
} else {
|
||||
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information
|
||||
$format = $input->getWord('format');
|
||||
|
||||
if ($format === 'feed') {
|
||||
$limit = $app->get('feed_limit');
|
||||
} else {
|
||||
$limit = $app->getUserStateFromRequest(
|
||||
'com_contact.category.list.limit',
|
||||
'limit',
|
||||
$params->get('contacts_display_num', $app->get('list_limit')),
|
||||
'uint'
|
||||
);
|
||||
}
|
||||
|
||||
$this->setState('list.limit', $limit);
|
||||
|
||||
$limitstart = $input->get('limitstart', 0, 'uint');
|
||||
$this->setState('list.start', $limitstart);
|
||||
|
||||
// Optional filter text
|
||||
$itemid = $input->get('Itemid', 0, 'int');
|
||||
$search = $app->getUserStateFromRequest('com_contact.category.list.' . $itemid . '.filter-search', 'filter-search', '', 'string');
|
||||
$this->setState('list.filter', $search);
|
||||
|
||||
$orderCol = $input->get('filter_order', $params->get('initial_sort', 'ordering'));
|
||||
|
||||
if (!\in_array($orderCol, $this->filter_fields)) {
|
||||
$orderCol = 'ordering';
|
||||
}
|
||||
|
||||
$this->setState('list.ordering', $orderCol);
|
||||
|
||||
$listOrder = $input->get('filter_order_Dir', 'ASC');
|
||||
|
||||
if (!\in_array(strtoupper($listOrder), ['ASC', 'DESC', ''])) {
|
||||
$listOrder = 'ASC';
|
||||
}
|
||||
|
||||
$this->setState('list.direction', $listOrder);
|
||||
|
||||
$id = $input->get('id', 0, 'int');
|
||||
$this->setState('category.id', $id);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if ((!$user->authorise('core.edit.state', 'com_contact')) && (!$user->authorise('core.edit', 'com_contact'))) {
|
||||
// Limit to published for people who can't edit or edit.state.
|
||||
$this->setState('filter.published', 1);
|
||||
|
||||
// Filter by start and end dates.
|
||||
$this->setState('filter.publish_date', true);
|
||||
}
|
||||
|
||||
$this->setState('filter.language', Multilanguage::isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get category data for the current category
|
||||
*
|
||||
* @return object The category object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
$app = Factory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
$active = $menu->getActive();
|
||||
|
||||
if ($active) {
|
||||
$params = $active->getParams();
|
||||
} else {
|
||||
$params = new Registry();
|
||||
}
|
||||
|
||||
$options = [];
|
||||
$options['countItems'] = $params->get('show_cat_items', 1) || $params->get('show_empty_categories', 0);
|
||||
$categories = Categories::getInstance('Contact', $options);
|
||||
$this->_item = $categories->get($this->getState('category.id', 'root'));
|
||||
|
||||
if (\is_object($this->_item)) {
|
||||
$this->_children = $this->_item->getChildren();
|
||||
$this->_parent = false;
|
||||
|
||||
if ($this->_item->getParent()) {
|
||||
$this->_parent = $this->_item->getParent();
|
||||
}
|
||||
|
||||
$this->_rightsibling = $this->_item->getSibling();
|
||||
$this->_leftsibling = $this->_item->getSibling(false);
|
||||
} else {
|
||||
$this->_children = false;
|
||||
$this->_parent = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent category.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sibling (adjacent) categories.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*/
|
||||
public function &getLeftSibling()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
return $this->_leftsibling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sibling (adjacent) categories.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*/
|
||||
public function &getRightSibling()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
return $this->_rightsibling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the child categories.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*/
|
||||
public function &getChildren()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
return $this->_children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate column expression for slug or catslug.
|
||||
*
|
||||
* @param \Joomla\Database\DatabaseQuery $query Current query instance.
|
||||
* @param string $id Column id name.
|
||||
* @param string $alias Column alias name.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private function getSlugColumn($query, $id, $alias)
|
||||
{
|
||||
return 'CASE WHEN '
|
||||
. $query->charLength($alias, '!=', '0')
|
||||
. ' THEN '
|
||||
. $query->concatenate([$query->castAsChar($id), $alias], ':')
|
||||
. ' ELSE '
|
||||
. $query->castAsChar($id) . ' END';
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the hit counter for the category.
|
||||
*
|
||||
* @param integer $pk Optional primary key of the category to increment.
|
||||
*
|
||||
* @return boolean True if successful; false otherwise and internal error set.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function hit($pk = 0)
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
$hitcount = $input->getInt('hitcount', 1);
|
||||
|
||||
if ($hitcount) {
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
|
||||
|
||||
$table = Table::getInstance('Category');
|
||||
$table->hit($pk);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
434
components/com_contact/src/Model/ContactModel.php
Normal file
434
components/com_contact/src/Model/ContactModel.php
Normal file
@ -0,0 +1,434 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Model;
|
||||
|
||||
use Joomla\CMS\Application\SiteApplication;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Model\FormModel;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Database\QueryInterface;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Single item model for a contact
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
* @since 1.5
|
||||
*/
|
||||
class ContactModel extends FormModel
|
||||
{
|
||||
/**
|
||||
* The name of the view for a single item
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $view_item = 'contact';
|
||||
|
||||
/**
|
||||
* A loaded item
|
||||
*
|
||||
* @var \stdClass[]
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $_item = [];
|
||||
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_contact.contact';
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
/** @var SiteApplication $app */
|
||||
$app = Factory::getContainer()->get(SiteApplication::class);
|
||||
|
||||
if (Factory::getApplication()->isClient('api')) {
|
||||
// @todo: remove this
|
||||
$app->loadLanguage();
|
||||
$this->setState('contact.id', Factory::getApplication()->getInput()->post->getInt('id'));
|
||||
} else {
|
||||
$this->setState('contact.id', $app->getInput()->getInt('id'));
|
||||
}
|
||||
|
||||
$this->setState('params', $app->getParams());
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if ((!$user->authorise('core.edit.state', 'com_contact')) && (!$user->authorise('core.edit', 'com_contact'))) {
|
||||
$this->setState('filter.published', 1);
|
||||
$this->setState('filter.archived', 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the contact form.
|
||||
* The base form is loaded from XML and then an event is fired
|
||||
*
|
||||
* @param array $data An optional array of data for the form to interrogate.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return Form A Form object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
$form = $this->loadForm('com_contact.contact', 'contact', ['control' => 'jform', 'load_data' => true]);
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$temp = clone $this->getState('params');
|
||||
$contact = $this->getItem($this->getState('contact.id'));
|
||||
$active = Factory::getContainer()->get(SiteApplication::class)->getMenu()->getActive();
|
||||
|
||||
if ($active) {
|
||||
// If the current view is the active item and a contact view for this contact, then the menu item params take priority
|
||||
if (strpos($active->link, 'view=contact') && strpos($active->link, '&id=' . (int) $contact->id)) {
|
||||
// $contact->params are the contact params, $temp are the menu item params
|
||||
// Merge so that the menu item params take priority
|
||||
$contact->params->merge($temp);
|
||||
} else {
|
||||
// Current view is not a single contact, so the contact params take priority here
|
||||
// Merge the menu item params with the contact params so that the contact params take priority
|
||||
$temp->merge($contact->params);
|
||||
$contact->params = $temp;
|
||||
}
|
||||
} else {
|
||||
// Merge so that contact params take priority
|
||||
$temp->merge($contact->params);
|
||||
$contact->params = $temp;
|
||||
}
|
||||
|
||||
if (!$contact->params->get('show_email_copy', 0)) {
|
||||
$form->removeField('contact_email_copy');
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* @return array The default data is an empty array.
|
||||
*
|
||||
* @since 1.6.2
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
$data = (array) Factory::getApplication()->getUserState('com_contact.contact.data', []);
|
||||
|
||||
if (empty($data['language']) && Multilanguage::isEnabled()) {
|
||||
$data['language'] = Factory::getLanguage()->getTag();
|
||||
}
|
||||
|
||||
// Add contact catid to contact form data, so fields plugin can work properly
|
||||
if (empty($data['catid'])) {
|
||||
$data['catid'] = $this->getItem()->catid;
|
||||
}
|
||||
|
||||
$this->preprocessData('com_contact.contact', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a contact
|
||||
*
|
||||
* @param integer $pk Id for the contact
|
||||
*
|
||||
* @return mixed Object or null
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
$pk = $pk ?: (int) $this->getState('contact.id');
|
||||
|
||||
if (!isset($this->_item[$pk])) {
|
||||
try {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select($this->getState('item.select', 'a.*'))
|
||||
->select($this->getSlugColumn($query, 'a.id', 'a.alias') . ' AS slug')
|
||||
->select($this->getSlugColumn($query, 'c.id', 'c.alias') . ' AS catslug')
|
||||
->from($db->quoteName('#__contact_details', 'a'))
|
||||
|
||||
// Join on category table.
|
||||
->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access')
|
||||
->leftJoin($db->quoteName('#__categories', 'c'), 'c.id = a.catid')
|
||||
|
||||
// Join over the categories to get parent category titles
|
||||
->select('parent.title AS parent_title, parent.id AS parent_id, parent.path AS parent_route, parent.alias AS parent_alias')
|
||||
->leftJoin($db->quoteName('#__categories', 'parent'), 'parent.id = c.parent_id')
|
||||
->where($db->quoteName('a.id') . ' = :id')
|
||||
->bind(':id', $pk, ParameterType::INTEGER);
|
||||
|
||||
// Filter by start and end dates.
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
|
||||
// Filter by published state.
|
||||
$published = $this->getState('filter.published');
|
||||
$archived = $this->getState('filter.archived');
|
||||
|
||||
if (is_numeric($published)) {
|
||||
$queryString = $db->quoteName('a.published') . ' = :published';
|
||||
|
||||
if ($archived !== null) {
|
||||
$queryString = '(' . $queryString . ' OR ' . $db->quoteName('a.published') . ' = :archived)';
|
||||
$query->bind(':archived', $archived, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
$query->where($queryString)
|
||||
->where('(' . $db->quoteName('a.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)')
|
||||
->bind(':published', $published, ParameterType::INTEGER)
|
||||
->bind(':publish_up', $nowDate)
|
||||
->bind(':publish_down', $nowDate);
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
$data = $db->loadObject();
|
||||
|
||||
if (empty($data)) {
|
||||
throw new \Exception(Text::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
// Check for published state if filter set.
|
||||
if ((is_numeric($published) || is_numeric($archived)) && (($data->published != $published) && ($data->published != $archived))) {
|
||||
throw new \Exception(Text::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
/**
|
||||
* In case some entity params have been set to "use global", those are
|
||||
* represented as an empty string and must be "overridden" by merging
|
||||
* the component and / or menu params here.
|
||||
*/
|
||||
$registry = new Registry($data->params);
|
||||
|
||||
$data->params = clone $this->getState('params');
|
||||
$data->params->merge($registry);
|
||||
|
||||
$registry = new Registry($data->metadata);
|
||||
$data->metadata = $registry;
|
||||
|
||||
// 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();
|
||||
$data->tags->getItemTags('com_contact.contact', $data->id);
|
||||
}
|
||||
|
||||
// Compute access permissions.
|
||||
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 {
|
||||
// If no access filter is set, the layout takes some responsibility for display of limited information.
|
||||
$user = $this->getCurrentUser();
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
|
||||
if ($data->catid == 0 || $data->category_access === null) {
|
||||
$data->params->set('access-view', \in_array($data->access, $groups));
|
||||
} else {
|
||||
$data->params->set('access-view', \in_array($data->access, $groups) && \in_array($data->category_access, $groups));
|
||||
}
|
||||
}
|
||||
|
||||
$this->_item[$pk] = $data;
|
||||
} catch (\Exception $e) {
|
||||
if ($e->getCode() == 404) {
|
||||
// Need to go through the error handler to allow Redirect to work.
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->setError($e);
|
||||
$this->_item[$pk] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_item[$pk]) {
|
||||
$this->buildContactExtendedData($this->_item[$pk]);
|
||||
}
|
||||
|
||||
return $this->_item[$pk];
|
||||
}
|
||||
|
||||
/**
|
||||
* Load extended data (profile, articles) for a contact
|
||||
*
|
||||
* @param object $contact The contact object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function buildContactExtendedData($contact)
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
$user = $this->getCurrentUser();
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
$published = $this->getState('filter.published');
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// If we are showing a contact list, then the contact parameters take priority
|
||||
// So merge the contact parameters with the merged parameters
|
||||
if ($this->getState('params')->get('show_contact_list')) {
|
||||
$this->getState('params')->merge($contact->params);
|
||||
}
|
||||
|
||||
// Get the com_content articles by the linked user
|
||||
if ((int) $contact->user_id && $this->getState('params')->get('show_articles')) {
|
||||
$query->select('a.id')
|
||||
->select('a.title')
|
||||
->select('a.state')
|
||||
->select('a.access')
|
||||
->select('a.catid')
|
||||
->select('a.created')
|
||||
->select('a.language')
|
||||
->select('a.publish_up')
|
||||
->select('a.introtext')
|
||||
->select('a.images')
|
||||
->select($this->getSlugColumn($query, 'a.id', 'a.alias') . ' AS slug')
|
||||
->select($this->getSlugColumn($query, 'c.id', 'c.alias') . ' AS catslug')
|
||||
->from($db->quoteName('#__content', 'a'))
|
||||
->leftJoin($db->quoteName('#__categories', 'c') . ' ON a.catid = c.id')
|
||||
->where($db->quoteName('a.created_by') . ' = :created_by')
|
||||
->whereIn($db->quoteName('a.access'), $groups)
|
||||
->bind(':created_by', $contact->user_id, ParameterType::INTEGER)
|
||||
->order('a.publish_up DESC');
|
||||
|
||||
// Filter per language if plugin published
|
||||
if (Multilanguage::isEnabled()) {
|
||||
$language = [Factory::getLanguage()->getTag(), '*'];
|
||||
$query->whereIn($db->quoteName('a.language'), $language, ParameterType::STRING);
|
||||
}
|
||||
|
||||
if (is_numeric($published)) {
|
||||
$query->where('a.state IN (1,2)')
|
||||
->where('(' . $db->quoteName('a.publish_up') . ' IS NULL' .
|
||||
' OR ' . $db->quoteName('a.publish_up') . ' <= :now1)')
|
||||
->where('(' . $db->quoteName('a.publish_down') . ' IS NULL' .
|
||||
' OR ' . $db->quoteName('a.publish_down') . ' >= :now2)')
|
||||
->bind([':now1', ':now2'], $nowDate);
|
||||
}
|
||||
|
||||
// Number of articles to display from config/menu params
|
||||
$articles_display_num = $this->getState('params')->get('articles_display_num', 10);
|
||||
|
||||
// Use contact setting?
|
||||
if ($articles_display_num === 'use_contact') {
|
||||
$articles_display_num = $contact->params->get('articles_display_num', 10);
|
||||
|
||||
// Use global?
|
||||
if ((string) $articles_display_num === '') {
|
||||
$articles_display_num = ComponentHelper::getParams('com_contact')->get('articles_display_num', 10);
|
||||
}
|
||||
}
|
||||
|
||||
$query->setLimit((int) $articles_display_num);
|
||||
$db->setQuery($query);
|
||||
$contact->articles = $db->loadObjectList();
|
||||
} else {
|
||||
$contact->articles = null;
|
||||
}
|
||||
|
||||
// Get the profile information for the linked user
|
||||
$userModel = $this->bootComponent('com_users')->getMVCFactory()
|
||||
->createModel('User', 'Administrator', ['ignore_request' => true]);
|
||||
$data = $userModel->getItem((int) $contact->user_id);
|
||||
|
||||
PluginHelper::importPlugin('user');
|
||||
|
||||
// Get the form.
|
||||
Form::addFormPath(JPATH_SITE . '/components/com_users/forms');
|
||||
|
||||
$form = Form::getInstance('com_users.profile', 'profile');
|
||||
|
||||
// Trigger the form preparation event.
|
||||
Factory::getApplication()->triggerEvent('onContentPrepareForm', [$form, $data]);
|
||||
|
||||
// Trigger the data preparation event.
|
||||
Factory::getApplication()->triggerEvent('onContentPrepareData', ['com_users.profile', $data]);
|
||||
|
||||
// Load the data into the form after the plugins have operated.
|
||||
$form->bind($data);
|
||||
$contact->profile = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate column expression for slug or catslug.
|
||||
*
|
||||
* @param QueryInterface $query Current query instance.
|
||||
* @param string $id Column id name.
|
||||
* @param string $alias Column alias name.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private function getSlugColumn($query, $id, $alias)
|
||||
{
|
||||
return 'CASE WHEN '
|
||||
. $query->charLength($alias, '!=', '0')
|
||||
. ' THEN '
|
||||
. $query->concatenate([$query->castAsChar($id), $alias], ':')
|
||||
. ' ELSE '
|
||||
. $query->castAsChar($id) . ' END';
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the hit counter for the contact.
|
||||
*
|
||||
* @param integer $pk Optional primary key of the contact to increment.
|
||||
*
|
||||
* @return boolean True if successful; false otherwise and internal error set.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function hit($pk = 0)
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
$hitcount = $input->getInt('hitcount', 1);
|
||||
|
||||
if ($hitcount) {
|
||||
$pk = $pk ?: (int) $this->getState('contact.id');
|
||||
|
||||
$table = $this->getTable('Contact');
|
||||
$table->hit($pk);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
209
components/com_contact/src/Model/FeaturedModel.php
Normal file
209
components/com_contact/src/Model/FeaturedModel.php
Normal file
@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Model;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Database\DatabaseQuery;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Featured contact model class.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
class FeaturedModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'name', 'a.name',
|
||||
'con_position', 'a.con_position',
|
||||
'suburb', 'a.suburb',
|
||||
'state', 'a.state',
|
||||
'country', 'a.country',
|
||||
'ordering', 'a.ordering',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of items.
|
||||
*
|
||||
* @return mixed An array of objects on success, false on failure.
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
// Invoke the parent getItems method to get the main list
|
||||
$items = parent::getItems();
|
||||
|
||||
// Convert the params field into an object, saving original in _params
|
||||
for ($i = 0, $n = \count($items); $i < $n; $i++) {
|
||||
$item = &$items[$i];
|
||||
|
||||
if (!isset($this->_params)) {
|
||||
$item->params = new Registry($item->params);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build an SQL query to load the list data.
|
||||
*
|
||||
* @return DatabaseQuery An SQL query
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select required fields from the categories.
|
||||
$query->select($this->getState('list.select', 'a.*'))
|
||||
->from($db->quoteName('#__contact_details', 'a'))
|
||||
->where($db->quoteName('a.featured') . ' = 1')
|
||||
->whereIn($db->quoteName('a.access'), $groups)
|
||||
->innerJoin($db->quoteName('#__categories', 'c') . ' ON c.id = a.catid')
|
||||
->whereIn($db->quoteName('c.access'), $groups);
|
||||
|
||||
// Filter by category.
|
||||
if ($categoryId = $this->getState('category.id')) {
|
||||
$query->where($db->quoteName('a.catid') . ' = :catid');
|
||||
$query->bind(':catid', $categoryId, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
$query->select('c.published as cat_published, c.published AS parents_published')
|
||||
->where('c.published = 1');
|
||||
|
||||
// Filter by state
|
||||
$state = $this->getState('filter.published');
|
||||
|
||||
if (is_numeric($state)) {
|
||||
$query->where($db->quoteName('a.published') . ' = :published');
|
||||
$query->bind(':published', $state, ParameterType::INTEGER);
|
||||
|
||||
// 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)')
|
||||
->where('(' . $db->quoteName('a.publish_down') .
|
||||
' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)')
|
||||
->bind(':publish_up', $nowDate)
|
||||
->bind(':publish_down', $nowDate);
|
||||
}
|
||||
|
||||
// Filter by search in title
|
||||
$search = $this->getState('list.filter');
|
||||
|
||||
// Filter by search in title
|
||||
if (!empty($search)) {
|
||||
$search = '%' . trim($search) . '%';
|
||||
$query->where($db->quoteName('a.name') . ' LIKE :name ');
|
||||
$query->bind(':name', $search);
|
||||
}
|
||||
|
||||
// Filter by language
|
||||
if ($this->getState('filter.language')) {
|
||||
$query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
$params = ComponentHelper::getParams('com_contact');
|
||||
|
||||
// List state information
|
||||
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit'), 'uint');
|
||||
$this->setState('list.limit', $limit);
|
||||
|
||||
$limitstart = $input->get('limitstart', 0, 'uint');
|
||||
$this->setState('list.start', $limitstart);
|
||||
|
||||
// Optional filter text
|
||||
$this->setState('list.filter', $input->getString('filter-search'));
|
||||
|
||||
$orderCol = $input->get('filter_order', 'ordering');
|
||||
|
||||
if (!\in_array($orderCol, $this->filter_fields)) {
|
||||
$orderCol = 'ordering';
|
||||
}
|
||||
|
||||
$this->setState('list.ordering', $orderCol);
|
||||
|
||||
$listOrder = $input->get('filter_order_Dir', 'ASC');
|
||||
|
||||
if (!\in_array(strtoupper($listOrder), ['ASC', 'DESC', ''])) {
|
||||
$listOrder = 'ASC';
|
||||
}
|
||||
|
||||
$this->setState('list.direction', $listOrder);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if ((!$user->authorise('core.edit.state', 'com_contact')) && (!$user->authorise('core.edit', 'com_contact'))) {
|
||||
// Limit to published for people who can't edit or edit.state.
|
||||
$this->setState('filter.published', 1);
|
||||
|
||||
// Filter by start and end dates.
|
||||
$this->setState('filter.publish_date', true);
|
||||
}
|
||||
|
||||
$this->setState('filter.language', Multilanguage::isEnabled());
|
||||
|
||||
// Load the parameters.
|
||||
$this->setState('params', $params);
|
||||
}
|
||||
}
|
||||
237
components/com_contact/src/Model/FormModel.php
Normal file
237
components/com_contact/src/Model/FormModel.php
Normal file
@ -0,0 +1,237 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact Component Contact Model
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class FormModel extends \Joomla\Component\Contact\Administrator\Model\ContactModel
|
||||
{
|
||||
/**
|
||||
* Model typeAlias string. Used for version history.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public $typeAlias = 'com_contact.contact';
|
||||
|
||||
/**
|
||||
* Name of the form
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $formName = 'form';
|
||||
|
||||
/**
|
||||
* Method to get the row form.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return Form|boolean A Form object on success, false on failure
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
$form = parent::getForm($data, $loadData);
|
||||
|
||||
// Prevent messing with article language and category when editing existing contact with associations
|
||||
if ($id = $this->getState('contact.id') && Associations::isEnabled()) {
|
||||
$associations = Associations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $id);
|
||||
|
||||
// Make fields read only
|
||||
if (!empty($associations)) {
|
||||
$form->setFieldAttribute('language', 'readonly', 'true');
|
||||
$form->setFieldAttribute('language', 'filter', 'unset');
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get contact data.
|
||||
*
|
||||
* @param integer $itemId The id of the contact.
|
||||
*
|
||||
* @return mixed Contact item data object on success, false on failure.
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getItem($itemId = null)
|
||||
{
|
||||
$itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('contact.id');
|
||||
|
||||
// Get a row instance.
|
||||
$table = $this->getTable();
|
||||
|
||||
// Attempt to load the row.
|
||||
try {
|
||||
if (!$table->load($itemId)) {
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$properties = $table->getProperties();
|
||||
$value = ArrayHelper::toObject($properties, \Joomla\CMS\Object\CMSObject::class);
|
||||
|
||||
// Convert field to Registry.
|
||||
$value->params = new Registry($value->params);
|
||||
|
||||
// Convert the metadata field to an array.
|
||||
$registry = new Registry($value->metadata);
|
||||
$value->metadata = $registry->toArray();
|
||||
|
||||
if ($itemId) {
|
||||
$value->tags = new TagsHelper();
|
||||
$value->tags->getTagIds($value->id, 'com_contact.contact');
|
||||
$value->metadata['tags'] = $value->tags;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the return URL.
|
||||
*
|
||||
* @return string The return URL.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getReturnPage()
|
||||
{
|
||||
return base64_encode($this->getState('return_page', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
* @param array $data The form data.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
// Associations are not edited in frontend ATM so we have to inherit them
|
||||
if (
|
||||
Associations::isEnabled() && !empty($data['id'])
|
||||
&& $associations = Associations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $data['id'])
|
||||
) {
|
||||
foreach ($associations as $tag => $associated) {
|
||||
$associations[$tag] = (int) $associated->id;
|
||||
}
|
||||
|
||||
$data['associations'] = $associations;
|
||||
}
|
||||
|
||||
return parent::save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
|
||||
// Load state from the request.
|
||||
$pk = $input->getInt('id');
|
||||
$this->setState('contact.id', $pk);
|
||||
|
||||
$this->setState('contact.catid', $input->getInt('catid'));
|
||||
|
||||
$return = $input->get('return', '', 'base64');
|
||||
$this->setState('return_page', base64_decode($return));
|
||||
|
||||
// Load the parameters.
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
$this->setState('layout', $input->getString('layout'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows preprocessing of the JForm object.
|
||||
*
|
||||
* @param Form $form The form object
|
||||
* @param array $data The data to be merged into the form object
|
||||
* @param string $group The plugin group to be executed
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function preprocessForm(Form $form, $data, $group = 'contact')
|
||||
{
|
||||
if (!Multilanguage::isEnabled()) {
|
||||
$form->setFieldAttribute('language', 'type', 'hidden');
|
||||
$form->setFieldAttribute('language', 'default', '*');
|
||||
}
|
||||
|
||||
parent::preprocessForm($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a table object, load it if necessary.
|
||||
*
|
||||
* @param string $name The table name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $options Configuration array for model. Optional.
|
||||
*
|
||||
* @return bool|Table A Table object
|
||||
*
|
||||
* @since 4.0.0
|
||||
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getTable($name = 'Contact', $prefix = 'Administrator', $options = [])
|
||||
{
|
||||
return parent::getTable($name, $prefix, $options);
|
||||
}
|
||||
}
|
||||
59
components/com_contact/src/Rule/ContactEmailMessageRule.php
Normal file
59
components/com_contact/src/Rule/ContactEmailMessageRule.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Rule;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Form\FormRule;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\String\StringHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* FormRule for com_contact to make sure the message body contains no banned word.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ContactEmailMessageRule extends FormRule
|
||||
{
|
||||
/**
|
||||
* Method to test a message for banned words
|
||||
*
|
||||
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
|
||||
* @param mixed $value The form field value to validate.
|
||||
* @param string $group The field name group control value. This acts as an array container for the field.
|
||||
* For example if the field has name="foo" and the group value is set to "bar" then the
|
||||
* full field name would end up being "bar[foo]".
|
||||
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
|
||||
* @param Form $form The form object for which the field is being tested.
|
||||
*
|
||||
* @return boolean True if the value is valid, false otherwise.
|
||||
*/
|
||||
public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
|
||||
{
|
||||
$params = ComponentHelper::getParams('com_contact');
|
||||
$banned = $params->get('banned_text');
|
||||
|
||||
if ($banned) {
|
||||
foreach (explode(';', $banned) as $item) {
|
||||
$item = trim($item);
|
||||
if ($item != '' && StringHelper::stristr($value, $item) !== false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
63
components/com_contact/src/Rule/ContactEmailRule.php
Normal file
63
components/com_contact/src/Rule/ContactEmailRule.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Rule;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Form\Rule\EmailRule;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\String\StringHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* FormRule for com_contact to make sure the email address is not blocked.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ContactEmailRule extends EmailRule
|
||||
{
|
||||
/**
|
||||
* Method to test for banned email addresses
|
||||
*
|
||||
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
|
||||
* @param mixed $value The form field value to validate.
|
||||
* @param string $group The field name group control value. This acts as an array container for the field.
|
||||
* For example if the field has name="foo" and the group value is set to "bar" then the
|
||||
* full field name would end up being "bar[foo]".
|
||||
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
|
||||
* @param Form $form The form object for which the field is being tested.
|
||||
*
|
||||
* @return boolean True if the value is valid, false otherwise.
|
||||
*/
|
||||
public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
|
||||
{
|
||||
if (!parent::test($element, $value, $group, $input, $form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$params = ComponentHelper::getParams('com_contact');
|
||||
$banned = $params->get('banned_email');
|
||||
|
||||
if ($banned) {
|
||||
foreach (explode(';', $banned) as $item) {
|
||||
$item = trim($item);
|
||||
if ($item != '' && StringHelper::stristr($value, $item) !== false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
59
components/com_contact/src/Rule/ContactEmailSubjectRule.php
Normal file
59
components/com_contact/src/Rule/ContactEmailSubjectRule.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Rule;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Form\FormRule;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\String\StringHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* FormRule for com_contact to make sure the subject contains no banned word.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ContactEmailSubjectRule extends FormRule
|
||||
{
|
||||
/**
|
||||
* Method to test for a banned subject
|
||||
*
|
||||
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
|
||||
* @param mixed $value The form field value to validate.
|
||||
* @param string $group The field name group control value. This acts as an array container for the field.
|
||||
* For example if the field has name="foo" and the group value is set to "bar" then the
|
||||
* full field name would end up being "bar[foo]".
|
||||
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
|
||||
* @param Form $form The form object for which the field is being tested.
|
||||
*
|
||||
* @return boolean True if the value is valid, false otherwise
|
||||
*/
|
||||
public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
|
||||
{
|
||||
$params = ComponentHelper::getParams('com_contact');
|
||||
$banned = $params->get('banned_subject');
|
||||
|
||||
if ($banned) {
|
||||
foreach (explode(';', $banned) as $item) {
|
||||
$item = trim($item);
|
||||
if ($item != '' && StringHelper::stristr($value, $item) !== false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
41
components/com_contact/src/Service/Category.php
Normal file
41
components/com_contact/src/Service/Category.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Service;
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact Component Category Tree
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class Category extends Categories
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $options Array of options
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
{
|
||||
$options['table'] = '#__contact_details';
|
||||
$options['extension'] = 'com_contact';
|
||||
$options['statefield'] = 'published';
|
||||
|
||||
parent::__construct($options);
|
||||
}
|
||||
}
|
||||
287
components/com_contact/src/Service/Router.php
Normal file
287
components/com_contact/src/Service/Router.php
Normal file
@ -0,0 +1,287 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\Service;
|
||||
|
||||
use Joomla\CMS\Application\SiteApplication;
|
||||
use Joomla\CMS\Categories\CategoryFactoryInterface;
|
||||
use Joomla\CMS\Categories\CategoryInterface;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Component\Router\RouterView;
|
||||
use Joomla\CMS\Component\Router\RouterViewConfiguration;
|
||||
use Joomla\CMS\Component\Router\Rules\MenuRules;
|
||||
use Joomla\CMS\Component\Router\Rules\NomenuRules;
|
||||
use Joomla\CMS\Component\Router\Rules\StandardRules;
|
||||
use Joomla\CMS\Menu\AbstractMenu;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Routing class from com_contact
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
class Router extends RouterView
|
||||
{
|
||||
/**
|
||||
* Flag to remove IDs
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $noIDs = false;
|
||||
|
||||
/**
|
||||
* The category factory
|
||||
*
|
||||
* @var CategoryFactoryInterface
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $categoryFactory;
|
||||
|
||||
/**
|
||||
* The category cache
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $categoryCache = [];
|
||||
|
||||
/**
|
||||
* The db
|
||||
*
|
||||
* @var DatabaseInterface
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* Content Component router constructor
|
||||
*
|
||||
* @param SiteApplication $app The application object
|
||||
* @param AbstractMenu $menu The menu object to work with
|
||||
* @param CategoryFactoryInterface $categoryFactory The category object
|
||||
* @param DatabaseInterface $db The database object
|
||||
*/
|
||||
public function __construct(SiteApplication $app, AbstractMenu $menu, CategoryFactoryInterface $categoryFactory, DatabaseInterface $db)
|
||||
{
|
||||
$this->categoryFactory = $categoryFactory;
|
||||
$this->db = $db;
|
||||
|
||||
$params = ComponentHelper::getParams('com_contact');
|
||||
$this->noIDs = (bool) $params->get('sef_ids');
|
||||
$categories = new RouterViewConfiguration('categories');
|
||||
$categories->setKey('id');
|
||||
$this->registerView($categories);
|
||||
$category = new RouterViewConfiguration('category');
|
||||
$category->setKey('id')->setParent($categories, 'catid')->setNestable();
|
||||
$this->registerView($category);
|
||||
$contact = new RouterViewConfiguration('contact');
|
||||
$contact->setKey('id')->setParent($category, 'catid');
|
||||
$this->registerView($contact);
|
||||
$this->registerView(new RouterViewConfiguration('featured'));
|
||||
$form = new RouterViewConfiguration('form');
|
||||
$form->setKey('id');
|
||||
$this->registerView($form);
|
||||
|
||||
parent::__construct($app, $menu);
|
||||
|
||||
$this->attachRule(new MenuRules($this));
|
||||
$this->attachRule(new StandardRules($this));
|
||||
$this->attachRule(new NomenuRules($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a category
|
||||
*
|
||||
* @param string $id ID of the category to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*/
|
||||
public function getCategorySegment($id, $query)
|
||||
{
|
||||
$category = $this->getCategories()->get($id);
|
||||
|
||||
if ($category) {
|
||||
$path = array_reverse($category->getPath(), true);
|
||||
$path[0] = '1:root';
|
||||
|
||||
if ($this->noIDs) {
|
||||
foreach ($path as &$segment) {
|
||||
list($id, $segment) = explode(':', $segment, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a category
|
||||
*
|
||||
* @param string $id ID of the category to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*/
|
||||
public function getCategoriesSegment($id, $query)
|
||||
{
|
||||
return $this->getCategorySegment($id, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a contact
|
||||
*
|
||||
* @param string $id ID of the contact to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*/
|
||||
public function getContactSegment($id, $query)
|
||||
{
|
||||
if (!strpos($id, ':')) {
|
||||
$id = (int) $id;
|
||||
$dbquery = $this->db->getQuery(true);
|
||||
$dbquery->select($this->db->quoteName('alias'))
|
||||
->from($this->db->quoteName('#__contact_details'))
|
||||
->where($this->db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
$this->db->setQuery($dbquery);
|
||||
|
||||
$id .= ':' . $this->db->loadResult();
|
||||
}
|
||||
|
||||
if ($this->noIDs) {
|
||||
list($void, $segment) = explode(':', $id, 2);
|
||||
|
||||
return [$void => $segment];
|
||||
}
|
||||
|
||||
return [(int) $id => $id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a form
|
||||
*
|
||||
* @param string $id ID of the contact form to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getFormSegment($id, $query)
|
||||
{
|
||||
return $this->getContactSegment($id, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the id for a category
|
||||
*
|
||||
* @param string $segment Segment to retrieve the ID for
|
||||
* @param array $query The request that is parsed right now
|
||||
*
|
||||
* @return mixed The id of this item or false
|
||||
*/
|
||||
public function getCategoryId($segment, $query)
|
||||
{
|
||||
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) {
|
||||
return $child->id;
|
||||
}
|
||||
} else {
|
||||
if ($child->id == (int) $segment) {
|
||||
return $child->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a category
|
||||
*
|
||||
* @param string $segment Segment to retrieve the ID for
|
||||
* @param array $query The request that is parsed right now
|
||||
*
|
||||
* @return mixed The id of this item or false
|
||||
*/
|
||||
public function getCategoriesId($segment, $query)
|
||||
{
|
||||
return $this->getCategoryId($segment, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a contact
|
||||
*
|
||||
* @param string $segment Segment of the contact to retrieve the ID for
|
||||
* @param array $query The request that is parsed right now
|
||||
*
|
||||
* @return mixed The id of this item or false
|
||||
*/
|
||||
public function getContactId($segment, $query)
|
||||
{
|
||||
if ($this->noIDs) {
|
||||
$dbquery = $this->db->getQuery(true);
|
||||
$dbquery->select($this->db->quoteName('id'))
|
||||
->from($this->db->quoteName('#__contact_details'))
|
||||
->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();
|
||||
}
|
||||
|
||||
return (int) $segment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get categories from cache
|
||||
*
|
||||
* @param array $options The options for retrieving categories
|
||||
*
|
||||
* @return CategoryInterface The object containing categories
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private function getCategories(array $options = []): CategoryInterface
|
||||
{
|
||||
$key = serialize($options);
|
||||
|
||||
if (!isset($this->categoryCache[$key])) {
|
||||
$this->categoryCache[$key] = $this->categoryFactory->createCategory($options);
|
||||
}
|
||||
|
||||
return $this->categoryCache[$key];
|
||||
}
|
||||
}
|
||||
39
components/com_contact/src/View/Categories/HtmlView.php
Normal file
39
components/com_contact/src/View/Categories/HtmlView.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\View\Categories;
|
||||
|
||||
use Joomla\CMS\MVC\View\CategoriesView;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact categories view.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends CategoriesView
|
||||
{
|
||||
/**
|
||||
* Language key for default page heading
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $pageHeading = 'COM_CONTACT_DEFAULT_PAGE_TITLE';
|
||||
|
||||
/**
|
||||
* @var string The name of the extension for the category
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $extension = 'com_contact';
|
||||
}
|
||||
48
components/com_contact/src/View/Category/FeedView.php
Normal file
48
components/com_contact/src/View/Category/FeedView.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\View\Category;
|
||||
|
||||
use Joomla\CMS\MVC\View\CategoryFeedView;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* HTML View class for the Contact component
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class FeedView extends CategoryFeedView
|
||||
{
|
||||
/**
|
||||
* @var string The name of the view to link individual items to
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $viewName = 'contact';
|
||||
|
||||
/**
|
||||
* Method to reconcile non standard names from components to usage in this class.
|
||||
* Typically overridden in the component feed view class.
|
||||
*
|
||||
* @param object $item The item for a feed, an element of the $items array.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
protected function reconcileNames($item)
|
||||
{
|
||||
parent::reconcileNames($item);
|
||||
|
||||
$item->description = $item->address;
|
||||
}
|
||||
}
|
||||
133
components/com_contact/src/View/Category/HtmlView.php
Normal file
133
components/com_contact/src/View/Category/HtmlView.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\View\Category;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Mail\MailHelper;
|
||||
use Joomla\CMS\MVC\View\CategoryView;
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* HTML View class for the Contacts component
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class HtmlView extends CategoryView
|
||||
{
|
||||
/**
|
||||
* @var string The name of the extension for the category
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $extension = 'com_contact';
|
||||
|
||||
/**
|
||||
* @var string Default title to use for page title
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $defaultPageTitle = 'COM_CONTACT_DEFAULT_PAGE_TITLE';
|
||||
|
||||
/**
|
||||
* @var string The name of the view to link individual items to
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $viewName = 'contact';
|
||||
|
||||
/**
|
||||
* Run the standard Joomla plugins
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.5
|
||||
*/
|
||||
protected $runPlugins = true;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
parent::commonCategoryDisplay();
|
||||
|
||||
// Flag indicates to not add limitstart=0 to URL
|
||||
$this->pagination->hideEmptyLimitstart = true;
|
||||
|
||||
// Prepare the data.
|
||||
// Compute the contact slug.
|
||||
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('show_email_headings', 0) == 1) {
|
||||
$item->email_to = trim($item->email_to);
|
||||
|
||||
if (!empty($item->email_to) && MailHelper::isEmailAddress($item->email_to)) {
|
||||
$item->email_to = HTMLHelper::_('email.cloak', $item->email_to);
|
||||
} else {
|
||||
$item->email_to = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareDocument()
|
||||
{
|
||||
parent::prepareDocument();
|
||||
|
||||
parent::addFeed();
|
||||
|
||||
if ($this->menuItemMatchCategory) {
|
||||
// If the active menu item is linked directly to the category being displayed, no further process is needed
|
||||
return;
|
||||
}
|
||||
|
||||
// Get ID of the category from active menu item
|
||||
$menu = $this->menu;
|
||||
|
||||
if (
|
||||
$menu && $menu->component == 'com_contact' && isset($menu->query['view'])
|
||||
&& \in_array($menu->query['view'], ['categories', 'category'])
|
||||
) {
|
||||
$id = $menu->query['id'];
|
||||
} else {
|
||||
$id = 0;
|
||||
}
|
||||
|
||||
$path = [['title' => $this->category->title, 'link' => '']];
|
||||
$category = $this->category->getParent();
|
||||
|
||||
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) {
|
||||
$this->pathway->addItem($item['title'], $item['link']);
|
||||
}
|
||||
}
|
||||
}
|
||||
471
components/com_contact/src/View/Contact/HtmlView.php
Normal file
471
components/com_contact/src/View/Contact/HtmlView.php
Normal file
@ -0,0 +1,471 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\View\Contact;
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\User\UserFactoryAwareInterface;
|
||||
use Joomla\CMS\User\UserFactoryAwareTrait;
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* HTML Contact View class for the Contact component
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView implements UserFactoryAwareInterface
|
||||
{
|
||||
use UserFactoryAwareTrait;
|
||||
|
||||
/**
|
||||
* The item model state
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The form object for the contact item
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* The item object details
|
||||
*
|
||||
* @var \Joomla\CMS\Object\CMSObject
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* The page to return to on submission
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @todo Implement this functionality
|
||||
*/
|
||||
protected $return_page = '';
|
||||
|
||||
/**
|
||||
* Should we show a captcha form for the submission of the contact request?
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 3.6.3
|
||||
*/
|
||||
protected $captchaEnabled = false;
|
||||
|
||||
/**
|
||||
* The page parameters
|
||||
*
|
||||
* @var \Joomla\Registry\Registry|null
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $params = null;
|
||||
|
||||
/**
|
||||
* The user object
|
||||
*
|
||||
* @var \Joomla\CMS\User\User
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Other contacts in this contacts category
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $contacts;
|
||||
|
||||
/**
|
||||
* The page class suffix
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $pageclass_sfx = '';
|
||||
|
||||
/**
|
||||
* The flag to mark if the active menu item is linked to the contact being displayed
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $menuItemMatchContact = false;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void|boolean
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$user = $this->getCurrentUser();
|
||||
$state = $this->get('State');
|
||||
$item = $this->get('Item');
|
||||
$this->form = $this->get('Form');
|
||||
$params = $state->get('params');
|
||||
$contacts = [];
|
||||
|
||||
$temp = clone $params;
|
||||
|
||||
$active = $app->getMenu()->getActive();
|
||||
|
||||
// If the current view is the active item and a contact view for this contact, then the menu item params take priority
|
||||
if (
|
||||
$active
|
||||
&& $active->component == 'com_contact'
|
||||
&& isset($active->query['view'], $active->query['id'])
|
||||
&& $active->query['view'] == 'contact'
|
||||
&& $active->query['id'] == $item->id
|
||||
) {
|
||||
$this->menuItemMatchContact = true;
|
||||
|
||||
// Load layout from active query (in case it is an alternative menu item)
|
||||
if (isset($active->query['layout'])) {
|
||||
$this->setLayout($active->query['layout']);
|
||||
} elseif ($layout = $item->params->get('contact_layout')) {
|
||||
// Check for alternative layout of contact
|
||||
$this->setLayout($layout);
|
||||
}
|
||||
|
||||
$item->params->merge($temp);
|
||||
} else {
|
||||
// Merge so that contact params take priority
|
||||
$temp->merge($item->params);
|
||||
$item->params = $temp;
|
||||
|
||||
if ($layout = $item->params->get('contact_layout')) {
|
||||
$this->setLayout($layout);
|
||||
}
|
||||
}
|
||||
|
||||
// Collect extra contact information when this information is required
|
||||
if ($item && $item->params->get('show_contact_list')) {
|
||||
// Get Category Model data
|
||||
/** @var \Joomla\Component\Contact\Site\Model\CategoryModel $categoryModel */
|
||||
$categoryModel = $app->bootComponent('com_contact')->getMVCFactory()
|
||||
->createModel('Category', 'Site', ['ignore_request' => true]);
|
||||
|
||||
$categoryModel->setState('category.id', $item->catid);
|
||||
$categoryModel->setState('list.ordering', 'a.name');
|
||||
$categoryModel->setState('list.direction', 'asc');
|
||||
$categoryModel->setState('filter.published', 1);
|
||||
|
||||
$contacts = $categoryModel->getItems();
|
||||
}
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
// Check if access is not public
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
|
||||
if (!\in_array($item->access, $groups) || !\in_array($item->category_access, $groups)) {
|
||||
$app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error');
|
||||
$app->setHeader('status', 403, true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$options['category_id'] = $item->catid;
|
||||
$options['order by'] = 'a.default_con DESC, a.ordering ASC';
|
||||
|
||||
/**
|
||||
* Handle email cloaking
|
||||
*
|
||||
* Keep a copy of the raw email address so it can
|
||||
* still be accessed in the layout if needed.
|
||||
*/
|
||||
$item->email_raw = $item->email_to;
|
||||
|
||||
if ($item->email_to && $item->params->get('show_email')) {
|
||||
$item->email_to = HTMLHelper::_('email.cloak', $item->email_to, (bool) $item->params->get('add_mailto_link', true));
|
||||
}
|
||||
|
||||
if (
|
||||
$item->params->get('show_street_address') || $item->params->get('show_suburb') || $item->params->get('show_state')
|
||||
|| $item->params->get('show_postcode') || $item->params->get('show_country')
|
||||
) {
|
||||
if (!empty($item->address) || !empty($item->suburb) || !empty($item->state) || !empty($item->country) || !empty($item->postcode)) {
|
||||
$item->params->set('address_check', 1);
|
||||
}
|
||||
} else {
|
||||
$item->params->set('address_check', 0);
|
||||
}
|
||||
|
||||
// Manage the display mode for contact detail groups
|
||||
switch ($item->params->get('contact_icons')) {
|
||||
case 1:
|
||||
// Text
|
||||
$item->params->set('marker_address', Text::_('COM_CONTACT_ADDRESS') . ': ');
|
||||
$item->params->set('marker_email', Text::_('JGLOBAL_EMAIL') . ': ');
|
||||
$item->params->set('marker_telephone', Text::_('COM_CONTACT_TELEPHONE') . ': ');
|
||||
$item->params->set('marker_fax', Text::_('COM_CONTACT_FAX') . ': ');
|
||||
$item->params->set('marker_mobile', Text::_('COM_CONTACT_MOBILE') . ': ');
|
||||
$item->params->set('marker_webpage', Text::_('COM_CONTACT_WEBPAGE') . ': ');
|
||||
$item->params->set('marker_misc', Text::_('COM_CONTACT_OTHER_INFORMATION') . ': ');
|
||||
$item->params->set('marker_class', 'jicons-text');
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// None
|
||||
$item->params->set('marker_address', '');
|
||||
$item->params->set('marker_email', '');
|
||||
$item->params->set('marker_telephone', '');
|
||||
$item->params->set('marker_mobile', '');
|
||||
$item->params->set('marker_fax', '');
|
||||
$item->params->set('marker_misc', '');
|
||||
$item->params->set('marker_webpage', '');
|
||||
$item->params->set('marker_class', 'jicons-none');
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($item->params->get('icon_address')) {
|
||||
$item->params->set(
|
||||
'marker_address',
|
||||
HTMLHelper::_('image', $item->params->get('icon_address', ''), Text::_('COM_CONTACT_ADDRESS'), false)
|
||||
);
|
||||
}
|
||||
|
||||
if ($item->params->get('icon_email')) {
|
||||
$item->params->set(
|
||||
'marker_email',
|
||||
HTMLHelper::_('image', $item->params->get('icon_email', ''), Text::_('COM_CONTACT_EMAIL'), false)
|
||||
);
|
||||
}
|
||||
|
||||
if ($item->params->get('icon_telephone')) {
|
||||
$item->params->set(
|
||||
'marker_telephone',
|
||||
HTMLHelper::_('image', $item->params->get('icon_telephone', ''), Text::_('COM_CONTACT_TELEPHONE'), false)
|
||||
);
|
||||
}
|
||||
|
||||
if ($item->params->get('icon_fax', '')) {
|
||||
$item->params->set(
|
||||
'marker_fax',
|
||||
HTMLHelper::_('image', $item->params->get('icon_fax', ''), Text::_('COM_CONTACT_FAX'), false)
|
||||
);
|
||||
}
|
||||
|
||||
if ($item->params->get('icon_misc')) {
|
||||
$item->params->set(
|
||||
'marker_misc',
|
||||
HTMLHelper::_('image', $item->params->get('icon_misc', ''), Text::_('COM_CONTACT_OTHER_INFORMATION'), false)
|
||||
);
|
||||
}
|
||||
|
||||
if ($item->params->get('icon_mobile')) {
|
||||
$item->params->set(
|
||||
'marker_mobile',
|
||||
HTMLHelper::_('image', $item->params->get('icon_mobile', ''), Text::_('COM_CONTACT_MOBILE'), false)
|
||||
);
|
||||
}
|
||||
|
||||
if ($item->params->get('icon_webpage')) {
|
||||
$item->params->set(
|
||||
'marker_webpage',
|
||||
HTMLHelper::_('image', $item->params->get('icon_webpage', ''), Text::_('COM_CONTACT_WEBPAGE'), false)
|
||||
);
|
||||
}
|
||||
|
||||
$item->params->set('marker_class', 'jicons-icons');
|
||||
break;
|
||||
}
|
||||
|
||||
// Add links to contacts
|
||||
if ($item->params->get('show_contact_list') && \count($contacts) > 1) {
|
||||
foreach ($contacts as &$contact) {
|
||||
$contact->link = Route::_(RouteHelper::getContactRoute($contact->slug, $contact->catid, $contact->language));
|
||||
}
|
||||
|
||||
$item->link = Route::_(RouteHelper::getContactRoute($item->slug, $item->catid, $item->language), false);
|
||||
}
|
||||
|
||||
// Process the content plugins.
|
||||
PluginHelper::importPlugin('content');
|
||||
$offset = $state->get('list.offset');
|
||||
|
||||
// Fix for where some plugins require a text attribute
|
||||
$item->text = '';
|
||||
|
||||
if (!empty($item->misc)) {
|
||||
$item->text = $item->misc;
|
||||
}
|
||||
|
||||
$app->triggerEvent('onContentPrepare', ['com_contact.contact', &$item, &$item->params, $offset]);
|
||||
|
||||
// Store the events for later
|
||||
$item->event = new \stdClass();
|
||||
$results = $app->triggerEvent('onContentAfterTitle', ['com_contact.contact', &$item, &$item->params, $offset]);
|
||||
$item->event->afterDisplayTitle = trim(implode("\n", $results));
|
||||
|
||||
$results = $app->triggerEvent('onContentBeforeDisplay', ['com_contact.contact', &$item, &$item->params, $offset]);
|
||||
$item->event->beforeDisplayContent = trim(implode("\n", $results));
|
||||
|
||||
$results = $app->triggerEvent('onContentAfterDisplay', ['com_contact.contact', &$item, &$item->params, $offset]);
|
||||
$item->event->afterDisplayContent = trim(implode("\n", $results));
|
||||
|
||||
if (!empty($item->text)) {
|
||||
$item->misc = $item->text;
|
||||
}
|
||||
|
||||
$contactUser = null;
|
||||
|
||||
if ($item->params->get('show_user_custom_fields') && $item->user_id && $contactUser = $this->getUserFactory()->loadUserById($item->user_id)) {
|
||||
$contactUser->text = '';
|
||||
$app->triggerEvent('onContentPrepare', ['com_users.user', &$contactUser, &$item->params, 0]);
|
||||
|
||||
if (!isset($contactUser->jcfields)) {
|
||||
$contactUser->jcfields = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($item->params->get('pageclass_sfx', ''));
|
||||
|
||||
$this->params = &$item->params;
|
||||
$this->state = &$state;
|
||||
$this->item = &$item;
|
||||
$this->user = &$user;
|
||||
$this->contacts = &$contacts;
|
||||
$this->contactUser = $contactUser;
|
||||
|
||||
$model = $this->getModel();
|
||||
$model->hit();
|
||||
|
||||
$captchaSet = $item->params->get('captcha', $app->get('captcha', '0'));
|
||||
|
||||
foreach (PluginHelper::getPlugin('captcha') as $plugin) {
|
||||
if ($captchaSet === $plugin->name) {
|
||||
$this->captchaEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$pathway = $app->getPathway();
|
||||
|
||||
// Because the application sets a default page title,
|
||||
// we need to get it from the menu item itself
|
||||
$menu = $app->getMenu()->getActive();
|
||||
|
||||
if ($menu) {
|
||||
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
|
||||
} else {
|
||||
$this->params->def('page_heading', Text::_('COM_CONTACT_DEFAULT_PAGE_TITLE'));
|
||||
}
|
||||
|
||||
$title = $this->params->get('page_title', '');
|
||||
|
||||
// If the menu item does not concern this contact
|
||||
if (!$this->menuItemMatchContact) {
|
||||
// If this is not a single contact menu item, set the page title to the contact title
|
||||
if ($this->item->name) {
|
||||
$title = $this->item->name;
|
||||
}
|
||||
|
||||
// Get ID of the category from active menu item
|
||||
if (
|
||||
$menu && $menu->component == 'com_contact' && isset($menu->query['view'])
|
||||
&& \in_array($menu->query['view'], ['categories', 'category'])
|
||||
) {
|
||||
$id = $menu->query['id'];
|
||||
} else {
|
||||
$id = 0;
|
||||
}
|
||||
|
||||
$path = [['title' => $this->item->name, 'link' => '']];
|
||||
$category = Categories::getInstance('Contact')->get($this->item->catid);
|
||||
|
||||
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) {
|
||||
$pathway->addItem($item['title'], $item['link']);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($title)) {
|
||||
$title = $this->item->name;
|
||||
}
|
||||
|
||||
$this->setDocumentTitle($title);
|
||||
|
||||
if ($this->item->metadesc) {
|
||||
$this->getDocument()->setDescription($this->item->metadesc);
|
||||
} elseif ($this->params->get('menu-meta_description')) {
|
||||
$this->getDocument()->setDescription($this->params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($this->params->get('robots')) {
|
||||
$this->getDocument()->setMetaData('robots', $this->params->get('robots'));
|
||||
}
|
||||
|
||||
$mdata = $this->item->metadata->toArray();
|
||||
|
||||
foreach ($mdata as $k => $v) {
|
||||
if ($v) {
|
||||
$this->getDocument()->setMetaData($k, $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
109
components/com_contact/src/View/Contact/VcfView.php
Normal file
109
components/com_contact/src/View/Contact/VcfView.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\View\Contact;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\View\AbstractView;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View to create a VCF for a contact item
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class VcfView extends AbstractView
|
||||
{
|
||||
/**
|
||||
* The contact item
|
||||
*
|
||||
* @var \Joomla\CMS\Object\CMSObject
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws GenericDataException
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// Get model data.
|
||||
$item = $this->get('Item');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$this->getDocument()->setMimeEncoding('text/directory', true);
|
||||
|
||||
// Compute lastname, firstname and middlename
|
||||
$item->name = trim($item->name);
|
||||
|
||||
// "Lastname, Firstname Middlename" format support
|
||||
// e.g. "de Gaulle, Charles"
|
||||
$namearray = explode(',', $item->name);
|
||||
|
||||
if (\count($namearray) > 1) {
|
||||
$lastname = $namearray[0];
|
||||
$card_name = $lastname;
|
||||
$name_and_midname = trim($namearray[1]);
|
||||
|
||||
$firstname = '';
|
||||
|
||||
if (!empty($name_and_midname)) {
|
||||
$namearray = explode(' ', $name_and_midname);
|
||||
|
||||
$firstname = $namearray[0];
|
||||
$middlename = (\count($namearray) > 1) ? $namearray[1] : '';
|
||||
$card_name = $firstname . ' ' . ($middlename ? $middlename . ' ' : '') . $card_name;
|
||||
}
|
||||
} else {
|
||||
// "Firstname Middlename Lastname" format support
|
||||
$namearray = explode(' ', $item->name);
|
||||
|
||||
$middlename = (\count($namearray) > 2) ? $namearray[1] : '';
|
||||
$firstname = array_shift($namearray);
|
||||
$lastname = \count($namearray) ? end($namearray) : '';
|
||||
$card_name = $firstname . ($middlename ? ' ' . $middlename : '') . ($lastname ? ' ' . $lastname : '');
|
||||
}
|
||||
|
||||
$rev = date('c', strtotime($item->modified));
|
||||
|
||||
Factory::getApplication()->setHeader('Content-disposition', 'attachment; filename="' . $card_name . '.vcf"', true);
|
||||
|
||||
$vcard = [];
|
||||
$vcard[] .= 'BEGIN:VCARD';
|
||||
$vcard[] .= 'VERSION:3.0';
|
||||
$vcard[] = 'N:' . $lastname . ';' . $firstname . ';' . $middlename;
|
||||
$vcard[] = 'FN:' . $item->name;
|
||||
$vcard[] = 'TITLE:' . $item->con_position;
|
||||
$vcard[] = 'TEL;TYPE=WORK,VOICE:' . $item->telephone;
|
||||
$vcard[] = 'TEL;TYPE=WORK,FAX:' . $item->fax;
|
||||
$vcard[] = 'TEL;TYPE=WORK,MOBILE:' . $item->mobile;
|
||||
$vcard[] = 'ADR;TYPE=WORK:;;' . $item->address . ';' . $item->suburb . ';' . $item->state . ';' . $item->postcode . ';' . $item->country;
|
||||
$vcard[] = 'LABEL;TYPE=WORK:' . $item->address . "\n" . $item->suburb . "\n" . $item->state . "\n" . $item->postcode . "\n" . $item->country;
|
||||
$vcard[] = 'EMAIL;TYPE=PREF,INTERNET:' . $item->email_to;
|
||||
$vcard[] = 'URL:' . $item->webpage;
|
||||
$vcard[] = 'REV:' . $rev . 'Z';
|
||||
$vcard[] = 'END:VCARD';
|
||||
|
||||
echo implode("\n", $vcard);
|
||||
}
|
||||
}
|
||||
173
components/com_contact/src/View/Featured/HtmlView.php
Normal file
173
components/com_contact/src/View/Featured/HtmlView.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\View\Featured;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Mail\MailHelper;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Featured View class
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The item model state
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The item details
|
||||
*
|
||||
* @var \Joomla\CMS\Object\CMSObject
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var \Joomla\CMS\Pagination\Pagination
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* The page parameters
|
||||
*
|
||||
* @var \Joomla\Registry\Registry|null
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $params = null;
|
||||
|
||||
/**
|
||||
* The page class suffix
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $pageclass_sfx = '';
|
||||
|
||||
/**
|
||||
* Method to display the view.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$params = $app->getParams();
|
||||
|
||||
// Get some data from the models
|
||||
$state = $this->get('State');
|
||||
$items = $this->get('Items');
|
||||
$category = $this->get('Category');
|
||||
$children = $this->get('Children');
|
||||
$parent = $this->get('Parent');
|
||||
$pagination = $this->get('Pagination');
|
||||
|
||||
// Flag indicates to not add limitstart=0 to URL
|
||||
$pagination->hideEmptyLimitstart = true;
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
// Prepare the data.
|
||||
// Compute the contact slug.
|
||||
for ($i = 0, $n = \count($items); $i < $n; $i++) {
|
||||
$item = &$items[$i];
|
||||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
|
||||
$temp = $item->params;
|
||||
$item->params = clone $params;
|
||||
$item->params->merge($temp);
|
||||
|
||||
if ($item->params->get('show_email', 0) == 1) {
|
||||
$item->email_to = trim($item->email_to);
|
||||
|
||||
if (!empty($item->email_to) && MailHelper::isEmailAddress($item->email_to)) {
|
||||
$item->email_to = HTMLHelper::_('email.cloak', $item->email_to);
|
||||
} else {
|
||||
$item->email_to = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx', ''), ENT_COMPAT, 'UTF-8');
|
||||
|
||||
$maxLevel = $params->get('maxLevel', -1);
|
||||
$this->maxLevel = &$maxLevel;
|
||||
$this->state = &$state;
|
||||
$this->items = &$items;
|
||||
$this->category = &$category;
|
||||
$this->children = &$children;
|
||||
$this->params = &$params;
|
||||
$this->parent = &$parent;
|
||||
$this->pagination = &$pagination;
|
||||
|
||||
$this->_prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
// Because the application sets a default page title,
|
||||
// we need to get it from the menu item itself
|
||||
$menu = Factory::getApplication()->getMenu()->getActive();
|
||||
|
||||
if ($menu) {
|
||||
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
|
||||
} else {
|
||||
$this->params->def('page_heading', Text::_('COM_CONTACT_DEFAULT_PAGE_TITLE'));
|
||||
}
|
||||
|
||||
$this->setDocumentTitle($this->params->get('page_title', ''));
|
||||
|
||||
if ($this->params->get('menu-meta_description')) {
|
||||
$this->getDocument()->setDescription($this->params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($this->params->get('robots')) {
|
||||
$this->getDocument()->setMetaData('robots', $this->params->get('robots'));
|
||||
}
|
||||
}
|
||||
}
|
||||
178
components/com_contact/src/View/Form/HtmlView.php
Normal file
178
components/com_contact/src/View/Form/HtmlView.php
Normal file
@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Site\View\Form;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\Component\Contact\Administrator\Helper\ContactHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* HTML Contact View class for the Contact component
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* @var object
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $return_page;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $pageclass_sfx;
|
||||
|
||||
/**
|
||||
* @var \Joomla\Registry\Registry
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* @var \Joomla\Registry\Registry
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $params;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void|boolean
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Get model data.
|
||||
$this->state = $this->get('State');
|
||||
$this->item = $this->get('Item');
|
||||
$this->form = $this->get('Form');
|
||||
$this->return_page = $this->get('ReturnPage');
|
||||
|
||||
if (empty($this->item->id)) {
|
||||
$authorised = $user->authorise('core.create', 'com_contact') || \count($user->getAuthorisedCategories('com_contact', 'core.create'));
|
||||
} else {
|
||||
// Since we don't track these assets at the item level, use the category id.
|
||||
$canDo = ContactHelper::getActions('com_contact', 'category', $this->item->catid);
|
||||
$authorised = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by === $user->id);
|
||||
}
|
||||
|
||||
if ($authorised !== true) {
|
||||
$app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error');
|
||||
$app->setHeader('status', 403, true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->item->tags = new TagsHelper();
|
||||
|
||||
if (!empty($this->item->id)) {
|
||||
$this->item->tags->getItemTags('com_contact.contact', $this->item->id);
|
||||
}
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
$app->enqueueMessage(implode("\n", $errors), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a shortcut to the parameters.
|
||||
$this->params = $this->state->params;
|
||||
|
||||
// Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx', ''));
|
||||
|
||||
// Override global params with contact specific params
|
||||
$this->params->merge($this->item->params);
|
||||
|
||||
// Propose current language as default when creating new contact
|
||||
if (empty($this->item->id) && Multilanguage::isEnabled()) {
|
||||
$lang = $this->getLanguage()->getTag();
|
||||
$this->form->setFieldAttribute('language', 'default', $lang);
|
||||
}
|
||||
|
||||
$this->_prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Because the application sets a default page title,
|
||||
// we need to get it from the menu item itself
|
||||
$menu = $app->getMenu()->getActive();
|
||||
|
||||
if ($menu) {
|
||||
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
|
||||
} else {
|
||||
$this->params->def('page_heading', Text::_('COM_CONTACT_FORM_EDIT_CONTACT'));
|
||||
}
|
||||
|
||||
$title = $this->params->def('page_title', Text::_('COM_CONTACT_FORM_EDIT_CONTACT'));
|
||||
|
||||
$this->setDocumentTitle($title);
|
||||
|
||||
$pathway = $app->getPathWay();
|
||||
$pathway->addItem($title, '');
|
||||
|
||||
if ($this->params->get('menu-meta_description')) {
|
||||
$this->getDocument()->setDescription($this->params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($this->params->get('menu-meta_keywords')) {
|
||||
$this->getDocument()->setMetaData('keywords', $this->params->get('menu-meta_keywords'));
|
||||
}
|
||||
|
||||
if ($this->params->get('robots')) {
|
||||
$this->getDocument()->setMetaData('robots', $this->params->get('robots'));
|
||||
}
|
||||
}
|
||||
}
|
||||
31
components/com_contact/tmpl/categories/default.php
Normal file
31
components/com_contact/tmpl/categories/default.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
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');
|
||||
$wa->useScript('com_categories.shared-categories-accordion');
|
||||
|
||||
?>
|
||||
<div class="com-contact-categories categories-list">
|
||||
<?php
|
||||
echo LayoutHelper::render('joomla.content.categories_default', $this);
|
||||
echo $this->loadTemplate('items');
|
||||
?>
|
||||
</div>
|
||||
775
components/com_contact/tmpl/categories/default.xml
Normal file
775
components/com_contact/tmpl/categories/default.xml
Normal file
@ -0,0 +1,775 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<layout title="COM_CONTACT_CATEGORIES_VIEW_DEFAULT_TITLE" option="COM_CONTACT_CATEGORIES_VIEW_DEFAULT_OPTION">
|
||||
<help
|
||||
key = "Menu_Item:_List_All_Contact_Categories"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[COM_CONTACT_CATEGORIES_VIEW_DEFAULT_DESC]]>
|
||||
</message>
|
||||
</layout>
|
||||
|
||||
<!-- Add fields to the request variables for the layout. -->
|
||||
<fields name="request">
|
||||
<fieldset name="request"
|
||||
>
|
||||
<field
|
||||
name="id"
|
||||
type="category"
|
||||
label="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_LABEL"
|
||||
extension="com_contact"
|
||||
show_root="true"
|
||||
required="true"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<fields name="params">
|
||||
<fieldset name="basic" label="JGLOBAL_CATEGORIES_OPTIONS">
|
||||
<field
|
||||
name="show_base_description"
|
||||
type="list"
|
||||
label="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="categories_description"
|
||||
type="textarea"
|
||||
label="JGLOBAL_FIELD_CATEGORIES_DESC_LABEL"
|
||||
cols="25"
|
||||
rows="5"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="maxLevelcat"
|
||||
type="list"
|
||||
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">JALL</option>
|
||||
<option value="1">J1</option>
|
||||
<option value="2">J2</option>
|
||||
<option value="3">J3</option>
|
||||
<option value="4">J4</option>
|
||||
<option value="5">J5</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_empty_categories_cat"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_subcat_desc_cat"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_cat_items_cat"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_CAT_ITEMS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="category" label="JGLOBAL_CATEGORY_OPTIONS" description="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL">
|
||||
|
||||
<field
|
||||
name="show_category_title"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_CATEGORY_TITLE"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_description"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_description_image"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="maxLevel"
|
||||
type="list"
|
||||
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">JALL</option>
|
||||
<option value="0">JNONE</option>
|
||||
<option value="1">J1</option>
|
||||
<option value="2">J2</option>
|
||||
<option value="3">J3</option>
|
||||
<option value="4">J4</option>
|
||||
<option value="5">J5</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_empty_categories"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_no_contacts"
|
||||
type="list"
|
||||
label="COM_CONTACT_NO_CONTACTS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_category_heading_title_text"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORY_HEADING"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_subcat_desc"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_cat_items"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_CAT_ITEMS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="advanced" label="JGLOBAL_LIST_LAYOUT_OPTIONS" description="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL">
|
||||
|
||||
<field
|
||||
name="filter_field"
|
||||
type="list"
|
||||
label="JGLOBAL_FILTER_FIELD_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination_limit"
|
||||
type="list"
|
||||
label="JGLOBAL_DISPLAY_SELECT_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_headings"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_HEADINGS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_position_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_POSITION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email_headings"
|
||||
type="list"
|
||||
label="JGLOBAL_EMAIL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_telephone_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_PHONE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_mobile_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_MOBILE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_fax_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_FAX_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_suburb_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_SUBURB_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_state_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_STATE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_country_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_COUNTRY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination"
|
||||
type="list"
|
||||
label="JGLOBAL_PAGINATION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="2">JGLOBAL_AUTO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination_results"
|
||||
type="list"
|
||||
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="contact" label="COM_CONTACT_BASIC_OPTIONS_FIELDSET_LABEL">
|
||||
|
||||
<field
|
||||
name="show_contact_category"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONTACT_SHOW_CATEGORY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="hide">JHIDE</option>
|
||||
<option value="show_no_link">COM_CONTACT_FIELD_VALUE_NO_LINK</option>
|
||||
<option value="show_with_link">COM_CONTACT_FIELD_VALUE_WITH_LINK</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_contact_list"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONTACT_SHOW_LIST_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_name"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_NAME_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_tags"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_TAGS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_info"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_INFO_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_position"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_CONTACT_POSITION_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email"
|
||||
type="list"
|
||||
label="JGLOBAL_EMAIL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_street_address"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STREET_ADDRESS_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_suburb"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TOWN-SUBURB_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_state"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STATE-COUNTY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_postcode"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_POST-ZIP_CODE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_country"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_COUNTRY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_telephone"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TELEPHONE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_mobile"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MOBILE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_fax"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_FAX_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_webpage"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_WEBPAGE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_image"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="allow_vcard"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_VCARD_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_misc"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MISC_INFO_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_articles"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_SHOW_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="articles_display_num"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_DISPLAY_NUM_LABEL"
|
||||
default=""
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="use_contact">COM_CONTACT_FIELD_VALUE_USE_CONTACT_SETTINGS</option>
|
||||
<option value="5">J5</option>
|
||||
<option value="10">J10</option>
|
||||
<option value="15">J15</option>
|
||||
<option value="20">J20</option>
|
||||
<option value="25">J25</option>
|
||||
<option value="30">J30</option>
|
||||
<option value="50">J50</option>
|
||||
<option value="75">J75</option>
|
||||
<option value="100">J100</option>
|
||||
<option value="150">J150</option>
|
||||
<option value="200">J200</option>
|
||||
<option value="250">J250</option>
|
||||
<option value="300">J300</option>
|
||||
<option value="0">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_links"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_LINKS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="linka_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKA_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkb_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKB_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkc_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKC_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkd_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKD_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linke_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKE_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
</fieldset>
|
||||
<!-- Form options. -->
|
||||
<fieldset name="Contact_Form" label="COM_CONTACT_MAIL_FIELDSET_LABEL">
|
||||
<field
|
||||
name="show_email_form"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_SHOW_FORM_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email_copy"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_EMAIL_COPY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="validate_session"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_SESSION_CHECK_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="custom_reply"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_CUSTOM_REPLY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="redirect"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_CONFIG_REDIRECT_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="integration">
|
||||
|
||||
<field
|
||||
name="show_feed_link"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_FEED_LINK_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
</metadata>
|
||||
68
components/com_contact/tmpl/categories/default_items.php
Normal file
68
components/com_contact/tmpl/categories/default_items.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
|
||||
if ($this->maxLevelcat != 0 && count($this->items[$this->parent->id]) > 0) :
|
||||
?>
|
||||
<?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-contact-categories__items">
|
||||
<h3 class="page-header item-title">
|
||||
<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_items_cat') == 1) :?>
|
||||
<span class="badge bg-info">
|
||||
<?php echo Text::_('COM_CONTACT_NUM_ITEMS'); ?>
|
||||
<?php echo $item->numitems; ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->maxLevelcat > 1 && count($item->getChildren()) > 0) : ?>
|
||||
<button
|
||||
type="button"
|
||||
id="category-btn-<?php echo $item->id; ?>"
|
||||
data-bs-target="#category-<?php echo $item->id; ?>"
|
||||
data-bs-toggle="collapse"
|
||||
class="btn btn-secondary btn-sm float-end"
|
||||
aria-label="<?php echo Text::_('JGLOBAL_EXPAND_CATEGORIES'); ?>"
|
||||
>
|
||||
<span class="icon-plus" aria-hidden="true"></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</h3>
|
||||
<?php if ($this->params->get('show_subcat_desc_cat') == 1) : ?>
|
||||
<?php if ($item->description) : ?>
|
||||
<div class="category-desc">
|
||||
<?php echo HTMLHelper::_('content.prepare', $item->description, '', 'com_contact.categories'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->maxLevelcat > 1 && count($item->getChildren()) > 0) : ?>
|
||||
<div class="collapse fade" id="category-<?php echo $item->id; ?>">
|
||||
<?php
|
||||
$this->items[$item->id] = $item->getChildren();
|
||||
$this->parent = $item;
|
||||
$this->maxLevelcat--;
|
||||
echo $this->loadTemplate('items');
|
||||
$this->parent = $item->getParent();
|
||||
$this->maxLevelcat++;
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?><?php
|
||||
endif; ?>
|
||||
22
components/com_contact/tmpl/category/default.php
Normal file
22
components/com_contact/tmpl/category/default.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
?>
|
||||
|
||||
<div class="com-contact-category">
|
||||
<?php
|
||||
$this->subtemplatename = 'items';
|
||||
echo LayoutHelper::render('joomla.content.category_default', $this);
|
||||
?>
|
||||
</div>
|
||||
792
components/com_contact/tmpl/category/default.xml
Normal file
792
components/com_contact/tmpl/category/default.xml
Normal file
@ -0,0 +1,792 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<layout title="COM_CONTACT_CATEGORY_VIEW_DEFAULT_TITLE" option="COM_CONTACT_CATEGORY_VIEW_DEFAULT_OPTION">
|
||||
<help
|
||||
key = "Menu_Item:_List_Contacts_in_a_Category"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[COM_CONTACT_CATEGORY_VIEW_DEFAULT_DESC]]>
|
||||
</message>
|
||||
</layout>
|
||||
|
||||
<!-- Add fields to the request variables for the layout. -->
|
||||
<fields name="request">
|
||||
<fieldset
|
||||
name="request"
|
||||
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
|
||||
>
|
||||
<field
|
||||
name="id"
|
||||
type="modal_category"
|
||||
label="COM_CONTACT_FIELD_CATEGORY_LABEL"
|
||||
extension="com_contact"
|
||||
required="true"
|
||||
select="true"
|
||||
new="true"
|
||||
edit="true"
|
||||
clear="true"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
|
||||
<!-- Add fields to the parameters object for the layout. -->
|
||||
<fields name="params">
|
||||
<fieldset
|
||||
name="basic"
|
||||
label="JGLOBAL_CATEGORY_OPTIONS"
|
||||
description="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="show_category_title"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_CATEGORY_TITLE"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_description"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_description_image"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="maxLevel"
|
||||
type="list"
|
||||
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">JALL</option>
|
||||
<option value="0">JNONE</option>
|
||||
<option value="1">J1</option>
|
||||
<option value="2">J2</option>
|
||||
<option value="3">J3</option>
|
||||
<option value="4">J4</option>
|
||||
<option value="5">J5</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_empty_categories"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_no_contacts"
|
||||
type="list"
|
||||
label="COM_CONTACT_NO_CONTACTS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_category_heading_title_text"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORY_HEADING"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_subcat_desc"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_cat_items"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_CAT_ITEMS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="advanced"
|
||||
label="JGLOBAL_LIST_LAYOUT_OPTIONS"
|
||||
description="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="filter_field"
|
||||
type="list"
|
||||
label="JGLOBAL_FILTER_FIELD_LABEL"
|
||||
default=""
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination_limit"
|
||||
type="list"
|
||||
label="JGLOBAL_DISPLAY_SELECT_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_headings"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_HEADINGS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_image_heading"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_SHOW_IMAGE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_position_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_POSITION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email_headings"
|
||||
type="list"
|
||||
label="JGLOBAL_EMAIL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_telephone_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_PHONE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_mobile_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_MOBILE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_fax_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_FAX_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_suburb_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_SUBURB_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_state_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_STATE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_country_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_COUNTRY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination"
|
||||
type="list"
|
||||
label="JGLOBAL_PAGINATION_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="2">JGLOBAL_AUTO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination_results"
|
||||
type="list"
|
||||
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="contacts_display_num"
|
||||
type="list"
|
||||
label="COM_CONTACT_NUMBER_CONTACTS_LIST_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="5">J5</option>
|
||||
<option value="10">J10</option>
|
||||
<option value="15">J15</option>
|
||||
<option value="20">J20</option>
|
||||
<option value="25">J25</option>
|
||||
<option value="30">J30</option>
|
||||
<option value="50">J50</option>
|
||||
<option value="100">J100</option>
|
||||
<option value="0">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="initial_sort"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_INITIAL_SORT_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="name">COM_CONTACT_FIELD_VALUE_NAME</option>
|
||||
<option value="sortname">COM_CONTACT_FIELD_VALUE_SORT_NAME</option>
|
||||
<option value="ordering">COM_CONTACT_FIELD_VALUE_ORDERING</option>
|
||||
<option value="featuredordering">COM_CONTACT_FIELD_VALUE_ORDERING_FEATURED</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="contact"
|
||||
label="COM_CONTACT_BASIC_OPTIONS_FIELDSET_LABEL"
|
||||
addfieldprefix="Joomla\Component\Fields\Administrator\Field"
|
||||
>
|
||||
|
||||
<field
|
||||
name="contact_layout"
|
||||
type="componentlayout"
|
||||
label="JGLOBAL_FIELD_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
menuitems="true"
|
||||
extension="com_contact"
|
||||
view="contact"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="show_contact_category"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONTACT_SHOW_CATEGORY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="hide">JHIDE</option>
|
||||
<option value="show_no_link">COM_CONTACT_FIELD_VALUE_NO_LINK</option>
|
||||
<option value="show_with_link">COM_CONTACT_FIELD_VALUE_WITH_LINK</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_contact_list"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONTACT_SHOW_LIST_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_name"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_NAME_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_tags"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_TAGS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_info"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_INFO_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_position"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_CONTACT_POSITION_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email"
|
||||
type="list"
|
||||
label="JGLOBAL_EMAIL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_street_address"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STREET_ADDRESS_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_suburb"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TOWN-SUBURB_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_state"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STATE-COUNTY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_postcode"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_POST-ZIP_CODE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_country"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_COUNTRY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_telephone"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TELEPHONE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_mobile"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MOBILE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_fax"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_FAX_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_webpage"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_WEBPAGE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_image"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="allow_vcard"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_VCARD_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_misc"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MISC_INFO_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_articles"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_SHOW_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="articles_display_num"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_DISPLAY_NUM_LABEL"
|
||||
default=""
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="use_contact">COM_CONTACT_FIELD_VALUE_USE_CONTACT_SETTINGS</option>
|
||||
<option value="5">J5</option>
|
||||
<option value="10">J10</option>
|
||||
<option value="15">J15</option>
|
||||
<option value="20">J20</option>
|
||||
<option value="25">J25</option>
|
||||
<option value="30">J30</option>
|
||||
<option value="50">J50</option>
|
||||
<option value="75">J75</option>
|
||||
<option value="100">J100</option>
|
||||
<option value="150">J150</option>
|
||||
<option value="200">J200</option>
|
||||
<option value="250">J250</option>
|
||||
<option value="300">J300</option>
|
||||
<option value="0">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_links"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_LINKS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_user_custom_fields"
|
||||
type="fieldgroups"
|
||||
label="COM_CONTACT_FIELD_USER_CUSTOM_FIELDS_SHOW_LABEL"
|
||||
multiple="true"
|
||||
context="com_users.user"
|
||||
addfieldprefix="Joomla\Component\Fields\Administrator\Field"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
>
|
||||
<option value="-1">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="linka_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKA_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkb_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKB_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkc_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKC_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkd_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKD_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linke_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKE_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
</fieldset>
|
||||
<!-- Form options. -->
|
||||
<fieldset
|
||||
name="Contact_Form"
|
||||
label="COM_CONTACT_MAIL_FIELDSET_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="show_email_form"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_SHOW_FORM_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email_copy"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_EMAIL_COPY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="validate_session"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_SESSION_CHECK_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="custom_reply"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_CUSTOM_REPLY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="redirect"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_CONFIG_REDIRECT_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="integration">
|
||||
|
||||
<field
|
||||
name="show_feed_link"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_FEED_LINK_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
</metadata>
|
||||
54
components/com_contact/tmpl/category/default_children.php
Normal file
54
components/com_contact/tmpl/category/default_children.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
|
||||
if ($this->maxLevel != 0 && count($this->children[$this->category->id]) > 0) :
|
||||
?>
|
||||
<ul class="com-contact-category__children list-striped list-condensed">
|
||||
<?php foreach ($this->children[$this->category->id] as $id => $child) : ?>
|
||||
<?php if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) : ?>
|
||||
<li>
|
||||
<h4 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_items') == 1) : ?>
|
||||
<span class="badge bg-info float-end" title="<?php echo Text::_('COM_CONTACT_CAT_NUM'); ?>"><?php echo $child->numitems; ?></span>
|
||||
<?php endif; ?>
|
||||
</h4>
|
||||
|
||||
<?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_contact.category'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (count($child->getChildren()) > 0) :
|
||||
$this->children[$child->id] = $child->getChildren();
|
||||
$this->category = $child;
|
||||
$this->maxLevel--;
|
||||
echo $this->loadTemplate('children');
|
||||
$this->category = $child->getParent();
|
||||
$this->maxLevel++;
|
||||
endif; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
226
components/com_contact/tmpl/category/default_items.php
Normal file
226
components/com_contact/tmpl/category/default_items.php
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\Component\Contact\Administrator\Helper\ContactHelper;
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('com_contact.contacts-list')
|
||||
->useScript('core');
|
||||
|
||||
$canDo = ContactHelper::getActions('com_contact', 'category', $this->category->id);
|
||||
$canEdit = $canDo->get('core.edit');
|
||||
$userId = $this->getCurrentUser()->id;
|
||||
|
||||
$showEditColumn = false;
|
||||
if ($canEdit) {
|
||||
$showEditColumn = true;
|
||||
} elseif ($canDo->get('core.edit.own') && !empty($this->items)) {
|
||||
foreach ($this->items as $item) {
|
||||
if ($item->created_by == $userId) {
|
||||
$showEditColumn = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
?>
|
||||
<div class="com-contact-category__items">
|
||||
<form action="<?php echo htmlspecialchars(Uri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<?php if ($this->params->get('filter_field')) : ?>
|
||||
<div class="com-contact-category__filter btn-group">
|
||||
<label class="filter-search-lbl visually-hidden" for="filter-search">
|
||||
<?php echo Text::_('COM_CONTACT_FILTER_SEARCH_DESC'); ?>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="filter-search"
|
||||
id="filter-search"
|
||||
value="<?php echo $this->escape($this->state->get('list.filter')); ?>"
|
||||
class="inputbox" onchange="document.adminForm.submit();"
|
||||
placeholder="<?php echo Text::_('COM_CONTACT_FILTER_SEARCH_DESC'); ?>"
|
||||
>
|
||||
<button type="submit" name="filter_submit" class="btn btn-primary"><?php echo Text::_('JGLOBAL_FILTER_BUTTON'); ?></button>
|
||||
<button type="reset" name="filter-clear-button" class="btn btn-secondary"><?php echo Text::_('JSEARCH_FILTER_CLEAR'); ?></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_pagination_limit')) : ?>
|
||||
<div class="com-contact-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 if ($this->params->get('show_no_contacts', 1)) : ?>
|
||||
<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_CONTACT_NO_CONTACTS'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else : ?>
|
||||
<table class="com-content-category__table category table table-striped table-bordered table-hover" id="contactList">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_CONTACT_TABLE_CAPTION'); ?>,
|
||||
</caption>
|
||||
<thead<?php echo $this->params->get('show_headings', '1') ? '' : ' class="visually-hidden"'; ?>>
|
||||
<tr>
|
||||
<th scope="col" id="categorylist_header_title">
|
||||
<?php echo HTMLHelper::_('grid.sort', 'COM_CONTACT_FIELD_NAME_LABEL', 'a.name', $listDirn, $listOrder, null, 'asc', '', 'adminForm'); ?>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<?php echo Text::_('COM_CONTACT_CONTACT_DETAILS'); ?>
|
||||
</th>
|
||||
<?php if ($showEditColumn) : ?>
|
||||
<th scope="col">
|
||||
<?php echo Text::_('COM_CONTACT_EDIT_CONTACT'); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<?php if ($this->items[$i]->published == 0) : ?>
|
||||
<tr class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
|
||||
<?php else : ?>
|
||||
<tr class="cat-list-row<?php echo $i % 2; ?>" >
|
||||
<?php endif; ?>
|
||||
<th scope="row" class="list-title">
|
||||
<a href="<?php echo Route::_(RouteHelper::getContactRoute($item->slug, $item->catid, $item->language)); ?>">
|
||||
<?php if ($this->params->get('show_image_heading')) : ?>
|
||||
<?php if ($item->image) : ?>
|
||||
<?php echo LayoutHelper::render(
|
||||
'joomla.html.image',
|
||||
[
|
||||
'src' => $item->image,
|
||||
'alt' => '',
|
||||
'class' => 'contact-thumbnail img-thumbnail',
|
||||
]
|
||||
); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php echo $this->escape($item->name); ?>
|
||||
</a>
|
||||
<?php if ($item->published == 0) : ?>
|
||||
<div>
|
||||
<span class="list-published badge bg-warning text-light">
|
||||
<?php echo Text::_('JUNPUBLISHED'); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($item->publish_up && strtotime($item->publish_up) > strtotime(Factory::getDate())) : ?>
|
||||
<div>
|
||||
<span class="list-published badge bg-warning text-light">
|
||||
<?php echo Text::_('JNOTPUBLISHEDYET'); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!is_null($item->publish_down) && strtotime($item->publish_down) < strtotime(Factory::getDate())) : ?>
|
||||
<div>
|
||||
<span class="list-published badge bg-warning text-light">
|
||||
<?php echo Text::_('JEXPIRED'); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($item->published == -2) : ?>
|
||||
<div>
|
||||
<span class="badge bg-warning text-light">
|
||||
<?php echo Text::_('JTRASHED'); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $item->event->afterDisplayTitle; ?>
|
||||
</th>
|
||||
<td>
|
||||
<?php echo $item->event->beforeDisplayContent; ?>
|
||||
|
||||
<?php if ($this->params->get('show_telephone_headings') && !empty($item->telephone)) : ?>
|
||||
<?php echo Text::sprintf('COM_CONTACT_TELEPHONE_NUMBER', $item->telephone); ?><br>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_mobile_headings') && !empty($item->mobile)) : ?>
|
||||
<?php echo Text::sprintf('COM_CONTACT_MOBILE_NUMBER', $item->mobile); ?><br>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_fax_headings') && !empty($item->fax)) : ?>
|
||||
<?php echo Text::sprintf('COM_CONTACT_FAX_NUMBER', $item->fax); ?><br>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_position_headings') && !empty($item->con_position)) : ?>
|
||||
<?php echo $item->con_position; ?><br>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_email_headings') && !empty($item->email_to)) : ?>
|
||||
<?php echo $item->email_to; ?><br>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $location = []; ?>
|
||||
<?php if ($this->params->get('show_suburb_headings') && !empty($item->suburb)) : ?>
|
||||
<?php $location[] = $item->suburb; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_state_headings') && !empty($item->state)) : ?>
|
||||
<?php $location[] = $item->state; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_country_headings') && !empty($item->country)) : ?>
|
||||
<?php $location[] = $item->country; ?>
|
||||
<?php endif; ?>
|
||||
<?php echo implode(', ', $location); ?>
|
||||
|
||||
<?php echo $item->event->afterDisplayContent; ?>
|
||||
</td>
|
||||
<?php if ($canEdit || ($canDo->get('core.edit.own') && $item->created_by === $userId)) : ?>
|
||||
<td>
|
||||
<?php echo HTMLHelper::_('contacticon.edit', $item, $this->params); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canDo->get('core.create')) : ?>
|
||||
<?php echo HTMLHelper::_('contacticon.create', $this->category, $this->category->params); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_pagination', 2)) : ?>
|
||||
<div class="com-contact-category__pagination w-100">
|
||||
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
|
||||
<p class="com-contact-category__counter counter float-end pt-3 pe-2">
|
||||
<?php echo $this->pagination->getPagesCounter(); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $this->pagination->getPagesLinks(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div>
|
||||
<input type="hidden" name="filter_order" value="<?php echo $this->escape($this->state->get('list.ordering')); ?>">
|
||||
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->escape($this->state->get('list.direction')); ?>">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
190
components/com_contact/tmpl/contact/default.php
Normal file
190
components/com_contact/tmpl/contact/default.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\FileLayout;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
|
||||
$tparams = $this->item->params;
|
||||
$canDo = ContentHelper::getActions('com_contact', 'category', $this->item->catid);
|
||||
$canEdit = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by === $this->getCurrentUser()->id);
|
||||
$htag = $tparams->get('show_page_heading') ? 'h2' : 'h1';
|
||||
$htag2 = ($tparams->get('show_page_heading') && $tparams->get('show_name')) ? 'h3' : 'h2';
|
||||
|
||||
?>
|
||||
|
||||
<div class="com-contact contact">
|
||||
<?php if ($tparams->get('show_page_heading')) : ?>
|
||||
<h1>
|
||||
<?php echo $this->escape($tparams->get('page_heading')); ?>
|
||||
</h1>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->item->name && $tparams->get('show_name')) : ?>
|
||||
<div class="page-header">
|
||||
<<?php echo $htag; ?>>
|
||||
<?php if ($this->item->published == 0) : ?>
|
||||
<span class="badge bg-warning text-light"><?php echo Text::_('JUNPUBLISHED'); ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="contact-name"><?php echo $this->item->name; ?></span>
|
||||
</<?php echo $htag; ?>>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canEdit) : ?>
|
||||
<div class="icons">
|
||||
<div class="float-end">
|
||||
<div>
|
||||
<?php echo HTMLHelper::_('contacticon.edit', $this->item, $tparams); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $show_contact_category = $tparams->get('show_contact_category'); ?>
|
||||
|
||||
<?php if ($show_contact_category === 'show_no_link') : ?>
|
||||
<<?php echo $htag2; ?>>
|
||||
<span class="contact-category"><?php echo $this->item->category_title; ?></span>
|
||||
</<?php echo $htag2; ?>>
|
||||
<?php elseif ($show_contact_category === 'show_with_link') : ?>
|
||||
<?php $contactLink = RouteHelper::getCategoryRoute($this->item->catid, $this->item->language); ?>
|
||||
<<?php echo $htag2; ?>>
|
||||
<span class="contact-category"><a href="<?php echo $contactLink; ?>">
|
||||
<?php echo $this->escape($this->item->category_title); ?></a>
|
||||
</span>
|
||||
</<?php echo $htag2; ?>>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $this->item->event->afterDisplayTitle; ?>
|
||||
|
||||
<?php if ($tparams->get('show_contact_list') && count($this->contacts) > 1) : ?>
|
||||
<form action="#" method="get" name="selectForm" id="selectForm">
|
||||
<label for="select_contact"><?php echo Text::_('COM_CONTACT_SELECT_CONTACT'); ?></label>
|
||||
<?php echo HTMLHelper::_(
|
||||
'select.genericlist',
|
||||
$this->contacts,
|
||||
'select_contact',
|
||||
'class="form-select" onchange="document.location.href = this.value"',
|
||||
'link',
|
||||
'name',
|
||||
$this->item->link
|
||||
);
|
||||
?>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($tparams->get('show_tags', 1) && !empty($this->item->tags->itemTags)) : ?>
|
||||
<div class="com-contact__tags">
|
||||
<?php $this->item->tagLayout = new FileLayout('joomla.content.tags'); ?>
|
||||
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $this->item->event->beforeDisplayContent; ?>
|
||||
|
||||
<?php if ($this->params->get('show_info', 1)) : ?>
|
||||
<div class="com-contact__container">
|
||||
<?php echo '<' . $htag2 . '>' . Text::_('COM_CONTACT_DETAILS') . '</' . $htag2 . '>'; ?>
|
||||
|
||||
<?php if ($this->item->image && $tparams->get('show_image')) : ?>
|
||||
<div class="com-contact__thumbnail thumbnail">
|
||||
<?php echo LayoutHelper::render(
|
||||
'joomla.html.image',
|
||||
[
|
||||
'src' => $this->item->image,
|
||||
'alt' => $this->item->name,
|
||||
]
|
||||
); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->item->con_position && $tparams->get('show_position')) : ?>
|
||||
<dl class="com-contact__position contact-position dl-horizontal">
|
||||
<dt><?php echo Text::_('COM_CONTACT_POSITION'); ?>:</dt>
|
||||
<dd>
|
||||
<?php echo $this->item->con_position; ?>
|
||||
</dd>
|
||||
</dl>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="com-contact__info">
|
||||
<?php echo $this->loadTemplate('address'); ?>
|
||||
|
||||
<?php if ($tparams->get('allow_vcard')) : ?>
|
||||
<?php echo Text::_('COM_CONTACT_DOWNLOAD_INFORMATION_AS'); ?>
|
||||
<a href="<?php echo Route::_('index.php?option=com_contact&view=contact&catid=' . $this->item->catslug . '&id=' . $this->item->slug . '&format=vcf'); ?>">
|
||||
<?php echo Text::_('COM_CONTACT_VCARD'); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($tparams->get('show_email_form') && ($this->item->email_to || $this->item->user_id)) : ?>
|
||||
<?php echo '<' . $htag2 . '>' . Text::_('COM_CONTACT_EMAIL_FORM') . '</' . $htag2 . '>'; ?>
|
||||
|
||||
<?php echo $this->loadTemplate('form'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($tparams->get('show_links')) : ?>
|
||||
<?php echo '<' . $htag2 . '>' . Text::_('COM_CONTACT_LINKS') . '</' . $htag2 . '>'; ?>
|
||||
|
||||
<?php echo $this->loadTemplate('links'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($tparams->get('show_articles') && $this->item->user_id && $this->item->articles) : ?>
|
||||
<?php echo '<' . $htag2 . '>' . Text::_('JGLOBAL_ARTICLES') . '</' . $htag2 . '>'; ?>
|
||||
|
||||
<?php echo $this->loadTemplate('articles'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($tparams->get('show_profile') && $this->item->user_id && PluginHelper::isEnabled('user', 'profile')) : ?>
|
||||
<?php echo '<' . $htag2 . '>' . Text::_('COM_CONTACT_PROFILE') . '</' . $htag2 . '>'; ?>
|
||||
|
||||
<?php echo $this->loadTemplate('profile'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($tparams->get('show_user_custom_fields') && $this->contactUser) : ?>
|
||||
<?php echo $this->loadTemplate('user_custom_fields'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->item->misc && $tparams->get('show_misc')) : ?>
|
||||
<?php echo '<' . $htag2 . '>' . Text::_('COM_CONTACT_OTHER_INFORMATION') . '</' . $htag2 . '>'; ?>
|
||||
|
||||
<div class="com-contact__miscinfo contact-miscinfo">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
<?php if (!$this->params->get('marker_misc')) : ?>
|
||||
<span class="icon-info-circle" aria-hidden="true"></span>
|
||||
<span class="visually-hidden"><?php echo Text::_('COM_CONTACT_OTHER_INFORMATION'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="<?php echo $this->params->get('marker_class'); ?>">
|
||||
<?php echo $this->params->get('marker_misc'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</dt>
|
||||
<dd>
|
||||
<span class="contact-misc">
|
||||
<?php echo $this->item->misc; ?>
|
||||
</span>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php echo $this->item->event->afterDisplayContent; ?>
|
||||
</div>
|
||||
463
components/com_contact/tmpl/contact/default.xml
Normal file
463
components/com_contact/tmpl/contact/default.xml
Normal file
@ -0,0 +1,463 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<layout title="COM_CONTACT_CONTACT_VIEW_DEFAULT_TITLE" option="COM_CONTACT_CONTACT_VIEW_DEFAULT_OPTION">
|
||||
<help
|
||||
key = "Menu_Item:_Single_Contact"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[COM_CONTACT_CONTACT_VIEW_DEFAULT_DESC]]>
|
||||
</message>
|
||||
</layout>
|
||||
|
||||
<!-- Add fields to the request variables for the layout. -->
|
||||
<fields name="request">
|
||||
<fieldset name="request"
|
||||
addfieldprefix="Joomla\Component\Contact\Administrator\Field"
|
||||
>
|
||||
<field
|
||||
name="id"
|
||||
type="modal_contact"
|
||||
label="COM_CONTACT_SELECT_CONTACT_LABEL"
|
||||
required="true"
|
||||
select="true"
|
||||
new="true"
|
||||
edit="true"
|
||||
clear="true"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
|
||||
<!-- Add fields to the parameters object for the layout. -->
|
||||
<fields name="params">
|
||||
|
||||
<!-- Basic options. -->
|
||||
<fieldset name="params"
|
||||
label="COM_CONTACT_BASIC_OPTIONS_FIELDSET_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="show_contact_category"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONTACT_SHOW_CATEGORY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="hide">JHIDE</option>
|
||||
<option value="show_no_link">COM_CONTACT_FIELD_VALUE_NO_LINK</option>
|
||||
<option value="show_with_link">COM_CONTACT_FIELD_VALUE_WITH_LINK</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_contact_list"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONTACT_SHOW_LIST_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_name"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_NAME_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_tags"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_TAGS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_info"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_INFO_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_position"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_CONTACT_POSITION_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email"
|
||||
type="list"
|
||||
label="JGLOBAL_EMAIL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="add_mailto_link"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_ADD_MAILTO_LINK_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_street_address"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STREET_ADDRESS_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_suburb"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TOWN-SUBURB_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_state"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STATE-COUNTY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_postcode"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_POST-ZIP_CODE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_country"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_COUNTRY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_telephone"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TELEPHONE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_mobile"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MOBILE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_fax"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_FAX_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_webpage"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_WEBPAGE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_image"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="allow_vcard"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_VCARD_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_misc"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MISC_INFO_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_articles"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_SHOW_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="articles_display_num"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_DISPLAY_NUM_LABEL"
|
||||
default=""
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="use_contact">COM_CONTACT_FIELD_VALUE_USE_CONTACT_SETTINGS</option>
|
||||
<option value="5">J5</option>
|
||||
<option value="10">J10</option>
|
||||
<option value="15">J15</option>
|
||||
<option value="20">J20</option>
|
||||
<option value="25">J25</option>
|
||||
<option value="30">J30</option>
|
||||
<option value="50">J50</option>
|
||||
<option value="75">J75</option>
|
||||
<option value="100">J100</option>
|
||||
<option value="150">J150</option>
|
||||
<option value="200">J200</option>
|
||||
<option value="250">J250</option>
|
||||
<option value="300">J300</option>
|
||||
<option value="0">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_profile"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PROFILE_SHOW_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_user_custom_fields"
|
||||
type="fieldgroups"
|
||||
label="COM_CONTACT_FIELD_USER_CUSTOM_FIELDS_SHOW_LABEL"
|
||||
multiple="true"
|
||||
context="com_users.user"
|
||||
addfieldprefix="Joomla\Component\Fields\Administrator\Field"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
>
|
||||
<option value="-1">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_links"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_LINKS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="linka_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKA_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkb_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKB_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkc_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKC_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkd_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKD_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linke_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKE_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<!-- Form options. -->
|
||||
<fieldset
|
||||
name="Contact_Form"
|
||||
label="COM_CONTACT_MAIL_FIELDSET_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="show_email_form"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_SHOW_FORM_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email_copy"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_EMAIL_COPY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="validate_session"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_SESSION_CHECK_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="custom_reply"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_CUSTOM_REPLY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="redirect"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_CONFIG_REDIRECT_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</metadata>
|
||||
159
components/com_contact/tmpl/contact/default_address.php
Normal file
159
components/com_contact/tmpl/contact/default_address.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\String\PunycodeHelper;
|
||||
|
||||
$icon = $this->params->get('contact_icons') == 0;
|
||||
|
||||
/**
|
||||
* Marker_class: Class based on the selection of text, none, or icons
|
||||
* jicon-text, jicon-none, jicon-icon
|
||||
*/
|
||||
?>
|
||||
<dl class="com-contact__address contact-address dl-horizontal">
|
||||
<?php
|
||||
if (
|
||||
($this->params->get('address_check') > 0) &&
|
||||
($this->item->address || $this->item->suburb || $this->item->state || $this->item->country || $this->item->postcode)
|
||||
) : ?>
|
||||
<dt>
|
||||
<?php if ($icon && !$this->params->get('marker_address')) : ?>
|
||||
<span class="icon-address" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('COM_CONTACT_ADDRESS'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="<?php echo $this->params->get('marker_class'); ?>">
|
||||
<?php echo $this->params->get('marker_address'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</dt>
|
||||
|
||||
<?php if ($this->item->address && $this->params->get('show_street_address')) : ?>
|
||||
<dd>
|
||||
<span class="contact-street">
|
||||
<?php echo nl2br($this->item->address, false); ?>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->item->suburb && $this->params->get('show_suburb')) : ?>
|
||||
<dd>
|
||||
<span class="contact-suburb">
|
||||
<?php echo $this->item->suburb; ?>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->item->state && $this->params->get('show_state')) : ?>
|
||||
<dd>
|
||||
<span class="contact-state">
|
||||
<?php echo $this->item->state; ?>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->item->postcode && $this->params->get('show_postcode')) : ?>
|
||||
<dd>
|
||||
<span class="contact-postcode">
|
||||
<?php echo $this->item->postcode; ?>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->item->country && $this->params->get('show_country')) : ?>
|
||||
<dd>
|
||||
<span class="contact-country">
|
||||
<?php echo $this->item->country; ?>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->item->email_to && $this->params->get('show_email')) : ?>
|
||||
<dt>
|
||||
<?php if ($icon && !$this->params->get('marker_email')) : ?>
|
||||
<span class="icon-envelope" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('COM_CONTACT_EMAIL_LABEL'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="<?php echo $this->params->get('marker_class'); ?>">
|
||||
<?php echo $this->params->get('marker_email'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</dt>
|
||||
<dd>
|
||||
<span class="contact-emailto">
|
||||
<?php echo $this->item->email_to; ?>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->item->telephone && $this->params->get('show_telephone')) : ?>
|
||||
<dt>
|
||||
<?php if ($icon && !$this->params->get('marker_telephone')) : ?>
|
||||
<span class="icon-phone" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('COM_CONTACT_TELEPHONE'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="<?php echo $this->params->get('marker_class'); ?>">
|
||||
<?php echo $this->params->get('marker_telephone'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</dt>
|
||||
<dd>
|
||||
<span class="contact-telephone">
|
||||
<?php echo $this->item->telephone; ?>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->item->fax && $this->params->get('show_fax')) : ?>
|
||||
<dt>
|
||||
<?php if ($icon && !$this->params->get('marker_fax')) : ?>
|
||||
<span class="icon-fax" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('COM_CONTACT_FAX'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="<?php echo $this->params->get('marker_class'); ?>">
|
||||
<?php echo $this->params->get('marker_fax'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</dt>
|
||||
<dd>
|
||||
<span class="contact-fax">
|
||||
<?php echo $this->item->fax; ?>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->item->mobile && $this->params->get('show_mobile')) : ?>
|
||||
<dt>
|
||||
<?php if ($icon && !$this->params->get('marker_mobile')) : ?>
|
||||
<span class="icon-mobile" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('COM_CONTACT_MOBILE'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="<?php echo $this->params->get('marker_class'); ?>">
|
||||
<?php echo $this->params->get('marker_mobile'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</dt>
|
||||
<dd>
|
||||
<span class="contact-mobile">
|
||||
<?php echo $this->item->mobile; ?>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->item->webpage && $this->params->get('show_webpage')) : ?>
|
||||
<dt>
|
||||
<?php if ($icon && !$this->params->get('marker_webpage')) : ?>
|
||||
<span class="icon-home" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('COM_CONTACT_WEBPAGE'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="<?php echo $this->params->get('marker_class'); ?>">
|
||||
<?php echo $this->params->get('marker_webpage'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</dt>
|
||||
<dd>
|
||||
<span class="contact-webpage">
|
||||
<a href="<?php echo $this->item->webpage; ?>" target="_blank" rel="noopener noreferrer">
|
||||
<?php echo PunycodeHelper::urlToUTF8($this->item->webpage); ?></a>
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
</dl>
|
||||
28
components/com_contact/tmpl/contact/default_articles.php
Normal file
28
components/com_contact/tmpl/contact/default_articles.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Content\Site\Helper\RouteHelper;
|
||||
|
||||
?>
|
||||
<?php if ($this->params->get('show_articles')) : ?>
|
||||
<div class="com-contact__articles contact-articles">
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($this->item->articles as $article) : ?>
|
||||
<li>
|
||||
<?php echo HTMLHelper::_('link', Route::_(RouteHelper::getArticleRoute($article->slug, $article->catid, $article->language)), htmlspecialchars($article->title, ENT_COMPAT, 'UTF-8')); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
55
components/com_contact/tmpl/contact/default_form.php
Normal file
55
components/com_contact/tmpl/contact/default_form.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate');
|
||||
|
||||
?>
|
||||
<div class="com-contact__form contact-form">
|
||||
<form id="contact-form" action="<?php echo Route::_('index.php'); ?>" method="post" class="form-validate form-horizontal well">
|
||||
<?php foreach ($this->form->getFieldsets() as $fieldset) : ?>
|
||||
<?php if ($fieldset->name === 'captcha' && $this->captchaEnabled) : ?>
|
||||
<?php continue; ?>
|
||||
<?php endif; ?>
|
||||
<?php $fields = $this->form->getFieldset($fieldset->name); ?>
|
||||
<?php if (count($fields)) : ?>
|
||||
<fieldset class="m-0">
|
||||
<?php if (isset($fieldset->label) && ($legend = trim(Text::_($fieldset->label))) !== '') : ?>
|
||||
<legend><?php echo $legend; ?></legend>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<?php echo $field->renderField(); ?>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($this->captchaEnabled) : ?>
|
||||
<?php echo $this->form->renderFieldset('captcha'); ?>
|
||||
<?php endif; ?>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button class="btn btn-primary validate" type="submit"><?php echo Text::_('COM_CONTACT_CONTACT_SEND'); ?></button>
|
||||
<input type="hidden" name="option" value="com_contact">
|
||||
<input type="hidden" name="task" value="contact.submit">
|
||||
<input type="hidden" name="return" value="<?php echo $this->return_page; ?>">
|
||||
<input type="hidden" name="id" value="<?php echo $this->item->slug; ?>">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
41
components/com_contact/tmpl/contact/default_links.php
Normal file
41
components/com_contact/tmpl/contact/default_links.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
<div class="com-contact__links contact-links">
|
||||
<ul class="list-unstyled">
|
||||
<?php
|
||||
// Letters 'a' to 'e'
|
||||
foreach (range('a', 'e') as $char) :
|
||||
$link = $this->item->params->get('link' . $char);
|
||||
$label = $this->item->params->get('link' . $char . '_name');
|
||||
|
||||
if (!$link) :
|
||||
continue;
|
||||
endif;
|
||||
|
||||
// Add 'http://' if not present
|
||||
$link = (0 === strpos($link, 'http')) ? $link : 'http://' . $link;
|
||||
|
||||
// If no label is present, take the link
|
||||
$label = $label ?: $link;
|
||||
?>
|
||||
<li>
|
||||
<a href="<?php echo $link; ?>" rel="noopener noreferrer">
|
||||
<?php echo $label; ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
51
components/com_contact/tmpl/contact/default_profile.php
Normal file
51
components/com_contact/tmpl/contact/default_profile.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\CMS\String\PunycodeHelper;
|
||||
|
||||
?>
|
||||
<?php if (PluginHelper::isEnabled('user', 'profile')) :
|
||||
$fields = $this->item->profile->getFieldset('profile'); ?>
|
||||
<div class="com-contact__profile contact-profile" id="users-profile-custom">
|
||||
<dl class="dl-horizontal">
|
||||
<?php foreach ($fields as $profile) :
|
||||
if ($profile->value) :
|
||||
echo '<dt>' . $profile->label . '</dt>';
|
||||
$profile->text = htmlspecialchars($profile->value, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
switch ($profile->id) :
|
||||
case 'profile_website':
|
||||
$v_http = substr($profile->value, 0, 4);
|
||||
|
||||
if ($v_http === 'http') :
|
||||
echo '<dd><a href="' . $profile->text . '">' . PunycodeHelper::urlToUTF8($profile->text) . '</a></dd>';
|
||||
else :
|
||||
echo '<dd><a href="http://' . $profile->text . '">' . PunycodeHelper::urlToUTF8($profile->text) . '</a></dd>';
|
||||
endif;
|
||||
break;
|
||||
|
||||
case 'profile_dob':
|
||||
echo '<dd>' . HTMLHelper::_('date', $profile->text, Text::_('DATE_FORMAT_LC4'), false) . '</dd>';
|
||||
break;
|
||||
|
||||
default:
|
||||
echo '<dd>' . $profile->text . '</dd>';
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
endforeach; ?>
|
||||
</dl>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$params = $this->item->params;
|
||||
|
||||
$displayGroups = $params->get('show_user_custom_fields');
|
||||
$userFieldGroups = [];
|
||||
?>
|
||||
|
||||
<?php if (!$displayGroups || !$this->contactUser) : ?>
|
||||
<?php return; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($this->contactUser->jcfields as $field) : ?>
|
||||
<?php if ($field->value && (in_array('-1', $displayGroups) || in_array($field->group_id, $displayGroups))) : ?>
|
||||
<?php $userFieldGroups[$field->group_title][] = $field; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php foreach ($userFieldGroups as $groupTitle => $fields) : ?>
|
||||
<?php $id = ApplicationHelper::stringURLSafe($groupTitle); ?>
|
||||
<?php echo '<h3>' . ($groupTitle ?: Text::_('COM_CONTACT_USER_FIELDS')) . '</h3>'; ?>
|
||||
|
||||
<div class="com-contact__user-fields contact-profile" id="user-custom-fields-<?php echo $id; ?>">
|
||||
<dl class="dl-horizontal">
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<?php if (!$field->value) : ?>
|
||||
<?php continue; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($field->params->get('showlabel')) : ?>
|
||||
<?php echo '<dt>' . Text::_($field->label) . '</dt>'; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo '<dd>' . $field->value . '</dd>'; ?>
|
||||
<?php endforeach; ?>
|
||||
</dl>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
34
components/com_contact/tmpl/featured/default.php
Normal file
34
components/com_contact/tmpl/featured/default.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
?>
|
||||
<div class="com-contact-featured blog-featured">
|
||||
<?php if ($this->params->get('show_page_heading') != 0) : ?>
|
||||
<h1>
|
||||
<?php echo $this->escape($this->params->get('page_heading')); ?>
|
||||
</h1>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $this->loadTemplate('items'); ?>
|
||||
|
||||
<?php if ($this->params->def('show_pagination', 2) == 1 || ($this->params->get('show_pagination') == 2 && $this->pagination->pagesTotal > 1)) : ?>
|
||||
<div class="com-contact-featured__pagination w-100">
|
||||
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
|
||||
<p class="counter float-end pt-3 pe-2">
|
||||
<?php echo $this->pagination->getPagesCounter(); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $this->pagination->getPagesLinks(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
550
components/com_contact/tmpl/featured/default.xml
Normal file
550
components/com_contact/tmpl/featured/default.xml
Normal file
@ -0,0 +1,550 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<metadata>
|
||||
<layout title="COM_CONTACT_FEATURED_VIEW_DEFAULT_TITLE" option="COM_CONTACT_FEATURED_VIEW_DEFAULT_OPTION">
|
||||
<help
|
||||
key = "Menu_Item:_Featured_Contacts"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[COM_CONTACT_FEATURED_VIEW_DEFAULT_DESC]]>
|
||||
</message>
|
||||
</layout>
|
||||
|
||||
<!-- Add fields to the parameters object for the layout. -->
|
||||
<fields name="params">
|
||||
<fieldset
|
||||
name="advanced"
|
||||
label="JGLOBAL_LIST_LAYOUT_OPTIONS"
|
||||
description="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="filter_field"
|
||||
type="list"
|
||||
label="JGLOBAL_FILTER_FIELD_LABEL"
|
||||
default=""
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination_limit"
|
||||
type="list"
|
||||
label="JGLOBAL_DISPLAY_SELECT_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_headings"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_HEADINGS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_position_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_POSITION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email_headings"
|
||||
type="list"
|
||||
label="JGLOBAL_EMAIL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_telephone_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_PHONE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_mobile_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_MOBILE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_fax_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_FAX_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_suburb_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_SUBURB_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_state_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_STATE_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_country_headings"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_COUNTRY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination"
|
||||
type="list"
|
||||
label="JGLOBAL_PAGINATION_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="2">JGLOBAL_AUTO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination_results"
|
||||
type="list"
|
||||
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="contact"
|
||||
label="COM_CONTACT_FIELDSET_CONTACT_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="show_tags"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_TAGS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_info"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_INFO_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_name"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_NAME_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_position"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_CONTACT_POSITION_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email"
|
||||
type="list"
|
||||
label="JGLOBAL_EMAIL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_street_address"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STREET_ADDRESS_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_suburb"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TOWN-SUBURB_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_state"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STATE-COUNTY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_postcode"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_POST-ZIP_CODE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_country"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_COUNTRY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_telephone"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TELEPHONE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_mobile"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MOBILE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_fax"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_FAX_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_webpage"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_WEBPAGE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_image"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="allow_vcard"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_VCARD_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_misc"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MISC_INFO_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_articles"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_SHOW_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="articles_display_num"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_DISPLAY_NUM_LABEL"
|
||||
default=""
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="use_contact">COM_CONTACT_FIELD_VALUE_USE_CONTACT_SETTINGS</option>
|
||||
<option value="5">J5</option>
|
||||
<option value="10">J10</option>
|
||||
<option value="15">J15</option>
|
||||
<option value="20">J20</option>
|
||||
<option value="25">J25</option>
|
||||
<option value="30">J30</option>
|
||||
<option value="50">J50</option>
|
||||
<option value="75">J75</option>
|
||||
<option value="100">J100</option>
|
||||
<option value="150">J150</option>
|
||||
<option value="200">J200</option>
|
||||
<option value="250">J250</option>
|
||||
<option value="300">J300</option>
|
||||
<option value="0">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_links"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_LINKS_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="linka_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKA_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkb_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKB_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkc_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKC_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkd_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKD_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linke_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKE_NAME_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="Contact_Form"
|
||||
label="COM_CONTACT_FIELDSET_CONTACTFORM_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="show_email_form"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_SHOW_FORM_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email_copy"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_EMAIL_COPY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="validate_session"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_SESSION_CHECK_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="custom_reply"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_CUSTOM_REPLY_LABEL"
|
||||
useglobal="true"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="redirect"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_CONFIG_REDIRECT_LABEL"
|
||||
useglobal="true"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
</fields>
|
||||
</metadata>
|
||||
198
components/com_contact/tmpl/featured/default_items.php
Normal file
198
components/com_contact/tmpl/featured/default_items.php
Normal file
@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('com_contact.contacts-list')
|
||||
->useScript('core');
|
||||
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
|
||||
?>
|
||||
<div class="com-contact-featured__items">
|
||||
<form action="<?php echo htmlspecialchars(Uri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<?php if ($this->params->get('filter_field')) : ?>
|
||||
<div class="com-contact-featured__filter btn-group">
|
||||
<label class="filter-search-lbl visually-hidden" for="filter-search">
|
||||
<?php echo Text::_('COM_CONTACT_FILTER_SEARCH_DESC'); ?>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="filter-search"
|
||||
id="filter-search"
|
||||
value="<?php echo $this->escape($this->state->get('list.filter')); ?>"
|
||||
class="inputbox" onchange="document.adminForm.submit();"
|
||||
placeholder="<?php echo Text::_('COM_CONTACT_FILTER_SEARCH_DESC'); ?>"
|
||||
>
|
||||
<button type="submit" name="filter_submit" class="btn btn-primary"><?php echo Text::_('JGLOBAL_FILTER_BUTTON'); ?></button>
|
||||
<button type="reset" name="filter-clear-button" class="btn btn-secondary"><?php echo Text::_('JSEARCH_FILTER_CLEAR'); ?></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_pagination_limit')) : ?>
|
||||
<div class="com-contact-featured__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)) : ?>
|
||||
<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_CONTACT_NO_CONTACTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<table class="com-contact-featured__table table table-striped table-bordered table-hover">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_CONTACT_TABLE_CAPTION'); ?>,
|
||||
</caption>
|
||||
<thead<?php echo $this->params->get('show_headings', '1') ? '' : ' class="visually-hidden"'; ?>>
|
||||
<tr>
|
||||
<th scope="col" class="item-title">
|
||||
<?php echo HTMLHelper::_('grid.sort', 'JGLOBAL_TITLE', 'a.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
|
||||
<?php if ($this->params->get('show_position_headings')) : ?>
|
||||
<th scope="col" class="item-position">
|
||||
<?php echo HTMLHelper::_('grid.sort', 'COM_CONTACT_POSITION', 'a.con_position', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_email_headings')) : ?>
|
||||
<th scope="col" class="item-email">
|
||||
<?php echo Text::_('JGLOBAL_EMAIL'); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_telephone_headings')) : ?>
|
||||
<th scope="col" class="item-phone">
|
||||
<?php echo Text::_('COM_CONTACT_TELEPHONE'); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_mobile_headings')) : ?>
|
||||
<th scope="col" class="item-phone">
|
||||
<?php echo Text::_('COM_CONTACT_MOBILE'); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_fax_headings')) : ?>
|
||||
<th scope="col" class="item-phone">
|
||||
<?php echo Text::_('COM_CONTACT_FAX'); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_suburb_headings')) : ?>
|
||||
<th scope="col" class="item-suburb">
|
||||
<?php echo HTMLHelper::_('grid.sort', 'COM_CONTACT_SUBURB', 'a.suburb', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_state_headings')) : ?>
|
||||
<th scope="col" class="item-state">
|
||||
<?php echo HTMLHelper::_('grid.sort', 'COM_CONTACT_STATE', 'a.state', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_country_headings')) : ?>
|
||||
<th scope="col" class="item-state">
|
||||
<?php echo HTMLHelper::_('grid.sort', 'COM_CONTACT_COUNTRY', 'a.country', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<?php if ($this->items[$i]->published == 0) : ?>
|
||||
<tr class="system-unpublished featured-list-row<?php echo $i % 2; ?>">
|
||||
<?php else : ?>
|
||||
<tr class="featured-list-row<?php echo $i % 2; ?>">
|
||||
<?php endif; ?>
|
||||
<th scope="row" class="list-title">
|
||||
<a href="<?php echo Route::_(RouteHelper::getContactRoute($item->slug, $item->catid, $item->language)); ?>">
|
||||
<span><?php echo $this->escape($item->name); ?></span>
|
||||
</a>
|
||||
<?php if ($item->published == 0) : ?>
|
||||
<div>
|
||||
<span class="list-published badge bg-warning text-light">
|
||||
<?php echo Text::_('JUNPUBLISHED'); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
|
||||
<?php if ($this->params->get('show_position_headings')) : ?>
|
||||
<td class="item-position">
|
||||
<?php echo $item->con_position; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_email_headings')) : ?>
|
||||
<td class="item-email">
|
||||
<?php echo $item->email_to; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_telephone_headings')) : ?>
|
||||
<td class="item-phone">
|
||||
<?php echo $item->telephone; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_mobile_headings')) : ?>
|
||||
<td class="item-phone">
|
||||
<?php echo $item->mobile; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_fax_headings')) : ?>
|
||||
<td class="item-phone">
|
||||
<?php echo $item->fax; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_suburb_headings')) : ?>
|
||||
<td class="item-suburb">
|
||||
<span><?php echo $item->suburb; ?></span>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_state_headings')) : ?>
|
||||
<td class="item-state">
|
||||
<span><?php echo $item->state; ?></span>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_country_headings')) : ?>
|
||||
<td class="item-state">
|
||||
<span><?php echo $item->country; ?></span>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
<div>
|
||||
<input type="hidden" name="filter_order" value="<?php echo $this->escape($this->state->get('list.ordering')); ?>">
|
||||
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->escape($this->state->get('list.direction')); ?>">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
84
components/com_contact/tmpl/form/edit.php
Normal file
84
components/com_contact/tmpl/form/edit.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate');
|
||||
|
||||
$this->tab_name = 'com-contact-form';
|
||||
$this->ignore_fieldsets = ['details', 'item_associations', 'language'];
|
||||
$this->useCoreUI = true;
|
||||
?>
|
||||
<div class="edit item-page<?php echo $this->pageclass_sfx; ?>">
|
||||
<?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; ?>
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_contact&id=' . (int) $this->item->id); ?>" method="post"
|
||||
name="adminForm" id="adminForm" class="form-validate form-vertical">
|
||||
<fieldset>
|
||||
<?php echo HTMLHelper::_('uitab.startTabSet', $this->tab_name, ['active' => 'details', 'recall' => true, 'breakpoint' => 768]); ?>
|
||||
<?php echo HTMLHelper::_('uitab.addTab', $this->tab_name, 'details', empty($this->item->id) ? Text::_('COM_CONTACT_NEW_CONTACT') : Text::_('COM_CONTACT_EDIT_CONTACT')); ?>
|
||||
<?php echo $this->form->renderField('name'); ?>
|
||||
|
||||
<?php if (is_null($this->item->id)) : ?>
|
||||
<?php echo $this->form->renderField('alias'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $this->form->renderFieldset('details'); ?>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', $this->tab_name, 'misc', Text::_('COM_CONTACT_FIELDSET_MISCELLANEOUS')); ?>
|
||||
<?php echo $this->form->getInput('misc'); ?>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<?php echo HTMLHelper::_('uitab.addTab', $this->tab_name, 'language', Text::_('JFIELD_LANGUAGE_LABEL')); ?>
|
||||
<?php echo $this->form->renderField('language'); ?>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
<?php else : ?>
|
||||
<?php echo $this->form->renderField('language'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>
|
||||
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
|
||||
|
||||
<input type="hidden" name="task" value=""/>
|
||||
<input type="hidden" name="return" value="<?php echo $this->return_page; ?>"/>
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</fieldset>
|
||||
<div class="mb-2">
|
||||
<button type="button" class="btn btn-primary" onclick="Joomla.submitbutton('contact.save')">
|
||||
<span class="icon-check" aria-hidden="true"></span>
|
||||
<?php echo Text::_('JSAVE'); ?>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger" onclick="Joomla.submitbutton('contact.cancel')">
|
||||
<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 echo $this->form->getInput('contenthistory'); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
14
components/com_contact/tmpl/form/edit.xml
Normal file
14
components/com_contact/tmpl/form/edit.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<layout title="COM_CONTACT_FORM_VIEW_DEFAULT_TITLE">
|
||||
<help
|
||||
key="Menu_Item:_Create_Contact"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[COM_CONTACT_FORM_VIEW_DEFAULT_DESC]]>
|
||||
</message>
|
||||
</layout>
|
||||
<fields name="params">
|
||||
|
||||
</fields>
|
||||
</metadata>
|
||||
390
components/com_content/forms/article.xml
Normal file
390
components/com_content/forms/article.xml
Normal file
@ -0,0 +1,390 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fieldset addfieldprefix="Joomla\Component\Categories\Administrator\Field">
|
||||
<field
|
||||
name="id"
|
||||
type="hidden"
|
||||
label="COM_CONTENT_ID_LABEL"
|
||||
size="10"
|
||||
default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="contenthistory"
|
||||
type="contenthistory"
|
||||
label="JTOOLBAR_VERSIONS"
|
||||
data-typeAlias="com_content.article"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="asset_id"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="title"
|
||||
type="text"
|
||||
label="JGLOBAL_TITLE"
|
||||
size="30"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="alias"
|
||||
type="text"
|
||||
label="JFIELD_ALIAS_LABEL"
|
||||
description="JFIELD_ALIAS_DESC"
|
||||
hint="JFIELD_ALIAS_PLACEHOLDER"
|
||||
size="45"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="articletext"
|
||||
type="editor"
|
||||
label="COM_CONTENT_FIELD_ARTICLETEXT_LABEL"
|
||||
hiddenLabel="true"
|
||||
buttons="true"
|
||||
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
asset_id="com_content"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="state"
|
||||
type="list"
|
||||
label="JSTATUS"
|
||||
class="form-select-color-state"
|
||||
size="1"
|
||||
default="1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JPUBLISHED</option>
|
||||
<option value="0">JUNPUBLISHED</option>
|
||||
<option value="2">JARCHIVED</option>
|
||||
<option value="-2">JTRASHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="featured"
|
||||
type="list"
|
||||
label="JGLOBAL_FIELD_FEATURED_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="featured_up"
|
||||
type="calendar"
|
||||
label="COM_CONTENT_FIELD_FEATURED_UP_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
size="22"
|
||||
filter="user_utc"
|
||||
showon="featured:1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="featured_down"
|
||||
type="calendar"
|
||||
label="COM_CONTENT_FIELD_FEATURED_DOWN_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
size="22"
|
||||
filter="user_utc"
|
||||
showon="featured:1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="catid"
|
||||
type="categoryedit"
|
||||
label="JCATEGORY"
|
||||
extension="com_content"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created"
|
||||
type="calendar"
|
||||
translateformat="true"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by"
|
||||
type="text"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by_alias"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_CREATED_BY_ALIAS_LABEL"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="note"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_NOTE_LABEL"
|
||||
size="40"
|
||||
maxlength="255"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="version_note"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
|
||||
maxlength="255"
|
||||
size="45"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_up"
|
||||
type="calendar"
|
||||
label="JGLOBAL_FIELD_PUBLISH_UP_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
size="22"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_down"
|
||||
type="calendar"
|
||||
label="JGLOBAL_FIELD_PUBLISH_DOWN_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
size="22"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="tags"
|
||||
type="tag"
|
||||
label="JTAG"
|
||||
multiple="true"
|
||||
size="45"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="metakey"
|
||||
type="textarea"
|
||||
label="JFIELD_META_KEYWORDS_LABEL"
|
||||
rows="5"
|
||||
cols="50"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="metadesc"
|
||||
type="textarea"
|
||||
label="JFIELD_META_DESCRIPTION_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
maxlength="300"
|
||||
charcounter="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
filter="UINT"
|
||||
validate="options"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="captcha"
|
||||
type="captcha"
|
||||
label="COM_CONTENT_CAPTCHA_LABEL"
|
||||
validate="captcha"
|
||||
namespace="article"
|
||||
/>
|
||||
</fieldset>
|
||||
<fields name="images">
|
||||
<fieldset name="image-intro">
|
||||
<field
|
||||
name="image_intro"
|
||||
type="media"
|
||||
label="COM_CONTENT_FIELD_INTRO_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_intro_alt"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_IMAGE_ALT_LABEL"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_intro_alt_empty"
|
||||
type="checkbox"
|
||||
label="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_LABEL"
|
||||
description="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_DESC"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_intro_caption"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_IMAGE_CAPTION_LABEL"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="float_intro"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_IMAGE_CLASS_LABEL"
|
||||
size="20"
|
||||
useglobal="true"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
</fieldset>
|
||||
<fieldset name="image-full">
|
||||
<field
|
||||
name="image_fulltext"
|
||||
type="media"
|
||||
label="COM_CONTENT_FIELD_FULL_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_fulltext_alt"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_IMAGE_ALT_LABEL"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_fulltext_alt_empty"
|
||||
type="checkbox"
|
||||
label="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_LABEL"
|
||||
description="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_DESC"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_fulltext_caption"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_IMAGE_CAPTION_LABEL"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="float_fulltext"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_IMAGE_CLASS_LABEL"
|
||||
size="20"
|
||||
useglobal="true"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<fields name="urls">
|
||||
<field
|
||||
name="urla"
|
||||
type="url"
|
||||
label="COM_CONTENT_FIELD_URLA_LABEL"
|
||||
validate="url"
|
||||
filter="url"
|
||||
relative="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="urlatext"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_URLA_LINK_TEXT_LABEL"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="targeta"
|
||||
type="hidden"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="urlb"
|
||||
type="url"
|
||||
label="COM_CONTENT_FIELD_URLB_LABEL"
|
||||
validate="url"
|
||||
filter="url"
|
||||
relative="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="urlbtext"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_URLB_LINK_TEXT_LABEL"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="targetb"
|
||||
type="hidden"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="urlc"
|
||||
type="url"
|
||||
label="COM_CONTENT_FIELD_URLC_LABEL"
|
||||
validate="url"
|
||||
filter="url"
|
||||
relative="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="urlctext"
|
||||
type="text"
|
||||
label="COM_CONTENT_FIELD_URLC_LINK_TEXT_LABEL"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="targetc"
|
||||
type="hidden"
|
||||
/>
|
||||
</fields>
|
||||
<fields name="metadata">
|
||||
<fieldset
|
||||
name="jmetadata"
|
||||
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
|
||||
|
||||
<field
|
||||
name="robots"
|
||||
type="hidden"
|
||||
label="JFIELD_METADATA_ROBOTS_LABEL"
|
||||
filter="unset"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="index, follow"></option>
|
||||
<option value="noindex, follow"></option>
|
||||
<option value="index, nofollow"></option>
|
||||
<option value="noindex, nofollow"></option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="author"
|
||||
type="hidden"
|
||||
label="JAUTHOR"
|
||||
filter="unset"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="rights"
|
||||
type="hidden"
|
||||
label="JFIELD_META_RIGHTS_LABEL"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
140
components/com_content/forms/filter_articles.xml
Normal file
140
components/com_content/forms/filter_articles.xml
Normal file
@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="filter">
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_CONTENT_MODAL_FILTER_SEARCH_LABEL"
|
||||
description="COM_CONTENT_MODAL_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="published"
|
||||
type="status"
|
||||
label="COM_CONTENT_FILTER_PUBLISHED"
|
||||
description="COM_CONTENT_FILTER_PUBLISHED_DESC"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_PUBLISHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="category_id"
|
||||
type="category"
|
||||
label="JOPTION_SELECT_CATEGORY"
|
||||
multiple="true"
|
||||
extension="com_content"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
hint="JOPTION_SELECT_CATEGORY"
|
||||
onchange="this.form.submit();"
|
||||
published="0,1,2"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JOPTION_SELECT_ACCESS"
|
||||
multiple="true"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
hint="JOPTION_SELECT_ACCESS"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="author_id"
|
||||
type="author"
|
||||
label="JOPTION_SELECT_AUTHOR"
|
||||
multiple="true"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
hint="JOPTION_SELECT_AUTHOR"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="0">JNONE</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="level"
|
||||
type="integer"
|
||||
label="JOPTION_FILTER_LEVEL"
|
||||
description="JOPTION_FILTER_LEVEL_DESC"
|
||||
first="1"
|
||||
last="10"
|
||||
step="1"
|
||||
languages="*"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_MAX_LEVELS</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JOPTION_FILTER_LANGUAGE"
|
||||
description="JOPTION_FILTER_LANGUAGE_DESC"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_LANGUAGE</option>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="tag"
|
||||
type="tag"
|
||||
label="JTAG"
|
||||
multiple="true"
|
||||
mode="nested"
|
||||
custom="false"
|
||||
hint="JOPTION_SELECT_TAG"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
|
||||
</fields>
|
||||
<fields name="list">
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="COM_CONTENT_LIST_FULL_ORDERING"
|
||||
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
|
||||
onchange="this.form.submit();"
|
||||
default="a.title ASC"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
|
||||
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
|
||||
<option value="a.state ASC">JSTATUS_ASC</option>
|
||||
<option value="a.state DESC">JSTATUS_DESC</option>
|
||||
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
|
||||
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
|
||||
<option value="category_title ASC">JCATEGORY_ASC</option>
|
||||
<option value="category_title DESC">JCATEGORY_DESC</option>
|
||||
<option value="association ASC" requires="associations">JASSOCIATIONS_ASC</option>
|
||||
<option value="association DESC" requires="associations">JASSOCIATIONS_DESC</option>
|
||||
<option value="a.access ASC">JGRID_HEADING_ACCESS_ASC</option>
|
||||
<option value="a.access DESC">JGRID_HEADING_ACCESS_DESC</option>
|
||||
<option value="a.created_by ASC">JAUTHOR_ASC</option>
|
||||
<option value="a.created_by DESC">JAUTHOR_DESC</option>
|
||||
<option value="language ASC" requires="multilanguage">JGRID_HEADING_LANGUAGE_ASC</option>
|
||||
<option value="language DESC" requires="multilanguage">JGRID_HEADING_LANGUAGE_DESC</option>
|
||||
<option value="a.created ASC">JDATE_ASC</option>
|
||||
<option value="a.created DESC">JDATE_DESC</option>
|
||||
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
|
||||
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
|
||||
<option value="a.featured ASC">JFEATURED_ASC</option>
|
||||
<option value="a.featured DESC">JFEATURED_DESC</option>
|
||||
<option value="a.hits ASC">JGLOBAL_HITS_ASC</option>
|
||||
<option value="a.hits DESC">JGLOBAL_HITS_DESC</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="limit"
|
||||
type="limitbox"
|
||||
label="COM_CONTENT_LIST_LIMIT"
|
||||
description="COM_CONTENT_LIST_LIMIT_DESC"
|
||||
default="25"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
||||
130
components/com_content/helpers/icon.php
Normal file
130
components/com_content/helpers/icon.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
*/
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component HTML Helper
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* Use the class \Joomla\Component\Content\Administrator\Service\HTML\Icon instead
|
||||
*/
|
||||
abstract class JHtmlIcon
|
||||
{
|
||||
/**
|
||||
* Method to generate a link to the create item page for the given category
|
||||
*
|
||||
* @param object $category The category information
|
||||
* @param Registry $params The item parameters
|
||||
* @param array $attribs Optional attributes for the link
|
||||
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
|
||||
*
|
||||
* @return string The HTML markup for the create item link
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* Use \Joomla\Component\Content\Administrator\Service\HTML\Icon::create instead
|
||||
* Example:
|
||||
* use Joomla\Component\Content\Administrator\Service\HTML\Icon;
|
||||
* Factory::getContainer()->get(Registry::class)->register('icon', new Icon());
|
||||
* echo HTMLHelper::_('icon.create', ...);
|
||||
*/
|
||||
public static function create($category, $params, $attribs = [], $legacy = false)
|
||||
{
|
||||
return self::getIcon()->create($category, $params, $attribs, $legacy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an edit icon for the article.
|
||||
*
|
||||
* This icon will not display in a popup window, nor if the article is trashed.
|
||||
* Edit access checks must be performed in the calling code.
|
||||
*
|
||||
* @param object $article The article information
|
||||
* @param Registry $params The item parameters
|
||||
* @param array $attribs Optional attributes for the link
|
||||
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
|
||||
*
|
||||
* @return string The HTML for the article edit icon.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* Use \Joomla\Component\Content\Administrator\Service\HTML\Icon::edit instead
|
||||
* Example:
|
||||
* use Joomla\Component\Content\Administrator\Service\HTML\Icon;
|
||||
* Factory::getContainer()->get(Registry::class)->register('icon', new Icon());
|
||||
* echo HTMLHelper::_('icon.edit', ...);
|
||||
*/
|
||||
public static function edit($article, $params, $attribs = [], $legacy = false)
|
||||
{
|
||||
return self::getIcon()->edit($article, $params, $attribs, $legacy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate a popup link to print an article
|
||||
*
|
||||
* @param object $article The article information
|
||||
* @param Registry $params The item parameters
|
||||
* @param array $attribs Optional attributes for the link
|
||||
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
|
||||
*
|
||||
* @return string The HTML markup for the popup link
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* No longer used, will be removed without replacement
|
||||
*/
|
||||
public static function print_popup($article, $params, $attribs = [], $legacy = false)
|
||||
{
|
||||
throw new \Exception(Text::_('COM_CONTENT_ERROR_PRINT_POPUP'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate a link to print an article
|
||||
*
|
||||
* @param object $article Not used
|
||||
* @param Registry $params The item parameters
|
||||
* @param array $attribs Not used
|
||||
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
|
||||
*
|
||||
* @return string The HTML markup for the popup link
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* Use \Joomla\Component\Content\Administrator\Service\HTML\Icon::print_screen instead
|
||||
* Example:
|
||||
* use Joomla\Component\Content\Administrator\Service\HTML\Icon;
|
||||
* Factory::getContainer()->get(Registry::class)->register('icon', new Icon());
|
||||
* echo HTMLHelper::_('icon.print_screen', ...);
|
||||
*/
|
||||
public static function print_screen($article, $params, $attribs = [], $legacy = false)
|
||||
{
|
||||
return self::getIcon()->print_screen($params, $legacy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an icon instance.
|
||||
*
|
||||
* @return \Joomla\Component\Content\Administrator\Service\HTML\Icon
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0 without replacement
|
||||
*/
|
||||
private static function getIcon()
|
||||
{
|
||||
return (new \Joomla\Component\Content\Administrator\Service\HTML\Icon(Joomla\CMS\Factory::getApplication()));
|
||||
}
|
||||
}
|
||||
428
components/com_content/src/Controller/ArticleController.php
Normal file
428
components/com_content/src/Controller/ArticleController.php
Normal file
@ -0,0 +1,428 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Controller;
|
||||
|
||||
use Joomla\CMS\Application\SiteApplication;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\CMS\Versioning\VersionableControllerTrait;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content article class.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
class ArticleController extends FormController
|
||||
{
|
||||
use VersionableControllerTrait;
|
||||
|
||||
/**
|
||||
* The URL view item variable.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $view_item = 'form';
|
||||
|
||||
/**
|
||||
* The URL view list variable.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $view_list = 'categories';
|
||||
|
||||
/**
|
||||
* The URL edit variable.
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2
|
||||
*/
|
||||
protected $urlVar = 'a.id';
|
||||
|
||||
/**
|
||||
* Method to add a new record.
|
||||
*
|
||||
* @return mixed True if the record can be added, an error object if not.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (!parent::add()) {
|
||||
// Redirect to the return page.
|
||||
$this->setRedirect($this->getReturnPage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Redirect to the edit screen.
|
||||
$this->setRedirect(
|
||||
Route::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_item . '&a_id=0'
|
||||
. $this->getRedirectToItemAppend(),
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowAdd($data = [])
|
||||
{
|
||||
$user = $this->app->getIdentity();
|
||||
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('catid'), 'int');
|
||||
$allow = null;
|
||||
|
||||
if ($categoryId) {
|
||||
// If the category has been passed in the data or URL check it.
|
||||
$allow = $user->authorise('core.create', 'com_content.category.' . $categoryId);
|
||||
}
|
||||
|
||||
if ($allow === null) {
|
||||
// In the absence of better information, revert to the component permissions.
|
||||
return parent::allowAdd();
|
||||
}
|
||||
|
||||
return $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can edit an existing record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key; default is id.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowEdit($data = [], $key = 'id')
|
||||
{
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
// Zero record (id:0), return component edit permission by calling parent controller method
|
||||
if (!$recordId) {
|
||||
return parent::allowEdit($data, $key);
|
||||
}
|
||||
|
||||
// Check edit on the record asset (explicit or inherited)
|
||||
if ($user->authorise('core.edit', 'com_content.article.' . $recordId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check edit own on the record asset (explicit or inherited)
|
||||
if ($user->authorise('core.edit.own', 'com_content.article.' . $recordId)) {
|
||||
// Existing record already has an owner, get it
|
||||
$record = $this->getModel()->getItem($recordId);
|
||||
|
||||
if (empty($record)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Grant if current user is owner of the record
|
||||
return $user->get('id') == $record->created_by;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cancel an edit.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
*
|
||||
* @return boolean True if access level checks pass, false otherwise.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function cancel($key = 'a_id')
|
||||
{
|
||||
$result = parent::cancel($key);
|
||||
|
||||
/** @var SiteApplication $app */
|
||||
$app = $this->app;
|
||||
|
||||
// Load the parameters.
|
||||
$params = $app->getParams();
|
||||
|
||||
$customCancelRedir = (bool) $params->get('custom_cancel_redirect');
|
||||
|
||||
if ($customCancelRedir) {
|
||||
$cancelMenuitemId = (int) $params->get('cancel_redirect_menuitem');
|
||||
|
||||
if ($cancelMenuitemId > 0) {
|
||||
$item = $app->getMenu()->getItem($cancelMenuitemId);
|
||||
$lang = '';
|
||||
|
||||
if (Multilanguage::isEnabled()) {
|
||||
$lang = !\is_null($item) && $item->language != '*' ? '&lang=' . $item->language : '';
|
||||
}
|
||||
|
||||
// Redirect to the user specified return page.
|
||||
$redirlink = $item->link . $lang . '&Itemid=' . $cancelMenuitemId;
|
||||
} else {
|
||||
// Redirect to the same article submission form (clean form).
|
||||
$redirlink = $app->getMenu()->getActive()->link . '&Itemid=' . $app->getMenu()->getActive()->id;
|
||||
}
|
||||
} else {
|
||||
$menuitemId = (int) $params->get('redirect_menuitem');
|
||||
|
||||
if ($menuitemId > 0) {
|
||||
$lang = '';
|
||||
$item = $app->getMenu()->getItem($menuitemId);
|
||||
|
||||
if (Multilanguage::isEnabled()) {
|
||||
$lang = !\is_null($item) && $item->language != '*' ? '&lang=' . $item->language : '';
|
||||
}
|
||||
|
||||
// Redirect to the general (redirect_menuitem) user specified return page.
|
||||
$redirlink = $item->link . $lang . '&Itemid=' . $menuitemId;
|
||||
} else {
|
||||
// Redirect to the return page.
|
||||
$redirlink = $this->getReturnPage();
|
||||
}
|
||||
}
|
||||
|
||||
$this->setRedirect(Route::_($redirlink, false));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to edit an existing record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key
|
||||
* (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return boolean True if access level check and checkout passes, false otherwise.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function edit($key = null, $urlVar = 'a_id')
|
||||
{
|
||||
$result = parent::edit($key, $urlVar);
|
||||
|
||||
if (!$result) {
|
||||
$this->setRedirect(Route::_($this->getReturnPage(), false));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a model object, loading it if required.
|
||||
*
|
||||
* @param string $name The model name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return object The model.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getModel($name = 'Form', $prefix = 'Site', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL arguments to append to an item redirect.
|
||||
*
|
||||
* @param integer $recordId The primary key id for the item.
|
||||
* @param string $urlVar The name of the URL variable for the id.
|
||||
*
|
||||
* @return string The arguments to append to the redirect URL.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'a_id')
|
||||
{
|
||||
// Need to override the parent method completely.
|
||||
$tmpl = $this->input->get('tmpl');
|
||||
|
||||
$append = '';
|
||||
|
||||
// Setup redirect info.
|
||||
if ($tmpl) {
|
||||
$append .= '&tmpl=' . $tmpl;
|
||||
}
|
||||
|
||||
// @todo This is a bandaid, not a long term solution.
|
||||
/**
|
||||
* if ($layout)
|
||||
* {
|
||||
* $append .= '&layout=' . $layout;
|
||||
* }
|
||||
*/
|
||||
|
||||
$append .= '&layout=edit';
|
||||
|
||||
if ($recordId) {
|
||||
$append .= '&' . $urlVar . '=' . $recordId;
|
||||
}
|
||||
|
||||
$itemId = $this->input->getInt('Itemid');
|
||||
$return = $this->getReturnPage();
|
||||
$catId = $this->input->getInt('catid');
|
||||
|
||||
if ($itemId) {
|
||||
$append .= '&Itemid=' . $itemId;
|
||||
}
|
||||
|
||||
if ($catId) {
|
||||
$append .= '&catid=' . $catId;
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
$append .= '&return=' . base64_encode($return);
|
||||
}
|
||||
|
||||
return $append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the return URL.
|
||||
*
|
||||
* If a "return" variable has been passed in the request
|
||||
*
|
||||
* @return string The return URL.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getReturnPage()
|
||||
{
|
||||
$return = $this->input->get('return', null, 'base64');
|
||||
|
||||
if (empty($return) || !Uri::isInternal(base64_decode($return))) {
|
||||
return Uri::base();
|
||||
}
|
||||
|
||||
return base64_decode($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save a record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return boolean True if successful, false otherwise.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function save($key = null, $urlVar = 'a_id')
|
||||
{
|
||||
$result = parent::save($key, $urlVar);
|
||||
|
||||
if (\in_array($this->getTask(), ['save2copy', 'apply'], true)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$app = $this->app;
|
||||
$articleId = $app->getInput()->getInt('a_id');
|
||||
|
||||
// Load the parameters.
|
||||
$params = $app->getParams();
|
||||
$menuitem = (int) $params->get('redirect_menuitem');
|
||||
|
||||
// Check for redirection after submission when creating a new article only
|
||||
if ($menuitem > 0 && $articleId == 0) {
|
||||
$lang = '';
|
||||
|
||||
if (Multilanguage::isEnabled()) {
|
||||
$item = $app->getMenu()->getItem($menuitem);
|
||||
$lang = !\is_null($item) && $item->language != '*' ? '&lang=' . $item->language : '';
|
||||
}
|
||||
|
||||
// If ok, redirect to the return page.
|
||||
if ($result) {
|
||||
$this->setRedirect(Route::_('index.php?Itemid=' . $menuitem . $lang, false));
|
||||
}
|
||||
} elseif ($this->getTask() === 'save2copy') {
|
||||
// Redirect to the article page, use the redirect url set from parent controller
|
||||
} else {
|
||||
// If ok, redirect to the return page.
|
||||
if ($result) {
|
||||
$this->setRedirect(Route::_($this->getReturnPage(), false));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to reload a record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.8.0
|
||||
*/
|
||||
public function reload($key = null, $urlVar = 'a_id')
|
||||
{
|
||||
parent::reload($key, $urlVar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save a vote.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function vote()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
$this->checkToken();
|
||||
|
||||
$user_rating = $this->input->getInt('user_rating', -1);
|
||||
|
||||
if ($user_rating > -1) {
|
||||
$url = $this->input->getString('url', '');
|
||||
$id = $this->input->getInt('id', 0);
|
||||
$viewName = $this->input->getString('view', $this->default_view);
|
||||
$model = $this->getModel($viewName);
|
||||
|
||||
// Don't redirect to an external URL.
|
||||
if (!Uri::isInternal($url)) {
|
||||
$url = Route::_('index.php');
|
||||
}
|
||||
|
||||
if ($model->storeVote($id, $user_rating)) {
|
||||
$this->setRedirect($url, Text::_('COM_CONTENT_ARTICLE_VOTE_SUCCESS'));
|
||||
} else {
|
||||
$this->setRedirect($url, Text::_('COM_CONTENT_ARTICLE_VOTE_FAILURE'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
126
components/com_content/src/Controller/DisplayController.php
Normal file
126
components/com_content/src/Controller/DisplayController.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Controller;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component Controller
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class DisplayController extends \Joomla\CMS\MVC\Controller\BaseController
|
||||
{
|
||||
/**
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* Recognized key values include 'name', 'default_task', 'model_path', and
|
||||
* 'view_path' (this list is not meant to be comprehensive).
|
||||
* @param MVCFactoryInterface|null $factory The factory.
|
||||
* @param CMSApplication|null $app The Application for the dispatcher
|
||||
* @param \Joomla\CMS\Input\Input|null $input The Input object for the request
|
||||
*
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
$this->input = Factory::getApplication()->getInput();
|
||||
|
||||
// Article frontpage Editor pagebreak proxying:
|
||||
if ($this->input->get('view') === 'article' && $this->input->get('layout') === 'pagebreak') {
|
||||
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
|
||||
} elseif ($this->input->get('view') === 'articles' && $this->input->get('layout') === 'modal') {
|
||||
// Article frontpage Editor article proxying:
|
||||
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
|
||||
}
|
||||
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached.
|
||||
* @param boolean $urlparams An array of safe URL parameters and their variable types.
|
||||
* @see \Joomla\CMS\Filter\InputFilter::clean() for valid values.
|
||||
*
|
||||
* @return DisplayController This object to support chaining.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = false)
|
||||
{
|
||||
$cachable = true;
|
||||
|
||||
/**
|
||||
* Set the default view name and format from the Request.
|
||||
* Note we are using a_id to avoid collisions with the router and the return page.
|
||||
* Frontend is a bit messier than the backend.
|
||||
*/
|
||||
$id = $this->input->getInt('a_id');
|
||||
$vName = $this->input->getCmd('view', 'categories');
|
||||
$this->input->set('view', $vName);
|
||||
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
if (
|
||||
$user->get('id')
|
||||
|| ($this->input->getMethod() === 'POST'
|
||||
&& (($vName === 'category' && $this->input->get('layout') !== 'blog') || $vName === 'archive'))
|
||||
) {
|
||||
$cachable = false;
|
||||
}
|
||||
|
||||
$safeurlparams = [
|
||||
'catid' => 'INT',
|
||||
'id' => 'INT',
|
||||
'cid' => 'ARRAY',
|
||||
'year' => 'INT',
|
||||
'month' => 'INT',
|
||||
'limit' => 'UINT',
|
||||
'limitstart' => 'UINT',
|
||||
'showall' => 'INT',
|
||||
'return' => 'BASE64',
|
||||
'filter' => 'STRING',
|
||||
'filter_order' => 'CMD',
|
||||
'filter_order_Dir' => 'CMD',
|
||||
'filter-search' => 'STRING',
|
||||
'print' => 'BOOLEAN',
|
||||
'lang' => 'CMD',
|
||||
'Itemid' => 'INT', ];
|
||||
|
||||
// Check for edit form.
|
||||
if ($vName === 'form' && !$this->checkEditId('com_content.edit.article', $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);
|
||||
}
|
||||
|
||||
if ($vName === 'article') {
|
||||
// Get/Create the model
|
||||
if ($model = $this->getModel($vName)) {
|
||||
if (ComponentHelper::getParams('com_content')->get('record_hits', 1) == 1) {
|
||||
$model->hit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::display($cachable, $safeurlparams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
58
components/com_content/src/Dispatcher/Dispatcher.php
Normal file
58
components/com_content/src/Dispatcher/Dispatcher.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Dispatcher;
|
||||
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcher;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* ComponentDispatcher class for com_content
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class Dispatcher extends ComponentDispatcher
|
||||
{
|
||||
/**
|
||||
* Dispatch a controller task. Redirecting the user if appropriate.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function dispatch()
|
||||
{
|
||||
$checkCreateEdit = ($this->input->get('view') === 'articles' && $this->input->get('layout') === 'modal')
|
||||
|| ($this->input->get('view') === 'article' && $this->input->get('layout') === 'pagebreak');
|
||||
|
||||
if ($checkCreateEdit) {
|
||||
// Can create in any category (component permission) or at least in one category
|
||||
$canCreateRecords = $this->app->getIdentity()->authorise('core.create', 'com_content')
|
||||
|| \count($this->app->getIdentity()->getAuthorisedCategories('com_content', 'core.create')) > 0;
|
||||
|
||||
// Instead of checking edit on all records, we can use **same** check as the form editing view
|
||||
$values = (array) $this->app->getUserState('com_content.edit.article.id');
|
||||
$isEditingRecords = \count($values);
|
||||
$hasAccess = $canCreateRecords || $isEditingRecords;
|
||||
|
||||
if (!$hasAccess) {
|
||||
$this->app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'warning');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
parent::dispatch();
|
||||
}
|
||||
}
|
||||
150
components/com_content/src/Helper/AssociationHelper.php
Normal file
150
components/com_content/src/Helper/AssociationHelper.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Helper;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\Component\Categories\Administrator\Helper\CategoryAssociationHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component Association Helper
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
abstract class AssociationHelper extends CategoryAssociationHelper
|
||||
{
|
||||
/**
|
||||
* Method to get the associations for a given item
|
||||
*
|
||||
* @param integer $id Id of the item
|
||||
* @param string $view Name of the view
|
||||
* @param string $layout View layout
|
||||
*
|
||||
* @return array Array of associations for the item
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function getAssociations($id = 0, $view = null, $layout = null)
|
||||
{
|
||||
$jinput = Factory::getApplication()->getInput();
|
||||
$view = $view ?? $jinput->get('view');
|
||||
$component = $jinput->getCmd('option');
|
||||
$id = empty($id) ? $jinput->getInt('id') : $id;
|
||||
|
||||
if ($layout === null && $jinput->get('view') == $view && $component == 'com_content') {
|
||||
$layout = $jinput->get('layout', '', 'string');
|
||||
}
|
||||
|
||||
if ($view === 'article') {
|
||||
if ($id) {
|
||||
$user = Factory::getUser();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$db = Factory::getDbo();
|
||||
$advClause = [];
|
||||
|
||||
// Filter by user groups
|
||||
$advClause[] = 'c2.access IN (' . $groups . ')';
|
||||
|
||||
// Filter by current language
|
||||
$advClause[] = 'c2.language != ' . $db->quote(Factory::getLanguage()->getTag());
|
||||
|
||||
if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) {
|
||||
// Filter by start and end dates.
|
||||
$date = Factory::getDate();
|
||||
|
||||
$nowDate = $db->quote($date->toSql());
|
||||
|
||||
$advClause[] = '(c2.publish_up IS NULL OR c2.publish_up <= ' . $nowDate . ')';
|
||||
$advClause[] = '(c2.publish_down IS NULL OR c2.publish_down >= ' . $nowDate . ')';
|
||||
|
||||
// Filter by published
|
||||
$advClause[] = 'c2.state = 1';
|
||||
}
|
||||
|
||||
$associations = Associations::getAssociations(
|
||||
'com_content',
|
||||
'#__content',
|
||||
'com_content.item',
|
||||
$id,
|
||||
'id',
|
||||
'alias',
|
||||
'catid',
|
||||
$advClause
|
||||
);
|
||||
|
||||
$return = [];
|
||||
|
||||
foreach ($associations as $tag => $item) {
|
||||
$return[$tag] = RouteHelper::getArticleRoute($item->id, (int) $item->catid, $item->language, $layout);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($view === 'category' || $view === 'categories') {
|
||||
return self::getCategoryAssociations($id, 'com_content', $layout);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to display in frontend the associations for a given article
|
||||
*
|
||||
* @param integer $id Id of the article
|
||||
*
|
||||
* @return array An array containing the association URL and the related language object
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public static function displayAssociations($id)
|
||||
{
|
||||
$return = [];
|
||||
|
||||
if ($associations = self::getAssociations($id, 'article')) {
|
||||
$levels = Factory::getUser()->getAuthorisedViewLevels();
|
||||
$languages = LanguageHelper::getLanguages();
|
||||
|
||||
foreach ($languages as $language) {
|
||||
// Do not display language when no association
|
||||
if (empty($associations[$language->lang_code])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not display language without frontend UI
|
||||
if (!\array_key_exists($language->lang_code, LanguageHelper::getInstalledLanguages(0))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not display language without specific home menu
|
||||
if (!\array_key_exists($language->lang_code, Multilanguage::getSiteHomePages())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not display language without authorized access level
|
||||
if (isset($language->access) && $language->access && !\in_array($language->access, $levels)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$return[$language->lang_code] = ['item' => $associations[$language->lang_code], 'language' => $language];
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
230
components/com_content/src/Helper/QueryHelper.php
Normal file
230
components/com_content/src/Helper/QueryHelper.php
Normal file
@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Helper;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component Query Helper
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class QueryHelper
|
||||
{
|
||||
/**
|
||||
* Translate an order code to a field for category ordering.
|
||||
*
|
||||
* @param string $orderby The ordering code.
|
||||
*
|
||||
* @return string The SQL field(s) to order by.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function orderbyPrimary($orderby)
|
||||
{
|
||||
switch ($orderby) {
|
||||
case 'alpha':
|
||||
$orderby = 'c.path, ';
|
||||
break;
|
||||
|
||||
case 'ralpha':
|
||||
$orderby = 'c.path DESC, ';
|
||||
break;
|
||||
|
||||
case 'order':
|
||||
$orderby = 'c.lft, ';
|
||||
break;
|
||||
|
||||
default:
|
||||
$orderby = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return $orderby;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate an order code to a field for article ordering.
|
||||
*
|
||||
* @param string $orderby The ordering code.
|
||||
* @param string $orderDate The ordering code for the date.
|
||||
* @param DatabaseInterface $db The database
|
||||
*
|
||||
* @return string The SQL field(s) to order by.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function orderbySecondary($orderby, $orderDate = 'created', DatabaseInterface $db = null)
|
||||
{
|
||||
$db = $db ?: Factory::getDbo();
|
||||
|
||||
$queryDate = self::getQueryDate($orderDate, $db);
|
||||
|
||||
switch ($orderby) {
|
||||
case 'date':
|
||||
$orderby = $queryDate;
|
||||
break;
|
||||
|
||||
case 'rdate':
|
||||
$orderby = $queryDate . ' DESC ';
|
||||
break;
|
||||
|
||||
case 'alpha':
|
||||
$orderby = 'a.title';
|
||||
break;
|
||||
|
||||
case 'ralpha':
|
||||
$orderby = 'a.title DESC';
|
||||
break;
|
||||
|
||||
case 'hits':
|
||||
$orderby = 'a.hits DESC';
|
||||
break;
|
||||
|
||||
case 'rhits':
|
||||
$orderby = 'a.hits';
|
||||
break;
|
||||
|
||||
case 'rorder':
|
||||
$orderby = 'a.ordering DESC';
|
||||
break;
|
||||
|
||||
case 'author':
|
||||
$orderby = 'author';
|
||||
break;
|
||||
|
||||
case 'rauthor':
|
||||
$orderby = 'author DESC';
|
||||
break;
|
||||
|
||||
case 'front':
|
||||
$orderby = 'a.featured DESC, fp.ordering, ' . $queryDate . ' DESC ';
|
||||
break;
|
||||
|
||||
case 'random':
|
||||
$orderby = $db->getQuery(true)->rand();
|
||||
break;
|
||||
|
||||
case 'vote':
|
||||
$orderby = 'a.id DESC ';
|
||||
|
||||
if (PluginHelper::isEnabled('content', 'vote')) {
|
||||
$orderby = 'rating_count DESC ';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'rvote':
|
||||
$orderby = 'a.id ASC ';
|
||||
|
||||
if (PluginHelper::isEnabled('content', 'vote')) {
|
||||
$orderby = 'rating_count ASC ';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'rank':
|
||||
$orderby = 'a.id DESC ';
|
||||
|
||||
if (PluginHelper::isEnabled('content', 'vote')) {
|
||||
$orderby = 'rating DESC ';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'rrank':
|
||||
$orderby = 'a.id ASC ';
|
||||
|
||||
if (PluginHelper::isEnabled('content', 'vote')) {
|
||||
$orderby = 'rating ASC ';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$orderby = 'a.ordering';
|
||||
break;
|
||||
}
|
||||
|
||||
return $orderby;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate an order code to a field for date ordering.
|
||||
*
|
||||
* @param string $orderDate The ordering code.
|
||||
* @param DatabaseInterface $db The database
|
||||
*
|
||||
* @return string The SQL field(s) to order by.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function getQueryDate($orderDate, DatabaseInterface $db = null)
|
||||
{
|
||||
$db = $db ?: Factory::getDbo();
|
||||
|
||||
switch ($orderDate) {
|
||||
case 'modified':
|
||||
$queryDate = ' CASE WHEN a.modified IS NULL THEN a.created ELSE a.modified END';
|
||||
break;
|
||||
|
||||
// Use created if publish_up is not set
|
||||
case 'published':
|
||||
$queryDate = ' CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END ';
|
||||
break;
|
||||
|
||||
case 'unpublished':
|
||||
$queryDate = ' CASE WHEN a.publish_down IS NULL THEN a.created ELSE a.publish_down END ';
|
||||
break;
|
||||
case 'created':
|
||||
default:
|
||||
$queryDate = ' a.created ';
|
||||
break;
|
||||
}
|
||||
|
||||
return $queryDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get join information for the voting query.
|
||||
*
|
||||
* @param \Joomla\Registry\Registry $params An options object for the article.
|
||||
*
|
||||
* @return array A named array with "select" and "join" keys.
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* Will be removed without replacement
|
||||
*/
|
||||
public static function buildVotingQuery($params = null)
|
||||
{
|
||||
if (!$params) {
|
||||
$params = ComponentHelper::getParams('com_content');
|
||||
}
|
||||
|
||||
$voting = $params->get('show_vote');
|
||||
|
||||
if ($voting) {
|
||||
// Calculate voting count
|
||||
$select = ' , ROUND(v.rating_sum / v.rating_count) AS rating, v.rating_count';
|
||||
$join = ' LEFT JOIN #__content_rating AS v ON a.id = v.content_id';
|
||||
} else {
|
||||
$select = '';
|
||||
$join = '';
|
||||
}
|
||||
|
||||
return ['select' => $select, 'join' => $join];
|
||||
}
|
||||
}
|
||||
108
components/com_content/src/Helper/RouteHelper.php
Normal file
108
components/com_content/src/Helper/RouteHelper.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Helper;
|
||||
|
||||
use Joomla\CMS\Categories\CategoryNode;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component Route Helper.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
abstract class RouteHelper
|
||||
{
|
||||
/**
|
||||
* Get the article route.
|
||||
*
|
||||
* @param integer $id The route of the content item.
|
||||
* @param integer $catid The category ID.
|
||||
* @param string $language The language code.
|
||||
* @param string $layout The layout value.
|
||||
*
|
||||
* @return string The article route.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getArticleRoute($id, $catid = 0, $language = null, $layout = null)
|
||||
{
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_content&view=article&id=' . $id;
|
||||
|
||||
if ((int) $catid > 1) {
|
||||
$link .= '&catid=' . $catid;
|
||||
}
|
||||
|
||||
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
|
||||
$link .= '&lang=' . $language;
|
||||
}
|
||||
|
||||
if ($layout) {
|
||||
$link .= '&layout=' . $layout;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category route.
|
||||
*
|
||||
* @param integer $catid The category ID.
|
||||
* @param integer $language The language code.
|
||||
* @param string $layout The layout value.
|
||||
*
|
||||
* @return string The article route.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getCategoryRoute($catid, $language = 0, $layout = null)
|
||||
{
|
||||
if ($catid instanceof CategoryNode) {
|
||||
$id = $catid->id;
|
||||
} else {
|
||||
$id = (int) $catid;
|
||||
}
|
||||
|
||||
if ($id < 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$link = 'index.php?option=com_content&view=category&id=' . $id;
|
||||
|
||||
if ($language && $language !== '*' && Multilanguage::isEnabled()) {
|
||||
$link .= '&lang=' . $language;
|
||||
}
|
||||
|
||||
if ($layout) {
|
||||
$link .= '&layout=' . $layout;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the form route.
|
||||
*
|
||||
* @param integer $id The form ID.
|
||||
*
|
||||
* @return string The article route.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getFormRoute($id)
|
||||
{
|
||||
return 'index.php?option=com_content&task=article.edit&a_id=' . (int) $id;
|
||||
}
|
||||
}
|
||||
225
components/com_content/src/Model/ArchiveModel.php
Normal file
225
components/com_content/src/Model/ArchiveModel.php
Normal file
@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\Component\Content\Administrator\Extension\ContentComponent;
|
||||
use Joomla\Component\Content\Site\Helper\QueryHelper;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component Archive Model
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class ArchiveModel extends ArticlesModel
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_context = 'com_content.archive';
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering The field to order on.
|
||||
* @param string $direction The direction to order on.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
parent::populateState();
|
||||
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
|
||||
// Add archive properties
|
||||
$params = $this->state->get('params');
|
||||
|
||||
// Filter on archived articles
|
||||
$this->setState('filter.published', ContentComponent::CONDITION_ARCHIVED);
|
||||
|
||||
// Filter on month, year
|
||||
$this->setState('filter.month', $input->getInt('month'));
|
||||
$this->setState('filter.year', $input->getInt('year'));
|
||||
|
||||
// Optional filter text
|
||||
$this->setState('list.filter', $input->getString('filter-search'));
|
||||
|
||||
// Get list limit
|
||||
$itemid = $input->get('Itemid', 0, 'int');
|
||||
$limit = $app->getUserStateFromRequest('com_content.archive.list' . $itemid . '.limit', 'limit', $params->get('display_num', 20), 'uint');
|
||||
$this->setState('list.limit', $limit);
|
||||
|
||||
// Set the archive ordering
|
||||
$articleOrderby = $params->get('orderby_sec', 'rdate');
|
||||
$articleOrderDate = $params->get('order_date');
|
||||
|
||||
// No category ordering
|
||||
$secondary = QueryHelper::orderbySecondary($articleOrderby, $articleOrderDate, $this->getDatabase());
|
||||
|
||||
$this->setState('list.ordering', $secondary . ', a.created DESC');
|
||||
$this->setState('list.direction', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the main query for retrieving a list of articles subject to the model state.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$params = $this->state->params;
|
||||
$app = Factory::getApplication();
|
||||
$catids = $app->getInput()->get('catid', [], 'array');
|
||||
$catids = array_values(array_diff($catids, ['']));
|
||||
|
||||
$articleOrderDate = $params->get('order_date');
|
||||
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = parent::getListQuery();
|
||||
|
||||
// Add routing for archive
|
||||
$query->select(
|
||||
[
|
||||
$this->getSlugColumn($query, 'a.id', 'a.alias') . ' AS ' . $db->quoteName('slug'),
|
||||
$this->getSlugColumn($query, 'c.id', 'c.alias') . ' AS ' . $db->quoteName('catslug'),
|
||||
]
|
||||
);
|
||||
|
||||
// Filter on month, year
|
||||
// First, get the date field
|
||||
$queryDate = QueryHelper::getQueryDate($articleOrderDate, $this->getDatabase());
|
||||
|
||||
if ($month = (int) $this->getState('filter.month')) {
|
||||
$query->where($query->month($queryDate) . ' = :month')
|
||||
->bind(':month', $month, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
if ($year = (int) $this->getState('filter.year')) {
|
||||
$query->where($query->year($queryDate) . ' = :year')
|
||||
->bind(':year', $year, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
if (\count($catids) > 0) {
|
||||
$query->whereIn($db->quoteName('c.id'), $catids);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the archived article list
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Lets load the content if it doesn't already exist
|
||||
if (empty($this->_data)) {
|
||||
// Get the page/component configuration
|
||||
$params = $app->getParams();
|
||||
|
||||
// Get the pagination request variables
|
||||
$limit = $app->getInput()->get('limit', $params->get('display_num', 20), 'uint');
|
||||
$limitstart = $app->getInput()->get('limitstart', 0, 'uint');
|
||||
|
||||
$query = $this->_buildQuery();
|
||||
|
||||
$this->_data = $this->_getList($query, $limitstart, $limit);
|
||||
}
|
||||
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the archived articles years
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.6.0
|
||||
*/
|
||||
public function getYears()
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
$query = $db->getQuery(true);
|
||||
$queryDate = QueryHelper::getQueryDate($this->state->params->get('order_date'), $db);
|
||||
$years = $query->year($queryDate);
|
||||
|
||||
$query->select('DISTINCT ' . $years)
|
||||
->from($db->quoteName('#__content', 'a'))
|
||||
->where($db->quoteName('a.state') . ' = ' . ContentComponent::CONDITION_ARCHIVED)
|
||||
->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('a.publish_up') . ' IS NULL',
|
||||
$db->quoteName('a.publish_up') . ' <= :publishUp',
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('a.publish_down') . ' IS NULL',
|
||||
$db->quoteName('a.publish_down') . ' >= :publishDown',
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->bind(':publishUp', $nowDate)
|
||||
->bind(':publishDown', $nowDate)
|
||||
->order('1 ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate column expression for slug or catslug.
|
||||
*
|
||||
* @param \Joomla\Database\DatabaseQuery $query Current query instance.
|
||||
* @param string $id Column id name.
|
||||
* @param string $alias Column alias name.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private function getSlugColumn($query, $id, $alias)
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
return 'CASE WHEN '
|
||||
. $query->charLength($db->quoteName($alias), '!=', '0')
|
||||
. ' THEN '
|
||||
. $query->concatenate([$query->castAsChar($db->quoteName($id)), $db->quoteName($alias)], ':')
|
||||
. ' ELSE '
|
||||
. $query->castAsChar($id) . ' END';
|
||||
}
|
||||
}
|
||||
435
components/com_content/src/Model/ArticleModel.php
Normal file
435
components/com_content/src/Model/ArticleModel.php
Normal file
@ -0,0 +1,435 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Model\ItemModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Component\Content\Administrator\Extension\ContentComponent;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Utilities\IpHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component Article Model
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class ArticleModel extends ItemModel
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_content.article';
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Load state from the request.
|
||||
$pk = $app->getInput()->getInt('id');
|
||||
$this->setState('article.id', $pk);
|
||||
|
||||
$offset = $app->getInput()->getUint('limitstart');
|
||||
$this->setState('list.offset', $offset);
|
||||
|
||||
// Load the parameters.
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
// If $pk is set then authorise on complete asset, else on component only
|
||||
$asset = empty($pk) ? 'com_content' : 'com_content.article.' . $pk;
|
||||
|
||||
if ((!$user->authorise('core.edit.state', $asset)) && (!$user->authorise('core.edit', $asset))) {
|
||||
$this->setState('filter.published', ContentComponent::CONDITION_PUBLISHED);
|
||||
$this->setState('filter.archived', ContentComponent::CONDITION_ARCHIVED);
|
||||
}
|
||||
|
||||
$this->setState('filter.language', Multilanguage::isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get article data.
|
||||
*
|
||||
* @param integer $pk The id of the article.
|
||||
*
|
||||
* @return object|boolean Menu item data object on success, boolean false
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
$pk = (int) ($pk ?: $this->getState('article.id'));
|
||||
|
||||
if ($this->_item === null) {
|
||||
$this->_item = [];
|
||||
}
|
||||
|
||||
if (!isset($this->_item[$pk])) {
|
||||
try {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select(
|
||||
$this->getState(
|
||||
'item.select',
|
||||
[
|
||||
$db->quoteName('a.id'),
|
||||
$db->quoteName('a.asset_id'),
|
||||
$db->quoteName('a.title'),
|
||||
$db->quoteName('a.alias'),
|
||||
$db->quoteName('a.introtext'),
|
||||
$db->quoteName('a.fulltext'),
|
||||
$db->quoteName('a.state'),
|
||||
$db->quoteName('a.catid'),
|
||||
$db->quoteName('a.created'),
|
||||
$db->quoteName('a.created_by'),
|
||||
$db->quoteName('a.created_by_alias'),
|
||||
$db->quoteName('a.modified'),
|
||||
$db->quoteName('a.modified_by'),
|
||||
$db->quoteName('a.checked_out'),
|
||||
$db->quoteName('a.checked_out_time'),
|
||||
$db->quoteName('a.publish_up'),
|
||||
$db->quoteName('a.publish_down'),
|
||||
$db->quoteName('a.images'),
|
||||
$db->quoteName('a.urls'),
|
||||
$db->quoteName('a.attribs'),
|
||||
$db->quoteName('a.version'),
|
||||
$db->quoteName('a.ordering'),
|
||||
$db->quoteName('a.metakey'),
|
||||
$db->quoteName('a.metadesc'),
|
||||
$db->quoteName('a.access'),
|
||||
$db->quoteName('a.hits'),
|
||||
$db->quoteName('a.metadata'),
|
||||
$db->quoteName('a.featured'),
|
||||
$db->quoteName('a.language'),
|
||||
]
|
||||
)
|
||||
)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('fp.featured_up'),
|
||||
$db->quoteName('fp.featured_down'),
|
||||
$db->quoteName('c.title', 'category_title'),
|
||||
$db->quoteName('c.alias', 'category_alias'),
|
||||
$db->quoteName('c.access', 'category_access'),
|
||||
$db->quoteName('c.language', 'category_language'),
|
||||
$db->quoteName('fp.ordering'),
|
||||
$db->quoteName('u.name', 'author'),
|
||||
$db->quoteName('parent.title', 'parent_title'),
|
||||
$db->quoteName('parent.id', 'parent_id'),
|
||||
$db->quoteName('parent.path', 'parent_route'),
|
||||
$db->quoteName('parent.alias', 'parent_alias'),
|
||||
$db->quoteName('parent.language', 'parent_language'),
|
||||
'ROUND(' . $db->quoteName('v.rating_sum') . ' / ' . $db->quoteName('v.rating_count') . ', 1) AS '
|
||||
. $db->quoteName('rating'),
|
||||
$db->quoteName('v.rating_count', 'rating_count'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__content', 'a'))
|
||||
->join(
|
||||
'INNER',
|
||||
$db->quoteName('#__categories', 'c'),
|
||||
$db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid')
|
||||
)
|
||||
->join('LEFT', $db->quoteName('#__content_frontpage', 'fp'), $db->quoteName('fp.content_id') . ' = ' . $db->quoteName('a.id'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('a.created_by'))
|
||||
->join('LEFT', $db->quoteName('#__categories', 'parent'), $db->quoteName('parent.id') . ' = ' . $db->quoteName('c.parent_id'))
|
||||
->join('LEFT', $db->quoteName('#__content_rating', 'v'), $db->quoteName('a.id') . ' = ' . $db->quoteName('v.content_id'))
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('a.id') . ' = :pk',
|
||||
$db->quoteName('c.published') . ' > 0',
|
||||
]
|
||||
)
|
||||
->bind(':pk', $pk, ParameterType::INTEGER);
|
||||
|
||||
// Filter by language
|
||||
if ($this->getState('filter.language')) {
|
||||
$query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
|
||||
}
|
||||
|
||||
if (
|
||||
!$user->authorise('core.edit.state', 'com_content.article.' . $pk)
|
||||
&& !$user->authorise('core.edit', 'com_content.article.' . $pk)
|
||||
) {
|
||||
// Filter by start and end dates.
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
|
||||
$query->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('a.publish_up') . ' IS NULL',
|
||||
$db->quoteName('a.publish_up') . ' <= :publishUp',
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('a.publish_down') . ' IS NULL',
|
||||
$db->quoteName('a.publish_down') . ' >= :publishDown',
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->bind([':publishUp', ':publishDown'], $nowDate);
|
||||
}
|
||||
|
||||
// Filter by published state.
|
||||
$published = $this->getState('filter.published');
|
||||
$archived = $this->getState('filter.archived');
|
||||
|
||||
if (is_numeric($published)) {
|
||||
$query->whereIn($db->quoteName('a.state'), [(int) $published, (int) $archived]);
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
$data = $db->loadObject();
|
||||
|
||||
if (empty($data)) {
|
||||
throw new \Exception(Text::_('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
// Check for published state if filter set.
|
||||
if ((is_numeric($published) || is_numeric($archived)) && ($data->state != $published && $data->state != $archived)) {
|
||||
throw new \Exception(Text::_('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND'), 404);
|
||||
}
|
||||
|
||||
// Convert parameter fields to objects.
|
||||
$registry = new Registry($data->attribs);
|
||||
|
||||
$data->params = clone $this->getState('params');
|
||||
$data->params->merge($registry);
|
||||
|
||||
$data->metadata = new Registry($data->metadata);
|
||||
|
||||
// Technically guest could edit an article, but lets not check that to improve performance a little.
|
||||
if (!$user->get('guest')) {
|
||||
$userId = $user->get('id');
|
||||
$asset = 'com_content.article.' . $data->id;
|
||||
|
||||
// Check general edit permission first.
|
||||
if ($user->authorise('core.edit', $asset)) {
|
||||
$data->params->set('access-edit', true);
|
||||
} elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) {
|
||||
// Now check if edit.own is available.
|
||||
// Check for a valid user and that they are the owner.
|
||||
if ($userId == $data->created_by) {
|
||||
$data->params->set('access-edit', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute view access permissions.
|
||||
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 {
|
||||
// If no access filter is set, the layout takes some responsibility for display of limited information.
|
||||
$user = $this->getCurrentUser();
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
|
||||
if ($data->catid == 0 || $data->category_access === null) {
|
||||
$data->params->set('access-view', \in_array($data->access, $groups));
|
||||
} else {
|
||||
$data->params->set('access-view', \in_array($data->access, $groups) && \in_array($data->category_access, $groups));
|
||||
}
|
||||
}
|
||||
|
||||
$this->_item[$pk] = $data;
|
||||
} catch (\Exception $e) {
|
||||
if ($e->getCode() == 404) {
|
||||
// Need to go through the error handler to allow Redirect to work.
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->setError($e);
|
||||
$this->_item[$pk] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_item[$pk];
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the hit counter for the article.
|
||||
*
|
||||
* @param integer $pk Optional primary key of the article to increment.
|
||||
*
|
||||
* @return boolean True if successful; false otherwise and internal error set.
|
||||
*/
|
||||
public function hit($pk = 0)
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
$hitcount = $input->getInt('hitcount', 1);
|
||||
|
||||
if ($hitcount) {
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('article.id');
|
||||
|
||||
$table = Table::getInstance('Content', '\\Joomla\\CMS\\Table\\');
|
||||
$table->hit($pk);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save user vote on article
|
||||
*
|
||||
* @param integer $pk Joomla Article Id
|
||||
* @param integer $rate Voting rate
|
||||
*
|
||||
* @return boolean Return true on success
|
||||
*/
|
||||
public function storeVote($pk = 0, $rate = 0)
|
||||
{
|
||||
$pk = (int) $pk;
|
||||
$rate = (int) $rate;
|
||||
|
||||
if ($rate >= 1 && $rate <= 5 && $pk > 0) {
|
||||
$userIP = IpHelper::getIp();
|
||||
|
||||
// Initialize variables.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Create the base select statement.
|
||||
$query->select('*')
|
||||
->from($db->quoteName('#__content_rating'))
|
||||
->where($db->quoteName('content_id') . ' = :pk')
|
||||
->bind(':pk', $pk, ParameterType::INTEGER);
|
||||
|
||||
// Set the query and load the result.
|
||||
$db->setQuery($query);
|
||||
|
||||
// Check for a database error.
|
||||
try {
|
||||
$rating = $db->loadObject();
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// There are no ratings yet, so lets insert our rating
|
||||
if (!$rating) {
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Create the base insert statement.
|
||||
$query->insert($db->quoteName('#__content_rating'))
|
||||
->columns(
|
||||
[
|
||||
$db->quoteName('content_id'),
|
||||
$db->quoteName('lastip'),
|
||||
$db->quoteName('rating_sum'),
|
||||
$db->quoteName('rating_count'),
|
||||
]
|
||||
)
|
||||
->values(':pk, :ip, :rate, 1')
|
||||
->bind(':pk', $pk, ParameterType::INTEGER)
|
||||
->bind(':ip', $userIP)
|
||||
->bind(':rate', $rate, ParameterType::INTEGER);
|
||||
|
||||
// Set the query and execute the insert.
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ($userIP != $rating->lastip) {
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Create the base update statement.
|
||||
$query->update($db->quoteName('#__content_rating'))
|
||||
->set(
|
||||
[
|
||||
$db->quoteName('rating_count') . ' = ' . $db->quoteName('rating_count') . ' + 1',
|
||||
$db->quoteName('rating_sum') . ' = ' . $db->quoteName('rating_sum') . ' + :rate',
|
||||
$db->quoteName('lastip') . ' = :ip',
|
||||
]
|
||||
)
|
||||
->where($db->quoteName('content_id') . ' = :pk')
|
||||
->bind(':rate', $rate, ParameterType::INTEGER)
|
||||
->bind(':ip', $userIP)
|
||||
->bind(':pk', $pk, ParameterType::INTEGER);
|
||||
|
||||
// Set the query and execute the update.
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_CONTENT_INVALID_RATING', $rate), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the cache of com_content and content modules
|
||||
*
|
||||
* @param string $group The cache group
|
||||
* @param integer $clientId No longer used, will be removed without replacement
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.9.9
|
||||
*/
|
||||
protected function cleanCache($group = null, $clientId = 0)
|
||||
{
|
||||
parent::cleanCache('com_content');
|
||||
parent::cleanCache('mod_articles_archive');
|
||||
parent::cleanCache('mod_articles_categories');
|
||||
parent::cleanCache('mod_articles_category');
|
||||
parent::cleanCache('mod_articles_latest');
|
||||
parent::cleanCache('mod_articles_news');
|
||||
parent::cleanCache('mod_articles_popular');
|
||||
}
|
||||
}
|
||||
838
components/com_content/src/Model/ArticlesModel.php
Normal file
838
components/com_content/src/Model/ArticlesModel.php
Normal file
@ -0,0 +1,838 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Model;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\Component\Content\Administrator\Extension\ContentComponent;
|
||||
use Joomla\Component\Content\Site\Helper\AssociationHelper;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\String\StringHelper;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* This models supports retrieving lists of articles.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ArticlesModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @see \JController
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'title', 'a.title',
|
||||
'alias', 'a.alias',
|
||||
'checked_out', 'a.checked_out',
|
||||
'checked_out_time', 'a.checked_out_time',
|
||||
'catid', 'a.catid', 'category_title',
|
||||
'state', 'a.state',
|
||||
'access', 'a.access', 'access_level',
|
||||
'created', 'a.created',
|
||||
'created_by', 'a.created_by',
|
||||
'ordering', 'a.ordering',
|
||||
'featured', 'a.featured',
|
||||
'language', 'a.language',
|
||||
'hits', 'a.hits',
|
||||
'publish_up', 'a.publish_up',
|
||||
'publish_down', 'a.publish_down',
|
||||
'images', 'a.images',
|
||||
'urls', 'a.urls',
|
||||
'filter_tag',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* This method should only be called once per instantiation and is designed
|
||||
* to be called on the first call to the getState() method unless the model
|
||||
* configuration flag to ignore the request is set.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.0.1
|
||||
*/
|
||||
protected function populateState($ordering = 'ordering', $direction = 'ASC')
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
|
||||
// List state information
|
||||
$value = $input->get('limit', $app->get('list_limit', 0), 'uint');
|
||||
$this->setState('list.limit', $value);
|
||||
|
||||
$value = $input->get('limitstart', 0, 'uint');
|
||||
$this->setState('list.start', $value);
|
||||
|
||||
$value = $input->get('filter_tag', 0, 'uint');
|
||||
$this->setState('filter.tag', $value);
|
||||
|
||||
$orderCol = $input->get('filter_order', 'a.ordering');
|
||||
|
||||
if (!\in_array($orderCol, $this->filter_fields)) {
|
||||
$orderCol = 'a.ordering';
|
||||
}
|
||||
|
||||
$this->setState('list.ordering', $orderCol);
|
||||
|
||||
$listOrder = $input->get('filter_order_Dir', 'ASC');
|
||||
|
||||
if (!\in_array(strtoupper($listOrder), ['ASC', 'DESC', ''])) {
|
||||
$listOrder = 'ASC';
|
||||
}
|
||||
|
||||
$this->setState('list.direction', $listOrder);
|
||||
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) {
|
||||
// Filter on published for those who do not have edit or edit.state rights.
|
||||
$this->setState('filter.published', ContentComponent::CONDITION_PUBLISHED);
|
||||
}
|
||||
|
||||
$this->setState('filter.language', Multilanguage::isEnabled());
|
||||
|
||||
// Process show_noauth parameter
|
||||
if ((!$params->get('show_noauth')) || (!ComponentHelper::getParams('com_content')->get('show_noauth'))) {
|
||||
$this->setState('filter.access', true);
|
||||
} else {
|
||||
$this->setState('filter.access', false);
|
||||
}
|
||||
|
||||
$this->setState('layout', $input->getString('layout'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . serialize($this->getState('filter.published'));
|
||||
$id .= ':' . $this->getState('filter.access');
|
||||
$id .= ':' . $this->getState('filter.featured');
|
||||
$id .= ':' . serialize($this->getState('filter.article_id'));
|
||||
$id .= ':' . $this->getState('filter.article_id.include');
|
||||
$id .= ':' . serialize($this->getState('filter.category_id'));
|
||||
$id .= ':' . $this->getState('filter.category_id.include');
|
||||
$id .= ':' . serialize($this->getState('filter.author_id'));
|
||||
$id .= ':' . $this->getState('filter.author_id.include');
|
||||
$id .= ':' . serialize($this->getState('filter.author_alias'));
|
||||
$id .= ':' . $this->getState('filter.author_alias.include');
|
||||
$id .= ':' . $this->getState('filter.date_filtering');
|
||||
$id .= ':' . $this->getState('filter.date_field');
|
||||
$id .= ':' . $this->getState('filter.start_date_range');
|
||||
$id .= ':' . $this->getState('filter.end_date_range');
|
||||
$id .= ':' . $this->getState('filter.relative_date');
|
||||
$id .= ':' . serialize($this->getState('filter.tag'));
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the master query for retrieving a list of articles subject to the model state.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
|
||||
/** @var \Joomla\Database\DatabaseQuery $query */
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
|
||||
$conditionArchived = ContentComponent::CONDITION_ARCHIVED;
|
||||
$conditionUnpublished = ContentComponent::CONDITION_UNPUBLISHED;
|
||||
|
||||
// Select the required fields from the table.
|
||||
$query->select(
|
||||
$this->getState(
|
||||
'list.select',
|
||||
[
|
||||
$db->quoteName('a.id'),
|
||||
$db->quoteName('a.title'),
|
||||
$db->quoteName('a.alias'),
|
||||
$db->quoteName('a.introtext'),
|
||||
$db->quoteName('a.fulltext'),
|
||||
$db->quoteName('a.checked_out'),
|
||||
$db->quoteName('a.checked_out_time'),
|
||||
$db->quoteName('a.catid'),
|
||||
$db->quoteName('a.created'),
|
||||
$db->quoteName('a.created_by'),
|
||||
$db->quoteName('a.created_by_alias'),
|
||||
$db->quoteName('a.modified'),
|
||||
$db->quoteName('a.modified_by'),
|
||||
// Use created if publish_up is null
|
||||
'CASE WHEN ' . $db->quoteName('a.publish_up') . ' IS NULL THEN ' . $db->quoteName('a.created')
|
||||
. ' ELSE ' . $db->quoteName('a.publish_up') . ' END AS ' . $db->quoteName('publish_up'),
|
||||
$db->quoteName('a.publish_down'),
|
||||
$db->quoteName('a.images'),
|
||||
$db->quoteName('a.urls'),
|
||||
$db->quoteName('a.attribs'),
|
||||
$db->quoteName('a.metadata'),
|
||||
$db->quoteName('a.metakey'),
|
||||
$db->quoteName('a.metadesc'),
|
||||
$db->quoteName('a.access'),
|
||||
$db->quoteName('a.hits'),
|
||||
$db->quoteName('a.featured'),
|
||||
$db->quoteName('a.language'),
|
||||
$query->length($db->quoteName('a.fulltext')) . ' AS ' . $db->quoteName('readmore'),
|
||||
$db->quoteName('a.ordering'),
|
||||
]
|
||||
)
|
||||
)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('fp.featured_up'),
|
||||
$db->quoteName('fp.featured_down'),
|
||||
// Published/archived article in archived category is treated as archived article. If category is not published then force 0.
|
||||
'CASE WHEN ' . $db->quoteName('c.published') . ' = 2 AND ' . $db->quoteName('a.state') . ' > 0 THEN ' . $conditionArchived
|
||||
. ' WHEN ' . $db->quoteName('c.published') . ' != 1 THEN ' . $conditionUnpublished
|
||||
. ' ELSE ' . $db->quoteName('a.state') . ' END AS ' . $db->quoteName('state'),
|
||||
$db->quoteName('c.title', 'category_title'),
|
||||
$db->quoteName('c.path', 'category_route'),
|
||||
$db->quoteName('c.access', 'category_access'),
|
||||
$db->quoteName('c.alias', 'category_alias'),
|
||||
$db->quoteName('c.language', 'category_language'),
|
||||
$db->quoteName('c.published'),
|
||||
$db->quoteName('c.published', 'parents_published'),
|
||||
$db->quoteName('c.lft'),
|
||||
'CASE WHEN ' . $db->quoteName('a.created_by_alias') . ' > ' . $db->quote(' ') . ' THEN ' . $db->quoteName('a.created_by_alias')
|
||||
. ' ELSE ' . $db->quoteName('ua.name') . ' END AS ' . $db->quoteName('author'),
|
||||
$db->quoteName('ua.email', 'author_email'),
|
||||
$db->quoteName('uam.name', 'modified_by_name'),
|
||||
$db->quoteName('parent.title', 'parent_title'),
|
||||
$db->quoteName('parent.id', 'parent_id'),
|
||||
$db->quoteName('parent.path', 'parent_route'),
|
||||
$db->quoteName('parent.alias', 'parent_alias'),
|
||||
$db->quoteName('parent.language', 'parent_language'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__content', 'a'))
|
||||
->join('LEFT', $db->quoteName('#__categories', 'c'), $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'ua'), $db->quoteName('ua.id') . ' = ' . $db->quoteName('a.created_by'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'uam'), $db->quoteName('uam.id') . ' = ' . $db->quoteName('a.modified_by'))
|
||||
->join('LEFT', $db->quoteName('#__categories', 'parent'), $db->quoteName('parent.id') . ' = ' . $db->quoteName('c.parent_id'));
|
||||
|
||||
$params = $this->getState('params');
|
||||
$orderby_sec = $params->get('orderby_sec');
|
||||
|
||||
// Join over the frontpage articles if required.
|
||||
$frontpageJoin = 'LEFT';
|
||||
|
||||
if ($this->getState('filter.frontpage')) {
|
||||
if ($orderby_sec === 'front') {
|
||||
$query->select($db->quoteName('fp.ordering'));
|
||||
$frontpageJoin = 'INNER';
|
||||
} else {
|
||||
$query->where($db->quoteName('a.featured') . ' = 1');
|
||||
}
|
||||
|
||||
$query->where(
|
||||
[
|
||||
'(' . $db->quoteName('fp.featured_up') . ' IS NULL OR ' . $db->quoteName('fp.featured_up') . ' <= :frontpageUp)',
|
||||
'(' . $db->quoteName('fp.featured_down') . ' IS NULL OR ' . $db->quoteName('fp.featured_down') . ' >= :frontpageDown)',
|
||||
]
|
||||
)
|
||||
->bind(':frontpageUp', $nowDate)
|
||||
->bind(':frontpageDown', $nowDate);
|
||||
} elseif ($orderby_sec === 'front' || $this->getState('list.ordering') === 'fp.ordering') {
|
||||
$query->select($db->quoteName('fp.ordering'));
|
||||
}
|
||||
|
||||
$query->join($frontpageJoin, $db->quoteName('#__content_frontpage', 'fp'), $db->quoteName('fp.content_id') . ' = ' . $db->quoteName('a.id'));
|
||||
|
||||
if (PluginHelper::isEnabled('content', 'vote')) {
|
||||
// Join on voting table
|
||||
$query->select(
|
||||
[
|
||||
'COALESCE(NULLIF(ROUND(' . $db->quoteName('v.rating_sum') . ' / ' . $db->quoteName('v.rating_count') . ', 1), 0), 0)'
|
||||
. ' AS ' . $db->quoteName('rating'),
|
||||
'COALESCE(NULLIF(' . $db->quoteName('v.rating_count') . ', 0), 0) AS ' . $db->quoteName('rating_count'),
|
||||
]
|
||||
)
|
||||
->join('LEFT', $db->quoteName('#__content_rating', 'v'), $db->quoteName('a.id') . ' = ' . $db->quoteName('v.content_id'));
|
||||
}
|
||||
|
||||
// Filter by access level.
|
||||
if ($this->getState('filter.access', true)) {
|
||||
$groups = $this->getState('filter.viewlevels', $user->getAuthorisedViewLevels());
|
||||
$query->whereIn($db->quoteName('a.access'), $groups)
|
||||
->whereIn($db->quoteName('c.access'), $groups);
|
||||
}
|
||||
|
||||
// Filter by published state
|
||||
$condition = $this->getState('filter.published');
|
||||
|
||||
if (is_numeric($condition) && $condition == 2) {
|
||||
/**
|
||||
* If category is archived then article has to be published or archived.
|
||||
* Or category is published then article has to be archived.
|
||||
*/
|
||||
$query->where('((' . $db->quoteName('c.published') . ' = 2 AND ' . $db->quoteName('a.state') . ' > :conditionUnpublished)'
|
||||
. ' OR (' . $db->quoteName('c.published') . ' = 1 AND ' . $db->quoteName('a.state') . ' = :conditionArchived))')
|
||||
->bind(':conditionUnpublished', $conditionUnpublished, ParameterType::INTEGER)
|
||||
->bind(':conditionArchived', $conditionArchived, ParameterType::INTEGER);
|
||||
} elseif (is_numeric($condition)) {
|
||||
$condition = (int) $condition;
|
||||
|
||||
// Category has to be published
|
||||
$query->where($db->quoteName('c.published') . ' = 1 AND ' . $db->quoteName('a.state') . ' = :condition')
|
||||
->bind(':condition', $condition, ParameterType::INTEGER);
|
||||
} elseif (\is_array($condition)) {
|
||||
// Category has to be published
|
||||
$query->where(
|
||||
$db->quoteName('c.published') . ' = 1 AND ' . $db->quoteName('a.state')
|
||||
. ' IN (' . implode(',', $query->bindArray($condition)) . ')'
|
||||
);
|
||||
}
|
||||
|
||||
// Filter by featured state
|
||||
$featured = $this->getState('filter.featured');
|
||||
|
||||
switch ($featured) {
|
||||
case 'hide':
|
||||
$query->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('a.featured') . ' = 0',
|
||||
'(' . $db->quoteName('fp.featured_up') . ' IS NOT NULL AND ' . $db->quoteName('fp.featured_up') . ' >= :featuredUp)',
|
||||
'(' . $db->quoteName('fp.featured_down') . ' IS NOT NULL AND ' . $db->quoteName('fp.featured_down') . ' <= :featuredDown)',
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->bind(':featuredUp', $nowDate)
|
||||
->bind(':featuredDown', $nowDate);
|
||||
break;
|
||||
|
||||
case 'only':
|
||||
$query->where(
|
||||
[
|
||||
$db->quoteName('a.featured') . ' = 1',
|
||||
'(' . $db->quoteName('fp.featured_up') . ' IS NULL OR ' . $db->quoteName('fp.featured_up') . ' <= :featuredUp)',
|
||||
'(' . $db->quoteName('fp.featured_down') . ' IS NULL OR ' . $db->quoteName('fp.featured_down') . ' >= :featuredDown)',
|
||||
]
|
||||
)
|
||||
->bind(':featuredUp', $nowDate)
|
||||
->bind(':featuredDown', $nowDate);
|
||||
break;
|
||||
|
||||
case 'show':
|
||||
default:
|
||||
// Normally we do not discriminate between featured/unfeatured items.
|
||||
break;
|
||||
}
|
||||
|
||||
// Filter by a single or group of articles.
|
||||
$articleId = $this->getState('filter.article_id');
|
||||
|
||||
if (is_numeric($articleId)) {
|
||||
$articleId = (int) $articleId;
|
||||
$type = $this->getState('filter.article_id.include', true) ? ' = ' : ' <> ';
|
||||
$query->where($db->quoteName('a.id') . $type . ':articleId')
|
||||
->bind(':articleId', $articleId, ParameterType::INTEGER);
|
||||
} elseif (\is_array($articleId)) {
|
||||
$articleId = ArrayHelper::toInteger($articleId);
|
||||
|
||||
if ($this->getState('filter.article_id.include', true)) {
|
||||
$query->whereIn($db->quoteName('a.id'), $articleId);
|
||||
} else {
|
||||
$query->whereNotIn($db->quoteName('a.id'), $articleId);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by a single or group of categories
|
||||
$categoryId = $this->getState('filter.category_id');
|
||||
|
||||
if (is_numeric($categoryId)) {
|
||||
$type = $this->getState('filter.category_id.include', true) ? ' = ' : ' <> ';
|
||||
|
||||
// Add subcategory check
|
||||
$includeSubcategories = $this->getState('filter.subcategories', false);
|
||||
|
||||
if ($includeSubcategories) {
|
||||
$categoryId = (int) $categoryId;
|
||||
$levels = (int) $this->getState('filter.max_category_levels', 1);
|
||||
|
||||
// Create a subquery for the subcategory list
|
||||
$subQuery = $db->getQuery(true)
|
||||
->select($db->quoteName('sub.id'))
|
||||
->from($db->quoteName('#__categories', 'sub'))
|
||||
->join(
|
||||
'INNER',
|
||||
$db->quoteName('#__categories', 'this'),
|
||||
$db->quoteName('sub.lft') . ' > ' . $db->quoteName('this.lft')
|
||||
. ' AND ' . $db->quoteName('sub.rgt') . ' < ' . $db->quoteName('this.rgt')
|
||||
)
|
||||
->where($db->quoteName('this.id') . ' = :subCategoryId');
|
||||
|
||||
$query->bind(':subCategoryId', $categoryId, ParameterType::INTEGER);
|
||||
|
||||
if ($levels >= 0) {
|
||||
$subQuery->where($db->quoteName('sub.level') . ' <= ' . $db->quoteName('this.level') . ' + :levels');
|
||||
$query->bind(':levels', $levels, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Add the subquery to the main query
|
||||
$query->where(
|
||||
'(' . $db->quoteName('a.catid') . $type . ':categoryId OR ' . $db->quoteName('a.catid') . ' IN (' . $subQuery . '))'
|
||||
);
|
||||
$query->bind(':categoryId', $categoryId, ParameterType::INTEGER);
|
||||
} else {
|
||||
$query->where($db->quoteName('a.catid') . $type . ':categoryId');
|
||||
$query->bind(':categoryId', $categoryId, ParameterType::INTEGER);
|
||||
}
|
||||
} elseif (\is_array($categoryId) && (\count($categoryId) > 0)) {
|
||||
$categoryId = ArrayHelper::toInteger($categoryId);
|
||||
|
||||
if (!empty($categoryId)) {
|
||||
if ($this->getState('filter.category_id.include', true)) {
|
||||
$query->whereIn($db->quoteName('a.catid'), $categoryId);
|
||||
} else {
|
||||
$query->whereNotIn($db->quoteName('a.catid'), $categoryId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by author
|
||||
$authorId = $this->getState('filter.author_id');
|
||||
$authorWhere = '';
|
||||
|
||||
if (is_numeric($authorId)) {
|
||||
$authorId = (int) $authorId;
|
||||
$type = $this->getState('filter.author_id.include', true) ? ' = ' : ' <> ';
|
||||
$authorWhere = $db->quoteName('a.created_by') . $type . ':authorId';
|
||||
$query->bind(':authorId', $authorId, ParameterType::INTEGER);
|
||||
} elseif (\is_array($authorId)) {
|
||||
$authorId = array_values(array_filter($authorId, 'is_numeric'));
|
||||
|
||||
if ($authorId) {
|
||||
$type = $this->getState('filter.author_id.include', true) ? ' IN' : ' NOT IN';
|
||||
$authorWhere = $db->quoteName('a.created_by') . $type . ' (' . implode(',', $query->bindArray($authorId)) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by author alias
|
||||
$authorAlias = $this->getState('filter.author_alias');
|
||||
$authorAliasWhere = '';
|
||||
|
||||
if (\is_string($authorAlias)) {
|
||||
$type = $this->getState('filter.author_alias.include', true) ? ' = ' : ' <> ';
|
||||
$authorAliasWhere = $db->quoteName('a.created_by_alias') . $type . ':authorAlias';
|
||||
$query->bind(':authorAlias', $authorAlias);
|
||||
} elseif (\is_array($authorAlias) && !empty($authorAlias)) {
|
||||
$type = $this->getState('filter.author_alias.include', true) ? ' IN' : ' NOT IN';
|
||||
$authorAliasWhere = $db->quoteName('a.created_by_alias') . $type
|
||||
. ' (' . implode(',', $query->bindArray($authorAlias, ParameterType::STRING)) . ')';
|
||||
}
|
||||
|
||||
if (!empty($authorWhere) && !empty($authorAliasWhere)) {
|
||||
$query->where('(' . $authorWhere . ' OR ' . $authorAliasWhere . ')');
|
||||
} elseif (!empty($authorWhere) || !empty($authorAliasWhere)) {
|
||||
// One of these is empty, the other is not so we just add both
|
||||
$query->where($authorWhere . $authorAliasWhere);
|
||||
}
|
||||
|
||||
// Filter by start and end dates.
|
||||
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) {
|
||||
$query->where(
|
||||
[
|
||||
'(' . $db->quoteName('a.publish_up') . ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publishUp)',
|
||||
'(' . $db->quoteName('a.publish_down') . ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publishDown)',
|
||||
]
|
||||
)
|
||||
->bind(':publishUp', $nowDate)
|
||||
->bind(':publishDown', $nowDate);
|
||||
}
|
||||
|
||||
// Filter by Date Range or Relative Date
|
||||
$dateFiltering = $this->getState('filter.date_filtering', 'off');
|
||||
$dateField = $db->escape($this->getState('filter.date_field', 'a.created'));
|
||||
|
||||
switch ($dateFiltering) {
|
||||
case 'range':
|
||||
$startDateRange = $this->getState('filter.start_date_range', '');
|
||||
$endDateRange = $this->getState('filter.end_date_range', '');
|
||||
|
||||
if ($startDateRange || $endDateRange) {
|
||||
$query->where($db->quoteName($dateField) . ' IS NOT NULL');
|
||||
|
||||
if ($startDateRange) {
|
||||
$query->where($db->quoteName($dateField) . ' >= :startDateRange')
|
||||
->bind(':startDateRange', $startDateRange);
|
||||
}
|
||||
|
||||
if ($endDateRange) {
|
||||
$query->where($db->quoteName($dateField) . ' <= :endDateRange')
|
||||
->bind(':endDateRange', $endDateRange);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'relative':
|
||||
$relativeDate = (int) $this->getState('filter.relative_date', 0);
|
||||
$query->where(
|
||||
$db->quoteName($dateField) . ' IS NOT NULL AND '
|
||||
. $db->quoteName($dateField) . ' >= ' . $query->dateAdd($db->quote($nowDate), -1 * $relativeDate, 'DAY')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'off':
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Process the filter for list views with user-entered filters
|
||||
if (\is_object($params) && ($params->get('filter_field') !== 'hide') && ($filter = $this->getState('list.filter'))) {
|
||||
// Clean filter variable
|
||||
$filter = StringHelper::strtolower($filter);
|
||||
$monthFilter = $filter;
|
||||
$hitsFilter = (int) $filter;
|
||||
$textFilter = '%' . $filter . '%';
|
||||
|
||||
switch ($params->get('filter_field')) {
|
||||
case 'author':
|
||||
$query->where(
|
||||
'LOWER(CASE WHEN ' . $db->quoteName('a.created_by_alias') . ' > ' . $db->quote(' ')
|
||||
. ' THEN ' . $db->quoteName('a.created_by_alias') . ' ELSE ' . $db->quoteName('ua.name') . ' END) LIKE :search'
|
||||
)
|
||||
->bind(':search', $textFilter);
|
||||
break;
|
||||
|
||||
case 'hits':
|
||||
$query->where($db->quoteName('a.hits') . ' >= :hits')
|
||||
->bind(':hits', $hitsFilter, ParameterType::INTEGER);
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
if ($monthFilter != '') {
|
||||
$monthStart = date("Y-m-d", strtotime($monthFilter)) . ' 00:00:00';
|
||||
$monthEnd = date("Y-m-t", strtotime($monthFilter)) . ' 23:59:59';
|
||||
|
||||
$query->where(
|
||||
[
|
||||
':monthStart <= CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END',
|
||||
':monthEnd >= CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END',
|
||||
]
|
||||
)
|
||||
->bind(':monthStart', $monthStart)
|
||||
->bind(':monthEnd', $monthEnd);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'title':
|
||||
default:
|
||||
// Default to 'title' if parameter is not valid
|
||||
$query->where('LOWER(' . $db->quoteName('a.title') . ') LIKE :search')
|
||||
->bind(':search', $textFilter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by language
|
||||
if ($this->getState('filter.language')) {
|
||||
$query->whereIn($db->quoteName('a.language'), [Factory::getApplication()->getLanguage()->getTag(), '*'], ParameterType::STRING);
|
||||
}
|
||||
|
||||
// Filter by a single or group of tags.
|
||||
$tagId = $this->getState('filter.tag');
|
||||
|
||||
if (\is_array($tagId) && \count($tagId) === 1) {
|
||||
$tagId = current($tagId);
|
||||
}
|
||||
|
||||
if (\is_array($tagId)) {
|
||||
$tagId = ArrayHelper::toInteger($tagId);
|
||||
|
||||
if ($tagId) {
|
||||
$subQuery = $db->getQuery(true)
|
||||
->select('DISTINCT ' . $db->quoteName('content_item_id'))
|
||||
->from($db->quoteName('#__contentitem_tag_map'))
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('tag_id') . ' IN (' . implode(',', $query->bindArray($tagId)) . ')',
|
||||
$db->quoteName('type_alias') . ' = ' . $db->quote('com_content.article'),
|
||||
]
|
||||
);
|
||||
|
||||
$query->join(
|
||||
'INNER',
|
||||
'(' . $subQuery . ') AS ' . $db->quoteName('tagmap'),
|
||||
$db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
|
||||
);
|
||||
}
|
||||
} elseif ($tagId = (int) $tagId) {
|
||||
$query->join(
|
||||
'INNER',
|
||||
$db->quoteName('#__contentitem_tag_map', 'tagmap'),
|
||||
$db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
|
||||
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_content.article')
|
||||
)
|
||||
->where($db->quoteName('tagmap.tag_id') . ' = :tagId')
|
||||
->bind(':tagId', $tagId, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$query->order(
|
||||
$db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))
|
||||
);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of articles.
|
||||
*
|
||||
* Overridden to inject convert the attribs field into a Registry object.
|
||||
*
|
||||
* @return mixed An array of objects on success, false on failure.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$items = parent::getItems();
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->get('id');
|
||||
$guest = $user->get('guest');
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
$input = Factory::getApplication()->getInput();
|
||||
|
||||
// Get the global params
|
||||
$globalParams = ComponentHelper::getParams('com_content', true);
|
||||
|
||||
$taggedItems = [];
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $item) {
|
||||
$articleParams = new Registry($item->attribs);
|
||||
|
||||
// Unpack readmore and layout params
|
||||
$item->alternative_readmore = $articleParams->get('alternative_readmore');
|
||||
$item->layout = $articleParams->get('layout');
|
||||
|
||||
$item->params = clone $this->getState('params');
|
||||
|
||||
/**
|
||||
* For blogs, article params override menu item params only if menu param = 'use_article'
|
||||
* Otherwise, menu item params control the layout
|
||||
* If menu item is 'use_article' and there is no article param, use global
|
||||
*/
|
||||
if (
|
||||
($input->getString('layout') === 'blog') || ($input->getString('view') === 'featured')
|
||||
|| ($this->getState('params')->get('layout_type') === 'blog')
|
||||
) {
|
||||
// Create an array of just the params set to 'use_article'
|
||||
$menuParamsArray = $this->getState('params')->toArray();
|
||||
$articleArray = [];
|
||||
|
||||
foreach ($menuParamsArray as $key => $value) {
|
||||
if ($value === 'use_article') {
|
||||
// If the article has a value, use it
|
||||
if ($articleParams->get($key) != '') {
|
||||
// Get the value from the article
|
||||
$articleArray[$key] = $articleParams->get($key);
|
||||
} else {
|
||||
// Otherwise, use the global value
|
||||
$articleArray[$key] = $globalParams->get($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Merge the selected article params
|
||||
if (\count($articleArray) > 0) {
|
||||
$articleParams = new Registry($articleArray);
|
||||
$item->params->merge($articleParams);
|
||||
}
|
||||
} else {
|
||||
// For non-blog layouts, merge all of the article params
|
||||
$item->params->merge($articleParams);
|
||||
}
|
||||
|
||||
// Get display date
|
||||
switch ($item->params->get('list_show_date')) {
|
||||
case 'modified':
|
||||
$item->displayDate = $item->modified;
|
||||
break;
|
||||
|
||||
case 'published':
|
||||
$item->displayDate = ($item->publish_up == 0) ? $item->created : $item->publish_up;
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'created':
|
||||
$item->displayDate = $item->created;
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the asset access permissions.
|
||||
* Technically guest could edit an article, but lets not check that to improve performance a little.
|
||||
*/
|
||||
if (!$guest) {
|
||||
$asset = 'com_content.article.' . $item->id;
|
||||
|
||||
// Check general edit permission first.
|
||||
if ($user->authorise('core.edit', $asset)) {
|
||||
$item->params->set('access-edit', true);
|
||||
} elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) {
|
||||
// Now check if edit.own is available.
|
||||
// Check for a valid user and that they are the owner.
|
||||
if ($userId == $item->created_by) {
|
||||
$item->params->set('access-edit', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$access = $this->getState('filter.access');
|
||||
|
||||
if ($access) {
|
||||
// If the access filter has been set, we already have only the articles this user can view.
|
||||
$item->params->set('access-view', true);
|
||||
} else {
|
||||
// If no access filter is set, the layout takes some responsibility for display of limited information.
|
||||
if ($item->catid == 0 || $item->category_access === null) {
|
||||
$item->params->set('access-view', \in_array($item->access, $groups));
|
||||
} else {
|
||||
$item->params->set('access-view', \in_array($item->access, $groups) && \in_array($item->category_access, $groups));
|
||||
}
|
||||
}
|
||||
|
||||
// Some contexts may not use tags data at all, so we allow callers to disable loading tag data
|
||||
if ($this->getState('load_tags', $item->params->get('show_tags', '1'))) {
|
||||
$item->tags = new TagsHelper();
|
||||
$taggedItems[$item->id] = $item;
|
||||
}
|
||||
|
||||
if (Associations::isEnabled() && $item->params->get('show_associations')) {
|
||||
$item->associations = AssociationHelper::displayAssociations($item->id);
|
||||
}
|
||||
}
|
||||
|
||||
// Load tags of all items.
|
||||
if ($taggedItems) {
|
||||
$tagsHelper = new TagsHelper();
|
||||
$itemIds = array_keys($taggedItems);
|
||||
|
||||
foreach ($tagsHelper->getMultipleItemTags('com_content.article', $itemIds) as $id => $tags) {
|
||||
$taggedItems[$id]->tags->itemTags = $tags;
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the starting number of items for the data set.
|
||||
*
|
||||
* @return integer The starting number of items available in the data set.
|
||||
*
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public function getStart()
|
||||
{
|
||||
return $this->getState('list.start');
|
||||
}
|
||||
|
||||
/**
|
||||
* Count Items by Month
|
||||
*
|
||||
* @return mixed An array of objects on success, false on failure.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*/
|
||||
public function countItemsByMonth()
|
||||
{
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get the list query.
|
||||
$listQuery = $this->getListQuery();
|
||||
$bounded = $listQuery->getBounded();
|
||||
|
||||
// Bind list query variables to our new query.
|
||||
$keys = array_keys($bounded);
|
||||
$values = array_column($bounded, 'value');
|
||||
$dataTypes = array_column($bounded, 'dataType');
|
||||
|
||||
$query->bind($keys, $values, $dataTypes);
|
||||
|
||||
$query
|
||||
->select(
|
||||
'DATE(' .
|
||||
$query->concatenate(
|
||||
[
|
||||
$query->year($db->quoteName('publish_up')),
|
||||
$db->quote('-'),
|
||||
$query->month($db->quoteName('publish_up')),
|
||||
$db->quote('-01'),
|
||||
]
|
||||
) . ') AS ' . $db->quoteName('d')
|
||||
)
|
||||
->select('COUNT(*) AS ' . $db->quoteName('c'))
|
||||
->from('(' . $this->getListQuery() . ') AS ' . $db->quoteName('b'))
|
||||
->group($db->quoteName('d'))
|
||||
->order($db->quoteName('d') . ' DESC');
|
||||
|
||||
return $db->setQuery($query)->loadObjectList();
|
||||
}
|
||||
}
|
||||
155
components/com_content/src/Model/CategoriesModel.php
Normal file
155
components/com_content/src/Model/CategoriesModel.php
Normal file
@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Model;
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
use Joomla\CMS\Categories\CategoryNode;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* This models supports retrieving lists of article categories.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class CategoriesModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_context = 'com_content.categories';
|
||||
|
||||
/**
|
||||
* The category context (allows other extensions to derived from this model).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_extension = 'com_content';
|
||||
|
||||
/**
|
||||
* Parent category of the current one
|
||||
*
|
||||
* @var CategoryNode|null
|
||||
*/
|
||||
private $_parent = null;
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering The field to order on.
|
||||
* @param string $direction The direction to order on.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$this->setState('filter.extension', $this->_extension);
|
||||
|
||||
// Get the parent id if defined.
|
||||
$parentId = $app->getInput()->getInt('id');
|
||||
$this->setState('filter.parentId', $parentId);
|
||||
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
$this->setState('filter.published', 1);
|
||||
$this->setState('filter.access', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.extension');
|
||||
$id .= ':' . $this->getState('filter.published');
|
||||
$id .= ':' . $this->getState('filter.access');
|
||||
$id .= ':' . $this->getState('filter.parentId');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redefine the function and add some properties to make the styling easier
|
||||
*
|
||||
* @param bool $recursive True if you want to return children recursively.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getItems($recursive = false)
|
||||
{
|
||||
$store = $this->getStoreId();
|
||||
|
||||
if (!isset($this->cache[$store])) {
|
||||
$app = Factory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
$active = $menu->getActive();
|
||||
|
||||
if ($active) {
|
||||
$params = $active->getParams();
|
||||
} else {
|
||||
$params = new Registry();
|
||||
}
|
||||
|
||||
$options = [];
|
||||
$options['countItems'] = $params->get('show_cat_num_articles_cat', 1) || !$params->get('show_empty_categories_cat', 0);
|
||||
$categories = Categories::getInstance('Content', $options);
|
||||
$this->_parent = $categories->get($this->getState('filter.parentId', 'root'));
|
||||
|
||||
if (\is_object($this->_parent)) {
|
||||
$this->cache[$store] = $this->_parent->getChildren($recursive);
|
||||
} else {
|
||||
$this->cache[$store] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent.
|
||||
*
|
||||
* @return object An array of data items on success, false on failure.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
if (!\is_object($this->_parent)) {
|
||||
$this->getItems();
|
||||
}
|
||||
|
||||
return $this->_parent;
|
||||
}
|
||||
}
|
||||
473
components/com_content/src/Model/CategoryModel.php
Normal file
473
components/com_content/src/Model/CategoryModel.php
Normal file
@ -0,0 +1,473 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Model;
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
use Joomla\CMS\Categories\CategoryNode;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Component\Content\Site\Helper\QueryHelper;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* This models supports retrieving a category, the articles associated with the category,
|
||||
* sibling, child and parent categories.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class CategoryModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Category items data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_item = null;
|
||||
|
||||
/**
|
||||
* Array of articles in the category
|
||||
*
|
||||
* @var \stdClass[]
|
||||
*/
|
||||
protected $_articles = null;
|
||||
|
||||
/**
|
||||
* Category left and right of this one
|
||||
*
|
||||
* @var CategoryNode[]|null
|
||||
*/
|
||||
protected $_siblings = null;
|
||||
|
||||
/**
|
||||
* Array of child-categories
|
||||
*
|
||||
* @var CategoryNode[]|null
|
||||
*/
|
||||
protected $_children = null;
|
||||
|
||||
/**
|
||||
* Parent category of the current one
|
||||
*
|
||||
* @var CategoryNode|null
|
||||
*/
|
||||
protected $_parent = null;
|
||||
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_content.category';
|
||||
|
||||
/**
|
||||
* The category that applies.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $_category = null;
|
||||
|
||||
/**
|
||||
* The list of categories.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_categories = null;
|
||||
|
||||
/**
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'title', 'a.title',
|
||||
'alias', 'a.alias',
|
||||
'checked_out', 'a.checked_out',
|
||||
'checked_out_time', 'a.checked_out_time',
|
||||
'catid', 'a.catid', 'category_title',
|
||||
'state', 'a.state',
|
||||
'access', 'a.access', 'access_level',
|
||||
'created', 'a.created',
|
||||
'created_by', 'a.created_by',
|
||||
'modified', 'a.modified',
|
||||
'ordering', 'a.ordering',
|
||||
'featured', 'a.featured',
|
||||
'language', 'a.language',
|
||||
'hits', 'a.hits',
|
||||
'publish_up', 'a.publish_up',
|
||||
'publish_down', 'a.publish_down',
|
||||
'author', 'a.author',
|
||||
'filter_tag',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering The field to order on.
|
||||
* @param string $direction The direction to order on.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
$pk = $app->getInput()->getInt('id');
|
||||
$this->setState('category.id', $pk);
|
||||
|
||||
// Load the parameters. Merge Global and Menu Item params into new object
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$asset = 'com_content';
|
||||
|
||||
if ($pk) {
|
||||
$asset .= '.category.' . $pk;
|
||||
}
|
||||
|
||||
if ((!$user->authorise('core.edit.state', $asset)) && (!$user->authorise('core.edit', $asset))) {
|
||||
// Limit to published for people who can't edit or edit.state.
|
||||
$this->setState('filter.published', 1);
|
||||
} else {
|
||||
$this->setState('filter.published', [0, 1]);
|
||||
}
|
||||
|
||||
// Process show_noauth parameter
|
||||
if (!$params->get('show_noauth')) {
|
||||
$this->setState('filter.access', true);
|
||||
} else {
|
||||
$this->setState('filter.access', false);
|
||||
}
|
||||
|
||||
$itemid = $app->getInput()->get('id', 0, 'int') . ':' . $app->getInput()->get('Itemid', 0, 'int');
|
||||
|
||||
$value = $this->getUserStateFromRequest('com_content.category.filter.' . $itemid . '.tag', 'filter_tag', 0, 'int', false);
|
||||
$this->setState('filter.tag', $value);
|
||||
|
||||
// Optional filter text
|
||||
$search = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter-search', 'filter-search', '', 'string');
|
||||
$this->setState('list.filter', $search);
|
||||
|
||||
// Filter.order
|
||||
$orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
|
||||
|
||||
if (!\in_array($orderCol, $this->filter_fields)) {
|
||||
$orderCol = 'a.ordering';
|
||||
}
|
||||
|
||||
$this->setState('list.ordering', $orderCol);
|
||||
|
||||
$listOrder = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
|
||||
|
||||
if (!\in_array(strtoupper($listOrder), ['ASC', 'DESC', ''])) {
|
||||
$listOrder = 'ASC';
|
||||
}
|
||||
|
||||
$this->setState('list.direction', $listOrder);
|
||||
|
||||
$this->setState('list.start', $app->getInput()->get('limitstart', 0, 'uint'));
|
||||
|
||||
// Set limit for query. If list, use parameter. If blog, add blog parameters for limit.
|
||||
if (($app->getInput()->get('layout') === 'blog') || $params->get('layout_type') === 'blog') {
|
||||
$limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
|
||||
$this->setState('list.links', $params->get('num_links'));
|
||||
} else {
|
||||
$limit = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint');
|
||||
}
|
||||
|
||||
$this->setState('list.limit', $limit);
|
||||
|
||||
// Set the depth of the category query based on parameter
|
||||
$showSubcategories = $params->get('show_subcategory_content', '0');
|
||||
|
||||
if ($showSubcategories) {
|
||||
$this->setState('filter.max_category_levels', $params->get('show_subcategory_content', '1'));
|
||||
$this->setState('filter.subcategories', true);
|
||||
}
|
||||
|
||||
$this->setState('filter.language', Multilanguage::isEnabled());
|
||||
|
||||
$this->setState('layout', $app->getInput()->getString('layout'));
|
||||
|
||||
// Set the featured articles state
|
||||
$this->setState('filter.featured', $params->get('show_featured'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the articles in the category
|
||||
*
|
||||
* @return array|bool An array of articles or false if an error occurs.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$limit = $this->getState('list.limit');
|
||||
|
||||
if ($this->_articles === null && $category = $this->getCategory()) {
|
||||
$model = $this->bootComponent('com_content')->getMVCFactory()
|
||||
->createModel('Articles', 'Site', ['ignore_request' => true]);
|
||||
$model->setState('params', Factory::getApplication()->getParams());
|
||||
$model->setState('filter.category_id', $category->id);
|
||||
$model->setState('filter.published', $this->getState('filter.published'));
|
||||
$model->setState('filter.access', $this->getState('filter.access'));
|
||||
$model->setState('filter.language', $this->getState('filter.language'));
|
||||
$model->setState('filter.featured', $this->getState('filter.featured'));
|
||||
$model->setState('list.ordering', $this->_buildContentOrderBy());
|
||||
$model->setState('list.start', $this->getState('list.start'));
|
||||
$model->setState('list.limit', $limit);
|
||||
$model->setState('list.direction', $this->getState('list.direction'));
|
||||
$model->setState('list.filter', $this->getState('list.filter'));
|
||||
$model->setState('filter.tag', $this->getState('filter.tag'));
|
||||
|
||||
// Filter.subcategories indicates whether to include articles from subcategories in the list or blog
|
||||
$model->setState('filter.subcategories', $this->getState('filter.subcategories'));
|
||||
$model->setState('filter.max_category_levels', $this->getState('filter.max_category_levels'));
|
||||
$model->setState('list.links', $this->getState('list.links'));
|
||||
|
||||
if ($limit >= 0) {
|
||||
$this->_articles = $model->getItems();
|
||||
|
||||
if ($this->_articles === false) {
|
||||
$this->setError($model->getError());
|
||||
}
|
||||
} else {
|
||||
$this->_articles = [];
|
||||
}
|
||||
|
||||
$this->_pagination = $model->getPagination();
|
||||
}
|
||||
|
||||
return $this->_articles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the orderby for the query
|
||||
*
|
||||
* @return string $orderby portion of query
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
protected function _buildContentOrderBy()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$db = $this->getDatabase();
|
||||
$params = $this->state->params;
|
||||
$itemid = $app->getInput()->get('id', 0, 'int') . ':' . $app->getInput()->get('Itemid', 0, 'int');
|
||||
$orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
|
||||
$orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
|
||||
$orderby = ' ';
|
||||
|
||||
if (!\in_array($orderCol, $this->filter_fields)) {
|
||||
$orderCol = null;
|
||||
}
|
||||
|
||||
if (!\in_array(strtoupper($orderDirn), ['ASC', 'DESC', ''])) {
|
||||
$orderDirn = 'ASC';
|
||||
}
|
||||
|
||||
if ($orderCol && $orderDirn) {
|
||||
$orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', ';
|
||||
}
|
||||
|
||||
$articleOrderby = $params->get('orderby_sec', 'rdate');
|
||||
$articleOrderDate = $params->get('order_date');
|
||||
$categoryOrderby = $params->def('orderby_pri', '');
|
||||
$secondary = QueryHelper::orderbySecondary($articleOrderby, $articleOrderDate, $this->getDatabase()) . ', ';
|
||||
$primary = QueryHelper::orderbyPrimary($categoryOrderby);
|
||||
|
||||
$orderby .= $primary . ' ' . $secondary . ' a.created ';
|
||||
|
||||
return $orderby;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a JPagination object for the data set.
|
||||
*
|
||||
* @return \Joomla\CMS\Pagination\Pagination A JPagination object for the data set.
|
||||
*
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public function getPagination()
|
||||
{
|
||||
if (empty($this->_pagination)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->_pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get category data for the current category
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
if (isset($this->state->params)) {
|
||||
$params = $this->state->params;
|
||||
$options = [];
|
||||
$options['countItems'] = $params->get('show_cat_num_articles', 1) || !$params->get('show_empty_categories_cat', 0);
|
||||
$options['access'] = $params->get('check_access_rights', 1);
|
||||
} else {
|
||||
$options['countItems'] = 0;
|
||||
}
|
||||
|
||||
$categories = Categories::getInstance('Content', $options);
|
||||
$this->_item = $categories->get($this->getState('category.id', 'root'));
|
||||
|
||||
// Compute selected asset permissions.
|
||||
if (\is_object($this->_item)) {
|
||||
$user = $this->getCurrentUser();
|
||||
$asset = 'com_content.category.' . $this->_item->id;
|
||||
|
||||
// Check general create permission.
|
||||
if ($user->authorise('core.create', $asset)) {
|
||||
$this->_item->getParams()->set('access-create', true);
|
||||
}
|
||||
|
||||
// @todo: Why aren't we lazy loading the children and siblings?
|
||||
$this->_children = $this->_item->getChildren();
|
||||
$this->_parent = false;
|
||||
|
||||
if ($this->_item->getParent()) {
|
||||
$this->_parent = $this->_item->getParent();
|
||||
}
|
||||
|
||||
$this->_rightsibling = $this->_item->getSibling();
|
||||
$this->_leftsibling = $this->_item->getSibling(false);
|
||||
} else {
|
||||
$this->_children = false;
|
||||
$this->_parent = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent category.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the left sibling (adjacent) categories.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function &getLeftSibling()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
return $this->_leftsibling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the right sibling (adjacent) categories.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function &getRightSibling()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
return $this->_rightsibling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the child categories.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function &getChildren()
|
||||
{
|
||||
if (!\is_object($this->_item)) {
|
||||
$this->getCategory();
|
||||
}
|
||||
|
||||
// Order subcategories
|
||||
if ($this->_children) {
|
||||
$params = $this->getState()->get('params');
|
||||
|
||||
$orderByPri = $params->get('orderby_pri');
|
||||
|
||||
if ($orderByPri === 'alpha' || $orderByPri === 'ralpha') {
|
||||
$this->_children = ArrayHelper::sortObjects($this->_children, 'title', ($orderByPri === 'alpha') ? 1 : (-1));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the hit counter for the category.
|
||||
*
|
||||
* @param int $pk Optional primary key of the category to increment.
|
||||
*
|
||||
* @return boolean True if successful; false otherwise and internal error set.
|
||||
*/
|
||||
public function hit($pk = 0)
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
$hitcount = $input->getInt('hitcount', 1);
|
||||
|
||||
if ($hitcount) {
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
|
||||
|
||||
$table = Table::getInstance('Category', '\\Joomla\\CMS\\Table\\');
|
||||
$table->hit($pk);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
168
components/com_content/src/Model/FeaturedModel.php
Normal file
168
components/com_content/src/Model/FeaturedModel.php
Normal file
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\Component\Content\Administrator\Extension\ContentComponent;
|
||||
use Joomla\Component\Content\Site\Helper\QueryHelper;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Frontpage Component Model
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class FeaturedModel extends ArticlesModel
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_context = 'com_content.frontpage';
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering The field to order on.
|
||||
* @param string $direction The direction to order on.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
parent::populateState($ordering, $direction);
|
||||
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
$user = $app->getIdentity();
|
||||
|
||||
// List state information
|
||||
$limitstart = $input->getUint('limitstart', 0);
|
||||
$this->setState('list.start', $limitstart);
|
||||
|
||||
$params = $this->state->params;
|
||||
|
||||
if ($menu = $app->getMenu()->getActive()) {
|
||||
$menuParams = $menu->getParams();
|
||||
} else {
|
||||
$menuParams = new Registry();
|
||||
}
|
||||
|
||||
$mergedParams = clone $menuParams;
|
||||
$mergedParams->merge($params);
|
||||
|
||||
$this->setState('params', $mergedParams);
|
||||
|
||||
$limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
|
||||
$this->setState('list.limit', $limit);
|
||||
$this->setState('list.links', $params->get('num_links'));
|
||||
|
||||
$this->setState('filter.frontpage', true);
|
||||
|
||||
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) {
|
||||
// Filter on published for those who do not have edit or edit.state rights.
|
||||
$this->setState('filter.published', ContentComponent::CONDITION_PUBLISHED);
|
||||
} else {
|
||||
$this->setState('filter.published', [ContentComponent::CONDITION_UNPUBLISHED, ContentComponent::CONDITION_PUBLISHED]);
|
||||
}
|
||||
|
||||
// Process show_noauth parameter
|
||||
if (!$params->get('show_noauth')) {
|
||||
$this->setState('filter.access', true);
|
||||
} else {
|
||||
$this->setState('filter.access', false);
|
||||
}
|
||||
|
||||
// Check for category selection
|
||||
if ($params->get('featured_categories') && implode(',', $params->get('featured_categories')) == true) {
|
||||
$featuredCategories = $params->get('featured_categories');
|
||||
$this->setState('filter.frontpage.categories', $featuredCategories);
|
||||
}
|
||||
|
||||
$articleOrderby = $params->get('orderby_sec', 'rdate');
|
||||
$articleOrderDate = $params->get('order_date');
|
||||
$categoryOrderby = $params->def('orderby_pri', '');
|
||||
|
||||
$secondary = QueryHelper::orderbySecondary($articleOrderby, $articleOrderDate, $this->getDatabase());
|
||||
$primary = QueryHelper::orderbyPrimary($categoryOrderby);
|
||||
|
||||
$this->setState('list.ordering', $primary . $secondary . ', a.created DESC');
|
||||
$this->setState('list.direction', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of articles.
|
||||
*
|
||||
* @return mixed An array of objects on success, false on failure.
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$params = clone $this->getState('params');
|
||||
$limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
|
||||
|
||||
if ($limit > 0) {
|
||||
$this->setState('list.limit', $limit);
|
||||
|
||||
return parent::getItems();
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= $this->getState('filter.frontpage');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of items.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = parent::getListQuery();
|
||||
|
||||
// Filter by categories
|
||||
$featuredCategories = $this->getState('filter.frontpage.categories');
|
||||
|
||||
if (\is_array($featuredCategories) && !\in_array('', $featuredCategories)) {
|
||||
$query->where('a.catid IN (' . implode(',', ArrayHelper::toInteger($featuredCategories)) . ')');
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
336
components/com_content/src/Model/FormModel.php
Normal file
336
components/com_content/src/Model/FormModel.php
Normal file
@ -0,0 +1,336 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component Article Model
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class FormModel extends \Joomla\Component\Content\Administrator\Model\ArticleModel
|
||||
{
|
||||
/**
|
||||
* Model typeAlias string. Used for version history.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $typeAlias = 'com_content.article';
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
|
||||
// Load the parameters.
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
if ($params && $params->get('enable_category') == 1 && $params->get('catid')) {
|
||||
$catId = $params->get('catid');
|
||||
} else {
|
||||
$catId = 0;
|
||||
}
|
||||
|
||||
// Load state from the request.
|
||||
$pk = $input->getInt('a_id');
|
||||
$this->setState('article.id', $pk);
|
||||
|
||||
$this->setState('article.catid', $input->getInt('catid', $catId));
|
||||
|
||||
$return = $input->get('return', '', 'base64');
|
||||
$this->setState('return_page', base64_decode($return));
|
||||
|
||||
$this->setState('layout', $input->getString('layout'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get article data.
|
||||
*
|
||||
* @param integer $itemId The id of the article.
|
||||
*
|
||||
* @return mixed Content item data object on success, false on failure.
|
||||
*/
|
||||
public function getItem($itemId = null)
|
||||
{
|
||||
$itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('article.id');
|
||||
|
||||
// Get a row instance.
|
||||
$table = $this->getTable();
|
||||
|
||||
// Attempt to load the row.
|
||||
$return = $table->load($itemId);
|
||||
|
||||
// Check for a table object error.
|
||||
if ($return === false && $table->getError()) {
|
||||
$this->setError($table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$properties = $table->getProperties(1);
|
||||
$value = ArrayHelper::toObject($properties, CMSObject::class);
|
||||
|
||||
// Convert attrib field to Registry.
|
||||
$value->params = new Registry($value->attribs);
|
||||
|
||||
// Compute selected asset permissions.
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->get('id');
|
||||
$asset = 'com_content.article.' . $value->id;
|
||||
|
||||
// Check general edit permission first.
|
||||
if ($user->authorise('core.edit', $asset)) {
|
||||
$value->params->set('access-edit', true);
|
||||
} elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) {
|
||||
// Now check if edit.own is available.
|
||||
// Check for a valid user and that they are the owner.
|
||||
if ($userId == $value->created_by) {
|
||||
$value->params->set('access-edit', true);
|
||||
}
|
||||
}
|
||||
|
||||
// Check edit state permission.
|
||||
if ($itemId) {
|
||||
// Existing item
|
||||
$value->params->set('access-change', $user->authorise('core.edit.state', $asset));
|
||||
} else {
|
||||
// New item.
|
||||
$catId = (int) $this->getState('article.catid');
|
||||
|
||||
if ($catId) {
|
||||
$value->params->set('access-change', $user->authorise('core.edit.state', 'com_content.category.' . $catId));
|
||||
$value->catid = $catId;
|
||||
} else {
|
||||
$value->params->set('access-change', $user->authorise('core.edit.state', 'com_content'));
|
||||
}
|
||||
}
|
||||
|
||||
$value->articletext = $value->introtext;
|
||||
|
||||
if (!empty($value->fulltext)) {
|
||||
$value->articletext .= '<hr id="system-readmore">' . $value->fulltext;
|
||||
}
|
||||
|
||||
// Convert the metadata field to an array.
|
||||
$registry = new Registry($value->metadata);
|
||||
$value->metadata = $registry->toArray();
|
||||
|
||||
if ($itemId) {
|
||||
$value->tags = new TagsHelper();
|
||||
$value->tags->getTagIds($value->id, 'com_content.article');
|
||||
$value->metadata['tags'] = $value->tags;
|
||||
|
||||
$value->featured_up = null;
|
||||
$value->featured_down = null;
|
||||
|
||||
if ($value->featured) {
|
||||
// Get featured dates.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('featured_up'),
|
||||
$db->quoteName('featured_down'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__content_frontpage'))
|
||||
->where($db->quoteName('content_id') . ' = :id')
|
||||
->bind(':id', $value->id, ParameterType::INTEGER);
|
||||
|
||||
$featured = $db->setQuery($query)->loadObject();
|
||||
|
||||
if ($featured) {
|
||||
$value->featured_up = $featured->featured_up;
|
||||
$value->featured_down = $featured->featured_down;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the return URL.
|
||||
*
|
||||
* @return string The return URL.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getReturnPage()
|
||||
{
|
||||
return base64_encode($this->getState('return_page', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
* @param array $data The form data.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
// Associations are not edited in frontend ATM so we have to inherit them
|
||||
if (
|
||||
Associations::isEnabled() && !empty($data['id'])
|
||||
&& $associations = Associations::getAssociations('com_content', '#__content', 'com_content.item', $data['id'])
|
||||
) {
|
||||
foreach ($associations as $tag => $associated) {
|
||||
$associations[$tag] = (int) $associated->id;
|
||||
}
|
||||
|
||||
$data['associations'] = $associations;
|
||||
}
|
||||
|
||||
if (!Multilanguage::isEnabled()) {
|
||||
$data['language'] = '*';
|
||||
}
|
||||
|
||||
return parent::save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return Form|boolean A Form object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
$form = parent::getForm($data, $loadData);
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$app = Factory::getApplication();
|
||||
$user = $app->getIdentity();
|
||||
|
||||
// On edit article, we get ID of article from article.id state, but on save, we use data from input
|
||||
$id = (int) $this->getState('article.id', $app->getInput()->getInt('a_id'));
|
||||
|
||||
// Existing record. We can't edit the category in frontend if not edit.state.
|
||||
if ($id > 0 && !$user->authorise('core.edit.state', 'com_content.article.' . $id)) {
|
||||
$form->setFieldAttribute('catid', 'readonly', 'true');
|
||||
$form->setFieldAttribute('catid', 'required', 'false');
|
||||
$form->setFieldAttribute('catid', 'filter', 'unset');
|
||||
}
|
||||
|
||||
// Prevent messing with article language and category when editing existing article with associations
|
||||
if ($this->getState('article.id') && Associations::isEnabled()) {
|
||||
$associations = Associations::getAssociations('com_content', '#__content', 'com_content.item', $id);
|
||||
|
||||
// Make fields read only
|
||||
if (!empty($associations)) {
|
||||
$form->setFieldAttribute('language', 'readonly', 'true');
|
||||
$form->setFieldAttribute('catid', 'readonly', 'true');
|
||||
$form->setFieldAttribute('language', 'filter', 'unset');
|
||||
$form->setFieldAttribute('catid', 'filter', 'unset');
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows preprocessing of the JForm object.
|
||||
*
|
||||
* @param Form $form The form object
|
||||
* @param array $data The data to be merged into the form object
|
||||
* @param string $group The plugin group to be executed
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected function preprocessForm(Form $form, $data, $group = 'content')
|
||||
{
|
||||
$params = $this->getState()->get('params');
|
||||
|
||||
if ($params && $params->get('enable_category') == 1 && $params->get('catid')) {
|
||||
$form->setFieldAttribute('catid', 'default', $params->get('catid'));
|
||||
$form->setFieldAttribute('catid', 'readonly', 'true');
|
||||
|
||||
if (Multilanguage::isEnabled()) {
|
||||
$categoryId = (int) $params->get('catid');
|
||||
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('language'))
|
||||
->from($db->quoteName('#__categories'))
|
||||
->where($db->quoteName('id') . ' = :categoryId')
|
||||
->bind(':categoryId', $categoryId, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
$result = $db->loadResult();
|
||||
|
||||
if ($result != '*') {
|
||||
$form->setFieldAttribute('language', 'readonly', 'true');
|
||||
$form->setFieldAttribute('language', 'default', $result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Multilanguage::isEnabled()) {
|
||||
$form->setFieldAttribute('language', 'type', 'hidden');
|
||||
$form->setFieldAttribute('language', 'default', '*');
|
||||
}
|
||||
|
||||
parent::preprocessForm($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a table object, load it if necessary.
|
||||
*
|
||||
* @param string $name The table name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $options Configuration array for model. Optional.
|
||||
*
|
||||
* @return Table A Table object
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getTable($name = 'Article', $prefix = 'Administrator', $options = [])
|
||||
{
|
||||
return parent::getTable($name, $prefix, $options);
|
||||
}
|
||||
}
|
||||
40
components/com_content/src/Service/Category.php
Normal file
40
components/com_content/src/Service/Category.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Service;
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component Category Tree
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class Category extends Categories
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $options Array of options
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
{
|
||||
$options['table'] = '#__content';
|
||||
$options['extension'] = 'com_content';
|
||||
|
||||
parent::__construct($options);
|
||||
}
|
||||
}
|
||||
288
components/com_content/src/Service/Router.php
Normal file
288
components/com_content/src/Service/Router.php
Normal file
@ -0,0 +1,288 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_content
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Content\Site\Service;
|
||||
|
||||
use Joomla\CMS\Application\SiteApplication;
|
||||
use Joomla\CMS\Categories\CategoryFactoryInterface;
|
||||
use Joomla\CMS\Categories\CategoryInterface;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Component\Router\RouterView;
|
||||
use Joomla\CMS\Component\Router\RouterViewConfiguration;
|
||||
use Joomla\CMS\Component\Router\Rules\MenuRules;
|
||||
use Joomla\CMS\Component\Router\Rules\NomenuRules;
|
||||
use Joomla\CMS\Component\Router\Rules\StandardRules;
|
||||
use Joomla\CMS\Menu\AbstractMenu;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Routing class of com_content
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
class Router extends RouterView
|
||||
{
|
||||
/**
|
||||
* Flag to remove IDs
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $noIDs = false;
|
||||
|
||||
/**
|
||||
* The category factory
|
||||
*
|
||||
* @var CategoryFactoryInterface
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $categoryFactory;
|
||||
|
||||
/**
|
||||
* The category cache
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $categoryCache = [];
|
||||
|
||||
/**
|
||||
* The db
|
||||
*
|
||||
* @var DatabaseInterface
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* Content Component router constructor
|
||||
*
|
||||
* @param SiteApplication $app The application object
|
||||
* @param AbstractMenu $menu The menu object to work with
|
||||
* @param CategoryFactoryInterface $categoryFactory The category object
|
||||
* @param DatabaseInterface $db The database object
|
||||
*/
|
||||
public function __construct(SiteApplication $app, AbstractMenu $menu, CategoryFactoryInterface $categoryFactory, DatabaseInterface $db)
|
||||
{
|
||||
$this->categoryFactory = $categoryFactory;
|
||||
$this->db = $db;
|
||||
|
||||
$params = ComponentHelper::getParams('com_content');
|
||||
$this->noIDs = (bool) $params->get('sef_ids');
|
||||
$categories = new RouterViewConfiguration('categories');
|
||||
$categories->setKey('id');
|
||||
$this->registerView($categories);
|
||||
$category = new RouterViewConfiguration('category');
|
||||
$category->setKey('id')->setParent($categories, 'catid')->setNestable()->addLayout('blog');
|
||||
$this->registerView($category);
|
||||
$article = new RouterViewConfiguration('article');
|
||||
$article->setKey('id')->setParent($category, 'catid');
|
||||
$this->registerView($article);
|
||||
$this->registerView(new RouterViewConfiguration('archive'));
|
||||
$this->registerView(new RouterViewConfiguration('featured'));
|
||||
$form = new RouterViewConfiguration('form');
|
||||
$form->setKey('a_id');
|
||||
$this->registerView($form);
|
||||
|
||||
parent::__construct($app, $menu);
|
||||
|
||||
$this->attachRule(new MenuRules($this));
|
||||
$this->attachRule(new StandardRules($this));
|
||||
$this->attachRule(new NomenuRules($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a category
|
||||
*
|
||||
* @param string $id ID of the category to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*/
|
||||
public function getCategorySegment($id, $query)
|
||||
{
|
||||
$category = $this->getCategories(['access' => true])->get($id);
|
||||
|
||||
if ($category) {
|
||||
$path = array_reverse($category->getPath(), true);
|
||||
$path[0] = '1:root';
|
||||
|
||||
if ($this->noIDs) {
|
||||
foreach ($path as &$segment) {
|
||||
list($id, $segment) = explode(':', $segment, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a category
|
||||
*
|
||||
* @param string $id ID of the category to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*/
|
||||
public function getCategoriesSegment($id, $query)
|
||||
{
|
||||
return $this->getCategorySegment($id, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for an article
|
||||
*
|
||||
* @param string $id ID of the article to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*/
|
||||
public function getArticleSegment($id, $query)
|
||||
{
|
||||
if (!strpos($id, ':')) {
|
||||
$id = (int) $id;
|
||||
$dbquery = $this->db->getQuery(true);
|
||||
$dbquery->select($this->db->quoteName('alias'))
|
||||
->from($this->db->quoteName('#__content'))
|
||||
->where($this->db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
$this->db->setQuery($dbquery);
|
||||
|
||||
$id .= ':' . $this->db->loadResult();
|
||||
}
|
||||
|
||||
if ($this->noIDs) {
|
||||
list($void, $segment) = explode(':', $id, 2);
|
||||
|
||||
return [$void => $segment];
|
||||
}
|
||||
|
||||
return [(int) $id => $id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a form
|
||||
*
|
||||
* @param string $id ID of the article form to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*
|
||||
* @since 3.7.3
|
||||
*/
|
||||
public function getFormSegment($id, $query)
|
||||
{
|
||||
return $this->getArticleSegment($id, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the id for a category
|
||||
*
|
||||
* @param string $segment Segment to retrieve the ID for
|
||||
* @param array $query The request that is parsed right now
|
||||
*
|
||||
* @return mixed The id of this item or false
|
||||
*/
|
||||
public function getCategoryId($segment, $query)
|
||||
{
|
||||
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) {
|
||||
return $child->id;
|
||||
}
|
||||
} else {
|
||||
if ($child->id == (int) $segment) {
|
||||
return $child->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a category
|
||||
*
|
||||
* @param string $segment Segment to retrieve the ID for
|
||||
* @param array $query The request that is parsed right now
|
||||
*
|
||||
* @return mixed The id of this item or false
|
||||
*/
|
||||
public function getCategoriesId($segment, $query)
|
||||
{
|
||||
return $this->getCategoryId($segment, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for an article
|
||||
*
|
||||
* @param string $segment Segment of the article to retrieve the ID for
|
||||
* @param array $query The request that is parsed right now
|
||||
*
|
||||
* @return mixed The id of this item or false
|
||||
*/
|
||||
public function getArticleId($segment, $query)
|
||||
{
|
||||
if ($this->noIDs) {
|
||||
$dbquery = $this->db->getQuery(true);
|
||||
$dbquery->select($this->db->quoteName('id'))
|
||||
->from($this->db->quoteName('#__content'))
|
||||
->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();
|
||||
}
|
||||
|
||||
return (int) $segment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get categories from cache
|
||||
*
|
||||
* @param array $options The options for retrieving categories
|
||||
*
|
||||
* @return CategoryInterface The object containing categories
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private function getCategories(array $options = []): CategoryInterface
|
||||
{
|
||||
$key = serialize($options);
|
||||
|
||||
if (!isset($this->categoryCache[$key])) {
|
||||
$this->categoryCache[$key] = $this->categoryFactory->createCategory($options);
|
||||
}
|
||||
|
||||
return $this->categoryCache[$key];
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user