]> 91.132.146.200 Git - insipid.git/commitdiff
link info detail page. tag and category listing. commin overviewpage
authorBanana <banana@optimus.de>
Sun, 1 Jan 2017 13:02:20 +0000 (14:02 +0100)
committerBanana <banana@optimus.de>
Sun, 1 Jan 2017 13:02:20 +0000 (14:02 +0100)
12 files changed:
source/foundation.info
webroot/asset/css/app.css
webroot/asset/img/insipid.png [deleted file]
webroot/index.php
webroot/lib/link.class.php
webroot/lib/management.class.php
webroot/view/home.inc.php
webroot/view/home.php
webroot/view/linkinfo.inc.php [new file with mode: 0644]
webroot/view/linkinfo.php [new file with mode: 0644]
webroot/view/overview.inc.php [new file with mode: 0644]
webroot/view/overview.php [new file with mode: 0644]

index c9e0c617f82cc28f974eeefbe9ed8ffe198b32a0..99ee314dd9db721b5d1617dae80f6bc1e02658d8 100644 (file)
@@ -1 +1 @@
-Foundation with flex active
+Foundation with flex grid active
index 3e8e7f64a1a63705ef392ca4cf07976bbab0d6e8..da480a89165bf0ce8864d5d48da7b73b9334514a 100644 (file)
@@ -1,3 +1,16 @@
 .linkthumbnail {
        max-height: 200px;
+}
+
+h4 a {
+       color: #000;
+}
+.linkbox {
+       border: 1px solid #ccc;
+       overflow: hidden;
+}
+
+.infolink {
+       padding-left: 10px;
+       color: red;
 }
\ No newline at end of file
diff --git a/webroot/asset/img/insipid.png b/webroot/asset/img/insipid.png
deleted file mode 100644 (file)
index 9a374a0..0000000
Binary files a/webroot/asset/img/insipid.png and /dev/null differ
index ccfe2104e7e578d69f3a75e004ef6e921d57159c..c7825451884990159c2a851eabc8c743c71cb6c6 100644 (file)
@@ -81,15 +81,13 @@ $DB->query("SET collation_connection = 'utf8mb4_bin'");
 # management needs the DB object
 $Management = new Management($DB);
 
-/*
 if(isset($_GET['p']) && !empty($_GET['p'])) {
-    $_requestMode = trim($_GET['p']);
-    $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : "dashboard";
+    $_requestPage = trim($_GET['p']);
+    $_requestPage = Summoner::validate($_requestPage,'nospace') ? $_requestPage : "home";
 
-    $ViewScript = $_requestMode.'/'.$_requestMode.'.php';
-    $View = $_requestMode.'/'.$_requestMode.'.html';
+    $ViewScript = $_requestPage.'.inc.php';
+    $View = $_requestPage.'.php';
 }
-*/
 
 # now inlcude the script
 # this sets informatio into $Data and can overwrite $View
index e61b5ae79e37878aa9a85ad7f7e6671dc008e29b..20b869caa7c3705a26db061334f5c02b1f537764 100644 (file)
@@ -43,6 +43,32 @@ class Link {
         $this->DB = $databaseConnectionObject;
     }
 
+    /**
+     * load all the info we have about a link by given hash
+     * @param string $hash
+     * @return mixed
+     */
+    public function load($hash) {
+        $ret = false;
+
+        if(!empty($hash)) {
+            $queryStr = "SELECT * FROM `".DB_PREFIX."_link`
+                            WHERE `hash` = '".$this->DB->real_escape_string($hash)."'";
+            $query = $this->DB->query($queryStr);
+            if(!empty($query) && $query->num_rows == 1) {
+                $ret = $query->fetch_assoc();
+
+                $this->id = $ret['hash'];
+
+                # add stuff
+                $ret['tags'] = $this->_tags();
+                $ret['categories'] = $this->_categories();
+            }
+        }
+
+        return $ret;
+    }
+
     public function create($data) {}
 
     /**
@@ -60,7 +86,45 @@ class Link {
             $query = $this->DB->query($queryStr);
             if(!empty($query) && $query->num_rows > 0) {
                 $result = $query->fetch_assoc();
-                $ret = $result['id'];
+                $ret = $result['hash'];
+            }
+        }
+
+        return $ret;
+    }
+
+    /**
+     * load all the tags we have to the already loaded link
+     * needs $this->load called first
+     */
+    private function _tags() {
+        $ret = array();
+
+        if(!empty($this->id)) {
+            $queryStr = "SELECT DISTINCT(tag) FROM `".DB_PREFIX."_combined`
+                            WHERE `hash` = '".$this->DB->real_escape_string($this->id)."'";
+            $query = $this->DB->query($queryStr);
+            if(!empty($query) && $query->num_rows > 0) {
+                $ret = $query->fetch_all(MYSQLI_ASSOC);
+            }
+        }
+
+        return $ret;
+    }
+
+    /**
+     * load all the categories we have to the already loaded link
+     * needs $this->load called first
+     */
+    private function _categories() {
+        $ret = array();
+
+        if(!empty($this->id)) {
+            $queryStr = "SELECT DISTINCT(category) FROM `".DB_PREFIX."_combined`
+                            WHERE `hash` = '".$this->DB->real_escape_string($this->id)."'";
+            $query = $this->DB->query($queryStr);
+            if(!empty($query) && $query->num_rows > 0) {
+                $ret = $query->fetch_all(MYSQLI_ASSOC);
             }
         }
 
index 458247562e2ce11b2eeedbcfabb8467f5efe09c3..d1a45e34a043c5dc67aef95f095f49b012e4c6ad 100644 (file)
@@ -85,6 +85,9 @@ class Management {
         $ret = array();
 
         $queryStr = "SELECT * FROM `".DB_PREFIX."_link` WHERE `status` = 2 ORDER BY `created` DESC";
+        if(!empty($limit)) {
+            $queryStr .= " LIMIT $limit";
+        }
         $query = $this->DB->query($queryStr);
         if(!empty($query) && $query->num_rows > 0) {
             $ret = $query->fetch_all(MYSQLI_ASSOC);
@@ -120,6 +123,12 @@ class Management {
         return $ret;
     }
 
+    /**
+     * find all links by given category string.
+     * Return array sorted by creation date DESC
+     * @param string $string
+     * @param number $limit
+     */
     public function linksByCategoryString($string,$limit=5) {
         $ret = array();
 
@@ -128,6 +137,49 @@ class Management {
                 AND `category` = '".$this->DB->real_escape_string($string)."'
             GROUP BY `hash`
             ORDER BY `created` DESC";
+        if(!empty($limit)) {
+            $queryStr .= " LIMIT $limit";
+        }
+        $query = $this->DB->query($queryStr);
+        if(!empty($query) && $query->num_rows > 0) {
+            $ret = $query->fetch_all(MYSQLI_ASSOC);
+        }
+
+        return $ret;
+    }
+
+    /**
+     * find all links by given tag string.
+     * Return array sorted by creation date DESC
+     * @param string $string
+     * @param number $limit
+     */
+    public function linksByTagString($string,$limit=5) {
+        $ret = array();
+
+        $queryStr = "SELECT * FROM `".DB_PREFIX."_combined`
+            WHERE `status` = 2
+                AND `tag` = '".$this->DB->real_escape_string($string)."'
+            GROUP BY `hash`
+            ORDER BY `created` DESC";
+        if(!empty($limit)) {
+            $queryStr .= " LIMIT $limit";
+        }
+        $query = $this->DB->query($queryStr);
+        if(!empty($query) && $query->num_rows > 0) {
+            $ret = $query->fetch_all(MYSQLI_ASSOC);
+        }
+
+        return $ret;
+    }
+
+    public function all($limit=false) {
+        $ret = array();
+
+        $queryStr = "SELECT * FROM `".DB_PREFIX."_combined`
+                        WHERE `status` = 2
+                        GROUP BY `hash`
+                        ORDER BY `created` DESC";
         $query = $this->DB->query($queryStr);
         if(!empty($query) && $query->num_rows > 0) {
             $ret = $query->fetch_all(MYSQLI_ASSOC);
index d6036009027bbe4d0efc961389cb4f7608a060ef..5823dad176bbe39b82d3675666b037c1ccbf98e6 100644 (file)
@@ -115,6 +115,7 @@ if(isset($_POST['data']) && !empty($_POST['data']) && isset($_POST['addnewone'])
     $isUrl = Summoner::validate($formData['url'],'url');
 
     if($isUrl === true && !empty($formData['title']) && $username === FRONTEND_USERNAME && $password === FRONTEND_PASSWORD) {
+        $hash = md5($formData['url']);
         $queryStr = "INSERT IGNORE INTO `".DB_PREFIX."_link` SET
                         `link` = '".$DB->real_escape_string($formData['url'])."',
                         `created` = NOW(),
@@ -122,7 +123,7 @@ if(isset($_POST['data']) && !empty($_POST['data']) && isset($_POST['addnewone'])
                         `description` = '".$DB->real_escape_string($formData['description'])."',
                         `title` = '".$DB->real_escape_string($formData['title'])."',
                         `image` = '".$DB->real_escape_string($formData['image'])."',
-                        `hash` = '".$DB->real_escape_string(md5($formData['url']))."'";
+                        `hash` = '".$DB->real_escape_string($hash)."'";
         $DB->query($queryStr);
         $linkID = $DB->insert_id;
 
@@ -153,7 +154,7 @@ if(isset($_POST['data']) && !empty($_POST['data']) && isset($_POST['addnewone'])
 
             $submitFeedback['message'] = 'Link added successfully.';
             $submitFeedback['status'] = 'success';
-            $TemplateData['refresh'] = 'index.php?p=showlink&id='.$linkID;
+            $TemplateData['refresh'] = 'index.php?p=linkinfo&id='.$hash;
         }
         else {
             $submitFeedback['message'] = 'Something went wrong...';
index 76b59b7f4d89c8a8ae5433537a2cc3bab8058f58..7cfb3b65258c3be99c8b55a910d5f5c5bd369ab4 100644 (file)
@@ -39,7 +39,7 @@
                        <input type="hidden" name="username" />
                <div class="input-group">
                        <span class="input-group-label"><i class="fi-link"></i></span>
-                       <input class="input-group-field" type="url" name="data[searchfield]">
+                       <input class="input-group-field" type="text" name="data[searchfield]">
                        <div class="input-group-button">
                                <input type="submit" class="button" value="Search" name="submitsearch">
                        </div>
@@ -74,7 +74,7 @@
 <?php foreach ($searchResult as $sr) { ?>
                <li>
                        <a href="<?php echo $sr['link']; ?>" target="_blank" ><?php echo $sr['title']; ?></a>
-                       <a href="<?php echo $sr['link']; ?>" ><i class="fi-info"></i></a>
+                       <a class="infolink" title="more details..." href="index.php?p=linkinfo&id=<?php echo $sr['hash']; ?>" ><i class="fi-list"></i></a>
                </li>
 <?php } ?>
                </ul>
 </form>
 <?php } ?>
 
-<div class="row expanded small-up-2 medium-up-3 large-up-4" data-equalizer data-equalize-by-row="true">
+<div class="row expanded small-up-2 medium-up-3 large-up-6" data-equalizer data-equalize-by-row="true">
        <div class="column" >
                <div class="card" data-equalizer-watch>
                        <div class="card-divider">
-                       <h4>Last added</h4>
+                       <h4><a href="index.php?p=overview&m=all">Last added</a></h4>
                        </div>
-                       <img src="asset/img/insipid.png">
                        <div class="card-section">
 <?php if(!empty($latestLinks)) { ?>
                                <ul>
                                        </li>
 <?php } ?>
                                </ul>
-                               <a class="button" href="#">more</a>
 <?php } ?>
                        </div>
                </div>
        <div class="column">
                <div class="card" data-equalizer-watch>
                        <div class="card-divider">
-                               <h4><?php echo $cat; ?></h4>
+                               <h4><a href="?p=overview&m=category&id=<?php echo urlencode($cat); ?>"><?php echo $cat; ?></a></h4>
                        </div>
-                       <img src="assets/img/generic/rectangle-1.jpg">
                        <div class="card-section">
                                <ul>
 <?php foreach ($links as $link) { ?>
                                        </li>
 <?php } ?>
                                </ul>
-                               <a class="button" href="#">more</a>
                        </div>
                </div>
        </div>
diff --git a/webroot/view/linkinfo.inc.php b/webroot/view/linkinfo.inc.php
new file mode 100644 (file)
index 0000000..cbb9637
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Insipid
+ * Personal web-bookmark-system
+ *
+ * Copyright 2016-2017 Johannes Keßler
+ *
+ * Development starting from 2011: Johannes Keßler
+ * https://www.bananas-playground.net/projekt/insipid/
+ *
+ * creator:
+ * Luke Reeves <luke@neuro-tech.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ */
+$_requestMode = false;
+if(isset($_GET['m']) && !empty($_GET['m'])) {
+    $_requestMode = trim($_GET['m']);
+    $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : "all";
+}
+
+$_id = false;
+if(isset($_GET['id']) && !empty($_GET['id'])) {
+    $_id = trim($_GET['id']);
+    $_id = Summoner::validate($_id,'nospace') ? $_id : false;
+}
+
+$linkObj = new Link($DB);
+$link = $linkObj->load($_id);
+if(empty($link)) {
+    header("HTTP/1.0 404 Not Found");
+}
\ No newline at end of file
diff --git a/webroot/view/linkinfo.php b/webroot/view/linkinfo.php
new file mode 100644 (file)
index 0000000..624fc9b
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+/**
+ * Insipid
+ * Personal web-bookmark-system
+ *
+ * Copyright 2016-2017 Johannes Keßler
+ *
+ * Development starting from 2011: Johannes Keßler
+ * https://www.bananas-playground.net/projekt/insipid/
+ *
+ * creator:
+ * Luke Reeves <luke@neuro-tech.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ */
+ ?>
+<?php if(empty($link)) { ?>
+<div class="callout alert">
+       <h5>Error</h5>
+       <p>Something went wrong...</p>
+</div>
+<?php } ?>
+<div class="row">
+       <div class="large-12 columns">
+               <h1 class="text-center"><?php echo $link['title']; ?></h1>
+       </div>
+</div>
+<div class="row expanded">
+       <div class="large-12 columns">
+               <p class="text-right"><a href="index.php" title="... back to home"><i class="fi-home"></i></a></p>
+       </div>
+</div>
+<div class="row">
+       <div class="small-12 medium-2 columns">
+               <p>Title:</p>
+       </div>
+       <div class="small-12 medium-10 columns">
+               <p><?php echo $link['title']; ?></p>
+       </div>
+</div>
+<div class="row">
+       <div class="small-12 medium-2 columns">
+               <p>Description:</p>
+       </div>
+       <div class="small-12 medium-10 columns">
+               <p><?php echo $link['description']; ?></p>
+       </div>
+</div>
+<div class="row">
+       <div class="small-12 medium-2 columns">
+               <p>
+                       Image:<br />
+                       <small>If provided</small>
+               </p>
+       </div>
+       <div class="small-12 medium-10 columns">
+               <p>
+                       <img class="linkthumbnail" src="<?php echo $link['image']; ?>" alt="Image if provided">
+               </p>
+       </div>
+</div>
+<div class="row">
+       <div class="small-12 medium-2 columns">
+               <p>Date added:</p>
+       </div>
+       <div class="small-12 medium-10 columns">
+               <p><?php echo $link['created']; ?></p>
+       </div>
+</div>
+<div class="row">
+       <div class="small-12 medium-2 columns">
+               <p>Tags:</p>
+       </div>
+       <div class="small-12 medium-10 columns">
+               <?php
+            if(!empty($link['tags'])) {
+                     foreach($link['tags'] as $v) {
+        ?>
+               <a href="index.php?p=overview&m=tag&id=<?php echo urlencode($v['tag']); ?>" class="button tiny"><i class="fi-price-tag"></i> <?php echo $v['tag']; ?></a>
+        <?php
+                     }
+            }
+           ?>
+       </div>
+</div>
+<div class="row">
+       <div class="small-12 medium-2 columns">
+               <p>Category:</p>
+       </div>
+       <div class="small-12 medium-10 columns">
+               <?php
+            if(!empty($link['categories'])) {
+                     foreach($link['categories'] as $v) {
+        ?>
+               <a href="index.php?p=overview&m=category&id=<?php echo urlencode($v['category']); ?>" class="button tiny"><i class="fi-ticket"></i> <?php echo $v['category']; ?></a>
+        <?php
+                     }
+            }
+           ?>
+       </div>
+</div>
+
diff --git a/webroot/view/overview.inc.php b/webroot/view/overview.inc.php
new file mode 100644 (file)
index 0000000..f4c0fe5
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Insipid
+ * Personal web-bookmark-system
+ *
+ * Copyright 2016-2017 Johannes Keßler
+ *
+ * Development starting from 2011: Johannes Keßler
+ * https://www.bananas-playground.net/projekt/insipid/
+ *
+ * creator:
+ * Luke Reeves <luke@neuro-tech.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ */
+$_requestMode = false;
+if(isset($_GET['m']) && !empty($_GET['m'])) {
+    $_requestMode = trim($_GET['m']);
+    $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : "all";
+}
+
+$_id = false;
+if(isset($_GET['id']) && !empty($_GET['id'])) {
+    $_id = trim($_GET['id']);
+    $_id = Summoner::validate($_id,'nospace') ? $_id : false;
+}
+
+$linkCollection = array();
+$subHeadline = false;
+$tagCollection = array();
+$categoryCollection = array();
+
+switch($_requestMode) {
+    case 'tag':
+        if(!empty($_id)) {
+            $linkCollection = $Management->linksByTagString($_id,false);
+            if(!empty($linkCollection)) {
+                $subHeadline = $linkCollection[0]['tag'];
+            }
+        }
+        else {
+            # show all the tags we have
+            $tagCollection = $Management->tags();
+            $subHeadline = 'All the tags <i class="fi-price-tag"></i>';
+        }
+    break;
+    case 'category':
+        if(!empty($_id)) {
+            $linkCollection = $Management->linksByCategoryString($_id,false);
+            if(!empty($linkCollection)) {
+                $subHeadline = $linkCollection[0]['category'];
+            }
+        }
+        else {
+            # show all the categories we have
+            $categoryCollection = $Management->categories();
+            $subHeadline = 'All the categories <i class="fi-ticket"></i>';
+        }
+    break;
+    case 'all':
+    default:
+        # show all
+        $linkCollection = $Management->all();
+}
diff --git a/webroot/view/overview.php b/webroot/view/overview.php
new file mode 100644 (file)
index 0000000..011fd94
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+/**
+ * Insipid
+ * Personal web-bookmark-system
+ *
+ * Copyright 2016-2017 Johannes Keßler
+ *
+ * Development starting from 2011: Johannes Keßler
+ * https://www.bananas-playground.net/projekt/insipid/
+ *
+ * creator:
+ * Luke Reeves <luke@neuro-tech.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ */
+ ?>
+<div class="row">
+       <div class="large-12 columns">
+               <h1 class="text-center">All of your links</h1>
+               <?php if(!empty($subHeadline)) { ?>
+               <h4 class="text-center"><?php echo $subHeadline; ?></h4>
+               <?php } ?>
+       </div>
+</div>
+<div class="row expanded">
+       <div class="large-12 columns">
+               <p class="text-right">
+                       <a href="index.php?p=overview&m=tag" title="all tags"><i class="fi-price-tag"></i></a>
+                       <a href="index.php?p=overview&m=category" title="all categories"><i class="fi-ticket"></i></a>
+                       <a href="index.php" title="... back to home"><i class="fi-home"></i></a>
+               </p>
+       </div>
+</div>
+
+<?php if(!empty($linkCollection)) { ?>
+<div class="row expanded small-up-1 medium-up-2 large-up-3" data-equalizer data-equalize-by-row="true">
+<?php foreach ($linkCollection as $link) { ?>
+       <div class="column">
+               <div class="media-object linkbox" data-equalizer-watch>
+               <?php if(!empty($link['image'])) { ?>
+               <div class="media-object-section">
+                       <a href="<?php echo $link['link']; ?>" target="_blank">
+               <img class="linkthumbnail" src= "<?php echo $link['image']; ?>">
+               </a>
+               </div>
+               <?php } ?>
+               <div class="media-object-section">
+                   <h4><a href="<?php echo $link['link']; ?>" target="_blank"><?php echo $link['title']; ?></a></h4>
+               <p><?php echo $link['description']; ?></p>
+               <p>
+                       <a href="<?php echo $link['link']; ?>" target="_blank" class="small button">Visit link</a>
+                       <a href="index.php?p=linkinfo&id=<?php echo $link['hash']; ?>" class="small button">More details</a>
+               </p>
+                 </div>
+        </div>
+       </div>
+<?php } ?>
+</div>
+<?php } if(!empty($tagCollection)) { ?>
+<div class="row">
+       <div class="large-12 columns">
+               <ul>
+               <?php foreach ($tagCollection as $t) { ?>
+                       <li><a href="index.php?p=overview&m=tag&id=<?php echo urlencode($t['name']); ?>"><?php echo $t['name']; ?></a></li>
+               <?php } ?>
+               </ul>
+       </div>
+</div>
+<?php } if(!empty($categoryCollection)) { ?>
+<div class="row">
+       <div class="large-12 columns">
+               <ul>
+               <?php foreach ($categoryCollection as $c) { ?>
+                       <li><a href="index.php?p=overview&m=category&id=<?php echo urlencode($c['name']); ?>"><?php echo $c['name']; ?></a></li>
+               <?php } ?>
+               </ul>
+       </div>
+</div>
+<?php } ?>
+