summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/admin_search_inc.php71
-rw-r--r--admin/schema_inc.php54
-rw-r--r--admin/upgrade_inc.php72
3 files changed, 63 insertions, 134 deletions
diff --git a/admin/admin_search_inc.php b/admin/admin_search_inc.php
index d383c82..5bee3c7 100644
--- a/admin/admin_search_inc.php
+++ b/admin/admin_search_inc.php
@@ -1,4 +1,6 @@
<?php
+namespace Bitweaver\Search;
+use Bitweaver\KernelTools;
// $Header$
@@ -6,63 +8,63 @@
// All Rights Reserved. See below for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
-$feedback = array();
+$feedback = [];
-$formSearchToggles = array(
- 'search_stats' => array(
+$formSearchToggles = [
+ 'search_stats' => [
'label' => 'Search Statistics',
'note' => 'Record searches made and their frequency.',
// 'page' => 'SearchStats',
- ),
- 'search_index_on_submit' => array(
+ ],
+ 'search_index_on_submit' => [
'label' => 'Index On Submit',
'note' => 'Index articles, blogs and wiki pages immdiately on submission. If unchecked, pages will be updated randomly according the the refresh rate below.',
- ),
-);
+ ],
+];
-$formSearchInts = array(
- 'search_refresh_rate' => array(
+$formSearchInts = [
+ 'search_refresh_rate' => [
'label' => 'Search Refresh Rate',
'note' => 'Varies the rate at which updates to the search index are made, 1 = every page read, while rate>1 will introduce a random chance of a refresh every "rate" pages',
- ),
- 'search_min_wordlength' => array(
+ ],
+ 'search_min_wordlength' => [
'label' => 'Minimum number of letters for search words',
'note' => 'By settings this value to 3, you can ignore search words such as "a" or "or", however searches for a number like "13" will be ignored as well.',
- ),
- 'search_max_syllwords' => array(
+ ],
+ 'search_max_syllwords' => [
'label' => 'Maximum number of words',
'note' => 'The maximum number of words containing a syllable that can be serached for in any one search.',
- ),
- 'search_syll_age' => array(
+ ],
+ 'search_syll_age' => [
'label' => 'Age in hours of search cache',
'note' => 'Define the Maximum age of cached search results for any given syllable. The results cache will be used to provide a search result if it is available, and will be cleared after either the age, or when the results cache reaches it\'s limit',
- ),
- 'search_lru_purge_rate' => array(
+ ],
+ 'search_lru_purge_rate' => [
'label' => 'Least Recently Used (LRU) list purging rate',
'note' => 'Purge the results cache every "rate" pages. This will keep space available in the cache for new search results',
- ),
- 'search_lru_length' => array(
+ ],
+ 'search_lru_length' => [
'label' => 'Least Recently Used (LRU) list length',
'note' => 'Limit the results cache to this number of entries',
- ),
-);
+ ],
+];
if( !empty( $_REQUEST['del_index'] ) ) {
- require_once( SEARCH_PKG_PATH.'/refresh_functions.php' );
+ require_once SEARCH_PKG_INCLUDE_PATH.'/refresh_functions.php';
delete_index_content_type( $_REQUEST["where"] );
- $feedback['success'] = tra( "The search index was successfully deleted." );
+ $feedback['success'] = KernelTools::tra( "The search index was successfully deleted." );
}
if( !empty( $_REQUEST['del_index_reindex'] ) ) {
- require_once( SEARCH_PKG_PATH.'/refresh_functions.php' );
+ require_once SEARCH_PKG_INCLUDE_PATH.'/refresh_functions.php';
$count = rebuild_index( $_REQUEST["where"] );
- $feedback['success'] = tra( "The search index was successfully deleted." ).tra( "Number of items re-indexed" ).": ".$count;
+ $feedback['success'] = KernelTools::tra( "The search index was successfully deleted." ).KernelTools::tra( "Number of items re-indexed" ).": ".$count;
}
if( !empty( $_REQUEST['del_searchwords'] ) ) {
- require_once( SEARCH_PKG_PATH.'/refresh_functions.php' );
+ require_once SEARCH_PKG_INCLUDE_PATH.'/refresh_functions.php';
delete_search_words_and_syllables();
- $feedback['success'] = tra( "The searchwords were successfully purged from the database." );
+ $feedback['success'] = KernelTools::tra( "The searchwords were successfully purged from the database." );
}
if( !empty( $_REQUEST['store_prefs'] ) ) {
@@ -82,12 +84,12 @@ $gBitSmarty->assign( 'formSearchToggles', $formSearchToggles );
$gBitSmarty->assign( 'formSearchInts', $formSearchInts );
$gBitSmarty->assign( 'feedback', $feedback );
-$formSearchTypeToggles = array(
- 'search_restrict_types' => array(
+$formSearchTypeToggles = [
+ 'search_restrict_types' => [
'label' => 'Restrict Types',
- 'note' => 'If selected the search will be limited to those selected below.'
- ),
-);
+ 'note' => 'If selected the search will be limited to those selected below.',
+ ],
+];
$gBitSmarty->assign( 'formSearchTypeToggles', $formSearchTypeToggles );
// allow selection of what packages can have search
@@ -100,7 +102,7 @@ if( !empty( $_REQUEST['store_content'] ) ) {
simple_set_toggle( $item, SEARCH_PKG_NAME );
}
foreach( array_keys( $formSearchable['guids'] ) as $searchable ) {
- $gBitSystem->storeConfig( $searchable, ( ( !empty( $_REQUEST['searchable_content'] ) && in_array( $searchable, $_REQUEST['searchable_content'] ) ) ? 'y' : NULL ), SEARCH_PKG_NAME );
+ $gBitSystem->storeConfig( $searchable, !empty( $_REQUEST['searchable_content'] ) && in_array( $searchable, $_REQUEST['searchable_content'] ) ? 'y' : null, SEARCH_PKG_NAME );
}
}
@@ -115,7 +117,7 @@ $gBitSmarty->assign( 'formSearchable', $formSearchable );
/* usually done in mod_package_search.php - but the module can be not here the first time */
if( empty( $contentTypes ) ) {
- $contentTypes = array( '' => tra( 'All Content' ) );
+ $contentTypes = [ '' => KernelTools::tra( 'All Content' ) ];
foreach( $gLibertySystem->mContentTypes as $cType ) {
if( $gBitSystem->getConfig( 'search_pkg_'.$cType['content_type_guid']) ) {
$contentTypes[$cType['content_type_guid']] = $gLibertySystem->getContentTypeName( $cType['content_type_guid'] );
@@ -123,4 +125,3 @@ if( empty( $contentTypes ) ) {
}
$gBitSmarty->assign( 'contentTypes', $contentTypes );
}
-?>
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index 8d26111..55a4522 100644
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -1,6 +1,6 @@
<?php
-$tables = array(
+$tables = [
'search_index' => "
searchword C(80) PRIMARY,
@@ -25,7 +25,7 @@ $tables = array(
hits I4
"
-) ;
+] ;
global $gBitInstaller;
@@ -34,44 +34,44 @@ foreach( array_keys( $tables ) AS $tableName ) {
$gBitInstaller->registerSchemaTable( SEARCH_PKG_NAME, $tableName, $tables[$tableName] );
}
-$indices = array (
- 'searchidx_last_update_idx' => array( 'table' => 'search_index', 'cols' => 'last_update', 'opts' => NULL ),
- 'searchidx_word_idx' => array( 'table' => 'search_index', 'cols' => 'searchword', 'opts' => NULL ),
- 'searchidx_con_idx' => array( 'table' => 'search_index', 'cols' => 'content_id', 'opts' => NULL ),
- 'searchsyl_last_used_idx' => array( 'table' => 'search_syllable', 'cols' => 'last_used', 'opts' => NULL )
-);
+$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 ]
+];
$gBitInstaller->registerSchemaIndexes( SEARCH_PKG_NAME, $indices );
-$gBitInstaller->registerPackageInfo( SEARCH_PKG_NAME, array(
+$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
-// array(SEARCH_PKG_NAME, 'search_fulltext','y'),
-$gBitInstaller->registerPreferences( SEARCH_PKG_NAME, array(
- array(SEARCH_PKG_NAME, 'search_stats','n'),
- array(SEARCH_PKG_NAME, 'search_index_on_submit','n'),
- array(SEARCH_PKG_NAME, 'search_refresh_rate','5'),
- array(SEARCH_PKG_NAME, 'search_min_wordlength','3'),
- array(SEARCH_PKG_NAME, 'search_max_syllwords','100'),
- array(SEARCH_PKG_NAME, 'search_lru_purge_rate','5'),
- array(SEARCH_PKG_NAME, 'search_lru_length','100'),
- array(SEARCH_PKG_NAME, 'search_syll_age','48')
-) );
+// [ SEARCH_PKG_NAME, 'search_fulltext','y' ],
+$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' ],
+ [ SEARCH_PKG_NAME, 'search_min_wordlength','3' ],
+ [ 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' ]
+] );
-$moduleHash = array(
- 'mod_package_search' => array(
+$moduleHash = [
+ 'mod_package_search' => [
'title' => 'Search',
'ord' => 3,
'pos' => 'r',
'module_rsrc' => 'bitpackage:search/mod_package_search.tpl'
-) );
+] ];
$gBitInstaller->registerModules( $moduleHash );
// Requirements
-$gBitInstaller->registerRequirements( SEARCH_PKG_NAME, array(
- 'liberty' => array( 'min' => '2.1.4' ),
-));
+$gBitInstaller->registerRequirements( SEARCH_PKG_NAME, [
+ 'liberty' => [ 'min' => '5.0.0' ],
+] );
diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php
deleted file mode 100644
index 3ceef25..0000000
--- a/admin/upgrade_inc.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-global $gBitSystem, $gUpgradeFrom, $gUpgradeTo;
-
-$upgrades = array(
-
-'BWR1' => array(
- 'BWR2' => array(
-array( 'DATADICT' => array(
- array( 'RENAMETABLE' => array(
- 'tiki_searchindex' => 'search_index',
- 'tiki_searchsyllable' => 'search_syllable',
- 'tiki_search_stats' => 'search_stats',
- 'tiki_searchwords' => 'search_words',
- )),
- array( 'RENAMECOLUMN' => array(
- 'search_index' => array( '`count`' => '`i_count` I4' ),
- )),
- array( 'DROPCOLUMN' => array(
- 'search_index' => array( '`location`' ),
- )),
-)),
- )
-),
-
-'BONNIE' => array(
- 'BWR1' => array(
-// STEP 1 - Data is transient, so let's recreate the table with proper multi-column keys
-array( 'DATADICT' => array(
- array( 'DROPTABLE' => array(
- 'tiki_searchindex'
- )),
- array( 'CREATE' => array (
- 'tiki_searchindex' => "
- searchword C(80) PRIMARY,
- location C(80) PRIMARY,
- content_id I4 PRIMARY,
- count I4 NOTNULL default '1',
- last_update I4 NOTNULL
- ",
- )),
-)),
-
-// STEP 2
-array( 'DATADICT' => array(
- array( 'RENAMECOLUMN' => array(
- 'tiki_searchsyllable' => array( '`lastUsed`' => '`last_used` I8',
- '`lastUpdated`' => '`last_updated` I8' ),
- )),
-)),
-
-// STEP 3
-array( 'DATADICT' => array(
- array( 'CREATEINDEX' => array(
- 'tiki_searchidx_con_id_idx' => array( 'tiki_searchindex', '`content_id`', array() ),
- 'tiki_searchidx_word_idx' => array( 'tiki_searchindex', '`searchword`', array() ),
- 'tiki_searchidx_loc_idx' => array( 'tiki_searchindex', '`location`', array() ),
- 'tiki_searchidx_update_idx' => array( 'tiki_searchindex', '`last_update`', array() ),
- )),
-)),
-
- )
-)
-
-);
-
-if( isset( $upgrades[$gUpgradeFrom][$gUpgradeTo] ) ) {
- $gBitSystem->registerUpgrade( SEARCH_PKG_NAME, $upgrades[$gUpgradeFrom][$gUpgradeTo] );
-}
-
-
-?>