* Insipid
* Personal web-bookmark-system
*
- * Copyright 2016-2020 Johannes Keßler
+ * Copyright 2016-2021 Johannes Keßler
*
* Development starting from 2011: Johannes Keßler
* https://www.bananas-playground.net/projekt/insipid/
/**
* loads only the info needed to display the link
* for edit use $this->load
+ *
* @param $hash
* @return array
*/
$this->_data = array();
if (!empty($hash)) {
- $queryStr = "SELECT `id`,`link`,`description`,`title`,`image`,`hash`
+ $queryStr = "SELECT `id`,`link`,`description`,`title`,`image`,`hash`, `created`
FROM `" . DB_PREFIX . "_link`
WHERE `hash` = '" . $this->DB->real_escape_string($hash) . "'";
return $this->_data;
}
+ public function loadFromDataShortInfo($data) {
+ $this->_data = array();
+
+ if(isset($data['id']) && isset($data['link']) && isset($data['created']) && isset($data['status'])
+ && isset($data['title']) && isset($data['hash']) && isset($data['description']) && isset($data['image'])) {
+ $this->_data = $data;
+ $this->_image();
+ }
+
+ return $this->_data;
+ }
+
/**
* return all or data for given key on the current loaded link
+ *
* @param bool $key
* @return array|mixed
*/
* Insipid
* Personal web-bookmark-system
*
- * Copyright 2016-2020 Johannes Keßler
+ * Copyright 2016-2021 Johannes Keßler
*
* Development starting from 2011: Johannes Keßler
* https://www.bananas-playground.net/projekt/insipid/
/**
* find all links by given category string or id.
* Return array sorted by creation date DESC
+ *
* @param int $id Category ID
- * @param string $string Category as string
* @param array $options Array with limit|offset|sort|sortDirection
* @return array
*/
- public function linksByCategory($id, $string, $options=array()) {
+ public function linksByCategory($id, $options=array()) {
$ret = array();
if(!isset($options['limit'])) $options['limit'] = 5;
if(!isset($options['sort'])) $options['sort'] = false;
if(!isset($options['sortDirection'])) $options['sortDirection'] = false;
- $querySelect = "SELECT ".self::COMBINED_SELECT_VALUES;
- $queryFrom = " FROM `".DB_PREFIX."_combined` AS t";
+ $querySelect = "SELECT `id`, `link`, `created`, `status`, `title`, `hash`, `description`, `image`";
+ $queryFrom = " FROM `".DB_PREFIX."_link` AS t
+ LEFT JOIN insipid_categoryrelation AS cr ON cr.linkid = t.id";
$queryWhere = " WHERE ".$this->_decideLinkTypeForQuery();
if(!empty($id) && is_numeric($id)) {
- $queryWhere .= " AND t.categoryId = '" . $this->DB->real_escape_string($id) . "'";
- }
- elseif(!empty($string) && is_string($string)) {
- $queryWhere .= " AND t.category = '" . $this->DB->real_escape_string($string) . "'";
+ $queryWhere .= " AND cr.categoryId = '" . $this->DB->real_escape_string($id) . "'";
}
else {
return $ret;
}
- $queryGroup = " GROUP BY t.hash";
$queryOrder = " ORDER BY";
if(!empty($options['sort'])) {
$queryOrder .= ' t.'.$options['sort'];
$queryLimit .= " OFFSET ".$options['offset'];
}
}
- $query = $this->DB->query($querySelect.$queryFrom.$queryWhere.$queryGroup.$queryOrder.$queryLimit);
+ $query = $this->DB->query($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit);
if(!empty($query) && $query->num_rows > 0) {
while($result = $query->fetch_assoc()) {
$linkObj = new Link($this->DB);
- $ret['results'][] = $linkObj->loadShortInfo($result['hash']);
+ $ret['results'][] = $linkObj->loadFromDataShortInfo($result);
unset($linkObj);
}
/**
* find all links by given tag string or id.
* Return array sorted by creation date DESC
+ *
* @param int $id Tag id
- * @param string $string Tag as string
* @param array $options Array with limit|offset|sort|sortDirection
* @return array
*/
- public function linksByTag($id, $string, $options=array()) {
+ public function linksByTag($id, $options=array()) {
$ret = array();
if(!isset($options['limit'])) $options['limit'] = 5;
if(!isset($options['sort'])) $options['sort'] = false;
if(!isset($options['sortDirection'])) $options['sortDirection'] = false;
- $querySelect = "SELECT ".self::COMBINED_SELECT_VALUES;
- $queryFrom = " FROM `".DB_PREFIX."_combined` AS t";
+ $querySelect = "SELECT `id`, `link`, `created`, `status`, `title`, `hash`, `description`, `image`";
+ $queryFrom = " FROM `".DB_PREFIX."_link` AS t
+ LEFT JOIN insipid_tagrelation AS tr ON tr.linkid = t.id";
$queryWhere = " WHERE ".$this->_decideLinkTypeForQuery();
if(!empty($id) && is_numeric($id)) {
- $queryWhere .= " AND t.tagId = '" . $this->DB->real_escape_string($id) . "'";
- }
- elseif(!empty($string) && is_string($string)) {
- $queryWhere .= " AND t.tag = '" . $this->DB->real_escape_string($string) . "'";
+ $queryWhere .= " AND tr.tagId = '".$this->DB->real_escape_string($id)."'";
}
else {
return $ret;
}
- $queryGroup = " GROUP BY t.hash";
$queryOrder = " ORDER BY";
if(!empty($options['sort'])) {
$queryOrder .= ' t.'.$options['sort'];
$queryLimit .= " OFFSET ".$options['offset'];
}
}
- $query = $this->DB->query($querySelect.$queryFrom.$queryWhere.$queryGroup.$queryOrder.$queryLimit);
+ $query = $this->DB->query($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit);
if(!empty($query) && $query->num_rows > 0) {
while($result = $query->fetch_assoc()) {
$linkObj = new Link($this->DB);
- $ret['results'][] = $linkObj->loadShortInfo($result['hash']);
+ $ret['results'][] = $linkObj->loadFromDataShortInfo($result);
unset($linkObj);
}
/**
* return the latest added link for given category id
+ *
* @param int $categoryid
* @return array
*/
$ret = array();
if(!empty($categoryid) && is_numeric($categoryid)) {
- $queryStr = "SELECT ".self::COMBINED_SELECT_VALUES."
- FROM `".DB_PREFIX."_combined` AS t";
+ $queryStr = "SELECT `id`, `link`, `created`, `status`, `description`, `title`, `image`, `hash`,
+ `tag`, `category`, `categoryId`, `tagId`
+ FROM `".DB_PREFIX."_combined` AS t";
$queryStr .= " WHERE ".$this->_decideLinkTypeForQuery();
$queryStr .= " AND t.categoryId = '" . $this->DB->real_escape_string($categoryid) . "'
ORDER BY t.created DESC
* Insipid
* Personal web-bookmark-system
*
- * Copyright 2016-2020 Johannes Keßler
+ * Copyright 2016-2021 Johannes Keßler
*
* Development starting from 2011: Johannes Keßler
* https://www.bananas-playground.net/projekt/insipid/
$tagname = $tagObj->getData('name');
$subHeadline = $tagname.' <i class="ion-md-pricetag"></i>';
- $linkCollection = $Management->linksByTag($_id,'', $_LinkColllectionQueryOptions);
+ $linkCollection = $Management->linksByTag($_id, $_LinkColllectionQueryOptions);
$currentGetParameters['id'] = $_id;
}
$catname = $catObj->getData('name');
$subHeadline = $catname.' <i class="ion-md-filing"></i>';
- $linkCollection = $Management->linksByCategory($_id,'', $_LinkColllectionQueryOptions);
+ $linkCollection = $Management->linksByCategory($_id, $_LinkColllectionQueryOptions);
$currentGetParameters['id'] = $_id;
}
$sortLink['default'] = Summoner::createFromParameterLinkQuery($currentGetParameters,array('s'=>false,'sd'=>false));
$sortLink['name'] = Summoner::createFromParameterLinkQuery($currentGetParameters,array('s'=>'title','sd'=>false));
-$sortLink['direction'] = Summoner::createFromParameterLinkQuery($currentGetParameters,array('sd'=>'asc'));
\ No newline at end of file
+$sortLink['direction'] = Summoner::createFromParameterLinkQuery($currentGetParameters,array('sd'=>'asc'));