Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
categories.php000064400000025217151160241170007407 0ustar00<?php
/**
* @package Joomla.Plugin
* @subpackage Finder.Categories
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @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 Joomla Categories.
*
* @since 2.5
*/
class PlgFinderCategories extends FinderIndexerAdapter
{
/**
* The plugin identifier.
*
* @var string
* @since 2.5
*/
protected $context = 'Categories';
/**
* The extension name.
*
* @var string
* @since 2.5
*/
protected $extension = 'com_categories';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 2.5
*/
protected $layout = 'category';
/**
* The type of content that the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $type_title = 'Category';
/**
* The table name.
*
* @var string
* @since 2.5
*/
protected $table = '#__categories';
/**
* The field the published state is stored in.
*
* @var string
* @since 2.5
*/
protected $state_field = 'published';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* 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 onFinderDelete($context, $table)
{
if ($context === 'com_categories.category')
{
$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 a category that has been saved.
* It also makes adjustments if the access level of the category has
changed.
*
* @param string $context The context of the category passed to the
plugin.
* @param JTable $row A JTable object.
* @param boolean $isNew True if the category 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 categories here.
if ($context === 'com_categories.category')
{
// Check if the access levels are different.
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
}
// Reindex the category item.
$this->reindex($row->id);
// Check if the parent access level is 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 category passed to the
plugin.
* @param JTable $row A JTable object.
* @param boolean $isNew True if the category 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 categories here.
if ($context === 'com_categories.category')
{
// Query the database for the old access level and the parent if the
item isn't new.
if (!$isNew)
{
$this->checkItemAccess($row);
$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 category passed to the
plugin.
* @param array $pks An array of primary key ids of the category
that has changed state.
* @param integer $value The value of the state that the category
has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle categories here.
if ($context === 'com_categories.category')
{
/*
* The category published state is tied to the parent category
* published state so we need to look up all published states
* before we change anything.
*/
foreach ($pks as $pk)
{
$query = clone $this->getStateQuery();
$query->where('a.id = ' . (int) $pk);
$this->db->setQuery($query);
$item = $this->db->loadObject();
// Translate the state.
$state = null;
if ($item->parent_id != 1)
{
$state = $item->cat_state;
}
$temp = $this->translateState($value, $state);
// Update the item.
$this->change($pk, 'state', $temp);
// Reindex the item.
$this->reindex($pk);
}
}
// 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')
{
// Check if the extension is enabled.
if (JComponentHelper::isEnabled($this->extension) === false)
{
return;
}
// Check if the extension that owns the category is also enabled.
if (JComponentHelper::isEnabled($item->extension) === false)
{
return;
}
$item->setLanguage();
$extension = ucfirst(substr($item->extension, 4));
// Initialize the item parameters.
$item->params = new Registry($item->params);
$item->metadata = new Registry($item->metadata);
/*
* Add the metadata processing instructions based on the category's
* configuration parameters.
*/
// Add the meta author.
$item->metaauthor = $item->metadata->get('author');
// Handle the link to the metadata.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link');
$item->addInstruction(FinderIndexer::META_CONTEXT,
'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT,
'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT,
'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT,
'author');
// Deactivated Methods
// $item->addInstruction(FinderIndexer::META_CONTEXT,
'created_by_alias');
// Trigger the onContentPrepare event.
$item->summary =
FinderIndexerHelper::prepareContent($item->summary, $item->params);
// Build the necessary route and path information.
$item->url = $this->getUrl($item->id, $item->extension,
$this->layout);
$class = $extension . 'HelperRoute';
// Need to import component route helpers dynamically, hence the reason
it's handled here.
JLoader::register($class, JPATH_SITE . '/components/' .
$item->extension . '/helpers/route.php');
if (class_exists($class) && method_exists($class,
'getCategoryRoute'))
{
$item->route = $class::getCategoryRoute($item->id,
$item->language);
}
else
{
$item->route = ContentHelperRoute::getCategoryRoute($item->id,
$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;
}
// Translate the state. Categories should only be published if the parent
category is published.
$item->state = $this->translateState($item->state);
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Category');
// 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 com_content route helper as it is the fallback for routing in the
indexer in this instance.
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.description AS summary,
a.extension')
->select('a.created_user_id AS created_by, a.modified_time AS
modified, a.modified_user_id AS modified_by')
->select('a.metakey, a.metadesc, a.metadata, a.language, a.lft,
a.parent_id, a.level')
->select('a.created_time AS start_date, a.published AS state,
a.access, a.params');
// 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)
->from('#__categories AS a')
->where($db->quoteName('a.id') . ' > 1');
return $query;
}
/**
* Method to get a SQL query to load the published and access states for
* a category and its parents.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getStateQuery()
{
$query = $this->db->getQuery(true)
->select($this->db->quoteName('a.id'))
->select($this->db->quoteName('a.parent_id'))
->select('a.' . $this->state_field . ' AS state,
c.published AS cat_state')
->select('a.access, c.access AS cat_access')
->from($this->db->quoteName('#__categories') . '
AS a')
->join('LEFT', '#__categories AS c ON c.id =
a.parent_id');
return $query;
}
}
categories.xml000064400000001521151160241170007410 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin"
group="finder" method="upgrade">
<name>plg_finder_categories</name>
<author>Joomla! Project</author>
<creationDate>August 2011</creationDate>
<copyright>(C) 2005 - 2020 Open Source Matters. All rights
reserved.</copyright>
<license>GNU General Public License version 2 or later; see
LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_FINDER_CATEGORIES_XML_DESCRIPTION</description>
<files>
<filename
plugin="categories">categories.php</filename>
</files>
<languages>
<language
tag="en-GB">language/en-GB/en-GB.plg_finder_categories.ini</language>
<language
tag="en-GB">language/en-GB/en-GB.plg_finder_categories.sys.ini</language>
</languages>
</extension>
default.php000064400000002435151165371140006711 0ustar00<?php
/**
* @package Joomla.Site
* @subpackage Template.beez5
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$app = JFactory::getApplication();
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
JHtml::_('behavior.caption');
?>
<div class="categories-list<?php echo
$this->pageclass_sfx;?>">
<?php if ($this->params->get('show_page_heading')) :
?>
<h1>
<?php echo
$this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>
<?php if ($this->params->get('show_base_description')) :
?>
<?php //If there is a description in the menu parameters use that;
?>
<?php if
($this->params->get('categories_description')) : ?>
<?php echo JHtml::_('content.prepare',
$this->params->get('categories_description'), '',
'com_content.categories'); ?>
<?php else: ?>
<?php //Otherwise get one from the database if it exists. ?>
<?php if ($this->parent->description) : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare',
$this->parent->description, '',
'com_content.categories'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php
echo $this->loadTemplate('items');
?>
</div>
default_items.php000064400000003246151165371140010113 0ustar00<?php
/**
* @package Joomla.Site
* @subpackage com_content
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
// no direct access
defined('_JEXEC') or die;
$class = ' class="first"';
if ($this->maxLevelcat != 0 &&
count($this->items[$this->parent->id]) > 0) :
?>
<ul>
<?php foreach ($this->items[$this->parent->id] as $id =>
$item) : ?>
<?php
if ($item->numitems ||
$this->params->get('show_empty_categories_cat') ||
count($item->getChildren())) :
if (!isset($this->items[$this->parent->id][$id + 1]))
{
$class = ' class="last"';
}
?>
<li<?php echo $class; ?>>
<?php $class = ''; ?>
<h3 class="item-title"><a href="<?php echo
JRoute::_(ContentHelperRoute::getCategoryRoute($item->id));?>">
<?php echo $this->escape($item->title); ?></a>
</h3>
<?php if ($this->params->get('show_subcat_desc_cat')
== 1) :?>
<?php if ($item->description) : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare',
$item->description); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if
($this->params->get('show_cat_num_articles_cat') == 1)
:?>
<dl class="article-count"><dt>
<?php echo JText::_('COM_CONTENT_NUM_ITEMS');
?></dt>
<dd><?php echo $item->numitems; ?></dd>
</dl>
<?php endif; ?>
<?php if (count($item->getChildren()) > 0) :
$this->items[$item->id] = $item->getChildren();
$this->parent = $item;
$this->maxLevelcat--;
echo $this->loadTemplate('items');
$this->parent = $item->getParent();
$this->maxLevelcat++;
endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>