first commit
This commit is contained in:
104
components/com_fields/forms/filter_fields.xml
Normal file
104
components/com_fields/forms/filter_fields.xml
Normal file
@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fieldset
|
||||
name="group"
|
||||
addfieldprefix="Joomla\Component\Fields\Administrator\Field"
|
||||
>
|
||||
<field
|
||||
name="context"
|
||||
type="fieldcontexts"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
</fieldset>
|
||||
<fields name="filter">
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label=""
|
||||
hint="JSEARCH_FILTER"
|
||||
class="js-stools-search-string"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="state"
|
||||
type="status"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_PUBLISHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="group_id"
|
||||
type="fieldgroups"
|
||||
state="0,1,2"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">COM_FIELDS_VIEW_FIELDS_SELECT_GROUP</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="assigned_cat_ids"
|
||||
type="category"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">COM_FIELDS_VIEW_FIELDS_SELECT_CATEGORY</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_ACCESS</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
onchange="this.form.submit();"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_LANGUAGE</option>
|
||||
</field>
|
||||
</fields>
|
||||
|
||||
<fields name="list">
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
description="JGLOBAL_SORT_BY"
|
||||
statuses="*,0,1,2,-2"
|
||||
onchange="this.form.submit();"
|
||||
default="a.ordering 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="a.type ASC">COM_FIELDS_VIEW_FIELDS_SORT_TYPE_ASC</option>
|
||||
<option value="a.type DESC">COM_FIELDS_VIEW_FIELDS_SORT_TYPE_DESC</option>
|
||||
<option value="g.title ASC">COM_FIELDS_VIEW_FIELDS_SORT_GROUP_ASC</option>
|
||||
<option value="g.title DESC">COM_FIELDS_VIEW_FIELDS_SORT_GROUP_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.language ASC" requires="multilanguage">JGRID_HEADING_LANGUAGE_ASC</option>
|
||||
<option value="a.language 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_FIELDS_LIST_LIMIT"
|
||||
description="COM_FIELDS_LIST_LIMIT_DESC"
|
||||
default="25"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
||||
42
components/com_fields/layouts/field/render.php
Normal file
42
components/com_fields/layouts/field/render.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_fields
|
||||
*
|
||||
* @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'];
|
||||
$label = Text::_($field->label);
|
||||
$value = $field->value;
|
||||
$showLabel = $field->params->get('showlabel');
|
||||
$prefix = Text::plural($field->params->get('prefix'), $value);
|
||||
$suffix = Text::plural($field->params->get('suffix'), $value);
|
||||
$labelClass = $field->params->get('label_render_class');
|
||||
$valueClass = $field->params->get('value_render_class');
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<?php if ($showLabel == 1) : ?>
|
||||
<span class="field-label <?php echo $labelClass; ?>"><?php echo htmlentities($label, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?>: </span>
|
||||
<?php endif; ?>
|
||||
<?php if ($prefix) : ?>
|
||||
<span class="field-prefix"><?php echo htmlentities($prefix, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="field-value <?php echo $valueClass; ?>"><?php echo $value; ?></span>
|
||||
<?php if ($suffix) : ?>
|
||||
<span class="field-suffix"><?php echo htmlentities($suffix, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?></span>
|
||||
<?php endif; ?>
|
||||
73
components/com_fields/layouts/fields/render.php
Normal file
73
components/com_fields/layouts/fields/render.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_fields
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
if (empty($fields)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$output = [];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
// If the value is empty do nothing
|
||||
if (!isset($field->value) || trim($field->value) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = $field->name . ' ' . $field->params->get('render_class');
|
||||
$layout = $field->params->get('layout', 'render');
|
||||
$content = FieldsHelper::render($context, 'field.' . $layout, ['field' => $field]);
|
||||
|
||||
// If the content is empty do nothing
|
||||
if (trim($content) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$output[] = '<li class="field-entry ' . $class . '">' . $content . '</li>';
|
||||
}
|
||||
|
||||
if (empty($output)) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<ul class="fields-container">
|
||||
<?php echo implode("\n", $output); ?>
|
||||
</ul>
|
||||
49
components/com_fields/src/Controller/DisplayController.php
Normal file
49
components/com_fields/src/Controller/DisplayController.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_fields
|
||||
*
|
||||
* @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\Fields\Site\Controller;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Base controller class for Fields Component.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
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 request's input object
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
// Frontpage Editor Fields Button proxying.
|
||||
if ($input->get('view') === 'fields' && $input->get('layout') === 'modal') {
|
||||
// Load the backend language file.
|
||||
$app->getLanguage()->load('com_fields', JPATH_ADMINISTRATOR);
|
||||
|
||||
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
|
||||
}
|
||||
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
}
|
||||
}
|
||||
53
components/com_fields/src/Dispatcher/Dispatcher.php
Normal file
53
components/com_fields/src/Dispatcher/Dispatcher.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_fields
|
||||
*
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Fields\Site\Dispatcher;
|
||||
|
||||
use Joomla\CMS\Access\Exception\NotAllowed;
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcher;
|
||||
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* ComponentDispatcher class for com_fields
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class Dispatcher extends ComponentDispatcher
|
||||
{
|
||||
/**
|
||||
* Method to check component access permission
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function checkAccess()
|
||||
{
|
||||
parent::checkAccess();
|
||||
|
||||
if ($this->input->get('view') !== 'fields' || $this->input->get('layout') !== 'modal') {
|
||||
return;
|
||||
}
|
||||
|
||||
$context = $this->app->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD');
|
||||
$parts = FieldsHelper::extract($context);
|
||||
|
||||
if (
|
||||
!$this->app->getIdentity()->authorise('core.create', $parts[0])
|
||||
|| !$this->app->getIdentity()->authorise('core.edit', $parts[0])
|
||||
) {
|
||||
throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user