]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/MoveToAvatarCache.php
Some more code beauty
[friendica.git] / src / Console / MoveToAvatarCache.php
index 6e6c07d9aab8fb633fd62551aace184b801b6cd1..f158c934001141ac7d8e9dbd967f90fa4f2d43f8 100644 (file)
@@ -66,7 +66,7 @@ Description
                Move all cached avatars to the file based avatar cache
 
 Options
-    -h|--help|-? Show help information
+       -h|--help|-? Show help information
 HELP;
                return $help;
        }
@@ -84,15 +84,16 @@ HELP;
        {
                $condition = ["`avatar` != ? AND `photo` LIKE ? AND `uid` = ? AND `uri-id` != ? AND NOT `uri-id` IS NULL",
                        '', $this->baseurl->get() . '/photo/%', 0, 0];
-               $total = $this->dba->count('contact', $condition);
+
+               $count    = 0;
+               $total    = $this->dba->count('contact', $condition);
                $contacts = $this->dba->select('contact', ['id', 'avatar', 'photo', 'uri-id', 'url', 'avatar'], $condition, ['order' => ['id' => true]]);
-               $count = 0;
                while ($contact = $this->dba->fetch($contacts)) {
                        echo ++$count . '/' . $total . "\t" . $contact['id'] . "\t" . $contact['url'] . "\t";
                        $resourceid = Photo::ridFromURI($contact['photo']);
                        if (empty($resourceid)) {
-                                       echo $this->l10n->t('no resource') . "\n";
-                                       continue;
+                               echo $this->l10n->t('no resource') . "\n";
+                               continue;
                        }
                        echo '1';
                        $photo = Photo::selectFirst([], ['resource-id' => $resourceid], ['order' => ['scale']]);
@@ -100,29 +101,29 @@ HELP;
                                echo $this->l10n->t('no photo') . "\n";
                                continue;
                        }
-                                       
+
                        echo '2';
                        $imgdata = Photo::getImageDataForPhoto($photo);
                        if (empty($imgdata)) {
-                                       echo $this->l10n->t('no image data') . "\n";
-                                       continue;
+                               echo $this->l10n->t('no image data') . "\n";
+                               continue;
                        }
                        echo '3';
                        $image = new Image($imgdata, Images::getMimeTypeByData($imgdata));
                        if (!$image->isValid()) {
-                                       echo $this->l10n->t('invalid image') . "\n";
-                                       continue;
+                               echo $this->l10n->t('invalid image') . "\n";
+                               continue;
                        }
-       
+
                        echo '4';
                        $fields = Avatar::storeAvatarByImage($contact, $image);
                        echo '5';
                        Contact::update($fields, ['uri-id' => $contact['uri-id']]);
                        echo '6';
                        Photo::delete(['resource-id' => $resourceid]);
-                       echo ' '.$fields['photo'] . "\n";
+                       echo ' ' . $fields['photo'] . "\n";
                }
-                               
+
                return 0;
        }
 }