]> git.mxchange.org Git - friendica.git/blobdiff - include/Photo.php
Require statement
[friendica.git] / include / Photo.php
index a86942ee29486452b7bd938fa6d71fb05320ddd9..761abc770c725742f605d9196b9225b288f9de5c 100644 (file)
@@ -5,7 +5,10 @@
  */
 
 use Friendica\App;
+use Friendica\Core\Cache;
+use Friendica\Core\Config;
 use Friendica\Core\System;
+use Friendica\Database\DBM;
 
 require_once("include/photos.php");
 
@@ -26,7 +29,7 @@ class Photo {
        /**
         * @brief supported mimetypes and corresponding file extensions
         */
-       static function supportedTypes() {
+       public static function supportedTypes() {
                if (class_exists('Imagick')) {
 
                        // Imagick::queryFormats won't help us a lot there...
@@ -49,7 +52,7 @@ class Photo {
 
        public function __construct($data, $type=null) {
                $this->imagick = class_exists('Imagick');
-               $this->types = $this->supportedTypes();
+               $this->types = static::supportedTypes();
                if (!array_key_exists($type, $this->types)){
                        $type='image/jpeg';
                }
@@ -119,7 +122,7 @@ class Photo {
                         */
                        switch($this->getType()){
                                case "image/png":
-                                       $quality = get_config('system', 'png_quality');
+                                       $quality = Config::get('system', 'png_quality');
                                        if ((! $quality) || ($quality > 9)) {
                                                $quality = PNG_QUALITY;
                                        }
@@ -135,7 +138,7 @@ class Photo {
                                        $this->image->setCompressionQuality($quality);
                                        break;
                                case "image/jpeg":
-                                       $quality = get_config('system', 'jpeg_quality');
+                                       $quality = Config::get('system', 'jpeg_quality');
                                        if ((! $quality) || ($quality > 100)) {
                                                $quality = JPEG_QUALITY;
                                        }
@@ -605,14 +608,14 @@ class Photo {
 
                switch($this->getType()){
                        case "image/png":
-                               $quality = get_config('system', 'png_quality');
+                               $quality = Config::get('system', 'png_quality');
                                if ((!$quality) || ($quality > 9)) {
                                        $quality = PNG_QUALITY;
                                }
                                imagepng($this->image, null, $quality);
                                break;
                        case "image/jpeg":
-                               $quality = get_config('system', 'jpeg_quality');
+                               $quality = Config::get('system', 'jpeg_quality');
                                if ((!$quality) || ($quality > 100)) {
                                        $quality = JPEG_QUALITY;
                                }
@@ -629,7 +632,7 @@ class Photo {
        public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '') {
 
                $r = dba::select('photo', array('guid'), array("`resource-id` = ? AND `guid` != ?", $rid, ''), array('limit' => 1));
-               if (dbm::is_result($r)) {
+               if (DBM::is_result($r)) {
                        $guid = $r['guid'];
                } else {
                        $guid = get_guid();
@@ -642,7 +645,7 @@ class Photo {
                                'datasize' => strlen($this->imageString()), 'data' => $this->imageString(), 'scale' => $scale, 'profile' => $profile,
                                'allow_cid' => $allow_cid, 'allow_gid' => $allow_gid, 'deny_cid' => $deny_cid, 'deny_gid' => $deny_gid, 'desc' => $desc);
 
-               if (dbm::is_result($x)) {
+               if (DBM::is_result($x)) {
                        $r = dba::update('photo', $fields, array('id' => $x['id']));
                } else {
                        $r = dba::insert('photo', $fields);
@@ -712,7 +715,7 @@ function guess_image_type($filename, $fromcurl=false) {
  */
 function update_contact_avatar($avatar, $uid, $cid, $force = false) {
        $r = q("SELECT `avatar`, `photo`, `thumb`, `micro`, `nurl` FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid));
-       if (!dbm::is_result($r)) {
+       if (!DBM::is_result($r)) {
                return false;
        } else {
                $data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]);
@@ -729,7 +732,7 @@ function update_contact_avatar($avatar, $uid, $cid, $force = false) {
                        // Update the public contact (contact id = 0)
                        if ($uid != 0) {
                                $pcontact = dba::select('contact', array('id'), array('nurl' => $r[0]['nurl']), array('limit' => 1));
-                               if (dbm::is_result($pcontact)) {
+                               if (DBM::is_result($pcontact)) {
                                        update_contact_avatar($avatar, 0, $pcontact['id'], $force);
                                }
                        }
@@ -747,7 +750,7 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
                intval($uid),
                intval($cid)
        );
-       if (dbm::is_result($r) && strlen($r[0]['resource-id'])) {
+       if (DBM::is_result($r) && strlen($r[0]['resource-id'])) {
                $hash = $r[0]['resource-id'];
        } else {
                $hash = photo_new_resource();
@@ -918,7 +921,7 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") {
                WHERE `user`.`uid` = %d AND `user`.`blocked` = 0 AND `contact`.`self` = 1 LIMIT 1",
                intval($uid));
 
-       if (!dbm::is_result($r)) {
+       if (!DBM::is_result($r)) {
                logger("Can't detect user data for uid ".$uid, LOGGER_DEBUG);
                return(array());
        }
@@ -940,7 +943,7 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") {
                $a->save_timestamp($stamp1, "file");
        }
 
-       $maximagesize = get_config('system', 'maximagesize');
+       $maximagesize = Config::get('system', 'maximagesize');
 
        if (($maximagesize) && (strlen($imagedata) > $maximagesize)) {
                logger("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG);
@@ -972,7 +975,7 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") {
        $ph->orient($tempfile);
        unlink($tempfile);
 
-       $max_length = get_config('system', 'max_image_length');
+       $max_length = Config::get('system', 'max_image_length');
        if (! $max_length) {
                $max_length = MAX_IMAGE_LENGTH;
        }