Release search stable BETA.
This commit is contained in:
@ -255,7 +255,7 @@ class External implements ExternalInterface
|
||||
))
|
||||
{
|
||||
// update the hash since it changed
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->target = $target_key;
|
||||
$object->hash = $live_hash;
|
||||
// update local hash
|
||||
@ -296,7 +296,7 @@ class External implements ExternalInterface
|
||||
))
|
||||
{
|
||||
// add the hash to track changes
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->target = $target_key;
|
||||
$object->hash = $live_hash;
|
||||
// insert local hash
|
||||
|
@ -108,6 +108,16 @@ abstract class Engine
|
||||
// set end marker
|
||||
$this->end = $this->config->marker_end;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* we count every line being searched
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function lineCounter()
|
||||
{
|
||||
// we count every line we search
|
||||
$this->config->line_counter = $this->config->line_counter + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ namespace VDM\Joomla\Componentbuilder\Search\Agent;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Search\Factory;
|
||||
use VDM\Joomla\Componentbuilder\Search\Config;
|
||||
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchTypeInterface as SearchEngine;
|
||||
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchInterface;
|
||||
|
||||
@ -34,6 +35,14 @@ class Search implements SearchInterface
|
||||
*/
|
||||
protected array $found = [];
|
||||
|
||||
/**
|
||||
* Search Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Search Engine
|
||||
*
|
||||
@ -45,12 +54,14 @@ class Search implements SearchInterface
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config|null $config The search config object.
|
||||
* @param SearchEngine|null $search The search engine object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?SearchEngine $search = null)
|
||||
public function __construct(?Config $config = null, ?SearchEngine $search = null)
|
||||
{
|
||||
$this->config = $config ?: Factory::_('Config');
|
||||
$this->search = $search ?: Factory::_('Search');
|
||||
}
|
||||
|
||||
@ -226,6 +237,9 @@ class Search implements SearchInterface
|
||||
// line counter
|
||||
$line = 1;
|
||||
|
||||
// we count every field we search
|
||||
$this->fieldCounter();
|
||||
|
||||
// check if string has a new line
|
||||
if (\preg_match('/\R/', $value))
|
||||
{
|
||||
@ -285,6 +299,16 @@ class Search implements SearchInterface
|
||||
}
|
||||
// we should add a call to get the item name if the table has a name field TODO
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* we count every field being searched
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function fieldCounter()
|
||||
{
|
||||
// we count every field we search
|
||||
$this->config->field_counter = $this->config->field_counter + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,28 @@ class Config extends BaseConfig
|
||||
return $this->input->get('item_id', 0, 'INT');
|
||||
}
|
||||
|
||||
/**
|
||||
* get field counter
|
||||
*
|
||||
* @return int we start at 0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getFieldcounter(): ?int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get line counter
|
||||
*
|
||||
* @return int we start at 0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getLinecounter(): ?int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the start marker
|
||||
*
|
||||
|
@ -93,6 +93,9 @@ class Basic extends Engine implements SearchTypeInterface
|
||||
*/
|
||||
public function string(string $value): ?string
|
||||
{
|
||||
// we count every line
|
||||
$this->lineCounter();
|
||||
|
||||
if (StringHelper::check($this->searchValue))
|
||||
{
|
||||
if ($this->wholeWord == 1)
|
||||
|
@ -65,6 +65,9 @@ class Regex extends Engine implements SearchTypeInterface
|
||||
*/
|
||||
public function string(string $value): ?string
|
||||
{
|
||||
// we count every line
|
||||
$this->lineCounter();
|
||||
|
||||
if (StringHelper::check($this->searchValue) && $this->match($value))
|
||||
{
|
||||
return trim(preg_replace(
|
||||
|
@ -119,6 +119,7 @@ class Agent implements ServiceProviderInterface
|
||||
public function getSearch(Container $container): Search
|
||||
{
|
||||
return new Search(
|
||||
$container->get('Config'),
|
||||
$container->get('Search')
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user