From: Banana Date: Mon, 8 Mar 2021 21:54:41 +0000 (+0100) Subject: some data loading brain fucks removed X-Git-Tag: 2.6_2021-03-21^2~5 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=fbd58b3e945cc4c7aa6028d18f28c374a3f1641a;p=insipid.git some data loading brain fucks removed --- diff --git a/ChangeLog b/ChangeLog index ff1eb15..1a0f9d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ -version 2.5.3 - Hypostyle +version 2.6 - Hypostyle + + Fixed sql problems with Maria DB. Any_value is not supported there + + Fixed some query and data loading brain fucks.. version 2.5.2 - Darkmere (2020-09-12) diff --git a/TODO b/TODO index d193e30..76a3096 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,11 @@ TODO / Feature list + translation support ++ adapt new php 7 +++ http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op + + stats cleanup. Management functions should be standalone + theme support + more "secure" user authentication ++ multiple user accounts and stuff -+ adapt new php 7 -++ http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op + combine cat and tag class into one. ++ view really still needed? diff --git a/webroot/lib/link.class.php b/webroot/lib/link.class.php index 64793d6..aa823f0 100644 --- a/webroot/lib/link.class.php +++ b/webroot/lib/link.class.php @@ -3,7 +3,7 @@ * 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/ @@ -86,6 +86,7 @@ class Link { /** * loads only the info needed to display the link * for edit use $this->load + * * @param $hash * @return array */ @@ -93,7 +94,7 @@ class Link { $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) . "'"; @@ -109,8 +110,21 @@ class Link { 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 */ diff --git a/webroot/lib/management.class.php b/webroot/lib/management.class.php index 2fe8e71..e269354 100644 --- a/webroot/lib/management.class.php +++ b/webroot/lib/management.class.php @@ -3,7 +3,7 @@ * 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/ @@ -227,12 +227,12 @@ class Management { /** * 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; @@ -240,20 +240,17 @@ class Management { 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']; @@ -277,12 +274,12 @@ class Management { $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); } @@ -297,12 +294,12 @@ class Management { /** * 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; @@ -310,20 +307,17 @@ class Management { 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']; @@ -347,12 +341,12 @@ class Management { $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); } @@ -402,6 +396,7 @@ class Management { /** * return the latest added link for given category id + * * @param int $categoryid * @return array */ @@ -409,8 +404,9 @@ class Management { $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 diff --git a/webroot/view/home.php b/webroot/view/home.php index 72fbd04..3a990e1 100644 --- a/webroot/view/home.php +++ b/webroot/view/home.php @@ -3,7 +3,7 @@ * 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/ @@ -261,7 +261,7 @@ $v) { - $links = $Management->linksByCategory($v['id'],''); + $links = $Management->linksByCategory($v['id']); ?>
diff --git a/webroot/view/overview.inc.php b/webroot/view/overview.inc.php index 44423b5..9bb53a7 100644 --- a/webroot/view/overview.inc.php +++ b/webroot/view/overview.inc.php @@ -3,7 +3,7 @@ * 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/ @@ -98,7 +98,7 @@ switch($_requestMode) { $tagname = $tagObj->getData('name'); $subHeadline = $tagname.' '; - $linkCollection = $Management->linksByTag($_id,'', $_LinkColllectionQueryOptions); + $linkCollection = $Management->linksByTag($_id, $_LinkColllectionQueryOptions); $currentGetParameters['id'] = $_id; } @@ -116,7 +116,7 @@ switch($_requestMode) { $catname = $catObj->getData('name'); $subHeadline = $catname.' '; - $linkCollection = $Management->linksByCategory($_id,'', $_LinkColllectionQueryOptions); + $linkCollection = $Management->linksByCategory($_id, $_LinkColllectionQueryOptions); $currentGetParameters['id'] = $_id; } @@ -169,4 +169,4 @@ else { $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'));