From ed7ded38465662eabdd1b16dd9cd4008d6c5528f Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Thu, 14 May 2026 09:52:56 +0100 Subject: php-cs-fixer tidies to php8.5 standards Co-Authored-By: Claude Sonnet 4.6 --- admin/admin_search_inc.php | 1 + admin/index.php | 2 +- admin/schema_inc.php | 27 +++++++++++++-------------- cmd_line_reindex.php | 3 +-- directory_search.php | 4 ++-- icons/pkg_search.gif | Bin icons/pkg_search.png | Bin includes/bit_setup_inc.php | 7 ++++--- includes/classes/SearchLib.php | 35 ++++++++++++++++++----------------- includes/classes/SearchStatsLib.php | 1 + includes/refresh_functions.php | 3 +-- index.php | 6 +++--- modules/help_mod_global_search.tpl | 0 modules/help_mod_package_search.tpl | 0 modules/index.php | 2 +- modules/mod_ajax_search.tpl | 0 modules/mod_global_search.tpl | 0 modules/mod_package_search.php | 4 ++-- modules/mod_package_search.tpl | 0 stats.php | 6 ++---- templates/flat_mini_search.tpl | 0 templates/global_mini_search.tpl | 0 templates/index.php | 2 +- templates/menu_search.tpl | 0 templates/menu_search_admin.tpl | 0 templates/search.tpl | 0 26 files changed, 51 insertions(+), 52 deletions(-) mode change 100644 => 100755 icons/pkg_search.gif mode change 100644 => 100755 icons/pkg_search.png mode change 100644 => 100755 modules/help_mod_global_search.tpl mode change 100644 => 100755 modules/help_mod_package_search.tpl mode change 100644 => 100755 modules/mod_ajax_search.tpl mode change 100644 => 100755 modules/mod_global_search.tpl mode change 100644 => 100755 modules/mod_package_search.tpl mode change 100644 => 100755 templates/flat_mini_search.tpl mode change 100644 => 100755 templates/global_mini_search.tpl mode change 100644 => 100755 templates/menu_search.tpl mode change 100644 => 100755 templates/menu_search_admin.tpl mode change 100644 => 100755 templates/search.tpl 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 @@ " 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' => 'LGPL', ] ); // ### 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 old mode 100644 new mode 100755 diff --git a/icons/pkg_search.png b/icons/pkg_search.png old mode 100644 new mode 100755 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 @@ 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 old mode 100644 new mode 100755 diff --git a/modules/help_mod_package_search.tpl b/modules/help_mod_package_search.tpl old mode 100644 new mode 100755 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 @@ -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 old mode 100644 new mode 100755 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 old mode 100644 new mode 100755 diff --git a/templates/global_mini_search.tpl b/templates/global_mini_search.tpl old mode 100644 new mode 100755 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 @@ -