Fix codestyle
authorjoshuaruesweg <ruesweg@woltlab.com>
Wed, 3 Mar 2021 13:48:40 +0000 (14:48 +0100)
committerjoshuaruesweg <ruesweg@woltlab.com>
Tue, 16 Mar 2021 15:19:12 +0000 (16:19 +0100)
12 files changed:
wcfsetup/install/files/lib/data/unfurl/url/UnfurlUrl.class.php
wcfsetup/install/files/lib/data/unfurl/url/UnfurlUrlAction.class.php
wcfsetup/install/files/lib/data/unfurl/url/UnfurlUrlEditor.class.php
wcfsetup/install/files/lib/data/unfurl/url/UnfurlUrlList.class.php
wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/background/job/UnfurlUrlJob.class.php [deleted file]
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php
wcfsetup/install/files/lib/system/html/node/HtmlNodeUnfurlLink.class.php
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputUnfurlUrlNode.class.php
wcfsetup/install/files/lib/system/message/embedded/object/UnfurlUrlEmbeddedObjectHandler.class.php
wcfsetup/install/files/lib/util/UnfurlUrlUtil.class.php
wcfsetup/install/files/style/ui/unfurlUrl.scss

index 3c9215a3c7d139d70e0ccef12698e9cb40e310e0..0ee207b4a14f3ae965f532bcdba2aa2e58fceccb 100644 (file)
@@ -11,11 +11,11 @@ use wcf\util\Url;
 /**
  * Represents an unfurl url object in the database.
  *
- * @author             Joshua Ruesweg
+ * @author      Joshua Ruesweg
  * @copyright   2001-2021 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\Data\Unfurl\Url
- * @since      5.4
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\Data\Unfurl\Url
+ * @since       5.4
  *
  * @property-read string $url
  * @property-read string $urlHash
@@ -27,51 +27,55 @@ use wcf\util\Url;
  */
 class UnfurlUrl extends DatabaseObject
 {
-       public const IMAGE_SQUARED = "SQUARED";
-       public const IMAGE_COVER = "COVER";
-       public const IMAGE_NO_IMAGE = "NOIMAGE";
+    public const IMAGE_SQUARED = "SQUARED";
 
-       public const STATUS_PENDING = "PENDING";
-       public const STATUS_SUCCESSFUL = "SUCCESSFUL";
-       public const STATUS_REJECTED = "REJECTED";
+    public const IMAGE_COVER = "COVER";
+
+    public const IMAGE_NO_IMAGE = "NOIMAGE";
+
+    public const STATUS_PENDING = "PENDING";
+
+    public const STATUS_SUCCESSFUL = "SUCCESSFUL";
+
+    public const STATUS_REJECTED = "REJECTED";
 
     /**
      * Renders the unfurl url card and returns the template.
      *
      * @return string
      */
-    public function render() : string
+    public function render(): string
     {
         return WCF::getTPL()->fetch('unfurlUrl', 'wcf', [
             'object' => $this,
         ]);
     }
-    
+
     /**
      * Returns the hostname of the url.
      *
      * @return string
      */
-    public function getHost() : string
+    public function getHost(): string
     {
         $url = Url::parse($this->url);
-        
+
         return $url['host'];
     }
-    
+
     /**
      * Returns the image url for the url.
      *
      * @throws \wcf\system\exception\SystemException
      */
-    public function getImageUrl() : ?string
+    public function getImageUrl(): ?string
     {
         if (!empty($this->imageHash)) {
             return WCF::getPath() . 'images/unfurlUrl/' . \substr($this->imageHash, 0, 2) . '/' . $this->imageHash;
         } elseif (!empty($this->imageUrl)) {
             if (MODULE_IMAGE_PROXY) {
                 $key = CryptoUtil::createSignedString($this->imageUrl);
-                
+
                 return LinkHandler::getInstance()->getLink('ImageProxy', [
                     'key' => $key,
                 ]);
@@ -80,20 +84,20 @@ class UnfurlUrl extends DatabaseObject
             }
         }
 
-               return null;
+        return null;
     }
-    
+
     /**
      * Returns the unfurl url object for a given url.
      *
      * @throws \InvalidArgumentException If the given URL is invalid.
      */
-    public static function getByUrl(string $url) : UnfurlUrl
+    public static function getByUrl(string $url): self
     {
         if (!Url::is($url)) {
             throw new \InvalidArgumentException("Given URL is not a valid URL.");
         }
-        
+
         $sql = "SELECT         unfurl_url.*
                                FROM            wcf" . WCF_N . "_unfurl_url unfurl_url
                                WHERE           unfurl_url.urlHash = ?";
@@ -103,7 +107,7 @@ class UnfurlUrl extends DatabaseObject
         if (!$row) {
             $row = [];
         }
-        
+
         return new self(null, $row);
     }
 }
index 749a31bf0e7fe4e8227c3019c9272918e06193c1..206fb74d072cbe9542c61720af5bc4e692225d7d 100644 (file)
@@ -4,19 +4,19 @@ namespace wcf\data\unfurl\url;
 
 use wcf\data\AbstractDatabaseObjectAction;
 use wcf\system\background\BackgroundQueueHandler;
-use wcf\system\background\job\UnfurlURLJob;
+use wcf\system\background\job\UnfurlUrlBackgroundJob;
 
 /**
  * Contains all dbo actions for unfurl url objects.
  *
- * @author             Joshua Ruesweg
+ * @author      Joshua Ruesweg
  * @copyright   2001-2021 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\Data\Unfurl\Url
- * @since      5.4
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\Data\Unfurl\Url
+ * @since       5.4
  *
- * @method     UnfurlUrlEditor[]       getObjects()
- * @method     UnfurlUrlEditor         getSingleObject()
+ * @method  UnfurlUrlEditor[]   getObjects()
+ * @method  UnfurlUrlEditor     getSingleObject()
  */
 class UnfurlUrlAction extends AbstractDatabaseObjectAction
 {
@@ -27,16 +27,16 @@ class UnfurlUrlAction extends AbstractDatabaseObjectAction
     {
         /** @var UnfurlUrl $object */
         $object = parent::create();
-        
+
         BackgroundQueueHandler::getInstance()->enqueueIn([
-            new UnfurlURLJob($object),
+            new UnfurlUrlBackgroundJob($object),
         ]);
 
         BackgroundQueueHandler::getInstance()->forceCheck();
-        
+
         return $object;
     }
-    
+
     /**
      * Returns the unfurl url object to a given url.
      *
@@ -45,7 +45,7 @@ class UnfurlUrlAction extends AbstractDatabaseObjectAction
     public function findOrCreate()
     {
         $object = UnfurlUrl::getByUrl($this->parameters['data']['url']);
-        
+
         if (!$object->urlID) {
             $returnValues = (new self([], 'create', [
                 'data' => [
@@ -53,10 +53,10 @@ class UnfurlUrlAction extends AbstractDatabaseObjectAction
                     'urlHash' => \sha1($this->parameters['data']['url']),
                 ],
             ]))->executeAction();
-            
+
             return $returnValues['returnValues'];
         }
-        
+
         return $object;
     }
 }
index e1aedcac4518c51c9bc9c0013ff1cd524124e504..c1e42f079d34caff2b67c67eaf6a8f38d11d7800 100644 (file)
@@ -7,14 +7,14 @@ use wcf\data\DatabaseObjectEditor;
 /**
  * Provide functions to edit an unfurl url.
  *
- * @author             Joshua Ruesweg
+ * @author      Joshua Ruesweg
  * @copyright   2001-2021 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\Data\Unfurl\Url
- * @since      5.4
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\Data\Unfurl\Url
+ * @since       5.4
  *
- * @method     UnfurlUrl       getDecoratedObject()
- * @mixin      UnfurlUrl
+ * @method  UnfurlUrl   getDecoratedObject()
+ * @mixin   UnfurlUrl
  */
 class UnfurlUrlEditor extends DatabaseObjectEditor
 {
index a561b5f22da29e75667b18a7370dae36ad241d6c..d2e7b9901afd07a75094a00172b796d7b8c059dc 100644 (file)
@@ -7,16 +7,16 @@ use wcf\data\DatabaseObjectList;
 /**
  * Represents a list of unfurled urls.
  *
- * @author             Joshua Ruesweg
+ * @author      Joshua Ruesweg
  * @copyright   2001-2021 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\Data\Unfurl\Url
- * @since      5.4
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\Data\Unfurl\Url
+ * @since       5.4
  *
- * @method     UnfurlUrl               current()
- * @method     UnfurlUrl[]             getObjects()
- * @method     UnfurlUrl|null          search($objectID)
- * @property   UnfurlUrl[]             $objects
+ * @method      UnfurlUrl           current()
+ * @method      UnfurlUrl[]         getObjects()
+ * @method      UnfurlUrl|null      search($objectID)
+ * @property    UnfurlUrl[]         $objects
  */
 class UnfurlUrlList extends DatabaseObjectList
 {
diff --git a/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php b/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php
new file mode 100644 (file)
index 0000000..954f6d4
--- /dev/null
@@ -0,0 +1,160 @@
+<?php
+
+namespace wcf\system\background\job;
+
+use wcf\data\unfurl\url\UnfurlUrl;
+use wcf\data\unfurl\url\UnfurlUrlAction;
+use wcf\util\FileUtil;
+use wcf\util\StringUtil;
+use wcf\util\UnfurlUrlUtil;
+
+/**
+ * Represents a background job to get information for an url.
+ *
+ * @author      Joshua Ruesweg
+ * @copyright   2001-2020 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\System\Background\Job
+ * @since       5.4
+ */
+class UnfurlUrlBackgroundJob extends AbstractBackgroundJob
+{
+    /**
+     * @var UnfurlUrl
+     */
+    private $url;
+
+    /**
+     * UnfurlURLJob constructor.
+     *
+     * @param UnfurlUrl $url
+     */
+    public function __construct(UnfurlUrl $url)
+    {
+        $this->url = $url;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function retryAfter()
+    {
+        switch ($this->getFailures()) {
+            case 1:
+                // 5 minutes
+                return 5 * 60;
+            case 2:
+                // 30 minutes
+                return 30 * 60;
+            case 3:
+                // 2 hours
+                return 2 * 60 * 60;
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function perform()
+    {
+        try {
+            $url = new UnfurlUrlUtil($this->url->url);
+
+            if (empty(StringUtil::trim($url->getTitle()))) {
+                $urlAction = new UnfurlUrlAction([$this->url], 'update', [
+                    'data' => [
+                        'title' => '',
+                        'description' => '',
+                        'status' => UnfurlUrl::STATUS_REJECTED,
+                    ],
+                ]);
+                $urlAction->executeAction();
+            } else {
+                $title = StringUtil::truncate($url->getTitle(), 255);
+                $description = $url->getDescription();
+                $data = [
+                    'title' => $title,
+                    'description' => $description !== null ? StringUtil::truncate($description, 500) : '',
+                    'status' => UnfurlUrl::STATUS_SUCCESSFUL,
+                ];
+
+                if ($url->getImageUrl()) {
+                    $image = UnfurlUrlUtil::downloadImageFromUrl($url->getImageUrl());
+
+                    if ($image !== null) {
+                        $imageData = @\getimagesizefromstring($image);
+
+                        // filter images which are too large or too small
+                        $isSquared = $imageData[0] === $imageData[1];
+                        if (
+                            (!$isSquared && ($imageData[0] < 300 && $imageData[1] < 150))
+                            || \min($imageData[0], $imageData[1]) < 50
+                        ) {
+                            $data['imageType'] = UnfurlUrl::IMAGE_NO_IMAGE;
+                        } else {
+                            if ($imageData[0] === $imageData[1]) {
+                                $data['imageUrl'] = $url->getImageUrl();
+                                $data['imageType'] = UnfurlUrl::IMAGE_SQUARED;
+                            } else {
+                                $data['imageUrl'] = $url->getImageUrl();
+                                $data['imageType'] = UnfurlUrl::IMAGE_COVER;
+                            }
+
+                            // Download image, if there is no image proxy or external source images allowed.
+                            if (!(MODULE_IMAGE_PROXY || IMAGE_ALLOW_EXTERNAL_SOURCE)) {
+                                if (isset($data['imageType'])) {
+                                    switch ($imageData[2]) {
+                                        case \IMAGETYPE_PNG:
+                                            $extension = 'png';
+                                            break;
+                                        case \IMAGETYPE_GIF:
+                                            $extension = 'gif';
+                                            break;
+                                        case \IMAGETYPE_JPEG:
+                                            $extension = 'jpg';
+                                            break;
+                                        default:
+                                            throw new \RuntimeException();
+                                    }
+
+                                    $data['imageHash'] = \sha1($image) . '.' . $extension;
+
+                                    $path = WCF_DIR . 'images/unfurlUrl/' . \substr($data['imageHash'], 0, 2);
+                                    FileUtil::makePath($path);
+
+                                    $fileLocation = $path . '/' . $data['imageHash'];
+
+                                    \file_put_contents($fileLocation, $image);
+
+                                    @\touch($fileLocation);
+                                }
+                            }
+                        }
+                    }
+                }
+
+                $urlAction = new UnfurlUrlAction([$this->url], 'update', [
+                    'data' => $data,
+                ]);
+                $urlAction->executeAction();
+            }
+        } catch (\InvalidArgumentException $e) {
+            \wcf\functions\exception\logThrowable($e);
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function onFinalFailure()
+    {
+        $urlAction = new UnfurlUrlAction([$this->url], 'update', [
+            'data' => [
+                'title' => '',
+                'description' => '',
+                'status' => 'REJECTED',
+            ],
+        ]);
+        $urlAction->executeAction();
+    }
+}
diff --git a/wcfsetup/install/files/lib/system/background/job/UnfurlUrlJob.class.php b/wcfsetup/install/files/lib/system/background/job/UnfurlUrlJob.class.php
deleted file mode 100644 (file)
index db088ca..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-<?php
-
-namespace wcf\system\background\job;
-
-use wcf\data\unfurl\url\UnfurlUrl;
-use wcf\data\unfurl\url\UnfurlUrlAction;
-use function wcf\functions\exception\logThrowable;
-use wcf\util\FileUtil;
-use wcf\util\StringUtil;
-use wcf\util\UnfurlUrlUtil;
-
-/**
- * Represents a background job to get information for an url.
- *
- * @author      Joshua Ruesweg
- * @copyright   2001-2020 WoltLab GmbH
- * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package     WoltLabSuite\Core\System\Background\Job
- * @since       5.4
- */
-class UnfurlURLJob extends AbstractBackgroundJob
-{
-    /**
-     * @var UnfurlUrl
-     */
-    private $url;
-    
-    /**
-     * UnfurlURLJob constructor.
-     *
-     * @param UnfurlUrl $url
-     */
-    public function __construct(UnfurlUrl $url)
-    {
-        $this->url = $url;
-    }
-    
-    /**
-     * @inheritDoc
-     */
-    public function retryAfter()
-    {
-        switch ($this->getFailures()) {
-            case 1:
-                // 5 minutes
-                return 5 * 60;
-            case 2:
-                // 30 minutes
-                return 30 * 60;
-            case 3:
-                // 2 hours
-                return 2 * 60 * 60;
-        }
-    }
-    
-    /**
-     * @inheritDoc
-     */
-    public function perform()
-    {
-        try {
-            $url = new UnfurlUrlUtil($this->url->url);
-            
-            if (empty(StringUtil::trim($url->getTitle()))) {
-                $urlAction = new UnfurlUrlAction([$this->url], 'update', [
-                    'data' => [
-                        'title' => '',
-                        'description' => '',
-                        'status' => UnfurlUrl::STATUS_REJECTED,
-                    ],
-                ]);
-                $urlAction->executeAction();
-            } else {
-                $title = StringUtil::truncate($url->getTitle(), 255);
-                $description = $url->getDescription();
-                $data = [
-                    'title' => $title,
-                    'description' => $description !== null ? StringUtil::truncate($description, 500) : '',
-                    'status' => UnfurlUrl::STATUS_SUCCESSFUL,
-                ];
-                
-                if ($url->getImageUrl()) {
-                    $image = UnfurlUrlUtil::downloadImageFromUrl($url->getImageUrl());
-
-                    if ($image !== null) {
-                        $imageData = @\getimagesizefromstring($image);
-                        
-                        // filter images which are too large or too small
-                        $isSquared = $imageData[0] === $imageData[1];
-                        if ((!$isSquared && ($imageData[0] < 300 && $imageData[1] < 150))
-                            || \min($imageData[0], $imageData[1]) < 50) {
-                            $data['imageType'] = UnfurlUrl::IMAGE_NO_IMAGE;
-                        } else {
-                            if ($imageData[0] === $imageData[1]) {
-                                $data['imageUrl'] = $url->getImageUrl();
-                                $data['imageType'] = UnfurlUrl::IMAGE_SQUARED;
-                            } else {
-                                $data['imageUrl'] = $url->getImageUrl();
-                                $data['imageType'] = UnfurlUrl::IMAGE_COVER;
-                            }
-                            
-                            // Download image, if there is no image proxy or external source images allowed.
-                            if (!(MODULE_IMAGE_PROXY || IMAGE_ALLOW_EXTERNAL_SOURCE)) {
-                                if (isset($data['imageType'])) {
-                                    switch ($imageData[2]) {
-                                        case \IMAGETYPE_PNG:
-                                            $extension = 'png';
-                                            break;
-                                        case \IMAGETYPE_GIF:
-                                            $extension = 'gif';
-                                            break;
-                                        case \IMAGETYPE_JPEG:
-                                            $extension = 'jpg';
-                                            break;
-                                        default:
-                                            throw new \RuntimeException();
-                                    }
-                                    
-                                    $data['imageHash'] = \sha1($image) . '.' . $extension;
-                                    
-                                    $path = WCF_DIR . 'images/unfurlUrl/' . \substr($data['imageHash'], 0, 2);
-                                    FileUtil::makePath($path);
-                                    
-                                    $fileLocation = $path . '/' . $data['imageHash'];
-                                    
-                                    \file_put_contents($fileLocation, $image);
-                                    
-                                    @\touch($fileLocation);
-                                }
-                            }
-                        }
-                    }
-                }
-                
-                $urlAction = new UnfurlUrlAction([$this->url], 'update', [
-                    'data' => $data,
-                ]);
-                $urlAction->executeAction();
-            }
-        } catch (\InvalidArgumentException $e) {
-            logThrowable($e);
-        }
-    }
-    
-    /**
-     * @inheritDoc
-     */
-    public function onFinalFailure()
-    {
-        $urlAction = new UnfurlUrlAction([$this->url], 'update', [
-            'data' => [
-                'title' => '',
-                'description' => '',
-                'status' => 'REJECTED',
-            ],
-        ]);
-        $urlAction->executeAction();
-    }
-}
index 9ac6dbba611006ff8c1ab0224b2d849e8c865a86..b0a715355be132438306a1f783f8931ae00ecfba 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace wcf\system\html\input\node;
 
-use wcf\data\unfurl\url\UnfurlUrlAction;
 use wcf\system\bbcode\BBCodeHandler;
 use wcf\system\event\EventHandler;
 use wcf\system\html\node\AbstractHtmlNodeProcessor;
index 74ff262b9dd7189a1046da3de03343c137518ebf..af4173d15ed6108beaa1470566730cb2bb463935 100644 (file)
@@ -7,11 +7,11 @@ use wcf\data\unfurl\url\UnfurlUrlAction;
 /**
  * Helper class to unfurl link objects.
  *
- * @author             Joshua Ruesweg
+ * @author      Joshua Ruesweg
  * @copyright   2001-2021 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Html\Node
- * @since      5.4
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\System\Html\Node
+ * @since       5.4
  */
 class HtmlNodeUnfurlLink extends HtmlNodePlainLink
 {
index 4a82c63b62a5e86be5bcab9215fe01dd617e95d3..cc48a352cde1f0012dc5358ee46c6a9108d4911b 100644 (file)
@@ -22,7 +22,7 @@ class HtmlOutputUnfurlUrlNode extends AbstractHtmlOutputNode
      * @inheritDoc
      */
     protected $tagName = 'a';
-    
+
     /**
      * @inheritDoc
      */
@@ -31,17 +31,19 @@ class HtmlOutputUnfurlUrlNode extends AbstractHtmlOutputNode
         /** @var \DOMElement $element */
         foreach ($elements as $element) {
             $attribute = $element->getAttribute(HtmlNodeUnfurlLink::UNFURL_URL_ID_ATTRIBUTE_NAME);
-            if ($this->outputType === 'text/html'
+            if (
+                $this->outputType === 'text/html'
                 && !empty($attribute)
-                && MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.unfurlUrl', $attribute) !== null) {
+                && MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.unfurlUrl', $attribute) !== null
+            ) {
                 $nodeIdentifier = StringUtil::getRandomID();
                 $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, ['urlId' => $attribute]);
-                
+
                 $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier);
             }
         }
     }
-    
+
     /**
      * @inheritDoc
      */
index b5c30ee50388a76a54286a249b7813914bd84c48..8ca51145dea820ef37478c66ba5e438f46189ab4 100644 (file)
@@ -9,11 +9,11 @@ use wcf\system\html\node\HtmlNodeUnfurlLink;
 /**
  * Represents the unfurl url embedded object handlers.
  *
- * @author             Joshua Ruesweg
+ * @author      Joshua Ruesweg
  * @copyright   2001-2021 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Message\Embedded\Object
- * @since      5.4
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\System\Message\Embedded\Object
+ * @since       5.4
  */
 class UnfurlUrlEmbeddedObjectHandler extends AbstractMessageEmbeddedObjectHandler
 {
@@ -28,7 +28,7 @@ class UnfurlUrlEmbeddedObjectHandler extends AbstractMessageEmbeddedObjectHandle
 
         return $urlList->getObjects();
     }
-    
+
     /**
      * @inheritDoc
      */
@@ -37,13 +37,13 @@ class UnfurlUrlEmbeddedObjectHandler extends AbstractMessageEmbeddedObjectHandle
         $unfurlUrlIDs = [];
         foreach ($htmlInputProcessor->getHtmlInputNodeProcessor()->getDocument()->getElementsByTagName('a') as $element) {
             /** @var \DOMElement $element */
-            $id = intval($element->getAttribute(HtmlNodeUnfurlLink::UNFURL_URL_ID_ATTRIBUTE_NAME));
-            
+            $id = \intval($element->getAttribute(HtmlNodeUnfurlLink::UNFURL_URL_ID_ATTRIBUTE_NAME));
+
             if (!empty($id)) {
                 $unfurlUrlIDs[] = $id;
             }
         }
-        
+
         return $unfurlUrlIDs;
     }
 }
index 6814d68e0d093a86376dd37854adb47df3491edd..faf446d38e9be1a8543bfb483a9b48d16e7d3226 100644 (file)
@@ -34,28 +34,28 @@ final class UnfurlUrlUtil
      * @var string
      */
     private $url;
-    
+
     /**
      * @var string
      */
     private $body;
-    
+
     /**
      * @var \DOMDocument
      */
     private $domDocument;
-    
+
     public function __construct(string $url)
     {
         if (!Url::is($url)) {
             throw new \InvalidArgumentException('Given URL "' . $url . '" is not a valid URL.');
         }
-        
+
         $this->url = $url;
-        
+
         $this->fetchUrl();
     }
-    
+
     /**
      * Fetches the body of the given url and converts the body to utf-8.
      */
@@ -70,7 +70,7 @@ final class UnfurlUrlUtil
                 'range' => \sprintf('bytes=%d-%d', 0, self::MAX_SIZE - 1),
             ]);
             $response = $client->send($request);
-            
+
             $this->body = "";
             while (!$response->getBody()->eof()) {
                 $this->body .= $response->getBody()->read(8192);
@@ -80,7 +80,7 @@ final class UnfurlUrlUtil
                 }
             }
             $response->getBody()->close();
-            
+
             if (\mb_detect_encoding($this->body) !== 'UTF-8') {
                 $this->body = StringUtil::convertEncoding(\mb_detect_encoding($this->body), 'UTF-8', $this->body);
             }
@@ -88,7 +88,7 @@ final class UnfurlUrlUtil
             // Ignore these exceptions.
         }
     }
-    
+
     /**
      * Returns the dom document of the website.
      */
@@ -99,10 +99,10 @@ final class UnfurlUrlUtil
             $this->domDocument = new \DOMDocument();
             $this->domDocument->loadHTML('<?xml version="1.0" encoding="UTF-8"?>' . $this->body);
         }
-        
+
         return $this->domDocument;
     }
-    
+
     /**
      * Determines the title of the website.
      */
@@ -110,7 +110,7 @@ final class UnfurlUrlUtil
     {
         if (!empty($this->body)) {
             $metaTags = $this->getDomDocument()->getElementsByTagName('meta');
-            
+
             // og
             foreach ($metaTags as $metaTag) {
                 foreach ($metaTag->attributes as $attr) {
@@ -123,7 +123,7 @@ final class UnfurlUrlUtil
                     }
                 }
             }
-            
+
             // title tag
             $title = $this->getDomDocument()->getElementsByTagName('title');
             if ($title->length) {
@@ -133,7 +133,7 @@ final class UnfurlUrlUtil
 
         return null;
     }
-    
+
     /**
      * Determines the description of the website.
      */
@@ -158,7 +158,7 @@ final class UnfurlUrlUtil
 
         return null;
     }
-    
+
     /**
      * Returns the image url for the current url.
      */
@@ -166,7 +166,7 @@ final class UnfurlUrlUtil
     {
         if (!empty($this->body)) {
             $metaTags = $this->getDomDocument()->getElementsByTagName('meta');
-            
+
             // og:image
             foreach ($metaTags as $metaTag) {
                 foreach ($metaTag->attributes as $attr) {
@@ -183,7 +183,7 @@ final class UnfurlUrlUtil
 
         return null;
     }
-    
+
     /**
      * Downloads the image from a url and returns the image body.
      */
index 69c8db036782723c81dc5d67a83f346f7218c540..655fbc0149dd1d0cd55a3f5d22ea116dc93fd9e3 100644 (file)
@@ -1,38 +1,38 @@
 .unfurlCard {
        background-color: $wcfContentBackground;
-       box-shadow: 0 0 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .24);
+       box-shadow: 0 0 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
        display: inline-block;
        margin: 20px 0;
        white-space: nowrap;
-       
+
        @include screen-md-up {
                max-width: 700px;
        }
-       
+
        @include screen-sm-down {
                max-width: 100%;
        }
-       
+
        > a {
                color: $wcfContentText;
-               
+
                .unfurlInformation {
                        position: relative;
                        padding: 10px 20px 20px;
                }
-               
+
                .urlTitle {
                        display: block;
                        overflow: hidden;
                        text-overflow: ellipsis;
-                       
+
                        @include wcfFontHeadline;
                }
-               
+
                .urlDescription {
                        white-space: normal;
                }
-               
+
                .urlHost {
                        @include wcfFontSmall;
                        float: right;
                        bottom: 5px;
                        position: absolute;
                        right: 5px;
-                       
+
                        img {
                                height: 12px !important;
                        }
                }
        }
-       
+
        &.unfurlLargeContentImage {
                min-width: 300px;
-               
+
                > a > :first-child:not(:last-child) {
                        min-height: 150px;
                        background-position: center;
                        position: relative;
                }
        }
-       
+
        &.unfurlSquaredContentImage {
                > a {
                        display: flex;
-                       
+
                        > :first-child:not(:last-child) {
                                flex: 0 0 auto;
                                height: 128px !important;
                                background-size: cover;
                                position: relative;
                        }
-                       
+
                        > :last-child {
                                flex: 1 1 auto;
                                overflow: hidden;
                                padding-left: 10px;
                        }
-                       
+
                        @include screen-sm-down {
                                > :first-child:not(:last-child) {
                                        display: none;
@@ -87,4 +87,4 @@
                        }
                }
        }
-}
\ No newline at end of file
+}