]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Photo.php
Add more Cookie tests (create new StaticCookie class for mocking setcookie())
[friendica.git] / src / Model / Photo.php
index 10e80a4fb5bc8daad21d8abbab828ea1137600fc..db3c4d429bb29680989524d419ae4f4d0b939e40 100644 (file)
@@ -715,4 +715,25 @@ class Photo extends BaseObject
 
                return DBA::exists('photo', ['resource-id' => $guid]);
        }
+
+       /**
+        * Tests if the link points to a locally stored picture page
+        *
+        * @param string $name Page link
+        * @return boolean
+        * @throws \Exception
+        */
+       public static function isLocalPage($name)
+       {
+               $a = \get_app();
+               $base = $a->getBaseURL();
+
+               $guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name));
+               $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);
+               if (empty($guid)) {
+                       return false;
+               }
+
+               return DBA::exists('photo', ['resource-id' => $guid]);
+       }
 }