summaryrefslogtreecommitdiff
path: root/app/ExternalLink/WebLink.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-30 20:38:20 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-30 20:38:20 -0500
commit5c92f467867b43034b9e66b46b3b465ba9db655c (patch)
treecb0855ea64d8bba3abe4dfe978c5dbabb745911d /app/ExternalLink/WebLink.php
parentec66a779c9158830fe4bb0f96a44eadfe697ef00 (diff)
Add external links for tasks with plugin api
Diffstat (limited to 'app/ExternalLink/WebLink.php')
-rw-r--r--app/ExternalLink/WebLink.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/app/ExternalLink/WebLink.php b/app/ExternalLink/WebLink.php
new file mode 100644
index 00000000..9338ca42
--- /dev/null
+++ b/app/ExternalLink/WebLink.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Kanboard\ExternalLink;
+
+use Kanboard\Core\ExternalLink\ExternalLinkInterface;
+
+/**
+ * Web Link
+ *
+ * @package externalLink
+ * @author Frederic Guillot
+ */
+class WebLink extends BaseLink implements ExternalLinkInterface
+{
+ /**
+ * Get link title
+ *
+ * @access public
+ * @return string
+ */
+ public function getTitle()
+ {
+ $html = $this->httpClient->get($this->url);
+
+ if (preg_match('/<title>(.*)<\/title>/siU', $html, $matches)) {
+ return trim($matches[1]);
+ }
+
+ $components = parse_url($this->url);
+
+ if (! empty($components['host']) && ! empty($components['path'])) {
+ return $components['host'].$components['path'];
+ }
+
+ return t('Title not found');
+ }
+}