From d18c78a7d495f8d336bb00c43365a8189db0cefd Mon Sep 17 00:00:00 2001 From: tobias Date: Sat, 28 Mar 2020 16:33:31 +0100 Subject: [PATCH 01/27] add url 2 urls support --- boot.php | 7 + functions/functions_search_it.php | 57 +-- install.php | 3 +- lang/de_de.lang | 2 + lang/en_gb.lang | 2 + lang/es_es.lang | 2 + lang/pt_br.lang | 2 + lang/sv_se.lang | 2 + lib/cronjob.php | 2 +- lib/pdf2txt.php | 4 +- lib/search_it.php | 343 +++++++++++++----- nbproject/project.properties | 10 + nbproject/project.xml | 9 + package.yml | 2 +- pages/ajax.php | 42 ++- pages/generate.php | 44 ++- pages/settings.addsources.php | 14 +- pages/settings.blacklist.php | 8 +- pages/settings.mode.php | 30 +- pages/settings.result.php | 2 +- pages/test.php | 2 +- .../autocomplete/lib/autocompleteHandler.php | 2 +- plugins/documentation/docs/de_de/main_navi.md | 1 + .../documentation/docs/de_de/module-url.md | 84 +++++ .../functions/functions_plaintext.php | 4 +- plugins/plaintext/lib/simple_html_dom.php | 48 +-- plugins/plaintext/pages/index.php | 2 +- .../stats/images/general_timestats.inc.php | 4 +- .../phplot/contrib/color_range.example.php | 2 +- .../phplot/contrib/data_table.example2.php | 2 +- .../phplot/contrib/prune_labels.example.php | 2 +- .../phplot/contrib/prune_labels.test.php | 2 +- plugins/stats/images/phplot/phplot.php | 72 ++-- .../stats/images/searchterm_timestats.inc.php | 4 +- plugins/stats/lib/stats.php | 10 +- plugins/stats/pages/index.php | 2 +- 36 files changed, 600 insertions(+), 230 deletions(-) create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml create mode 100644 plugins/documentation/docs/de_de/module-url.md diff --git a/boot.php b/boot.php index e1dce37..212226a 100644 --- a/boot.php +++ b/boot.php @@ -8,6 +8,13 @@ define('SEARCH_IT_ART_NOTOK',5); define('SEARCH_IT_ART_404',6); + define('SEARCH_IT_URL_EXCLUDED',0); + define('SEARCH_IT_URL_GENERATED',2); + define('SEARCH_IT_URL_REDIRECT',3); + define('SEARCH_IT_URL_ERROR',4); + define('SEARCH_IT_URL_NOTOK',5); + define('SEARCH_IT_URL_404',6); + define('SEARCH_IT_FILE_NOEXIST',0); define('SEARCH_IT_FILE_XPDFERR_OPENSRC',1); define('SEARCH_IT_FILE_XPDFERR_OPENDEST',2); diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index b8ee4cc..df88885 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -3,14 +3,14 @@ function search_it_getArticles($cats = false) { $si = rex_addon::get('search_it'); - $whereCats = array(); + $whereCats = []; if(is_array($cats)){ foreach($cats as $catID) { $whereCats[] = "path LIKE '%|" . $catID . "|%'"; } } - $return = array(); + $return = []; $query = 'SELECT id,name,path FROM '.rex::getTable('article').' WHERE 1'; if( !$si->getConfig('indexoffline') ) { $query .= ' AND status = 1'; @@ -31,11 +31,11 @@ function search_it_getArticles($cats = false) { function search_it_getCategories($_ignoreoffline = true, $_onlyIDs = false, $_cats = false) { $si = rex_addon::get('search_it'); - $return = array(); + $return = []; if(!empty($_cats)){ - $whereCats = array(); - $sqlCats = array(); + $whereCats = []; + $sqlCats = []; if(is_array($_cats)){ foreach($_cats as $catID){ $whereCats[] = "path LIKE '%|".intval($catID)."|%'"; @@ -43,7 +43,7 @@ function search_it_getCategories($_ignoreoffline = true, $_onlyIDs = false, $_ca } } - $return = array(); + $return = []; $query = 'SELECT id,catname,path FROM '.rex::getTable('article').' WHERE startarticle = 1'; if( !$si->getConfig('indexoffline') AND $_ignoreoffline ) { $query .= ' AND status = 1'; @@ -94,9 +94,9 @@ function search_it_getDirs($_startDir = '', $_getSubdirs = false){ if (@is_dir($_SERVER['DOCUMENT_ROOT'] . $_startDir)){ $dirs2 = array_diff(scandir($_SERVER['DOCUMENT_ROOT'] . $_startDir), array('.', '..')); } else { - return array(); + return []; } - $dirs = array(); + $dirs = []; foreach ($dirs2 as $k => $dir){ if (@is_dir($_SERVER['DOCUMENT_ROOT'] . $_startDir . '/' . $dir)) { $dirs[$_SERVER['DOCUMENT_ROOT'] . $_startDir . '/' . $dir] = utf8_encode($_startDir . '/' . $dir); @@ -106,14 +106,14 @@ function search_it_getDirs($_startDir = '', $_getSubdirs = false){ return $dirs; } - $return = array(); + $return = []; while(!empty($dirs)){ $dir = array_shift($dirs); $depth = substr_count($dir, '/') - $startDepth; if(@is_dir($_SERVER['DOCUMENT_ROOT'].$dir) AND $depth <= $si->getConfig('dirdepth')){ $return[$_SERVER['DOCUMENT_ROOT'].$dir] = utf8_encode($dir); - $subdirs = array(); + $subdirs = []; foreach(array_diff(scandir($_SERVER['DOCUMENT_ROOT'].$dir), array( '.', '..' )) as $subdir) { if (@is_dir($_SERVER['DOCUMENT_ROOT'] . $dir . '/' . $subdir)) { $subdirs[] = $dir . '/' . $subdir; @@ -126,10 +126,10 @@ function search_it_getDirs($_startDir = '', $_getSubdirs = false){ return $return; } -function search_it_getFiles($_startDir = '', $_fileexts = array(), $_getSubdirs = false){ +function search_it_getFiles($_startDir = '', $_fileexts = [], $_getSubdirs = false){ $si = rex_addon::get('search_it'); - $return = array(); + $return = []; $fileextPattern=''; if(!empty($_fileexts)) { @@ -142,9 +142,9 @@ function search_it_getFiles($_startDir = '', $_fileexts = array(), $_getSubdirs if(@is_dir($_SERVER['DOCUMENT_ROOT'].$_startDir)) { $dirs2 = array_diff(scandir($_SERVER['DOCUMENT_ROOT'] . $_startDir), array('.', '..')); } else { - return array(); + return []; } - $dirs = array(); + $dirs = []; foreach($dirs2 as $k => $dir){ if(@is_dir($_SERVER['DOCUMENT_ROOT'].$_startDir.'/'.$dir)) { $dirs[$_SERVER['DOCUMENT_ROOT'] . $_startDir . '/' . $dir] = $_startDir . '/' . $dir; @@ -162,7 +162,7 @@ function search_it_getFiles($_startDir = '', $_fileexts = array(), $_getSubdirs $depth = substr_count($dir, '/') - $startDepth; if(@is_dir($_SERVER['DOCUMENT_ROOT'].$dir) AND $depth <= $si->getConfig('dirdepth')){ - $subdirs = array(); + $subdirs = []; foreach(array_diff(scandir($_SERVER['DOCUMENT_ROOT'].$dir), array( '.', '..' )) as $subdir) { if (@is_dir($_SERVER['DOCUMENT_ROOT'] . $dir . '/' . $subdir)) { $subdirs[] = $dir . '/' . $subdir; @@ -186,7 +186,7 @@ function search_it_handle_extensionpoint($_ep){ $_params = $_ep->getParams(); $_subject = $_ep->getSubject(); - $includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : array(); + $includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : []; $search_it = new search_it(); switch($_ep->getName()){ @@ -297,14 +297,19 @@ function search_it_handle_extensionpoint($_ep){ $search_it->deleteCache(); } -function search_it_getSettingsFormSection($id = '', $title = ' ', $elements = array(), $ownsection = 'info', $collapse = false ){ +function search_it_getSettingsFormSection($id = '', $title = ' ', $elements = [], $ownsection = 'info', $collapse = false ) { $return = '
'; $formElements = []; $fragment = new rex_fragment(); - foreach($elements as $element){ - $n = array(); + foreach($elements as $element) { + if(count($element) == 0) { + // Skip empty elements + continue; + } + + $n = []; switch($element['type']){ // HIDDEN @@ -440,17 +445,17 @@ function search_it_config_unserialize($_str){ return $conf; } - $return = array(); + $return = []; if(is_array($conf)){ foreach(unserialize($_str) as $k => $v){ if(is_array($v)){ - $return[$k] = array(); + $return[$k] = []; foreach($v as $k2 => $v2) { if (is_array($v2)) { - $return[$k][$k2] = array(); + $return[$k][$k2] = []; foreach ($v2 as $k3 => $v3) { if (is_array($v3)) { - $return[$k][$k2][$k3] = array(); + $return[$k][$k2][$k3] = []; foreach ($v3 as $k4 => $v4) { $return[$k][$k2][$k3][$k4] = stripslashes($v4); } @@ -704,7 +709,7 @@ function soundex_ger($word) //echo "
code2: " . $code . "
"; // entfernen aller Codes "0" ausser am Anfang $codelen = strlen($code); - $num = array(); + $num = []; $num = str_split($code); $phoneticcode = $num[0]; @@ -743,7 +748,7 @@ function search_it_search_highlighter_output($_ep){ function search_it_search_highlighter_getHighlightedText($_subject, $_searchString, $_tags){ preg_match_all('~(?:(\+*)"([^"]*)")|(?:(\+*)(\S+))~is', $_searchString, $matches, PREG_SET_ORDER); - $searchterms = array(); + $searchterms = []; foreach ($matches as $match) { if (count($match) == 5) { // words without double quotes (foo) @@ -778,7 +783,7 @@ function search_it_reindex_cols($_ep){ $_params = $_ep->getParams(); - $includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : array(); + $includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : []; $search_it = new search_it; $didcol = false; diff --git a/install.php b/install.php index a1037f9..40ae1d9 100644 --- a/install.php +++ b/install.php @@ -46,5 +46,4 @@ ->ensureColumn(new rex_sql_column('count', 'int(11)', false, '1')) ->setPrimaryKey('id') ->ensureIndex(new rex_sql_index('keyword', ['keyword', 'clang'], rex_sql_index::UNIQUE)) - ->ensure(); - + ->ensure(); \ No newline at end of file diff --git a/lang/de_de.lang b/lang/de_de.lang index 49655b3..67989c2 100644 --- a/lang/de_de.lang +++ b/lang/de_de.lang @@ -27,6 +27,7 @@ search_it_settings_title_indexmode = Indexierung search_it_settings_indexoffline = Offline-Artikel indexieren search_it_settings_automaticindex_label = Artikel (ADD, EDIT, DELETE) automatisch (de)indexieren search_it_settings_reindex_cols_onforms_label = Reindexieren aller Spalten, wenn Tabellen mit YForm oder form bearbeitet werden +search_it_settings_index_url_addon_label = URLs aus dem URL Addon (Version >=2) indexieren search_it_settings_http_authbasic = HTTP Basic AUTH ( .htaccess Passwortschutz) search_it_settings_http_auth_desc = Wenn ein Zugriffsschutz die Website schützt, kann hier ein Login hinterlegt werden, um die Indexierung zu ermöglichen @@ -116,6 +117,7 @@ search_it_generate_media_error_pdf2 = Anderer PDF Fehlerr search_it_generate_media_error_output = XPDF-Fehler: Fehler beim Öffnen einer Ausgabedatei search_it_generate_media_error_permissions = XPDF-Fehler: PDF Rechte fehlen search_it_generate_media_empty = Medium is leer oder kein Inhalt konnte extrahiert werden +search_it_generate_url_excluded = nicht indexiert, URL wurde ausgeschlossen search_it_settings_fileext_header = Datei-Inhalte durchsuchen search_it_settings_fileext_label = Dateiendungen (z.B. txt,csv,pdf)
(frei lassen für beliebige Dateien) diff --git a/lang/en_gb.lang b/lang/en_gb.lang index 5c7cd15..a1160fd 100644 --- a/lang/en_gb.lang +++ b/lang/en_gb.lang @@ -27,6 +27,7 @@ search_it_settings_title_indexmode = Indexing search_it_settings_indexoffline = Index offline articles search_it_settings_automaticindex_label = Index and deindex articles automatically (ADD, EDIT, DELETE) search_it_settings_reindex_cols_onforms_label = Reindex all columns, if tables are changed through YForm or form +search_it_settings_index_url_addon_label = Index URL addon (version >=2) URLs search_it_settings_http_authbasic = HTTP Basic AUTH ( .htaccess protection) search_it_settings_http_auth_desc = If the website i s protected through HTTP Basic Auth, you can put a valid login here, in order to allow indexing @@ -116,6 +117,7 @@ search_it_generate_media_error_pdf2 = Other PDF Error search_it_generate_media_error_output = XPDF-error: Error opening an output file search_it_generate_media_error_permissions = XPDF-error: Error related to PDF permissions search_it_generate_media_empty = Media is empty or could not be extracted +search_it_generate_url_excluded = not indexed, url was excluded search_it_settings_fileext_header = File search search_it_settings_fileext_label = Extensions (i.e. 'txt,csv,pdf'
(leave empty for any files) diff --git a/lang/es_es.lang b/lang/es_es.lang index 5c69e66..45a8e90 100644 --- a/lang/es_es.lang +++ b/lang/es_es.lang @@ -27,6 +27,7 @@ search_it_settings_title_indexmode = Indexación search_it_settings_indexoffline = Artículo sin conexión de índice search_it_settings_automaticindex_label = Automáticamente indexar artículos (AGREGAR, EDITAR, ELIMINAR) search_it_settings_reindex_cols_onforms_label = Reindexar todas las columnas al editar tablas con YForm o formulario +search_it_settings_index_url_addon_label = Index URL addon (version >=2) URLs search_it_settings_http_authbasic = HTTP Basic AUTH (protección de contraseñas .htaccess) search_it_settings_http_auth_desc = Si una protección de acceso protege el sitio web, se puede almacenar un inicio de sesión aquí para permitir la indexación @@ -116,6 +117,7 @@ search_it_generate_media_error_pdf2 = Otro error de PDF search_it_generate_media_error_output = Error de XPDF: error al abrir un archivo de salida search_it_generate_media_error_permissions = Error de XPDF: faltan los derechos de PDF search_it_generate_media_empty = El medio está vacío o no se pudo extraer contenido +search_it_generate_article_excluded = No indexado, el url fue excluido search_it_settings_fileext_header = Buscar contenido de archivos search_it_settings_fileext_label = Extensiones de archivos (por ejemplo, txt, csv, pdf)
(déjelo en blanco para cualquier archivo) diff --git a/lang/pt_br.lang b/lang/pt_br.lang index f6543b2..72fef77 100644 --- a/lang/pt_br.lang +++ b/lang/pt_br.lang @@ -27,6 +27,7 @@ search_it_settings_title_indexmode = Indexação search_it_settings_indexoffline = Indexar artigos offline search_it_settings_automaticindex_label = Indexar e de-indexar artigos automaticamente (ADD, EDIT, DELETE) search_it_settings_reindex_cols_onforms_label = Re-indexar todas as colunas se as tabelas foram modificadas com Yform ou form +search_it_settings_index_url_addon_label = Index URL addon (version >=2) URLs search_it_settings_http_authbasic = HTTP Basic AUTH ( .htaccess Passwortschutz) search_it_settings_http_auth_desc = Wenn ein Zugriffsschutz die Website schützt, kann hier ein Login hinterlegt werden, um die Indexierung zu ermöglichen @@ -116,6 +117,7 @@ search_it_generate_media_error_pdf2 = Other PDF Error search_it_generate_media_error_output = XPDF-error: Error opening an output file search_it_generate_media_error_permissions = XPDF-error: Error related to PDF permissions search_it_generate_media_empty = Media is empty or could not be extracted +search_it_generate_article_excluded = not indexed, url was excluded search_it_settings_fileext_header = Arquivo de busva search_it_settings_fileext_label = Extensões (ex: 'txt,csv,pdf'
( deixar vazio para arquivos desejados) diff --git a/lang/sv_se.lang b/lang/sv_se.lang index e4713da..25e4222 100644 --- a/lang/sv_se.lang +++ b/lang/sv_se.lang @@ -27,6 +27,7 @@ search_it_settings_title_indexmode = Indexering search_it_settings_indexoffline = Indexera offline artiklar search_it_settings_automaticindex_label = Indexera och deindexera artikel (ADD, EDIT, DELETE) automatisk search_it_settings_reindex_cols_onforms_label = Reindexera alla kolumner, om tabeller ändras via YForm eller form +search_it_settings_index_url_addon_label = Index URL addon (version >=2) URLs search_it_settings_http_authbasic = HTTP Basic AUTH ( .htaccess lösenordskydd) search_it_settings_http_auth_desc = Om webbplatsen skyddas mot åtkomst kan en inloggning sparas här för att aktivera indexering @@ -116,6 +117,7 @@ search_it_generate_media_error_pdf2 = Other PDF Error search_it_generate_media_error_output = XPDF-error: Error opening an output file search_it_generate_media_error_permissions = XPDF-error: Error related to PDF permissions search_it_generate_media_empty = Media is empty or could not be extracted +search_it_generate_url_excluded = not indexed, url was excluded search_it_settings_fileext_header = Genomsök filinnehåll search_it_settings_fileext_label = Filtillägg (t.ex. 'txt,csv,pdf'
(lämna tomma för alla filer) diff --git a/lib/cronjob.php b/lib/cronjob.php index d404f72..95e0253 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -10,7 +10,7 @@ public function execute() //$message = $this->getParam('action').':'."\n"; $search_it = new search_it(); - $includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : array(); + $includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : []; switch ($this->getParam('action')){ case 2: // Spalten neu indexieren diff --git a/lib/pdf2txt.php b/lib/pdf2txt.php index 8580df0..a834823 100644 --- a/lib/pdf2txt.php +++ b/lib/pdf2txt.php @@ -86,7 +86,7 @@ function convert($_data = false) // the following code ignores the keyword "stream" and "endstream" if they are in a string $isStream = false; $stream = ''; - $streams = array(); + $streams = []; $openBracketCount = 0; $encodedStream = false; foreach (preg_split('~(<<\s*/.*?>>\s*stream\s*)|(\s*endstream\s*)|(\()|(\))~ism', $this->data, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $k => $part) { @@ -132,7 +132,7 @@ function convert($_data = false) } } - $textObjects = array(); + $textObjects = []; foreach ($streams as $k => $stream) { // uncompress the stream if (false === $uncompressed = @gzuncompress($stream)) diff --git a/lib/search_it.php b/lib/search_it.php index ab7cbf3..33a0e5a 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -23,21 +23,21 @@ class search_it private $tablePrefix; private $tempTablePrefix; private $significantCharacterCount = 3; - private $stopwords = array(); + private $stopwords = []; private $errormessages = ''; private $ci = true; private $where = ''; private $groupBy = true; - private $order = array('RELEVANCE_SEARCH_IT' => 'DESC'); + private $order = ['RELEVANCE_SEARCH_IT' => 'DESC']; - private $searchArray = array(); + private $searchArray = []; private $searchHtmlEntities = false; private $cache = true; - private $cachedArray = array(); - private $searchInIDs = array(); + private $cachedArray = []; + private $searchInIDs = []; private $searchAllArticlesAnyway = false; - private $whitelist = array(); + private $whitelist = []; /* config values */ @@ -54,14 +54,14 @@ class search_it private $maxHighlightedTextChars = 100; private $highlightType = 'surroundtext'; - private $includeColumns = array(); - private $fileExtensions = array(); + private $includeColumns = []; + private $fileExtensions = []; private $indexMediapool = false; - private $fileDirectories = array(); + private $fileDirectories = []; - private $blacklist = array(); - private $blacklisted = array(); - private $excludeIDs = array(); + private $blacklist = []; + private $blacklisted = []; + private $excludeIDs = []; function __construct($_clang = false, $_loadSettings = true, $_useStopwords = true) @@ -86,15 +86,15 @@ function __construct($_clang = false, $_loadSettings = true, $_useStopwords = tr } $this->setHighlightType(rex_addon::get('search_it')->getConfig('highlight')); - $this->includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : array(); + $this->includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : []; $this->fileExtensions = rex_addon::get('search_it')->getConfig('fileextensions'); $this->indexMediapool = rex_addon::get('search_it')->getConfig('indexmediapool'); - $this->fileDirectories = is_array(rex_addon::get('search_it')->getConfig('indexfolders')) ? rex_addon::get('search_it')->getConfig('indexfolders') : array(); + $this->fileDirectories = is_array(rex_addon::get('search_it')->getConfig('indexfolders')) ? rex_addon::get('search_it')->getConfig('indexfolders') : []; - $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()); + $this->setBlacklist(is_array(rex_addon::get('search_it')->getConfig('blacklist')) ? rex_addon::get('search_it')->getConfig('blacklist') : []); + $this->setExcludeIDs(is_array(rex_addon::get('search_it')->getConfig('exclude_article_ids')) ? rex_addon::get('search_it')->getConfig('exclude_article_ids') : []); if (is_array(rex_addon::get('search_it')->getConfig('exclude_category_ids'))) { - $ids = array(); + $ids = []; foreach (rex_addon::get('search_it')->getConfig('exclude_category_ids') as $catID) { foreach (search_it_getArticles(array($catID)) as $id => $name) { $ids[] = $id; @@ -130,7 +130,6 @@ public function generateIndex() $this->deleteIndex(); $this->deleteCache(); - // index articles $global_return = 0; $art_sql = rex_sql::factory(); @@ -144,7 +143,21 @@ public function generateIndex() } } - // index columns + // index url 2 addon URLs + if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { + $url_sql = rex_sql::factory(); + $url_sql->setTable($this->tablePrefix . 'url_generator_url'); + if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { + foreach ($url_sql->getArray() as $url) { + $returns = $this->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); + foreach ( $returns as $return ) { + if ($return > 3 ) { $global_return += $return; } + } + } + } + } + + // index columns foreach ($this->includeColumns as $table => $columnArray) { foreach ($columnArray as $column) { $this->indexColumn($table, $column); @@ -170,7 +183,7 @@ public function generateIndex() } } - return $global_return; + return $global_return; } /** @@ -190,8 +203,8 @@ public function indexArticle($_id, $_clang = false) $langs = array(rex_clang::get($_clang)); } - $return = array(); - $keywords = array(); + $return = []; + $keywords = []; foreach ($langs as $lang) { $langID = $lang->getId(); @@ -210,7 +223,7 @@ public function indexArticle($_id, $_clang = false) $select->setWhere($where); $select->select('id'); - $indexIds = array(); + $indexIds = []; foreach ($select->getArray() as $result) { $indexIds[] = $result['id']; } @@ -307,7 +320,7 @@ public function indexArticle($_id, $_clang = false) $insert = rex_sql::factory(); - $articleData = array(); + $articleData = []; $articleData['texttype'] = 'article'; $articleData['ftable'] = $this->tablePrefix . 'article'; @@ -320,7 +333,7 @@ public function indexArticle($_id, $_clang = false) $articleData['plaintext'] = $plaintext; if (array_key_exists($this->tablePrefix . 'article', $this->includeColumns)) { - $additionalValues = array(); + $additionalValues = []; $select->flushValues(); $select->setTable($this->tablePrefix . 'article'); $select->setWhere('id = ' . $_id . ' AND clang_id = ' . $langID); @@ -354,7 +367,169 @@ public function indexArticle($_id, $_clang = false) return $return; } + /** + * Indexes a certain url from url Addon. + * + * @param int $id url_generate_url table id + * @param int $article_id redaxo article id + * @param int $profile_id url addon profile id + * @param int $data_id url addon profile id + * @param int $clang_id redaxo clang id + * + * @return int + */ + public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) + { + $return = []; + $keywords = []; + + $delete = rex_sql::factory(); + $where = "ftable = '". $this->tablePrefix . "url_generator_url' AND fid = ". $id ." AND clang = ". $clang_id; + // delete from cache + $select = rex_sql::factory(); + $select->setTable($this->tempTablePrefix . 'search_it_index'); + $select->setWhere($where); + $select->select('id'); + + $indexIds = []; + foreach ($select->getArray() as $result) { + $indexIds[] = $result['id']; + } + $this->deleteCache($indexIds); + + // delete old + $delete->setTable($this->tempTablePrefix . 'search_it_index'); + $delete->setWhere($where); + $delete->delete(); + + // index article + $article = rex_article::get($article_id, $clang_id); + if ( is_null($article)) { + $return[$clang_id] = SEARCH_IT_ART_IDNOTFOUND; + } + else if (is_object($article) AND ($article->isOnline() OR rex_addon::get('search_it')->getConfig('indexoffline'))) { + try { + $url_profile = \Url\Profile::get($profile_id); + $server = rtrim(rex::getServer(), "/"); + $search_it_build_index = "do-it"; + if(rex_addon::get('yrewrite')->isAvailable()) { + $hit_domain = rex_yrewrite::getDomainByArticleId($hit['fid'], $hit['clang']); + $server = rtrim($hit_domain->getUrl(), "/"); + $search_it_build_index = "do-it-with-yrewrite"; + } + + $scanurl = $server .'/'. ltrim(str_replace(['../', './'], '', rex_getUrl($article_id, $clang_id, [$url_profile->getNamespace() => $data_id, 'search_it_build_index' => $search_it_build_index],'&')),"/"); + + $files_socket = rex_socket::factoryURL($scanurl); + if (rex_addon::get('search_it')->getConfig('htaccess_user') != '' && rex_addon::get('search_it')->getConfig('htaccess_pass') != '') { + $files_socket->addBasicAuthorization(rex_addon::get('search_it')->getConfig('htaccess_user'), rex_addon::get('search_it')->getConfig('htaccess_pass')); + } + $response = $files_socket->doGet(); + + $redircount = 0; + while ($response->isRedirection() && $redircount < 3) { + + $lastscanurl = $scanurl; + $scanurl = str_replace(array('../', './'), '/', $response->getHeader('location')); + + if (strpos($scanurl,'//') === false ) { + $parts = parse_url($lastscanurl); + if ( isset($parts['scheme']) && isset($parts['host']) ) { + $scanurl = $parts['scheme'] . '://' . $parts['host'] . $scanurl; + } + } + $scanurl .= ( strpos($scanurl,'?') !== false ? '&' : '?').'search_it_build_index=redirect'; + //rex_logger::factory()->log('Warning','Redirect von '.$lastscanurl.' zu '.$scanurl.', '.$response->getHeader()); + + $files_socket = rex_socket::factoryURL($scanurl); + if (rex_addon::get('search_it')->getConfig('htaccess_user') != '' && rex_addon::get('search_it')->getConfig('htaccess_pass') != '') { + $files_socket->addBasicAuthorization(rex_addon::get('search_it')->getConfig('htaccess_user'),rex_addon::get('search_it')->getConfig('htaccess_pass')); + } + $response = $files_socket->doGet(); + $redircount++; + } + if ($response->isOk()) { + $articleText = $response->getBody(); + } else { + $articleText = ''; + !is_null($response) ? $response_text = $response->getStatusCode() . ' - ' . $response->getStatusMessage() : $response_text = ''; + if ( $response->isRedirection() ) { + $return[$clang_id] = SEARCH_IT_URL_REDIRECT; + $response_text = rex_i18n::msg('search_it_generate_article_redirect'); + rex_logger::factory()->log( 'Warning', rex_i18n::msg('search_it_generate_article_http_error') .' '. $scanurl . '
' . $response_text ); + } else if ( $response->getStatusCode() == '404' ) { + $return[$clang_id] = SEARCH_IT_URL_404; + rex_logger::factory()->log( 'Warning', rex_i18n::msg('search_it_generate_article_404_error') .' '. $scanurl . '
' . $response_text ); + } else { + rex_logger::factory()->log( 'Warning', rex_i18n::msg('search_it_generate_article_http_error') .' '. $scanurl . '
' . $response_text ); + $return[$clang_id] = SEARCH_IT_URL_NOTOK; + } + return $return; + } + + } catch (rex_socket_exception $e) { + $articleText = ''; + rex_logger::factory()->log( 'Warning', rex_i18n::msg('search_it_generate_article_socket_error') .' '.$scanurl. '
' .$e->getMessage() ); + $return[$clang_id] = SEARCH_IT_URL_ERROR; + } + // regex time + preg_match_all('/(.*)/sU', $articleText, $matches, PREG_SET_ORDER); + $articleText = ''; + foreach ($matches as $match) { + if ( $match[1] == $article_id || $match[1] == '' ) { + // eventuell in diesem enthaltene weitere tags entfernen + $articleText .= ' ' . preg_replace('/)]*\s?-->/s','', $match[2]); + } + } + + $insert = rex_sql::factory(); + $articleData = []; + + $articleData['texttype'] = 'url'; + $articleData['ftable'] = $this->tablePrefix . 'url_generator_url'; + $articleData['fcolumn'] = NULL; + $articleData['clang'] = $clang_id; + $articleData['fid'] = intval($id); + $articleData['catid'] = $article->getCategoryId(); + $articleData['unchangedtext'] = $articleText; + $plaintext = $this->getPlaintext($articleText); + $articleData['plaintext'] = $plaintext; + + if (array_key_exists($this->tablePrefix . 'url_generator_url', $this->includeColumns)) { + $additionalValues = []; + $select->flushValues(); + $select->setTable($this->tablePrefix . 'url_generator_url'); + $select->setWhere('id = ' . $id . ' AND clang_id = ' . $clang_id); + $select->select('`' . implode('`,`', $this->includeColumns[$this->tablePrefix . 'url_generator_url']) . '`'); + foreach ($this->includeColumns[$this->tablePrefix . 'url_generator_url'] as $col) { + if ( $select->hasValue($col) ) { $additionalValues[$col] = $select->getValue($col); } + } + + $articleData['values'] = serialize($additionalValues); + } + + foreach (preg_split('~[[:punct:][:space:]]+~ismu', $plaintext) as $keyword) { + if ($this->significantCharacterCount <= mb_strlen($keyword, 'UTF-8')) { + $keywords[] = array('search' => $keyword, 'clang' => $clang_id); + } + } + + $articleData['teaser'] = $this->getTeaserText($plaintext); + $insert->setTable($this->tempTablePrefix . 'search_it_index'); + $insert->setValues($articleData); + $insert->insert(); + + + $return[$clang_id] = SEARCH_IT_URL_GENERATED; + + $this->storeKeywords($keywords, false); + } + + return $return; + } + + /** * Excludes an article from the index. * * @param int $_id @@ -380,7 +555,7 @@ public function unindexArticle($_id, $_clang = false) $select->setWhere($where); $select->select('id'); - $indexIds = array(); + $indexIds = []; foreach ($select->getArray() as $result) { $indexIds[] = $result['id']; } @@ -424,7 +599,7 @@ public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_ $cache = clone $delete; // delete from cache - $indexIds = array(); + $indexIds = []; if ($cache->select('id')) { foreach ($cache->getArray() as $result) { $indexIds[] = $result['id']; @@ -440,7 +615,7 @@ public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_ $sql = rex_sql::factory(); // get primary key column(s) - $primaryKeys = array(); + $primaryKeys = []; foreach ($sql->getArray("SHOW COLUMNS FROM `" . $_table . "` WHERE `KEY` = 'PRI'") as $col) { $primaryKeys[] = $col['Field']; } @@ -461,14 +636,14 @@ public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_ if ($sql->select('*')) { $count = 0; - $keywords = array(); + $keywords = []; foreach ($sql->getArray() as $row) { if (!empty($row[$_column]) AND ( rex_addon::get('search_it')->getConfig('indexoffline') OR $this->tablePrefix . 'article' != $_table OR $row['status'] == '1') AND ($this->tablePrefix . 'article' != $_table OR !in_array($row['id'], $this->excludeIDs)) ) { $insert = rex_sql::factory(); - $indexData = array(); + $indexData = []; $indexData['texttype'] = 'db_column'; $indexData['ftable'] = $_table; @@ -487,7 +662,7 @@ public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_ } elseif (count($primaryKeys) == 1) { $indexData['fid'] = $row[$primaryKeys[0]]; } elseif (count($primaryKeys)) { - $fids = array(); + $fids = []; foreach ($primaryKeys as $pk) { $fids[$pk] = $row[$pk]; } @@ -508,7 +683,7 @@ public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_ } else { $indexData['catid'] = NULL; } - $additionalValues = array(); + $additionalValues = []; foreach ($this->includeColumns[$_table] as $col) { if ( isset($row[$col]) ) { $additionalValues[$col] = $row[$col]; } } @@ -602,7 +777,7 @@ public function indexFile($_filename, $_doPlaintext = false, $_clang = false, $_ $select = rex_sql::factory(); $select->setTable($this->tempTablePrefix . 'search_it_index'); $select->setWhere($where); - $indexIds = array(); + $indexIds = []; if ($select->select('id')) { foreach ($select->getArray() as $result) { $indexIds[] = $result['id']; @@ -735,7 +910,7 @@ public function indexFile($_filename, $_doPlaintext = false, $_clang = false, $_ $fileData['unchangedtext'] = $text; $fileData['plaintext'] = $plaintext; - $keywords = array(); + $keywords = []; foreach (preg_split('~[[:punct:][:space:]]+~ismu', $plaintext) as $keyword) { if ($this->significantCharacterCount <= mb_strlen($keyword, 'UTF-8')) { $keywords[] = array('search' => $keyword, 'clang' => !isset($fileData['clang']) ? false : $fileData['clang']); @@ -838,7 +1013,7 @@ private static function getMaxFID($_table) public function deleteIndex() { $delete = rex_sql::factory(); - $delete->setQuery('TRUNCATE '. $this->tempTablePrefix .'search_it_index'); + $delete->setQuery('TRUNCATE '. $this->tempTablePrefix .'search_it_index'); $this->deleteCache(); } @@ -896,13 +1071,13 @@ public function setSearchString($_searchString) public function parseSearchString($_searchString) { // reset searchArray - $this->searchArray = array(); + $this->searchArray = []; - $matches = array(); + $matches = []; preg_match_all('~(?:(\+*)"([^"]*)")|(?:(\+*)(\S+))~isu', $_searchString, $matches, PREG_SET_ORDER); $count = 0; - $searchWords = array(); + $searchWords = []; foreach ($matches as $match) { if (count($match) == 5) { @@ -967,11 +1142,11 @@ public function addWhitelist($_whitelist) private function setSearchInIDs($_searchInIDs, $_reset = false) { if ($_reset) { - $this->searchInIDs = array(); + $this->searchInIDs = []; } if (array_key_exists('articles', $_searchInIDs)) { if (!array_key_exists('articles', $this->searchInIDs)) { - $this->searchInIDs['articles'] = array(); + $this->searchInIDs['articles'] = []; } foreach ($_searchInIDs['articles'] as $id) { if ($id = intval($id)) { @@ -983,7 +1158,7 @@ private function setSearchInIDs($_searchInIDs, $_reset = false) if (array_key_exists('categories', $_searchInIDs)) { if (!array_key_exists('categories', $this->searchInIDs)) { - $this->searchInIDs['categories'] = array(); + $this->searchInIDs['categories'] = []; } foreach ($_searchInIDs['categories'] as $id) { if ($id = intval($id)) { @@ -995,7 +1170,7 @@ private function setSearchInIDs($_searchInIDs, $_reset = false) if (array_key_exists('filecategories', $_searchInIDs)) { if (!array_key_exists('filecategories', $this->searchInIDs)) { - $this->searchInIDs['filecategories'] = array(); + $this->searchInIDs['filecategories'] = []; } foreach ($_searchInIDs['filecategories'] as $id) { if ($id = intval($id)) { @@ -1007,11 +1182,11 @@ private function setSearchInIDs($_searchInIDs, $_reset = false) if (array_key_exists('db_columns', $_searchInIDs)) { if (!array_key_exists('db_columns', $this->searchInIDs)) { - $this->searchInIDs['db_columns'] = array(); + $this->searchInIDs['db_columns'] = []; } foreach ($_searchInIDs['db_columns'] as $table => $columnArray) { $this->hashMe .= $table; - $tmp = array(); + $tmp = []; foreach ($columnArray as $column) { $tmp[] = $column; $this->hashMe .= $column; @@ -1090,7 +1265,7 @@ public function searchInCategoryTree($_id) private function getChildList($_id) { $subs= rex_category::get($_id)->getChildren(); - $childlist = array(); + $childlist = []; $childlist[] = (int) $_id; if( !empty($subs)){ foreach ( $subs as $sub){ @@ -1449,8 +1624,8 @@ public function getHighlightedText($_text) $Apieces = preg_split($regex, $_text, -1, PREG_SPLIT_DELIM_CAPTURE); - $search = array(); - $replace = array(); + $search = []; + $replace = []; foreach ($this->searchArray as $keyword) { $search[] = preg_quote($keyword['search'], '~'); $replace[] = '~' . preg_quote($keyword['search'], '~') . '~isu'; @@ -1469,7 +1644,7 @@ public function getHighlightedText($_text) $return .= $Apieces[$i]; } - $cutted = array(); + $cutted = []; preg_match('~^.*?(' . implode('|', $search) . ').{0,' . $this->maxHighlightedTextChars . '}~imsu', $return, $cutted); if (!empty($cutted)) { $needEllipses = false; @@ -1491,17 +1666,17 @@ public function getHighlightedText($_text) case 'array': $startEllipsis = false; $endEllipsis = false; - $Ahighlighted = array(); + $Ahighlighted = []; $_text = preg_replace('~\s+~', ' ', $_text); - $replace = array(); + $replace = []; foreach ($this->searchArray as $keyword) { $replace[] = '~' . preg_quote($keyword['search'], '~') . '~isu'; } $strlen = mb_strlen($_text); - $positions = array(); + $positions = []; for ($i = 0; $i < count($this->searchArray); $i++) { - $hits = array(); + $hits = []; $offset = 0; preg_match_all('~((.{0,' . $this->maxHighlightedTextChars . '})' . preg_quote($this->searchArray[$i]['search'], '~') . '(.{0,' . $this->maxHighlightedTextChars . '}))~imsu', $_text, $hits, PREG_SET_ORDER); @@ -1510,7 +1685,7 @@ public function getHighlightedText($_text) $currentposition = ceil(intval(($offset - 1) / (2 * $this->maxHighlightedTextChars))); if ($this->highlightType == 'array' AND !array_key_exists($this->searchArray[$i]['search'], $Ahighlighted)) { - $Ahighlighted[$this->searchArray[$i]['search']] = array(); + $Ahighlighted[$this->searchArray[$i]['search']] = []; } if (trim($hit[1]) != '') { @@ -1567,7 +1742,7 @@ public function getHighlightedText($_text) break; case 'teaser': - $search = array(); + $search = []; foreach ($this->searchArray as $keyword) { $search[] = '~' . preg_quote($keyword['search'], '~') . '~isu'; } @@ -1636,7 +1811,7 @@ private function cacheSearch($_result, $_indexIds) $sql->insert(); $lastId = $sql->getLastId(); - $Ainsert = array(); + $Ainsert = []; foreach ($_indexIds as $id) { $Ainsert[] = sprintf('(%d,%d)', $id, $lastId); } @@ -1721,7 +1896,7 @@ private function storeKeywords($_keywords, $_doCount = true) { // store similar words $simWordsSQL = rex_sql::factory(); - $simWords = array(); + $simWords = []; foreach ($_keywords as $keyword) { if (!in_array(mb_strtolower($keyword['search'], 'UTF-8'), $this->blacklist) AND !in_array(mb_strtolower($keyword['search'], 'UTF-8'), $this->stopwords) @@ -1771,10 +1946,10 @@ function search($_search) { $startTime = microtime(true); - $return = array(); + $return = []; $return['errormessages'] = ''; $return['simwordsnewsearch'] = ''; - $return['simwords'] = array(); + $return['simwords'] = []; $this->searchString = trim(stripslashes($_search)); $keywordCount = $this->parseSearchString($this->searchString); // setzt $this->searchArray @@ -1782,14 +1957,14 @@ function search($_search) if (empty($this->searchString) OR empty($this->searchArray)) { return array( 'count' => 0, - 'hits' => array(), - 'keywords' => array(), + 'hits' => [], + 'keywords' => [], 'keywords' => '', 'sql' => 'No search performed.', 'blacklisted' => false, 'hash' => '', 'simwordsnewsearch' => '', - 'simwords' => array(), + 'simwords' => [], 'time' => 0 ); } @@ -1811,9 +1986,9 @@ function search($_search) if ($this->similarwords) { $simWordsSQL = rex_sql::factory(); - $simwordQuerys = array(); + $simwordQuerys = []; foreach ($this->searchArray as $keyword) { - $sounds = array(); + $sounds = []; if ($this->similarwordsMode & SEARCH_IT_SIMILARWORDS_SOUNDEX) { $sounds[] = "soundex = '" . soundex($keyword['search']) . "'"; } @@ -1866,7 +2041,7 @@ function search($_search) implode(' UNION ', $simwordQuerys), $this->similarwordsPermanent ? '' : 'GROUP BY keyword, typedin' ).''; die();*/ - $newsearch = array(); + $newsearch = []; foreach ($this->searchArray as $keyword) { if (preg_match('~\s~isu', $keyword['search'])) { $quotes = '"'; @@ -1891,7 +2066,7 @@ function search($_search) //echo '
'; print_r($return['simwords']); echo '
'; - $searchColumns = array(); + $searchColumns = []; switch ($this->textMode) { case 'unmodified': $searchColumns[] = 'unchangedtext'; @@ -1908,11 +2083,11 @@ function search($_search) $sql = rex_sql::factory(); - $A2Where = array(); - $Amatch = array(); + $A2Where = []; + $Amatch = []; foreach ($this->searchArray as $searchword) { - $AWhere = array(); + $AWhere = []; $similarkeywords = ''; if ($this->similarwords && !isset($return['simwords'][$searchword['search']])) { continue; @@ -1935,7 +2110,7 @@ function search($_search) if ($this->searchMode == 'match') { $AWhere[] = $match; } else { - $tmpWhere = array(); + $tmpWhere = []; foreach ($searchColumns as $searchColumn) { $tmpWhere[] = sprintf("(`%s` LIKE '%%%s%%')", $searchColumn, str_replace(array('%', '_'), array('\%', '\_'), substr($sql->escape($keyword['search']), 1, -1))); @@ -1961,19 +2136,25 @@ function search($_search) $where = '(' . implode($this->logicalMode, $A2Where) . ')'; //$where = sprintf("( MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)) > 0",implode(',',$searchColumns),implode(' ',$Awhere)); - // language if ($this->clang !== false) { $where .= ' AND (clang = ' . intval($this->clang) . ' OR clang IS NULL)'; } - $AwhereToSearch = array(); + $AwhereToSearch = []; if (array_key_exists('articles', $this->searchInIDs) AND count($this->searchInIDs['articles'])) { $AwhereToSearch[] = "texttype = 'article'"; $AwhereToSearch[] = "(fid IN (" . implode(',', $this->searchInIDs['articles']) . "))"; } + if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { + if (array_key_exists('url', $this->searchInIDs) AND count($this->searchInIDs['url'])) { + $AwhereToSearch[] = "texttype = 'url'"; + $AwhereToSearch[] = "(fid IN (" . implode(',', $this->searchInIDs['url']) . "))"; + } + } + if (array_key_exists('categories', $this->searchInIDs) AND count($this->searchInIDs['categories'])) { $AwhereToSearch[] = "(catid IN (" . implode(',', $this->searchInIDs['categories']) . ") AND ftable = '" . $this->tablePrefix . "article')"; } @@ -1985,7 +2166,7 @@ function search($_search) if (array_key_exists('db_columns', $this->searchInIDs) AND count($this->searchInIDs['db_columns'])) { $AwhereToSearch[] = "texttype = 'db_column'"; - $Acolumns = array(); + $Acolumns = []; foreach ($this->searchInIDs['db_columns'] as $table => $colArray) { foreach ($colArray as $column) { @@ -2010,12 +2191,12 @@ function search($_search) } // build ORDER-BY-String - $Aorder = array(); + $Aorder = []; foreach ($this->order as $col => $dir) { $Aorder[] = $col . ' ' . $dir; } - $selectFields = array(); + $selectFields = []; if ($this->groupBy) { $selectFields[] = sprintf('(SELECT SUM%s FROM `%s` summe WHERE summe.fid = r1.fid AND summe.ftable = r1.ftable) AS RELEVANCE_SEARCH_IT', $match, $this->tempTablePrefix . 'search_it_index'); $selectFields[] = sprintf('(SELECT COUNT(*) FROM `%s` summe WHERE summe.fid = r1.fid AND (summe.ftable IS NULL OR summe.ftable = r1.ftable) AND (summe.fcolumn IS NULL OR summe.fcolumn = r1.fcolumn) AND summe.texttype = r1.texttype) AS COUNT_SEARCH_IT', $this->tempTablePrefix . 'search_it_index'); @@ -2056,7 +2237,7 @@ function search($_search) $where, $match, $match, - rex::getTempPrefix(). 'search_it_index', + $this->tempTablePrefix . 'search_it_index', ($this->clang !== false) ? 'AND (clang = ' . intval($this->clang) . ' OR clang IS NULL)' : '', implode(",\n", $Aorder), $this->limit[0], $this->limit[1] @@ -2081,25 +2262,25 @@ function search($_search) $sqlResult = $sql->getArray($query); $info = 'Success'; } catch (rex_sql_exception $e) { - $sqlResult = array(); + $sqlResult = []; $error = $e->getMessage(); $return['errormessages'] .= $error; } $return['errormessages'] .= $this->errormessages; - $indexIds = array(); + $indexIds = []; $count = 0; $sqlResultCount = $sql->getArray('SELECT FOUND_ROWS() as count'); $return['count'] = intval($sqlResultCount[0]['count']); // hits - $return['hits'] = array(); + $return['hits'] = []; $i = 0; foreach ($sqlResult as $hit) { $indexIds[] = $hit['id']; - $return['hits'][$i] = array(); + $return['hits'][$i] = []; $return['hits'][$i]['id'] = $hit['id']; $return['hits'][$i]['fid'] = $hit['fid']; if (!is_numeric($hit['fid']) AND !is_null($json_decode_fid = json_decode($hit['fid'], true))) { @@ -2125,7 +2306,7 @@ function search($_search) } if ($this->groupBy) { - $indexIds = array(); + $indexIds = []; foreach ($sql->getArray( sprintf(' SELECT id @@ -2176,4 +2357,4 @@ function search($_search) return $return; } -} +} \ No newline at end of file diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..b895b16 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,10 @@ +file.reference.Redaxo-Redaxo5=../../Dropbox/www.design-to-use.de/Redaxo/Redaxo5 +include.path=\ + ${php.global.include.path}:\ + ${file.reference.Redaxo-Redaxo5} +php.version=PHP_74 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..29083bd --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + search_it + + + diff --git a/package.yml b/package.yml index 2296518..6d225f5 100644 --- a/package.yml +++ b/package.yml @@ -22,7 +22,7 @@ page: blacklist: { title: 'translate:settings_blacklist' } test: { title: 'translate:test', icon: rex-icon fa-flask } requires: - redaxo: '^5.5.0' + redaxo: '^5.10.0' php: '^7' system_plugins: diff --git a/pages/ajax.php b/pages/ajax.php index fd85ebb..4665c30 100644 --- a/pages/ajax.php +++ b/pages/ajax.php @@ -41,7 +41,45 @@ } } break; - + + case 'url': + $url_sql = rex_sql::factory(); + $url_sql->setTable(rex::getTablePrefix() . 'url_generator_url'); + $url_sql->setWhere("id = ". rex_get('id')); + if ($url_sql->select('id, article_id, clang_id, profile_id, data_id, seo, url')) { + if($url_sql->getValue('id') > 0) { + foreach($search_it->indexUrl($url_sql->getValue('id'), $url_sql->getValue('article_id'), $url_sql->getValue('clang_id'), $url_sql->getValue('profile_id'), $url_sql->getValue('data_id')) as $langID => $url) { + $url_info = json_decode($url_sql->getValue('seo'), true); + $msgtext = ''. rex_escape($url_info["title"]).' (URL ID='. $url_sql->getValue('id') .') '; + + switch($url){ + case SEARCH_IT_URL_ERROR: + echo '

'. $msgtext . $this->i18n('search_it_generate_article_socket_error').'

'; + break; + case SEARCH_IT_URL_EXCLUDED: + echo '

'. $msgtext . $this->i18n('search_it_generate_url_excluded').'

'; + break; + case SEARCH_IT_URL_404: + echo '

'. $msgtext . $this->i18n('search_it_generate_article_404_error').'

'; + break; + case SEARCH_IT_URL_NOTOK: + echo '

'. $msgtext . $this->i18n('search_it_generate_article_http_error').'

'; + break; + case SEARCH_IT_ART_IDNOTFOUND: + echo '

' . $msgtext . $this->i18n('search_it_generate_article_id_not_found').'

'; + break; + case SEARCH_IT_URL_REDIRECT: + echo '

'. $msgtext . $this->i18n('search_it_generate_article_redirect').'

'; + break; + case SEARCH_IT_URL_GENERATED: + echo '

'. $msgtext . $this->i18n('search_it_generate_article_done').'

'; + break; + } + } + } + } + break; + case 'col': if(false !== ($count = $search_it->indexColumn(rex_get('t'), rex_get('c'), false, false, rex_get('s'), rex_get('w')))) { echo '

`' . rex_get('t') . '`.`' . rex_get('c') . '` (' . rex_get('s') . ' - ' . (rex_get('s') + rex_get('w')) . ') '. $this->i18n('search_it_generate_col_done',$count) . '

'; @@ -126,7 +164,7 @@ $str = stripslashes(rex_request('startdirs','string','[]')); $startdirs = explode('","', substr($str, 2, -2)); - $dirs = array(); + $dirs = []; if(!empty($startdirs)){ if(is_array($startdirs)){ diff --git a/pages/generate.php b/pages/generate.php index 986f00e..789fed6 100644 --- a/pages/generate.php +++ b/pages/generate.php @@ -1,14 +1,14 @@ getConfig('indexoffline') ) { $query .= ' WHERE status = 1'; @@ -42,12 +42,25 @@ function search_it_getArticleIds($cats = false) { $js_output = ''; $globalcount = 0; - foreach(search_it_getArticleIds() as $id) { + + foreach(search_it_getArticleIds() as $id) { #$js_output .= 'index("art",'.$id.');'; $js_output .= 'indexArray.push(new Array("art",'.$id.'));'; $globalcount++; } - + + // index url 2 addon URLs + if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { + $url_sql = rex_sql::factory(); + $url_sql->setTable(rex::getTablePrefix() . 'url_generator_url'); + if ($url_sql->select('id')) { + foreach ($url_sql->getArray() as $url) { + $js_output .= 'indexArray.push(new Array("url",'. $url['id'] .'));'; + $globalcount++; + } + } + } + if(!empty($this->getConfig('include')) AND is_array($this->getConfig('include'))) { foreach($this->getConfig('include') as $table=>$columnArray) { $sql = rex_sql::factory(); @@ -87,7 +100,7 @@ function search_it_getArticleIds($cats = false) { if(!empty($this->getConfig('indexfolders')) AND is_array($this->getConfig('indexfolders'))) { foreach($this->getConfig('indexfolders') as $dir) { - foreach(search_it_getFiles($dir, !empty($this->getConfig('fileextensions')) ? $this->getConfig('fileextensions') :array(), true) as $filename) { + foreach(search_it_getFiles($dir, !empty($this->getConfig('fileextensions')) ? $this->getConfig('fileextensions') :[], true) as $filename) { if(!empty($this->getConfig('fileextensions'))) { // extract file-extension $filenameArray = explode('.', $filename); @@ -117,13 +130,15 @@ function search_it_getArticleIds($cats = false) { function index(type,data){ var url; - if(type == 'art') { + if(type === 'art') { url = 'index.php?page=search_it&ajax=generate&do=incremental&type=art&id=' + data; - } else if(type == 'col') { + } else if(type === 'url') { + url = 'index.php?page=search_it&ajax=generate&do=incremental&type=url&id=' + data; + } else if(type === 'col') { url = 'index.php?page=search_it&ajax=generate&do=incremental&type=col&t=' + data[0] + '&c=' + data[1] + '&s=' + data[2] + '&w=' + data[3]; - } else if(type == 'file') { + } else if(type === 'file') { url = 'index.php?page=search_it&ajax=generate&do=incremental&type=file&name=' + data; - } else if(type == 'mediapool') { + } else if(type === 'mediapool') { url = 'index.php?page=search_it&ajax=generate&do=incremental&type=mediapool&name=' + data[0] + '&file_id=' + data[1] + '&category_id=' + data[2]; } @@ -138,13 +153,13 @@ function index(type,data){ h = Math.floor(durationSeconds / 3600); m = Math.floor((durationSeconds - (h * 3600)) / 60); s = (durationSeconds - h * 3600 - m * 60) % 60; - duration = ((''+h).length == 1 ? '0' : '') + h + ':' + ((''+m).length == 1 ? '0' : '') + m + ':' + ((''+s).length == 1 ? '0' : '') + s; + duration = ((''+h).length === 1 ? '0' : '') + h + ':' + ((''+m).length === 1 ? '0' : '') + m + ':' + ((''+s).length === 1 ? '0' : '') + s; average = Math.floor(currentDuration / globalcount * ( - globalcount) / 1000); h = Math.floor(average / 3600); m = Math.floor((average - (h * 3600)) / 60); s = (average - h * 3600 - m * 60) % 60; - timeleft = ((''+h).length == 1 ? '0' : '') + h + ':' + ((''+m).length == 1 ? '0' : '') + m + ':' + ((''+s).length == 1 ? '0' : '') + s; + timeleft = ((''+h).length === 1 ? '0' : '') + h + ':' + ((''+m).length === 1 ? '0' : '') + m + ':' + ((''+s).length === 1 ? '0' : '') + s; jQuery('#search_it_generate_progressbar') .css('background-position',(Math.floor(quotient * maxProgressbarWidth) - 5000) + 'px 0') @@ -153,7 +168,7 @@ function index(type,data){ ' i18n('search_it_generate_timeleft'); ?>' + timeleft + '<'+'/span>' + ' ' + Math.floor(quotient * 100) + '%<'+'/span>'); - if(globalcount == ){ + if(globalcount === ){ jQuery('#search_it_generate_inprogress').hide(); jQuery('#search_it_generate_done').show(); jQuery('#search_it_generate_log').addClass('index-done'); @@ -220,7 +235,6 @@ function index(type,data){ } } - $content = '

'.$this->i18n('search_it_generate_full_text').'

'; $content .= '

' . $this->i18n('search_it_generate_full') . '


'; $content .= '

'.$this->i18n('search_it_generate_incremental_text').'

'; @@ -230,12 +244,10 @@ function index(type,data){ $content .= '

'.$this->i18n('search_it_generate_delete_keywords_text').'

'; $content .= '

' . $this->i18n('search_it_generate_delete_keywords') . '

'; - $content = rex_extension::registerPoint(new rex_extension_point('SEARCH_IT_PAGE_MAINTENANCE',$content)); - + $content = rex_extension::registerPoint(new rex_extension_point('SEARCH_IT_PAGE_MAINTENANCE', $content)); $fragment = new rex_fragment(); $fragment->setVar('title', $this->i18n('search_it_generate_actions_title'), false); $fragment->setVar('body', $content , false); echo $fragment->parse('core/page/section.php'); - } \ No newline at end of file diff --git a/pages/settings.addsources.php b/pages/settings.addsources.php index 01fa89c..2968dbf 100644 --- a/pages/settings.addsources.php +++ b/pages/settings.addsources.php @@ -14,27 +14,27 @@ // aus Komma-Listen arrays machen, bzw. arrays umformen if( !empty($posted_config['fileextensions']) ) { - $fileExtensions = array(); + $fileExtensions = []; foreach(explode(',', $posted_config['fileextensions']) as $fileext) { $fileExtensions[] = trim($fileext); } $posted_config['fileextensions'] = $fileExtensions; } else { - $posted_config['fileextensions'] = array(); + $posted_config['fileextensions'] = []; } if( !empty($posted_config['include']) && is_array($posted_config['include']) ) { - $returnArray = array(); + $returnArray = []; foreach($posted_config['include'] as $include) { $includeArray = explode('`.`',$include); if(!array_key_exists($includeArray[0],$returnArray)) { - $returnArray[$includeArray[0]] = array(); + $returnArray[$includeArray[0]] = []; } $returnArray[$includeArray[0]][] = $includeArray[1]; } $posted_config['include'] = $returnArray; } else { - $posted_config['include'] = array(); + $posted_config['include'] = []; } $changed = array_keys(array_merge(array_diff_assoc(array_map('serialize',$posted_config),array_map('serialize',$this->getConfig())), array_diff_assoc(array_map('serialize',$this->getConfig()),array_map('serialize',$posted_config)))); @@ -67,13 +67,13 @@ $sql_tables = rex_sql::factory(); foreach ( $sql_tables->showTables() as $table ) { if ( false === strpos($table, 'search_it') ) { - $options = array(); + $options = []; $sql_columns = $sql_tables->showColumns($table); sort($sql_columns); foreach ( $sql_columns as $column ) { $options[] = array( 'value' => rex_escape($table . '`.`' . $column['name']), - 'checked' => in_array($column['name'], (!empty($this->getConfig('include')[$table]) AND is_array($this->getConfig('include')[$table])) ? $this->getConfig('include')[$table] : array()), + 'checked' => in_array($column['name'], (!empty($this->getConfig('include')[$table]) AND is_array($this->getConfig('include')[$table])) ? $this->getConfig('include')[$table] : []), 'name' => $column['name'], 'id' => $table . '.' . $column['name'] ); diff --git a/pages/settings.blacklist.php b/pages/settings.blacklist.php index ddcbf35..b78bdbd 100644 --- a/pages/settings.blacklist.php +++ b/pages/settings.blacklist.php @@ -14,7 +14,7 @@ if( !empty($posted_config['blacklist']) ) { $posted_config['blacklist'] = explode(',',$posted_config['blacklist']); } else { - $posted_config['blacklist'] = array(); + $posted_config['blacklist'] = []; } @@ -41,12 +41,12 @@ $content = ''; -$content2 = array(); +$content2 = []; $formElements = []; -$categories = array(); +$categories = []; foreach(search_it_getCategories(false) as $id => $name){ $categories[] = array( 'value' => $id, @@ -54,7 +54,7 @@ 'name' => $name.' ('.$id.')' ); } -$articles = array(); +$articles = []; foreach(search_it_getArticles() as $id => $name){ $articles[] = array( 'value' => $id, diff --git a/pages/settings.mode.php b/pages/settings.mode.php index 15f7e10..9ce96ec 100644 --- a/pages/settings.mode.php +++ b/pages/settings.mode.php @@ -15,6 +15,7 @@ ['indexoffline', 'bool'], ['automaticindex', 'bool'], ['reindex_cols_onforms', 'bool'], + ['index_url_addon', 'bool'], ]); @@ -46,36 +47,49 @@ $content = ''; $content3 = []; +// URL Addon Checkbox +$url_checkbox = []; +if(rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { + $url_checkbox = [ + 'type' => 'checkbox', + 'id' => 'search_it_index_url_addon', + 'name' => 'search_config[index_url_addon]', + 'label' => $this->i18n('search_it_settings_index_url_addon_label'), + 'value' => '1', + 'checked' => $this->getConfig('index_url_addon') + ]; +} $content = search_it_getSettingsFormSection( 'search_it_index', $this->i18n('search_it_settings_title_indexmode'), - array( - array( + [ + [ 'type' => 'checkbox', 'id' => 'search_it_indexoffline', 'name' => 'search_config[indexoffline]', 'label' => $this->i18n('search_it_settings_indexoffline'), 'value' => '1', 'checked' => $this->getConfig('indexoffline') - ), - array( + ], + [ 'type' => 'checkbox', 'id' => 'search_it_automaticindex', 'name' => 'search_config[automaticindex]', 'label' => $this->i18n('search_it_settings_automaticindex_label'), 'value' => '1', 'checked' => $this->getConfig('automaticindex') - ), - array( + ], + [ 'type' => 'checkbox', 'id' => 'search_it_reindex_cols_onforms', 'name' => 'search_config[reindex_cols_onforms]', 'label' => $this->i18n('search_it_settings_reindex_cols_onforms_label'), 'value' => '1', 'checked' => $this->getConfig('reindex_cols_onforms') - ) - ),'edit' + ], + $url_checkbox + ],'edit' ); $content .= search_it_getSettingsFormSection( diff --git a/pages/settings.result.php b/pages/settings.result.php index 04c971b..75f8e84 100644 --- a/pages/settings.result.php +++ b/pages/settings.result.php @@ -22,7 +22,7 @@ $content = ''; -$content2 = array(); +$content2 = []; $formElements = []; diff --git a/pages/test.php b/pages/test.php index 50c2b5f..2954ae3 100644 --- a/pages/test.php +++ b/pages/test.php @@ -72,4 +72,4 @@ echo $content; -echo ""; +echo ""; \ No newline at end of file diff --git a/plugins/autocomplete/lib/autocompleteHandler.php b/plugins/autocomplete/lib/autocompleteHandler.php index 124af86..a068852 100644 --- a/plugins/autocomplete/lib/autocompleteHandler.php +++ b/plugins/autocomplete/lib/autocompleteHandler.php @@ -35,7 +35,7 @@ function execute() { if($result['count'] > 0) { - $ids = array(); + $ids = []; foreach($result['hits'] as $hit) { diff --git a/plugins/documentation/docs/de_de/main_navi.md b/plugins/documentation/docs/de_de/main_navi.md index 94d7de3..618a40f 100644 --- a/plugins/documentation/docs/de_de/main_navi.md +++ b/plugins/documentation/docs/de_de/main_navi.md @@ -17,6 +17,7 @@ - [Erweiterte Suche](module-enhanced.md) - [Mediensuche](module-media_search.md) - [Komplexe Suche](module-complex.md) (in Arbeit) + - [URL Addon (>=2.0) Suche](module-url.md) - [Weitere Beispiele](module-more_enhanced.md) - FAQ - [Tipps zur Konfiguration](howto-setup.md) diff --git a/plugins/documentation/docs/de_de/module-url.md b/plugins/documentation/docs/de_de/module-url.md new file mode 100644 index 0000000..cf64b83 --- /dev/null +++ b/plugins/documentation/docs/de_de/module-url.md @@ -0,0 +1,84 @@ +# Suche über URLs aus dem URL Addon (>= Version 2.0) + +Dieses Suchergebnis-Modul gibt Suchergebnisse aus dem URL Addon 2.0 oder größer aus. Um URLs aus dem URL Addon zu indexieren muss in den Einstellungen die Indexierung der URLs aus dem URL Addon aktiviert sein. + +## Modulausgabe + +``` +'; + + // Init search and execute + $search_it = new search_it(); + $result = $search_it->search($request); + + echo '

Suchergebnisse

'; + if($result['count']) { + + echo '
    '; + foreach($result['hits'] as $hit) { + if($hit['type'] == 'url') { + // url hits + $url_sql = rex_sql::factory(); + $url_sql->setTable(rex::getTablePrefix() . 'url_generator_url'); + $url_sql->setWhere("id = ". $hit['fid']); + if ($url_sql->select('article_id, clang_id, profile_id, data_id, seo')) { + $url_info = json_decode($url_sql->getValue('seo'), true); + $url_profile = \Url\Profile::get($url_sql->getValue('profile_id')); + + // get yrewrite article domain + $hit_server = $server; + if(rex_addon::get('yrewrite')->isAvailable()) { + $hit_domain = rex_yrewrite::getDomainByArticleId($url_sql->getValue('article_id'), $url_sql->getValue('clang_id')); + $hit_server = rtrim($hit_domain->getUrl(), "/"); + } + + $hit_link = $hit_server . rex_getUrl($url_sql->getValue('article_id'), $url_sql->getValue('clang_id'), [$url_profile->getNamespace() => $url_sql->getValue('data_id'), 'search_highlighter' => $request]); + echo '
  • '; + echo ''; + echo ''. $url_info['title'] .''; + echo '
    '; + echo ''. $hit['highlightedtext'] .'
    '; + echo ''.$hit_server.rex_getUrl($url_sql->getValue('article_id'), $url_sql->getValue('clang_id'), [$url_profile->getNamespace() => $url_sql->getValue('data_id')]).''; + echo '
  • '; + } + } + else { + // other hit types + } + } + echo '
'; + } + else if(!$result['count']) { + echo '

Keine Suchergebnisse gefunden.

'; + } + print ""; +} +``` + +## CSS + +Das Sucheingabe-Formular kann beliebig formatiert und mit Klassen ausgezeichnet werden. Das nachfolgende CSS formatiert das oben vorgegebene Beispiel. + +``` + +``` \ No newline at end of file diff --git a/plugins/plaintext/functions/functions_plaintext.php b/plugins/plaintext/functions/functions_plaintext.php index 6fb8340..5abbb34 100644 --- a/plugins/plaintext/functions/functions_plaintext.php +++ b/plugins/plaintext/functions/functions_plaintext.php @@ -25,8 +25,8 @@ function search_it_getPlaintext($_text,$_remove){ case 'regex': // regex if (!empty($pt->getConfig('regex'))) { - $regex = array(); - $replacement = array(); + $regex = []; + $replacement = []; $odd = true; foreach (explode("\n", $pt->getConfig('regex')) as $line) { if ($line != '') { diff --git a/plugins/plaintext/lib/simple_html_dom.php b/plugins/plaintext/lib/simple_html_dom.php index 65e56e6..9513d20 100644 --- a/plugins/plaintext/lib/simple_html_dom.php +++ b/plugins/plaintext/lib/simple_html_dom.php @@ -89,11 +89,11 @@ function str_get_dom($str, $lowercase=true) { class simple_html_dom_node { /*public*/ var $nodetype = HDOM_TYPE_TEXT; /*public*/ var $tag = 'text'; - /*public*/ var $attr = array(); - /*public*/ var $children = array(); - /*public*/ var $nodes = array(); + /*public*/ var $attr = []; + /*public*/ var $children = []; + /*public*/ var $nodes = []; /*public*/ var $parent = null; - /*public*/ var $_ = array(); + /*public*/ var $_ = []; /*private*/ var $dom = null; function __construct($dom) { @@ -266,19 +266,19 @@ function makeup() { // find elements by css selector function find($selector, $idx=null) { $selectors = $this->parse_selector($selector); - if (($count=count($selectors))===0) return array(); - $found_keys = array(); + if (($count=count($selectors))===0) return []; + $found_keys = []; // find each selector for ($c=0; $c<$count; ++$c) { - if (($levle=count($selectors[0]))===0) return array(); - if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); + if (($levle=count($selectors[0]))===0) return []; + if (!isset($this->_[HDOM_INFO_BEGIN])) return []; $head = array($this->_[HDOM_INFO_BEGIN]=>1); // handle descendant selectors, no recursive! for ($l=0; $l<$levle; ++$l) { - $ret = array(); + $ret = []; foreach($head as $k=>$v) { $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k]; $n->seek($selectors[$c][$l], $ret); @@ -295,7 +295,7 @@ function find($selector, $idx=null) { // sort keys ksort($found_keys); - $found = array(); + $found = []; foreach($found_keys as $k=>$v) $found[] = $this->dom->nodes[$k]; @@ -393,8 +393,8 @@ function find($selector, $idx=null) { // tyrant88: fix for PHP 7.3 $pattern = "/([\w\-\:\*]*)(?:\#([\w\-]+)|\.([\w\-]+))?(?:\[@?(!?[\w\-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER); - $selectors = array(); - $result = array(); + $selectors = []; + $result = []; //print_r($matches); foreach ($matches as $m) { @@ -418,7 +418,7 @@ function find($selector, $idx=null) { $result[] = array($tag, $key, $val, $exp, $no_key); if (trim($m[7])===',') { $selectors[] = $result; - $result = array(); + $result = []; } } if (count($result)>0) @@ -488,19 +488,19 @@ function previousSibling() {return $this->prev_sibling();} // remove elements by css selector function remove($selector) { $selectors = $this->parse_selector($selector); - if (($count=count($selectors))===0) return array(); - $found_keys = array(); + if (($count=count($selectors))===0) return []; + $found_keys = []; // find each selector for ($c=0; $c<$count; ++$c) { - if (($levle=count($selectors[0]))===0) return array(); - if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); + if (($levle=count($selectors[0]))===0) return []; + if (!isset($this->_[HDOM_INFO_BEGIN])) return []; $head = array($this->_[HDOM_INFO_BEGIN]=>1); // handle descendant selectors, no recursive! for ($l=0; $l<$levle; ++$l) { - $ret = array(); + $ret = []; foreach($head as $k=>$v) { $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k]; $n->seek($selectors[$c][$l], $ret); @@ -517,7 +517,7 @@ function remove($selector) { // sort keys ksort($found_keys); - $found = array(); + $found = []; foreach($found_keys as $k=>$v) $this->dom->nodes[$k]->outertext = ''; } @@ -527,7 +527,7 @@ function remove($selector) { // ----------------------------------------------------------------------------- class simple_html_dom { /*public*/ var $root = null; - /*public*/ var $nodes = array(); + /*public*/ var $nodes = []; /*public*/ var $callback = null; /*public*/ var $lowercase = false; /*protected*/ var $pos; @@ -536,7 +536,7 @@ class simple_html_dom { /*protected*/ var $size; /*protected*/ var $cursor; /*protected*/ var $parent; - /*protected*/ var $noise = array(); + /*protected*/ var $noise = []; /*protected*/ var $token_blank = " \t\r\n"; /*protected*/ var $token_equal = ' =/>'; /*protected*/ var $token_slash = " />\r\n\t"; @@ -643,8 +643,8 @@ function dump($show_attr=true) { $this->doc = $str; $this->pos = 0; $this->cursor = 1; - $this->noise = array(); - $this->nodes = array(); + $this->noise = []; + $this->nodes = []; $this->lowercase = $lowercase; $this->root = new simple_html_dom_node($this); $this->root->tag = 'root'; @@ -820,7 +820,7 @@ function dump($show_attr=true) { if($this->doc[$this->pos-1]=='<') { $node->nodetype = HDOM_TYPE_TEXT; $node->tag = 'text'; - $node->attr = array(); + $node->attr = []; $node->_[HDOM_INFO_END] = 0; $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1); $this->pos -= 2; diff --git a/plugins/plaintext/pages/index.php b/plugins/plaintext/pages/index.php index dbf21c9..eb88b64 100644 --- a/plugins/plaintext/pages/index.php +++ b/plugins/plaintext/pages/index.php @@ -43,7 +43,7 @@ } -$content = array(); +$content = []; $content[] = search_it_getSettingsFormSection( diff --git a/plugins/stats/images/general_timestats.inc.php b/plugins/stats/images/general_timestats.inc.php index 68d09f2..eb83c59 100644 --- a/plugins/stats/images/general_timestats.inc.php +++ b/plugins/stats/images/general_timestats.inc.php @@ -7,8 +7,8 @@ // fetch data -$bardata = array(); -$cumulateddata = array(); +$bardata = []; +$cumulateddata = []; $statCounts = $stats->getCount(); $max = 1; diff --git a/plugins/stats/images/phplot/contrib/color_range.example.php b/plugins/stats/images/phplot/contrib/color_range.example.php index 7659fd2..3f6524d 100644 --- a/plugins/stats/images/phplot/contrib/color_range.example.php +++ b/plugins/stats/images/phplot/contrib/color_range.example.php @@ -10,7 +10,7 @@ $x_values = 4; mt_srand(1); -$data = array(); +$data = []; for ($i = 0; $i < $x_values; $i++) { $row = array($i); for ($j = 0; $j < $bars_per_group; $j++) $row[] = mt_rand(0, 100); diff --git a/plugins/stats/images/phplot/contrib/data_table.example2.php b/plugins/stats/images/phplot/contrib/data_table.example2.php index d27d600..8007a91 100644 --- a/plugins/stats/images/phplot/contrib/data_table.example2.php +++ b/plugins/stats/images/phplot/contrib/data_table.example2.php @@ -4,7 +4,7 @@ require_once 'phplot.php'; require_once 'data_table.php'; -$data = array(); +$data = []; for ($i = 0; $i < 20; $i++) $data[] = array('', $i, 2 * $i, $i * $i); diff --git a/plugins/stats/images/phplot/contrib/prune_labels.example.php b/plugins/stats/images/phplot/contrib/prune_labels.example.php index 99430c3..e32d4c1 100644 --- a/plugins/stats/images/phplot/contrib/prune_labels.example.php +++ b/plugins/stats/images/phplot/contrib/prune_labels.example.php @@ -8,7 +8,7 @@ require_once 'prune_labels.php'; $base = mktime(12, 0, 0, 1, 1, 2000); -$data = array(); +$data = []; for ($i = 0; $i < 250; $i++) { $data[] = array(86400 * $i + $base, $i, $i * 0.20); } diff --git a/plugins/stats/images/phplot/contrib/prune_labels.test.php b/plugins/stats/images/phplot/contrib/prune_labels.test.php index c2bf2a2..f65f394 100644 --- a/plugins/stats/images/phplot/contrib/prune_labels.test.php +++ b/plugins/stats/images/phplot/contrib/prune_labels.test.php @@ -9,7 +9,7 @@ function test($count, $maxlabels) { # Make an array of count records, like PHPlot uses, with labels: - $data = array(); + $data = []; for ($i = 0; $i < $count; $i++) { $data[] = array("Row $i", $i, 100, 200, 300); } diff --git a/plugins/stats/images/phplot/phplot.php b/plugins/stats/images/phplot/phplot.php index 0a1c5c3..ddfc00e 100644 --- a/plugins/stats/images/phplot/phplot.php +++ b/plugins/stats/images/phplot/phplot.php @@ -152,7 +152,7 @@ class PHPlot static protected $datatypes = array( // See DecodeDataType() and $datatype_* flags 'text-data' => array('implied' => TRUE), 'text-data-single' => array('implied' => TRUE, 'pie_single' => TRUE), - 'data-data' => array(), + 'data-data' => [], 'data-data-error' => array('error_bars' => TRUE), 'data-data-yx' => array('swapped_xy' => TRUE), 'text-data-yx' => array('implied' => TRUE, 'swapped_xy' => TRUE), @@ -179,7 +179,7 @@ class PHPlot /** Default TrueType font file */ protected $default_ttfont; /** Array of flags for elements that must be drawn at most once */ - protected $done = array(); + protected $done = []; /** Flag: How to handle missing Y values */ protected $draw_broken_lines = FALSE; /** Flag: Draw data borders, available with some plot types */ @@ -233,7 +233,7 @@ class PHPlot /** Flag: don't send headers */ protected $is_inline = FALSE; /** Label format info */ - protected $label_format = array('x' => array(), 'xd' => array(), 'y' => array(), 'yd' => array()); + protected $label_format = array('x' => [], 'xd' => [], 'y' => [], 'yd' => []); /** Pie chart label position factor */ protected $label_scale_position = 0.5; /** Legend text array */ @@ -830,7 +830,7 @@ protected function GetColorIndex(&$color, $default_color_index = 0) protected function GetColorIndexArray($color_array, $max_colors) { $n = min(count($color_array), $max_colors); - $result = array(); + $result = []; for ($i = 0; $i < $n; $i++) $result[] = $this->GetColorIndex($color_array[$i]); return $result; @@ -849,7 +849,7 @@ protected function GetColorIndexArray($color_array, $max_colors) protected function GetDarkColorIndexArray($color_array, $max_colors) { $n = min(count($color_array), $max_colors); - $result = array(); + $result = []; for ($i = 0; $i < $n; $i++) $result[] = $this->GetDarkColorIndex($color_array[$i]); return $result; @@ -1278,7 +1278,7 @@ function SetDataColors($which_data = NULL, $which_border = NULL, $alpha = NULL) // Check each color and convert to array (r,g,b,a) form. // Use the $alpha argument as a default for the alpha value of each color. - $this->data_colors = array(); + $this->data_colors = []; foreach ($colors as $color) { $color_array = $this->SetRGBColor($color, $alpha); if (!$color_array) return FALSE; // SetRGBColor already did an error message. @@ -1314,7 +1314,7 @@ function SetDataBorderColors($which_br = NULL) } // Check each color and convert to array (r,g,b,a) form. - $this->data_border_colors = array(); + $this->data_border_colors = []; foreach ($colors as $color) { $color_array = $this->SetRGBColor($color); if (!$color_array) return FALSE; // SetRGBColor already did an error message. @@ -1346,7 +1346,7 @@ function SetErrorBarColors($which_err = NULL) } // Check each color and convert to array (r,g,b,a) form. - $this->error_bar_colors = array(); + $this->error_bar_colors = []; foreach ($colors as $color) { $color_array = $this->SetRGBColor($color); if (!$color_array) return FALSE; // SetRGBColor already did an error message. @@ -2488,7 +2488,7 @@ function PrintImageFrame() echo $this->stream_frame_header, "Content-Length: $size\r\n\r\n", $frame, "\r\n"; flush(); // This gets the next DrawGraph() to do background and titles again. - $this->done = array(); + $this->done = []; return TRUE; } @@ -2866,7 +2866,7 @@ protected function CheckOption($which_opt, $which_acc, $which_func) protected function CheckOptionArray($opt, $acc, $func) { $opt_array = (array)$opt; - $result = array(); + $result = []; foreach ($opt_array as $option) { $choice = $this->CheckOption($option, $acc, $func); if (is_null($choice)) return NULL; // In case CheckOption error handler returns @@ -3495,8 +3495,8 @@ function SetDataValues($which_dv) { $this->num_data_rows = count($which_dv); $this->total_records = 0; - $this->data = array(); - $this->num_recs = array(); + $this->data = []; + $this->num_recs = []; for ($i = 0; $i < $this->num_data_rows; $i++) { if (!isset($which_dv[$i]) || !is_array($which_dv[$i])) { return $this->PrintError("SetDataValues(): Invalid data array (row $i)"); @@ -3930,15 +3930,15 @@ protected function FindDataLimits() $abs_vals = !empty(self::$plots[$this->plot_type]['abs_vals']); // Take absolute values // Initialize arrays which track the min/max per-row dependent values: - $this->data_min = array(); - $this->data_max = array(); + $this->data_min = []; + $this->data_max = []; // Independent values are in the data array or assumed? if ($this->datatype_implied) { // Range for text-data is 0.5 to num_data_rows-0.5. Add 0.5 fixed margins on each side. $all_iv = array(0, $this->num_data_rows); } else { - $all_iv = array(); // Calculated below + $all_iv = []; // Calculated below } // For X/Y/Z plots, make sure these are not left over from a previous plot. if ($this->datatype_yz) @@ -3956,7 +3956,7 @@ protected function FindDataLimits() if ($sum_vals) { $all_dv = array(0, 0); // One limit is 0, other calculated below } else { - $all_dv = array(); + $all_dv = []; } while ($j < $n_vals) { if (is_numeric($val = $this->data[$i][$j++])) { @@ -6404,7 +6404,7 @@ protected function DrawYDataLine($ypos, $row) */ protected function FormatPieLabel($index, $pie_label_source, $arc_angle, $slice_weight) { - $values = array(); // Builds up label value, one field at a time. + $values = []; // Builds up label value, one field at a time. foreach ($pie_label_source as $word) { switch ($word) { case 'label': // Use label from data array, but only if data type is compatible @@ -6490,7 +6490,7 @@ function SetLegend($which_leg) if (is_array($which_leg)) { // use array (or cancel, if empty array) $this->legend = $which_leg; } elseif (!is_null($which_leg)) { // append string - if (!isset($this->legend)) $this->legend = array(); // Seems unnecessary, but be safe. + if (!isset($this->legend)) $this->legend = []; // Seems unnecessary, but be safe. $this->legend[] = $which_leg; } else { $this->legend = NULL; // Reset to no legend. @@ -7292,8 +7292,8 @@ protected function CheckPieLabels() */ protected function SetupAreaPlot($stacked, &$xd, &$yd) { - $xd = array(); - $yd = array(); + $xd = []; + $yd = []; // Outer loop over rows (X); inner over columns (Y): for ($row = 0; $row < $this->num_data_rows; $row++) { @@ -7316,7 +7316,7 @@ protected function SetupAreaPlot($stacked, &$xd, &$yd) if ($stacked) $yd[$row] = array($this->x_axis_y_pixels); else - $yd[$row] = array(); + $yd[$row] = []; // Store the Y values for this X. Missing Y values are not supported, and are replaced with 0. // Negative numbers are not supported, and are replaced with absolute values. @@ -7491,7 +7491,7 @@ protected function DrawPieChart() $label_max_width = 0; // Widest label width, in pixels $label_max_height = 0; // Tallest label height, in pixels if ($do_labels) { - $labels = array(); // Array to store the formatted label strings + $labels = []; // Array to store the formatted label strings $end_angle = $start_angle = $this->pie_start_angle; for ($j = 0; $j < $num_slices; $j++) { $slice_weight = $sumarr[$j]; @@ -7664,7 +7664,7 @@ protected function DrawDots($paired = FALSE) // Adjust the point shapes and point sizes arrays: $this->CheckPointParams(); - $gcvars = array(); // For GetDataColor, which initializes and uses this. + $gcvars = []; // For GetDataColor, which initializes and uses this. // Special flag for data color callback to indicate the 'points' part of 'linepoints': $alt_flag = $paired ? 1 : 0; @@ -7758,7 +7758,7 @@ protected function DrawThinBarLines() if (!$this->CheckDataType('text-data, data-data, text-data-yx, data-data-yx')) return FALSE; - $gcvars = array(); // For GetDataColor, which initializes and uses this. + $gcvars = []; // For GetDataColor, which initializes and uses this. for ($row = 0; $row < $this->num_data_rows; $row++) { $rec = 1; // Skip record #0 (data label) @@ -7843,7 +7843,7 @@ protected function DrawArea($do_stacked = FALSE) // number of entries in the yd[] arrays is data_columns+1. $prev_col = 0; for ($col = 1; $col < $n_columns; $col++) { // 1 extra for X axis artificial column - $pts = array(); + $pts = []; // Previous data set forms top (for area) or bottom (for stackedarea): for ($row = 0; $row < $n_rows; $row++) { array_push($pts, $xd[$row], $yd[$row][$prev_col]); @@ -7892,7 +7892,7 @@ protected function DrawLines($paired = FALSE) if ($this->data_columns > 0) $start_lines = array_fill(0, $this->data_columns, FALSE); - $gcvars = array(); // For GetDataColor, which initializes and uses this. + $gcvars = []; // For GetDataColor, which initializes and uses this. // Data labels, Data Value Labels? if ($this->datatype_swapped_xy) { @@ -8035,7 +8035,7 @@ protected function DrawSquared() if ($this->data_columns > 0) $start_lines = array_fill(0, $this->data_columns, FALSE); - $gcvars = array(); // For GetDataColor, which initializes and uses this. + $gcvars = []; // For GetDataColor, which initializes and uses this. // Data Value Labels? $do_dvls = $this->CheckDataValueLabels($this->y_data_label_pos, $dvl); @@ -8180,7 +8180,7 @@ protected function DrawBars() // in the group. See also CalcBarWidths above. $x_first_bar = ($this->data_columns * $this->record_bar_width) / 2 - $this->bar_adjust_gap; - $gcvars = array(); // For GetBarColors, which initializes and uses this. + $gcvars = []; // For GetBarColors, which initializes and uses this. for ($row = 0; $row < $this->num_data_rows; $row++) { $record = 1; // Skip record #0 (data label) @@ -8249,7 +8249,7 @@ protected function DrawHorizBars() // in the group. See also CalcBarWidths above. $y_first_bar = ($this->data_columns * $this->record_bar_width) / 2 - $this->bar_adjust_gap; - $gcvars = array(); // For GetBarColors, which initializes and uses this. + $gcvars = []; // For GetBarColors, which initializes and uses this. for ($row = 0; $row < $this->num_data_rows; $row++) { $record = 1; // Skip record #0 (data label) @@ -8322,7 +8322,7 @@ protected function DrawStackedBars() // This is the X offset from the bar's label center point to the left side of the bar. $x_first_bar = $this->record_bar_width / 2 - $this->bar_adjust_gap; - $gcvars = array(); // For GetBarColors, which initializes and uses this. + $gcvars = []; // For GetBarColors, which initializes and uses this. // Determine if any data labels are on: $data_labels_within = ($this->y_data_label_pos == 'plotstack'); @@ -8432,7 +8432,7 @@ protected function DrawHorizStackedBars() // This is the Y offset from the bar's label center point to the bottom of the bar $y_first_bar = $this->record_bar_width / 2 - $this->bar_adjust_gap; - $gcvars = array(); // For GetBarColors, which initializes and uses this. + $gcvars = []; // For GetBarColors, which initializes and uses this. // Determine if any data labels are on: $data_labels_within = ($this->x_data_label_pos == 'plotstack'); @@ -8559,7 +8559,7 @@ protected function DrawOHLC($draw_candles, $always_fill = FALSE) // Get line widths to use: index 0 for body/stroke, 1 for wick/tick. list($body_thickness, $wick_thickness) = $this->line_widths; - $gcvars = array(); // For GetDataColor, which initializes and uses this. + $gcvars = []; // For GetDataColor, which initializes and uses this. for ($row = 0; $row < $this->num_data_rows; $row++) { $record = 1; // Skip record #0 (data label) @@ -8660,7 +8660,7 @@ protected function DrawBubbles() if (!$this->CheckDataType('data-data-xyz')) return FALSE; - $gcvars = array(); // For GetDataColor, which initializes and uses this. + $gcvars = []; // For GetDataColor, which initializes and uses this. // Calculate or use supplied maximum bubble size: if (isset($this->bubbles_max_size)) { @@ -8738,7 +8738,7 @@ protected function DrawBoxes() // A box plot can use up to 3 different line widths: list($box_thickness, $belt_thickness, $whisker_thickness) = $this->line_widths; - $gcvars = array(); // For GetDataColor, which initializes and uses this. + $gcvars = []; // For GetDataColor, which initializes and uses this. for ($row = 0; $row < $this->num_data_rows; $row++) { $record = 1; // Skip record #0 (data label) @@ -8762,7 +8762,7 @@ protected function DrawBoxes() } // Collect the 5 primary Y values, plus any outliers: - $yd = array(); // Device coords + $yd = []; // Device coords for ($i = 0; $i < $num_y; $i++) { $yd[$i] = is_numeric($y = $this->data[$row][$record++]) ? $this->ytr($y) : NULL; } @@ -8832,7 +8832,7 @@ function DrawGraph() // Load some configuration values from the array of plot types: $pt = &self::$plots[$this->plot_type]; // Use reference for shortcut $draw_method = $pt['draw_method']; - $draw_arg = isset($pt['draw_arg']) ? $pt['draw_arg'] : array(); + $draw_arg = isset($pt['draw_arg']) ? $pt['draw_arg'] : []; $draw_axes = empty($pt['suppress_axes']); // Allocate colors for the plot: diff --git a/plugins/stats/images/searchterm_timestats.inc.php b/plugins/stats/images/searchterm_timestats.inc.php index 300e917..b481bec 100644 --- a/plugins/stats/images/searchterm_timestats.inc.php +++ b/plugins/stats/images/searchterm_timestats.inc.php @@ -16,8 +16,8 @@ require_once $curDir . '/phplot/phplot.php'; // fetch data -$bardata = array(); -$cumulateddata = array(); +$bardata = []; +$cumulateddata = []; $max = 1; foreach ( $stats->getTimestats($term, $this->getConfig('searchtermselectmonthcount')) as $month) { diff --git a/plugins/stats/lib/stats.php b/plugins/stats/lib/stats.php index 7b1e9b2..418178a 100644 --- a/plugins/stats/lib/stats.php +++ b/plugins/stats/lib/stats.php @@ -53,7 +53,7 @@ function getTopSearchterms($_count, $_getonly = 0){ ); if (empty($return)) { - $return = array(); + $return = []; } return $return; @@ -80,12 +80,12 @@ function getCount($_count = 6){ $this->sql->setWhere('1 GROUP BY y, m ORDER BY y DESC, m DESC LIMIT ' . $_count); $this->sql->select('COUNT( * ) AS count, YEAR(`time`) AS y, MONTH(`time`) AS m'); - $tmp = array(); + $tmp = []; foreach ($this->sql->getArray() as $month) { $tmp[intval($month['y']) . '-' . intval($month['m'])] = $month; } - $return = array(); + $return = []; $y = intval(date('Y')); for ($i = intval(date('n')) - 1, $k = 0; $k < $_count; $i = ($i + 11) % 12, $k++) { if (array_key_exists($y . '-' . ($i + 1), $tmp)) { @@ -121,12 +121,12 @@ function getTimestats($_term = '', $_count = 12){ $this->sql->setWhere(sprintf('%s GROUP BY y, m ORDER BY y DESC, m DESC LIMIT %d', $where, $_count)); $this->sql->select('COUNT( * ) AS count, YEAR(`time`) AS y, MONTH(`time`) AS m'); - $tmp = array(); + $tmp = []; foreach ($this->sql->getArray() as $month) { $tmp[intval($month['y']) . '-' . intval($month['m'])] = $month; } - $return = array(); + $return = []; $y = intval(date('Y')); for ($i = intval(date('n')) - 1, $k = 0; $k < $_count; $i = ($i + 11) % 12, $k++) { if (array_key_exists($y . '-' . ($i + 1), $tmp)) { diff --git a/plugins/stats/pages/index.php b/plugins/stats/pages/index.php index af9430e..c64caaf 100644 --- a/plugins/stats/pages/index.php +++ b/plugins/stats/pages/index.php @@ -36,7 +36,7 @@ } -$content = array(); +$content = []; $content[] = search_it_getSettingsFormSection( 'search_it_stats_description', From 0e022e52edd0c3380bc4f96d3e464330b459f9c5 Mon Sep 17 00:00:00 2001 From: tobias Date: Sat, 28 Mar 2020 16:35:39 +0100 Subject: [PATCH 02/27] correct version --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 053afda..ebb28fe 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,8 @@ Search it basiert auf [RexSearch (Xong) für REDAXO 4](https://github.com/xong/r ## Systemvoraussetzungen -* `PHP >= 5.5` -* `MySQL >= 5.1` -* `REDAXO >= 5.3` +* `PHP ^7` +* `REDAXO >= 5.10` ## Plugins @@ -39,4 +38,4 @@ Die Tabellen werden nicht in die Datenbank-Sicherung des backup-Addons miteinbez ## First Steps -Nach der Installation sollten zunächst die Einstellungen vorgenommen werden und anschließend der Index vollständig generiert werden. +Nach der Installation sollten zunächst die Einstellungen vorgenommen werden und anschließend der Index vollständig generiert werden. \ No newline at end of file From c4a06b4d4a3526e3d99fdc79f3ea4b53e353d7f1 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Sat, 28 Mar 2020 16:53:48 +0100 Subject: [PATCH 03/27] add changlog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8133b9a..489e660 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Änderungen von search_it +- URLs aus dem URL Addon (>= 2.0) können indexiert werden. - bei schrittweiser Indexierung sind die Artikel in der Ausgabe verlinkt - minimale PHP Version ergänzt @staabm - install.sql -> install.php From 3aa6dfa04541b905ed417ee54130ab1a97315cc4 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Sat, 28 Mar 2020 18:04:23 +0100 Subject: [PATCH 04/27] add "tmp_" table prefix to url addon tabel --- lib/search_it.php | 14 +++++++------- pages/ajax.php | 2 +- pages/generate.php | 2 +- plugins/documentation/docs/de_de/module-url.md | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/search_it.php b/lib/search_it.php index 33a0e5a..6f5673a 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -146,7 +146,7 @@ public function generateIndex() // index url 2 addon URLs if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { $url_sql = rex_sql::factory(); - $url_sql->setTable($this->tablePrefix . 'url_generator_url'); + $url_sql->setTable($this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { foreach ($url_sql->getArray() as $url) { $returns = $this->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); @@ -385,7 +385,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $keywords = []; $delete = rex_sql::factory(); - $where = "ftable = '". $this->tablePrefix . "url_generator_url' AND fid = ". $id ." AND clang = ". $clang_id; + $where = "ftable = '". $this->tablePrefix . \rex::getTempPrefix() . "url_generator_url' AND fid = ". $id ." AND clang = ". $clang_id; // delete from cache $select = rex_sql::factory(); $select->setTable($this->tempTablePrefix . 'search_it_index'); @@ -487,7 +487,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $articleData = []; $articleData['texttype'] = 'url'; - $articleData['ftable'] = $this->tablePrefix . 'url_generator_url'; + $articleData['ftable'] = $this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'; $articleData['fcolumn'] = NULL; $articleData['clang'] = $clang_id; $articleData['fid'] = intval($id); @@ -496,13 +496,13 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $plaintext = $this->getPlaintext($articleText); $articleData['plaintext'] = $plaintext; - if (array_key_exists($this->tablePrefix . 'url_generator_url', $this->includeColumns)) { + if (array_key_exists($this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url', $this->includeColumns)) { $additionalValues = []; $select->flushValues(); - $select->setTable($this->tablePrefix . 'url_generator_url'); + $select->setTable($this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'); $select->setWhere('id = ' . $id . ' AND clang_id = ' . $clang_id); - $select->select('`' . implode('`,`', $this->includeColumns[$this->tablePrefix . 'url_generator_url']) . '`'); - foreach ($this->includeColumns[$this->tablePrefix . 'url_generator_url'] as $col) { + $select->select('`' . implode('`,`', $this->includeColumns[$this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url']) . '`'); + foreach ($this->includeColumns[$this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'] as $col) { if ( $select->hasValue($col) ) { $additionalValues[$col] = $select->getValue($col); } } diff --git a/pages/ajax.php b/pages/ajax.php index 4665c30..f66d098 100644 --- a/pages/ajax.php +++ b/pages/ajax.php @@ -44,7 +44,7 @@ case 'url': $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . 'url_generator_url'); + $url_sql->setTable(rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); $url_sql->setWhere("id = ". rex_get('id')); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id, seo, url')) { if($url_sql->getValue('id') > 0) { diff --git a/pages/generate.php b/pages/generate.php index 789fed6..cfddf15 100644 --- a/pages/generate.php +++ b/pages/generate.php @@ -52,7 +52,7 @@ function search_it_getArticleIds($cats = false) { // index url 2 addon URLs if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . 'url_generator_url'); + $url_sql->setTable(rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); if ($url_sql->select('id')) { foreach ($url_sql->getArray() as $url) { $js_output .= 'indexArray.push(new Array("url",'. $url['id'] .'));'; diff --git a/plugins/documentation/docs/de_de/module-url.md b/plugins/documentation/docs/de_de/module-url.md index cf64b83..2b6fb35 100644 --- a/plugins/documentation/docs/de_de/module-url.md +++ b/plugins/documentation/docs/de_de/module-url.md @@ -26,7 +26,7 @@ if($request) { // Wenn ein Suchbegriff eingegeben wurde if($hit['type'] == 'url') { // url hits $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . 'url_generator_url'); + $url_sql->setTable(rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); $url_sql->setWhere("id = ". $hit['fid']); if ($url_sql->select('article_id, clang_id, profile_id, data_id, seo')) { $url_info = json_decode($url_sql->getValue('seo'), true); From 131b2e9e7352a6024ab9e5d36988e18f29993ad5 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Sat, 28 Mar 2020 21:52:45 +0100 Subject: [PATCH 05/27] index url addon urls in cronjob --- lang/de_de.lang | 1 + lang/en_gb.lang | 1 + lang/es_es.lang | 1 + lang/pt_br.lang | 1 + lang/sv_se.lang | 1 + lib/cronjob.php | 16 +++++++++++++++- 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lang/de_de.lang b/lang/de_de.lang index 67989c2..6e56980 100644 --- a/lang/de_de.lang +++ b/lang/de_de.lang @@ -97,6 +97,7 @@ search_it_generate_duration = Dauer: search_it_generate_timeleft = Verbleibend: search_it_generate_articles = Artikel neu-indexieren search_it_generate_columns = Tabellen neu-indexieren +search_it_generate_urls = URLs aus URL Addon neu-indexieren search_it_generate_article_excluded = nicht indexiert, Artikel wurde ausgeschlossen search_it_generate_article_done = indexiert diff --git a/lang/en_gb.lang b/lang/en_gb.lang index a1160fd..30f77e5 100644 --- a/lang/en_gb.lang +++ b/lang/en_gb.lang @@ -97,6 +97,7 @@ search_it_generate_duration = Time: search_it_generate_timeleft = Remaining: search_it_generate_articles = reindex articles search_it_generate_columns = reindex tables +search_it_generate_urls = reindex url addon urls search_it_generate_article_excluded = not indexed, article was excluded search_it_generate_article_done = indexed diff --git a/lang/es_es.lang b/lang/es_es.lang index 45a8e90..4ce2d01 100644 --- a/lang/es_es.lang +++ b/lang/es_es.lang @@ -97,6 +97,7 @@ search_it_generate_duration = Duración: search_it_generate_timeleft = Restante: search_it_generate_articles = Re-indexar artículos search_it_generate_columns = Re-index tables +search_it_generate_urls = reindex url addon urls search_it_generate_article_excluded = No indexado, el artículo fue excluido search_it_generate_article_done = indexado diff --git a/lang/pt_br.lang b/lang/pt_br.lang index 72fef77..c39a993 100644 --- a/lang/pt_br.lang +++ b/lang/pt_br.lang @@ -97,6 +97,7 @@ search_it_generate_duration = Tempo: search_it_generate_timeleft = Faltante: search_it_generate_articles = Re-indexar artigos search_it_generate_columns = Re-indexar tabelas +search_it_generate_urls = reindex url addon urls search_it_generate_article_excluded = not indexed, article was excluded search_it_generate_article_done = indexed diff --git a/lang/sv_se.lang b/lang/sv_se.lang index 25e4222..c0ee126 100644 --- a/lang/sv_se.lang +++ b/lang/sv_se.lang @@ -97,6 +97,7 @@ search_it_generate_duration = Tid: search_it_generate_timeleft = Förblivande tid: search_it_generate_articles = Nyindexera artiklar search_it_generate_columns = Nyindexera tabeller +search_it_generate_urls = reindex url addon urls search_it_generate_article_excluded = not indexed, article was excluded search_it_generate_article_done = indexed diff --git a/lib/cronjob.php b/lib/cronjob.php index 95e0253..6fd5d94 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -32,6 +32,19 @@ public function execute() } break; + case 3: + // URLs neu indexieren + if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { + $url_sql = rex_sql::factory(); + $url_sql->setTable($this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'); + if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { + foreach ($url_sql->getArray() as $url) { + $search_it->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); + } + } + } + break; + case 1: default: $search_it->generateIndex(); @@ -58,7 +71,8 @@ public function getParamFields() 'options' => [ 1 => rex_i18n::msg('search_it_generate_full'), 2 => rex_i18n::msg('search_it_generate_columns'), - 3 => rex_i18n::msg('search_it_generate_articles')], + 3 => rex_i18n::msg('search_it_generate_articles'), + 4 => rex_i18n::msg('search_it_generate_urls')], 'default' => '1', 'notice' => rex_i18n::msg('search_it_generate_actions_title'), ], From 797a8dc5b703c6bff1747873969178bf28cc5839 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Sat, 28 Mar 2020 21:58:53 +0100 Subject: [PATCH 06/27] index url addon urls in cronjob --- lib/cronjob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cronjob.php b/lib/cronjob.php index 6fd5d94..dc5056d 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -32,7 +32,7 @@ public function execute() } break; - case 3: + case 4: // URLs neu indexieren if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { $url_sql = rex_sql::factory(); From 82ff8768390673a3f0e1af3127a839e2d7c0a570 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Sun, 29 Mar 2020 08:20:23 +0200 Subject: [PATCH 07/27] index url addon urls in cronjob --- lib/cronjob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cronjob.php b/lib/cronjob.php index dc5056d..242cc83 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -36,7 +36,7 @@ public function execute() // URLs neu indexieren if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { $url_sql = rex_sql::factory(); - $url_sql->setTable($this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'); + $url_sql->setTable(\rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { foreach ($url_sql->getArray() as $url) { $search_it->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); From d1f736b6f84257c530828a9fbaa8c45fba00a910 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Sun, 29 Mar 2020 18:28:54 +0200 Subject: [PATCH 08/27] delete index before index regeneration --- lib/cronjob.php | 2 ++ lib/search_it.php | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/cronjob.php b/lib/cronjob.php index 242cc83..da3c227 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -38,6 +38,8 @@ public function execute() $url_sql = rex_sql::factory(); $url_sql->setTable(\rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { + // index und cache zuerst löschen, damit keine alten Einträge überleben + $search_it->deleteIndexForType("url"); foreach ($url_sql->getArray() as $url) { $search_it->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); } diff --git a/lib/search_it.php b/lib/search_it.php index 6f5673a..6fa65da 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -1006,7 +1006,8 @@ private static function getMaxFID($_table) return ($maxfid > 0) ? ++$maxfid : 1; } - /** + + /** * Deletes the complete search index. * */ @@ -1018,6 +1019,24 @@ public function deleteIndex() $this->deleteCache(); } + /** + * Deletes the search index for given type + * @param string $texttype Index text type + */ + public function deleteIndexForType($texttype) + { + $sql = rex_sql::factory(); + $query = 'SELECT id FROM '. $this->tempTablePrefix .'search_it_index WHERE texttype = "'. $texttype .'";'; + $deleteIds = []; + foreach ($sql->getArray($query) as $cacheId) { + $deleteIds[] = $cacheId['id']; + } + // Delete index + $sql->setQuery('DELETE FROM '. $this->tempTablePrefix .'search_it_index WHERE texttype = "'. $texttype .'"'); + // Delete cache + $this->deleteCache($deleteIds); + } + /** * Exclude Articles with the transfered IDs. * From cd723d84ad8b82f87eed583073af612caee19c90 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Sun, 29 Mar 2020 21:41:29 +0200 Subject: [PATCH 09/27] mutlidomain support --- lib/search_it.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/search_it.php b/lib/search_it.php index 6fa65da..a854fb9 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -130,7 +130,7 @@ public function generateIndex() $this->deleteIndex(); $this->deleteCache(); - // index articles + // index articles $global_return = 0; $art_sql = rex_sql::factory(); $art_sql->setTable($this->tablePrefix . 'article'); @@ -140,7 +140,7 @@ public function generateIndex() foreach ( $returns as $return ) { if ($return > 3 ) { $global_return += $return; } } - } + } } // index url 2 addon URLs @@ -414,12 +414,16 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $server = rtrim(rex::getServer(), "/"); $search_it_build_index = "do-it"; if(rex_addon::get('yrewrite')->isAvailable()) { - $hit_domain = rex_yrewrite::getDomainByArticleId($hit['fid'], $hit['clang']); + $hit_domain = rex_yrewrite::getDomainByArticleId($article_id, $clang_id); $server = rtrim($hit_domain->getUrl(), "/"); $search_it_build_index = "do-it-with-yrewrite"; } - $scanurl = $server .'/'. ltrim(str_replace(['../', './'], '', rex_getUrl($article_id, $clang_id, [$url_profile->getNamespace() => $data_id, 'search_it_build_index' => $search_it_build_index],'&')),"/"); + $scanurl = rex_getUrl($article_id, $clang_id, [$url_profile->getNamespace() => $data_id, 'search_it_build_index' => $search_it_build_index],'&'); + if(strpos($scanurl, 'http') === false) { + // URL addon multidomain site return server name in url + $scanurl = $server .'/'. ltrim(str_replace(['../', './'], '', $scanurl),"/"); + } $files_socket = rex_socket::factoryURL($scanurl); if (rex_addon::get('search_it')->getConfig('htaccess_user') != '' && rex_addon::get('search_it')->getConfig('htaccess_pass') != '') { From fc298411191baabe264bf1ed4f8da4455fcab779 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Tue, 31 Mar 2020 07:31:57 +0200 Subject: [PATCH 10/27] add correct temp prefix --- lib/search_it.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/search_it.php b/lib/search_it.php index a854fb9..c7ac3bc 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -146,7 +146,7 @@ public function generateIndex() // index url 2 addon URLs if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { $url_sql = rex_sql::factory(); - $url_sql->setTable($this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'); + $url_sql->setTable($this->tempTablePrefix . 'url_generator_url'); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { foreach ($url_sql->getArray() as $url) { $returns = $this->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); @@ -385,7 +385,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $keywords = []; $delete = rex_sql::factory(); - $where = "ftable = '". $this->tablePrefix . \rex::getTempPrefix() . "url_generator_url' AND fid = ". $id ." AND clang = ". $clang_id; + $where = "ftable = '". $this->tempTablePrefix . "url_generator_url' AND fid = ". $id ." AND clang = ". $clang_id; // delete from cache $select = rex_sql::factory(); $select->setTable($this->tempTablePrefix . 'search_it_index'); @@ -491,7 +491,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $articleData = []; $articleData['texttype'] = 'url'; - $articleData['ftable'] = $this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'; + $articleData['ftable'] = $this->tempTablePrefix . 'url_generator_url'; $articleData['fcolumn'] = NULL; $articleData['clang'] = $clang_id; $articleData['fid'] = intval($id); @@ -500,13 +500,13 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $plaintext = $this->getPlaintext($articleText); $articleData['plaintext'] = $plaintext; - if (array_key_exists($this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url', $this->includeColumns)) { + if (array_key_exists($this->tempTablePrefix . 'url_generator_url', $this->includeColumns)) { $additionalValues = []; $select->flushValues(); - $select->setTable($this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'); + $select->setTable($this->tempTablePrefix . 'url_generator_url'); $select->setWhere('id = ' . $id . ' AND clang_id = ' . $clang_id); - $select->select('`' . implode('`,`', $this->includeColumns[$this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url']) . '`'); - foreach ($this->includeColumns[$this->tablePrefix . \rex::getTempPrefix() . 'url_generator_url'] as $col) { + $select->select('`' . implode('`,`', $this->includeColumns[$this->tempTablePrefix . 'url_generator_url']) . '`'); + foreach ($this->includeColumns[$this->tempTablePrefix . 'url_generator_url'] as $col) { if ( $select->hasValue($col) ) { $additionalValues[$col] = $select->getValue($col); } } From 1be73c7da6b4f027edbb698692fe2b5a37377bc5 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Tue, 31 Mar 2020 08:16:10 +0200 Subject: [PATCH 11/27] bugfix --- plugins/stats/lib/stats.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/stats/lib/stats.php b/plugins/stats/lib/stats.php index 418178a..3f30eda 100644 --- a/plugins/stats/lib/stats.php +++ b/plugins/stats/lib/stats.php @@ -32,7 +32,7 @@ function insert($_searchterm, $_resultcount, $_time = false){ } function truncate(){ - $this->sql->setQuery('TRUNCATE ' . rex::getTempPrefix(). 'search_it_stats_searchterms'); + $this->sql->setQuery('TRUNCATE ' . rex::getTablePrefix().rex::getTempPrefix(). 'search_it_stats_searchterms'); } function getTopSearchterms($_count, $_getonly = 0){ From 00b63a538189dec1b94ee9176b619f0926bb179f Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Tue, 31 Mar 2020 08:16:32 +0200 Subject: [PATCH 12/27] make cronjob howto clear --- plugins/documentation/docs/de_de/howto-reindex.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/documentation/docs/de_de/howto-reindex.md b/plugins/documentation/docs/de_de/howto-reindex.md index ee8c053..77a9a66 100644 --- a/plugins/documentation/docs/de_de/howto-reindex.md +++ b/plugins/documentation/docs/de_de/howto-reindex.md @@ -19,7 +19,7 @@ ## Reindexierung von Artikeln via Cronjob -`Search it` fügt ein eigenes Cronjob-Profil hinzu, das sich im Cronjob-AddOn zeitgesteuert ausführen lässt. +`Search it` fügt ein eigenes Cronjob-Profil hinzu, das sich im Cronjob-AddOn zeitgesteuert ausführen lässt. Um ihn zu nutzen muss ein neuer CronJob hinzugefügt werden und im Feld "Typ" der Wert "Search it: Reindexieren ## Reindexierung von Datenbank-Feldern From 4dbb3c326f0dcc1fa5a8bf53fe1bfb8aef47e034 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Tue, 31 Mar 2020 08:30:54 +0200 Subject: [PATCH 13/27] bugfix --- plugins/stats/lib/stats.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/stats/lib/stats.php b/plugins/stats/lib/stats.php index 3f30eda..3da7c33 100644 --- a/plugins/stats/lib/stats.php +++ b/plugins/stats/lib/stats.php @@ -39,9 +39,9 @@ function getTopSearchterms($_count, $_getonly = 0){ $this->flushSQL(); if (empty($_getonly)){ - $query = 'SELECT term, COUNT(*) as count, 1 as success FROM `' . rex::getTempPrefix. 'search_it_stats_searchterms' . '` WHERE resultcount > 0 GROUP BY term + $query = 'SELECT term, COUNT(*) as count, 1 as success FROM `' . rex::getTablePrefix().rex::getTempPrefix(). 'search_it_stats_searchterms' . '` WHERE resultcount > 0 GROUP BY term UNION - SELECT term, COUNT(*) as count, 0 as success FROM `' . rex::getTempPrefix(). 'search_it_stats_searchterms' . '` WHERE resultcount <= 0 GROUP BY term'; + SELECT term, COUNT(*) as count, 0 as success FROM `' . rex::getTablePrefix().rex::getTempPrefix(). 'search_it_stats_searchterms' . '` WHERE resultcount <= 0 GROUP BY term'; } else { $query = 'SELECT term, COUNT(*) as count, ' . ($_getonly == 1 ? 1 : 0) . ' as success FROM `' . rex::getTempPrefix(). 'search_it_stats_searchterms' . '` WHERE resultcount ' . ($_getonly == 1 ? '>' : '<=') . ' 0 GROUP BY term'; // getonly = 1: only successful searchterms From bc37d61a9decc1813858215a84e4f8e791f2ef67 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Thu, 2 Apr 2020 08:18:35 +0200 Subject: [PATCH 14/27] =?UTF-8?q?Methode=20zur=20vereinfachten=20Pr=C3=BCf?= =?UTF-8?q?ung=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/functions_search_it.php | 8 ++++++++ lib/cronjob.php | 2 +- lib/search_it.php | 4 ++-- pages/generate.php | 2 +- pages/settings.mode.php | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index df88885..8c0fbb8 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -775,6 +775,14 @@ function ($match){ return $all; } +/** + * Prüft ob das URL Addon in der kompatiblen Version verfügbar ist. + * @return bool + */ +function search_it_isUrlAddOnAvailable() { + return (rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); +} + // ex reindex plugin function search_it_reindex_cols($_ep){ if ($_ep->getSubject() instanceof Exception) { diff --git a/lib/cronjob.php b/lib/cronjob.php index da3c227..5cc2b53 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -34,7 +34,7 @@ public function execute() case 4: // URLs neu indexieren - if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { + if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); $url_sql->setTable(\rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { diff --git a/lib/search_it.php b/lib/search_it.php index c7ac3bc..ae4013b 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -144,7 +144,7 @@ public function generateIndex() } // index url 2 addon URLs - if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { + if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); $url_sql->setTable($this->tempTablePrefix . 'url_generator_url'); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { @@ -2171,7 +2171,7 @@ function search($_search) $AwhereToSearch[] = "(fid IN (" . implode(',', $this->searchInIDs['articles']) . "))"; } - if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { + if(search_it_isUrlAddOnAvailable()) { if (array_key_exists('url', $this->searchInIDs) AND count($this->searchInIDs['url'])) { $AwhereToSearch[] = "texttype = 'url'"; $AwhereToSearch[] = "(fid IN (" . implode(',', $this->searchInIDs['url']) . "))"; diff --git a/pages/generate.php b/pages/generate.php index cfddf15..dc0ea65 100644 --- a/pages/generate.php +++ b/pages/generate.php @@ -50,7 +50,7 @@ function search_it_getArticleIds($cats = false) { } // index url 2 addon URLs - if(rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { + if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); $url_sql->setTable(rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); if ($url_sql->select('id')) { diff --git a/pages/settings.mode.php b/pages/settings.mode.php index 9ce96ec..60435fa 100644 --- a/pages/settings.mode.php +++ b/pages/settings.mode.php @@ -49,7 +49,7 @@ // URL Addon Checkbox $url_checkbox = []; -if(rex_addon::get('url')->isAvailable() && rex_version::compare(\rex_addon::get('url')->getVersion(), '1.5', '>=')) { +if(search_it_isUrlAddOnAvailable()) { $url_checkbox = [ 'type' => 'checkbox', 'id' => 'search_it_index_url_addon', From fb213fe8c0f0776508b98a826cb0d003885cf78d Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Thu, 2 Apr 2020 08:37:31 +0200 Subject: [PATCH 15/27] =?UTF-8?q?tmp=5F=20Pr=C3=A4fix=20bei=20URL=20Addon?= =?UTF-8?q?=20Tabellen=20entfernt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cronjob.php | 2 +- lib/search_it.php | 16 ++++++++-------- nbproject/project.properties | 4 +++- pages/ajax.php | 2 +- pages/generate.php | 2 +- plugins/documentation/docs/de_de/module-url.md | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/cronjob.php b/lib/cronjob.php index 5cc2b53..baf9af3 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -36,7 +36,7 @@ public function execute() // URLs neu indexieren if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); - $url_sql->setTable(\rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); + $url_sql->setTable(\rex::getTablePrefix() . W\Url\Profile::TABLE_NAME); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { // index und cache zuerst löschen, damit keine alten Einträge überleben $search_it->deleteIndexForType("url"); diff --git a/lib/search_it.php b/lib/search_it.php index ae4013b..458c968 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -146,7 +146,7 @@ public function generateIndex() // index url 2 addon URLs if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); - $url_sql->setTable($this->tempTablePrefix . 'url_generator_url'); + $url_sql->setTable($this->tablePrefix . \Url\Profile::TABLE_NAME); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { foreach ($url_sql->getArray() as $url) { $returns = $this->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); @@ -371,7 +371,7 @@ public function indexArticle($_id, $_clang = false) /** * Indexes a certain url from url Addon. * - * @param int $id url_generate_url table id + * @param int $id url_generator_url table id * @param int $article_id redaxo article id * @param int $profile_id url addon profile id * @param int $data_id url addon profile id @@ -385,7 +385,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $keywords = []; $delete = rex_sql::factory(); - $where = "ftable = '". $this->tempTablePrefix . "url_generator_url' AND fid = ". $id ." AND clang = ". $clang_id; + $where = "ftable = '". $this->tablePrefix . \Url\Profile::TABLE_NAME ."' AND fid = ". $id ." AND clang = ". $clang_id; // delete from cache $select = rex_sql::factory(); $select->setTable($this->tempTablePrefix . 'search_it_index'); @@ -491,7 +491,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $articleData = []; $articleData['texttype'] = 'url'; - $articleData['ftable'] = $this->tempTablePrefix . 'url_generator_url'; + $articleData['ftable'] = $this->tablePrefix . \Url\Profile::TABLE_NAME; $articleData['fcolumn'] = NULL; $articleData['clang'] = $clang_id; $articleData['fid'] = intval($id); @@ -500,13 +500,13 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $plaintext = $this->getPlaintext($articleText); $articleData['plaintext'] = $plaintext; - if (array_key_exists($this->tempTablePrefix . 'url_generator_url', $this->includeColumns)) { + if (array_key_exists($this->tablePrefix . \Url\Profile::TABLE_NAME, $this->includeColumns)) { $additionalValues = []; $select->flushValues(); - $select->setTable($this->tempTablePrefix . 'url_generator_url'); + $select->setTable($this->tablePrefix . \Url\Profile::TABLE_NAME); $select->setWhere('id = ' . $id . ' AND clang_id = ' . $clang_id); - $select->select('`' . implode('`,`', $this->includeColumns[$this->tempTablePrefix . 'url_generator_url']) . '`'); - foreach ($this->includeColumns[$this->tempTablePrefix . 'url_generator_url'] as $col) { + $select->select('`' . implode('`,`', $this->includeColumns[$this->tablePrefix . \Url\Profile::TABLE_NAME]) . '`'); + foreach ($this->includeColumns[$this->tablePrefix . \Url\Profile::TABLE_NAME] as $col) { if ( $select->hasValue($col) ) { $additionalValues[$col] = $select->getValue($col); } } diff --git a/nbproject/project.properties b/nbproject/project.properties index b895b16..19d5f7a 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,7 +1,9 @@ +file.reference.NetBeansProjects-redaxo_url=../redaxo_url file.reference.Redaxo-Redaxo5=../../Dropbox/www.design-to-use.de/Redaxo/Redaxo5 include.path=\ ${php.global.include.path}:\ - ${file.reference.Redaxo-Redaxo5} + ${file.reference.Redaxo-Redaxo5}:\ + ${file.reference.NetBeansProjects-redaxo_url} php.version=PHP_74 source.encoding=UTF-8 src.dir=. diff --git a/pages/ajax.php b/pages/ajax.php index f66d098..9a7b4a5 100644 --- a/pages/ajax.php +++ b/pages/ajax.php @@ -44,7 +44,7 @@ case 'url': $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); + $url_sql->setTable(rex::getTablePrefix() . \Url\Profile::TABLE_NAME); $url_sql->setWhere("id = ". rex_get('id')); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id, seo, url')) { if($url_sql->getValue('id') > 0) { diff --git a/pages/generate.php b/pages/generate.php index dc0ea65..edf6c57 100644 --- a/pages/generate.php +++ b/pages/generate.php @@ -52,7 +52,7 @@ function search_it_getArticleIds($cats = false) { // index url 2 addon URLs if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); + $url_sql->setTable(rex::getTablePrefix() . \Url\Profile::TABLE_NAME); if ($url_sql->select('id')) { foreach ($url_sql->getArray() as $url) { $js_output .= 'indexArray.push(new Array("url",'. $url['id'] .'));'; diff --git a/plugins/documentation/docs/de_de/module-url.md b/plugins/documentation/docs/de_de/module-url.md index 2b6fb35..d1d007a 100644 --- a/plugins/documentation/docs/de_de/module-url.md +++ b/plugins/documentation/docs/de_de/module-url.md @@ -26,7 +26,7 @@ if($request) { // Wenn ein Suchbegriff eingegeben wurde if($hit['type'] == 'url') { // url hits $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . \rex::getTempPrefix() . 'url_generator_url'); + $url_sql->setTable(rex::getTablePrefix() . \Url\Profile::TABLE_NAME); $url_sql->setWhere("id = ". $hit['fid']); if ($url_sql->select('article_id, clang_id, profile_id, data_id, seo')) { $url_info = json_decode($url_sql->getValue('seo'), true); From 6b32383ac64a1dbbf88506f7e69d0e1a62248a9d Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Thu, 2 Apr 2020 08:44:15 +0200 Subject: [PATCH 16/27] Redaxo Version angepasst --- README.md | 2 +- package.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ebb28fe..f1ded70 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Search it basiert auf [RexSearch (Xong) für REDAXO 4](https://github.com/xong/r ## Systemvoraussetzungen * `PHP ^7` -* `REDAXO >= 5.10` +* `REDAXO >= 5.5 ## Plugins diff --git a/package.yml b/package.yml index 6d225f5..2296518 100644 --- a/package.yml +++ b/package.yml @@ -22,7 +22,7 @@ page: blacklist: { title: 'translate:settings_blacklist' } test: { title: 'translate:test', icon: rex-icon fa-flask } requires: - redaxo: '^5.10.0' + redaxo: '^5.5.0' php: '^7' system_plugins: From c390b57cf223766776eb25bc8c880d81a0d07ed1 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Thu, 2 Apr 2020 09:45:36 +0200 Subject: [PATCH 17/27] falscher Tabellenname korrigiert --- lib/cronjob.php | 2 +- lib/search_it.php | 14 +++++++------- pages/ajax.php | 2 +- pages/generate.php | 2 +- plugins/documentation/docs/de_de/module-url.md | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/cronjob.php b/lib/cronjob.php index baf9af3..224361a 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -36,7 +36,7 @@ public function execute() // URLs neu indexieren if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); - $url_sql->setTable(\rex::getTablePrefix() . W\Url\Profile::TABLE_NAME); + $url_sql->setTable(\rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { // index und cache zuerst löschen, damit keine alten Einträge überleben $search_it->deleteIndexForType("url"); diff --git a/lib/search_it.php b/lib/search_it.php index 458c968..9ab3f47 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -146,7 +146,7 @@ public function generateIndex() // index url 2 addon URLs if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); - $url_sql->setTable($this->tablePrefix . \Url\Profile::TABLE_NAME); + $url_sql->setTable($this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { foreach ($url_sql->getArray() as $url) { $returns = $this->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); @@ -385,7 +385,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $keywords = []; $delete = rex_sql::factory(); - $where = "ftable = '". $this->tablePrefix . \Url\Profile::TABLE_NAME ."' AND fid = ". $id ." AND clang = ". $clang_id; + $where = "ftable = '". $this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME ."' AND fid = ". $id ." AND clang = ". $clang_id; // delete from cache $select = rex_sql::factory(); $select->setTable($this->tempTablePrefix . 'search_it_index'); @@ -491,7 +491,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $articleData = []; $articleData['texttype'] = 'url'; - $articleData['ftable'] = $this->tablePrefix . \Url\Profile::TABLE_NAME; + $articleData['ftable'] = $this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME; $articleData['fcolumn'] = NULL; $articleData['clang'] = $clang_id; $articleData['fid'] = intval($id); @@ -500,13 +500,13 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $plaintext = $this->getPlaintext($articleText); $articleData['plaintext'] = $plaintext; - if (array_key_exists($this->tablePrefix . \Url\Profile::TABLE_NAME, $this->includeColumns)) { + if (array_key_exists($this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME, $this->includeColumns)) { $additionalValues = []; $select->flushValues(); - $select->setTable($this->tablePrefix . \Url\Profile::TABLE_NAME); + $select->setTable($this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME); $select->setWhere('id = ' . $id . ' AND clang_id = ' . $clang_id); - $select->select('`' . implode('`,`', $this->includeColumns[$this->tablePrefix . \Url\Profile::TABLE_NAME]) . '`'); - foreach ($this->includeColumns[$this->tablePrefix . \Url\Profile::TABLE_NAME] as $col) { + $select->select('`' . implode('`,`', $this->includeColumns[$this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME]) . '`'); + foreach ($this->includeColumns[$this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME] as $col) { if ( $select->hasValue($col) ) { $additionalValues[$col] = $select->getValue($col); } } diff --git a/pages/ajax.php b/pages/ajax.php index 9a7b4a5..ea31acd 100644 --- a/pages/ajax.php +++ b/pages/ajax.php @@ -44,7 +44,7 @@ case 'url': $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . \Url\Profile::TABLE_NAME); + $url_sql->setTable(rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); $url_sql->setWhere("id = ". rex_get('id')); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id, seo, url')) { if($url_sql->getValue('id') > 0) { diff --git a/pages/generate.php b/pages/generate.php index edf6c57..97b26ad 100644 --- a/pages/generate.php +++ b/pages/generate.php @@ -52,7 +52,7 @@ function search_it_getArticleIds($cats = false) { // index url 2 addon URLs if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . \Url\Profile::TABLE_NAME); + $url_sql->setTable(rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); if ($url_sql->select('id')) { foreach ($url_sql->getArray() as $url) { $js_output .= 'indexArray.push(new Array("url",'. $url['id'] .'));'; diff --git a/plugins/documentation/docs/de_de/module-url.md b/plugins/documentation/docs/de_de/module-url.md index d1d007a..1f5f1cf 100644 --- a/plugins/documentation/docs/de_de/module-url.md +++ b/plugins/documentation/docs/de_de/module-url.md @@ -26,7 +26,7 @@ if($request) { // Wenn ein Suchbegriff eingegeben wurde if($hit['type'] == 'url') { // url hits $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . \Url\Profile::TABLE_NAME); + $url_sql->setTable(rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); $url_sql->setWhere("id = ". $hit['fid']); if ($url_sql->select('article_id, clang_id, profile_id, data_id, seo')) { $url_info = json_decode($url_sql->getValue('seo'), true); From f3c389329a77c146ecb2288326b459a116e33b40 Mon Sep 17 00:00:00 2001 From: Norbert Micheel Date: Thu, 2 Apr 2020 17:00:15 +0200 Subject: [PATCH 18/27] jetzt mit search_it_getUrlAddOnTableName() --- CHANGELOG.md | 5 +- functions/functions_search_it.php | 30 +++- lib/cronjob.php | 168 +++++++++--------- lib/search_it.php | 24 +-- package.yml | 2 +- pages/ajax.php | 6 +- pages/generate.php | 10 +- pages/settings.mode.php | 2 +- plugins/autocomplete/package.yml | 2 +- .../documentation/docs/de_de/module-url.md | 12 +- plugins/documentation/package.yml | 2 +- plugins/plaintext/package.yml | 2 +- plugins/stats/package.yml | 2 +- 13 files changed, 148 insertions(+), 119 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 489e660..2a90a8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Änderungen von search_it -- URLs aus dem URL Addon (>= 2.0) können indexiert werden. -- bei schrittweiser Indexierung sind die Artikel in der Ausgabe verlinkt +## Version 6.7.0 (2020-04-02) +- URLs aus dem URL Addon (>= 2.0) können indexiert werden. @TobiasKrais +- bei schrittweiser Indexierung sind die Artikel in der Ausgabe verlinkt @alexplusde - minimale PHP Version ergänzt @staabm - install.sql -> install.php - wird eine Tabelle oder Spalte gelöscht, die in "zusätzliche Datenquelle" angegeben ist und neuindexiert -> woops #222 thx @alexplusde diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index 8c0fbb8..0f50646 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -308,7 +308,7 @@ function search_it_getSettingsFormSection($id = '', $title = ' ', $elements // Skip empty elements continue; } - + $n = []; switch($element['type']){ @@ -780,7 +780,33 @@ function ($match){ * @return bool */ function search_it_isUrlAddOnAvailable() { - return (rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); + return (/*rex_addon::get('search_it')->getConfig('index_url_addon') &&*/ rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); +} + + +/** + * Ermittelt den Namen der Tabelle des URL Addons + * @return string + */ +function search_it_getUrlAddOnTableName() { + + if (search_it_isUrlAddOnAvailable()) { + + $tableName = null; + + $sql = rex_sql::factory(); + $allTables = $sql->getTables(); + + foreach( $allTables as $oneTable ) { + if ( strpos($oneTable, \Url\UrlManagerSql::TABLE_NAME) !== false ) { + $tableName = $oneTable; + break; + } + } + + return $tableName; + } + } // ex reindex plugin diff --git a/lib/cronjob.php b/lib/cronjob.php index 224361a..3aa9f42 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -1,84 +1,84 @@ -isAvailable() ) { - - //$message = $this->getParam('action').':'."\n"; - - $search_it = new search_it(); - $includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : []; - switch ($this->getParam('action')){ - case 2: - // Spalten neu indexieren - foreach( $includeColumns as $table => $columnArray ){ - foreach( $columnArray as $column ){ - $search_it->indexColumn($table, $column); - } - } - break; - - case 3: - // Artikel neu indexieren - $art_sql = rex_sql::factory(); - $art_sql->setTable(rex::getTable('article')); - if( $art_sql->select('id,clang_id') ){ - foreach( $art_sql->getArray() as $art ){ - $search_it->indexArticle($art['id'], $art['clang_id']); - } - } - break; - - case 4: - // URLs neu indexieren - if(search_it_isUrlAddOnAvailable()) { - $url_sql = rex_sql::factory(); - $url_sql->setTable(\rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); - if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { - // index und cache zuerst löschen, damit keine alten Einträge überleben - $search_it->deleteIndexForType("url"); - foreach ($url_sql->getArray() as $url) { - $search_it->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); - } - } - } - break; - - case 1: - default: - $search_it->generateIndex(); - break; - } - - //if ( $message != '' ) { $this->setMessage($message); } - return true; - } - $this->setMessage('Search it is not installed'); - return false; - } - public function getTypeName() - { - return rex_i18n::msg('search_it_reindex'); - } - public function getParamFields() - { - $fields = [ - [ - 'label' => rex_i18n::msg('search_it_generate_actions_title'), - 'name' => 'action', - 'type' => 'select', - 'options' => [ - 1 => rex_i18n::msg('search_it_generate_full'), - 2 => rex_i18n::msg('search_it_generate_columns'), - 3 => rex_i18n::msg('search_it_generate_articles'), - 4 => rex_i18n::msg('search_it_generate_urls')], - 'default' => '1', - 'notice' => rex_i18n::msg('search_it_generate_actions_title'), - ], - ]; - return $fields; - } -} \ No newline at end of file +isAvailable() ) { + + //$message = $this->getParam('action').':'."\n"; + + $search_it = new search_it(); + $includeColumns = is_array(rex_addon::get('search_it')->getConfig('include')) ? rex_addon::get('search_it')->getConfig('include') : []; + switch ($this->getParam('action')){ + case 2: + // Spalten neu indexieren + foreach( $includeColumns as $table => $columnArray ){ + foreach( $columnArray as $column ){ + $search_it->indexColumn($table, $column); + } + } + break; + + case 3: + // Artikel neu indexieren + $art_sql = rex_sql::factory(); + $art_sql->setTable(rex::getTable('article')); + if( $art_sql->select('id,clang_id') ){ + foreach( $art_sql->getArray() as $art ){ + $search_it->indexArticle($art['id'], $art['clang_id']); + } + } + break; + + case 4: + // URLs neu indexieren + if(search_it_isUrlAddOnAvailable()) { + $url_sql = rex_sql::factory(); + $url_sql->setTable(search_it_getUrlAddOnTableName()); + if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { + // index und cache zuerst löschen, damit keine alten Einträge überleben + $search_it->deleteIndexForType("url"); + foreach ($url_sql->getArray() as $url) { + $search_it->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); + } + } + } + break; + + case 1: + default: + $search_it->generateIndex(); + break; + } + + //if ( $message != '' ) { $this->setMessage($message); } + return true; + } + $this->setMessage('Search it is not installed'); + return false; + } + public function getTypeName() + { + return rex_i18n::msg('search_it_reindex'); + } + public function getParamFields() + { + $fields = [ + [ + 'label' => rex_i18n::msg('search_it_generate_actions_title'), + 'name' => 'action', + 'type' => 'select', + 'options' => [ + 1 => rex_i18n::msg('search_it_generate_full'), + 2 => rex_i18n::msg('search_it_generate_columns'), + 3 => rex_i18n::msg('search_it_generate_articles'), + 4 => rex_i18n::msg('search_it_generate_urls')], + 'default' => '1', + 'notice' => rex_i18n::msg('search_it_generate_actions_title'), + ], + ]; + return $fields; + } +} diff --git a/lib/search_it.php b/lib/search_it.php index 9ab3f47..bcb103a 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -22,6 +22,7 @@ class search_it private $ellipsis; private $tablePrefix; private $tempTablePrefix; + private $urlAddOnTableName; private $significantCharacterCount = 3; private $stopwords = []; private $errormessages = ''; @@ -107,6 +108,7 @@ function __construct($_clang = false, $_loadSettings = true, $_useStopwords = tr $this->setClang($_clang); $this->tablePrefix = rex::getTablePrefix(); $this->tempTablePrefix = rex::getTablePrefix().rex::getTempPrefix(); + $this->urlAddOnTableName = search_it_getUrlAddOnTableName(); $this->ellipsis = rex_i18n::msg('search_it_ellipsis'); @@ -146,7 +148,7 @@ public function generateIndex() // index url 2 addon URLs if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); - $url_sql->setTable($this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME); + $url_sql->setTable($this->urlAddOnTableName); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { foreach ($url_sql->getArray() as $url) { $returns = $this->indexUrl($url['id'], $url['article_id'], $url['clang_id'], $url['profile_id'], $url['data_id']); @@ -372,10 +374,10 @@ public function indexArticle($_id, $_clang = false) * Indexes a certain url from url Addon. * * @param int $id url_generator_url table id - * @param int $article_id redaxo article id + * @param int $article_id redaxo article id * @param int $profile_id url addon profile id * @param int $data_id url addon profile id - * @param int $clang_id redaxo clang id + * @param int $clang_id redaxo clang id * * @return int */ @@ -385,7 +387,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $keywords = []; $delete = rex_sql::factory(); - $where = "ftable = '". $this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME ."' AND fid = ". $id ." AND clang = ". $clang_id; + $where = "ftable = '". $this->urlAddOnTableName ."' AND fid = ". $id ." AND clang = ". $clang_id; // delete from cache $select = rex_sql::factory(); $select->setTable($this->tempTablePrefix . 'search_it_index'); @@ -491,7 +493,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $articleData = []; $articleData['texttype'] = 'url'; - $articleData['ftable'] = $this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME; + $articleData['ftable'] = $this->urlAddOnTableName; $articleData['fcolumn'] = NULL; $articleData['clang'] = $clang_id; $articleData['fid'] = intval($id); @@ -500,13 +502,13 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) $plaintext = $this->getPlaintext($articleText); $articleData['plaintext'] = $plaintext; - if (array_key_exists($this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME, $this->includeColumns)) { + if (array_key_exists($this->urlAddOnTableName, $this->includeColumns)) { $additionalValues = []; $select->flushValues(); - $select->setTable($this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME); + $select->setTable($this->urlAddOnTableName); $select->setWhere('id = ' . $id . ' AND clang_id = ' . $clang_id); - $select->select('`' . implode('`,`', $this->includeColumns[$this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME]) . '`'); - foreach ($this->includeColumns[$this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME] as $col) { + $select->select('`' . implode('`,`', $this->includeColumns[$this->urlAddOnTableName]) . '`'); + foreach ($this->includeColumns[$this->urlAddOnTableName] as $col) { if ( $select->hasValue($col) ) { $additionalValues[$col] = $select->getValue($col); } } @@ -532,7 +534,7 @@ public function indexURL($id, $article_id, $clang_id, $profile_id, $data_id) return $return; } - + /** * Excludes an article from the index. * @@ -2380,4 +2382,4 @@ function search($_search) return $return; } -} \ No newline at end of file +} diff --git a/package.yml b/package.yml index 2296518..58bc01b 100644 --- a/package.yml +++ b/package.yml @@ -1,5 +1,5 @@ package: search_it -version: '6.6.6' +version: '6.7.0' author: Friends Of REDAXO supportpage: https://github.com/FriendsOfREDAXO/search_it diff --git a/pages/ajax.php b/pages/ajax.php index ea31acd..7d6610e 100644 --- a/pages/ajax.php +++ b/pages/ajax.php @@ -41,10 +41,10 @@ } } break; - + case 'url': $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); + $url_sql->setTable(search_it_getUrlAddOnTableName()); $url_sql->setWhere("id = ". rex_get('id')); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id, seo, url')) { if($url_sql->getValue('id') > 0) { @@ -79,7 +79,7 @@ } } break; - + case 'col': if(false !== ($count = $search_it->indexColumn(rex_get('t'), rex_get('c'), false, false, rex_get('s'), rex_get('w')))) { echo '

`' . rex_get('t') . '`.`' . rex_get('c') . '` (' . rex_get('s') . ' - ' . (rex_get('s') + rex_get('w')) . ') '. $this->i18n('search_it_generate_col_done',$count) . '

'; diff --git a/pages/generate.php b/pages/generate.php index 97b26ad..8d5cec8 100644 --- a/pages/generate.php +++ b/pages/generate.php @@ -52,7 +52,7 @@ function search_it_getArticleIds($cats = false) { // index url 2 addon URLs if(search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); + $url_sql->setTable(search_it_getUrlAddOnTableName()); if ($url_sql->select('id')) { foreach ($url_sql->getArray() as $url) { $js_output .= 'indexArray.push(new Array("url",'. $url['id'] .'));'; @@ -60,7 +60,7 @@ function search_it_getArticleIds($cats = false) { } } } - + if(!empty($this->getConfig('include')) AND is_array($this->getConfig('include'))) { foreach($this->getConfig('include') as $table=>$columnArray) { $sql = rex_sql::factory(); @@ -77,7 +77,7 @@ function search_it_getArticleIds($cats = false) { } } } - + if(!empty($this->getConfig('indexmediapool')) AND intval($this->getConfig('indexmediapool'))) { $mediaSQL = rex_sql::factory(); $mediaSQL->setTable(rex::getTable('media')); @@ -141,7 +141,7 @@ function index(type,data){ } else if(type === 'mediapool') { url = 'index.php?page=search_it&ajax=generate&do=incremental&type=mediapool&name=' + data[0] + '&file_id=' + data[1] + '&category_id=' + data[2]; } - + jQuery.get(url,{},function(data){ jQuery('#search_it_generate_log').prepend(data); globalcount++; @@ -250,4 +250,4 @@ function index(type,data){ $fragment->setVar('title', $this->i18n('search_it_generate_actions_title'), false); $fragment->setVar('body', $content , false); echo $fragment->parse('core/page/section.php'); -} \ No newline at end of file +} diff --git a/pages/settings.mode.php b/pages/settings.mode.php index 60435fa..8456447 100644 --- a/pages/settings.mode.php +++ b/pages/settings.mode.php @@ -256,4 +256,4 @@ echo '
' . $content . ' -
'; \ No newline at end of file +'; diff --git a/plugins/autocomplete/package.yml b/plugins/autocomplete/package.yml index 4d5111e..f61517b 100644 --- a/plugins/autocomplete/package.yml +++ b/plugins/autocomplete/package.yml @@ -1,5 +1,5 @@ package: search_it/autocomplete -version: '6.6.6' +version: '6.7.0' author: Manétage title: 'translate:search_it_autocomplete_plugin_title' diff --git a/plugins/documentation/docs/de_de/module-url.md b/plugins/documentation/docs/de_de/module-url.md index 1f5f1cf..04d0d5e 100644 --- a/plugins/documentation/docs/de_de/module-url.md +++ b/plugins/documentation/docs/de_de/module-url.md @@ -11,22 +11,22 @@ $request = rex_request('search', 'string', false); if($request) { // Wenn ein Suchbegriff eingegeben wurde $server = rtrim(rex::getServer(), "/"); - + print '
'; - + // Init search and execute $search_it = new search_it(); $result = $search_it->search($request); echo '

Suchergebnisse

'; if($result['count']) { - - echo '
    '; + + echo '
      '; foreach($result['hits'] as $hit) { if($hit['type'] == 'url') { // url hits $url_sql = rex_sql::factory(); - $url_sql->setTable(rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); + $url_sql->setTable(search_it_getUrlAddOnTableName()); $url_sql->setWhere("id = ". $hit['fid']); if ($url_sql->select('article_id, clang_id, profile_id, data_id, seo')) { $url_info = json_decode($url_sql->getValue('seo'), true); @@ -81,4 +81,4 @@ Das Sucheingabe-Formular kann beliebig formatiert und mit Klassen ausgezeichnet font-weight: bold; } -``` \ No newline at end of file +``` diff --git a/plugins/documentation/package.yml b/plugins/documentation/package.yml index 8759b35..d5b52b8 100644 --- a/plugins/documentation/package.yml +++ b/plugins/documentation/package.yml @@ -1,5 +1,5 @@ package: search_it/documentation -version: '6.6.6' +version: '6.7.0' author: Friends Of REDAXO title: 'translate:search_it_documentation_title' diff --git a/plugins/plaintext/package.yml b/plugins/plaintext/package.yml index bf18d43..be8243c 100644 --- a/plugins/plaintext/package.yml +++ b/plugins/plaintext/package.yml @@ -1,5 +1,5 @@ package: search_it/plaintext -version: '6.6.6' +version: '6.7.0' author: Friends Of REDAXO title: 'translate:search_it_plaintext_title' diff --git a/plugins/stats/package.yml b/plugins/stats/package.yml index 0e09137..6d1d571 100644 --- a/plugins/stats/package.yml +++ b/plugins/stats/package.yml @@ -1,5 +1,5 @@ package: search_it/stats -version: '6.6.6' +version: '6.7.0' author: Friends Of REDAXO title: 'translate:search_it_stats_plugin_title' From 695fec5c03de5a6b172527bf791739e32ae5a965 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Thu, 2 Apr 2020 17:30:17 +0200 Subject: [PATCH 19/27] config abfragen --- functions/functions_search_it.php | 2 +- lib/cronjob.php | 2 +- lib/search_it.php | 9 ++++----- pages/generate.php | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index 8c0fbb8..cf13ef7 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -780,7 +780,7 @@ function ($match){ * @return bool */ function search_it_isUrlAddOnAvailable() { - return (rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); + return (rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); } // ex reindex plugin diff --git a/lib/cronjob.php b/lib/cronjob.php index 224361a..6a2a868 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -34,7 +34,7 @@ public function execute() case 4: // URLs neu indexieren - if(search_it_isUrlAddOnAvailable()) { + if(rex_addon::get('search_it')->getConfig('index_url_addon') && search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); $url_sql->setTable(\rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { diff --git a/lib/search_it.php b/lib/search_it.php index 9ab3f47..357fec0 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -144,7 +144,7 @@ public function generateIndex() } // index url 2 addon URLs - if(search_it_isUrlAddOnAvailable()) { + if(rex_addon::get('search_it')->getConfig('index_url_addon') && search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); $url_sql->setTable($this->tablePrefix . \Url\UrlManagerSql::TABLE_NAME); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { @@ -1359,12 +1359,10 @@ public function setOrder($_order) $this->errormessages = sprintf('Column %d has no correct sort order (ASC or DESC). Descending (DESC) sort order is assumed', $i); $dir2upper = 'DESC'; } - $this->order[$col2upper] = $dir2upper; $this->hashMe .= $col2upper . $dir2upper; } } - return true; } @@ -2171,7 +2169,7 @@ function search($_search) $AwhereToSearch[] = "(fid IN (" . implode(',', $this->searchInIDs['articles']) . "))"; } - if(search_it_isUrlAddOnAvailable()) { + if(rex_addon::get('search_it')->getConfig('index_url_addon') && search_it_isUrlAddOnAvailable()) { if (array_key_exists('url', $this->searchInIDs) AND count($this->searchInIDs['url'])) { $AwhereToSearch[] = "texttype = 'url'"; $AwhereToSearch[] = "(fid IN (" . implode(',', $this->searchInIDs['url']) . "))"; @@ -2279,7 +2277,8 @@ function search($_search) $this->limit[0], $this->limit[1] ); } - //echo '
      '.$query.'
      ';die(); +print $query; +exit; //echo '
      '.implode(",\n",$selectFields).'
      '; try { $sqlResult = $sql->getArray($query); diff --git a/pages/generate.php b/pages/generate.php index 97b26ad..09b04bf 100644 --- a/pages/generate.php +++ b/pages/generate.php @@ -50,7 +50,7 @@ function search_it_getArticleIds($cats = false) { } // index url 2 addon URLs - if(search_it_isUrlAddOnAvailable()) { + if(rex_addon::get('search_it')->getConfig('index_url_addon') && search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); $url_sql->setTable(rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); if ($url_sql->select('id')) { From 699b249427ce5b18925d08d8c9f789bdd77bdbf5 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Thu, 2 Apr 2020 21:36:54 +0200 Subject: [PATCH 20/27] merge --- functions/functions_search_it.php | 8 ++++++++ lib/search_it.php | 1 + pages/index.php | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index 3d834c1..55b91c5 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -798,6 +798,14 @@ function search_it_getUrlAddOnTableName() { } } +/** + * Prüft ob das URL Addon in der kompatiblen Version verfügbar ist. + * @return bool + */ +function search_it_isUrlAddOnAvailable() { + return (rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); +} + // ex reindex plugin function search_it_reindex_cols($_ep){ if ($_ep->getSubject() instanceof Exception) { diff --git a/lib/search_it.php b/lib/search_it.php index 18f2fbf..360d54a 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -1362,6 +1362,7 @@ public function setOrder($_order) $dir2upper = 'DESC'; } $this->order[$col2upper] = $dir2upper; + $this->order = array_reverse($this->order, TRUE); $this->hashMe .= $col2upper . $dir2upper; } } diff --git a/pages/index.php b/pages/index.php index 38073e0..54e3121 100644 --- a/pages/index.php +++ b/pages/index.php @@ -10,4 +10,4 @@ echo rex_view::title($this->i18n('title').' ('.$this->getProperty('version').')'); -rex_be_controller::includeCurrentPageSubPath(); +rex_be_controller::includeCurrentPageSubPath(); \ No newline at end of file From f845955c8d324efbf3cbe1ccac199a09c205d58e Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Thu, 2 Apr 2020 21:45:06 +0200 Subject: [PATCH 21/27] =?UTF-8?q?erlaubt=20neue=20Elemente=20der=20Sortier?= =?UTF-8?q?ung=20an=20erster=20Stelle=20einzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/search_it.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/search_it.php b/lib/search_it.php index 360d54a..c8a8225 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -1339,10 +1339,12 @@ public function setWhere($_where) * and the direction (DESC or ASC) as value (e.g.: array['COLUMN'] = 'ASC'). * * @param array $_order + * @param bool $reverse_order add new order criteria and then reverse order array + * so that last element of $_order array will be first in mysql ORDER clause * * @return bool */ - public function setOrder($_order) + public function setOrder($_order, $reverse_order = false) { if (!is_array($_order)) { $this->errormessages = 'Wrong parameter. Expecting an array'; @@ -1362,7 +1364,10 @@ public function setOrder($_order) $dir2upper = 'DESC'; } $this->order[$col2upper] = $dir2upper; - $this->order = array_reverse($this->order, TRUE); + // Put new order first + if($reverse_order) { + $this->order = array_reverse($this->order, TRUE); + } $this->hashMe .= $col2upper . $dir2upper; } } @@ -2280,8 +2285,6 @@ function search($_search) $this->limit[0], $this->limit[1] ); } -print $query; -exit; //echo '
      '.implode(",\n",$selectFields).'
      '; try { $sqlResult = $sql->getArray($query); From 55c48d25d12e3b436bca64b7e8afa5baf50eee72 Mon Sep 17 00:00:00 2001 From: Norbert Micheel Date: Thu, 2 Apr 2020 23:33:55 +0200 Subject: [PATCH 22/27] jetzt mit search_it_getUrlAddOnTableName() --- functions/functions_search_it.php | 10 ++++++++++ lib/cronjob.php | 2 +- lib/search_it.php | 3 +-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index 3d834c1..5c09d2b 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -775,11 +775,21 @@ function ($match){ return $all; } +/** + * Prüft ob das URL Addon in der kompatiblen Version verfügbar ist. + * @return bool + */ +function search_it_isUrlAddOnAvailable() { + return (/*rex_addon::get('search_it')->getConfig('index_url_addon') &&*/ rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); +} + + /** * Ermittelt den Namen der Tabelle des URL Addons * @return string */ function search_it_getUrlAddOnTableName() { + if (search_it_isUrlAddOnAvailable()) { $tableName = null; diff --git a/lib/cronjob.php b/lib/cronjob.php index 4bc96d8..c5dd6b5 100644 --- a/lib/cronjob.php +++ b/lib/cronjob.php @@ -36,7 +36,7 @@ public function execute() // URLs neu indexieren if(rex_addon::get('search_it')->getConfig('index_url_addon') && search_it_isUrlAddOnAvailable()) { $url_sql = rex_sql::factory(); - $url_sql->setTable(\rex::getTablePrefix() . \Url\UrlManagerSql::TABLE_NAME); + $url_sql->setTable(search_it_getUrlAddOnTableName()); if ($url_sql->select('id, article_id, clang_id, profile_id, data_id')) { // index und cache zuerst löschen, damit keine alten Einträge überleben $search_it->deleteIndexForType("url"); diff --git a/lib/search_it.php b/lib/search_it.php index 18f2fbf..78bdfd9 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -2279,8 +2279,7 @@ function search($_search) $this->limit[0], $this->limit[1] ); } -print $query; -exit; + //echo '
      '.$query.'
      ';die(); //echo '
      '.implode(",\n",$selectFields).'
      '; try { $sqlResult = $sql->getArray($query); From 594250ca1640153fe58fca20f80c3d1f115b9ebd Mon Sep 17 00:00:00 2001 From: Norbert Micheel Date: Fri, 3 Apr 2020 00:36:38 +0200 Subject: [PATCH 23/27] noch den Kommentar weg --- functions/functions_search_it.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index 4d68af7..7f6748e 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -780,7 +780,7 @@ function ($match){ * @return bool */ function search_it_isUrlAddOnAvailable() { - return (/*rex_addon::get('search_it')->getConfig('index_url_addon') &&*/ rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); + return ( rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); } From 97ad86f1ffd02180e9418f86670e649f8135938b Mon Sep 17 00:00:00 2001 From: Norbert Micheel Date: Fri, 3 Apr 2020 00:52:57 +0200 Subject: [PATCH 24/27] =?UTF-8?q?Ist=20schon=20zu=20sp=C3=A4t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/functions_search_it.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index 7f6748e..1845f27 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -808,13 +808,6 @@ function search_it_getUrlAddOnTableName() { } } -/** - * Prüft ob das URL Addon in der kompatiblen Version verfügbar ist. - * @return bool - */ -function search_it_isUrlAddOnAvailable() { - return (rex_addon::get('search_it')->getConfig('index_url_addon') && rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); -} // ex reindex plugin function search_it_reindex_cols($_ep){ From a7e6e608e2780f53147fa3e4815ccf757a05fdca Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Fri, 3 Apr 2020 07:58:46 +0200 Subject: [PATCH 25/27] =?UTF-8?q?erlaubt=20neue=20Elemente=20der=20Sortier?= =?UTF-8?q?ung=20an=20erster=20Stelle=20einzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/search_it.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/search_it.php b/lib/search_it.php index c8a8225..319a3ae 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -1339,12 +1339,11 @@ public function setWhere($_where) * and the direction (DESC or ASC) as value (e.g.: array['COLUMN'] = 'ASC'). * * @param array $_order - * @param bool $reverse_order add new order criteria and then reverse order array - * so that last element of $_order array will be first in mysql ORDER clause + * @param bool $put_first put new order criteria(s) first in order clause * * @return bool */ - public function setOrder($_order, $reverse_order = false) + public function setOrder($_order, $put_first = false) { if (!is_array($_order)) { $this->errormessages = 'Wrong parameter. Expecting an array'; @@ -1363,11 +1362,7 @@ public function setOrder($_order, $reverse_order = false) $this->errormessages = sprintf('Column %d has no correct sort order (ASC or DESC). Descending (DESC) sort order is assumed', $i); $dir2upper = 'DESC'; } - $this->order[$col2upper] = $dir2upper; - // Put new order first - if($reverse_order) { - $this->order = array_reverse($this->order, TRUE); - } + $this->order = $put_first ? array_merge([$col => $dir2upper], $this->order) : array_merge($this->order, [$col => $dir2upper]); $this->hashMe .= $col2upper . $dir2upper; } } From 5a8b629ae3d6e2862c211dfcc9a2b24fbedccae2 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Fri, 3 Apr 2020 08:02:29 +0200 Subject: [PATCH 26/27] solve conflicts --- functions/functions_search_it.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index 1845f27..fe415a5 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -783,7 +783,6 @@ function search_it_isUrlAddOnAvailable() { return ( rex_addon::get('url')->isAvailable() && rex_string::versionCompare(\rex_addon::get('url')->getVersion(), '1.5', '>=')); } - /** * Ermittelt den Namen der Tabelle des URL Addons * @return string @@ -808,7 +807,6 @@ function search_it_getUrlAddOnTableName() { } } - // ex reindex plugin function search_it_reindex_cols($_ep){ if ($_ep->getSubject() instanceof Exception) { From e6310dd1f8602344e40f7bb19031849743049fa9 Mon Sep 17 00:00:00 2001 From: Norbert Micheel Date: Fri, 3 Apr 2020 14:14:13 +0200 Subject: [PATCH 27/27] Beim "Davorsetzen" entsteht die umgekehrte Reihenfolge, daher vorher einmal rumdrehen... --- lib/search_it.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/search_it.php b/lib/search_it.php index 6cfd3c0..0112d11 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -1349,7 +1349,9 @@ public function setOrder($_order, $put_first = false) $this->errormessages = 'Wrong parameter. Expecting an array'; return false; } - + if ($put_first) { + $_order = array_reverse($_order, TRUE); + } $i = 0; $dir2upper = ''; $col2upper = '';