diff --git a/.gitattributes b/.gitattributes index 2a61500..d7adb22 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,8 @@ +/.github export-ignore /tests export-ignore /client/src export-ignore /.gitattributes export-ignore /.travis.yml export-ignore /.scrutinizer.yml export-ignore -/.github export-ignore +/doctum* export-ignore + diff --git a/.gitignore b/.gitignore index c1eda34..23a5407 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ +composer.lock +doctum_build +doctum_cache gh-payload.json +vendor + diff --git a/composer.json b/composer.json index 947fd9c..4204d7a 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,9 @@ "ext-sqlite3": "*", "symbiote/silverstripe-queuedjobs": "^4.12 || ^5.1" }, + "require-dev": { + "code-lts/doctum": "^5.5" + }, "autoload": { "psr-4": { "Werkbot\\Search\\": "src/" diff --git a/doctum.config.php b/doctum.config.php new file mode 100644 index 0000000..5836001 --- /dev/null +++ b/doctum.config.php @@ -0,0 +1,8 @@ + 'Werkbot Search', + 'build_dir' => __DIR__.'/doctum_build', + 'cache_dir' => __DIR__.'/doctum_cache', +]); + diff --git a/src/DatabaseAdminExtension.php b/src/DatabaseAdminExtension.php index e46182a..94b022b 100644 --- a/src/DatabaseAdminExtension.php +++ b/src/DatabaseAdminExtension.php @@ -4,6 +4,7 @@ use SilverStripe\Control\Controller; use SilverStripe\ORM\DataExtension; +use Werkbot\Search\Tasks\SearchIndex; class DatabaseAdminExtension extends DataExtension { diff --git a/src/Helpers/TNTSearchHelper.php b/src/Helpers/TNTSearchHelper.php index 3e63e27..ed55592 100644 --- a/src/Helpers/TNTSearchHelper.php +++ b/src/Helpers/TNTSearchHelper.php @@ -1,11 +1,10 @@ queueJob(new RemoveSearchQueriesJob(), date('Y-m-d', strtotime($queueNextRun))); } } + diff --git a/src/SearchControllerExtension.php b/src/SearchControllerExtension.php index 376ad51..2b4fa19 100644 --- a/src/SearchControllerExtension.php +++ b/src/SearchControllerExtension.php @@ -2,21 +2,21 @@ namespace Werkbot\Search; -use SilverStripe\ORM\ArrayList; +use SilverStripe\CMS\Search\SearchForm; +use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\ClassInfo; use SilverStripe\Forms\FieldList; -use SilverStripe\Forms\TextField; use SilverStripe\Forms\FormAction; +use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\TextField; +use SilverStripe\ORM\ArrayList; use SilverStripe\ORM\DataExtension; +use SilverStripe\ORM\FieldType\DBField; use SilverStripe\ORM\PaginatedList; -use Werkbot\Search\TNTSearchHelper; -use SilverStripe\Control\HTTPRequest; -use SilverStripe\Forms\RequiredFields; use SilverStripe\ORM\ValidationResult; -use SilverStripe\CMS\Search\SearchForm; -use SilverStripe\ORM\FieldType\DBField; use SilverStripe\SiteConfig\SiteConfig; use TeamTNT\TNTSearch\Exceptions\IndexNotFoundException; +use Werkbot\Search\Helpers\TNTSearchHelper; class SearchControllerExtension extends DataExtension { @@ -66,9 +66,9 @@ public function SiteSearchForm() /** * Process and render search results. * - * @param array $data The raw request data submitted by user + * @param array $searchdata The raw request data submitted by user * @param SiteSearchForm $form The form instance that was submitted - * @param HTTPRequest $request Request generated for this action + * @return string - Rendered search results HTML **/ public function SiteSearchFormResults($searchdata, $form) { diff --git a/src/SearchQueries/CustomeSideReport_SearchQuery.php b/src/SearchQueries/CustomSideReport_SearchQuery.php similarity index 96% rename from src/SearchQueries/CustomeSideReport_SearchQuery.php rename to src/SearchQueries/CustomSideReport_SearchQuery.php index 3346ad4..3fef4e7 100644 --- a/src/SearchQueries/CustomeSideReport_SearchQuery.php +++ b/src/SearchQueries/CustomSideReport_SearchQuery.php @@ -1,6 +1,6 @@ records($params); } - + public function columns() { $fields = [ @@ -86,8 +86,8 @@ public function columns() return $fields; } - - public function parameterFields() + + public function parameterFields() { $today = date('Y-m-d'); @@ -107,3 +107,4 @@ public function parameterFields() ); } } + diff --git a/src/SearchQueries/SearchQuery.php b/src/SearchQueries/SearchQuery.php index 98695e1..ab756c1 100644 --- a/src/SearchQueries/SearchQuery.php +++ b/src/SearchQueries/SearchQuery.php @@ -1,16 +1,17 @@ 'Text', ]; } + diff --git a/src/SearchableExtension.php b/src/SearchableExtension.php index 19aae99..d09f3df 100644 --- a/src/SearchableExtension.php +++ b/src/SearchableExtension.php @@ -2,24 +2,25 @@ namespace Werkbot\Search; -use SilverStripe\Forms\Tab; -use SilverStripe\Forms\TabSet; use SilverStripe\Core\ClassInfo; -use SilverStripe\ORM\DataObject; -use SilverStripe\Forms\FieldList; -use SilverStripe\Forms\TextField; -use SilverStripe\Forms\FieldGroup; -use SilverStripe\ORM\DataExtension; use SilverStripe\Forms\CheckboxField; -use SilverStripe\Versioned\Versioned; +use SilverStripe\Forms\FieldGroup; +use SilverStripe\Forms\FieldList; use SilverStripe\Forms\GridField\GridField; -use SilverStripe\Forms\GridField\GridFieldConfig; use SilverStripe\Forms\GridField\GridFieldButtonRow; +use SilverStripe\Forms\GridField\GridFieldConfig; use SilverStripe\Forms\GridField\GridFieldDeleteAction; use SilverStripe\Forms\GridField\GridFieldToolbarHeader; -use Symbiote\GridFieldExtensions\GridFieldOrderableRows; -use Symbiote\GridFieldExtensions\GridFieldEditableColumns; +use SilverStripe\Forms\Tab; +use SilverStripe\Forms\TabSet; +use SilverStripe\Forms\TextField; +use SilverStripe\ORM\DataExtension; +use SilverStripe\ORM\DataObject; +use SilverStripe\Versioned\Versioned; use Symbiote\GridFieldExtensions\GridFieldAddNewInlineButton; +use Symbiote\GridFieldExtensions\GridFieldEditableColumns; +use Symbiote\GridFieldExtensions\GridFieldOrderableRows; +use Werkbot\Search\Helpers\TNTSearchHelper; class SearchableExtension extends DataExtension { @@ -42,6 +43,7 @@ class SearchableExtension extends DataExtension "getSearchableTitle" => "Text", "getSearchableSummary" => 'HTMLText', ]; + /** * updateCMSFields * Adds the SearchTerms GridField to the CMS tab @@ -113,7 +115,7 @@ public function addSearchSettingFields(FieldList &$fields) * getIndexQuery * This query is used when building the index * - * @return string/boolean - FALSE if not set + * @return string|boolean - FALSE if not set * Example: SELECT concat(\"Page_\", SiteTree.ID) AS ID, @@ -148,6 +150,7 @@ public function getSearchableID() { return $this->owner->ClassName . "_" . $this->owner->ID; } + /** * getSearchableTitle * Returns the title, to be used in search results @@ -163,6 +166,7 @@ public function getSearchableTitle() return $this->owner->Title; } } + /** * getSearchableTitleColumnName * Returns the name of the Title Column, "Title" is returned if the @@ -177,6 +181,7 @@ public function getSearchableTitleColumnName() return "Title"; } } + /** * getSearchableSummary * Returns the content to be used in search results @@ -197,6 +202,7 @@ public function getSearchableSummary() return $content; } + /** * getSearchableContent * Returns the content to be used when indexing this record @@ -221,6 +227,7 @@ public function getSearchableContent() return $content; } + /** * getSearchableSummaryColumnName * Returns the name of the Summary Column, "Content" is returned if the @@ -235,6 +242,7 @@ public function getSearchableSummaryColumnName() return "Content"; } } + /** * insertIndex * @@ -255,6 +263,7 @@ public function insertIndex() 'Content' => $content, ]); } + /** * updateIndex * @@ -278,6 +287,7 @@ public function updateIndex() ] ); } + /** * deleteIndex * @@ -288,6 +298,7 @@ public function deleteIndex() $index = TNTSearchHelper::Instance()->getTNTSearchIndex(); $index->delete(ClassInfo::shortName($this->owner->ClassName) . "_" . $this->owner->ID); } + /** * onBeforeWrite * @@ -302,6 +313,7 @@ public function onBeforeWrite() } parent::onBeforeWrite(); } + /** * onAfterWrite * @@ -314,6 +326,7 @@ public function onAfterWrite() } parent::onAfterWrite(); } + /** * onBeforePublish * @@ -325,6 +338,7 @@ public function onBeforePublish() $this->owner->insertIndex(); } } + /** * onAfterPublish * @@ -334,6 +348,7 @@ public function onAfterPublish() { $this->owner->updateIndex(); } + /** * onAfterUnpublish * @@ -343,6 +358,7 @@ public function onAfterUnpublish() { $this->owner->deleteIndex(); } + /** * onAfterDelete * @@ -350,6 +366,8 @@ public function onAfterUnpublish() **/ public function onAfterDelete() { - $this->owner->deleteIndex(); + $this->owner->deleteIndex(); } + } + diff --git a/src/Tasks/SearchIndex.php b/src/Tasks/SearchIndex.php index 4e7ed21..1d8958e 100644 --- a/src/Tasks/SearchIndex.php +++ b/src/Tasks/SearchIndex.php @@ -1,11 +1,11 @@