-Foundation with flex active
+Foundation with flex grid active
.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
# 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
$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) {}
/**
$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);
}
}
$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);
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();
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);
$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(),
`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;
$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...';
<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>
<?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>
--- /dev/null
+<?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
--- /dev/null
+<?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>
+
--- /dev/null
+<?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();
+}
--- /dev/null
+<?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 } ?>
+