first commit

This commit is contained in:
Llewellyn van der Merwe 2023-04-15 17:01:55 +02:00
commit 52a59e002f
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
98 changed files with 10019 additions and 0 deletions

435
README.md Normal file
View File

@ -0,0 +1,435 @@
```
███████╗██╗ ██╗██████╗ ███████╗██████╗
██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗
███████╗██║ ██║██████╔╝█████╗ ██████╔╝
╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗
███████║╚██████╔╝██║ ███████╗██║ ██║
╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝
```
### What is JCB Super Powers?
The Joomla Component Builder (JCB) Super Power features are designed to enhance JCB's functionality and streamline the development process. These Super Powers enable developers to efficiently manage and share their custom powers across multiple JCB instances through repositories hosted on [https://git.vdm.dev/[username]/[repository-name]](https://git.vdm.dev). JCB Super Powers are managed using a combination of layers, events, tasks, methods, switches, and algorithms, which work together to provide powerful customization and extensibility options. More details on JCB Super Powers can be found in the [Super Powers Documentation](https://git.vdm.dev/joomla/super-powers/wiki).
In summary, JCB Super Powers offer a flexible and efficient way to manage and share functionalities between JCB instances. By utilizing a sophisticated system of layers, events, tasks, methods, switches, and algorithms, developers can seamlessly integrate JCB core powers and their custom powers. For more information on how to work with JCB Super Powers, refer to the [Super Powers User Guide](https://git.vdm.dev/joomla/super-powers/wiki).
### What can I find here?
This repository contains an index (see below) of all the approved powers within the JCB GUI. During the compilation of a component, these powers are automatically added to the repository, ensuring a well-organized and accessible collection of functionalities.
# Index of powers
- **Namespace**: [VDM\Joomla\Componentbuilder\Search](#vdm-joomla-componentbuilder-search)
- **abstract class Factory** | [Details](src/01a89ba8-f8bb-435c-93de-0a8f3fa9432a) | [Code](src/01a89ba8-f8bb-435c-93de-0a8f3fa9432a/code.php) | [Settings](src/01a89ba8-f8bb-435c-93de-0a8f3fa9432a/settings.json) | [01a89ba8-f8bb-435c-93de-0a8f3fa9432a](src/01a89ba8-f8bb-435c-93de-0a8f3fa9432a)
- **class Agent** | [Details](src/0b658434-3767-401e-addc-eabfd1d0e94a) | [Code](src/0b658434-3767-401e-addc-eabfd1d0e94a/code.php) | [Settings](src/0b658434-3767-401e-addc-eabfd1d0e94a/settings.json) | [0b658434-3767-401e-addc-eabfd1d0e94a](src/0b658434-3767-401e-addc-eabfd1d0e94a)
- **class Config** | [Details](src/6e2ca779-f70e-4871-a138-0ee5eaec6a97) | [Code](src/6e2ca779-f70e-4871-a138-0ee5eaec6a97/code.php) | [Settings](src/6e2ca779-f70e-4871-a138-0ee5eaec6a97/settings.json) | [6e2ca779-f70e-4871-a138-0ee5eaec6a97](src/6e2ca779-f70e-4871-a138-0ee5eaec6a97)
- **Namespace**: [VDM\Joomla\Componentbuilder\Search\Abstraction](#vdm-joomla-componentbuilder-search-abstraction)
- **abstract class Engine** | [Details](src/8f9449fc-bfbc-49a5-b146-d58c8c17dfdf) | [Code](src/8f9449fc-bfbc-49a5-b146-d58c8c17dfdf/code.php) | [Settings](src/8f9449fc-bfbc-49a5-b146-d58c8c17dfdf/settings.json) | [8f9449fc-bfbc-49a5-b146-d58c8c17dfdf](src/8f9449fc-bfbc-49a5-b146-d58c8c17dfdf)
- **Namespace**: [VDM\Joomla\Componentbuilder\Search\Agent](#vdm-joomla-componentbuilder-search-agent)
- **class Find** | [Details](src/15d9e1a9-3364-4d69-9d9f-9b87db820e5c) | [Code](src/15d9e1a9-3364-4d69-9d9f-9b87db820e5c/code.php) | [Settings](src/15d9e1a9-3364-4d69-9d9f-9b87db820e5c/settings.json) | [15d9e1a9-3364-4d69-9d9f-9b87db820e5c](src/15d9e1a9-3364-4d69-9d9f-9b87db820e5c)
- **class Replace** | [Details](src/abc37ddd-1ff5-4204-9e5b-015ab4f3d4c7) | [Code](src/abc37ddd-1ff5-4204-9e5b-015ab4f3d4c7/code.php) | [Settings](src/abc37ddd-1ff5-4204-9e5b-015ab4f3d4c7/settings.json) | [abc37ddd-1ff5-4204-9e5b-015ab4f3d4c7](src/abc37ddd-1ff5-4204-9e5b-015ab4f3d4c7)
- **class Search** | [Details](src/e544a248-4b6a-46cb-9926-a3ac9937807c) | [Code](src/e544a248-4b6a-46cb-9926-a3ac9937807c/code.php) | [Settings](src/e544a248-4b6a-46cb-9926-a3ac9937807c/settings.json) | [e544a248-4b6a-46cb-9926-a3ac9937807c](src/e544a248-4b6a-46cb-9926-a3ac9937807c)
- **class Update** | [Details](src/3ac29912-0681-4ca9-8197-d5a8f6a49ac7) | [Code](src/3ac29912-0681-4ca9-8197-d5a8f6a49ac7/code.php) | [Settings](src/3ac29912-0681-4ca9-8197-d5a8f6a49ac7/settings.json) | [3ac29912-0681-4ca9-8197-d5a8f6a49ac7](src/3ac29912-0681-4ca9-8197-d5a8f6a49ac7)
- **Namespace**: [VDM\Joomla\Componentbuilder\Search\Database](#vdm-joomla-componentbuilder-search-database)
- **class Insert** | [Details](src/6caf9473-133c-49a9-afa0-9f84151b5155) | [Code](src/6caf9473-133c-49a9-afa0-9f84151b5155/code.php) | [Settings](src/6caf9473-133c-49a9-afa0-9f84151b5155/settings.json) | [6caf9473-133c-49a9-afa0-9f84151b5155](src/6caf9473-133c-49a9-afa0-9f84151b5155)
- **class Load** | [Details](src/2dabfb4a-64cd-4c04-9772-4a75f9f3b710) | [Code](src/2dabfb4a-64cd-4c04-9772-4a75f9f3b710/code.php) | [Settings](src/2dabfb4a-64cd-4c04-9772-4a75f9f3b710/settings.json) | [2dabfb4a-64cd-4c04-9772-4a75f9f3b710](src/2dabfb4a-64cd-4c04-9772-4a75f9f3b710)
- **Namespace**: [VDM\Joomla\Componentbuilder\Search\Engine](#vdm-joomla-componentbuilder-search-engine)
- **class Basic** | [Details](src/db093eca-63b3-4d6c-9232-3ceb058121c0) | [Code](src/db093eca-63b3-4d6c-9232-3ceb058121c0/code.php) | [Settings](src/db093eca-63b3-4d6c-9232-3ceb058121c0/settings.json) | [db093eca-63b3-4d6c-9232-3ceb058121c0](src/db093eca-63b3-4d6c-9232-3ceb058121c0)
- **class Regex** | [Details](src/83efa9a0-4aec-41f8-9c05-b1ac9617746e) | [Code](src/83efa9a0-4aec-41f8-9c05-b1ac9617746e/code.php) | [Settings](src/83efa9a0-4aec-41f8-9c05-b1ac9617746e/settings.json) | [83efa9a0-4aec-41f8-9c05-b1ac9617746e](src/83efa9a0-4aec-41f8-9c05-b1ac9617746e)
- **Namespace**: [VDM\Joomla\Componentbuilder\Search\Interfaces](#vdm-joomla-componentbuilder-search-interfaces)
- **interface FindInterface** | [Details](src/55280ec7-e48d-431b-af25-10308dd30636) | [Code](src/55280ec7-e48d-431b-af25-10308dd30636/code.php) | [Settings](src/55280ec7-e48d-431b-af25-10308dd30636/settings.json) | [55280ec7-e48d-431b-af25-10308dd30636](src/55280ec7-e48d-431b-af25-10308dd30636)
- **interface InsertInterface** | [Details](src/4c44e5d3-750c-4609-88c8-aa441838b8fe) | [Code](src/4c44e5d3-750c-4609-88c8-aa441838b8fe/code.php) | [Settings](src/4c44e5d3-750c-4609-88c8-aa441838b8fe/settings.json) | [4c44e5d3-750c-4609-88c8-aa441838b8fe](src/4c44e5d3-750c-4609-88c8-aa441838b8fe)
- **interface LoadInterface** | [Details](src/2bd1a32c-3d90-4646-9314-28d44d164f76) | [Code](src/2bd1a32c-3d90-4646-9314-28d44d164f76/code.php) | [Settings](src/2bd1a32c-3d90-4646-9314-28d44d164f76/settings.json) | [2bd1a32c-3d90-4646-9314-28d44d164f76](src/2bd1a32c-3d90-4646-9314-28d44d164f76)
- **interface ReplaceInterface** | [Details](src/afdae35d-fe7f-4055-99ea-afd8ff8349b6) | [Code](src/afdae35d-fe7f-4055-99ea-afd8ff8349b6/code.php) | [Settings](src/afdae35d-fe7f-4055-99ea-afd8ff8349b6/settings.json) | [afdae35d-fe7f-4055-99ea-afd8ff8349b6](src/afdae35d-fe7f-4055-99ea-afd8ff8349b6)
- **interface SearchInterface** | [Details](src/0d9442ab-54d9-4947-a219-244cfaea3084) | [Code](src/0d9442ab-54d9-4947-a219-244cfaea3084/code.php) | [Settings](src/0d9442ab-54d9-4947-a219-244cfaea3084/settings.json) | [0d9442ab-54d9-4947-a219-244cfaea3084](src/0d9442ab-54d9-4947-a219-244cfaea3084)
- **interface SearchTypeInterface** | [Details](src/117d8c9e-3f8d-40ae-b375-1efa2fe5538a) | [Code](src/117d8c9e-3f8d-40ae-b375-1efa2fe5538a/code.php) | [Settings](src/117d8c9e-3f8d-40ae-b375-1efa2fe5538a/settings.json) | [117d8c9e-3f8d-40ae-b375-1efa2fe5538a](src/117d8c9e-3f8d-40ae-b375-1efa2fe5538a)
- **Namespace**: [VDM\Joomla\Componentbuilder\Search\Model](#vdm-joomla-componentbuilder-search-model)
- **class Insert** | [Details](src/02efe40a-7792-4c82-9444-7d0377243483) | [Code](src/02efe40a-7792-4c82-9444-7d0377243483/code.php) | [Settings](src/02efe40a-7792-4c82-9444-7d0377243483/settings.json) | [02efe40a-7792-4c82-9444-7d0377243483](src/02efe40a-7792-4c82-9444-7d0377243483)
- **class Load** | [Details](src/f523ab49-907a-4356-b064-51c85a187fbd) | [Code](src/f523ab49-907a-4356-b064-51c85a187fbd/code.php) | [Settings](src/f523ab49-907a-4356-b064-51c85a187fbd/settings.json) | [f523ab49-907a-4356-b064-51c85a187fbd](src/f523ab49-907a-4356-b064-51c85a187fbd)
- **Namespace**: [VDM\Joomla\Componentbuilder\Search\Service](#vdm-joomla-componentbuilder-search-service)
- **class Agent** | [Details](src/cc6972a7-1574-4ae0-92a8-7f1012aac6f7) | [Code](src/cc6972a7-1574-4ae0-92a8-7f1012aac6f7/code.php) | [Settings](src/cc6972a7-1574-4ae0-92a8-7f1012aac6f7/settings.json) | [cc6972a7-1574-4ae0-92a8-7f1012aac6f7](src/cc6972a7-1574-4ae0-92a8-7f1012aac6f7)
- **class Database** | [Details](src/d5de47ce-9a9e-4e76-a5c6-61ed74842ea3) | [Code](src/d5de47ce-9a9e-4e76-a5c6-61ed74842ea3/code.php) | [Settings](src/d5de47ce-9a9e-4e76-a5c6-61ed74842ea3/settings.json) | [d5de47ce-9a9e-4e76-a5c6-61ed74842ea3](src/d5de47ce-9a9e-4e76-a5c6-61ed74842ea3)
- **class Model** | [Details](src/7f40cc7d-9ab8-4601-8a2b-4eb3d712a40a) | [Code](src/7f40cc7d-9ab8-4601-8a2b-4eb3d712a40a/code.php) | [Settings](src/7f40cc7d-9ab8-4601-8a2b-4eb3d712a40a/settings.json) | [7f40cc7d-9ab8-4601-8a2b-4eb3d712a40a](src/7f40cc7d-9ab8-4601-8a2b-4eb3d712a40a)
- **class Search** | [Details](src/da714ea5-96bb-4eb1-959b-39b457be9cd1) | [Code](src/da714ea5-96bb-4eb1-959b-39b457be9cd1/code.php) | [Settings](src/da714ea5-96bb-4eb1-959b-39b457be9cd1/settings.json) | [da714ea5-96bb-4eb1-959b-39b457be9cd1](src/da714ea5-96bb-4eb1-959b-39b457be9cd1)
# Class Diagrams
## VDM Joomla Componentbuilder Search
> namespace VDM\Joomla\Componentbuilder\Search
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Search #Olive {
abstract Factory #Orange {
# static $container
+ {static} _() : Mixed
+ {static} getContainer() : Container
# {static} createContainer() : Container
}
class Agent #Gold {
# Config $config
# Load $load
# Insert $insert
# Find $find
# Replace $replace
# Search $search
# Update $update
# Table $table
# string $return
# array $marker
# array $markerHtml
+ __construct()
+ getValue() : ?string
+ setValue() : bool
+ table() : ?array
+ find() : ?array
+ replace() : int
# getRow() : array
# getRowCode() : string
# getRowEditButton() : string
# setReturnValue() : void
# setMarkers() : void
}
class Config #Gold {
# getTypesearch() : ?int
# getSearchvalue() : ?string
# getReplacevalue() : string
# getMatchcase() : int
# getWholeword() : int
# getRegexsearch() : int
# getComponentid() : int
# getTablename() : ?string
# getFieldname() : ?string
# getItemid() : int
# getFieldcounter() : int
# getLinecounter() : int
# getMarkerstart() : string
# getMarkerend() : string
}
}
@enduml
```
## VDM Joomla Componentbuilder Search Abstraction
> namespace VDM\Joomla\Componentbuilder\Search\Abstraction
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Search\Abstraction #LightGreen {
abstract Engine #Orange {
# Config $config
# ?string $searchValue
# string $replaceValue
# int $matchCase
# int $wholeWord
# string $start
# string $end
+ __construct()
# lineCounter()
}
}
@enduml
```
## VDM Joomla Componentbuilder Search Agent
> namespace VDM\Joomla\Componentbuilder\Search\Agent
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Search\Agent #LightGreen {
class Find #Gold {
# array $found
# Config $config
# Search $search
+ __construct()
+ get() : ?array
+ item() : void
+ items() : void
+ reset() : void
}
class Replace #Gold {
# array $updated
# Config $config
# Update $update
+ __construct()
+ get() : ?array
+ item() : void
+ items() : void
+ reset() : void
}
class Search #Gold {
# array $found
# Config $config
# SearchEngine $search
+ __construct()
+ get() : ?array
+ value() : bool
+ reset() : void
# searchValue() : ?array
# string() : ?array
# prep() : void
# fieldCounter()
}
class Update #Gold {
# SearchEngine $search
+ __construct()
+ value() : mixed
# updateValue() : mixed
# validateUpdateKey() : bool
# string() : string
}
}
@enduml
```
## VDM Joomla Componentbuilder Search Database
> namespace VDM\Joomla\Componentbuilder\Search\Database
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Search\Database #LightGreen {
class Insert #Gold {
# Config $config
# Table $table
# Model $model
# \JDatabaseDriver $db
+ __construct()
+ value() : bool
+ item() : bool
+ items() : bool
}
class Load #Gold {
# int $bundle
# Config $config
# Table $table
# Model $model
# Database $load
+ __construct()
+ value() : mixed
+ item() : ?object
+ items() : ?array
# next() : int
# incremental() : int
# setDatabaseFields() : ?array
}
}
@enduml
```
## VDM Joomla Componentbuilder Search Engine
> namespace VDM\Joomla\Componentbuilder\Search\Engine
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Search\Engine #LightGreen {
class Basic #Gold {
# string $regexValue
+ __construct()
+ string() : ?string
+ replace() : string
# replaceWhole() : string
# searchWhole() : ?string
+ match() : bool
# searchAll() : ?string
# replaceAll() : string
}
class Regex #Gold {
# string $regexValue
+ __construct()
+ string() : ?string
+ replace() : string
+ match() : bool
}
}
@enduml
```
## VDM Joomla Componentbuilder Search Interfaces
> namespace VDM\Joomla\Componentbuilder\Search\Interfaces
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Search\Interfaces #LightGreen {
interface FindInterface #Lavender {
+ get() : ?array
+ item() : void
+ items() : void
+ reset() : void
}
interface InsertInterface #Lavender {
+ value() : bool
+ item() : bool
+ items() : bool
}
interface LoadInterface #Lavender {
+ value() : mixed
+ item() : ?object
+ items() : ?array
}
interface ReplaceInterface #Lavender {
+ get() : ?array
+ item() : void
+ items() : void
+ reset() : void
}
interface SearchInterface #Lavender {
+ get() : ?array
+ value() : bool
+ reset() : void
}
interface SearchTypeInterface #Lavender {
+ string() : ?string
+ replace() : string
}
}
@enduml
```
## VDM Joomla Componentbuilder Search Model
> namespace VDM\Joomla\Componentbuilder\Search\Model
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Search\Model #LightGreen {
class Insert #Gold {
# Config $config
+ __construct()
+ value() : mixed
# validateBefore() : bool
# validateAfter() : bool
# getTable() : string
}
class Load #Gold {
# Config $config
+ __construct()
+ value() : mixed
# validateBefore() : bool
# validateAfter() : bool
# getTable() : string
}
}
@enduml
```
## VDM Joomla Componentbuilder Search Service
> namespace VDM\Joomla\Componentbuilder\Search\Service
```uml
@startuml
namespace VDM\Joomla\Componentbuilder\Search\Service #LightGreen {
class Agent #Gold {
+ register() : void
+ getAgent() : SearchAgent
+ getFind() : Find
+ getReplace() : Replace
+ getSearch() : Search
+ getUpdate() : Update
}
class Database #Gold {
+ register() : void
+ getLoad() : Load
+ getDatabaseLoad() : LoadDatabase
+ getDatabaseInsert() : InsertDatabase
}
class Model #Gold {
+ register() : void
+ getModelLoad() : Load
+ getModelInsert() : Insert
}
class Search #Gold {
# $searchEngine
+ register() : void
+ getConfig() : Config
+ getTable() : Table
+ getRegex() : Regex
+ getBasic() : Basic
+ getSearch() : SearchEngine
}
}
@enduml
```
---
```
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,54 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Factory (Details)
> namespace: **VDM\Joomla\Componentbuilder\Search**
```uml
@startuml
abstract Factory #Orange {
# static $container
+ {static} _(string $key) : Mixed
+ {static} getContainer() : Container
# {static} createContainer() : Container
}
note right of Factory::_
Get any class from the search container
since: 3.2.0
return: Mixed
end note
note right of Factory::getContainer
Get the global search container
since: 3.2.0
return: Container
end note
note right of Factory::createContainer
Create a container object
since: 3.2.0
return: Container
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,83 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @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;
use VDM\Joomla\Componentbuilder\Search\Service\Search;
use VDM\Joomla\Componentbuilder\Search\Service\Model;
use VDM\Joomla\Componentbuilder\Search\Service\Database;
use VDM\Joomla\Componentbuilder\Search\Service\Agent;
use VDM\Joomla\Componentbuilder\Interfaces\FactoryInterface;
/**
* Search Factory
*
* @since 3.2.0
*/
abstract class Factory implements FactoryInterface
{
/**
* Global Search Container
*
* @var Container
* @since 3.2.0
**/
protected static $container = null;
/**
* Get any class from the search container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _(string $key)
{
return self::getContainer()->get($key);
}
/**
* Get the global search 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
{
return (new Container())
->registerServiceProvider(new Search())
->registerServiceProvider(new Model())
->registerServiceProvider(new Database())
->registerServiceProvider(new Agent());
}
}

View File

@ -0,0 +1,51 @@
/**
* Global Search Container
*
* @var Container
* @since 3.2.0
**/
protected static $container = null;
/**
* Get any class from the search container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _(string $key)
{
return self::getContainer()->get($key);
}
/**
* Get the global search 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
{
return (new Container())
->registerServiceProvider(new Search())
->registerServiceProvider(new Model())
->registerServiceProvider(new Database())
->registerServiceProvider(new Agent());
}

View File

@ -0,0 +1,37 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "0",
"guid": "01a89ba8-f8bb-435c-93de-0a8f3fa9432a",
"implements": [
"caf33c5d-858c-4f9a-894f-ab302ec5445a"
],
"load_selection": null,
"name": "Factory",
"power_version": "1.0.0",
"system_name": "JCB.Search.Factory",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "da714ea5-96bb-4eb1-959b-39b457be9cd1",
"as": "default"
},
"use_selection1": {
"use": "7f40cc7d-9ab8-4601-8a2b-4eb3d712a40a",
"as": "default"
},
"use_selection2": {
"use": "d5de47ce-9a9e-4e76-a5c6-61ed74842ea3",
"as": "default"
},
"use_selection3": {
"use": "cc6972a7-1574-4ae0-92a8-7f1012aac6f7",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Componentbuilder.Search.Factory",
"description": "Search Factory\r\n\r\n@since 3.2.0",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
"head": "use Joomla\\DI\\Container;",
"composer": ""
}

View File

@ -0,0 +1,85 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Insert (Details)
> namespace: **VDM\Joomla\Componentbuilder\Search\Model**
```uml
@startuml
class Insert #Gold {
# Config $config
+ __construct(?Config $config = null, ?Table $table = null)
+ value(mixed $value, string $field, ...) : mixed
# validateBefore(mixed $value, ?string $field = null, ...) : bool
# validateAfter(mixed $value, ?string $field = null, ...) : bool
# getTable() : string
}
note right of Insert::__construct
Constructor
since: 3.2.0
end note
note right of Insert::value
Model the value
Example: $this->value(value, 'field_key', 'table_name');
since: 3.2.0
return: mixed
arguments:
mixed $value
string $field
?string $table = null
end note
note right of Insert::validateBefore
Validate before the value is modelled (basic, override in child class)
since: 3.2.0
return: bool
arguments:
mixed $value
?string $field = null
?string $table = null
end note
note right of Insert::validateAfter
Validate after the value is modelled (basic, override in child class)
since: 3.2.0
return: bool
arguments:
mixed $value
?string $field = null
?string $table = null
end note
note right of Insert::getTable
Get the current active table
since: 3.2.0
return: string
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,137 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @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\Factory;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Abstraction\Model;
/**
* Search Insert Model
*
* @since 3.2.0
*/
class Insert extends Model implements ModelInterface
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* 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)
{
parent::__construct($table ?? Factory::_('Table'));
$this->config = $config ?: Factory::_('Config');
}
/**
* 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->getTable();
}
// 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((string) $value);
break;
case 'json':
$value = json_encode($value, JSON_FORCE_OBJECT);
break;
}
}
return $value;
}
/**
* Validate before the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool
{
// check values
if (StringHelper::check($value) || ArrayHelper::check($value, true))
{
return true;
}
// remove empty values
return false;
}
/**
* Validate after the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool
{
return true;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return $this->config->table_name;
}
}

View File

@ -0,0 +1,106 @@
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* 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)
{
parent::__construct($table ?? Factory::_('Table'));
$this->config = $config ?: Factory::_('Config');
}
/**
* 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->getTable();
}
// 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((string) $value);
break;
case 'json':
$value = json_encode($value, JSON_FORCE_OBJECT);
break;
}
}
return $value;
}
/**
* Validate before the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool
{
// check values
if (StringHelper::check($value) || ArrayHelper::check($value, true))
{
return true;
}
// remove empty values
return false;
}
/**
* Validate after the value is modelled (basic, override in child class)
*
* @param mixed $value The field value
* @param string|null $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool
{
return true;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return $this->config->table_name;
}

View File

@ -0,0 +1,33 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "584747d1-3a86-453d-b7a3-a2219de8d777",
"guid": "02efe40a-7792-4c82-9444-7d0377243483",
"implements": [
"8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff"
],
"load_selection": null,
"name": "Insert",
"power_version": "1.0.0",
"system_name": "JCB.Search.Model.Insert",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "01a89ba8-f8bb-435c-93de-0a8f3fa9432a",
"as": "default"
},
"use_selection1": {
"use": "bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8",
"as": "default"
},
"use_selection2": {
"use": "6e2ca779-f70e-4871-a138-0ee5eaec6a97",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\Componentbuilder.Search.Model.Insert",
"description": "Search Insert Model\r\n\r\n@since 3.2.0",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
"head": "",
"composer": ""
}

View File

@ -0,0 +1,163 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Agent (Details)
> namespace: **VDM\Joomla\Componentbuilder\Search**
```uml
@startuml
class Agent #Gold {
# Config $config
# Load $load
# Insert $insert
# Find $find
# Replace $replace
# Search $search
# Update $update
# Table $table
# string $return
# array $marker
# array $markerHtml
+ __construct(?Config $config = null, ?Load $load = null, ...)
+ getValue(int $id, string $field, ...) : ?string
+ setValue(mixed $value, int $id, ...) : bool
+ table(?string $table = null) : ?array
+ find(?string $table = null) : ?array
+ replace(?string $table = null) : int
# getRow(string $code, string $table, ...) : array
# getRowCode(string $code) : string
# getRowEditButton(string $view, string $field, ...) : string
# setReturnValue() : void
# setMarkers() : void
}
note right of Agent::__construct
Constructor
since: 3.2.0
arguments:
?Config $config = null
?Load $load = null
?Insert $insert = null
?Find $find = null
?Replace $replace = null
?Search $search = null
?Update $update = null
?Table $table = null
end note
note left of Agent::getValue
Get the value of a field in a row and table
since: 3.2.0
return: ?string
arguments:
int $id
string $field
mixed $line = null
?string $table = null
bool $update = false
end note
note right of Agent::setValue
Set the value of a field in a row and table
since: 3.2.0
return: bool
arguments:
mixed $value
int $id
string $field
?string $table = null
end note
note left of Agent::table
Return Table Ready Search Results
since: 3.2.0
return: ?array
end note
note right of Agent::find
Search the posted table for the search value and return all
since: 3.2.0
return: ?array
end note
note left of Agent::replace
Search the posted table for the search value, and replace all
since: 3.2.0
return: int
end note
note right of Agent::getRow
Return prepared code string for table
since: 3.2.0
return: array
arguments:
string $code
string $table
string $field
int $id
mixed $line
end note
note left of Agent::getRowCode
Return prepared code string for table
since: 3.2.0
return: string
end note
note right of Agent::getRowEditButton
Get the Item button to edit an item
since: 3.2.0
return: string
arguments:
string $view
string $field
int $id
mixed $line
end note
note left of Agent::setReturnValue
Set the return value for this search
since: 3.2.0
return: void
end note
note right of Agent::setMarkers
Set the markers of the found code
since: 3.2.0
return: void
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,425 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @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\CMS\Language\Text;
use VDM\Joomla\Componentbuilder\Search\Factory;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Database\Load;
use VDM\Joomla\Componentbuilder\Search\Database\Insert;
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;
use VDM\Joomla\Componentbuilder\Table;
/**
* Search Agent
*
* @since 3.2.0
*/
class Agent
{
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Load Database
*
* @var Load
* @since 3.2.0
*/
protected Load $load;
/**
* Search Insert Database
*
* @var Insert
* @since 3.2.0
*/
protected Insert $insert;
/**
* 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;
/**
* Update
*
* @var Update
* @since 3.2.0
*/
protected Update $update;
/**
* Table
*
* @var Table
* @since 3.2.0
*/
protected Table $table;
/**
* Return value to search view
*
* @var string
* @since 3.2.0
*/
protected string $return;
/**
* Marker start and end values
*
* @var array
* @since 3.2.0
*/
protected array $marker;
/**
* Marker start and end html values
*
* @var array
* @since 3.2.0
*/
protected array $markerHtml;
/**
* Constructor
*
* @param Config|null $config The search config object.
* @param Load|null $load The search load database object.
* @param Insert|null $insert The search insert 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.
* @param Update|null $update The update object.
* @param Table|null $table The table object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Load $load = null,
?Insert $insert = null, ?Find $find = null, ?Replace $replace = null,
?Search $search = null, ?Update $update = null, ?Table $table = null)
{
$this->config = $config ?: Factory::_('Config');
$this->load = $load ?: Factory::_('Load.Database');
$this->insert = $insert ?: Factory::_('Insert.Database');
$this->find = $find ?: Factory::_('Agent.Find');
$this->replace = $replace ?: Factory::_('Agent.Replace');
$this->search = $search ?: Factory::_('Agent.Search');
$this->update = $update ?: Factory::_('Agent.Update');
$this->table = $table ?: Factory::_('Table');
}
/**
* Get the value of a field in a row and table
*
* @param int $id The item ID
* @param string $field The field key
* @param mixed $line The field line
* @param string|null $table The table
* @param bool $update The switch to triger an update (default is false)
*
* @return string|null
* @since 3.2.0
*/
public function getValue(int $id, string $field, $line = null,
?string $table = null, bool $update = false): ?string
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (($value = $this->load->value($id, $field, $table)) !== null)
{
// we only return strings that can load in an editor
if (is_string($value))
{
// try to update the value if required
if ($update && ($updated_value = $this->update->value($value, $line)) !== null)
{
return $updated_value;
}
return $value;
}
return '// VALUE CAN NOT BE LOADED (AT THIS TIME) SINCE ITS NOT A STRING';
}
return null;
}
/**
* Set the value of a field in a row and table
*
* @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 setValue($value, int $id, string $field, ?string $table = null): bool
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
return $this->insert->value($value, $id, $field, $table);
}
/**
* Return Table Ready Search Results
*
* @param string|null $table The table being searched
*
* @return array|null
* @since 3.2.0
*/
public function table(?string $table = null): ?array
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if(($values = $this->find($table)) !== null)
{
// build return value
$this->setReturnValue();
// set the markers
$this->setMarkers();
// start table bucket
$table_rows = [];
foreach ($values as $id => $fields)
{
foreach ($fields as $field => $lines)
{
foreach ($lines as $line => $code)
{
$table_rows[] = $this->getRow($code, $table, $field, $id, $line);
}
}
}
return $table_rows;
}
return null;
}
/**
* 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->load->items($table, $set)) !== null)
{
$this->find->items($items, $table);
$set++;
}
return $this->search->get($table);
}
/**
* Search the posted table for the search value, and replace all
*
* @param string|null $table The table being searched
*
* @return int
* @since 3.2.0
*/
public function replace(?string $table = null): int
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
$set = 1;
$replaced = 0;
// continue loading items until all was loaded
while(($items = $this->load->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
if ($this->insert->items($this->replace->get($table), $table))
{
$replaced++;
}
// reset found items
$this->find->reset($table);
$this->replace->reset($table);
$set++;
}
// we return the number of times we replaced
return $replaced;
}
/**
* Return prepared code string for table
*
* @param string $code The code value fro the table
* @param string|null $table The table
* @param string $field The field key
* @param int $id The the row id
* @param mixed $line The code line where found
*
* @return array
* @since 3.2.0
*/
protected function getRow(string $code, string $table, string $field, int $id, $line): array
{
return [
'edit' => $this->getRowEditButton($table, $field, $id, $line),
'code' => $this->getRowCode($code),
'table' => $table,
'field' => $field,
'id' => $id,
'line' => $line
];
}
/**
* Return prepared code string for table
*
* @param string $code The code value fro the table
*
* @return string
* @since 3.2.0
*/
protected function getRowCode(string $code): string
{
return str_replace($this->marker, $this->markerHtml, htmlentities($code));
}
/**
* Get the Item button to edit an item
*
* @param string|null $view The single view
* @param string $field The field key
* @param int $id The the row id
* @param mixed $line The code line where found
*
* @return string
* @since 3.2.0
*/
protected function getRowEditButton(string $view, string $field, int $id, $line): string
{
// get list view
$views = $this->table->get($view, $field, 'list');
$tab = $this->table->get($view, $field, 'tab_name');
// return edit link
return '<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder' .
'&view=' . $views .
'&task=' . $view . '.edit' .
'&id=' . $id .
'&open_tab=' . $tab .
'&open_field=' . $field .
'&return=' . $this->return . '" title="' .
Text::sprintf('COM_COMPONENTBUILDER_EDIT_S_S_DIRECTLY', $view, $field) . '." ><span class="icon-edit"></span></a>';
}
/**
* Set the return value for this search
*
* @return void
* @since 3.2.0
*/
protected function setReturnValue()
{
// set the return value so the search auto load on return
$this->return = urlencode(base64_encode('index.php?option=com_componentbuilder&view=search' .
'&type_search=' . (int) $this->config->type_search .
'&match_case=' . (int) $this->config->match_case .
'&whole_word=' . (int) $this->config->whole_word .
'&regex_search=' . (int) $this->config->regex_search .
'&search_value=' . (string) urlencode((string) $this->config->search_value) .
'&replace_value=' . (string) urlencode((string) $this->config->replace_value)));
}
/**
* Set the markers of the found code
*
* @return void
* @since 3.2.0
*/
protected function setMarkers()
{
// set the markers
$this->marker = [$this->config->marker_start, $this->config->marker_end];
$this->markerHtml = ['<span class="found_code">','</span>'];
}
}

View File

@ -0,0 +1,389 @@
/**
* Search Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Search Load Database
*
* @var Load
* @since 3.2.0
*/
protected Load $load;