Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] new input field ,,URL with key" #6

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion Classes/TinyUrl/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,45 @@ public function setDeleteOnUse($deleteOnUse) {
$this->tinyUrlGenerator->setOptionDeleteOnUse($deleteOnUse);
}

public function tx_url_with_key($fObj) {

$url = $this->getUrlWithKey($fObj['row']['uid']);
$renderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$renderer->addJsInlineCode('effects',
'function clipboard(){
document.getElementById("url_key").select();
document.getElementById("url_key").focus();
document.execCommand(\'Copy\');
};
');
$iconFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Imaging\IconFactory::class
);
$icon = $iconFactory->getIcon(
'tx-myext-action-preview',
\TYPO3\CMS\Core\Imaging\Icon::SIZE_SMALL,
'overlay-identifier'
);
$formField = "<input type='text' id='url_key' name='url_with_key' value=' " .
$url. " ' size = 60 />";

$formField .= "
<span onclick='clipboard()' style='cursor: pointer'>
".$icon."
</span>";
return $formField;
}

/**
* @var array data_array
* @return mixed
*/
public function getUrlWithKey($id)
{
$data_array = $this->tinyUrlGenerator->getTinyUrlDataById($id);
$result_url = $this->tinyUrlGenerator->getTinyUrlById($data_array['urlkey']);
return $result_url;
}
/**
* Sets a custom URL key, must be unique
*
Expand All @@ -84,7 +123,6 @@ public function setDeleteOnUse($deleteOnUse) {
public function setUrlKey($urlKey) {
$this->tinyUrlGenerator->setOptionUrlKey($urlKey);
}

/**
* Sets the timestamp until the generated URL is valid
*
Expand Down
Loading