Adds the initial classes needed for the new search feature. Adds the empty view for the search feature. #952

This commit is contained in:
2022-09-14 17:40:02 +02:00
parent 1dddba0fc8
commit d757e14fac
57 changed files with 6293 additions and 177 deletions

View File

@ -0,0 +1,131 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder;
use Joomla\Registry\Registry;
use Joomla\CMS\Factory;
use Joomla\Input\Input;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
/**
* Configurations
*
* @since 3.2.0
*/
abstract class BaseConfig extends Registry
{
/**
* Hold a JInput object for easier access to the input variables.
*
* @var Input
* @since 3.2.0
*/
protected $input;
/**
* The Params
*
* @var Registry
* @since 3.2.0
*/
protected Registry $params;
/**
* Constructor
*
* @param Input|null $input Input
* @param Registry|null $params The component parameters
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?Registry $params = null)
{
$this->input = $input ?: Factory::getApplication()->input;
$this->params = $params ?: Helper::getParams('com_componentbuilder');
// use underscore as the separator
$this->separator = '_';
// Instantiate the internal data object.
$this->data = new \stdClass();
}
/**
* setting any config value
*
* @param String $key The value's key/path name
* @param mixed $value Optional default value, returned if the internal value is null.
*
* @since 3.2.0
*/
public function __set($key, $value)
{
$this->set($key, $value);
}
/**
* getting any valid value
*
* @param String $key The value's key/path name
*
* @since 3.2.0
* @throws \InvalidArgumentException If $key is not a valid function name.
*/
public function __get($key)
{
// check if it has been set
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function [%s], or path.', $key, $method));
}
/**
* Get a config value.
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
* @param mixed $default Optional default value, returned if the internal value is null.
*
* @return mixed Value of entry or null
*
* @since 3.2.0
*/
public function get($path, $default = null)
{
// function name with no underscores
$method = 'get' . ucfirst(ClassfunctionHelper::safe(str_replace('_', '', $path)));
// check if it has been set
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}();
$this->set($path, $value);
return $value;
}
return $default;
}
}

View File

@ -71,11 +71,11 @@ class Placeholder implements PlaceholderInterface
/**
* get all System Placeholders
*
* @return array The global placeholders
* @return array The global placeholders
*
* @since 3.2.0
*/
public function get()
public function get(): array
{
// set only once
if (is_array($this->placeholders))

View File

@ -12,13 +12,9 @@
namespace VDM\Joomla\Componentbuilder\Compiler;
use Joomla\Registry\Registry;
use Joomla\CMS\Factory;
use Joomla\Input\Input;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Componentbuilder\BaseConfig;
/**
@ -26,119 +22,8 @@ use VDM\Joomla\Utilities\String\ClassfunctionHelper;
*
* @since 3.2.0
*/
class Config extends Registry implements \JsonSerializable, \ArrayAccess, \IteratorAggregate, \Countable
class Config extends BaseConfig
{
/**
* Hold a JInput object for easier access to the input variables.
*
* @var Input
* @since 3.2.0
*/
protected $input;
/**
* The Params
*
* @var Registry
* @since 3.2.0
*/
protected Registry $params;
/**
* Constructor
*
* @param Input|null $input Input
* @param Registry|null $params The component parameters
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?Registry $params = null)
{
$this->input = $input ?: Factory::getApplication()->input;
$this->params = $params ?: Helper::getParams('com_componentbuilder');
// use underscore as the separator
$this->separator = '_';
// Instantiate the internal data object.
$this->data = new \stdClass();
}
/**
* setting any config value
*
* @param String $key The value's key/path name
* @param mixed $value Optional default value, returned if the internal value is null.
*
* @since 3.2.0
*/
public function __set($key, $value)
{
$this->set($key, $value);
}
/**
* getting any valid value
*
* @param String $key The value's key/path name
*
* @since 3.2.0
* @throws \InvalidArgumentException If $key is not a valid function name.
*/
public function __get($key)
{
// function name with no underscores
$method = 'get' . ucfirst(ClassfunctionHelper::safe(str_replace('_', '', $key)));
if (($value = $this->get($key, '__N0T_S3T_')) !== '__N0T_S3T_')
{
return $value;
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}();
$this->set($key, $value);
return $value;
}
throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function [%s], or path.', $key, $method));
}
/**
* Get a registry value.
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
* @param mixed $default Optional default value, returned if the internal value is null.
*
* @return mixed Value of entry or null
*
* @since 3.2.0
*/
public function get($path, $default = null)
{
// function name with no underscores
$method = 'get' . ucfirst(ClassfunctionHelper::safe(str_replace('_', '', $path)));
// check if it has been set
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}();
$this->set($path, $value);
return $value;
}
return $default;
}
/**
* get posted component id
*

View File

@ -26,6 +26,6 @@ interface PlaceholderInterface
*
* @since 3.2.0
*/
public function get();
public function get(): array;
}

View File

@ -13,6 +13,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler;
use Joomla\Registry\Registry as JoomlaRegistry;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
@ -24,6 +25,14 @@ use Joomla\Registry\Registry as JoomlaRegistry;
*/
class Registry extends JoomlaRegistry implements \JsonSerializable, \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* Default indentation value
*
* @var int
* @since 1.0
*/
protected $indent = 2;
/**
* Method to iterate over any part of the registry
*
@ -43,6 +52,73 @@ class Registry extends JoomlaRegistry implements \JsonSerializable, \ArrayAccess
}
return $data->getIterator();
}
}
/**
* Method to export a set of values to a PHP array
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
* @param int $default The default indentation
*
* @return ?string The var set being exported as a PHP array
*
* @since 3.4.0
*/
public function varExport(string $path, int $default = 2): ?string
{
// check if we have data
if (($data = $this->extract($path)) !== null)
{
// set the default indentation value
$this->indent = $default;
// convert to array
$data = $data->toArray();
// convert to string
$data = var_export($data, true);
// replace all space with system indentation
$data = preg_replace_callback("/^(\s{2})(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(.*)/m", [$this, 'convertIndent'], $data);
// convert all array to []
$array = preg_split("/\r\n|\n|\r/", $data);
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1', ' => ['], $array);
$data = join(PHP_EOL, array_filter(["["] + $array));
// add needed indentation to the last ]
$data = preg_replace("/^(\])/m", Indent::_($default) . '$1', $data);
return $data;
}
return null;
}
/**
* Method to convert found of grouped spaces to system indentation
*
* @param array $matches The regex array of matching values
*
* @return string The resulting string.
*
* @since 3.4.0
*/
protected function convertIndent(array $matches): string
{
// set number to indent by default
$indent = Indent::_($this->indent);
// update each found space (group) with one indentation
foreach (range(1, 11) as $space)
{
if (strlen($matches[$space]) > 0)
{
$indent .= Indent::_(1);
}
}
return $indent . $matches[12];
}
}

View File

@ -44,9 +44,9 @@ abstract class Path
{
foreach ($targets as $target)
{
if (isset($values[$target]) && strpos($values[$target], '\\') !== false)
if (isset($values[$target]))
{
$values[$target] = str_replace('\\', '/', $values[$target]);
self::fix($values[$target], $targets);
}
}
}

View File

@ -0,0 +1,170 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Database\Get;
use VDM\Joomla\Componentbuilder\Search\Database\Set;
use VDM\Joomla\Componentbuilder\Search\Agent\Find;
use VDM\Joomla\Componentbuilder\Search\Agent\Replace;
use VDM\Joomla\Componentbuilder\Search\Agent\Search;
/**
* Search Agent
*
* @since 3.2.0
*/
class Agent
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Get Database
*
* @var Get
* @since 3.2.0
*/
protected Get $get;
/**
* Search Set Database
*
* @var Set
* @since 3.2.0
*/
protected Set $set;
/**
* Search Find
*
* @var Find
* @since 3.2.0
*/
protected Find $find;
/**
* Search Replace
*
* @var Replace
* @since 3.2.0
*/
protected Replace $replace;
/**
* Search
*
* @var Search
* @since 3.2.0
*/
protected Search $search;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Get|null $get The search get database object.
* @param Set|null $set The search get database object.
* @param Find|null $find The search find object.
* @param Replace|null $replace The search replace object.
* @param Search|null $search The search object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Get $get = null,
?Set$set = null, ?Find $find = null, ?Replace $replace = null,
?Search $search = null)
{
$this->config = $config ?: Factory::_('Config');
$this->get = $get ?: Factory::_('Get.Database');
$this->set = $set ?: Factory::_('Set.Database');
$this->find = $find ?: Factory::_('Agent.Find');
$this->replace = $replace ?: Factory::_('Agent.Replace');
$this->search = $search ?: Factory::_('Agent.Search');
}
/**
* Search the posted table for the search value and return all
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function find(?string $table = null): ?array
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
$set = 1;
// continue loading items until all are searched
while(($items = $this->get->items($table, $set)) !== null)
{
$this->find->items($items, $table);
$set++;
}
return $this->search->found($table);
}
/**
* Search the posted table for the search value, and replace all
*
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function replace(?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
$set = 1;
// continue loading items until all was loaded
while(($items = $this->get->items($table, $set)) !== null)
{
// search for items
$this->find->items($items, $table);
// update those found
$this->replace->items($this->find->get($table), $table);
// update the database
$this->set->items($this->replace->get($table), $table);
// reset found items
$this->find->reset($table);
$this->replace->reset($table);
$set++;
}
}
}

View File

@ -0,0 +1,180 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Agent;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Agent\Search;
use VDM\Joomla\Componentbuilder\Search\Interfaces\FindInterface;
/**
* Search Agent Find
*
* @since 3.2.0
*/
class Find implements FindInterface
{
/**
* Found Values
*
* @var array
* @since 3.2.0
*/
protected array $found = [];
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search
*
* @var Search
* @since 3.2.0
*/
protected Search $search;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Search|null $search The search object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Search $search = null)
{
$this->config = $config ?: Factory::_('Config');
$this->search = $search ?: Factory::_('Agent.Search');
}
/**
* Get found values
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(?string $table = null): ?array
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (isset($this->found[$table]))
{
return $this->found[$table];
}
return null;
}
/**
* Search over an item fields
*
* @param object $item The item object of fields to search through
* @param int|null $id The item id
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function item(object $item, ?int $id =null, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// set the item id
if (empty($id))
{
$id = $item->id;
}
if (ObjectHelper::check($item))
{
foreach ($item as $field => $value)
{
if ($field !== 'id' && $this->search->value($value, $id, $field, $table))
{
if (empty($this->found[$table][$id]))
{
$this->found[$table][$id] = new \stdClass();
$this->found[$table][$id]->id = $id;
}
$this->found[$table][$id]->{$field} = $value;
}
}
}
}
/**
* Search over an array of items
*
* @param array|null $items The array of items to search through
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (ArrayHelper::check($items))
{
foreach ($items as $id => $item)
{
$this->item($item, $id, $table);
}
}
}
/**
* Reset all found values of a table
*
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// empty or unset the table active values
unset($this->found[$table]);
}
}

View File

@ -0,0 +1,181 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Agent;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Agent\Update;
use VDM\Joomla\Componentbuilder\Search\Interfaces\ReplaceInterface;
/**
* Search Agent Replace
*
* @since 3.2.0
*/
class Replace implements ReplaceInterface
{
/**
* Updated Values
*
* @var array
* @since 3.2.0
*/
protected array $updated = [];
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Update
*
* @var Update
* @since 3.2.0
*/
protected Update $update;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Update|null $update The update object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Update $update = null)
{
$this->config = $config ?: Factory::_('Config');
$this->update = $update ?: Factory::_('Agent.Update');
}
/**
* Get updated values
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(?string $table = null): ?array
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (isset($this->updated[$table]))
{
return $this->updated[$table];
}
return null;
}
/**
* Search over an item fields
*
* @param object $item The item object of fields to search through
* @param int|null $id The item id
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function item(object $item, ?int $id =null, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// set the item id
if (empty($id))
{
$id = $item->id;
}
if (ObjectHelper::check($item))
{
foreach ($item as $field => $value)
{
if ($field !== 'id' && ($_value = $this->update->value($value, $id, $field, $table)) !== null)
{
if (empty($this->updated[$table][$id]))
{
$this->updated[$table][$id] = new \stdClass();
$this->updated[$table][$id]->id = $id;
}
// add updated value
$this->updated[$table][$id]->{$field} = $_value;
}
}
}
}
/**
* Search over an array of items
*
* @param array|null $items The array of items to search through
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (ArrayHelper::check($items))
{
foreach ($items as $id => $item)
{
$this->item($item, $id, $table);
}
}
}
/**
* Reset all updated values of a table
*
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// empty or unset the table active values
unset($this->updated[$table]);
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Agent;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Table;
/**
* Search Agent Search
*
* @since 3.2.0
*/
class Search
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
}
/**
* Search inside a value
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, ?string $table = null): bool
{
return true;
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Agent;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Table;
/**
* Search Agent Update
*
* @since 3.2.0
*/
class Update
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
}
/**
* Update value
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, int $id, string $field, ?string $table = null)
{
return $value;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,125 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search;
use VDM\Joomla\Componentbuilder\BaseConfig;
/**
* Search Configurations
*
* @since 3.2.0
*/
class Config extends BaseConfig
{
/**
* get posted search value
*
* @return string Raw search value
* @since 3.2.0
*/
protected function getSearchvalue(): string
{
return $this->input->post->get('search_value', null, 'RAW');
}
/**
* get posted replace value
*
* @return string Raw replace value
* @since 3.2.0
*/
protected function getReplacevalue(): string
{
return $this->input->post->get('replace_value', null, 'RAW');
}
/**
* get posted search match case
*
* @return int Match case
* @since 3.2.0
*/
protected function getMatchcase(): int
{
return $this->input->post->get('match_case', 0, 'INT');
}
/**
* get posted search whole word
*
* @return int Whole word
* @since 3.2.0
*/
protected function getWholeword(): int
{
return $this->input->post->get('whole_word', 0, 'INT');
}
/**
* get posted search regex
*
* @return int Regex
* @since 3.2.0
*/
protected function getRegex(): int
{
return $this->input->post->get('regex_search', 0, 'INT');
}
/**
* get posted component
*
* @return int Component ID
* @since 3.2.0
*/
protected function getComponentid(): int
{
return $this->input->post->get('component_id', 0, 'INT');
}
/**
* get posted area/table
*
* @return string Table name
* @since 3.2.0
*/
protected function getTablename(): string
{
return $this->input->post->get('table_name', null, 'word');
}
/**
* get posted field
*
* @return string Field name
* @since 3.2.0
*/
protected function getFieldname(): string
{
return $this->input->post->get('field_name', null, 'word');
}
/**
* get posted item id
*
* @return int Item id
* @since 3.2.0
*/
protected function getItemid(): int
{
return $this->input->post->get('item_id', 0, 'INT');
}
}

View File

@ -0,0 +1,295 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Database;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Table;
use VDM\Joomla\Componentbuilder\Search\Model\Get as Model;
use VDM\Joomla\Componentbuilder\Search\Interfaces\GetInterface;
/**
* Search Database Get
*
* @since 3.2.0
*/
class Get implements GetInterface
{
/**
* Bundle Size
*
* @var int
* @since 3.2.0
*/
protected int $bundle = 300;
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Search Model
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
* @param Model|null $model The search get model object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null,
?Model $model = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
$this->model = $model ?: Factory::_('Get.Model');
$this->db = $db ?: JoomlaFactory::getDbo();
}
/**
* Get values from a given table
* Example: $this->value(23, 'value_key', 'table_name');
*
* @param string $field The field key
* @param int $id The item ID
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value(string $field, int $id, string $table = null)
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid field and table
if ($id > 0 && ($name = $this->table->get($table, $field, 'name')) !== null)
{
// Create a new query object.
$query = $this->db->getQuery(true);
// Order it by the ordering field.
$query->select($name);
$query->from($this->db->quoteName('#__componentbuilder_' . $table));
// get by id
$query->where($this->db->quoteName('id') . " = " . $id);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
$this->db->execute();
// check if we have any values
if ($this->db->getNumRows())
{
// return found values
return $this->model->value($this->db->loadResult(), $name, $table);
}
}
return null;
}
/**
* Get values from a given table
* Example: $this->item(23, 'table_name');
*
* @param int $id The item ID
* @param string| null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(int $id, string $table = null): ?object
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if ($id > 0 && ($fields = $this->table->fields($table)) !== null)
{
// add the ID
array_unshift($fields , 'id');
// Create a new query object.
$query = $this->db->getQuery(true);
// Order it by the ordering field.
$query->select($this->db->quoteName($fields));
$query->from($this->db->quoteName('#__componentbuilder_' . $table));
// get by id
$query->where($this->db->quoteName('id') . " = " . $id);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
$this->db->execute();
// check if we have any values
if ($this->db->getNumRows())
{
// return found values
return $this->model->item($this->db->loadObject(), $table);
}
}
return null;
}
/**
* Get values from a given table
* Example: $this->items('table_name');
*
* @param string|null $table The table
* @param int $bundle The bundle to return (0 = all)
*
* @return array|null
* @since 3.2.0
*/
public function items(string $table = null, int $bundle = 0): ?array
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (($fields = $this->table->fields($table)) !== null)
{
// add the ID
array_unshift($fields , 'id');
// get the title value
$title = $this->table->titleName($table);
// Create a new query object.
$query = $this->db->getQuery(true);
// Order it by the ordering field.
$query->select($this->db->quoteName($fields));
$query->from($this->db->quoteName('#__componentbuilder_' . $table));
$query->order($title .' ASC');
// add limitation and pagination
if ($bundle > 0)
{
// get the incremental number
$query->where($this->db->quoteName('id') . " >= " . $this->next($table, $bundle));
// only return a limited number
$query->setLimit($this->bundle);
}
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
$this->db->execute();
// check if we have any values
if ($this->db->getNumRows())
{
// return found values
return $this->model->items($this->db->loadObjectList('id'), $table);
}
}
return null;
}
/**
* Get next id to call
*
* @param string $table The table
* @param int $bundle The bundle to return
*
* @return int
* @since 3.2.0
*/
protected function next(string $table, int $bundle): int
{
if ($bundle == 1 || $bundle == 0)
{
return 1;
}
if (($number = $this->model->last($table)) !== null)
{
return $number + 1;
}
return $this->incremental($bundle);
}
/**
* Get Incremental number where the set starts
*
* @param int $bundle The bundle to return
*
* @return int
* @since 3.2.0
*/
protected function incremental(int $bundle): int
{
// just in case
if ($bundle == 1 || $bundle == 0)
{
return 1;
}
/** Number two set starts at 301
* 2 x 300 = 600
* 600 - 300 = 300
* 300 + 1 = 301 <--
* Number five set starts at 1201
* 5 x 300 = 1500
* 1500 - 300 = 1200
* 1200 + 1 = 1201 <--
**/
return (($bundle * $this->bundle) - $this->bundle) + 1;
}
}

View File

@ -0,0 +1,187 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Database;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Table;
use VDM\Joomla\Componentbuilder\Search\Model\Set as Model;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SetInterface;
/**
* Search Database Set
*
* @since 3.2.0
*/
class Set implements SetInterface
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Search Model
*
* @var Model
* @since 3.2.0
*/
protected Model $model;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
* @param Model|null $model The search get model object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null,
?Model $model = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
$this->model = $model ?: Factory::_('Set.Model');
$this->db = $db ?: JoomlaFactory::getDbo();
}
/**
* Set values to a given table
* Example: $this->value(Value, 23, 'value_key', 'table_name');
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, ?string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid field and table
if ($id > 0 && ($name = $this->table->get($table, $field, 'name')) !== null)
{
// build the object
$item = new \stdClass();
$item->id = $id;
$item->{$name} = $this->model->value($value, $name, $table);
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' . $table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->item(Object, 23, 'table_name');
*
* @param object $item The item to save
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (($fields = $this->table->fields($table)) !== null)
{
// model the item values
foreach ($fields as $field)
{
if (isset($item->{$field}))
{
$item->{$field} = $this->model->value($item->{$field}, $field, $table);
}
}
// Update the column of this table using id as the primary key.
return $this->db->updateObject('#__componentbuilder_' . $table, $item, 'id');
}
return false;
}
/**
* Set values to a given table
* Example: $this->items(Array, 'table_name');
*
* @param array $items The items being saved
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function items(array $items, string $table = null): bool
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (ArrayHelper::check($items))
{
$success = true;
foreach ($items as $item)
{
if ($this->item($item, $table) !== true)
{
$success = false;
break;
}
}
return $success;
}
return false;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,80 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search;
use Joomla\DI\Container;
/**
* Search Factory
*
* @since 3.2.0
*/
abstract class Factory
{
/**
* Global Compiler Container
*
* @var Container
* @since 3.2.0
**/
protected static $container = null;
/**
* Get any class from the compiler container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _($key)
{
return self::getContainer()->get($key);
}
/**
* Get a the global compiler container
*
* @return Container
* @since 3.2.0
*/
public static function getContainer(): Container
{
if (!self::$container)
{
self::$container = self::createContainer();
}
return self::$container;
}
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
$container = (new Container())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Search\Service\Search())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Search\Service\Model())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Search\Service\Database())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Search\Service\Agent());
return $container;
}
}

View File

@ -0,0 +1,65 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Interfaces;
/**
* Search Find Interface
*
* @since 3.2.0
*/
interface FindInterface
{
/**
* Get found values
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(?string $table = null): ?array;
/**
* Search over an item fields
*
* @param object $item The item object of fields to search through
* @param int|null $id The item id
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function item(object $item, ?int $id =null, ?string $table = null);
/**
* Search over an array of items
*
* @param array|null $items The array of items to search through
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null);
/**
* Reset all found values of a table
*
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(?string $table = null);
}

View File

@ -0,0 +1,60 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Interfaces;
/**
* Search Database Get Interface
*
* @since 3.2.0
*/
interface GetInterface
{
/**
* Get values from a given table
* Example: $this->value(23, 'value_key', 'table_name');
*
* @param string $field The field key
* @param int $id The item ID
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value(string $field, int $id, string $table = null);
/**
* Get values from a given table
* Example: $this->item(23, 'table_name');
*
* @param int $id The item ID
* @param string| null $table The table
*
* @return object|null
* @since 3.2.0
*/
public function item(int $id, string $table = null): ?object;
/**
* Get values from a given table
* Example: $this->items('table_name');
*
* @param string|null $table The table
* @param int $bundle The bundle to return (0 = all)
*
* @return array|null
* @since 3.2.0
*/
public function items(string $table = null, int $bundle = 0): ?array;
}

View File

@ -0,0 +1,71 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Interfaces;
/**
* Search Model Interface
*
* @since 3.2.0
*/
interface ModelInterface
{
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null);
/**
* Model the values of an item
* Example: $this->item('table_name', Object);
*
* @param string $table The table
* @param object $item The item object
*
* @return object
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): object;
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null): ?array;
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int;
}

View File

@ -0,0 +1,66 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Interfaces;
/**
* Search Replace Interface
*
* @since 3.2.0
*/
interface ReplaceInterface
{
/**
* Get updated values
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function get(?string $table = null): ?array;
/**
* Search over an item fields
*
* @param object $item The item object of fields to search through
* @param int|null $id The item id
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function item(object $item, ?int $id =null, ?string $table = null);
/**
* Search over an array of items
*
* @param array|null $items The array of items to search through
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null);
/**
* Reset all updated values of a table
*
* @param string|null $table The table being searched
*
* @return void
* @since 3.2.0
*/
public function reset(?string $table = null);
}

View File

@ -0,0 +1,60 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Interfaces;
/**
* Search Database Set Interface
*
* @since 3.2.0
*/
interface SetInterface
{
/**
* Set values to a given table
* Example: $this->value(Value, 23, 'value_key', 'table_name');
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function value($value, int $id, string $field, ?string $table = null): bool;
/**
* Set values to a given table
* Example: $this->item(Object, 23, 'table_name');
*
* @param object $item The item to save
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): bool;
/**
* Set values to a given table
* Example: $this->items(Array, 'table_name');
*
* @param array $items The items being saved
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function items(array $items, string $table = null): bool;
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,160 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Table;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Search Model
*
* @since 3.2.0
*/
abstract class Model
{
/**
* Last ID
*
* @var array
* @since 3.2.0
*/
protected array $last;
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
}
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');
*
* @param object $item The item object
* @param string|null $table The table
*
* @return object
* @since 3.2.0
*/
public function item(object $item, ?string $table = null): object
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (($fields = $this->table->fields($table)) !== null)
{
foreach ($fields as $field)
{
if(isset($item->{$field}))
{
$item->{$field} = $this->value($item->{$field}, $field, $table);
}
}
}
return $item;
}
/**
* Model the values of multiple items
* Example: $this->items(Array, 'table_name');
*
* @param array|null $items The array of item objects
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function items(?array $items = null, ?string $table = null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
foreach ($items as $id => &$item)
{
// model the item
$item = $this->item($item, $table);
// add the last ID
$this->last[$table] = $item->id;
}
}
return $items;
}
/**
* Get last modeled ID
* Example: $this->last('table_name');
*
* @param string|null $table The table
*
* @return int|null
* @since 3.2.0
*/
public function last(?string $table = null): ?int
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if ($table && isset($this->last[$table]))
{
return $this->last[$table];
}
return null;
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Model;
use VDM\Joomla\Componentbuilder\Search\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Search\Model;
/**
* Search Get Model
*
* @since 3.2.0
*/
class Get extends Model implements ModelInterface
{
/**
* Model the value
* Example: $this->value(value, 'value_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null)
{
// load the table
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (($store = $this->table->get($table, $field, 'store')) !== null)
{
// open the value based on the store method
switch($store)
{
case 'base64':
$value = \base64_decode($value);
break;
case 'json':
$value = \json_decode($value, true);
break;
}
}
return $value;
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Model;
use VDM\Joomla\Componentbuilder\Search\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Search\Model;
/**
* Search Set Model
*
* @since 3.2.0
*/
class Set extends Model implements ModelInterface
{
/**
* Model the value
* Example: $this->value(value, 'field_key', 'table_name');
*
* @param mixed $value The value to model
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value($value, string $field, ?string $table = null)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
// check if this is a valid table
if (($store = $this->table->get($table, $field, 'store')) !== null)
{
// open the value based on the store method
switch($store)
{
case 'base64':
$value = \base64_encode($value);
break;
case 'json':
$value = \json_encode($value, JSON_FORCE_OBJECT);
break;
}
}
return $value;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,142 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Search\Agent as SearchAgent;
use VDM\Joomla\Componentbuilder\Search\Agent\Find;
use VDM\Joomla\Componentbuilder\Search\Agent\Replace;
use VDM\Joomla\Componentbuilder\Search\Agent\Search;
use VDM\Joomla\Componentbuilder\Search\Agent\Update;
/**
* Agent Service Provider
*
* @since 3.2.0
*/
class Agent implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(SearchAgent::class, 'Agent')
->share('Agent', [$this, 'getAgent'], true);
$container->alias(Find::class, 'Agent.Find')
->share('Agent.Find', [$this, 'getFind'], true);
$container->alias(Replace::class, 'Agent.Replace')
->share('Agent.Replace', [$this, 'getReplace'], true);
$container->alias(Search::class, 'Agent.Search')
->share('Agent.Search', [$this, 'getSearch'], true);
$container->alias(Update::class, 'Agent.Update')
->share('Agent.Update', [$this, 'getUpdate'], true);
}
/**
* Get the Search Agent
*
* @param Container $container The DI container.
*
* @return SearchAgent
* @since 3.2.0
*/
public function getAgent(Container $container): SearchAgent
{
return new SearchAgent(
$container->get('Config'),
$container->get('Get.Database'),
$container->get('Set.Database'),
$container->get('Agent.Find'),
$container->get('Agent.Replace'),
$container->get('Agent.Search')
);
}
/**
* Get the Search Agent Find
*
* @param Container $container The DI container.
*
* @return Find
* @since 3.2.0
*/
public function getFind(Container $container): Find
{
return new Find(
$container->get('Config'),
$container->get('Agent.Search')
);
}
/**
* Get the Search Agent Replace
*
* @param Container $container The DI container.
*
* @return Replace
* @since 3.2.0
*/
public function getReplace(Container $container): Replace
{
return new Replace(
$container->get('Config'),
$container->get('Agent.Update')
);
}
/**
* Get the Search Agent Search
*
* @param Container $container The DI container.
*
* @return Search
* @since 3.2.0
*/
public function getSearch(Container $container): Search
{
return new Search(
$container->get('Config'),
$container->get('Table')
);
}
/**
* Get the Search Agent Update
*
* @param Container $container The DI container.
*
* @return Update
* @since 3.2.0
*/
public function getUpdate(Container $container): Update
{
return new Update(
$container->get('Config'),
$container->get('Table')
);
}
}

View File

@ -0,0 +1,80 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Search\Database\Get as GetDatabase;
use VDM\Joomla\Componentbuilder\Search\Database\Set as SetDatabase;
/**
* Database Service Provider
*
* @since 3.2.0
*/
class Database implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(GetDatabase::class, 'Get.Database')
->share('Get.Database', [$this, 'getDatabaseGet'], true);
$container->alias(SetDatabase::class, 'Set.Database')
->share('Set.Database', [$this, 'getDatabaseSet'], true);
}
/**
* Get the Get Database
*
* @param Container $container The DI container.
*
* @return GetDatabase
* @since 3.2.0
*/
public function getDatabaseGet(Container $container): GetDatabase
{
return new GetDatabase(
$container->get('Config'),
$container->get('Table'),
$container->get('Get.Model')
);
}
/**
* Get the Set Database
*
* @param Container $container The DI container.
*
* @return SetDatabase
* @since 3.2.0
*/
public function getDatabaseSet(Container $container): SetDatabase
{
return new SetDatabase(
$container->get('Config'),
$container->get('Table'),
$container->get('Set.Model')
);
}
}

View File

@ -0,0 +1,78 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Search\Model\Get;
use VDM\Joomla\Componentbuilder\Search\Model\Set;
/**
* Model Service Provider
*
* @since 3.2.0
*/
class Model implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Get::class, 'Get.Model')
->share('Get.Model', [$this, 'getModelGet'], true);
$container->alias(Set::class, 'Set.Model')
->share('Set.Model', [$this, 'getModelSet'], true);
}
/**
* Get the Get Model
*
* @param Container $container The DI container.
*
* @return Get
* @since 3.2.0
*/
public function getModelGet(Container $container): Get
{
return new Get(
$container->get('Config'),
$container->get('Table')
);
}
/**
* Get the Set Model
*
* @param Container $container The DI container.
*
* @return Set
* @since 3.2.0
*/
public function getModelSet(Container $container): Set
{
return new Set(
$container->get('Config'),
$container->get('Table')
);
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Table;
/**
* Search Service Provider
*
* @since 3.2.0
*/
class Search implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
}
/**
* Get the Config
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.0
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get the Table
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.0
*/
public function getTable(Container $container): Table
{
return new Table(
$container->get('Config')
);
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>