Skip to content

Commit

Permalink
Merge pull request #254 from FriendsOfREDAXO/url2
Browse files Browse the repository at this point in the history
Url Addon Version 2 hinzugefügt
  • Loading branch information
TobiasKrais authored Apr 7, 2020
2 parents 7f290c8 + 439abff commit 9b35bb7
Show file tree
Hide file tree
Showing 44 changed files with 775 additions and 320 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Änderungen von search_it

- 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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ https://github.com/FriendsOfREDAXO
Search it basiert auf: [RexSearch (Xong) für REDAXO 4](https://github.com/xong/rexsearch)
[Norbert Micheel](https://github.com/tyrant88/) Portierung für R5 und aktiven Entwicklung
[Alexander Walther](https://github.com/skerbis) Dokumentation und Hilfe
[und weitere Entwickler...](https://github.com/FriendsOfREDAXO/search_it/graphs/contributors)
[Tobias Krais](https://github.com/tobiaskrais) URL Addon (>= 2.0) Support
[und weitere Entwickler...](https://github.com/FriendsOfREDAXO/search_it/graphs/contributors)
7 changes: 7 additions & 0 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
89 changes: 63 additions & 26 deletions functions/functions_search_it.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -31,19 +31,19 @@ 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)."|%'";
$sqlCats[] = intval($catID);
}
}

$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';
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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)) {
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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()){
Expand Down Expand Up @@ -297,14 +297,19 @@ function search_it_handle_extensionpoint($_ep){
$search_it->deleteCache();
}

function search_it_getSettingsFormSection($id = '', $title = '&nbsp;', $elements = array(), $ownsection = 'info', $collapse = false ){
function search_it_getSettingsFormSection($id = '', $title = '&nbsp;', $elements = [], $ownsection = 'info', $collapse = false ) {

$return = '<fieldset id="'.$id.'">';
$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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -704,7 +709,7 @@ function soundex_ger($word)
//echo "<br>code2: <b>" . $code . "</b><br />";
// entfernen aller Codes "0" ausser am Anfang
$codelen = strlen($code);
$num = array();
$num = [];
$num = str_split($code);
$phoneticcode = $num[0];

Expand Down Expand Up @@ -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)
Expand All @@ -770,6 +775,38 @@ 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('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
function search_it_reindex_cols($_ep){
if ($_ep->getSubject() instanceof Exception) {
Expand All @@ -778,7 +815,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;
Expand Down
3 changes: 1 addition & 2 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
3 changes: 3 additions & 0 deletions lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,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
Expand All @@ -116,6 +118,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. <code>txt,csv,pdf</code>)<br />(frei lassen für beliebige Dateien)
Expand Down
3 changes: 3 additions & 0 deletions lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,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
Expand All @@ -116,6 +118,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' <br />(leave empty for any files)
Expand Down
3 changes: 3 additions & 0 deletions lang/es_es.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,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
Expand All @@ -116,6 +118,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, <code>txt, csv, pdf</code>)<br/> (déjelo en blanco para cualquier archivo)
Expand Down
3 changes: 3 additions & 0 deletions lang/pt_br.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,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
Expand All @@ -116,6 +118,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' <br />( deixar vazio para arquivos desejados)
Expand Down
3 changes: 3 additions & 0 deletions lang/sv_se.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,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
Expand All @@ -116,6 +118,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' <br />(lämna tomma för alla filer)
Expand Down
Loading

0 comments on commit 9b35bb7

Please sign in to comment.