]> 91.132.146.200 Git - insipid.git/commitdiff
code tabs
authorBanana <banana@optimus.de>
Tue, 16 Jul 2019 15:28:23 +0000 (17:28 +0200)
committerBanana <banana@optimus.de>
Tue, 16 Jul 2019 15:28:23 +0000 (17:28 +0200)
webroot/lib/link.class.php
webroot/lib/summoner.class.php
webroot/view/editlink.inc.php
webroot/view/editlink.php
webroot/view/home.php
webroot/view/linkinfo.php
webroot/view/overview.php

index bd4867fa9b9fed328fb8193a8066c59c09a4e1b1..10174732b6e1ae2763d6c1bef3e4373c9c49c15b 100644 (file)
  */
 
 class Link {
-    /**
-     * the database object
-     * @var object
-     */
-    private $DB;
-
-    /**
-     * the current loaded link data
-     * @var array
-     */
-    private $_data;
-
-    public function __construct($databaseConnectionObject) {
-        $this->DB = $databaseConnectionObject;
-    }
-
-    /**
-     * load all the info we have about a link by given hash
-     * @param string $hash
-     * @return mixed
-     */
-    public function load($hash) {
-
-        $this->_data = array();
-
-        if(!empty($hash)) {
-            $queryStr = "SELECT
+       /**
+        * the database object
+        * @var object
+        */
+       private $DB;
+
+       /**
+        * the current loaded link data
+        * @var array
+        */
+       private $_data;
+
+       public function __construct($databaseConnectionObject) {
+               $this->DB = $databaseConnectionObject;
+       }
+
+       /**
+        * load all the info we have about a link by given hash
+        * @param string $hash
+        * @return mixed
+        */
+       public function load($hash) {
+
+               $this->_data = array();
+
+               if(!empty($hash)) {
+                       $queryStr = "SELECT
                                any_value(`id`) as id,
                                any_value(`link`) as link,
                                any_value(`created`) as created,
@@ -64,248 +64,248 @@ class Link {
                                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) {
+                               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->_tags();
-                $this->_categories();
-                $this->_image();
-            }
-        }
-
-        return $this->_data;
-    }
-
-    public function getData($key=false) {
-        $ret = $this->_data;
-
-        if(!empty($key) && isset($this->_data[$key])) {
-            $ret = $this->_data[$key];
-        }
-
-        return $ret;
-    }
-
-    /**
-     * reload the current id from DB
-     */
-    public function reload() {
-        $this->load($this->_data['hash']);
-    }
-
-    /**
-     * create a new link with the given data
-     * @param array $data
-     */
-    public function create($data) {
-    }
-
-    /**
-     * update the current loaded link with the given data
-     * @param array $data
-     * @return boolean|int
-     */
-    public function update($data) {
-
-        $ret = false;
-
-        if(isset($data['title']) && !empty($data['title'])) {
-
-            # categories and tag stuff
-            $catArr = Summoner::prepareTagOrCategoryStr($data['category']);
-            $tagArr = Summoner::prepareTagOrCategoryStr($data['tag']);
-
-            $search = $data['title'];
-            $search .= ' '.$data['description'];
-            $search .= ' '.implode(" ",$tagArr);
-            $search .= ' '.implode(" ",$catArr);
-
-            # did the image url change?
+                               # add stuff
+                               $this->_tags();
+                               $this->_categories();
+                               $this->_image();
+                       }
+               }
+
+               return $this->_data;
+       }
+
+       public function getData($key=false) {
+               $ret = $this->_data;
+
+               if(!empty($key) && isset($this->_data[$key])) {
+                       $ret = $this->_data[$key];
+               }
+
+               return $ret;
+       }
+
+       /**
+        * reload the current id from DB
+        */
+       public function reload() {
+               $this->load($this->_data['hash']);
+       }
+
+       /**
+        * create a new link with the given data
+        * @param array $data
+        */
+       public function create($data) {
+       }
+
+       /**
+        * update the current loaded link with the given data
+        * @param array $data
+        * @return boolean|int
+        */
+       public function update($data) {
+
+               $ret = false;
+
+               if(isset($data['title']) && !empty($data['title'])) {
+
+                       # categories and tag stuff
+                       $catArr = Summoner::prepareTagOrCategoryStr($data['category']);
+                       $tagArr = Summoner::prepareTagOrCategoryStr($data['tag']);
+
+                       $search = $data['title'];
+                       $search .= ' '.$data['description'];
+                       $search .= ' '.implode(" ",$tagArr);
+                       $search .= ' '.implode(" ",$catArr);
+
+                       # did the image url change?
                        $_imageUrlChanged = false;
                        if($this->_data['image'] != $data['image']) {
                                $_imageUrlChanged = true;
                        }
 
-            $queryStr = "UPDATE `".DB_PREFIX."_link` SET
-                            `status` = '".$this->DB->real_escape_string($data['private'])."',
-                            `description` = '".$this->DB->real_escape_string($data['description'])."',
-                            `title` = '".$this->DB->real_escape_string($data['title'])."',
-                            `image` = '".$this->DB->real_escape_string($data['image'])."',
-                            `search` = '".$this->DB->real_escape_string($search)."'
-                          WHERE `hash` = '".$this->DB->real_escape_string($this->_data['hash'])."'";
-
-            $query = $this->DB->query($queryStr);
-
-            $catObj = new Category($this->DB);
-            $tagObj = new Tag($this->DB);
-            // clean the relations first
-            $this->_removeTagRelation(false);
-            $this->_removeCategoryRelation(false);
-
-            if(!empty($catArr)) {
-                foreach($catArr as $c) {
-                    $catObj->initbystring($c);
-                    $catObj->setRelation($this->_data['id']);
-                }
-            }
-            if(!empty($tagArr)) {
-                foreach($tagArr as $t) {
-                    $tagObj->initbystring($t);
-                    $tagObj->setRelation($this->_data['id']);
-                }
-            }
-
-            # decide to store or remove the image
+                       $queryStr = "UPDATE `".DB_PREFIX."_link` SET
+                                                       `status` = '".$this->DB->real_escape_string($data['private'])."',
+                                                       `description` = '".$this->DB->real_escape_string($data['description'])."',
+                                                       `title` = '".$this->DB->real_escape_string($data['title'])."',
+                                                       `image` = '".$this->DB->real_escape_string($data['image'])."',
+                                                       `search` = '".$this->DB->real_escape_string($search)."'
+                                                 WHERE `hash` = '".$this->DB->real_escape_string($this->_data['hash'])."'";
+
+                       $query = $this->DB->query($queryStr);
+
+                       $catObj = new Category($this->DB);
+                       $tagObj = new Tag($this->DB);
+                       // clean the relations first
+                       $this->_removeTagRelation(false);
+                       $this->_removeCategoryRelation(false);
+
+                       if(!empty($catArr)) {
+                               foreach($catArr as $c) {
+                                       $catObj->initbystring($c);
+                                       $catObj->setRelation($this->_data['id']);
+                               }
+                       }
+                       if(!empty($tagArr)) {
+                               foreach($tagArr as $t) {
+                                       $tagObj->initbystring($t);
+                                       $tagObj->setRelation($this->_data['id']);
+                               }
+                       }
+
+                       # decide to store or remove the image
                        if(isset($data['localImage'])) {
-               $image = ABSOLUTE_PATH.'/'.LOCAL_STORAGE.'/thumbnail-'.$this->_data['hash'];
-               if($data['localImage'] === true) {
+                               $image = ABSOLUTE_PATH.'/'.LOCAL_STORAGE.'/thumbnail-'.$this->_data['hash'];
+                               if($data['localImage'] === true) {
                                        if(!file_exists($image) || $_imageUrlChanged === true) {
                                                Summoner::downloadFile($data['image'],$image);
                                        }
                                }
                                elseif($data['localImage'] === false) {
-                       if(file_exists($image)) {
-                               unlink($image);
+                                       if(file_exists($image)) {
+                                               unlink($image);
                                        }
                                }
                        }
 
-            $ret = true;
-        }
+                       $ret = true;
+               }
 
-        return $ret;
-    }
+               return $ret;
+       }
 
-    /**
-     * check if the given URL exists in the DB
-     * if so return the hash. If not, return false
-     * @param string $link
-     * @return string
-     */
-    public function exists($link) {
-        $ret = false;
+       /**
+        * check if the given URL exists in the DB
+        * if so return the hash. If not, return false
+        * @param string $link
+        * @return string
+        */
+       public function exists($link) {
+               $ret = false;
 
-        if(!empty($link)) {
-            $queryStr = "SELECT 
+               if(!empty($link)) {
+                       $queryStr = "SELECT 
                                any_value(`hash`) as hash
-                               FROM `".DB_PREFIX."_link`
-                WHERE `link` = '".$this->DB->real_escape_string($link)."'";
-            $query = $this->DB->query($queryStr);
-            if(!empty($query) && $query->num_rows > 0) {
-                $result = $query->fetch_assoc();
-                $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->_data['hash'])) {
-            $queryStr = "SELECT 
+                               FROM `".DB_PREFIX."_link`
+                               WHERE `link` = '".$this->DB->real_escape_string($link)."'";
+                       $query = $this->DB->query($queryStr);
+                       if(!empty($query) && $query->num_rows > 0) {
+                               $result = $query->fetch_assoc();
+                               $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->_data['hash'])) {
+                       $queryStr = "SELECT 
                                DISTINCT(tag) as tag
                                FROM `".DB_PREFIX."_combined`
                                WHERE `hash` = '".$this->DB->real_escape_string($this->_data['hash'])."'";
-            $query = $this->DB->query($queryStr);
-            if(!empty($query) && $query->num_rows > 0) {
-                while($result = $query->fetch_assoc()) {
-                    if($result['tag'] !== NULL) {
-                        $ret[$result['tag']] = $result['tag'];
-                    }
-                }
-
-            }
-        }
-
-        $this->_data['tags'] = $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->_data['hash'])) {
-            $queryStr = "SELECT 
+                       $query = $this->DB->query($queryStr);
+                       if(!empty($query) && $query->num_rows > 0) {
+                               while($result = $query->fetch_assoc()) {
+                                       if($result['tag'] !== NULL) {
+                                               $ret[$result['tag']] = $result['tag'];
+                                       }
+                               }
+
+                       }
+               }
+
+               $this->_data['tags'] = $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->_data['hash'])) {
+                       $queryStr = "SELECT 
                                DISTINCT(category) FROM `".DB_PREFIX."_combined`
-                WHERE `hash` = '".$this->DB->real_escape_string($this->_data['hash'])."'";
-            $query = $this->DB->query($queryStr);
-            if(!empty($query) && $query->num_rows > 0) {
-            while($result = $query->fetch_assoc()) {
-                    if($result['category'] !== NULL) {
-                        $ret[$result['category']] = $result['category'];
-                    }
-                }
-            }
-        }
-
-        $this->_data['categories'] = $ret;
-    }
-
-    /**
-     * remove all or given tag relation to the current loaded link
-     * @param mixed $tagid
-     */
-    private function _removeTagRelation($tagid) {
-        if(!empty($this->_data['id'])) {
-            $queryStr = false;
-            if($tagid === false) {
-                $queryStr = "DELETE 
+                               WHERE `hash` = '".$this->DB->real_escape_string($this->_data['hash'])."'";
+                       $query = $this->DB->query($queryStr);
+                       if(!empty($query) && $query->num_rows > 0) {
+                       while($result = $query->fetch_assoc()) {
+                                       if($result['category'] !== NULL) {
+                                               $ret[$result['category']] = $result['category'];
+                                       }
+                               }
+                       }
+               }
+
+               $this->_data['categories'] = $ret;
+       }
+
+       /**
+        * remove all or given tag relation to the current loaded link
+        * @param mixed $tagid
+        */
+       private function _removeTagRelation($tagid) {
+               if(!empty($this->_data['id'])) {
+                       $queryStr = false;
+                       if($tagid === false) {
+                               $queryStr = "DELETE 
                                        FROM `".DB_PREFIX."_tagrelation`
-                    WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'";
-            }
-            elseif(is_numeric($tagid)) {
-                $queryStr = "DELETE 
+                                       WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'";
+                       }
+                       elseif(is_numeric($tagid)) {
+                               $queryStr = "DELETE 
                                        FROM `".DB_PREFIX."_tagrelation`
-                    WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'
-                    AND `tagid` = '".$this->DB->real_escape_string($tagid)."'";
-            }
-            if(!empty($queryStr)) {
-                $this->DB->query($queryStr);
-            }
-        }
-    }
-
-    /**
-     * remove all or given category relation to the current loaded link
-     * @param mixed $categoryid
-     */
-    private function _removeCategoryRelation($categoryid) {
-        if(!empty($this->_data['id'])) {
-            $queryStr = false;
-            if($categoryid === false) {
-                $queryStr = "DELETE 
+                                       WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'
+                                       AND `tagid` = '".$this->DB->real_escape_string($tagid)."'";
+                       }
+                       if(!empty($queryStr)) {
+                               $this->DB->query($queryStr);
+                       }
+               }
+       }
+
+       /**
+        * remove all or given category relation to the current loaded link
+        * @param mixed $categoryid
+        */
+       private function _removeCategoryRelation($categoryid) {
+               if(!empty($this->_data['id'])) {
+                       $queryStr = false;
+                       if($categoryid === false) {
+                               $queryStr = "DELETE 
                                        FROM `".DB_PREFIX."_categoryrelation`
-                    WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'";
-            }
-            elseif(is_numeric($categoryid)) {
-                $queryStr = "DELETE
+                                       WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'";
+                       }
+                       elseif(is_numeric($categoryid)) {
+                               $queryStr = "DELETE
                                        FROM `".DB_PREFIX."_categoryrelation`
                                        WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'
-                    AND `categoryid` = '".$this->DB->real_escape_string($categoryid)."'";
-            }
-            if(!empty($queryStr)) {
-                $this->DB->query($queryStr);
-            }
-        }
-    }
+                                       AND `categoryid` = '".$this->DB->real_escape_string($categoryid)."'";
+                       }
+                       if(!empty($queryStr)) {
+                               $this->DB->query($queryStr);
+                       }
+               }
+       }
 
        /**
         * determine of we have a local stored image
         * if so populate the localImage attribute
         */
-    private function _image() {
+       private function _image() {
                if(!empty($this->_data['hash'])) {
                        $this->_data['imageToShow'] = $this->_data['image'];
                        $image = ABSOLUTE_PATH.'/'.LOCAL_STORAGE.'/thumbnail-'.$this->_data['hash'];
index 7b5487faa8e9c081a1e5b1658d4301915bcd8f0b..6400cecdde63b34d1f5e22630844b7a61474bee2 100644 (file)
@@ -58,12 +58,12 @@ class Summoner {
 
                switch ($mode) {
                        case 'mail':
-                           if(filter_var($input,FILTER_VALIDATE_EMAIL) === $input) {
-                               return true;
-                           }
-                else {
-                    return false;
-                           }
+                               if(filter_var($input,FILTER_VALIDATE_EMAIL) === $input) {
+                                       return true;
+                               }
+                               else {
+                                       return false;
+                               }
                        break;
 
                        case 'url':
@@ -137,14 +137,14 @@ class Summoner {
        static function is_utf8($string) {
           // From http://w3.org/International/questions/qa-forms-utf-8.html
           return preg_match('%^(?:
-                [\x09\x0A\x0D\x20-\x7E]            # ASCII
-              | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte
-              |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs
-              | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
-              |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
-              |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3
-              | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
-              |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
+                        [\x09\x0A\x0D\x20-\x7E]            # ASCII
+                  | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte
+                  |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs
+                  | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
+                  |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
+                  |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3
+                  | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
+                  |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
           )*$%xs', $string);
        }
 
@@ -262,7 +262,7 @@ class Summoner {
         * @return bool
         */
        static function ifset($array,$key) {
-           return isset($array[$key]) ? $array[$key] : false;
+               return isset($array[$key]) ? $array[$key] : false;
        }
 
        /**
@@ -271,16 +271,16 @@ class Summoner {
         * @return array|bool
         */
        static function gatherInfoFromURL($url) {
-           $ret = false;
+               $ret = false;
 
-           if(self::validate($url,'url')) {
-               $data = self::curlCall($url);
-               if(!empty($data)) {
-                   $ret = self::socialMetaInfos($data);
-               }
-           }
+               if(self::validate($url,'url')) {
+                       $data = self::curlCall($url);
+                       if(!empty($data)) {
+                               $ret = self::socialMetaInfos($data);
+                       }
+               }
 
-           return $ret;
+               return $ret;
        }
 
        /**
@@ -290,88 +290,88 @@ class Summoner {
         * @return array
         */
        static function socialMetaInfos($string) {
-           #http://www.w3bees.com/2013/11/fetch-facebook-og-meta-tags-with-php.html
-           #http://www.9lessons.info/2014/01/social-meta-tags-for-google-twitter-and.html
-           #http://ogp.me/
-           #https://moz.com/blog/meta-data-templates-123
-
-           $dom = new DomDocument;
-           # surpress invalid html warnings
-           @$dom->loadHTML($string);
-
-           $xpath = new DOMXPath($dom);
-           $metas = $xpath->query('//*/meta');
-
-           $mediaInfos = array();
-
-           # meta tags
-           foreach($metas as $meta) {
-               if($meta->getAttribute('property')) {
-                   $prop = $meta->getAttribute('property');
-                   $prop = mb_strtolower($prop);
-
-                   # minimum required information
-                   # http://ogp.me/#metadata
-                   if($prop == "og:title") {
-
-                       $mediaInfos['title'] = $meta->getAttribute('content');
-                   }
-                   elseif($prop == "og:image") {
-                       $mediaInfos['image'] = $meta->getAttribute('content');
-                   }
-                   elseif($prop == "og:url") {
-                       $mediaInfos['link'] = $meta->getAttribute('content');
-                   }
-                   elseif($prop == "og:description") {
-                       $mediaInfos['description'] = $meta->getAttribute('content');
-                   }
-               }
-               elseif($meta->getAttribute('name')) {
-                   $name = $meta->getAttribute('name');
-                   $name = mb_strtolower($name);
-
-                   # twitter
-                   # https://dev.twitter.com/cards/overview
-
-                   if($name == "twitter:title") {
-                       $mediaInfos['title'] = $meta->getAttribute('content');
-                   }
-                   elseif($name == "twitter:description") {
-                       $mediaInfos['description'] = $meta->getAttribute('content');
-                   }
-                   elseif($name == "twitter:image") {
-                       $mediaInfos['image'] = $meta->getAttribute('content');
-                   }
-                   elseif($name == "description") {
-                       $mediaInfos['description'] = $meta->getAttribute('content');
-                   }
-
-               }
-               elseif($meta->getAttribute('itemprop')) {
-                   $itemprop = $meta->getAttribute('itemprop');
-                   $itemprop = mb_strtolower($itemprop);
-
-                   # google plus
-                   if($itemprop == "name") {
-                       $mediaInfos['title'] = $meta->getAttribute('content');
-                   }
-                   elseif($itemprop == "description") {
-                       $mediaInfos['description'] = $meta->getAttribute('content');
-                   }
-                   elseif($itemprop == "image") {
-                       $mediaInfos['image'] = $meta->getAttribute('content');
-                   }
-
-               }
-           }
-
-
-           if(!isset($mediaInfos['title'])) {
-               $titleDom = $xpath->query('//html/head/title');
-               $mediaInfos['title'] = $titleDom->item(0)->nodeValue;
-           }
-
-           return $mediaInfos;
+               #http://www.w3bees.com/2013/11/fetch-facebook-og-meta-tags-with-php.html
+               #http://www.9lessons.info/2014/01/social-meta-tags-for-google-twitter-and.html
+               #http://ogp.me/
+               #https://moz.com/blog/meta-data-templates-123
+
+               $dom = new DomDocument;
+               # surpress invalid html warnings
+               @$dom->loadHTML($string);
+
+               $xpath = new DOMXPath($dom);
+               $metas = $xpath->query('//*/meta');
+
+               $mediaInfos = array();
+
+               # meta tags
+               foreach($metas as $meta) {
+                       if($meta->getAttribute('property')) {
+                               $prop = $meta->getAttribute('property');
+                               $prop = mb_strtolower($prop);
+
+                               # minimum required information
+                               # http://ogp.me/#metadata
+                               if($prop == "og:title") {
+
+                                       $mediaInfos['title'] = $meta->getAttribute('content');
+                               }
+                               elseif($prop == "og:image") {
+                                       $mediaInfos['image'] = $meta->getAttribute('content');
+                               }
+                               elseif($prop == "og:url") {
+                                       $mediaInfos['link'] = $meta->getAttribute('content');
+                               }
+                               elseif($prop == "og:description") {
+                                       $mediaInfos['description'] = $meta->getAttribute('content');
+                               }
+                       }
+                       elseif($meta->getAttribute('name')) {
+                               $name = $meta->getAttribute('name');
+                               $name = mb_strtolower($name);
+
+                               # twitter
+                               # https://dev.twitter.com/cards/overview
+
+                               if($name == "twitter:title") {
+                                       $mediaInfos['title'] = $meta->getAttribute('content');
+                               }
+                               elseif($name == "twitter:description") {
+                                       $mediaInfos['description'] = $meta->getAttribute('content');
+                               }
+                               elseif($name == "twitter:image") {
+                                       $mediaInfos['image'] = $meta->getAttribute('content');
+                               }
+                               elseif($name == "description") {
+                                       $mediaInfos['description'] = $meta->getAttribute('content');
+                               }
+
+                       }
+                       elseif($meta->getAttribute('itemprop')) {
+                               $itemprop = $meta->getAttribute('itemprop');
+                               $itemprop = mb_strtolower($itemprop);
+
+                               # google plus
+                               if($itemprop == "name") {
+                                       $mediaInfos['title'] = $meta->getAttribute('content');
+                               }
+                               elseif($itemprop == "description") {
+                                       $mediaInfos['description'] = $meta->getAttribute('content');
+                               }
+                               elseif($itemprop == "image") {
+                                       $mediaInfos['image'] = $meta->getAttribute('content');
+                               }
+
+                       }
+               }
+
+
+               if(!isset($mediaInfos['title'])) {
+                       $titleDom = $xpath->query('//html/head/title');
+                       $mediaInfos['title'] = $titleDom->item(0)->nodeValue;
+               }
+
+               return $mediaInfos;
        }
 
        /**
@@ -383,56 +383,56 @@ class Summoner {
         * @return array
         */
        static function prepareTagOrCategoryStr($string) {
-           $ret = array();
-
-           $string = trim($string, ", ");
-           if(strstr($string, ",")) {
-               $_t = explode(",", $string);
-               foreach($_t as $new) {
-                   $ret[$new] = $new;
-               }
-               unset($_t);
-               unset($new);
-
-               foreach($ret as $e) {
-                   if(strstr($e, " ")) {
-                       unset($ret[$e]);
-                       $_t = explode(" ", $e);
-                       foreach($_t as $new) {
-                           $new = trim($new);
-                           if(!empty($new)) {
-                               $ret[$new] = $new;
-                           }
-                       }
-                   }
-               }
-           }
-           else {
-               $_t = explode(" ", $string);
-               foreach($_t as $new) {
-                   $new = trim($new);
-                   if(!empty($new)) {
-                      $ret[$new] = $new;
-                   }
-               }
-           }
-
-
-           return $ret;
+               $ret = array();
+
+               $string = trim($string, ", ");
+               if(strstr($string, ",")) {
+                       $_t = explode(",", $string);
+                       foreach($_t as $new) {
+                               $ret[$new] = $new;
+                       }
+                       unset($_t);
+                       unset($new);
+
+                       foreach($ret as $e) {
+                               if(strstr($e, " ")) {
+                                       unset($ret[$e]);
+                                       $_t = explode(" ", $e);
+                                       foreach($_t as $new) {
+                                               $new = trim($new);
+                                               if(!empty($new)) {
+                                                       $ret[$new] = $new;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               else {
+                       $_t = explode(" ", $string);
+                       foreach($_t as $new) {
+                               $new = trim($new);
+                               if(!empty($new)) {
+                                  $ret[$new] = $new;
+                               }
+                       }
+               }
+
+
+               return $ret;
        }
 
        /**
         * a very simple HTTP_AUTH authentication.
         */
        static function simpleAuth() {
-           if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])
-               || $_SERVER['PHP_AUTH_USER'] !== FRONTEND_USERNAME || $_SERVER['PHP_AUTH_PW'] !== FRONTEND_PASSWORD
-               ) {
-               header('WWW-Authenticate: Basic realm="Insipid edit area"');
-               header('HTTP/1.0 401 Unauthorized');
-               echo 'No Access.';
-               exit;
-           }
+               if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])
+                       || $_SERVER['PHP_AUTH_USER'] !== FRONTEND_USERNAME || $_SERVER['PHP_AUTH_PW'] !== FRONTEND_PASSWORD
+                       ) {
+                       header('WWW-Authenticate: Basic realm="Insipid edit area"');
+                       header('HTTP/1.0 401 Unauthorized');
+                       echo 'No Access.';
+                       exit;
+               }
        }
 
        /**
@@ -444,20 +444,20 @@ class Summoner {
         * @return array $ret
         */
        static function extractEmailLinks($string) {
-           $ret = array();
+               $ret = array();
 
-           #this matches a valid URL. An URL with | is still valid...
-           $urlpattern  = '#(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))#';
+               #this matches a valid URL. An URL with | is still valid...
+               $urlpattern  = '#(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))#';
 
-           preg_match_all($urlpattern, $string, $matches);
-           if(isset($matches[0]) && !empty($matches[0])) {
-               foreach($matches[0] as $match) {
-                   $ret[md5($match)] = $match;
-               }
-           }
+               preg_match_all($urlpattern, $string, $matches);
+               if(isset($matches[0]) && !empty($matches[0])) {
+                       foreach($matches[0] as $match) {
+                               $ret[md5($match)] = $match;
+                       }
+               }
 
 
-           return $ret;
+               return $ret;
        }
 }
 
index 4aaa1ad0941008bde43dcfa30d9556518b6f9dc0..522106b9ebc4155c895d6492f0fece42fac977c2 100644 (file)
@@ -35,24 +35,24 @@ Summoner::simpleAuth();
 
 $_id = false;
 if(isset($_GET['id']) && !empty($_GET['id'])) {
-    $_id = trim($_GET['id']);
-    $_id = Summoner::validate($_id,'nospace') ? $_id : false;
+       $_id = trim($_GET['id']);
+       $_id = Summoner::validate($_id,'nospace') ? $_id : false;
 }
 
 $linkObj = new Link($DB);
 $linkObj->load($_id);
 $linkData = $linkObj->getData();
 if(empty($linkData)) {
-    header("HTTP/1.0 404 Not Found");
+       header("HTTP/1.0 404 Not Found");
 }
 
 if(isset($_POST['data']) && !empty($_POST['data']) && isset($_POST['editlink'])) {
-    $fData = $_POST['data'];
+       $fData = $_POST['data'];
 
-    $formData['private'] = 2;
-    if(isset($fData['private'])) {
-        $formData['private'] = 1;
-    }
+       $formData['private'] = 2;
+       if(isset($fData['private'])) {
+               $formData['private'] = 1;
+       }
 
        $formData['localImage'] = false;
        if(isset($fData['localImage'])) {
@@ -60,31 +60,31 @@ if(isset($_POST['data']) && !empty($_POST['data']) && isset($_POST['editlink']))
        }
 
 
-    $formData['description'] = trim($fData['description']);
-    $formData['title'] = trim($fData['title']);
-    $formData['image'] = trim($fData['image']);
-    $formData['category'] = trim($fData['category']);
-    $formData['tag'] = trim($fData['tag']);
+       $formData['description'] = trim($fData['description']);
+       $formData['title'] = trim($fData['title']);
+       $formData['image'] = trim($fData['image']);
+       $formData['category'] = trim($fData['category']);
+       $formData['tag'] = trim($fData['tag']);
 
-    if(!empty($formData['title'])) {
-        $update = $linkObj->update($formData);
+       if(!empty($formData['title'])) {
+               $update = $linkObj->update($formData);
 
-        if($update === true) {
-            $submitFeedback['message'] = 'Link updated successfully.';
-            $submitFeedback['status'] = 'success';
-            // update link info
-            $linkObj->reload();
-            $linkData = $linkObj->getData();
-        }
-        else {
-            $submitFeedback['message'] = 'Something went wrong...';
-            $submitFeedback['status'] = 'error';
-        }
-    }
-    else {
-        $submitFeedback['message'] = 'Please provide a title.';
-        $submitFeedback['status'] = 'error';
-    }
+               if($update === true) {
+                       $submitFeedback['message'] = 'Link updated successfully.';
+                       $submitFeedback['status'] = 'success';
+                       // update link info
+                       $linkObj->reload();
+                       $linkData = $linkObj->getData();
+               }
+               else {
+                       $submitFeedback['message'] = 'Something went wrong...';
+                       $submitFeedback['status'] = 'error';
+               }
+       }
+       else {
+               $submitFeedback['message'] = 'Please provide a title.';
+               $submitFeedback['status'] = 'error';
+       }
 }
 elseif(isset($_POST['refreshlink'])) {
        $linkInfo = Summoner::gatherInfoFromURL($linkData['link']);
@@ -105,19 +105,19 @@ $formData = $linkData;
 # prepare the tag string
 $formData['tag'] = '';
 if(!empty($linkData['tags'])) {
-    foreach($linkData['tags'] as $k=>$v) {
-        $formData['tag'] .= $v.',';
-    }
-    $formData['tag'] = trim($formData['tag']," ,");
+       foreach($linkData['tags'] as $k=>$v) {
+               $formData['tag'] .= $v.',';
+       }
+       $formData['tag'] = trim($formData['tag']," ,");
 }
 
 # prepare the category string
 $formData['category'] = '';
 if(!empty($linkData['categories'])) {
-    foreach($linkData['categories'] as $k=>$v) {
-        $formData['category'] .= $v.',';
-    }
-    $formData['category'] = trim($formData['category']," ,");
+       foreach($linkData['categories'] as $k=>$v) {
+               $formData['category'] .= $v.',';
+       }
+       $formData['category'] = trim($formData['category']," ,");
 }
 
 $existingCategories = $Management->categories();
index 8152f1aba264f9a892e75e936a1eaa8c8c20ae3e..f3676a2b0ec090829dd4d1e042adc1ece556b9a8 100644 (file)
 
 <section class="section">
 <?php if(empty($linkData)) { ?>
-    <div class="columns">
-       <div class="column">
-               <div class="notification is-danger">
-                       <h5>Error</h5>
-                       <p>Something went wrong...</p>
-               </div>
-       </div>
-    </div>
+       <div class="columns">
+               <div class="column">
+                       <div class="notification is-danger">
+                               <h5>Error</h5>
+                               <p>Something went wrong...</p>
+                       </div>
+               </div>
+       </div>
 <?php } ?>
 <?php if(!empty($submitFeedback)) { ?>
        <div class="columns">
                <div class="column">
 <?php if($submitFeedback['status'] == "error") { ?>
-               <div class="notification is-danger">
-                       <h5>Error</h5>
-                       <p><?php echo $submitFeedback['message']; ?></p>
-               </div>
+                       <div class="notification is-danger">
+                               <h5>Error</h5>
+                               <p><?php echo $submitFeedback['message']; ?></p>
+                       </div>
 <?php } else { ?>
-               <div class="notification is-success">
-                       <h5>Success</h5>
-                       <p><?php echo $submitFeedback['message']; ?></p>
-               </div>
+                       <div class="notification is-success">
+                               <h5>Success</h5>
+                               <p><?php echo $submitFeedback['message']; ?></p>
+                       </div>
 <?php } ?>
                </div>
        </div>
 <?php } ?>
 
        <div class="columns">
-       <div class="column">
-               <p class="has-text-right">
-                       <a href="index.php" title="... back to home" class="button">
-                               <i class="icon ion-md-home"></i>
-                       </a>
-               </p>
-       </div>
-    </div>
+               <div class="column">
+                       <p class="has-text-right">
+                               <a href="index.php" title="... back to home" class="button">
+                                       <i class="icon ion-md-home"></i>
+                               </a>
+                       </p>
+               </div>
+       </div>
 
        <div class="columns">
-       <div class="column">
+               <div class="column">
                        <h1 class="is-size-2"><?php echo $linkData['title']; ?></h1>
                </div>
        </div>
 
 <section class="section">
 
-    <form method="post">
-       <div class="columns">
-               <div class="column is-one-quarter">
-                       <p>Date added:</p>
-               </div>
-               <div class="column">
-                       <p>
+       <form method="post">
+               <div class="columns">
+                       <div class="column is-one-quarter">
+                               <p>Date added:</p>
+                       </div>
+                       <div class="column">
+                               <p>
                                        <?php echo $linkData['created']; ?>
                                        (Last update: <?php echo $linkData['updated']; ?>)
                                </p>
-               </div>
-        </div>
-        <div class="columns">
-               <div class="column is-one-quarter">
-                       <p>Title:</p>
-               </div>
-               <div class="column">
-                       <input class="input" type="text" name="data[title]" value="<?php echo Summoner::ifset($formData, 'title'); ?>" />
-               </div>
-        </div>
-        <div class="columns">
-               <div class="column is-one-quarter">
-                       <p>Description:</p>
-               </div>
-               <div class="column">
-                       <input class="input" type="text" name="data[description]" value="<?php echo Summoner::ifset($formData, 'description'); ?>" />
-               </div>
-        </div>
-        <div class="columns">
-               <div class="column is-one-quarter">
-                       <p>URL:</p>
-               </div>
-               <div class="column">
-                       <p><?php echo $linkData['link']; ?></p>
-               </div>
-        </div>
-        <div class="columns">
-               <div class="column is-one-quarter">
-                       <p>
-                               Image: (<small>If provided</small>)
-                       </p>
-               </div>
-               <div class="column">
-                       <p>
-                               <img class="linkthumbnail" src="<?php echo $linkData['imageToShow']; ?>" alt="Image if provided...">
-                       </p>
-                       <input class="input" type="text" name="data[image]" value="<?php echo Summoner::ifset($formData, 'image'); ?>" /><br />
+                       </div>
+               </div>
+               <div class="columns">
+                       <div class="column is-one-quarter">
+                               <p>Title:</p>
+                       </div>
+                       <div class="column">
+                               <input class="input" type="text" name="data[title]" value="<?php echo Summoner::ifset($formData, 'title'); ?>" />
+                       </div>
+               </div>
+               <div class="columns">
+                       <div class="column is-one-quarter">
+                               <p>Description:</p>
+                       </div>
+                       <div class="column">
+                               <input class="input" type="text" name="data[description]" value="<?php echo Summoner::ifset($formData, 'description'); ?>" />
+                       </div>
+               </div>
+               <div class="columns">
+                       <div class="column is-one-quarter">
+                               <p>URL:</p>
+                       </div>
+                       <div class="column">
+                               <p><?php echo $linkData['link']; ?></p>
+                       </div>
+               </div>
+               <div class="columns">
+                       <div class="column is-one-quarter">
+                               <p>
+                                       Image: (<small>If provided</small>)
+                               </p>
+                       </div>
+                       <div class="column">
+                               <p>
+                                       <img class="linkthumbnail" src="<?php echo $linkData['imageToShow']; ?>" alt="Image if provided...">
+                               </p>
+                               <input class="input" type="text" name="data[image]" value="<?php echo Summoner::ifset($formData, 'image'); ?>" /><br />
                                <br />
                                <input class="checkbox" type="checkbox" name="data[localImage]" value="1" <?php if(Summoner::ifset($formData, 'localImage')) echo "checked"; ?> />
                                Store image locally
-               </div>
-        </div>
+                       </div>
+               </div>
 
-        <div class="columns">
-               <div class="column is-one-quarter">
-                       <p>Tags:</p>
-               </div>
-               <div class="column">
-                   <input type="text" name="data[tag]" list="taglist"
-                               class="flexdatalist input" multiple='multiple'
-                               data-min-length="0" data-cache="0"
-                               data-toggle-selected="true"
-                               value="<?php echo Summoner::ifset($formData, 'tag'); ?>" />
-                       <datalist id="taglist">
-                       <?php foreach($existingTags as $t) { ?>
-                               <option value="<?php echo $t['name']; ?>"><?php echo $t['name']; ?></option>
-                       <?php } ?>
-                </datalist>
-               </div>
-        </div>
-        <div class="columns">
-               <div class="column is-one-quarter">
-                       <p>Category:</p>
-               </div>
-               <div class="column">
-                   <input type="text" name="data[category]" list="categorylist"
-                               class="flexdatalist input" multiple='multiple'
-                               data-min-length="0" data-cache="0"
-                               data-toggle-selected="true"
-                               value="<?php echo Summoner::ifset($formData, 'category'); ?>" />
-                       <datalist id="categorylist">
-                       <?php foreach($existingCategories as $c) { ?>
-                               <option value="<?php echo $c['name']; ?>"><?php echo $c['name']; ?></option>
-                       <?php } ?>
-                </datalist>
-               </div>
-        </div>
-        <div class="columns">
-               <div class="column is-half">
-                       <label>Private</label>
-                       <input class="checkbox" type="checkbox" name="data[private]" value="1" <?php if(Summoner::ifset($formData, 'private')) echo "checked"; ?> />
-               </div>
-               <div class="column is-half">
+               <div class="columns">
+                       <div class="column is-one-quarter">
+                               <p>Tags:</p>
+                       </div>
+                       <div class="column">
+                               <input type="text" name="data[tag]" list="taglist"
+                                       class="flexdatalist input" multiple='multiple'
+                                       data-min-length="0" data-cache="0"
+                                       data-toggle-selected="true"
+                                       value="<?php echo Summoner::ifset($formData, 'tag'); ?>" />
+                               <datalist id="taglist">
+                               <?php foreach($existingTags as $t) { ?>
+                                       <option value="<?php echo $t['name']; ?>"><?php echo $t['name']; ?></option>
+                               <?php } ?>
+                               </datalist>
+                       </div>
+               </div>
+               <div class="columns">
+                       <div class="column is-one-quarter">
+                               <p>Category:</p>
+                       </div>
+                       <div class="column">
+                               <input type="text" name="data[category]" list="categorylist"
+                                       class="flexdatalist input" multiple='multiple'
+                                       data-min-length="0" data-cache="0"
+                                       data-toggle-selected="true"
+                                       value="<?php echo Summoner::ifset($formData, 'category'); ?>" />
+                               <datalist id="categorylist">
+                               <?php foreach($existingCategories as $c) { ?>
+                                       <option value="<?php echo $c['name']; ?>"><?php echo $c['name']; ?></option>
+                               <?php } ?>
+                               </datalist>
+                       </div>
+               </div>
+               <div class="columns">
+                       <div class="column is-half">
+                               <label>Private</label>
+                               <input class="checkbox" type="checkbox" name="data[private]" value="1" <?php if(Summoner::ifset($formData, 'private')) echo "checked"; ?> />
+                       </div>
+                       <div class="column is-half">
                                <input type="submit" class="button is-info" name="refreshlink" value="Refresh from source">
                                <input type="submit" class="button is-primary" name="editlink" value="Save">
-               </div>
-        </div>
-    </form>
+                       </div>
+               </div>
+       </form>
 </section>
 
 <link rel="stylesheet" href="asset/css/jquery.flexdatalist.min.css">
index ed7b850c855af28915b6c420314676fb3d06207f..404a6e43f25052ad696caa876df928fcd3058e21 100644 (file)
 ?>
 
 <section class="section">
-    <div class="columns">
-       <div class="column">
-               <form method="post">
-                       <input type="hidden" name="password" />
-                       <input type="hidden" name="username" />
+       <div class="columns">
+               <div class="column">
+                       <form method="post">
+                               <input type="hidden" name="password" />
+                               <input type="hidden" name="username" />
                                <div class="field has-addons">
-                               <div class="control is-expanded">
-                                       <div class="control has-icons-left">
-                                               <input class="input" type="text" name="data[searchfield]" placeholder="Search your bookmarks">
-                                               <span class="icon is-small is-left">
-                                                       <i class="ion-link"></i>
-                                               </span>
-                                       </div>
-                               </div>
-                               <div class="control">
-                                       <input type="submit" class="button is-info" value="Search" name="submitsearch">
-                               </div>
-                       </div>
-               </form>
-        </div>
-    </div>
+                                       <div class="control is-expanded">
+                                               <div class="control has-icons-left">
+                                                       <input class="input" type="text" name="data[searchfield]" placeholder="Search your bookmarks">
+                                                       <span class="icon is-small is-left">
+                                                               <i class="ion-link"></i>
+                                                       </span>
+                                               </div>
+                                       </div>
+                                       <div class="control">
+                                               <input type="submit" class="button is-info" value="Search" name="submitsearch">
+                                       </div>
+                               </div>
+                       </form>
+               </div>
+       </div>
 </section>
 
 <?php if(!empty($submitFeedback)) { ?>
 
 <?php if(!empty($searchResult)) { ?>
 <section class="section">
-    <div class="columns">
-       <div class="column">
-               <div class="content">
-                       <h3>Something has been found...</h3>
-                       <div class="field is-grouped is-grouped-multiline">
+       <div class="columns">
+               <div class="column">
+                       <div class="content">
+                               <h3>Something has been found...</h3>
+                               <div class="field is-grouped is-grouped-multiline">
 <?php foreach ($searchResult as $sr) { ?>
                                        <div class="control">
                                                <div class="tags has-addons">
-                                               <a class="tag is-dark" href="<?php echo $sr['link']; ?>" target="_blank" ><?php echo $sr['title']; ?></a>
-                                               <a class="tag is-info" title="more details..." href="index.php?p=linkinfo&id=<?php echo $sr['hash']; ?>" ><i class="ion-gear-a"></i></a>
-                                       </div>
-                               </div>
+                                                       <a class="tag is-dark" href="<?php echo $sr['link']; ?>" target="_blank" ><?php echo $sr['title']; ?></a>
+                                                       <a class="tag is-info" title="more details..." href="index.php?p=linkinfo&id=<?php echo $sr['hash']; ?>" ><i class="ion-gear-a"></i></a>
+                                               </div>
+                                       </div>
 <?php } ?>
-                       </div>
-               </div>
-       </div>
-    </div>
+                               </div>
+                       </div>
+               </div>
+       </div>
 </section>
 <?php } ?>
 
 <?php if($showAddForm) { ?>
 <section class="section">
        <form method="post">
-       <input type="hidden" name="password" />
-       <input type="hidden" name="username" />
-       <div class="columns">
-               <div class="column">
-                       <div class="content">
-                               <h3>This URL was not found. Want to add it?</h3>
-                   </div>
-                   <div class="field has-addons">
-                               <div class="control is-expanded">
-                                       <div class="control has-icons-left">
-                                               <input type="url" name="data[url]" class="input" value="<?php echo Summoner::ifset($formData, 'url'); ?>" />
-                                               <span class="icon is-small is-left">
-                                                       <i class="ion-link"></i>
-                                               </span>
-                                       </div>
-                               </div>
-                       </div>
-               </div>
-       </div>
+               <input type="hidden" name="password" />
+               <input type="hidden" name="username" />
+               <div class="columns">
+                       <div class="column">
+                               <div class="content">
+                                       <h3>This URL was not found. Want to add it?</h3>
+                               </div>
+                               <div class="field has-addons">
+                                       <div class="control is-expanded">
+                                               <div class="control has-icons-left">
+                                                       <input type="url" name="data[url]" class="input" value="<?php echo Summoner::ifset($formData, 'url'); ?>" />
+                                                       <span class="icon is-small is-left">
+                                                               <i class="ion-link"></i>
+                                                       </span>
+                                               </div>
+                                       </div>
+                               </div>
+                       </div>
+               </div>
 
-       <div class="columns">
-               <div class="column is-half">
-                       <div class="field">
-                               <label class="label">Title</label>
-                               <div class="control">
-                                       <input class="input" type="text" name="data[title]" value="<?php echo Summoner::ifset($formData, 'title'); ?>" />
-                               </div>
-                       </div>
-               </div>
-               <div class="column is-half">
-                       <div class="field">
-                               <label class="label">Description</label>
-                       <div class="control">
-                               <input class="input" type="text" name="data[description]" value="<?php echo Summoner::ifset($formData, 'description'); ?>" />
-                       </div>
-               </div>
-               </div>
-        </div>
+               <div class="columns">
+                       <div class="column is-half">
+                               <div class="field">
+                                       <label class="label">Title</label>
+                                       <div class="control">
+                                               <input class="input" type="text" name="data[title]" value="<?php echo Summoner::ifset($formData, 'title'); ?>" />
+                                       </div>
+                               </div>
+                       </div>
+                       <div class="column is-half">
+                               <div class="field">
+                                       <label class="label">Description</label>
+                                       <div class="control">
+                                               <input class="input" type="text" name="data[description]" value="<?php echo Summoner::ifset($formData, 'description'); ?>" />
+                                       </div>
+                               </div>
+                       </div>
+               </div>
 
-        <div class="columns">
-               <div class="column is-half">
-                       <img class="linkthumbnail" src="<?php echo Summoner::ifset($formData, 'imageToShow'); ?>" alt="Image from provided link" />
-               </div>
-               <div class="column is-half">
-                       <div class="field">
-                               <label class="label">Image Link</label>
-                               <div class="control">
-                                       <input class="input" type="url" name="data[image]" value="<?php echo Summoner::ifset($formData, 'image'); ?>" />
-                               </div>
-                       </div>
-               </div>
-       </div>
+               <div class="columns">
+                       <div class="column is-half">
+                               <img class="linkthumbnail" src="<?php echo Summoner::ifset($formData, 'imageToShow'); ?>" alt="Image from provided link" />
+                       </div>
+                       <div class="column is-half">
+                               <div class="field">
+                                       <label class="label">Image Link</label>
+                                       <div class="control">
+                                               <input class="input" type="url" name="data[image]" value="<?php echo Summoner::ifset($formData, 'image'); ?>" />
+                                       </div>
+                               </div>
+                       </div>
+               </div>
 
-       <div class="columns">
-               <div class="column is-half">
-                       <label class="label">Category</label>
-                       <div class="control">
-                               <input type="text" name="data[category]" list="categorylist"
-                                       class="flexdatalist input" multiple='multiple'
-                                       data-min-length="0" data-cache="0"
-                                       value="<?php echo Summoner::ifset($formData, 'category'); ?>" />
-                               <datalist id="categorylist">
-                               <?php foreach($existingCategories as $c) { ?>
-                                       <option value="<?php echo $c['name']; ?>"><?php echo $c['name']; ?></option>
-                               <?php } ?>
-                    </datalist>
-                       </div>
-               </div>
-               <div class="column is-half">
-                       <label class="label">Tag</label>
-                       <div class="control">
-                               <input type="text" name="data[tag]" list="taglist"
-                                       class="flexdatalist input" multiple='multiple'
-                                       data-min-length="0" data-cache="0"
-                                       value="<?php echo Summoner::ifset($formData, 'tag'); ?>" />
-                               <datalist id="taglist">
-                               <?php foreach($existingTags as $t) { ?>
-                                       <option value="<?php echo $t['name']; ?>"><?php echo $t['name']; ?></option>
-                               <?php } ?>
-                    </datalist>
-                       </div>
-               </div>
-        </div>
+               <div class="columns">
+                       <div class="column is-half">
+                               <label class="label">Category</label>
+                               <div class="control">
+                                       <input type="text" name="data[category]" list="categorylist"
+                                               class="flexdatalist input" multiple='multiple'
+                                               data-min-length="0" data-cache="0"
+                                               value="<?php echo Summoner::ifset($formData, 'category'); ?>" />
+                                       <datalist id="categorylist">
+                                       <?php foreach($existingCategories as $c) { ?>
+                                               <option value="<?php echo $c['name']; ?>"><?php echo $c['name']; ?></option>
+                                       <?php } ?>
+                                       </datalist>
+                               </div>
+                       </div>
+                       <div class="column is-half">
+                               <label class="label">Tag</label>
+                               <div class="control">
+                                       <input type="text" name="data[tag]" list="taglist"
+                                               class="flexdatalist input" multiple='multiple'
+                                               data-min-length="0" data-cache="0"
+                                               value="<?php echo Summoner::ifset($formData, 'tag'); ?>" />
+                                       <datalist id="taglist">
+                                       <?php foreach($existingTags as $t) { ?>
+                                               <option value="<?php echo $t['name']; ?>"><?php echo $t['name']; ?></option>
+                                       <?php } ?>
+                                       </datalist>
+                               </div>
+                       </div>
+               </div>
 
-        <div class="columns">
-               <div class="column is-half">
-                       <label class="checkbox is-pulled-right">
-                               <input type="checkbox" name="data[private]" value="1" <?php if(Summoner::ifset($formData, 'private')) echo "checked"; ?> />
-                               Private
-                       </label>
-               </div>
-               <div class="column is-half">
-                       <div class="control">
-                               <input type="submit" class="button is-primary" name="addnewone" value="Add new Link">
-                       </div>
-               </div>
-        </div>
+               <div class="columns">
+                       <div class="column is-half">
+                               <label class="checkbox is-pulled-right">
+                                       <input type="checkbox" name="data[private]" value="1" <?php if(Summoner::ifset($formData, 'private')) echo "checked"; ?> />
+                                       Private
+                               </label>
+                       </div>
+                       <div class="column is-half">
+                               <div class="control">
+                                       <input type="submit" class="button is-primary" name="addnewone" value="Add new Link">
+                               </div>
+                       </div>
+               </div>
 
        </form>
 </section>
 
 <section class="section">
        <div class="columns">
-       <div class="column">
-               <div class="content">
-                       <h4><a href="index.php?p=overview&m=all">Last added</a></h4>
+               <div class="column">
+                       <div class="content">
+                               <h4><a href="index.php?p=overview&m=all">Last added</a></h4>
 <?php if(!empty($latestLinks)) { ?>
                                <div class="tags">
 <?php foreach ($latestLinks as $ll) { ?>
 <section class="section">
        <div class="columns is-multiline">
 <?php
-    if(!empty($orderedCategories)) {
-        foreach ($orderedCategories as $k=>$v) {
-            $links = $Management->linksByCategory($v['id'],false);
+       if(!empty($orderedCategories)) {
+               foreach ($orderedCategories as $k=>$v) {
+                       $links = $Management->linksByCategory($v['id'],false);
 ?>
-       <div class="column is-one-quarter">
-               <div class="content">
-                       <h4><a href="?p=overview&m=category&id=<?php echo urlencode($v['id']); ?>"><?php echo $v['name']; ?></a></h4>
+               <div class="column is-one-quarter">
+                       <div class="content">
+                               <h4><a href="?p=overview&m=category&id=<?php echo urlencode($v['id']); ?>"><?php echo $v['name']; ?></a></h4>
                                <div class="tags">
 <?php foreach ($links as $link) { ?>
                                        <a class="tag" href="<?php echo $link['link']; ?>" target="_blank"><?php echo $link['title']; ?></a>
                        </div>
                </div>
 <?php
-        }
-    }
+               }
+       }
 ?>
        </div>
 </section>
index 664286e2fc3dc15c0c19526917e6687399113227..073bce189b29d89bcb1262bd65a6beb05495cf2a 100644 (file)
 
 <?php if(empty($linkData)) { ?>
 <section class="section">
-    <div class="columns">
-       <div class="column">
-               <div class="notification is-danger">
-                       <h5>Error</h5>
-                       <p>Something went wrong...</p>
-               </div>
-       </div>
-    </div>
+       <div class="columns">
+               <div class="column">
+                       <div class="notification is-danger">
+                               <h5>Error</h5>
+                               <p>Something went wrong...</p>
+                       </div>
+               </div>
+       </div>
 </section>
 <?php } ?>
 
 <section class="section">
        <div class="columns">
-       <div class="column">
-               <p class="has-text-right">
-                       <a href="index.php" title="... back to home" class="button">
-                               <i class="icon ion-md-home"></i>
-                       </a>
-               </p>
-       </div>
-    </div>
+               <div class="column">
+                       <p class="has-text-right">
+                               <a href="index.php" title="... back to home" class="button">
+                                       <i class="icon ion-md-home"></i>
+                               </a>
+                       </p>
+               </div>
+       </div>
 
        <div class="columns">
-       <div class="column">
+               <div class="column">
                        <h1 class="is-size-2"><?php echo $linkData['title']; ?></h1>
                </div>
        </div>
                </div>
        </div>
        <div class="columns">
-       <div class="column is-one-third">
-               <p>Description:</p>
-       </div>
-       <div class="column is-two-third">
-               <p><?php echo $linkData['description']; ?></p>
-       </div>
-    </div>
-    <div class="columns">
-       <div class="column is-one-third">
-               <p>URL:</p>
-       </div>
-       <div class="column is-two-third">
-               <p><a href="<?php echo $linkData['link']; ?>" target="_blank"><?php echo $linkData['link']; ?></a></p>
-       </div>
-    </div>
-    <div class="columns">
-       <div class="column is-one-third">
-               <p>
-                       Image: (<small>If provided</small>)
-               </p>
-       </div>
-       <div class="column is-two-third">
-               <p>
-                       <img class="linkthumbnail" src="<?php echo $linkData['imageToShow']; ?>" alt="Image if provided...">
-               </p>
-       </div>
-    </div>
-    <div class="columns">
-       <div class="column is-one-third">
-               <p>Date added:</p>
-       </div>
-       <div class="column is-two-third">
-               <p><?php echo $linkData['created']; ?></p>
-       </div>
-    </div>
-    <div class="columns">
-       <div class="column is-one-third">
-               <p>Tags:</p>
-       </div>
-       <div class="column is-two-third">
-               <?php
-                if(!empty($linkData['tags'])) {
-                     foreach($linkData['tags'] as $k=>$v) {
-            ?>
-               <a href="index.php?p=overview&m=tag&id=<?php echo urlencode($k); ?>" class="button is-small">
-                       <span class="icon"><i class="ion-md-pricetag"></i></span>
-                       <span><?php echo $v; ?></span>
-               </a>
-            <?php
-                     }
-                }
-           ?>
-       </div>
-    </div>
-    <div class="columns">
-       <div class="column is-one-third">
-               <p>Category:</p>
-       </div>
-       <div class="column is-two-third">
-               <?php
-                if(!empty($linkData['categories'])) {
-                     foreach($linkData['categories'] as $k=>$v) {
-            ?>
-               <a href="index.php?p=overview&m=category&id=<?php echo urlencode($k); ?>" class="button is-small">
-                       <span class="icon"><i class="ion-md-list"></i></span>
-                       <span><?php echo $v; ?></span>
-               </a>
-            <?php
-                     }
-                }
-           ?>
-       </div>
-    </div>
-    <div class="columns">
-       <div class="column">
-            <a href="index.php?p=editlink&id=<?php echo $linkData['hash']; ?>" class="button is-small is-danger">
-               <span class="icon">
-                       <i class="ion-md-create"></i>
-               </span>
-               <span>edit</span>
-            </a>
-       </div>
-    </div>
+               <div class="column is-one-third">
+                       <p>Description:</p>
+               </div>
+               <div class="column is-two-third">
+                       <p><?php echo $linkData['description']; ?></p>
+               </div>
+       </div>
+       <div class="columns">
+               <div class="column is-one-third">
+                       <p>URL:</p>
+               </div>
+               <div class="column is-two-third">
+                       <p><a href="<?php echo $linkData['link']; ?>" target="_blank"><?php echo $linkData['link']; ?></a></p>
+               </div>
+       </div>
+       <div class="columns">
+               <div class="column is-one-third">
+                       <p>
+                               Image: (<small>If provided</small>)
+                       </p>
+               </div>
+               <div class="column is-two-third">
+                       <p>
+                               <img class="linkthumbnail" src="<?php echo $linkData['imageToShow']; ?>" alt="Image if provided...">
+                       </p>
+               </div>
+       </div>
+       <div class="columns">
+               <div class="column is-one-third">
+                       <p>Date added:</p>
+               </div>
+               <div class="column is-two-third">
+                       <p><?php echo $linkData['created']; ?></p>
+               </div>
+       </div>
+       <div class="columns">
+               <div class="column is-one-third">
+                       <p>Tags:</p>
+               </div>
+               <div class="column is-two-third">
+                       <?php
+                               if(!empty($linkData['tags'])) {
+                                 foreach($linkData['tags'] as $k=>$v) {
+                       ?>
+                               <a href="index.php?p=overview&m=tag&id=<?php echo urlencode($k); ?>" class="button is-small">
+                                       <span class="icon"><i class="ion-md-pricetag"></i></span>
+                                       <span><?php echo $v; ?></span>
+                               </a>
+                       <?php
+                                 }
+                               }
+                       ?>
+               </div>
+       </div>
+       <div class="columns">
+               <div class="column is-one-third">
+                       <p>Category:</p>
+               </div>
+               <div class="column is-two-third">
+                       <?php
+                               if(!empty($linkData['categories'])) {
+                                 foreach($linkData['categories'] as $k=>$v) {
+                       ?>
+                               <a href="index.php?p=overview&m=category&id=<?php echo urlencode($k); ?>" class="button is-small">
+                                       <span class="icon"><i class="ion-md-list"></i></span>
+                                       <span><?php echo $v; ?></span>
+                               </a>
+                       <?php
+                                 }
+                               }
+                       ?>
+               </div>
+       </div>
+       <div class="columns">
+               <div class="column">
+                       <a href="index.php?p=editlink&id=<?php echo $linkData['hash']; ?>" class="button is-small is-danger">
+                               <span class="icon">
+                                       <i class="ion-md-create"></i>
+                               </span>
+                               <span>edit</span>
+                       </a>
+               </div>
+       </div>
 </section>
 
 
index 540cf49a726e37952c5ddd4cfbb23fa46118fc23..b52aeda99fe8989f8fb82a742799e1e31ed8f6d5 100644 (file)
 <section class="section">
        <div class="columns">
                <div class="column">
-               <p class="has-text-right">
-                       <a href="index.php?p=overview&m=tag" title="all tags" class="button">
-                               <span class="icon"><i class="ion-md-pricetag"></i></span>
-                       </a>
-                       <a href="index.php?p=overview&m=category" title="all categories" class="button">
-                               <span class="icon"><i class="ion-md-list"></i></span>
-                       </a>
-                       <a href="index.php" title="... back to home" class="button">
-                               <span class="icon"><i class="ion-md-home"></i></span>
-                       </a>
-               </p>
-       </div>
+                       <p class="has-text-right">
+                               <a href="index.php?p=overview&m=tag" title="all tags" class="button">
+                                       <span class="icon"><i class="ion-md-pricetag"></i></span>
+                               </a>
+                               <a href="index.php?p=overview&m=category" title="all categories" class="button">
+                                       <span class="icon"><i class="ion-md-list"></i></span>
+                               </a>
+                               <a href="index.php" title="... back to home" class="button">
+                                       <span class="icon"><i class="ion-md-home"></i></span>
+                               </a>
+                       </p>
+               </div>
        </div>
 
        <div class="columns">
                <div class="column">
-               <?php if(!empty($subHeadline)) { ?>
-               <h2 class="is-size-2"><?php echo $subHeadline; ?></h2>
-               <?php } ?>
+                       <?php if(!empty($subHeadline)) { ?>
+                       <h2 class="is-size-2"><?php echo $subHeadline; ?></h2>
+                       <?php } ?>
                </div>
        </div>
 </section>
        <div class="column is-one-quarter">
                <div class="card">
                        <div class="card-image">
-                       <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']; ?>">
+                               <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']; ?>">
                        <?php } else { ?>
-                <img class="" src= "asset/img/no-link-picture.png">
-            <?php } ?>
-               </a>
-               </figure>
+                               <img class="" src= "asset/img/no-link-picture.png">
+                       <?php } ?>
+                               </a>
+                               </figure>
                        </div>
                        <div class="card-content">
                                <div class="content">
-                   <h4><a href="<?php echo $link['link']; ?>" target="_blank"><?php echo $link['title']; ?></a></h4>
-                       <p><?php echo $link['description']; ?></p>
+                                       <h4><a href="<?php echo $link['link']; ?>" target="_blank"><?php echo $link['title']; ?></a></h4>
+                                       <p><?php echo $link['description']; ?></p>
                                </div>
-                       </div>
-                       <footer class="card-footer">
+                       </div>
+                       <footer class="card-footer">
                                <a href="<?php echo $link['link']; ?>" target="_blank" class="card-footer-item">Visit link</a>
                                <a href="index.php?p=linkinfo&id=<?php echo $link['hash']; ?>" class="card-footer-item">More details</a>
                        </footer>
-        </div>
+               </div>
        </div>
 <?php } ?>
 </div>
 <?php } if(!empty($categoryCollection)) { ?>
 <div class="columns">
        <div class="column">
-        <table class="table">
-            <tr>
-                <th>Name</th>
-                <th># of links</th>
-            </tr>
+               <table class="table">
+                       <tr>
+                               <th>Name</th>
+                               <th># of links</th>
+                       </tr>
                <?php foreach ($categoryCollection as $k=>$v) { ?>
                        <tr>
-                <td><a href="index.php?p=overview&m=category&id=<?php echo urlencode($k); ?>"><?php echo $v['name']; ?></a></td>
-                <td><?php echo $v['amount']; ?></td>
-            </tr>
+                               <td><a href="index.php?p=overview&m=category&id=<?php echo urlencode($k); ?>"><?php echo $v['name']; ?></a></td>
+                               <td><?php echo $v['amount']; ?></td>
+                       </tr>
                <?php } ?>
-        </table>
+               </table>
        </div>
 </div>
 <?php } ?>