| Current Path : /home/w/u/e/wuectly/www/03cbe/ |
| Current File : /home/w/u/e/wuectly/www/03cbe/content.php.tar |
home/wuectly/www/plugins/search/content/content.php 0000604 00000032177 15245557262 0016622 0 ustar 00 <?php
/**
* @package Joomla.Plugin
* @subpackage Search.content
*
* @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;
/**
* Content search plugin.
*
* @since 1.6
*/
class PlgSearchContent extends JPlugin
{
/**
* Determine areas searchable by this plugin.
*
* @return array An array of search areas.
*
* @since 1.6
*/
public function onContentSearchAreas()
{
static $areas = array(
'content' => 'JGLOBAL_ARTICLES'
);
return $areas;
}
/**
* Search content (articles).
* The SQL must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav.
*
* @param string $text Target search string.
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
* @param mixed $areas An array if the search it to be restricted to areas or null to search all areas.
*
* @return array Search results.
*
* @since 1.6
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$db = JFactory::getDbo();
$serverType = $db->getServerType();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$tag = JFactory::getLanguage()->getTag();
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
JLoader::register('SearchHelper', JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php');
$searchText = $text;
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas())))
{
return array();
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$nullDate = $db->getNullDate();
$date = JFactory::getDate();
$now = $date->toSql();
$text = trim($text);
if ($text === '')
{
return array();
}
switch ($phrase)
{
case 'exact':
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE ' . $text;
$wheres2[] = 'a.introtext LIKE ' . $text;
$wheres2[] = 'a.fulltext LIKE ' . $text;
$wheres2[] = 'a.metakey LIKE ' . $text;
$wheres2[] = 'a.metadesc LIKE ' . $text;
$relevance[] = ' CASE WHEN ' . $wheres2[0] . ' THEN 5 ELSE 0 END ';
// Join over Fields.
$subQuery = $db->getQuery(true);
$subQuery->select("cfv.item_id")
->from("#__fields_values AS cfv")
->join('LEFT', '#__fields AS f ON f.id = cfv.field_id')
->where('(f.context IS NULL OR f.context = ' . $db->q('com_content.article') . ')')
->where('(f.state IS NULL OR f.state = 1)')
->where('(f.access IS NULL OR f.access IN (' . $groups . '))')
->where('cfv.value LIKE ' . $text);
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$subQuery->where('(f.language IS NULL OR f.language in (' . $db->quote($tag) . ',' . $db->quote('*') . '))');
}
if ($serverType == "mysql")
{
/* This generates a dependent sub-query so do no use in MySQL prior to version 6.0 !
* $wheres2[] = 'a.id IN( '. (string) $subQuery.')';
*/
$db->setQuery($subQuery);
$fieldids = $db->loadColumn();
if (count($fieldids))
{
$wheres2[] = 'a.id IN(' . implode(",", $fieldids) . ')';
}
}
else
{
$wheres2[] = $subQuery->castAsChar('a.id') . ' IN( ' . (string) $subQuery . ')';
}
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
$cfwhere = array();
foreach ($words as $word)
{
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'LOWER(a.title) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.introtext) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.fulltext) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.metakey) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.metadesc) LIKE LOWER(' . $word . ')';
$relevance[] = ' CASE WHEN ' . $wheres2[0] . ' THEN 5 ELSE 0 END ';
if ($phrase === 'all')
{
// Join over Fields.
$subQuery = $db->getQuery(true);
$subQuery->select("cfv.item_id")
->from("#__fields_values AS cfv")
->join('LEFT', '#__fields AS f ON f.id = cfv.field_id')
->where('(f.context IS NULL OR f.context = ' . $db->q('com_content.article') . ')')
->where('(f.state IS NULL OR f.state = 1)')
->where('(f.access IS NULL OR f.access IN (' . $groups . '))')
->where('LOWER(cfv.value) LIKE LOWER(' . $word . ')');
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$subQuery->where('(f.language IS NULL OR f.language in (' . $db->quote($tag) . ',' . $db->quote('*') . '))');
}
if ($serverType == "mysql")
{
$db->setQuery($subQuery);
$fieldids = $db->loadColumn();
if (count($fieldids))
{
$wheres2[] = 'a.id IN(' . implode(",", $fieldids) . ')';
}
}
else
{
$wheres2[] = $subQuery->castAsChar('a.id') . ' IN( ' . (string) $subQuery . ')';
}
}
else
{
$cfwhere[] = 'LOWER(cfv.value) LIKE LOWER(' . $word . ')';
}
$wheres[] = implode(' OR ', $wheres2);
}
if ($phrase === 'any')
{
// Join over Fields.
$subQuery = $db->getQuery(true);
$subQuery->select("cfv.item_id")
->from("#__fields_values AS cfv")
->join('LEFT', '#__fields AS f ON f.id = cfv.field_id')
->where('(f.context IS NULL OR f.context = ' . $db->q('com_content.article') . ')')
->where('(f.state IS NULL OR f.state = 1)')
->where('(f.access IS NULL OR f.access IN (' . $groups . '))')
->where('(' . implode(($phrase === 'all' ? ') AND (' : ') OR ('), $cfwhere) . ')');
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$subQuery->where('(f.language IS NULL OR f.language in (' . $db->quote($tag) . ',' . $db->quote('*') . '))');
}
if ($serverType == "mysql")
{
$db->setQuery($subQuery);
$fieldids = $db->loadColumn();
if (count($fieldids))
{
$wheres[] = 'a.id IN(' . implode(",", $fieldids) . ')';
}
}
else
{
$wheres[] = $subQuery->castAsChar('a.id') . ' IN( ' . (string) $subQuery . ')';
}
}
$where = '(' . implode(($phrase === 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering)
{
case 'oldest':
$order = 'a.created ASC';
break;
case 'popular':
$order = 'a.hits DESC';
break;
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
$order = 'c.title ASC, a.title ASC';
break;
case 'newest':
default:
$order = 'a.created DESC';
break;
}
$rows = array();
$query = $db->getQuery(true);
// Search articles.
if ($sContent && $limit > 0)
{
$query->clear();
// SQLSRV changes.
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
if (!empty($relevance))
{
$query->select(implode(' + ', $relevance) . ' AS relevance');
$order = ' relevance DESC, ' . $order;
}
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, a.language, a.catid')
->select($query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text')
->select('c.title AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav')
->from('#__content AS a')
->join('INNER', '#__categories AS c ON c.id=a.catid')
->where(
'(' . $where . ') AND a.state=1 AND c.published = 1 AND a.access IN (' . $groups . ') '
. 'AND c.access IN (' . $groups . ')'
. 'AND (a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ') '
. 'AND (a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')'
)
->group('a.id, a.title, a.metadesc, a.metakey, a.created, a.language, a.catid, a.introtext, a.fulltext, c.title, a.alias, c.alias, c.id')
->order($order);
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')
->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try
{
$list = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$list = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
$limit -= count($list);
if (isset($list))
{
foreach ($list as $key => $item)
{
$list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language);
}
}
$rows[] = $list;
}
// Search archived content.
if ($sArchived && $limit > 0)
{
$query->clear();
// SQLSRV changes.
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
if (!empty($relevance))
{
$query->select(implode(' + ', $relevance) . ' AS relevance');
$order = ' relevance DESC, ' . $order;
}
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, a.language, a.catid')
->select($query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text')
->select('c.title AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav')
->from('#__content AS a')
->join('INNER', '#__categories AS c ON c.id=a.catid AND c.access IN (' . $groups . ')')
->where(
'(' . $where . ') AND a.state = 2 AND c.published = 1 AND a.access IN (' . $groups
. ') AND c.access IN (' . $groups . ') '
. 'AND (a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ') '
. 'AND (a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')'
)
->order($order);
// Join over Fields is no longer needed
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')
->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try
{
$list3 = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$list3 = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
if (isset($list3))
{
foreach ($list3 as $key => $item)
{
$list3[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language);
}
}
$rows[] = $list3;
}
$results = array();
if (count($rows))
{
foreach ($rows as $row)
{
$new_row = array();
foreach ($row as $article)
{
// Not efficient to get these ONE article at a TIME
// Lookup field values so they can be checked, GROUP_CONCAT would work in above queries, but isn't supported by non-MySQL DBs.
$query = $db->getQuery(true);
$query->select('fv.value')
->from('#__fields_values as fv')
->join('left', '#__fields as f on fv.field_id = f.id')
->where('f.context = ' . $db->quote('com_content.article'))
->where('fv.item_id = ' . $db->quote((int) $article->slug));
$db->setQuery($query);
$article->jcfields = implode(',', $db->loadColumn());
if (SearchHelper::checkNoHtml($article, $searchText, array('text', 'title', 'jcfields', 'metadesc', 'metakey')))
{
$new_row[] = $article;
}
}
$results = array_merge($results, (array) $new_row);
}
}
return $results;
}
}
home/wuectly/www/libraries/cms/html/content.php 0000604 00000003660 15245561505 0015712 0 ustar 00 <?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class to fire onContentPrepare for non-article based content.
*
* @since 1.5
*/
abstract class JHtmlContent
{
/**
* Fire onContentPrepare for content that isn't part of an article.
*
* @param string $text The content to be transformed.
* @param array $params The content params.
* @param string $context The context of the content to be transformed.
*
* @return string The content after transformation.
*
* @since 1.5
*/
public static function prepare($text, $params = null, $context = 'text')
{
if ($params === null)
{
$params = new JObject;
}
$article = new stdClass;
$article->text = $text;
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onContentPrepare', array($context, &$article, &$params, 0));
return $article->text;
}
/**
* Returns an array of months.
*
* @param Registry $state The state object.
*
* @return array
*
* @since 3.9.0
*/
public static function months($state)
{
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
foreach ($state as $key => $value)
{
$model->setState($key, $value);
}
$model->setState('filter.category_id', $state->get('category.id'));
$model->setState('list.start', 0);
$model->setState('list.limit', -1);
$model->setState('list.direction', 'asc');
$model->setState('list.filter', '');
$items = array();
foreach ($model->countItemsByMonth() as $item)
{
$date = new JDate($item->d);
$items[] = JHtml::_('select.option', $item->d, $date->format('F Y') . ' [' . $item->c . ']');
}
return $items;
}
}
home/wuectly/www/administrator/components/com_content/content.php 0000604 00000001235 15245567016 0021564 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @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;
JHtml::_('behavior.tabstate');
if (!JFactory::getUser()->authorise('core.manage', 'com_content'))
{
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
JLoader::register('ContentHelper', __DIR__ . '/helpers/content.php');
$controller = JControllerLegacy::getInstance('Content');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
home/wuectly/www/plugins/privacy/content/content.php 0000604 00000003210 15245570506 0017010 0 ustar 00 <?php
/**
* @package Joomla.Plugin
* @subpackage Privacy.content
*
* @copyright (C) 2018 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('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php');
/**
* Privacy plugin managing Joomla user content data
*
* @since 3.9.0
*/
class PlgPrivacyContent extends PrivacyPlugin
{
/**
* Processes an export request for Joomla core user content data
*
* This event will collect data for the content core table
*
* - Content custom fields
*
* @param PrivacyTableRequest $request The request record being processed
* @param JUser $user The user account associated with this request if available
*
* @return PrivacyExportDomain[]
*
* @since 3.9.0
*/
public function onPrivacyExportRequest(PrivacyTableRequest $request, JUser $user = null)
{
if (!$user)
{
return array();
}
$domains = array();
$domain = $this->createDomain('user_content', 'joomla_user_content_data');
$domains[] = $domain;
$query = $this->db->getQuery(true)
->select('*')
->from($this->db->quoteName('#__content'))
->where($this->db->quoteName('created_by') . ' = ' . (int) $user->id)
->order($this->db->quoteName('ordering') . ' ASC');
$items = $this->db->setQuery($query)->loadObjectList();
foreach ($items as $item)
{
$domain->addItem($this->createItemFromArray((array) $item));
}
$domains[] = $this->createCustomFieldsDomain('com_content.article', $items);
return $domains;
}
}
home/wuectly/www/components/com_content/content.php 0000604 00000003140 15245572077 0016704 0 ustar 00 <?php
/**
* @package Joomla.Site
* @subpackage com_content
*
* @copyright (C) 2005 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('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
JLoader::register('ContentHelperQuery', JPATH_SITE . '/components/com_content/helpers/query.php');
JLoader::register('ContentHelperAssociation', JPATH_SITE . '/components/com_content/helpers/association.php');
$input = JFactory::getApplication()->input;
$user = JFactory::getUser();
$checkCreateEdit = ($input->get('view') === 'articles' && $input->get('layout') === 'modal')
|| ($input->get('view') === 'article' && $input->get('layout') === 'pagebreak');
if ($checkCreateEdit)
{
// Can create in any category (component permission) or at least in one category
$canCreateRecords = $user->authorise('core.create', 'com_content')
|| count($user->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) JFactory::getApplication()->getUserState('com_content.edit.article.id');
$isEditingRecords = count($values);
$hasAccess = $canCreateRecords || $isEditingRecords;
if (!$hasAccess)
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');
return;
}
}
$controller = JControllerLegacy::getInstance('Content');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
home/wuectly/www/plugins/finder/content/content.php 0000604 00000025400 15245657457 0016622 0 ustar 00 <?php
/**
* @package Joomla.Plugin
* @subpackage Finder.Content
*
* @copyright (C) 2011 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;
JLoader::register('FinderIndexerAdapter', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php');
/**
* Smart Search adapter for com_content.
*
* @since 2.5
*/
class PlgFinderContent extends FinderIndexerAdapter
{
/**
* The plugin identifier.
*
* @var string
* @since 2.5
*/
protected $context = 'Content';
/**
* The extension name.
*
* @var string
* @since 2.5
*/
protected $extension = 'com_content';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 2.5
*/
protected $layout = 'article';
/**
* The type of content that the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $type_title = 'Article';
/**
* The table name.
*
* @var string
* @since 2.5
*/
protected $table = '#__content';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Method to update the item link information when the item category is
* changed. This is fired when the item category is published or unpublished
* from the list view.
*
* @param string $extension The extension whose category has been updated.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderCategoryChangeState($extension, $pks, $value)
{
// Make sure we're handling com_content categories.
if ($extension === 'com_content')
{
$this->categoryStateChange($pks, $value);
}
}
/**
* Method to remove the link information for items that have been deleted.
*
* @param string $context The context of the action being performed.
* @param JTable $table A JTable object containing the record to be deleted
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterDelete($context, $table)
{
if ($context === 'com_content.article')
{
$id = $table->id;
}
elseif ($context === 'com_finder.index')
{
$id = $table->link_id;
}
else
{
return true;
}
// Remove item from the index.
return $this->remove($id);
}
/**
* Smart Search after save content method.
* Reindexes the link information for an article that has been saved.
* It also makes adjustments if the access level of an item or the
* category to which it belongs has changed.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object.
* @param boolean $isNew True if the content has just been created.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle articles here.
if ($context === 'com_content.article' || $context === 'com_content.form')
{
// Check if the access levels are different.
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
}
// Reindex the item.
$this->reindex($row->id);
}
// Check for access changes in the category.
if ($context === 'com_categories.category')
{
// Check if the access levels are different.
if (!$isNew && $this->old_cataccess != $row->access)
{
$this->categoryAccessChange($row);
}
}
return true;
}
/**
* Smart Search before content save method.
* This event is fired before the data is actually saved.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object.
* @param boolean $isNew If the content is just about to be created.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderBeforeSave($context, $row, $isNew)
{
// We only want to handle articles here.
if ($context === 'com_content.article' || $context === 'com_content.form')
{
// Query the database for the old access level if the item isn't new.
if (!$isNew)
{
$this->checkItemAccess($row);
}
}
// Check for access levels from the category.
if ($context === 'com_categories.category')
{
// Query the database for the old access level if the item isn't new.
if (!$isNew)
{
$this->checkCategoryAccess($row);
}
}
return true;
}
/**
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks An array of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle articles here.
if ($context === 'com_content.article' || $context === 'com_content.form')
{
$this->itemStateChange($pks, $value);
}
// Handle when the plugin is disabled.
if ($context === 'com_plugins.plugin' && $value === 0)
{
$this->pluginDisable($pks);
}
}
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as a FinderIndexerResult object.
* @param string $format The item format. Not used.
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
$item->setLanguage();
// Check if the extension is enabled.
if (JComponentHelper::isEnabled($this->extension) === false)
{
return;
}
$item->context = 'com_content.article';
// Initialise the item parameters.
$registry = new Registry($item->params);
$item->params = clone JComponentHelper::getParams('com_content', true);
$item->params->merge($registry);
$item->metadata = new Registry($item->metadata);
// Trigger the onContentPrepare event.
$item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params, $item);
$item->body = FinderIndexerHelper::prepareContent($item->body, $item->params, $item);
// Build the necessary route and path information.
$item->url = $this->getUrl($item->id, $this->extension, $this->layout);
$item->route = ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language);
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Get the menu title if it exists.
$title = $this->getItemMenuTitle($item->url);
// Adjust the title if necessary.
if (!empty($title) && $this->params->get('use_menu_title', true))
{
$item->title = $title;
}
// Add the meta author.
$item->metaauthor = $item->metadata->get('author');
// Add the metadata processing instructions.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Translate the state. Articles should only be published if the category is published.
$item->state = $this->translateState($item->state, $item->cat_state);
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Article');
// Add the author taxonomy data.
if (!empty($item->author) || !empty($item->created_by_alias))
{
$item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author);
}
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
$this->indexer->index($item);
}
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function setup()
{
// Load dependent classes.
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
return true;
}
/**
* Method to get the SQL query used to retrieve the list of content items.
*
* @param mixed $query A JDatabaseQuery object or null.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body')
->select('a.images')
->select('a.state, a.catid, a.created AS start_date, a.created_by')
->select('a.created_by_alias, a.modified, a.modified_by, a.attribs AS params')
->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.version, a.ordering')
->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date')
->select('c.title AS category, c.published AS cat_state, c.access AS cat_access');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id . ' END as slug';
$query->select($case_when_item_alias);
$case_when_category_alias = ' CASE WHEN ';
$case_when_category_alias .= $query->charLength('c.alias', '!=', '0');
$case_when_category_alias .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id . ' END as catslug';
$query->select($case_when_category_alias)
->select('u.name AS author')
->from('#__content AS a')
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->join('LEFT', '#__users AS u ON u.id = a.created_by');
return $query;
}
}
home/wuectly/www/libraries/regularlabs/helpers/assignments/content.php 0000604 00000013030 15245721140 0022445 0 ustar 00 <?php
/**
* @package Regular Labs Library
* @version 21.4.10972
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
use Joomla\CMS\Table\Table as JTable;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsContent extends RLAssignment
{
public function passPageTypes()
{
$components = ['com_content', 'com_contentsubmit'];
if ( ! in_array($this->request->option, $components))
{
return $this->pass(false);
}
if ($this->request->view == 'category' && $this->request->layout == 'blog')
{
$view = 'categoryblog';
}
else
{
$view = $this->request->view;
}
return $this->passSimple($view);
}
public function passCategories()
{
// components that use the com_content secs/cats
$components = ['com_content', 'com_flexicontent', 'com_contentsubmit'];
if ( ! in_array($this->request->option, $components))
{
return $this->pass(false);
}
if (empty($this->selection))
{
return $this->pass(false);
}
$is_content = in_array($this->request->option, ['com_content', 'com_flexicontent']);
$is_category = in_array($this->request->view, ['category']);
$is_item = in_array($this->request->view, ['', 'article', 'item', 'form']);
if (
$this->request->option != 'com_contentsubmit'
&& ! ($this->params->inc_categories && $is_content && $is_category)
&& ! ($this->params->inc_articles && $is_content && $is_item)
&& ! ($this->params->inc_others && ! ($is_content && ($is_category || $is_item)))
)
{
return $this->pass(false);
}
if ($this->request->option == 'com_contentsubmit')
{
// Content Submit
$contentsubmit_params = new ContentsubmitModelArticle;
if (in_array($contentsubmit_params->_id, $this->selection))
{
return $this->pass(true);
}
return $this->pass(false);
}
$pass = false;
if (
$this->params->inc_others
&& ! ($is_content && ($is_category || $is_item))
&& $this->article
)
{
if ( ! isset($this->article->id) && isset($this->article->slug))
{
$this->article->id = (int) $this->article->slug;
}
if ( ! isset($this->article->catid) && isset($this->article->catslug))
{
$this->article->catid = (int) $this->article->catslug;
}
$this->request->id = $this->article->id;
$this->request->view = 'article';
}
$catids = $this->getCategoryIds($is_category);
foreach ($catids as $catid)
{
if ( ! $catid)
{
continue;
}
$pass = in_array($catid, $this->selection);
if ($pass && $this->params->inc_children == 2)
{
$pass = false;
continue;
}
if ( ! $pass && $this->params->inc_children)
{
$parent_ids = $this->getCatParentIds($catid);
$parent_ids = array_diff($parent_ids, [1]);
foreach ($parent_ids as $id)
{
if (in_array($id, $this->selection))
{
$pass = true;
break;
}
}
unset($parent_ids);
}
}
return $this->pass($pass);
}
private function getCategoryIds($is_category = false)
{
if ($is_category)
{
return (array) $this->request->id;
}
if ( ! $this->article && $this->request->id)
{
$this->article = JTable::getInstance('content');
$this->article->load($this->request->id);
}
if ($this->article && $this->article->catid)
{
return (array) $this->article->catid;
}
$catid = JFactory::getApplication()->input->getInt('catid', JFactory::getApplication()->getUserState('com_content.articles.filter.category_id'));
$menuparams = $this->getMenuItemParams($this->request->Itemid);
if ($this->request->view == 'featured')
{
$menuparams = $this->getMenuItemParams($this->request->Itemid);
return isset($menuparams->featured_categories) ? (array) $menuparams->featured_categories : (array) $catid;
}
return isset($menuparams->catid) ? (array) $menuparams->catid : (array) $catid;
}
public function passArticles()
{
if ( ! $this->request->id
|| ! (($this->request->option == 'com_content' && $this->request->view == 'article')
|| ($this->request->option == 'com_flexicontent' && $this->request->view == 'item')
)
)
{
return $this->pass(false);
}
$pass = false;
// Pass Article Id
if ( ! $this->passItemByType($pass, 'ContentIds'))
{
return $this->pass(false);
}
// Pass Content Keywords
if ( ! $this->passItemByType($pass, 'ContentKeywords'))
{
return $this->pass(false);
}
// Pass Meta Keywords
if ( ! $this->passItemByType($pass, 'MetaKeywords'))
{
return $this->pass(false);
}
// Pass Authors
if ( ! $this->passItemByType($pass, 'Authors'))
{
return $this->pass(false);
}
return $this->pass($pass);
}
public function getItem($fields = [])
{
if ($this->article)
{
return $this->article;
}
if ( ! class_exists('ContentModelArticle'))
{
require_once JPATH_SITE . '/components/com_content/models/article.php';
}
$model = JModel::getInstance('article', 'contentModel');
if ( ! method_exists($model, 'getItem'))
{
return null;
}
$this->article = $model->getItem($this->request->id);
return $this->article;
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'categories');
}
}