generated from aljawaid/KanboardSkeletonPlugin
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- #2
- Loading branch information
Showing
3 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Kanboard\ExternalLink; | ||
|
||
use Kanboard\Core\ExternalLink\ExternalLinkInterface; | ||
|
||
/** | ||
* Web Link | ||
* | ||
* @package externalLink | ||
* @author Frederic Guillot | ||
*/ | ||
class NextcloudLink 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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Kanboard\ExternalLink; | ||
|
||
use Kanboard\Core\ExternalLink\ExternalLinkProviderInterface; | ||
|
||
/** | ||
* Web Link Provider | ||
* | ||
* @package externalLink | ||
* @author Frederic Guillot | ||
*/ | ||
class NextcloudLinkProvider 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters