| <?php |
|
|
| namespace Kanboard\ExternalLink; |
|
|
| use Kanboard\Core\ExternalLink\ExternalLinkProviderInterface; |
|
|
| |
| |
| |
| |
| |
| |
| class AttachmentLinkProvider extends BaseLinkProvider implements ExternalLinkProviderInterface |
| { |
| |
| |
| |
| |
| |
| |
| protected $extensions = array( |
| 'html', |
| 'htm', |
| 'xhtml', |
| 'php', |
| 'jsp', |
| 'do', |
| 'action', |
| 'asp', |
| 'aspx', |
| 'cgi', |
| ); |
|
|
| |
| |
| |
| |
| |
| |
| public function getName() |
| { |
| return t('Attachment'); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getType() |
| { |
| return 'attachment'; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getDependencies() |
| { |
| return array( |
| 'related' => t('Related'), |
| ); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function match() |
| { |
| if (preg_match('/^https?:\/\/.*\/.*\.([^\/]+)$/', $this->userInput, $matches)) { |
| return $this->isValidExtension($matches[1]); |
| } |
|
|
| return false; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getLink() |
| { |
| $link = new AttachmentLink($this->container); |
| $link->setUrl($this->userInput); |
|
|
| return $link; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| protected function isValidExtension($extension) |
| { |
| $extension = strtolower($extension); |
|
|
| foreach ($this->extensions as $ext) { |
| if ($extension === $ext) { |
| return false; |
| } |
| } |
|
|
| return true; |
| } |
| } |
|
|