]> 91.132.146.200 Git - insipid.git/commitdiff
fixing bug #10. URL is now in the search index. hypostyle 11/head
authorBanana <mail@bananas-playground.net>
Sun, 21 Mar 2021 10:31:58 +0000 (11:31 +0100)
committerBanana <mail@bananas-playground.net>
Sun, 21 Mar 2021 10:31:58 +0000 (11:31 +0100)
ChangeLog
TODO
documentation/update.txt
webroot/job/email-import.php
webroot/lib/link.class.php
webroot/lib/management.class.php
webroot/view/home.inc.php

index 79aaf00179772446d1f46b4ee8d9cc1146208c51..d9cf500adb3c362e2286c838812e0da73c8f6d0b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@ version 2.6 - Hypostyle
 
        + Fixed sql problems with Maria DB. Any_value is not supported there
        + Fixed some query and data loading brain fucks..
+       + Fixed #10. URL is now considered when building search information.
+               Update search index from stats view to update all the exiting information
        + Updated third party information in readme
        + Fixed xml import xsd
        + Added translation support. More information in translation.txt
diff --git a/TODO b/TODO
index bcc5912542138c6c4203a4d0d76773ab2c8820d1..6f07b6539697be448b7221cd851d174da9215c38 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,10 +1,9 @@
 TODO / Feature list
 + adapt new php 7
 ++ http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op
-
++ view table really still needed?
 + stats cleanup. Management functions should be standalone
 + theme support
 + more "secure" user authentication
 ++ multiple user accounts and stuff
 + combine cat and tag class into one.
-+ view really still needed?
index 30b5ec6d46ef2271989dafb8fa7052f29bdacd61..10d2e6935b142a7f16c26cb2b99a908f0399e567 100644 (file)
@@ -5,6 +5,7 @@ the version your are updating from is done.
 
 + Update config file with the new language setting. See config.default and
   translation.txt for more information
++ Run update search index to use the URL within the search index for your existing data.
 
 ## version 2.5 - Winnowing Hall
 
index f7db1b631639b10e7d557d0555f3fc33ca1a96a8..e786269c0ed3eb849b1e1e9bb122b57c127456df 100644 (file)
@@ -155,7 +155,6 @@ if(!empty($emails)) {
                                $newdata['title'] = '';
                                $newdata['image'] = '';
                                $newdata['status'] = '3'; # moderation required
-                               $newdata['search'] = '';
                                $newdata['tagArr'] = array();
                                $newdata['catArr'] = array();
                                $newdata['hash'] = '';
@@ -199,13 +198,6 @@ if(!empty($emails)) {
                                        continue;
                                }
 
-                               $newdata['search'] = $newdata['title'];
-                               $newdata['search'] .= ' '.$newdata['description'];
-                               $newdata['search'] .= ' '.implode(" ",$newdata['tagArr']);
-                               $newdata['search'] .= ' '.implode(" ",$newdata['catArr']);
-                               $newdata['search'] = trim($newdata['search']);
-                $newdata['search'] = strtolower($newdata['search']);
-
                                if(DEBUG === true) var_dump($newdata);
 
                 $linkObj = new Link($DB);
@@ -225,12 +217,13 @@ if(!empty($emails)) {
                     try {
                         $linkID = $linkObj->create(array(
                             'hash' => $newdata['hash'],
-                            'search' => $newdata['search'],
                             'link' => $newdata['link'],
                             'status' => $newdata['status'],
                             'description' => $newdata['description'],
                             'title' => $newdata['title'],
-                            'image' => $newdata['image']
+                            'image' => $newdata['image'],
+                                                       'tagArr' => $newdata['tagArr'],
+                                                       'catArr' => $newdata['catArr']
                         ), true);
                     } catch (Exception $e) {
                         $_m = "WARN Can not create new link into DB." . $e->getMessage();
index aa823f0708f18e4027e3d210204e412c923ba72b..5c99e50c755a932fddf649164da75418807458fc 100644 (file)
@@ -158,6 +158,16 @@ class Link {
                if (!isset($data['hash']) || empty($data['hash'])) return false;
                if (!isset($data['title']) || empty($data['title'])) return false;
 
+               $_t = parse_url($data['link']);
+               $data['search'] = $data['title'];
+               $data['search'] .= ' '.$data['description'];
+               $data['search'] .= ' '.implode(" ",$data['tagArr']);
+               $data['search'] .= ' '.implode(" ",$data['catArr']);
+               $data['search'] .= ' '.$_t['host'];
+               $data['search'] .= ' '.implode(' ',explode('/',$_t['path']));
+               $data['search'] = trim($data['search']);
+               $data['search'] = strtolower($data['search']);
+
                $queryStr = "INSERT INTO `" . DB_PREFIX . "_link` SET
                         `link` = '" . $this->DB->real_escape_string($data['link']) . "',
                         `created` = NOW(),
@@ -181,6 +191,7 @@ class Link {
 
        /**
         * update the current loaded link with the given data
+        *
         * @param array $data
         * @return boolean|int
         */
@@ -194,10 +205,13 @@ class Link {
                        $catArr = Summoner::prepareTagOrCategoryStr($data['category']);
                        $tagArr = Summoner::prepareTagOrCategoryStr($data['tag']);
 
+                       $_t = parse_url($this->_data['link']);
                        $search = $data['title'];
                        $search .= ' '.$data['description'];
                        $search .= ' '.implode(" ", $tagArr);
                        $search .= ' '.implode(" ", $catArr);
+                       $search .= ' '.$_t['host'];
+                       $search .= ' '.implode(' ',explode('/',$_t['path']));
             $search = trim($search);
                        $search = strtolower($search);
 
index e26935480a684f68f9f51b0fb44b5c81fe760b39..a609fff31ca0ae69ea499b6d8d0bb035378b1d8a 100644 (file)
@@ -686,10 +686,13 @@ class Management {
                                $LinkObj = new Link($this->DB);
                                $l = $LinkObj->load($link['hash']);
 
+                               $_t = parse_url($l['link']);
                                $searchStr = $l['title'];
                                $searchStr .= ' '.$l['description'];
                                $searchStr .= ' '.implode(' ',$l['tags']);
                 $searchStr .= ' '.implode(' ',$l['categories']);
+                               $searchStr .= ' '.$_t['host'];
+                               $searchStr .= ' '.implode(' ',explode('/',$_t['path']));
                 $searchStr = trim($searchStr);
                 $searchStr = strtolower($searchStr);
 
@@ -759,7 +762,6 @@ class Management {
                                                        'status' => $linkToImport['private'],
                                                        'description' => $linkToImport['description'],
                                                        'title' => $linkToImport['title'],
-                                                       'search' => '',
                                                        'image' => $linkToImport['image']
                                                ), true);
                                        } catch (Exception $e) {
index b67c7f97c200cf0c1c327bfbbbd1c2e333375548..463f4e8af265db596b9667fe9d1f8882d7778b47 100644 (file)
@@ -125,24 +125,18 @@ if(isset($_POST['data']) && !empty($_POST['data']) && isset($_POST['addnewone'])
                $catArr = Summoner::prepareTagOrCategoryStr($formData['category']);
                $tagArr = Summoner::prepareTagOrCategoryStr($formData['tag']);
 
-               $search = $formData['title'];
-               $search .= ' '.$formData['description'];
-               $search .= ' '.implode(" ",$tagArr);
-               $search .= ' '.implode(" ",$catArr);
-               $search .= trim($search);
-               $search = strtolower($search);
-
                $DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
 
                $linkObj = new Link($DB);
                $linkID = $linkObj->create(array(
                        'hash' => $hash,
-                       'search' => $search,
                        'link' => $formData['url'],
                        'status' => $formData['private'],
                        'description' => $formData['description'],
                        'title' => $formData['title'],
-                       'image' => $formData['image']
+                       'image' => $formData['image'],
+                       'tagArr'  => $tagArr,
+                       'catArr' => $catArr
                ),true);
 
                if(!empty($linkID)) {