summaryrefslogtreecommitdiff
path: root/app/ExternalLink/WebLinkProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/ExternalLink/WebLinkProvider.php')
-rw-r--r--app/ExternalLink/WebLinkProvider.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/app/ExternalLink/WebLinkProvider.php b/app/ExternalLink/WebLinkProvider.php
new file mode 100644
index 00000000..5ec1bbe4
--- /dev/null
+++ b/app/ExternalLink/WebLinkProvider.php
@@ -0,0 +1,77 @@
+<?php
+
+namespace Kanboard\ExternalLink;
+
+use Kanboard\Core\ExternalLink\ExternalLinkProviderInterface;
+
+/**
+ * Web Link Provider
+ *
+ * @package externalLink
+ * @author Frederic Guillot
+ */
+class WebLinkProvider extends BaseLinkProvider implements ExternalLinkProviderInterface
+{
+ /**
+ * Get provider name
+ *
+ * @access public
+ * @return string
+ */
+ public function getName()
+ {
+ return t('Web Link');
+ }
+
+ /**
+ * Get link type
+ *
+ * @access public
+ * @return string
+ */
+ public function getType()
+ {
+ return 'weblink';
+ }
+
+ /**
+ * Get a dictionary of supported dependency types by the provider
+ *
+ * @access public
+ * @return array
+ */
+ public function getDependencies()
+ {
+ return array(
+ 'related' => t('Related'),
+ );
+ }
+
+ /**
+ * Return true if the provider can parse correctly the user input
+ *
+ * @access public
+ * @return boolean
+ */
+ public function match()
+ {
+ $startWithHttp = strpos($this->userInput, 'http://') === 0 || strpos($this->userInput, 'https://') === 0;
+ $validUrl = filter_var($this->userInput, FILTER_VALIDATE_URL);
+
+ return $startWithHttp && $validUrl;
+ }
+
+ /**
+ * Get the link found with the properties
+ *
+ * @access public
+ * @return \Kanboard\Core\ExternalLink\ExternalLinkInterface
+ */
+ public function getLink()
+ {
+ $link = new WebLink($this->container);
+ $link->setUrl($this->userInput);
+
+ return $link;
+ }
+}