|
<?php |
|
|
|
namespace Kanboard\ExternalLink; |
|
|
|
use Kanboard\Core\ExternalLink\ExternalLinkProviderInterface; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FileLinkProvider extends BaseLinkProvider implements ExternalLinkProviderInterface |
|
{ |
|
protected $excludedPrefixes= array( |
|
'http', |
|
'ftp', |
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getName() |
|
{ |
|
return t('Local File'); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getType() |
|
{ |
|
return 'file'; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDependencies() |
|
{ |
|
return array( |
|
'related' => t('Related'), |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function match() |
|
{ |
|
if (strpos($this->userInput, '://') === false) { |
|
return false; |
|
} |
|
|
|
foreach ($this->excludedPrefixes as $prefix) { |
|
if (strpos($this->userInput, $prefix) === 0) { |
|
return false; |
|
} |
|
} |
|
|
|
return true; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getLink() |
|
{ |
|
$link = new FileLink($this->container); |
|
$link->setUrl($this->userInput); |
|
|
|
return $link; |
|
} |
|
} |
|
|