From: Banana Date: Sun, 1 Jan 2017 13:02:20 +0000 (+0100) Subject: link info detail page. tag and category listing. commin overviewpage X-Git-Tag: 2.1-alpha-2019-0-29~52 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=cbda9a65ee89e1b0858daf9e5598ba96130fb592;p=insipid.git link info detail page. tag and category listing. commin overviewpage --- diff --git a/source/foundation.info b/source/foundation.info index c9e0c61..99ee314 100644 --- a/source/foundation.info +++ b/source/foundation.info @@ -1 +1 @@ -Foundation with flex active +Foundation with flex grid active diff --git a/webroot/asset/css/app.css b/webroot/asset/css/app.css index 3e8e7f6..da480a8 100644 --- a/webroot/asset/css/app.css +++ b/webroot/asset/css/app.css @@ -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 index 9a374a0..0000000 Binary files a/webroot/asset/img/insipid.png and /dev/null differ diff --git a/webroot/index.php b/webroot/index.php index ccfe210..c782545 100644 --- a/webroot/index.php +++ b/webroot/index.php @@ -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 diff --git a/webroot/lib/link.class.php b/webroot/lib/link.class.php index e61b5ae..20b869c 100644 --- a/webroot/lib/link.class.php +++ b/webroot/lib/link.class.php @@ -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); } } diff --git a/webroot/lib/management.class.php b/webroot/lib/management.class.php index 4582475..d1a45e3 100644 --- a/webroot/lib/management.class.php +++ b/webroot/lib/management.class.php @@ -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); diff --git a/webroot/view/home.inc.php b/webroot/view/home.inc.php index d603600..5823dad 100644 --- a/webroot/view/home.inc.php +++ b/webroot/view/home.inc.php @@ -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...'; diff --git a/webroot/view/home.php b/webroot/view/home.php index 76b59b7..7cfb3b6 100644 --- a/webroot/view/home.php +++ b/webroot/view/home.php @@ -39,7 +39,7 @@
- +
@@ -74,7 +74,7 @@
  • - +
  • @@ -179,13 +179,12 @@ -
    +
    -

    Last added

    +

    Last added

    -
      @@ -195,7 +194,6 @@
    - more
    @@ -208,9 +206,8 @@
    -

    +

    -
      @@ -219,7 +216,6 @@
    - more
    diff --git a/webroot/view/linkinfo.inc.php b/webroot/view/linkinfo.inc.php new file mode 100644 index 0000000..cbb9637 --- /dev/null +++ b/webroot/view/linkinfo.inc.php @@ -0,0 +1,44 @@ + + * + * 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 index 0000000..624fc9b --- /dev/null +++ b/webroot/view/linkinfo.php @@ -0,0 +1,114 @@ + + * + * 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. + * + */ + ?> + +
    +
    Error
    +

    Something went wrong...

    +
    + +
    +
    +

    +
    +
    +
    +
    +

    +
    +
    +
    +
    +

    Title:

    +
    +
    +

    +
    +
    +
    +
    +

    Description:

    +
    +
    +

    +
    +
    +
    +
    +

    + Image:
    + If provided +

    +
    +
    +

    + Image if provided +

    +
    +
    +
    +
    +

    Date added:

    +
    +
    +

    +
    +
    +
    +
    +

    Tags:

    +
    +
    + + + +
    +
    +
    +
    +

    Category:

    +
    +
    + + + +
    +
    + diff --git a/webroot/view/overview.inc.php b/webroot/view/overview.inc.php new file mode 100644 index 0000000..f4c0fe5 --- /dev/null +++ b/webroot/view/overview.inc.php @@ -0,0 +1,76 @@ + + * + * 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 '; + } + 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 '; + } + 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 index 0000000..011fd94 --- /dev/null +++ b/webroot/view/overview.php @@ -0,0 +1,92 @@ + + * + * 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. + * + */ + ?> +
    +
    +

    All of your links

    + +

    + +
    +
    +
    +
    +

    + + + +

    +
    +
    + + +
    + +
    + +
    + +
    + +
    +
    +
      + +
    • + +
    +
    +
    + +
    +
    +
      + +
    • + +
    +
    +
    + +