本文整理汇总了PHP中TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::typoLink方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentObjectRenderer::typoLink方法的具体用法?PHP ContentObjectRenderer::typoLink怎么用?PHP ContentObjectRenderer::typoLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
的用法示例。
在下文中一共展示了ContentObjectRenderer::typoLink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Process the link generation
*
* @param string $linkText
* @param array $typoLinkConfiguration TypoLink Configuration array
* @param string $linkHandlerKeyword Define the identifier that an record is given
* @param string $linkHandlerValue Table and uid of the requested record like "tt_news:2"
* @param string $linkParameters Full link params like "record:tt_news:2"
* @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer
* @return string
*/
public function main($linkText, array $typoLinkConfiguration, $linkHandlerKeyword, $linkHandlerValue, $linkParameters, \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer)
{
$typoScriptConfiguration = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_linkhandler.'];
$generatedLink = $linkText;
// extract link params like "target", "css-class" or "title"
$additionalLinkParameters = str_replace('"' . $linkHandlerKeyword . ':' . $linkHandlerValue . '"', '', $linkParameters);
$additionalLinkParameters = str_replace($linkHandlerKeyword . ':' . $linkHandlerValue, '', $additionalLinkParameters);
list($recordTableName, $recordUid) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $linkHandlerValue);
$recordArray = $this->getCurrentRecord($recordTableName, $recordUid);
if ($recordArray && $this->isRecordLinkable($recordTableName, $typoScriptConfiguration, $recordArray)) {
$this->localContentObject = clone $contentObjectRenderer;
$this->localContentObject->start($recordArray, '');
unset($typoLinkConfiguration['parameter']);
$typoScriptConfiguration[$recordTableName . '.']['parameter'] .= $additionalLinkParameters;
$currentLinkConfigurationArray = $this->mergeTypoScript($typoScriptConfiguration, $typoLinkConfiguration, $recordTableName);
if (isset($currentLinkConfigurationArray['storagePidParameterOverride.'])) {
if (array_key_exists($recordArray['pid'], $currentLinkConfigurationArray['storagePidParameterOverride.'])) {
$currentLinkConfigurationArray['parameter'] = $currentLinkConfigurationArray['storagePidParameterOverride.'][$recordArray['pid']];
}
}
// build the full link to the record
$generatedLink = $this->localContentObject->typoLink($linkText, $currentLinkConfigurationArray);
$this->updateParentLastTypoLinkMember($contentObjectRenderer);
}
return $generatedLink;
}
示例2: render
/**
* Render URL
*
* @param string $parameter
* @param array $configuration
* @return string Rendered page URI
*/
public function render($parameter = null, $configuration = array())
{
$typoLinkConfiguration = array('parameter' => $parameter ? $parameter : $this->contentObject->data['pid']);
if (!empty($configuration)) {
ArrayUtility::mergeRecursiveWithOverrule($typoLinkConfiguration, $configuration);
}
$content = $this->renderChildren();
return $this->contentObject->typoLink($content, $typoLinkConfiguration);
}
示例3: execute
/**
* Creates a link to a given page with a given link text
*
* @param array Array of arguments, [0] is the link text, [1] is the (optional) page Id to link to (otherwise TSFE->id), [2] are additional URL parameters, [3] use cache, defaults to FALSE, [4] additional A tag parameters
* @return string complete anchor tag with URL and link text
*/
public function execute(array $arguments = array())
{
$linkText = $arguments[0];
$additionalParameters = $arguments[2] ? $arguments[2] : '';
$useCache = $arguments[3] ? true : false;
$ATagParams = $arguments[4] ? $arguments[4] : '';
// by default or if no link target is set, link to the current page
$linkTarget = $GLOBALS['TSFE']->id;
// if the link target is a number, interpret it as a page ID
$linkArgument = trim($arguments[1]);
if (is_numeric($linkArgument)) {
$linkTarget = intval($linkArgument);
} elseif (!empty($linkArgument) && is_string($linkArgument)) {
/** @var \ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration $configuration */
$configuration = Util::getSolrConfiguration();
if ($configuration->isValidPath($linkArgument)) {
try {
$typoscript = $configuration->getObjectByPath($linkArgument);
$pathExploded = explode('.', $linkArgument);
$lastPathSegment = array_pop($pathExploded);
$linkTarget = intval($typoscript[$lastPathSegment]);
} catch (\InvalidArgumentException $e) {
// ignore exceptions caused by markers, but accept the exception for wrong TS paths
if (substr($linkArgument, 0, 3) != '###') {
throw $e;
}
}
} elseif (GeneralUtility::isValidUrl($linkArgument) || GeneralUtility::isValidUrl(GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . '/' . $linkArgument)) {
// $linkTarget is an URL
$linkTarget = filter_var($linkArgument, FILTER_SANITIZE_URL);
}
}
$linkConfiguration = array('useCacheHash' => $useCache, 'no_cache' => false, 'parameter' => $linkTarget, 'additionalParams' => $additionalParameters, 'ATagParams' => $ATagParams);
return $this->contentObject->typoLink($linkText, $linkConfiguration);
}
示例4: generateLink
/**
* Generates a typolink by using the matching configuration.
*
* @throws \Exception
* @return string
*/
protected function generateLink()
{
if (!array_key_exists($this->configurationKey, $this->configuration)) {
throw new MissingConfigurationException(sprintf('No linkhandler TypoScript configuration found for key %s.', $this->configurationKey), 1448384257);
}
$typoScriptConfiguration = $this->configuration[$this->configurationKey]['typolink.'];
try {
$this->initRecord();
} catch (RecordNotFoundException $e) {
// Unless linking is forced, return only the link text
// @todo: should we not get the record in this case (using \TYPO3\CMS\Frontend\Page\PageRepository::getRawRecord()) otherwise link generation will be pretty meaningless?
if (!$this->configuration[$this->configurationKey]['forceLink']) {
return $this->linkText;
}
}
// Assemble full parameters syntax with additional attributes like target, class or title
$this->linkParameters['url'] = $typoScriptConfiguration['parameter'];
$typoScriptConfiguration['parameter'] = GeneralUtility::makeInstance(TypoLinkCodecService::class)->encode($this->linkParameters);
$hookParams = array('linkInformation' => &$this->linkParameters, 'typoscriptConfiguration' => &$typoScriptConfiguration, 'linkText' => &$this->linkText, 'recordRow' => &$this->record);
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkhandler']['generateLink'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkhandler']['generateLink'] as $funcRef) {
// @todo: make that clean with an interface
GeneralUtility::callUserFunction($funcRef, $hookParams, $this);
}
}
// Build the full link to the record
$this->localContentObjectRenderer->start($this->record, $this->table);
$this->localContentObjectRenderer->parameters = $this->contentObjectRenderer->parameters;
$link = $this->localContentObjectRenderer->typoLink($this->linkText, $typoScriptConfiguration);
// Make the typolink data available in the parent content object
$this->contentObjectRenderer->lastTypoLinkLD = $this->localContentObjectRenderer->lastTypoLinkLD;
$this->contentObjectRenderer->lastTypoLinkUrl = $this->localContentObjectRenderer->lastTypoLinkUrl;
$this->contentObjectRenderer->lastTypoLinkTarget = $this->localContentObjectRenderer->lastTypoLinkTarget;
return $link;
}
示例5: menuTypoLink
/**
* Calls typolink to create menu item links.
*
* @param array $page Page record (uid points where to link to)
* @param string $oTarget Target frame/window
* @param boolean $no_cache TRUE if caching should be disabled
* @param string $script Alternative script name
* @param array $overrideArray Array to override values in $page
* @param string $addParams Parameters to add to URL
* @param array $typeOverride "type" value
* @return array See linkData
* @todo Define visibility
*/
public function menuTypoLink($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '')
{
$conf = array('parameter' => is_array($overrideArray) && $overrideArray['uid'] ? $overrideArray['uid'] : $page['uid']);
if (MathUtility::canBeInterpretedAsInteger($typeOverride)) {
$conf['parameter'] .= ',' . (int) $typeOverride;
}
if ($addParams) {
$conf['additionalParams'] = $addParams;
}
if ($no_cache) {
$conf['no_cache'] = TRUE;
} elseif ($this->useCacheHash) {
$conf['useCacheHash'] = TRUE;
}
if ($oTarget) {
$conf['target'] = $oTarget;
}
if ($page['sectionIndex_uid']) {
$conf['section'] = $page['sectionIndex_uid'];
}
$conf['linkAccessRestrictedPages'] = $this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages'] !== 'NONE';
$this->parent_cObj->typoLink('|', $conf);
$LD = $this->parent_cObj->lastTypoLinkLD;
$LD['totalURL'] = $this->parent_cObj->lastTypoLinkUrl;
return $LD;
}
示例6: getLanguageUrl
/**
* Get link of language menu entry
*
* @param $uid
* @return string
*/
protected function getLanguageUrl($uid)
{
$excludedVars = trim((string) $this->arguments['excludeQueryVars']);
$config = array('parameter' => $this->getPageUid(), 'returnLast' => 'url', 'additionalParams' => '&L=' . $uid, 'useCacheHash' => $this->arguments['useCHash'], 'addQueryString' => 'GET', 'addQueryString.' => array('exclude' => 'id,L,cHash' . ($excludedVars ? ',' . $excludedVars : '')));
if (TRUE === is_array($this->arguments['configuration'])) {
$config = $this->mergeArrays($config, $this->arguments['configuration']);
}
return $this->cObj->typoLink('', $config);
}
示例7: pi_linkTP
/**
* Link string to the current page.
* Returns the $str wrapped in <a>-tags with a link to the CURRENT page, but with $urlParameters set as extra parameters for the page.
*
* @param string $str The content string to wrap in <a> tags
* @param array $urlParameters Array with URL parameters as key/value pairs. They will be "imploded" and added to the list of parameters defined in the plugins TypoScript property "parent.addParams" plus $this->pi_moreParams.
* @param boolean $cache If $cache is set (0/1), the page is asked to be cached by a &cHash value (unless the current plugin using this class is a USER_INT). Otherwise the no_cache-parameter will be a part of the link.
* @param integer $altPageId Alternative page ID for the link. (By default this function links to the SAME page!)
* @return string The input string wrapped in <a> tags
* @see pi_linkTP_keepPIvars(), tslib_cObj::typoLink()
* @todo Define visibility
*/
public function pi_linkTP($str, $urlParameters = array(), $cache = 0, $altPageId = 0)
{
$conf = array();
$conf['useCacheHash'] = $this->pi_USER_INT_obj ? 0 : $cache;
$conf['no_cache'] = $this->pi_USER_INT_obj ? 0 : !$cache;
$conf['parameter'] = $altPageId ? $altPageId : ($this->pi_tmpPageId ? $this->pi_tmpPageId : $GLOBALS['TSFE']->id);
$conf['additionalParams'] = $this->conf['parent.']['addParams'] . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $urlParameters, '', TRUE) . $this->pi_moreParams;
return $this->cObj->typoLink($str, $conf);
}
示例8: pi_linkTP
/**
* Link string to the current page.
* Returns the $str wrapped in <a>-tags with a link to the CURRENT page, but with $urlParameters set as extra parameters for the page.
*
* @param string $str The content string to wrap in <a> tags
* @param array $urlParameters Array with URL parameters as key/value pairs. They will be "imploded" and added to the list of parameters defined in the plugins TypoScript property "parent.addParams" plus $this->pi_moreParams.
* @param bool $cache If $cache is set (0/1), the page is asked to be cached by a &cHash value (unless the current plugin using this class is a USER_INT). Otherwise the no_cache-parameter will be a part of the link.
* @param int $altPageId Alternative page ID for the link. (By default this function links to the SAME page!)
* @return string The input string wrapped in <a> tags
* @see pi_linkTP_keepPIvars(), ContentObjectRenderer::typoLink()
*/
public function pi_linkTP($str, $urlParameters = array(), $cache = FALSE, $altPageId = 0)
{
$conf = array();
$conf['useCacheHash'] = $this->pi_USER_INT_obj ? 0 : $cache;
$conf['no_cache'] = $this->pi_USER_INT_obj ? 0 : !$cache;
$conf['parameter'] = $altPageId ? $altPageId : ($this->pi_tmpPageId ? $this->pi_tmpPageId : $this->frontendController->id);
$conf['additionalParams'] = $this->conf['parent.']['addParams'] . GeneralUtility::implodeArrayForUrl('', $urlParameters, '', TRUE) . $this->pi_moreParams;
return $this->cObj->typoLink($str, $conf);
}
示例9: smarty_email
public function smarty_email($params, $smarty)
{
$address = $this->getParam($params, 'address');
$label = $this->getParam($params, 'label', $address);
$parameter = $this->getParam($params, 'parameter', $address . ' - mail');
$ATagParams = $this->getParam($params, 'ATagParams');
$conf = array('parameter' => $parameter, 'ATagParams' => $ATagParams);
return $this->contentObject->typoLink($label, $conf);
}
示例10: getLanguageUrl
/**
* Get link of language menu entry
*
* @param $uid
* @return string
*/
protected function getLanguageUrl($uid)
{
$getValues = GeneralUtility::_GET();
$getValues['L'] = $uid;
unset($getValues['id']);
unset($getValues['cHash']);
$addParams = http_build_query($getValues);
$config = array('parameter' => $this->getPageUid(), 'returnLast' => 'url', 'additionalParams' => '&' . $addParams, 'useCacheHash' => $this->arguments['useCHash']);
return $this->cObj->typoLink('', $config);
}
示例11: typolinkReturnsCorrectLinksFiles
/**
* @test
* @param string $linkText
* @param array $configuration
* @param string $expectedResult
* @dataProvider typolinkReturnsCorrectLinksFilesDataProvider
*/
public function typolinkReturnsCorrectLinksFiles($linkText, $configuration, $expectedResult)
{
$templateServiceObjectMock = $this->getMock('TYPO3\\CMS\\Core\\TypoScript\\TemplateService', array('dummy'));
$templateServiceObjectMock->setup = array('lib.' => array('parseFunc.' => $this->getLibParseFunc()));
$typoScriptFrontendControllerMockObject = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(), '', FALSE);
$typoScriptFrontendControllerMockObject->config = array('config' => array(), 'mainScript' => 'index.php');
$typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
$GLOBALS['TSFE'] = $typoScriptFrontendControllerMockObject;
$this->assertEquals($expectedResult, $this->cObj->typoLink($linkText, $configuration));
}
示例12: typolinkReturnsCorrectLinksForFilesWithAbsRefPrefix
/**
* @test
* @param string $linkText
* @param array $configuration
* @param string $absRefPrefix
* @param string $expectedResult
* @dataProvider typolinkReturnsCorrectLinksForFilesWithAbsRefPrefixDataProvider
*/
public function typolinkReturnsCorrectLinksForFilesWithAbsRefPrefix($linkText, $configuration, $absRefPrefix, $expectedResult)
{
$templateServiceObjectMock = $this->getMock(TemplateService::class, array('dummy'));
$templateServiceObjectMock->setup = array('lib.' => array('parseFunc.' => $this->getLibParseFunc()));
$typoScriptFrontendControllerMockObject = $this->getMock(TypoScriptFrontendController::class, array(), array(), '', false);
$typoScriptFrontendControllerMockObject->config = array('config' => array(), 'mainScript' => 'index.php');
$typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
$GLOBALS['TSFE'] = $typoScriptFrontendControllerMockObject;
$GLOBALS['TSFE']->absRefPrefix = $absRefPrefix;
$this->subject->_set('typoScriptFrontendController', $typoScriptFrontendControllerMockObject);
$this->assertEquals($expectedResult, $this->subject->typoLink($linkText, $configuration));
}
示例13: getLanguageUrl
/**
* Get link of language menu entry
*
* @param $uid
* @return string
*/
protected function getLanguageUrl($uid)
{
$getValues = GeneralUtility::_GET();
$getValues['L'] = $uid;
unset($getValues['id']);
unset($getValues['cHash']);
$addParams = http_build_query($getValues, '', '&');
$config = array('parameter' => $this->getPageUid(), 'returnLast' => 'url', 'additionalParams' => '&' . $addParams, 'useCacheHash' => $this->arguments['useCHash']);
if (TRUE === is_array($this->arguments['configuration'])) {
$config = ViewHelperUtility::mergeArrays($config, $this->arguments['configuration']);
}
return $this->cObj->typoLink('', $config);
}
示例14: getQueryLink
/**
* Generates a html link - an anchor tag.
*
* TODO currently everything in $additionalQueryParameters is prefixed with tx_solr,
* allow arbitrary parameters, too (either filter them out or introduce a new 4th parameter)
*
* @param string $linkText Link Text
* @param array $additionalQueryParameters Additional query parameters
* @param array $typolinkOptions Typolink Options
* @return string A html link
*/
public function getQueryLink($linkText, array $additionalQueryParameters = array(), array $typolinkOptions = array())
{
$queryParameters = array_merge($this->getPluginParameters(), $additionalQueryParameters);
$queryParameters = $this->removeUnwantedUrlParameters($queryParameters);
$queryGetParameter = '';
$keywords = $this->query->getKeywords();
if (!empty($keywords)) {
$queryGetParameter = '&q=' . $keywords;
}
$linkConfiguration = array('useCacheHash' => false, 'no_cache' => false, 'parameter' => $this->linkTargetPageId, 'additionalParams' => $queryGetParameter . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', array($this->prefix => $queryParameters), '', true) . $this->getUrlParameters());
// merge linkConfiguration with typolinkOptions
$linkConfiguration = array_merge($linkConfiguration, $typolinkOptions);
return $this->contentObject->typoLink($linkText, $linkConfiguration);
}
示例15: menuTypoLink
/**
* Calls typolink to create menu item links.
*
* @param array $page Page record (uid points where to link to)
* @param string $oTarget Target frame/window
* @param boolean $no_cache TRUE if caching should be disabled
* @param string $script Alternative script name
* @param array $overrideArray Array to override values in $page
* @param string $addParams Parameters to add to URL
* @param array $typeOverride "type" value
* @return array See linkData
* @todo Define visibility
*/
public function menuTypoLink($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '')
{
$conf = array('parameter' => is_array($overrideArray) && $overrideArray['uid'] ? $overrideArray['uid'] : $page['uid']);
if ($typeOverride && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($typeOverride)) {
$conf['parameter'] .= ',' . $typeOverride;
}
if ($addParams) {
$conf['additionalParams'] = $addParams;
}
if ($no_cache) {
$conf['no_cache'] = TRUE;
}
if ($oTarget) {
$conf['target'] = $oTarget;
}
if ($page['sectionIndex_uid']) {
$conf['section'] = $page['sectionIndex_uid'];
}
$this->parent_cObj->typoLink('|', $conf);
$LD = $this->parent_cObj->lastTypoLinkLD;
$LD['totalURL'] = $this->parent_cObj->lastTypoLinkUrl;
return $LD;
}