Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
PK�8�[{��Y
Y
AbstractObserver.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Table\Observer;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Table\TableInterface;
use Joomla\CMS\Table\Table;
/**
* Table class supporting modified pre-order tree traversal behavior.
*
* @since 3.1.2
*/
abstract class AbstractObserver implements \JObserverInterface
{
/**
* The observed table
*
* @var Table
* @since 3.1.2
*/
protected $table;
/**
* Constructor: Associates to $table $this observer
*
* @param TableInterface $table Table to be observed
*
* @since 3.1.2
*/
public function __construct(TableInterface $table)
{
$table->attachObserver($this);
$this->table = $table;
}
/**
* Pre-processor for $table->load($keys, $reset)
*
* @param mixed $keys An optional primary key value to load the row
by, or an array of fields to match. If not
* set the instance property value is used.
* @param boolean $reset True to reset the default values before
loading the new row.
*
* @return void
*
* @since 3.1.2
*/
public function onBeforeLoad($keys, $reset)
{
}
/**
* Post-processor for $table->load($keys, $reset)
*
* @param boolean &$result The result of the load
* @param array $row The loaded (and already binded to
$this->table) row of the database table
*
* @return void
*
* @since 3.1.2
*/
public function onAfterLoad(&$result, $row)
{
}
/**
* Pre-processor for $table->store($updateNulls)
*
* @param boolean $updateNulls The result of the load
* @param string $tableKey The key of the table
*
* @return void
*
* @since 3.1.2
*/
public function onBeforeStore($updateNulls, $tableKey)
{
}
/**
* Post-processor for $table->store($updateNulls)
*
* @param boolean &$result The result of the store
*
* @return void
*
* @since 3.1.2
*/
public function onAfterStore(&$result)
{
}
/**
* Pre-processor for $table->delete($pk)
*
* @param mixed $pk An optional primary key value to delete. If not
set the instance property value is used.
*
* @return void
*
* @since 3.1.2
* @throws \UnexpectedValueException
*/
public function onBeforeDelete($pk)
{
}
/**
* Post-processor for $table->delete($pk)
*
* @param mixed $pk The deleted primary key value.
*
* @return void
*
* @since 3.1.2
*/
public function onAfterDelete($pk)
{
}
}
PK�8�[lK�%LLContentHistory.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Table\Observer;
defined('JPATH_PLATFORM') or die;
/**
* Table class supporting modified pre-order tree traversal behavior.
*
* @since 3.2
*/
class ContentHistory extends AbstractObserver
{
/**
* Helper object for storing and deleting version history information
associated with this table observer
*
* @var \JHelperContenthistory
* @since 3.2
*/
protected $contenthistoryHelper;
/**
* The pattern for this table's TypeAlias
*
* @var string
* @since 3.2
*/
protected $typeAliasPattern = null;
/**
* Not public, so marking private and deprecated, but needed internally in
parseTypeAlias for
* PHP < 5.4.0 as it's not passing context $this to closure
function.
*
* @var ContentHistory
* @since 3.2
* @deprecated Never use this
* @private
*/
public static $_myTableForPregreplaceOnly;
/**
* Creates the associated observer instance and attaches it to the
$observableObject
* Creates the associated content history helper class instance
* $typeAlias can be of the form "{variableName}.type",
automatically replacing {variableName} with table-instance variables
variableName
*
* @param \JObservableInterface $observableObject The subject object
to be observed
* @param array $params (
'typeAlias' => $typeAlias )
*
* @return ContentHistory
*
* @since 3.2
*/
public static function createObserver(\JObservableInterface
$observableObject, $params = array())
{
$typeAlias = $params['typeAlias'];
$observer = new self($observableObject);
$observer->contenthistoryHelper = new
\JHelperContenthistory($typeAlias);
$observer->typeAliasPattern = $typeAlias;
return $observer;
}
/**
* Post-processor for $table->store($updateNulls)
*
* @param boolean &$result The result of the load
*
* @return void
*
* @since 3.2
*/
public function onAfterStore(&$result)
{
if ($result)
{
$this->parseTypeAlias();
$aliasParts = explode('.',
$this->contenthistoryHelper->typeAlias);
if
(\JComponentHelper::getParams($aliasParts[0])->get('save_history',
0))
{
$this->contenthistoryHelper->store($this->table);
}
}
}
/**
* Pre-processor for $table->delete($pk)
*
* @param mixed $pk An optional primary key value to delete. If not
set the instance property value is used.
*
* @return void
*
* @since 3.2
* @throws \UnexpectedValueException
*/
public function onBeforeDelete($pk)
{
$this->parseTypeAlias();
$aliasParts = explode('.',
$this->contenthistoryHelper->typeAlias);
if
(\JComponentHelper::getParams($aliasParts[0])->get('save_history',
0))
{
$this->parseTypeAlias();
$this->contenthistoryHelper->deleteHistory($this->table);
}
}
/**
* Internal method
* Parses a TypeAlias of the form "{variableName}.type",
replacing {variableName} with table-instance variables variableName
* Storing result into $this->contenthistoryHelper->typeAlias
*
* @return void
*
* @since 3.2
*/
protected function parseTypeAlias()
{
// Needed for PHP < 5.4.0 as it's not passing context $this to
closure function
static::$_myTableForPregreplaceOnly = $this->table;
$this->contenthistoryHelper->typeAlias =
preg_replace_callback('/{([^}]+)}/',
function($matches)
{
return ContentHistory::$_myTableForPregreplaceOnly->{$matches[1]};
},
$this->typeAliasPattern
);
}
}
PK�8�[:���Tags.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Table\Observer;
defined('JPATH_PLATFORM') or die;
/**
* Abstract class defining methods that can be
* implemented by an Observer class of a Table class (which is an
Observable).
* Attaches $this Observer to the $table in the constructor.
* The classes extending this class should not be instantiated directly, as
they
* are automatically instanciated by the \JObserverMapper
*
* @since 3.1.2
*/
class Tags extends AbstractObserver
{
/**
* Helper object for managing tags
*
* @var \JHelperTags
* @since 3.1.2
*/
protected $tagsHelper;
/**
* The pattern for this table's TypeAlias
*
* @var string
* @since 3.1.2
*/
protected $typeAliasPattern = null;
/**
* Override for postStoreProcess param newTags, Set by setNewTags, used by
onAfterStore and onBeforeStore
*
* @var array
* @since 3.1.2
*/
protected $newTags = false;
/**
* Override for postStoreProcess param replaceTags. Set by setNewTags,
used by onAfterStore
*
* @var boolean
* @since 3.1.2
*/
protected $replaceTags = true;
/**
* Not public, so marking private and deprecated, but needed internally in
parseTypeAlias for
* PHP < 5.4.0 as it's not passing context $this to closure
function.
*
* @var Tags
* @since 3.1.2
* @deprecated Never use this
* @private
*/
public static $_myTableForPregreplaceOnly;
/**
* Creates the associated observer instance and attaches it to the
$observableObject
* Creates the associated tags helper class instance
* $typeAlias can be of the form "{variableName}.type",
automatically replacing {variableName} with table-instance variables
variableName
*
* @param \JObservableInterface $observableObject The subject object
to be observed
* @param array $params (
'typeAlias' => $typeAlias )
*
* @return Tags
*
* @since 3.1.2
*/
public static function createObserver(\JObservableInterface
$observableObject, $params = array())
{
$typeAlias = $params['typeAlias'];
$observer = new self($observableObject);
$observer->tagsHelper = new \JHelperTags;
$observer->typeAliasPattern = $typeAlias;
return $observer;
}
/**
* Pre-processor for $table->store($updateNulls)
*
* @param boolean $updateNulls The result of the load
* @param string $tableKey The key of the table
*
* @return void
*
* @since 3.1.2
*/
public function onBeforeStore($updateNulls, $tableKey)
{
$this->parseTypeAlias();
if (empty($this->table->tagsHelper->tags))
{
$this->tagsHelper->preStoreProcess($this->table);
}
else
{
$this->tagsHelper->preStoreProcess($this->table, (array)
$this->table->tagsHelper->tags);
}
}
/**
* Post-processor for $table->store($updateNulls)
* You can change optional params newTags and replaceTags of tagsHelper
with method setNewTagsToAdd
*
* @param boolean &$result The result of the load
*
* @return void
*
* @since 3.1.2
*/
public function onAfterStore(&$result)
{
if ($result)
{
if (empty($this->table->tagsHelper->tags))
{
$result = $this->tagsHelper->postStoreProcess($this->table);
}
else
{
$result = $this->tagsHelper->postStoreProcess($this->table,
$this->table->tagsHelper->tags);
}
// Restore default values for the optional params:
$this->newTags = array();
$this->replaceTags = true;
}
}
/**
* Pre-processor for $table->delete($pk)
*
* @param mixed $pk An optional primary key value to delete. If not
set the instance property value is used.
*
* @return void
*
* @since 3.1.2
* @throws \UnexpectedValueException
*/
public function onBeforeDelete($pk)
{
$this->parseTypeAlias();
$this->tagsHelper->deleteTagData($this->table, $pk);
}
/**
* Sets the new tags to be added or to replace existing tags
*
* @param array $newTags New tags to be added to or replace
current tags for an item
* @param boolean $replaceTags Replace tags (true) or add them (false)
*
* @return boolean
*
* @since 3.1.2
*/
public function setNewTags($newTags, $replaceTags)
{
$this->parseTypeAlias();
return $this->tagsHelper->postStoreProcess($this->table,
$newTags, $replaceTags);
}
/**
* Internal method
* Parses a TypeAlias of the form "{variableName}.type",
replacing {variableName} with table-instance variables variableName
* Storing result into $this->tagsHelper->typeAlias
*
* @return void
*
* @since 3.1.2
*/
protected function parseTypeAlias()
{
// Needed for PHP < 5.4.0 as it's not passing context $this to
closure function
static::$_myTableForPregreplaceOnly = $this->table;
$this->tagsHelper->typeAlias =
preg_replace_callback('/{([^}]+)}/',
function($matches)
{
return Tags::$_myTableForPregreplaceOnly->{$matches[1]};
},
$this->typeAliasPattern
);
}
}
PK�8�[{��Y
Y
AbstractObserver.phpnu�[���PK�8�[lK�%LL�
ContentHistory.phpnu�[���PK�8�[:���+Tags.phpnu�[���PK�d-