summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-14 09:52:56 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-14 09:52:56 +0100
commited7ded38465662eabdd1b16dd9cd4008d6c5528f (patch)
tree7c3ebe7246ac47f6b7bbca3419f22be3718892f6
parent758faa3c26c4756874616e87e0433691e8393b6e (diff)
downloadsearch-ed7ded38465662eabdd1b16dd9cd4008d6c5528f.tar.gz
search-ed7ded38465662eabdd1b16dd9cd4008d6c5528f.tar.bz2
search-ed7ded38465662eabdd1b16dd9cd4008d6c5528f.zip
php-cs-fixer tidies to php8.5 standards
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--admin/admin_search_inc.php1
-rw-r--r--admin/index.php2
-rw-r--r--admin/schema_inc.php27
-rwxr-xr-xcmd_line_reindex.php3
-rw-r--r--directory_search.php4
-rwxr-xr-x[-rw-r--r--]icons/pkg_search.gifbin1997 -> 1997 bytes
-rwxr-xr-x[-rw-r--r--]icons/pkg_search.pngbin3253 -> 3253 bytes
-rwxr-xr-xincludes/bit_setup_inc.php7
-rwxr-xr-xincludes/classes/SearchLib.php35
-rwxr-xr-xincludes/classes/SearchStatsLib.php1
-rwxr-xr-xincludes/refresh_functions.php3
-rw-r--r--index.php6
-rwxr-xr-x[-rw-r--r--]modules/help_mod_global_search.tpl0
-rwxr-xr-x[-rw-r--r--]modules/help_mod_package_search.tpl0
-rw-r--r--modules/index.php2
-rwxr-xr-x[-rw-r--r--]modules/mod_ajax_search.tpl0
-rwxr-xr-x[-rw-r--r--]modules/mod_global_search.tpl0
-rw-r--r--modules/mod_package_search.php4
-rwxr-xr-x[-rw-r--r--]modules/mod_package_search.tpl0
-rwxr-xr-xstats.php6
-rwxr-xr-x[-rw-r--r--]templates/flat_mini_search.tpl0
-rwxr-xr-x[-rw-r--r--]templates/global_mini_search.tpl0
-rw-r--r--templates/index.php2
-rwxr-xr-x[-rw-r--r--]templates/menu_search.tpl0
-rwxr-xr-x[-rw-r--r--]templates/menu_search_admin.tpl0
-rwxr-xr-x[-rw-r--r--]templates/search.tpl0
26 files changed, 51 insertions, 52 deletions
diff --git a/admin/admin_search_inc.php b/admin/admin_search_inc.php
index 4db321e..b290efa 100644
--- a/admin/admin_search_inc.php
+++ b/admin/admin_search_inc.php
@@ -1,5 +1,6 @@
<?php
namespace Bitweaver\Search;
+
use Bitweaver\KernelTools;
// $Header$
diff --git a/admin/index.php b/admin/index.php
index 3e305fe..c0437d0 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -1,4 +1,4 @@
-<?php
+<?php
// This is not a package.
header ("location: ../index.php");
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index 55a4522..60ece95 100644
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -1,6 +1,6 @@
<?php
-$tables = [
+$tables = [
'search_index' => "
searchword C(80) PRIMARY,
@@ -23,34 +23,33 @@ $tables = [
'search_stats' => "
term C(50) PRIMARY,
hits I4
-"
+",
] ;
-
global $gBitInstaller;
foreach( array_keys( $tables ) AS $tableName ) {
$gBitInstaller->registerSchemaTable( SEARCH_PKG_NAME, $tableName, $tables[$tableName] );
}
-$indices = [
+$indices = [
'searchidx_last_update_idx' => [ 'table' => 'search_index', 'cols' => 'last_update', 'opts' => null ],
'searchidx_word_idx' => [ 'table' => 'search_index', 'cols' => 'searchword', 'opts' => null ],
'searchidx_con_idx' => [ 'table' => 'search_index', 'cols' => 'content_id', 'opts' => null ],
- 'searchsyl_last_used_idx' => [ 'table' => 'search_syllable', 'cols' => 'last_used', 'opts' => null ]
+ 'searchsyl_last_used_idx' => [ 'table' => 'search_syllable', 'cols' => 'last_used', 'opts' => null ],
];
$gBitInstaller->registerSchemaIndexes( SEARCH_PKG_NAME, $indices );
-$gBitInstaller->registerPackageInfo( SEARCH_PKG_NAME, [
+$gBitInstaller->registerPackageInfo( SEARCH_PKG_NAME, [
'description' => "This package makes any content on your site searchable.",
'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
] );
// ### Default Preferences
// [ SEARCH_PKG_NAME, 'search_fulltext','y' ],
-$gBitInstaller->registerPreferences( SEARCH_PKG_NAME, [
+$gBitInstaller->registerPreferences( SEARCH_PKG_NAME, [
[ SEARCH_PKG_NAME, 'search_stats','n' ],
[ SEARCH_PKG_NAME, 'search_index_on_submit','n' ],
[ SEARCH_PKG_NAME, 'search_refresh_rate','5' ],
@@ -58,20 +57,20 @@ $gBitInstaller->registerPreferences( SEARCH_PKG_NAME, [
[ SEARCH_PKG_NAME, 'search_max_syllwords','100' ],
[ SEARCH_PKG_NAME, 'search_lru_purge_rate','5' ],
[ SEARCH_PKG_NAME, 'search_lru_length','100' ],
- [ SEARCH_PKG_NAME, 'search_syll_age','48' ]
+ [ SEARCH_PKG_NAME, 'search_syll_age','48' ],
] );
-$moduleHash = [
- 'mod_package_search' => [
+$moduleHash = [
+ 'mod_package_search' => [
'title' => 'Search',
'ord' => 3,
'pos' => 'r',
- 'module_rsrc' => 'bitpackage:search/mod_package_search.tpl'
-] ];
+ 'module_rsrc' => 'bitpackage:search/mod_package_search.tpl',
+], ];
$gBitInstaller->registerModules( $moduleHash );
// Requirements
-$gBitInstaller->registerRequirements( SEARCH_PKG_NAME, [
- 'liberty' => [ 'min' => '5.0.0' ],
+$gBitInstaller->registerRequirements( SEARCH_PKG_NAME, [
+ 'liberty' => [ 'min' => '5.0.0' ],
] );
diff --git a/cmd_line_reindex.php b/cmd_line_reindex.php
index 887abd8..882f476 100755
--- a/cmd_line_reindex.php
+++ b/cmd_line_reindex.php
@@ -36,7 +36,7 @@
/**
* Define Server Variables so script won't puke on command line
- */
+ */
$_SERVER['SERVER_NAME'] = 'batch';
$_SERVER['HTTP_HOST'] = 'batch';
$_SERVER['HTTP_USER_AGENT'] = 'batch';
@@ -45,7 +45,6 @@ $_SERVER['SERVER_SOFTWARE'] = 'batch';
$_SERVER['HTTP_USER_AGENT'] = 'batch';
require_once '../kernel/includes/setup_inc.php';
-use Bitweaver\Liberty\LibertyBase;
require_once 'includes/refresh_functions.php';
$whatToIndex = "pages";
diff --git a/directory_search.php b/directory_search.php
index 19f2b88..e19bcf4 100644
--- a/directory_search.php
+++ b/directory_search.php
@@ -13,7 +13,7 @@
* @package search
* @subpackage functions
*/
-
+
/**
* required setup
*/
@@ -67,4 +67,4 @@ $gBitSmarty->assign('items', $items["data"]);
$section = 'directory';
// Display the template
-$gBitSystem->display( 'bitpackage:search/directory_search.tpl', null, array( 'display_mode' => 'display' ));
+$gBitSystem->display( 'bitpackage:search/directory_search.tpl', null, [ 'display_mode' => 'display' ]);
diff --git a/icons/pkg_search.gif b/icons/pkg_search.gif
index 2dbc316..2dbc316 100644..100755
--- a/icons/pkg_search.gif
+++ b/icons/pkg_search.gif
Binary files differ
diff --git a/icons/pkg_search.png b/icons/pkg_search.png
index 47c3c3c..47c3c3c 100644..100755
--- a/icons/pkg_search.png
+++ b/icons/pkg_search.png
Binary files differ
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
index ae4cfed..2c8ad5e 100755
--- a/includes/bit_setup_inc.php
+++ b/includes/bit_setup_inc.php
@@ -1,5 +1,6 @@
<?php
namespace Bitweaver\Search;
+
global $gBitSystem, $gLibertySystem ;
$pRegisterHash = [
@@ -12,9 +13,9 @@ $pRegisterHash = [
define( 'SEARCH_PKG_NAME', $pRegisterHash['package_name'] );
define( 'SEARCH_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' );
define( 'SEARCH_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' );
-define( 'SEARCH_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/');
+define( 'SEARCH_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/');
define( 'SEARCH_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/');
-define( 'SEARCH_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/');
+define( 'SEARCH_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/');
$gBitSystem->registerPackage( $pRegisterHash );
@@ -35,5 +36,5 @@ if( $gBitSystem->isPackageActive( 'search' ) ) {
}
include_once SEARCH_PKG_INCLUDE_PATH . 'refresh_functions.php';
$gLibertySystem->registerService( LIBERTY_SERVICE_SEARCH, SEARCH_PKG_NAME,
- [ 'content_store_function' => 'refresh_index'] );
+ [ 'content_store_function' => 'refresh_index'], );
} \ No newline at end of file
diff --git a/includes/classes/SearchLib.php b/includes/classes/SearchLib.php
index 024d340..f43a9eb 100755
--- a/includes/classes/SearchLib.php
+++ b/includes/classes/SearchLib.php
@@ -18,6 +18,7 @@
*/
namespace Bitweaver\Search;
+
use Bitweaver\BitBase;
use Bitweaver\Liberty\LibertyBase;
@@ -37,7 +38,7 @@ class SearchLib extends BitBase {
foreach ($words as $word) {
$word = trim($word);
$cant = $this->mDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX .
- "search_stats` WHERE `term`=?", [ $word ]);
+ "search_stats` WHERE `term`=?", [ $word ], );
$query = $cant
? "UPDATE `" . BIT_DB_PREFIX . "search_stats` SET `hits`= `hits` + 1 WHERE `term`=?"
: "INSERT INTO `" . BIT_DB_PREFIX . "search_stats` (`term`,`hits`) VALUES (?,1)";
@@ -70,7 +71,7 @@ class SearchLib extends BitBase {
$bindvars = [ $syllable ];
$age = time() - $this->mDb->getOne(
"select `last_updated` from `" . BIT_DB_PREFIX . "search_syllable` where `syllable`=?",
- $bindvars);
+ $bindvars, );
if(!$age || $age > ($search_syll_age * 3600)) {// older than search_syll_age hours
$a = $this->refresh_lru_wordlist($syllable);
}
@@ -81,7 +82,7 @@ class SearchLib extends BitBase {
// update lru last used value (Used to purge oldest last used records)
$now = time();
$this->mDb->query("update `" . BIT_DB_PREFIX . "search_syllable` set `last_used`=? where `syllable`=?",
- [ (int) $now, $syllable ]);
+ [ (int) $now, $syllable ], );
}
return $ret;
}
@@ -89,14 +90,14 @@ class SearchLib extends BitBase {
public function get_lru_wordlist($syllable) {
$ret = [];
if(!isset($this->wordlist_cache[$syllable])) {
- $query = "select `searchword` from `" . BIT_DB_PREFIX . "search_words` where `syllable`=?";
- $result = $this->mDb->query($query, [ $syllable ]);
- if ($result->RecordCount() > 0) {
- while ($res = $result->fetchRow()) {
- $this->wordlist_cache[$syllable][]=$res["searchword"];
- }
- $ret = $this->wordlist_cache[$syllable];
- }
+ $query = "select `searchword` from `" . BIT_DB_PREFIX . "search_words` where `syllable`=?";
+ $result = $this->mDb->query($query, [ $syllable ]);
+ if ($result->RecordCount() > 0) {
+ while ($res = $result->fetchRow()) {
+ $this->wordlist_cache[$syllable][]=$res["searchword"];
+ }
+ $ret = $this->wordlist_cache[$syllable];
+ }
}
return $ret;
}
@@ -124,13 +125,13 @@ class SearchLib extends BitBase {
foreach($ret as $searchword) {
$this->mDb->query("INSERT INTO `" . BIT_DB_PREFIX .
"search_words` (`syllable`,`searchword`) VALUES (?,?)",
- [ $syllable, $searchword ], -1, -1);
+ [ $syllable, $searchword ], -1, -1, );
}
// set lru list parameters
$now = time();
$this->mDb->query("INSERT INTO `" . BIT_DB_PREFIX .
"search_syllable`(`syllable`,`last_used`,`last_updated`) values (?,?,?)",
- [ $syllable, (int) $now, (int) $now ]);
+ [ $syllable, (int) $now, (int) $now ], );
// at random rate: check length of lru list and purge these that
// have not been used for long time. This is what a lru list
@@ -139,7 +140,7 @@ class SearchLib extends BitBase {
srand (ceil($sec + 100 * $usec));
if(rand(1, $search_lru_purge_rate) == 1) {
$lrulength = $this->mDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX .
- "search_syllable`", []);
+ "search_syllable`", [], );
if ($lrulength > $search_lru_length) { // only purge if lru list is too long.
//purge oldest
$oldwords = [];
@@ -151,9 +152,9 @@ class SearchLib extends BitBase {
}
foreach($oldwords as $oldword) {
$this->mDb->query("delete from `" . BIT_DB_PREFIX .
- "search_words` where `syllable`=?", [ $oldword ], -1, -1);
+ "search_words` where `syllable`=?", [ $oldword ], -1, -1, );
$this->mDb->query("delete from `" . BIT_DB_PREFIX .
- "search_syllable` where `syllable`=?", [ $oldword ], -1, -1);
+ "search_syllable` where `syllable`=?", [ $oldword ], -1, -1, );
}
}
@@ -297,7 +298,7 @@ class SearchLib extends BitBase {
$pParamHash['cant'] = 0;
$ret = [];
}
- return $ret;
+ return $ret;
}
public function mergeResults(&$ret, $result) {
diff --git a/includes/classes/SearchStatsLib.php b/includes/classes/SearchStatsLib.php
index f38f030..14a207a 100755
--- a/includes/classes/SearchStatsLib.php
+++ b/includes/classes/SearchStatsLib.php
@@ -14,6 +14,7 @@
*/
namespace Bitweaver\Search;
+
use Bitweaver\BitBase;
/**
diff --git a/includes/refresh_functions.php b/includes/refresh_functions.php
index 3f62674..5cfa144 100755
--- a/includes/refresh_functions.php
+++ b/includes/refresh_functions.php
@@ -22,7 +22,6 @@
* and pass it to refresh_index() to do the work.
*/
namespace Bitweaver\Liberty;
-use Bitweaver\Liberty\rebuild_index;
function random_refresh_index($pContentType = "") {
global $gBitSystem;
@@ -90,7 +89,7 @@ function refresh_index( $pContentObject = null ) {
function refresh_index_oldest(){
global $gBitSystem;
$contentId = $gBitSystem->mDb->getOne("SELECT `content_id` FROM `" . BIT_DB_PREFIX .
- "search_index` ORDER BY `last_update`", []);
+ "search_index` ORDER BY `last_update`", [], );
if ( isset($contentId) ) {
refresh_index($contentId);
}
diff --git a/index.php b/index.php
index eb384bf..1249122 100644
--- a/index.php
+++ b/index.php
@@ -43,7 +43,7 @@ if( !empty($_REQUEST["highlight"]) ) {
}
if ($gBitSystem->isFeatureActive("search_stats")) {
- $searchlib->register_search(isset($_REQUEST["words"]) ? $_REQUEST["words"] : '');
+ $searchlib->register_search($_REQUEST["words"] ?? '');
}
if (!isset($_REQUEST["content_type_guid"])) {
@@ -68,7 +68,7 @@ $_REQUEST["words"] = !isset($_REQUEST["words"]) || (empty($_REQUEST["words"])) ?
$gBitSmarty->assign('words', $_REQUEST["words"]);
$results = $searchlib->find( $_REQUEST );
-if ($_REQUEST['cant'] <> 1) $where2 .= "s";
+if ($_REQUEST['cant'] <> 1) $where2 .= "s";
$gBitSmarty->assign('where2', KernelTools::tra($where2));
$gBitSmarty->assign('content_type_guid', $_REQUEST["content_type_guid"]);
@@ -95,4 +95,4 @@ $gBitSmarty->assign( 'listInfo', $_REQUEST['listInfo'] );
$gBitSmarty->assign('results', $results);
// Display the template
-$gBitSystem->display( 'bitpackage:search/search.tpl', 'Search Results for: '.strip_tags($_REQUEST["highlight"]), array( 'display_mode' => 'display' ));
+$gBitSystem->display( 'bitpackage:search/search.tpl', 'Search Results for: '.strip_tags($_REQUEST["highlight"]), [ 'display_mode' => 'display' ]);
diff --git a/modules/help_mod_global_search.tpl b/modules/help_mod_global_search.tpl
index 9e6db5d..9e6db5d 100644..100755
--- a/modules/help_mod_global_search.tpl
+++ b/modules/help_mod_global_search.tpl
diff --git a/modules/help_mod_package_search.tpl b/modules/help_mod_package_search.tpl
index 9e6db5d..9e6db5d 100644..100755
--- a/modules/help_mod_package_search.tpl
+++ b/modules/help_mod_package_search.tpl
diff --git a/modules/index.php b/modules/index.php
index 3e305fe..c0437d0 100644
--- a/modules/index.php
+++ b/modules/index.php
@@ -1,4 +1,4 @@
-<?php
+<?php
// This is not a package.
header ("location: ../index.php");
diff --git a/modules/mod_ajax_search.tpl b/modules/mod_ajax_search.tpl
index 5ab1a4b..5ab1a4b 100644..100755
--- a/modules/mod_ajax_search.tpl
+++ b/modules/mod_ajax_search.tpl
diff --git a/modules/mod_global_search.tpl b/modules/mod_global_search.tpl
index 15a7659..15a7659 100644..100755
--- a/modules/mod_global_search.tpl
+++ b/modules/mod_global_search.tpl
diff --git a/modules/mod_package_search.php b/modules/mod_package_search.php
index 925fc66..7508c23 100644
--- a/modules/mod_package_search.php
+++ b/modules/mod_package_search.php
@@ -21,10 +21,10 @@ use Bitweaver\KernelTools;
* Initialization
*/
global $gBitSystem, $gLibertySystem;
-
+
$tplName = $gBitSystem->getActivePackage().'_mini_search.tpl';
$searchTemplatePath = BIT_ROOT_URL.constant( strtoupper( $gBitSystem->getActivePackage() ).'_PKG_PATH' ).'templates/'.$tplName;
-
+
if( file_exists( $searchTemplatePath ) ) {
$searchTemplateRsrc = 'bitpackage:'.$gBitSystem->getActivePackage().'/'.$tplName;
$searchTitle = ucfirst( $gBitSystem->getActivePackage() );
diff --git a/modules/mod_package_search.tpl b/modules/mod_package_search.tpl
index ab0c498..ab0c498 100644..100755
--- a/modules/mod_package_search.tpl
+++ b/modules/mod_package_search.tpl
diff --git a/stats.php b/stats.php
index 9903af9..f4d24bb 100755
--- a/stats.php
+++ b/stats.php
@@ -13,7 +13,7 @@
* @package search
* @subpackage functions
*/
-
+
/**
* requires setup
*/
@@ -65,7 +65,5 @@ if ($offset > 0) {
$gBitSmarty->assign('channels', $channels["data"]);
-
-
// Display the template
-$gBitSystem->display( 'bitpackage:stats/search_stats.tpl', null, array( 'display_mode' => 'display' ));
+$gBitSystem->display( 'bitpackage:stats/search_stats.tpl', null, [ 'display_mode' => 'display' ]);
diff --git a/templates/flat_mini_search.tpl b/templates/flat_mini_search.tpl
index 85a7613..85a7613 100644..100755
--- a/templates/flat_mini_search.tpl
+++ b/templates/flat_mini_search.tpl
diff --git a/templates/global_mini_search.tpl b/templates/global_mini_search.tpl
index f97a02b..f97a02b 100644..100755
--- a/templates/global_mini_search.tpl
+++ b/templates/global_mini_search.tpl
diff --git a/templates/index.php b/templates/index.php
index 3e305fe..c0437d0 100644
--- a/templates/index.php
+++ b/templates/index.php
@@ -1,4 +1,4 @@
-<?php
+<?php
// This is not a package.
header ("location: ../index.php");
diff --git a/templates/menu_search.tpl b/templates/menu_search.tpl
index 0ebf979..0ebf979 100644..100755
--- a/templates/menu_search.tpl
+++ b/templates/menu_search.tpl
diff --git a/templates/menu_search_admin.tpl b/templates/menu_search_admin.tpl
index fab8fbb..fab8fbb 100644..100755
--- a/templates/menu_search_admin.tpl
+++ b/templates/menu_search_admin.tpl
diff --git a/templates/search.tpl b/templates/search.tpl
index ddfdc03..ddfdc03 100644..100755
--- a/templates/search.tpl
+++ b/templates/search.tpl