Файловый менеджер - Редактировать - /home/wuectly/www/03cbe/fields.php.tar
Назад
home/wuectly/www/plugins/system/fields/fields.php 0000604 00000031375 15245527356 0016271 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.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\Form\Form; use Joomla\Registry\Registry; use Joomla\CMS\Factory; use Joomla\CMS\Language\Multilanguage; JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); /** * Fields Plugin * * @since 3.7 */ class PlgSystemFields extends JPlugin { /** * Load the language file on instantiation. * * @var boolean * @since 3.7.0 */ protected $autoloadLanguage = true; /** * Normalizes the request data. * * @param string $context The context * @param object $data The object * @param Form $form The form * * @return void * * @since 3.8.7 */ public function onContentNormaliseRequestData($context, $data, Form $form) { if (!FieldsHelper::extract($context, $data)) { return true; } // Loop over all fields foreach ($form->getGroup('com_fields') as $field) { if ($field->disabled === true) { /** * Disabled fields should NEVER be added to the request as * they should NEVER be added by the browser anyway so nothing to check against * as "disabled" means no interaction at all. */ // Make sure the data object has an entry before delete it if (isset($data->com_fields[$field->fieldname])) { unset($data->com_fields[$field->fieldname]); } continue; } // Make sure the data object has an entry if (isset($data->com_fields[$field->fieldname])) { continue; } // Set a default value for the field $data->com_fields[$field->fieldname] = false; } } /** * The save event. * * @param string $context The context * @param JTable $item The table * @param boolean $isNew Is new item * @param array $data The validated data * * @return boolean * * @since 3.7.0 */ public function onContentAfterSave($context, $item, $isNew, $data = array()) { // Check if data is an array and the item has an id if (!is_array($data) || empty($item->id) || empty($data['com_fields'])) { return true; } // Create correct context for category if ($context == 'com_categories.category') { $context = $item->extension . '.categories'; // Set the catid on the category to get only the fields which belong to this category $item->catid = $item->id; } // Check the context $parts = FieldsHelper::extract($context, $item); if (!$parts) { return true; } // Compile the right context for the fields $context = $parts[0] . '.' . $parts[1]; // Loading the fields $fields = FieldsHelper::getFields($context, $item); if (!$fields) { return true; } // Loading the model $model = JModelLegacy::getInstance('Field', 'FieldsModel', array('ignore_request' => true)); // Loop over the fields foreach ($fields as $field) { // Determine the value if it is (un)available from the data if (key_exists($field->name, $data['com_fields'])) { $value = $data['com_fields'][$field->name] === false ? null : $data['com_fields'][$field->name]; } // Field not available on form, use stored value else { $value = $field->rawvalue; } // If no value set (empty) remove value from database if (is_array($value) ? !count($value) : !strlen($value)) { $value = null; } // JSON encode value for complex fields if (is_array($value) && (count($value, COUNT_NORMAL) !== count($value, COUNT_RECURSIVE) || !count(array_filter(array_keys($value), 'is_numeric')))) { $value = json_encode($value); } // Setting the value for the field and the item $model->setFieldValue($field->id, $item->id, $value); } return true; } /** * The save event. * * @param array $userData The date * @param boolean $isNew Is new * @param boolean $success Is success * @param string $msg The message * * @return boolean * * @since 3.7.0 */ public function onUserAfterSave($userData, $isNew, $success, $msg) { // It is not possible to manipulate the user during save events // Check if data is valid or we are in a recursion if (!$userData['id'] || !$success) { return true; } $user = JFactory::getUser($userData['id']); $task = JFactory::getApplication()->input->getCmd('task'); // Skip fields save when we activate a user, because we will lose the saved data if (in_array($task, array('activate', 'block', 'unblock'))) { return true; } // Trigger the events with a real user $this->onContentAfterSave('com_users.user', $user, false, $userData); return true; } /** * The delete event. * * @param string $context The context * @param stdClass $item The item * * @return boolean * * @since 3.7.0 */ public function onContentAfterDelete($context, $item) { $parts = FieldsHelper::extract($context, $item); if (!$parts || empty($item->id)) { return true; } $context = $parts[0] . '.' . $parts[1]; JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_fields/models', 'FieldsModel'); $model = JModelLegacy::getInstance('Field', 'FieldsModel', array('ignore_request' => true)); $model->cleanupValues($context, $item->id); return true; } /** * The user delete event. * * @param stdClass $user The context * @param boolean $succes Is success * @param string $msg The message * * @return boolean * * @since 3.7.0 */ public function onUserAfterDelete($user, $succes, $msg) { $item = new stdClass; $item->id = $user['id']; return $this->onContentAfterDelete('com_users.user', $item); } /** * The form event. * * @param JForm $form The form * @param stdClass $data The data * * @return boolean * * @since 3.7.0 */ public function onContentPrepareForm(JForm $form, $data) { $context = $form->getName(); // When a category is edited, the context is com_categories.categorycom_content if (strpos($context, 'com_categories.category') === 0) { $context = str_replace('com_categories.category', '', $context) . '.categories'; // Set the catid on the category to get only the fields which belong to this category if (is_array($data) && key_exists('id', $data)) { $data['catid'] = $data['id']; } if (is_object($data) && isset($data->id)) { $data->catid = $data->id; } } $parts = FieldsHelper::extract($context, $form); if (!$parts) { return true; } $input = JFactory::getApplication()->input; // If we are on the save command we need the actual data $jformData = $input->get('jform', array(), 'array'); if ($jformData && !$data) { $data = $jformData; } if (is_array($data)) { $data = (object) $data; } FieldsHelper::prepareForm($parts[0] . '.' . $parts[1], $form, $data); return true; } /** * The display event. * * @param string $context The context * @param stdClass $item The item * @param Registry $params The params * @param integer $limitstart The start * * @return string * * @since 3.7.0 */ public function onContentAfterTitle($context, $item, $params, $limitstart = 0) { return $this->display($context, $item, $params, 1); } /** * The display event. * * @param string $context The context * @param stdClass $item The item * @param Registry $params The params * @param integer $limitstart The start * * @return string * * @since 3.7.0 */ public function onContentBeforeDisplay($context, $item, $params, $limitstart = 0) { return $this->display($context, $item, $params, 2); } /** * The display event. * * @param string $context The context * @param stdClass $item The item * @param Registry $params The params * @param integer $limitstart The start * * @return string * * @since 3.7.0 */ public function onContentAfterDisplay($context, $item, $params, $limitstart = 0) { return $this->display($context, $item, $params, 3); } /** * Performs the display event. * * @param string $context The context * @param stdClass $item The item * @param Registry $params The params * @param integer $displayType The type * * @return string * * @since 3.7.0 */ private function display($context, $item, $params, $displayType) { $parts = FieldsHelper::extract($context, $item); if (!$parts) { return ''; } // If we have a category, set the catid field to fetch only the fields which belong to it if ($parts[1] == 'categories' && !isset($item->catid)) { $item->catid = $item->id; } $context = $parts[0] . '.' . $parts[1]; // Convert tags if ($context == 'com_tags.tag' && !empty($item->type_alias)) { // Set the context $context = $item->type_alias; $item = $this->prepareTagItem($item); } if (is_string($params) || !$params) { $params = new Registry($params); } $fields = FieldsHelper::getFields($context, $item, $displayType); if ($fields) { $app = Factory::getApplication(); if ($app->isClient('site') && Multilanguage::isEnabled() && isset($item->language) && $item->language == '*') { $lang = $app->getLanguage()->getTag(); foreach ($fields as $key => $field) { if ($field->language == '*' || $field->language == $lang) { continue; } unset($fields[$key]); } } } if ($fields) { foreach ($fields as $key => $field) { $fieldDisplayType = $field->params->get('display', '2'); if ($fieldDisplayType == $displayType) { continue; } unset($fields[$key]); } } if ($fields) { return FieldsHelper::render( $context, 'fields.render', array( 'item' => $item, 'context' => $context, 'fields' => $fields ) ); } return ''; } /** * Performs the display event. * * @param string $context The context * @param stdClass $item The item * * @return void * * @since 3.7.0 */ public function onContentPrepare($context, $item) { // Check property exists (avoid costly & useless recreation), if need to recreate them, just unset the property! if (isset($item->jcfields)) { return; } $parts = FieldsHelper::extract($context, $item); if (!$parts) { return; } $context = $parts[0] . '.' . $parts[1]; // Convert tags if ($context == 'com_tags.tag' && !empty($item->type_alias)) { // Set the context $context = $item->type_alias; $item = $this->prepareTagItem($item); } // Get item's fields, also preparing their value property for manual display // (calling plugins events and loading layouts to get their HTML display) $fields = FieldsHelper::getFields($context, $item, true); // Adding the fields to the object $item->jcfields = array(); foreach ($fields as $key => $field) { $item->jcfields[$field->id] = $field; } } /** * The finder event. * * @param stdClass $item The item * * @return boolean * * @since 3.7.0 */ public function onPrepareFinderContent($item) { $section = strtolower($item->layout); $tax = $item->getTaxonomy('Type'); if ($tax) { foreach ($tax as $context => $value) { // This is only a guess, needs to be improved $component = strtolower($context); if (strpos($context, 'com_') !== 0) { $component = 'com_' . $component; } // Transform com_article to com_content if ($component === 'com_article') { $component = 'com_content'; } // Create a dummy object with the required fields $tmp = new stdClass; $tmp->id = $item->__get('id'); if ($item->__get('catid')) { $tmp->catid = $item->__get('catid'); } // Getting the fields for the constructed context $fields = FieldsHelper::getFields($component . '.' . $section, $tmp, true); if (is_array($fields)) { foreach ($fields as $field) { // Adding the instructions how to handle the text $item->addInstruction(FinderIndexer::TEXT_CONTEXT, $field->name); // Adding the field value as a field $item->{$field->name} = $field->value; } } } } return true; } /** * Prepares a tag item to be ready for com_fields. * * @param stdClass $item The item * * @return object * * @since 3.8.4 */ private function prepareTagItem($item) { // Map core fields $item->id = $item->content_item_id; $item->language = $item->core_language; // Also handle the catid if (!empty($item->core_catid)) { $item->catid = $item->core_catid; } return $item; } } home/wuectly/www/plugins/editors-xtd/fields/fields.php 0000604 00000003317 15245557237 0017207 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Editors-xtd.fields * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Editor Fields button * * @since 3.7.0 */ class PlgButtonFields extends JPlugin { /** * Load the language file on instantiation. * * @var boolean * @since 3.7.0 */ protected $autoloadLanguage = true; /** * Display the button * * @param string $name The name of the button to add * * @return JObject The button options as JObject * * @since 3.7.0 */ public function onDisplay($name) { // Check if com_fields is enabled if (!JComponentHelper::isEnabled('com_fields')) { return; } // Register FieldsHelper JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); // Guess the field context based on view. $jinput = JFactory::getApplication()->input; $context = $jinput->get('option') . '.' . $jinput->get('view'); // Validate context. $context = implode('.', FieldsHelper::extract($context)); if (!FieldsHelper::getFields($context)) { return; } $link = 'index.php?option=com_fields&view=fields&layout=modal&tmpl=component&context=' . $context . '&editor=' . $name . '&' . JSession::getFormToken() . '=1'; $button = new JObject; $button->modal = true; $button->class = 'btn'; $button->link = $link; $button->text = JText::_('PLG_EDITORS-XTD_FIELDS_BUTTON_FIELD'); $button->name = 'puzzle'; $button->options = "{handler: 'iframe', size: {x: 800, y: 500}}"; return $button; } } home/wuectly/www/administrator/components/com_fields/fields.php 0000604 00000001647 15245567005 0021161 0 ustar 00 <?php /** * @package Joomla.Administrator * @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; JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); $app = JFactory::getApplication(); $context = $app->getUserStateFromRequest( 'com_fields.groups.context', 'context', $app->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD'), 'CMD' ); $parts = FieldsHelper::extract($context); if (!$parts || !JFactory::getUser()->authorise('core.manage', $parts[0])) { throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Fields'); $controller->execute($app->input->get('task')); $controller->redirect(); home/wuectly/www/components/com_fields/fields.php 0000604 00000001771 15245572016 0016275 0 ustar 00 <?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; JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); $input = JFactory::getApplication()->input; $context = JFactory::getApplication()->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD'); $parts = FieldsHelper::extract($context); if ($input->get('view') === 'fields' && $input->get('layout') === 'modal') { if (!JFactory::getUser()->authorise('core.create', $parts[0]) || !JFactory::getUser()->authorise('core.edit', $parts[0])) { JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error'); return; } } $controller = JControllerLegacy::getInstance('Fields'); $controller->execute($input->get('task')); $controller->redirect(); home/wuectly/www/plugins/content/fields/fields.php 0000604 00000010140 15245572051 0016372 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Content.Fields * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die(); /** * Plug-in to show a custom field in eg an article * This uses the {fields ID} syntax * * @since 3.7.0 */ class PlgContentFields extends JPlugin { /** * Plugin that shows a custom field * * @param string $context The context of the content being passed to the plugin. * @param object &$item The item object. Note $article->text is also available * @param object &$params The article params * @param int $page The 'page' number * * @return void * * @since 3.7.0 */ public function onContentPrepare($context, &$item, &$params, $page = 0) { // If the item has a context, overwrite the existing one if ($context == 'com_finder.indexer' && !empty($item->context)) { $context = $item->context; } elseif ($context == 'com_finder.indexer') { // Don't run this plugin when the content is being indexed and we have no real context return; } // Don't run if there is no text property (in case of bad calls) or it is empty if (empty($item->text)) { return; } // Simple performance check to determine whether bot should process further if (strpos($item->text, 'field') === false) { return; } // Register FieldsHelper JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); // Prepare the text if (isset($item->text)) { $item->text = $this->prepare($item->text, $context, $item); } // Prepare the intro text if (isset($item->introtext)) { $item->introtext = $this->prepare($item->introtext, $context, $item); } } /** * Prepares the given string by parsing {field} and {fieldgroup} groups and replacing them. * * @param string $string The text to prepare * @param string $context The context of the content * @param object $item The item object * * @return string * * @since 3.8.1 */ private function prepare($string, $context, $item) { // Search for {field ID} or {fieldgroup ID} tags and put the results into $matches. $regex = '/{(field|fieldgroup)\s+(.*?)}/i'; preg_match_all($regex, $string, $matches, PREG_SET_ORDER); if (!$matches) { return $string; } $parts = FieldsHelper::extract($context); if (count($parts) < 2) { return $string; } $context = $parts[0] . '.' . $parts[1]; $fields = FieldsHelper::getFields($context, $item, true); $fieldsById = array(); $groups = array(); // Rearranging fields in arrays for easier lookup later. foreach ($fields as $field) { $fieldsById[$field->id] = $field; $groups[$field->group_id][] = $field; } foreach ($matches as $i => $match) { // $match[0] is the full pattern match, $match[1] is the type (field or fieldgroup) and $match[2] the ID and optional the layout $explode = explode(',', $match[2]); $id = (int) $explode[0]; $output = ''; if ($match[1] == 'field' && $id) { if (isset($fieldsById[$id])) { $layout = !empty($explode[1]) ? trim($explode[1]) : $fieldsById[$id]->params->get('layout', 'render'); $output = FieldsHelper::render( $context, 'field.' . $layout, array( 'item' => $item, 'context' => $context, 'field' => $fieldsById[$id] ) ); } } else { if ($match[2] === '*') { $match[0] = str_replace('*', '\*', $match[0]); $renderFields = $fields; } else { $renderFields = isset($groups[$id]) ? $groups[$id] : ''; } if ($renderFields) { $layout = !empty($explode[1]) ? trim($explode[1]) : 'render'; $output = FieldsHelper::render( $context, 'fields.' . $layout, array( 'item' => $item, 'context' => $context, 'fields' => $renderFields ) ); } } $string = preg_replace("|$match[0]|", addcslashes($output, '\\$'), $string, 1); } return $string; } } home/wuectly/www/administrator/components/com_fields/models/fields.php 0000604 00000025411 15245657617 0022450 0 ustar 00 <?php /** * @package Joomla.Administrator * @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\Registry\Registry; use Joomla\Utilities\ArrayHelper; /** * Fields Model * * @since 3.7.0 */ class FieldsModelFields extends JModelList { /** * Constructor. * * @param array $config An optional associative array of configuration settings. * * @see JModelLegacy * @since 3.7.0 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'title', 'a.title', 'type', 'a.type', 'name', 'a.name', 'state', 'a.state', 'access', 'a.access', 'access_level', 'language', 'a.language', 'ordering', 'a.ordering', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'created_time', 'a.created_time', 'created_user_id', 'a.created_user_id', 'group_title', 'g.title', 'category_id', 'a.category_id', 'group_id', 'a.group_id', 'assigned_cat_ids' ); } 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.7.0 */ protected function populateState($ordering = null, $direction = null) { // List state information. parent::populateState('a.ordering', 'asc'); $context = $this->getUserStateFromRequest($this->context . '.context', 'context', 'com_content.article', 'CMD'); $this->setState('filter.context', $context); // Split context into component and optional section $parts = FieldsHelper::extract($context); if ($parts) { $this->setState('filter.component', $parts[0]); $this->setState('filter.section', $parts[1]); } } /** * Method to get a store id based on the 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 An identifier string to generate the store id. * * @return string A store id. * * @since 3.7.0 */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('filter.search'); $id .= ':' . $this->getState('filter.context'); $id .= ':' . serialize($this->getState('filter.assigned_cat_ids')); $id .= ':' . $this->getState('filter.state'); $id .= ':' . $this->getState('filter.group_id'); $id .= ':' . serialize($this->getState('filter.language')); return parent::getStoreId($id); } /** * Method to get a JDatabaseQuery object for retrieving the data set from a database. * * @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set. * * @since 3.7.0 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); $app = JFactory::getApplication(); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'DISTINCT a.id, a.title, a.name, a.checked_out, a.checked_out_time, a.note' . ', a.state, a.access, a.created_time, a.created_user_id, a.ordering, a.language' . ', a.fieldparams, a.params, a.type, a.default_value, a.context, a.group_id' . ', a.label, a.description, a.required' ) ); $query->from('#__fields AS a'); // Join over the language $query->select('l.title AS language_title, l.image AS language_image') ->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language'); // Join over the users for the checked out user. $query->select('uc.name AS editor')->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); // Join over the asset groups. $query->select('ag.title AS access_level')->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Join over the users for the author. $query->select('ua.name AS author_name')->join('LEFT', '#__users AS ua ON ua.id = a.created_user_id'); // Join over the field groups. $query->select('g.title AS group_title, g.access as group_access, g.state AS group_state, g.note as group_note'); $query->join('LEFT', '#__fields_groups AS g ON g.id = a.group_id'); // Filter by context if ($context = $this->getState('filter.context')) { $query->where('a.context = ' . $db->quote($context)); } // Filter by access level. if ($access = $this->getState('filter.access')) { if (is_array($access)) { $access = ArrayHelper::toInteger($access); $query->where('a.access in (' . implode(',', $access) . ')'); } else { $query->where('a.access = ' . (int) $access); } } if (($categories = $this->getState('filter.assigned_cat_ids')) && $context) { $categories = (array) $categories; $categories = ArrayHelper::toInteger($categories); $parts = FieldsHelper::extract($context); if ($parts) { // Get the category $cat = JCategories::getInstance(str_replace('com_', '', $parts[0]) . '.' . $parts[1]); // If there is no category for the component and section, so check the component only if (!$cat) { $cat = JCategories::getInstance(str_replace('com_', '', $parts[0])); } if ($cat) { foreach ($categories as $assignedCatIds) { // Check if we have the actual category $parent = $cat->get($assignedCatIds); if ($parent) { $categories[] = (int) $parent->id; // Traverse the tree up to get all the fields which are attached to a parent while ($parent->getParent() && $parent->getParent()->id != 'root') { $parent = $parent->getParent(); $categories[] = (int) $parent->id; } } } } } $categories = array_unique($categories); // Join over the assigned categories $query->join('LEFT', $db->quoteName('#__fields_categories') . ' AS fc ON fc.field_id = a.id'); if (in_array('0', $categories)) { $query->where('(fc.category_id IS NULL OR fc.category_id IN (' . implode(',', $categories) . '))'); } else { $query->where('fc.category_id IN (' . implode(',', $categories) . ')'); } } // Implement View Level Access if (!$app->isClient('administrator') || !$user->authorise('core.admin')) { $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('a.access IN (' . $groups . ') AND (a.group_id = 0 OR g.access IN (' . $groups . '))'); } // Filter by state $state = $this->getState('filter.state'); // Include group state only when not on on back end list $includeGroupState = !$app->isClient('administrator') || $app->input->get('option') != 'com_fields' || $app->input->get('view') != 'fields'; if (is_numeric($state)) { $query->where('a.state = ' . (int) $state); if ($includeGroupState) { $query->where('(a.group_id = 0 OR g.state = ' . (int) $state . ')'); } } elseif (!$state) { $query->where('a.state IN (0, 1)'); if ($includeGroupState) { $query->where('(a.group_id = 0 OR g.state IN (0, 1))'); } } $groupId = $this->getState('filter.group_id'); if (is_numeric($groupId)) { $query->where('a.group_id = ' . (int) $groupId); } // Filter by search in title $search = $this->getState('filter.search'); if (! empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } elseif (stripos($search, 'author:') === 0) { $search = $db->quote('%' . $db->escape(substr($search, 7), true) . '%'); $query->where('(ua.name LIKE ' . $search . ' OR ua.username LIKE ' . $search . ')'); } else { $search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%')); $query->where('(a.title LIKE ' . $search . ' OR a.name LIKE ' . $search . ' OR a.note LIKE ' . $search . ')'); } } // Filter on the language. if ($language = $this->getState('filter.language')) { $language = (array) $language; foreach ($language as $key => $l) { $language[$key] = $db->quote($l); } $query->where('a.language in (' . implode(',', $language) . ')'); } // Add the list ordering clause $listOrdering = $this->state->get('list.ordering', 'a.ordering'); $orderDirn = $this->state->get('list.direction', 'ASC'); $query->order($db->escape($listOrdering) . ' ' . $db->escape($orderDirn)); return $query; } /** * Gets an array of objects from the results of database query. * * @param string $query The query. * @param integer $limitstart Offset. * @param integer $limit The number of records. * * @return array An array of results. * * @since 3.7.0 * @throws RuntimeException */ protected function _getList($query, $limitstart = 0, $limit = 0) { $result = parent::_getList($query, $limitstart, $limit); if (is_array($result)) { foreach ($result as $field) { $field->fieldparams = new Registry($field->fieldparams); $field->params = new Registry($field->params); } } return $result; } /** * Get the filter form * * @param array $data data * @param boolean $loadData load current data * * @return JForm|false the JForm object or false * * @since 3.7.0 */ public function getFilterForm($data = array(), $loadData = true) { $form = parent::getFilterForm($data, $loadData); if ($form) { $form->setValue('context', null, $this->getState('filter.context')); $form->setFieldAttribute('group_id', 'context', $this->getState('filter.context'), 'filter'); $form->setFieldAttribute('assigned_cat_ids', 'extension', $this->state->get('filter.component'), 'filter'); } return $form; } /** * Get the groups for the batch method * * @return array An array of groups * * @since 3.7.0 */ public function getGroups() { $user = JFactory::getUser(); $viewlevels = ArrayHelper::toInteger($user->getAuthorisedViewLevels()); $db = $this->getDbo(); $query = $db->getQuery(true); $query->select('title AS text, id AS value, state'); $query->from('#__fields_groups'); $query->where('state IN (0,1)'); $query->where('context = ' . $db->quote($this->state->get('filter.context'))); $query->where('access IN (' . implode(',', $viewlevels) . ')'); $db->setQuery($query); return $db->loadObjectList(); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка