+ theme support
+ bookmark js snippet
+ snapshots
-+ stats
++ stats, storage usage
+ private links
+ more "secure" user authentication
++ multiple user accounts and stuff
return $this->_data;
}
+ /**
+ * loads only the info needed to display the link
+ * for edit use $this->load
+ * @param $hash
+ * @return array
+ */
+ public function loadShortInfo($hash) {
+ $this->_data = array();
+
+ if(!empty($hash)) {
+ $queryStr = "SELECT
+ any_value(`id`) as id,
+ any_value(`link`) as link,
+ any_value(`description`) as description,
+ any_value(`title`) as title,
+ any_value(`image`) as image,
+ any_value(`hash`) as hash
+ FROM `".DB_PREFIX."_link`
+ WHERE `hash` = '".$this->DB->real_escape_string($hash)."'";
+ $query = $this->DB->query($queryStr);
+ if(!empty($query) && $query->num_rows == 1) {
+ $this->_data = $query->fetch_assoc();
+
+ # add stuff
+ $this->_image();
+ }
+ }
+
+ return $this->_data;
+ }
+
+ /**
+ * return all or data fpr given key on the current loaded link
+ * @param bool $key
+ * @return array|mixed
+ */
public function getData($key=false) {
$ret = $this->_data;
/**
* return all links and Info we have from the combined view
* @param bool | int $limit
+ * @param bool $offset
* @return array
*/
public function links($limit=false,$offset=false) {
$ret = array();
- $queryStr = "SELECT ".$this->COMBINED_SELECT_VALUES."
- FROM `".DB_PREFIX."_combined`
+ $queryStr = "SELECT `hash`
+ FROM `".DB_PREFIX."_link`
WHERE `status` = 2
- 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['results'] = $query->fetch_all(MYSQLI_ASSOC);
+ while($result = $query->fetch_assoc()) {
+ $linkObj = new Link($this->DB);
+ $ret['results'][] = $linkObj->loadShortInfo($result['hash']);
+ unset($linkObj);
+ }
$query = $this->DB->query("SELECT COUNT(DISTINCT(hash)) AS `amount`
FROM `".DB_PREFIX."_combined`
<figure class="image is-4by3">
<a href="<?php echo $link['link']; ?>" target="_blank">
<?php if(!empty($link['image'])) { ?>
- <img class="linkthumbnail" src= "<?php echo $link['image']; ?>">
+ <img class="linkthumbnail" src= "<?php echo $link['imageToShow']; ?>">
<?php } else { ?>
<img class="" src= "asset/img/no-link-picture.png">
<?php } ?>