Skip to content

Commit

Permalink
indexColumn Lösch-Logik geändert, damit DB nicht ständig wächst, func…
Browse files Browse the repository at this point in the history
…tion setCI durch setCaseInsensitive ersetzt, EP SLICE_ADDED war nooch nicht registriert
  • Loading branch information
tyrant88 committed Sep 28, 2016
1 parent 29e3f59 commit 87b76b2
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 82 deletions.
6 changes: 5 additions & 1 deletion boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@
'CAT_UPDATED',
'MEDIA_ADDED',
'MEDIA_UPDATED',
'SLICE_ADDED',
'SLICE_DELETED',
'SLICE_UPDATED',
'SLICE_SHOW',
);
search_it_register_extensions($extensionPoints);
foreach($extensionPoints as $ep){
rex_extension::register($ep, 'search_it_handle_extensionpoint');
}
}

//set default Values on installation
Expand Down
22 changes: 2 additions & 20 deletions functions/functions_search_it.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function search_it_getArticles($cats = false) {
return $return;
}


function search_it_getCategories($_ignoreoffline = true, $_onlyIDs = false, $_cats = false) {
$si = rex_addon::get('search_it');

Expand Down Expand Up @@ -88,7 +87,6 @@ function search_it_getCategories($_ignoreoffline = true, $_onlyIDs = false, $_ca
return $return;
}


function search_it_getDirs($_startDir = '', $_getSubdirs = false){
$si = rex_addon::get('search_it');

Expand Down Expand Up @@ -128,7 +126,6 @@ function search_it_getDirs($_startDir = '', $_getSubdirs = false){
return $return;
}


function search_it_getFiles($_startDir = '', $_fileexts = array(), $_getSubdirs = false){
$si = rex_addon::get('search_it');

Expand Down Expand Up @@ -183,12 +180,6 @@ function search_it_getFiles($_startDir = '', $_fileexts = array(), $_getSubdirs
}


function search_it_register_extensions($_Aep){
foreach($_Aep as $ep){
rex_extension::register($ep, 'search_it_handle_extensionpoint');
}
}


function search_it_handle_extensionpoint($_ep){
$si = rex_addon::get('search_it');
Expand All @@ -206,6 +197,7 @@ function search_it_handle_extensionpoint($_ep){
// update meta-infos for article
case 'ART_META_UPDATED':
case 'ART_ADDED':
case 'ART_UPDATED':
foreach($search_it->includeColumns as $table => $columnArray){
if($table == $search_it->tablePrefix.'article'){
foreach($columnArray as $column) {
Expand Down Expand Up @@ -233,16 +225,6 @@ function search_it_handle_extensionpoint($_ep){
break;


case 'ART_UPDATED':
foreach($search_it->includeColumns as $table => $columnArray){
if($table == $search_it->tablePrefix.'article'){
foreach($columnArray as $column) {
$search_it->indexColumn($table, $column, 'id', $_params['id']);
}
}
}
break;

case 'CAT_DELETED':
//echo rex_view::warning(rex_i18n::rawMsg('search_it_cat_deleted'));
break;
Expand Down Expand Up @@ -281,7 +263,7 @@ function search_it_handle_extensionpoint($_ep){
case 'MEDIA_ADDED':
foreach($search_it->includeColumns as $table => $columnArray){
if($table == $search_it->tablePrefix.'media'){
foreach($columnArray as $column) {
foreach($columnArray as $column) {$tex[] = $table.$column;
$search_it->indexColumn($table, $column);
}
}
Expand Down
82 changes: 33 additions & 49 deletions lib/search_it.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function __construct($_clang = false, $_loadSettings = true, $_useStopwords = tr
$this->setSearchMode(rex_addon::get('search_it')->getConfig('searchmode'));
$this->setSurroundTags(rex_addon::get('search_it')->getConfig('surroundtags'));
$this->setLimit(rex_addon::get('search_it')->getConfig('limit'));
$this->setCI(rex_addon::get('search_it')->getConfig('ci'));
$this->setCaseInsensitive(rex_addon::get('search_it')->getConfig('ci'));
$this->setBlacklist(is_array(rex_addon::get('search_it')->getConfig('blacklist')) ? rex_addon::get('search_it')->getConfig('blacklist') : array() );
$this->setExcludeIDs(is_array(rex_addon::get('search_it')->getConfig('exclude_article_ids')) ? rex_addon::get('search_it')->getConfig('exclude_article_ids') : array() );
if(is_array(rex_addon::get('search_it')->getConfig('exclude_category_ids'))){
Expand Down Expand Up @@ -112,7 +112,6 @@ function __construct($_clang = false, $_loadSettings = true, $_useStopwords = tr
$this->documentRoot = realpath($_SERVER['DOCUMENT_ROOT']);
$this->mediaFolder = rex_path::media();


$this->ellipsis = rex_i18n::msg('search_it_ellipsis');

// german stopwords
Expand Down Expand Up @@ -200,25 +199,6 @@ function setSearchInIDs($_searchInIDs, $_reset = false){
}


/**
* Sets the maximum count of letters the teaser of a searched through text may have.
*
* @param int $_count
*/
function setMaxTeaserChars($_count){
$this->maxTeaserChars = intval($_count);
$this->hashMe .= $_count;
}


/**
* Sets the maximum count of letters around an found search term in the highlighted text.
* @param int $_count
*/
function setMaxHighlightedTextChars($_count){
$this->maxHighlightedTextChars = intval($_count);
$this->hashMe .= $_count;
}

/**
* Generates the full index at once.
Expand Down Expand Up @@ -426,8 +406,10 @@ function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_start =
$delete = rex_sql::factory();

$where = sprintf(" `ftable` = '%s' AND `fcolumn` = '%s' AND `texttype` = 'db_column'",$_table,$_column);
//if(is_string($_idcol) AND ($_id !== false))
//$where .= sprintf(' AND fid = %d',$_id);
//lus: reaktiviert damit einzeln gelöscht werden kann
if(is_string($_idcol) AND ($_id !== false)) {
$where .= sprintf(' AND fid = %d', $_id);
}

// delete from cache
$select = rex_sql::factory();
Expand All @@ -441,8 +423,8 @@ function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_start =
$this->deleteCache($indexIds);
}

// delete old data
if($_start === 0){
// delete old data + lus: immer alle löschen
if( $_start === 0 || $_start === false || (is_string($_idcol) AND ($_id !== false)) ){
$delete->setTable($this->tablePrefix.'search_it_index');
$delete->setWhere($where);
$delete->delete();
Expand All @@ -464,7 +446,8 @@ function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_start =
$where .= sprintf(' AND (%s = %d)', $_idcol, $_id);
}
if(!empty($_where) AND is_string($_where)) {
$where .= ' AND (' . $_where . ')';
// lus: sorry,muss ale neu schreiben, weil ich oben alle lösche
//$where .= ' AND (' . $_where . ')';
}

if(is_numeric($_start) AND is_numeric($_count)) {
Expand Down Expand Up @@ -823,6 +806,26 @@ function deleteIndex(){
}


/**
* Sets the maximum count of letters the teaser of a searched through text may have.
*
* @param int $_count
*/
function setMaxTeaserChars($_count){
$this->maxTeaserChars = intval($_count);
$this->hashMe .= $_count;
}


/**
* Sets the maximum count of letters around an found search term in the highlighted text.
* @param int $_count
*/
function setMaxHighlightedTextChars($_count){
$this->maxHighlightedTextChars = intval($_count);
$this->hashMe .= $_count;
}

/**
* Sets the surround-tags for found keywords.
*
Expand Down Expand Up @@ -987,7 +990,6 @@ function setLogicalMode($_logicalMode){
return true;
}


/**
* Sets the mode concerning which text is to be searched through.
*
Expand Down Expand Up @@ -1028,7 +1030,6 @@ function setTextMode($_textMode){
return true;
}


/**
* Sets the MySQL search mode.
*
Expand All @@ -1054,7 +1055,6 @@ function setSearchMode($_searchMode){
return true;
}


/**
* Sets the sort order of the results.
*
Expand Down Expand Up @@ -1092,7 +1092,6 @@ function setOrder($_order){
return true;
}


/**
* Sets the type of the text with the highlighted keywords.
*
Expand Down Expand Up @@ -1120,7 +1119,6 @@ function setHighlightType($_type){
$this->hashMe .= $this->highlightType;
}


/**
* Converts the search string to an array.
*
Expand Down Expand Up @@ -1196,7 +1194,6 @@ function addWhitelist($_whitelist){
}
}


/**
* Case sensitive or case insensitive?
*
Expand All @@ -1205,22 +1202,9 @@ function addWhitelist($_whitelist){
* @ignore
*/
function setCaseInsensitive($_ci = true){
setCI($_ci);
}


/**
* Case sensitive or case insensitive?
*
* @param bool $_ci
*
* @ignore
*/
function setCI($_ci = true){
$this->ci = (bool) $_ci;
}


/**
* Sets the language-Id.
*
Expand All @@ -1239,6 +1223,7 @@ function setClang($_clang){
}



/**
* Strips the HTML-Tags from a text and replaces them with spaces or line breaks
*
Expand Down Expand Up @@ -1455,6 +1440,7 @@ function getTeaserText($_text){
}



/**
* Returns if a search term is already cached.
* The cached result will be stored in $this->cachedArray.
Expand All @@ -1477,7 +1463,6 @@ function isCached($_search){
return false;
}


/**
* Calculates the cache hash.
*
Expand All @@ -1489,7 +1474,6 @@ function cacheHash($_searchString){
return md5($_searchString.$this->hashMe);
}


/**
* Stores a search result in the cache.
*
Expand Down Expand Up @@ -1537,7 +1521,6 @@ function cacheSearch($_result, $_indexIds){
}
}


/**
* Truncates the cache or deletes all data that are concerned with the given index-ids.
*
Expand Down Expand Up @@ -1591,6 +1574,7 @@ function deleteCache($_indexIds = false){
}



function storeKeywords($_keywords, $_doCount = true){
// store similar words
$simWordsSQL = rex_sql::factory();
Expand Down Expand Up @@ -1625,13 +1609,13 @@ function storeKeywords($_keywords, $_doCount = true){
}
}


function deleteKeywords(){
$kw_sql = rex_sql::factory();
return $kw_sql->setQuery(sprintf('TRUNCATE TABLE `%s`', $this->tablePrefix.'search_it_keywords'));
}



/**
* Executes the search.
*
Expand Down
13 changes: 4 additions & 9 deletions plugins/documentation/docs/de_de/search_it-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

Methode | Erläuterung
-----|-----
[function __construct($_clang = false, $_loadSettings = true, $_useStopwords = true)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L72) | ###Alex###
[cologne_phone($_word)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L151) | A function for retrieving the K?lner Phonetik value of a string.
[__construct($_clang = false, $_loadSettings = true, $_useStopwords = true)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L72) | ###Alex###
[doSearchArticles($_bool = false)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L238) | ###Alex###
[doGroupBy($_bool = true)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L243) | ###Alex###
[setSearchInIDs($_searchInIDs, $_reset = false)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L251) | ###Alex###
[encodeRegex($_regex)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L319) | If utf8-encoding is used, the parameter will be appended with an "u". Since there is only UTF-8 supported, it always appends the "u".
[beginFrontendMode()](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L327) | Simulates the frontend by setting $REX['REDAXO'] to false. The original state is saved in $this->redaxo.
[endFrontendMode()](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L337) | Ends the frontend-mode by setting $REX['REDAXO'] to the original state.
[setMaxTeaserChars($_count)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L348) | Sets the maximum count of letters the teaser of a searched through text may have.
[setMaxHighlightedTextChars($_count)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L358) | Sets the maximum count of letters around an found search term in the highlighted text.
[generateIndex()](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L366) | Generates the full index at once.
Expand All @@ -32,19 +28,18 @@ Methode | Erläuterung
[setLogicalMode($_logicalMode)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1107) | Sets the mode of how the keywords are logical connected.
[setTextMode($_textMode)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1143) | Sets the mode concerning which text is to be searched through.
[setSearchMode($_searchMode)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1184) | Sets the MySQL search mode.
[ function setOrder($_order)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1211) | Sets the sort order of the results.
[setOrder($_order)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1211) | Sets the sort order of the results.
[setHighlightType($_type)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1246) | Sets the type of the text with the highlighted keywords.
[parseSearchString($_searchString)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1276) | Converts the search string to an array.
[addWhitelist($_whitelist)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1334) | This method adds weight to special words.
[setCaseInsensitive($_ci = true)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1350) | Case sensitive or case insensitive?
[setCI($_ci = true)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1362) | Case sensitive or case insensitive?
[setClang($_clang)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1374) | Sets the language-Id.
[getPlaintext($_text)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1392) | Strips the HTML-Tags from a text and replaces them with spaces or line breaks
[getHighlightedText($_text)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1419) | According to the highlight-type this method will return a string or an array. Found keywords will be highlighted with the surround-tags.
[getTeaserText($_text)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1577) | Gets the teaser of a text.
[isCached($_search)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1609) | Returns if a search term is already cached. The cached result will be stored in $this->cachedArray.
[cacheSearch($_result, $_indexIds)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1644) | Stores a search result in the cache.
[ function deleteCache($_indexIds = false)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1691) | Truncates the cache or deletes all data that are concerned with the given index-ids.
[deleteCache($_indexIds = false)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1691) | Truncates the cache or deletes all data that are concerned with the given index-ids.
[storeKeywords($_keywords, $_doCount = true)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1737) | ###Alex###
[ function deleteKeywords()](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1772) | ###Alex###
[deleteKeywords()](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1772) | ###Alex###
[search($_search)](https://github.com/pixelfirma/search_it/blob/Doku/lib/search_it.php#L1785) | Executes the search.
2 changes: 1 addition & 1 deletion plugins/documentation/package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: search_it/documentation
version: '5.8.2'
version: '5.9.0'
author: Norbert Micheel

title: 'translate:search_it_documentation_title'
Expand Down
2 changes: 1 addition & 1 deletion plugins/plaintext/pages/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'name' => 'search_it_plaintext[order]',
'value' => !empty($this->getConfig('order')) ? htmlspecialchars($this->getConfig('order')) : ''
)
),false
), false, false
);


Expand Down
2 changes: 1 addition & 1 deletion plugins/stats/pages/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
'type' => 'directoutput',
'output' => ''
)
),false
),false, false
);

$content[] = '<div id="stats_elements">';
Expand Down

0 comments on commit 87b76b2

Please sign in to comment.