Accept more file types for FileLinkProvider
This commit is contained in:
parent
9302ff82f3
commit
26e901dfe6
|
|
@ -12,6 +12,11 @@ use Kanboard\Core\ExternalLink\ExternalLinkProviderInterface;
|
|||
*/
|
||||
class FileLinkProvider extends BaseLinkProvider implements ExternalLinkProviderInterface
|
||||
{
|
||||
protected $excludedPrefixes= array(
|
||||
'http',
|
||||
'ftp',
|
||||
);
|
||||
|
||||
/**
|
||||
* Get provider name
|
||||
*
|
||||
|
|
@ -55,7 +60,17 @@ class FileLinkProvider extends BaseLinkProvider implements ExternalLinkProviderI
|
|||
*/
|
||||
public function match()
|
||||
{
|
||||
return strpos($this->userInput, 'file://') === 0;
|
||||
if (strpos($this->userInput, '://') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->excludedPrefixes as $prefix) {
|
||||
if (strpos($this->userInput, $prefix) === 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,8 +32,14 @@
|
|||
<div class="dropdown">
|
||||
<a href="#" class="dropdown-menu dropdown-menu-link-icon"><i class="fa fa-cog fa-fw"></i><i class="fa fa-caret-down"></i></a>
|
||||
<ul>
|
||||
<li><?= $this->url->link(t('Edit'), 'TaskExternalLinkController', 'edit', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li><?= $this->url->link(t('Remove'), 'TaskExternalLinkController', 'confirm', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li>
|
||||
<i class="fa fa-edit fa-fw"></i>
|
||||
<?= $this->url->link(t('Edit'), 'TaskExternalLinkController', 'edit', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-trash-o fa-fw"></i>
|
||||
<?= $this->url->link(t('Remove'), 'TaskExternalLinkController', 'confirm', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,21 @@ class FileLinkProviderTest extends Base
|
|||
$attachmentLinkProvider->setUserTextInput('file:///tmp/test.txt');
|
||||
$this->assertTrue($attachmentLinkProvider->match());
|
||||
|
||||
$attachmentLinkProvider->setUserTextInput('owncloud:///tmp/test.txt');
|
||||
$this->assertTrue($attachmentLinkProvider->match());
|
||||
|
||||
$attachmentLinkProvider->setUserTextInput('notebooks:///tmp/test.txt');
|
||||
$this->assertTrue($attachmentLinkProvider->match());
|
||||
|
||||
$attachmentLinkProvider->setUserTextInput('http://google.com/');
|
||||
$this->assertFalse($attachmentLinkProvider->match());
|
||||
|
||||
$attachmentLinkProvider->setUserTextInput('https://google.com/');
|
||||
$this->assertFalse($attachmentLinkProvider->match());
|
||||
|
||||
$attachmentLinkProvider->setUserTextInput('ftp://google.com/');
|
||||
$this->assertFalse($attachmentLinkProvider->match());
|
||||
|
||||
$attachmentLinkProvider->setUserTextInput('');
|
||||
$this->assertFalse($attachmentLinkProvider->match());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue