/**
  * Renders the TypoScript object in the given TypoScript setup path.
  *
  * @param string $typoscriptObjectPath the TypoScript setup path of the TypoScript object to render
  * @param mixed $data the data to be used for rendering the cObject. Can be an object, array or string. If this argument is not set, child nodes will be used
  * @param string $currentValueKey
  * @return string the content of the rendered TypoScript object
  * @author Bastian Waidelich <*****@*****.**>
  * @author Niels Pardon <*****@*****.**>
  */
 public function render($typoscriptObjectPath, $data = NULL, $currentValueKey = NULL)
 {
     if ($data === NULL) {
         $data = $this->renderChildren();
     }
     $currentValue = NULL;
     if (is_object($data)) {
         $data = Tx_Extbase_Reflection_ObjectAccess::getAccessibleProperties($data);
     } elseif (is_string($data)) {
         $currentValue = $data;
         $data = array($data);
     }
     $this->contentObject->start($data);
     if ($currentValue !== NULL) {
         $this->contentObject->setCurrentVal($currentValue);
     } elseif ($currentValueKey !== NULL && isset($data[$currentValueKey])) {
         $this->contentObject->setCurrentVal($data[$currentValueKey]);
     }
     $pathSegments = t3lib_div::trimExplode('.', $typoscriptObjectPath);
     $lastSegment = array_pop($pathSegments);
     $setup = $this->typoScriptSetup;
     foreach ($pathSegments as $segment) {
         if (!array_key_exists($segment . '.', $setup)) {
             throw new Tx_Fluid_Core_ViewHelper_Exception('TypoScript object path "' . htmlspecialchars($typoscriptObjectPath) . '" does not exist', 1253191023);
         }
         $setup = $setup[$segment . '.'];
     }
     return $this->contentObject->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.']);
 }
 /**
  * Rendering the "clickenlarge" custom attribute, called from TypoScript
  *
  * @param	string		Content input. Not used, ignore.
  * @param	array		TypoScript configuration
  * @return	string		HTML output.
  * @access private
  */
 function render_clickenlarge($content, $conf)
 {
     $clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
     $path = $this->cObj->parameters['src'];
     $pathPre = $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] . 'RTEmagicC_';
     if (t3lib_div::isFirstPartOfStr($path, $pathPre)) {
         // Find original file:
         $pI = pathinfo(substr($path, strlen($pathPre)));
         $filename = substr($pI['basename'], 0, -strlen('.' . $pI['extension']));
         $file = $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] . 'RTEmagicP_' . $filename;
     } else {
         $file = $this->cObj->parameters['src'];
     }
     unset($this->cObj->parameters['clickenlarge']);
     unset($this->cObj->parameters['allParams']);
     $content = '<img ' . t3lib_div::implodeAttributes($this->cObj->parameters, TRUE, TRUE) . ' />';
     if ($clickenlarge && is_array($conf['imageLinkWrap.'])) {
         $theImage = $file ? $GLOBALS['TSFE']->tmpl->getFileName($file) : '';
         if ($theImage) {
             $this->cObj->parameters['origFile'] = $theImage;
             if ($this->cObj->parameters['title']) {
                 $conf['imageLinkWrap.']['title'] = $this->cObj->parameters['title'];
             }
             if ($this->cObj->parameters['alt']) {
                 $conf['imageLinkWrap.']['alt'] = $this->cObj->parameters['alt'];
             }
             $content = $this->cObj->imageLinkWrap($content, $theImage, $conf['imageLinkWrap.']);
             $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
         }
     }
     return $content;
 }
 /**
  * The constructor.
  *
  * @param int $registrationUid UID of the registration record, must be > 0
  */
 public function __construct($registrationUid = 0)
 {
     if ($registrationUid > 0) {
         $dbResult = tx_oelib_db::select('*', $this->tableName, 'uid = ' . $registrationUid);
     } else {
         $dbResult = FALSE;
     }
     $contentObject = new tslib_cObj();
     $contentObject->start(array());
     parent::__construct($contentObject, $dbResult);
 }
Exemplo n.º 4
0
 /**
  * Gets the raw content as configured - a certain value or database field.
  *
  * @param	tslib_cObj	$contentObject The original content object
  * @param	array	$configuration content object configuration
  * @return	string	The raw content
  */
 protected function getRawContent($contentObject, $configuration)
 {
     $content = '';
     if (isset($configuration['value'])) {
         $content = $configuration['value'];
         unset($configuration['value']);
     }
     if (!empty($configuration)) {
         $content = $contentObject->stdWrap($content, $configuration);
     }
     return $content;
 }
Exemplo n.º 5
0
 /**
  * Converts a given unix timestamp to a human readble date
  *
  * @param array $arguments
  * @return	string
  */
 public function execute(array $arguments = array())
 {
     $content = '';
     if (count($arguments) > 1) {
         $this->dateFormat = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['general.']['dateFormat.'];
         $this->dateFormat['date'] = $arguments[1];
     }
     if (is_numeric($arguments[0])) {
         $content = $this->contentObject->stdWrap($arguments[0], $this->dateFormat);
     }
     return $content;
 }
 /**
  * Creates a link to a given page with a given link text with the current
  * tx_solr parameters appended to the URL
  *
  * @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
  * @return	string	complete anchor tag with URL and link text
  */
 public function execute(array $arguments = array())
 {
     $linkText = $arguments[0];
     $pageId = $arguments[1] ? intval($arguments[1]) : $GLOBALS['TSFE']->id;
     $additionalParameters = $arguments[2] ? $arguments[2] : '';
     $useCache = $arguments[3] ? TRUE : FALSE;
     $query = $this->search->getQuery();
     $prefix = 'tx_solr';
     $getParameters = t3lib_div::_GET($prefix);
     $piVars = is_array($getParameters) ? $getParameters : array();
     $queryParameters = array_merge($piVars, array('q' => $query->getKeywords()));
     $queryParameters = $query->removeUnwantedUrlParameters($queryParameters);
     $linkConfiguration = array('useCacheHash' => $useCache, 'no_cache' => FALSE, 'parameter' => $pageId, 'additionalParams' => t3lib_div::implodeArrayForUrl('', array($prefix => $queryParameters), '', TRUE) . $additionalParameters);
     return $this->contentObject->typoLink($linkText, $linkConfiguration);
 }
 /**
  * User function (called from TypoScript) for generating a code listing (used in parsefunc)
  *
  * @param	string		$content: Empty, ignore.
  * @param	array		$conf: TypoScript parameters
  * @return	string		Processed output.
  */
 function typocode($content, $conf)
 {
     // Nothing is really done here...
     $this->conf = $conf;
     $this->siteUrl = $conf['siteUrl'];
     return $this->cObj->getCurrentVal();
 }
Exemplo n.º 8
0
 /**
  * Resizes a given image (if required) and renders the respective img tag
  * @see http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/5/#id4164427
  *
  * @param string $src
  * @param string $width width of the image. This can be a numeric value representing the fixed width of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
  * @param string $height height of the image. This can be a numeric value representing the fixed height of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
  * @param integer $minWidth minimum width of the image
  * @param integer $minHeight minimum height of the image
  * @param integer $maxWidth maximum width of the image
  * @param integer $maxHeight maximum height of the image
  *
  * @return string rendered tag.
  * @author Sebastian Böttger <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function render($src, $width = NULL, $height = NULL, $minWidth = NULL, $minHeight = NULL, $maxWidth = NULL, $maxHeight = NULL)
 {
     if (TYPO3_MODE === 'BE') {
         $this->simulateFrontendEnvironment();
     }
     $setup = array('width' => $width, 'height' => $height, 'minW' => $minWidth, 'minH' => $minHeight, 'maxW' => $maxWidth, 'maxH' => $maxHeight);
     if (TYPO3_MODE === 'BE' && substr($src, 0, 3) === '../') {
         $src = substr($src, 3);
     }
     $imageInfo = $this->contentObject->getImgResource($src, $setup);
     $GLOBALS['TSFE']->lastImageInfo = $imageInfo;
     if (!is_array($imageInfo)) {
         throw new Tx_Fluid_Core_ViewHelper_Exception('Could not get image resource for "' . htmlspecialchars($src) . '".', 1253191060);
     }
     $imageInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imageInfo[3]);
     $GLOBALS['TSFE']->imagesOnPage[] = $imageInfo[3];
     $imageSource = $GLOBALS['TSFE']->absRefPrefix . t3lib_div::rawUrlEncodeFP($imageInfo[3]);
     if (TYPO3_MODE === 'BE') {
         $imageSource = '../' . $imageSource;
         $this->resetFrontendEnvironment();
     }
     $this->tag->addAttribute('src', $imageSource);
     $this->tag->addAttribute('width', $imageInfo[0]);
     $this->tag->addAttribute('height', $imageInfo[1]);
     if ($this->arguments['title'] === '') {
         $this->tag->addAttribute('title', $this->arguments['alt']);
     }
     return $this->tag->render();
 }
Exemplo n.º 9
0
 /**
  * Renders Lorem Ipsum paragraphs. If $lipsum is provided it
  * will be used as source text. If not provided as an argument
  * or as inline argument, $lipsum is fetched from TypoScript settings.
  *
  * @param string $lipsum String of paragraphs file path or EXT:myext/path/to/file
  * @return string
  */
 public function render($lipsum = NULL)
 {
     if (strlen($lipsum) === 0) {
         $this->getDefaultLoremIpsum();
     }
     if (strlen($lipsum) < 255 && !preg_match('/[^a-z0-9_\\./]/i', $lipsum)) {
         // argument is most likely a file reference.
         $sourceFile = t3lib_div::getFileAbsFileName($lipsum);
         if (file_exists($sourceFile) === TRUE) {
             $lipsum = file_get_contents($sourceFile);
         } else {
             t3lib_div::sysLog('Vhs LipsumViewHelper was asked to load Lorem Ipsum from a file which does not exist. ' . 'The file was: ' . $sourceFile, 'Vhs');
             $lipsum = $this->getDefaultLoremIpsum();
         }
     }
     $lipsum = preg_replace('/[\\r\\n]{1,}/i', "\n", $lipsum);
     $paragraphs = explode("\n", $lipsum);
     $paragraphs = array_slice($paragraphs, 0, intval($settings['paragraphs']));
     foreach ($paragraphs as $index => $paragraph) {
         $length = $settings['wordsPerParagraph'] + rand(0 - intval($settings['skew']), intval($settings['skew']));
         $words = explode(' ', $paragraph);
         $paragraphs[$index] = implode(' ', array_slice($words, 0, $length));
     }
     $lipsum = implode("\n", $paragraphs);
     if ((bool) $settings['html'] === TRUE) {
         $lipsum = $this->contentObject->parseFunc($lipsum, array(), '< ' . $settings['parseFuncTSPath']);
     }
     return $lipsum;
 }
Exemplo n.º 10
0
 /**
  * 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, interprete it as a page ID
     $linkArgument = trim($arguments[1]);
     if (is_numeric($linkArgument)) {
         $linkTarget = intval($linkArgument);
     } elseif (!empty($linkArgument) && is_string($linkArgument)) {
         if (Tx_Solr_Util::isValidTypoScriptPath($linkArgument)) {
             try {
                 $typoscript = Tx_Solr_Util::getTypoScriptObject($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 (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($linkArgument) || \TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl(\TYPO3\CMS\Core\Utility\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);
 }
 function checkDataSubmission($feObj)
 {
     // config
     global $TSFE;
     $this->cObj = $TSFE->cObj;
     // cObject
     $this->confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['wt_doorman']);
     // Get backandconfig
     $this->removeXSS = t3lib_div::makeInstance('tx_wtdoorman_RemoveXSS');
     // Create new instance for removeXSS class
     $varsDefinition = $this->string2array($this->confArr['varsDefinition']);
     // get config for doorman
     if ($this->confArr['pidInRootline'] > -1) {
         $pid = t3lib_div::trimExplode(',', $this->confArr['pidInRootline'] . ',' . tslib_cObj::getTreeList($this->confArr['pidInRootline'], 100), 1);
     }
     // array with all allowed pids
     // Let's go
     if ($this->confArr['pidInRootline'] > -1 && (in_array($GLOBALS['TSFE']->id, $pid) || $this->confArr['pidInRootline'] == 0)) {
         // if current page is allowed
         $this->sec = t3lib_div::makeInstance('tx_wtdoorman_security');
         // Create new instance for security class
         $this->sec->secParams = $this->string2array($this->confArr['varsDefinition']);
         // get config for backend definition
         $this->sec->delNotSetVars = $this->confArr['clearNotDefinedVars'];
         // now allowed params should be deleted or not?
         $_GET = $this->sec->sec($_GET);
         // overwrite GET params with vars from doorman class
         $_POST = $this->sec->sec($_POST);
         // overwrite POST params with vars from doorman class
     }
 }
 /**
  * Adds an edit icon to the content string. The edit icon links to alt_doc.php with proper parameters for editing the table/fields of the context.
  * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well).
  *
  * @param	string		The content to which the edit icons should be appended
  * @param	string		The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to alt_doc.php
  * @param	array		TypoScript properties for configuring the edit icons.
  * @param	string		The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW"
  * @param	array		Alternative data array to use. Default is $this->data
  * @param	string		Additional URL parameters for the link pointing to alt_doc.php
  * @return	string		The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
  */
 public function editIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArr = array(), $addUrlParamStr = '', $table, $editUid, $fieldList)
 {
     // Special content is about to be shown, so the cache must be disabled.
     $GLOBALS['TSFE']->set_no_cache();
     $style = $conf['styleAttribute'] ? ' style="' . htmlspecialchars($conf['styleAttribute']) . '"' : '';
     $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']);
     $iconImg = $conf['iconImg'] ? $conf['iconImg'] : '<img src="' . TYPO3_mainDir . 'gfx/edit_fe.gif" width="11" height="12" border="0" align="top" title="' . t3lib_div::deHSCentities(htmlspecialchars($iconTitle)) . '"' . $style . ' class="frontEndEditIcons" alt="" />';
     $nV = t3lib_div::_GP('ADMCMD_view') ? 1 : 0;
     $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
     $icon = $this->editPanelLinkWrap_doWrap($iconImg, $adminURL . 'alt_doc.php?edit[' . $table . '][' . $editUid . ']=edit&columnsOnly=' . rawurlencode($fieldList) . '&noView=' . $nV . $addUrlParamStr, $currentRecord);
     if ($conf['beforeLastTag'] < 0) {
         $content = $icon . $content;
     } elseif ($conf['beforeLastTag'] > 0) {
         $cBuf = rtrim($content);
         $securCount = 30;
         while ($securCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') {
             $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf));
             $securCount--;
         }
         $content = strlen($cBuf) && $securCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content);
     } else {
         $content .= $icon;
     }
     return $content;
 }
 /**
  * Build Teasercontent
  *
  * @param string $content The whole resultcontent
  * @return string The cutted recultcontent
  */
 public function buildTeaserContent($content)
 {
     if (is_array($this->pObj->swords) && count($this->pObj->swords)) {
         $amountOfSearchWords = count($this->pObj->swords);
         $content = strip_tags($content);
         // with each new searchword and all the croppings here the teaser for each word will become too small/short
         // I decided to add 20 additional letters for each searchword. It looks much better and is more readable
         $charsForEachSearchWord = ceil($this->conf['resultChars'] / $amountOfSearchWords) + 20;
         $charsBeforeAfterSearchWord = ceil($charsForEachSearchWord / 2);
         $aSearchWordWasFound = false;
         $isSearchWordAtTheBeginning = false;
         foreach ($this->pObj->swords as $word) {
             $word = ' ' . $word;
             // our searchengine searches for wordbeginnings
             $pos = stripos($content, $word);
             if ($pos === false) {
                 // if the word was not found it could be within brakets => (searchWord)
                 // so give it a second try
                 $pos = stripos($content, trim($word));
                 if ($pos === false) {
                     continue;
                 }
             }
             $aSearchWordWasFound = true;
             // if searchword is the first word
             if ($pos === 0) {
                 $isSearchWordAtTheBeginning = true;
             }
             // find search starting point
             $startPos = $pos - $charsBeforeAfterSearchWord;
             if ($startPos < 0) {
                 $startPos = 0;
             }
             // crop some words behind searchword
             $partWithSearchWord = substr($content, $startPos);
             $temp = $this->cObj->crop($partWithSearchWord, $charsForEachSearchWord . '|...|1');
             // crop some words before searchword
             // after last cropping our text is too short now. So we have to find a new cutting position
             $startPos > 10 ? $length = strlen($temp) - 10 : ($length = strlen($temp));
             $teaserArray[] = $this->cObj->crop($temp, '-' . $length . '||1');
         }
         // When the searchword was found in title but not in content the teaser is empty
         // in that case we have to get the first x letters without containing any searchword
         if ($aSearchWordWasFound === false) {
             $teaser = $this->cObj->crop($content, $this->conf['resultChars'] . '||1');
         } elseif ($isSearchWordAtTheBeginning === true) {
             $teaser = implode(' ', $teaserArray);
         } else {
             $teaser = '...' . implode(' ', $teaserArray);
         }
         // highlight hits?
         if ($this->conf['highlightSword']) {
             $teaser = $this->highlightArrayOfWordsInContent($this->pObj->swords, $teaser);
         }
         return $teaser;
     } else {
         return $this->cObj->crop($content, $this->conf['resultChars'] . '|...|1');
     }
 }
Exemplo n.º 14
0
 /**
  * remove boundaries from TYPO3 content
  *
  * @param    string $content : the content with boundaries in comment
  * @return    string        the content without boundaries
  */
 function stripInnerBoundaries($content)
 {
     // only dummy code at the moment
     $searchString = $this->cObj->wrap('[\\d,]*', $this->boundaryStartWrap);
     $content = preg_replace('/' . $searchString . '/', '', $content);
     $content = preg_replace('/' . $this->boundaryEnd . '/', '', $content);
     return $content;
 }
Exemplo n.º 15
0
 /**
  * Builds the URI, frontend flavour
  *
  * @return string The URI
  * @see buildTypolinkConfiguration()
  */
 public function buildFrontendUri()
 {
     $typolinkConfiguration = $this->buildTypolinkConfiguration();
     if ($this->createAbsoluteUri === TRUE) {
         $typolinkConfiguration['forceAbsoluteUrl'] = TRUE;
     }
     $uri = $this->contentObject->typoLink_URL($typolinkConfiguration);
     return $uri;
 }
 /**
  * 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
  * @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;
     // 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, interprete it as a page ID
     if (is_numeric($arguments[1])) {
         $linkTarget = intval($arguments[1]);
     }
     // treat everything else as an URL
     if (filter_var($arguments[1], FILTER_VALIDATE_URL)) {
         $linkTarget = filter_var($arguments[1], FILTER_SANITIZE_URL);
     }
     $linkConfiguration = array('useCacheHash' => $useCache, 'no_cache' => FALSE, 'parameter' => $linkTarget, 'additionalParams' => $additionalParameters);
     return $this->contentObject->typoLink($linkText, $linkConfiguration);
 }
 /**
  * Renders a single facet option link according to the rendering
  * instructions that may have been configured.
  *
  * @param	string	$option The facet option's raw string value.
  * @return	string	The facet option rendered according to rendering instructions if available
  */
 protected function renderOption($option)
 {
     $renderedFacetOption = $option;
     if (isset($this->facetConfiguration['renderingInstruction'])) {
         // TODO provide a data field with information about whether a facet option is selected, and pssibly all information from the renderOptions method so that one can use that with TS
         $this->contentObject->start(array('optionValue' => $option));
         $renderedFacetOption = $this->contentObject->cObjGetSingle($this->facetConfiguration['renderingInstruction'], $this->facetConfiguration['renderingInstruction.']);
     }
     return $renderedFacetOption;
 }
 /**
  * @test
  */
 public function buildFrontendUriCreatesAbsoluteUrisIfSpecified()
 {
     $uriBuilder = $this->getMock('Tx_Extbase_MVC_Web_Routing_UriBuilder', array('buildTypolinkConfiguration'), array($this->contentObject));
     $uriBuilder->expects($this->once())->method('buildTypolinkConfiguration')->will($this->returnValue(array('foo' => 'bar')));
     $this->contentObject->expects($this->once())->method('typoLink_URL')->with(array('foo' => 'bar', 'forceAbsoluteUrl' => TRUE))->will($this->returnValue('http://baseuri/relative/uri'));
     $uriBuilder->setCreateAbsoluteUri(TRUE);
     $expectedResult = 'http://baseuri/relative/uri';
     $actualResult = $uriBuilder->buildFrontendUri();
     $this->assertSame($expectedResult, $actualResult);
 }
 function stdWrap_postUserFuncInt($content = '', $conf = array())
 {
     $content = parent::render($conf);
     if ($conf['no_esi'] == FALSE && t3lib_div::_GP('from_varnish') == FALSE) {
         $substKey = str_replace(array('<!--', '-->'), '', $content);
         $url = t3lib_div::getIndpEnv('TYPO3_SITE_PATH') . '?id=' . $GLOBALS['TSFE']->id . '&type=978&key=' . $substKey . '&identifier=' . $GLOBALS['TSFE']->newHash . '&from_varnish=1';
         $content = '<esi:include src="' . $url . '" />';
     }
     return $content;
 }
 /**
  * Provides a "show all link" if a certain limit of facet options is
  * reached.
  *
  * (non-PHPdoc)
  * @see Tx_Solr_Facet_AbstractFacetRenderer::getFacetProperties()
  */
 public function getFacetProperties()
 {
     $facet = parent::getFacetProperties();
     if ($facet['count'] > $this->solrConfiguration['search.']['faceting.']['limit']) {
         $showAllLink = '<a href="#" class="tx-solr-facet-show-all">###LLL:faceting_showMore###</a>';
         $showAllLink = tslib_cObj::wrap($showAllLink, $this->solrConfiguration['search.']['faceting.']['showAllLink.']['wrap']);
         $facet['show_all_link'] = $showAllLink;
     }
     return $facet;
 }
Exemplo n.º 21
0
 /**
  * Render a page browser using the Universal Page Browser (EXT:pagebrowse)
  * made by Dmitry Dulepov.
  * 
  * @see   http://dmitry-dulepov.com/article/do-you-need-a-page-browser-for-your-typo3-extension.html
  * @param integer $numberOfPages The number of pages to show.
  * @param array $settings The settings which override the default one.
  * @return string The HTML page browser.
  * @author Romain Ruetschi <*****@*****.**>
  */
 public function render($numberOfPages, array $settings = array())
 {
     // Add the number of pages to show in the configuration.
     $settings['numberOfPages'] = intval($numberOfPages);
     // Recursively merge the predefined settings with the
     // supplied ones.
     $settings = t3lib_div::array_merge_recursive_overrule($this->settings, $settings);
     // Return the resulting code.
     return $this->cObj->cObjGetSingle('USER', $settings);
 }
Exemplo n.º 22
0
 /**
  * Creates a request an dispatches it to a controller.
  *
  * @param string $content The content
  * @param array $configuration The TS configuration array
  * @return string $content The processed content
  */
 public function dispatch($content, $configuration)
 {
     // FIXME Remove the next lines. These are only there to generate the ext_autoload.php file
     //$extutil = new Tx_Extbase_Utility_Extension;
     //$extutil->createAutoloadRegistryForExtension('extbase', t3lib_extMgm::extPath('extbase'));
     //$extutil->createAutoloadRegistryForExtension('fluid', t3lib_extMgm::extPath('fluid'));
     $this->timeTrackPush('Extbase is called.', '');
     $this->timeTrackPush('Extbase gets initialized.', '');
     if (!is_array($configuration)) {
         t3lib_div::sysLog('Extbase was not able to dispatch the request. No configuration.', 'extbase', t3lib_div::SYSLOG_SEVERITY_ERROR);
         return $content;
     }
     $this->initializeConfigurationManagerAndFrameworkConfiguration($configuration);
     $requestBuilder = t3lib_div::makeInstance('Tx_Extbase_MVC_Web_RequestBuilder');
     $request = $requestBuilder->initialize(self::$extbaseFrameworkConfiguration);
     $request = $requestBuilder->build();
     if (isset($this->cObj->data) && is_array($this->cObj->data)) {
         // we need to check the above conditions as cObj is not available in Backend.
         $request->setContentObjectData($this->cObj->data);
         $request->setIsCached($this->cObj->getUserObjectType() == tslib_cObj::OBJECTTYPE_USER);
     }
     $response = t3lib_div::makeInstance('Tx_Extbase_MVC_Web_Response');
     // Request hash service
     $requestHashService = t3lib_div::makeInstance('Tx_Extbase_Security_Channel_RequestHashService');
     // singleton
     $requestHashService->verifyRequest($request);
     $persistenceManager = self::getPersistenceManager();
     $this->timeTrackPull();
     $this->timeTrackPush('Extbase dispatches request.', '');
     $dispatchLoopCount = 0;
     while (!$request->isDispatched()) {
         if ($dispatchLoopCount++ > 99) {
             throw new Tx_Extbase_MVC_Exception_InfiniteLoop('Could not ultimately dispatch the request after ' . $dispatchLoopCount . ' iterations.', 1217839467);
         }
         $controller = $this->getPreparedController($request);
         try {
             $controller->processRequest($request, $response);
         } catch (Tx_Extbase_MVC_Exception_StopAction $ignoredException) {
         }
     }
     $this->timeTrackPull();
     $this->timeTrackPush('Extbase persists all changes.', '');
     $flashMessages = t3lib_div::makeInstance('Tx_Extbase_MVC_Controller_FlashMessages');
     // singleton
     $flashMessages->persist();
     $persistenceManager->persistAll();
     $this->timeTrackPull();
     self::$reflectionService->shutdown();
     if (count($response->getAdditionalHeaderData()) > 0) {
         $GLOBALS['TSFE']->additionalHeaderData[$request->getControllerExtensionName()] = implode("\n", $response->getAdditionalHeaderData());
     }
     $response->sendHeaders();
     $this->timeTrackPull();
     return $response->getContent();
 }
Exemplo n.º 23
0
 /**
  * Get content records based on column and pid
  *
  * @return array
  */
 protected function getContentRecords()
 {
     $loadRegister = FALSE;
     if (empty($this->arguments['loadRegister']) === FALSE) {
         $this->contentObject->cObjGetSingle('LOAD_REGISTER', $this->arguments['loadRegister']);
         $loadRegister = TRUE;
     }
     $pid = $this->arguments['pageUid'] ? $this->arguments['pageUid'] : $GLOBALS['TSFE']->id;
     $order = $this->arguments['order'] . ' ' . $this->arguments['sortDirection'];
     $colPos = $this->arguments['column'];
     $contentUids = $this->arguments['contentUids'];
     $slide = $this->arguments['slide'] ? $this->arguments['slide'] : FALSE;
     $slideCollect = $this->arguments['slideCollect'] ? $this->arguments['slideCollect'] : FALSE;
     if ($slideCollect !== FALSE) {
         $slide = min($slide, $slideCollect);
     }
     $slideCollectReverse = $this->arguments['slideCollectReverse'];
     $rootLine = NULL;
     if ($slide) {
         $pageSelect = new t3lib_pageSelect();
         $rootLine = $pageSelect->getRootLine($pid);
         if ($slideCollectReverse) {
             $rootLine = array_reverse($rootLine);
         }
     }
     $content = array();
     do {
         if ($slide) {
             $page = array_shift($rootLine);
             if (!$page) {
                 break;
             }
             $pid = $page['uid'];
         }
         if (is_array($contentUids)) {
             $conditions = 'uid IN (' . implode(',', $contentUids) . ')';
         } else {
             $conditions = "pid = '" . $pid . "' AND colPos = '" . $colPos . "' AND (tx_flux_column = '' OR tx_flux_column IS NULL) " . $GLOBALS['TSFE']->cObj->enableFields('tt_content') . " AND (sys_language_uid IN (-1,0) OR (sys_language_uid = '" . $GLOBALS['TSFE']->sys_language_uid . "' AND l18n_parent = '0'))";
         }
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tt_content', $conditions, 'uid', $order, $this->arguments['limit']);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $conf = array('tables' => 'tt_content', 'source' => $row['uid'], 'dontCheckPid' => 0);
             array_push($content, $GLOBALS['TSFE']->cObj->RECORDS($conf));
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
         if (count($content) && !$slideCollect) {
             break;
         }
     } while ($slide !== FALSE && --$slide !== -1);
     if ($loadRegister) {
         $this->contentObject->cObjGetSingle('RESTORE_REGISTER', '');
     }
     return $content;
 }
Exemplo n.º 24
0
 /**
  * Get link of language menu entry
  *
  * @param $uid
  * @return string
  */
 protected function getLanguageUrl($uid)
 {
     $getValues = t3lib_div::_GET();
     $getValues['L'] = $uid;
     $currentPage = $GLOBALS['TSFE']->id;
     unset($getValues['id']);
     unset($getValues['cHash']);
     $addParams = http_build_query($getValues);
     $config = array('parameter' => $currentPage, 'returnLast' => 'url', 'additionalParams' => '&' . $addParams, 'useCacheHash' => $this->arguments['useCHash']);
     return $this->cObj->typoLink('', $config);
 }
Exemplo n.º 25
0
 /**
  * Provides the values for the markers in the simple form template
  *
  * @return array An array containing values for markers in the simple form template
  * @throws InvalidArgumentException if an registered form modifier fails to implement the required interface Tx_Solr_FormModifier
  */
 public function execute()
 {
     $url = $this->cObj->getTypoLink_URL($this->parentPlugin->conf['search.']['targetPage']);
     $marker = array('action' => htmlspecialchars($url), 'action_id' => intval($this->parentPlugin->conf['search.']['targetPage']), 'action_language' => intval($GLOBALS['TSFE']->sys_page->sys_language_uid), 'action_language_parameter' => 'L', 'accept-charset' => $GLOBALS['TSFE']->metaCharset, 'q' => $this->parentPlugin->getCleanUserQuery());
     // hook to modify the search form
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['modifySearchForm'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['modifySearchForm'] as $classReference) {
             $formModifier = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classReference);
             if ($formModifier instanceof Tx_Solr_FormModifier) {
                 if ($formModifier instanceof Tx_Solr_CommandPluginAware) {
                     $formModifier->setParentPlugin($this->parentPlugin);
                 }
                 $marker = $formModifier->modifyForm($marker, $this->parentPlugin->getTemplate());
             } else {
                 throw new InvalidArgumentException('Form modifier "' . $classReference . '" must implement the Tx_Solr_FormModifier interface.', 1262864703);
             }
         }
     }
     return $marker;
 }
Exemplo n.º 26
0
 /**
  * @param string $parseFuncTSPath path to TypoScript parseFunc setup.
  * @return the parsed string.
  * @author Bastian Waidelich <*****@*****.**>
  * @author Niels Pardon <*****@*****.**>
  */
 public function render($parseFuncTSPath = 'lib.parseFunc_RTE')
 {
     if (TYPO3_MODE === 'BE') {
         $this->simulateFrontendEnvironment();
     }
     $value = $this->renderChildren();
     $content = $this->contentObject->parseFunc($value, array(), '< ' . $parseFuncTSPath);
     if (TYPO3_MODE === 'BE') {
         $this->resetFrontendEnvironment();
     }
     return $content;
 }
 /**
  * get the option records from DB which are configured as commaseperate list within the filter records
  *
  * @param string $optionUids A commaseperated list of option uids
  * @return array Array with option records
  */
 public function getOptionsFromUidList($optionUids)
 {
     if (empty($optionUids)) {
         return array();
     }
     $fields = '*';
     $table = 'tx_kesearch_filteroptions';
     $where = 'FIND_IN_SET(uid, "' . $GLOBALS['TYPO3_DB']->quoteStr($optionUids, $table) . '")';
     $where .= ' AND pid in (' . $GLOBALS['TYPO3_DB']->quoteStr($this->startingPoints, $table) . ')';
     $where .= $this->cObj->enableFields($table);
     return $this->languageOverlay($GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table, $where, '', 'FIND_IN_SET(uid, "' . $GLOBALS['TYPO3_DB']->quoteStr($optionUids, $table) . '")', '', 'uid'), $table);
 }
 /**
  * render a hidden field
  * They are needed to not forget setted options while search for another word
  *
  * @param integer $filterUid The filter uid
  * @param array $option An array containing the option
  * @return string A HTML formatted hidden input field
  */
 public function renderHiddenField($filterUid, $option)
 {
     $attributes = array();
     $attributes['type'] = 'hidden';
     $attributes['name'] = 'tx_kesearch_pi1[filter][' . $filterUid . '][' . $option['uid'] . ']';
     $attributes['id'] = 'tx_kesearch_pi1_' . $filterUid . '_' . $option['uid'];
     $attributes['value'] = htmlspecialchars($option['tag']);
     foreach ($attributes as $key => $attribut) {
         $attributes[$key] = $key . $this->cObj->wrap($attribut, '="|"');
     }
     return '<input ' . implode(' ', $attributes) . ' />';
 }
 /**
  * Modifies the search form by providing an additional marker linking to a
  * new query with the suggestions provided by Solr as the search terms.
  *
  * @param	array	An array of existing form markers
  * @param	tx_solr_Template	An isntance of the tempalte engine
  * @return	array	Array with additional markers for suggestions
  */
 public function modifyForm(array $markers, tx_solr_Template $template)
 {
     $spellCheckingEnabled = $this->configuration['search.']['spellchecking'];
     if ($spellCheckingEnabled && $this->search->hasSearched()) {
         $suggestions = $this->search->getSpellcheckingSuggestions();
         if ($suggestions) {
             $query = clone $this->search->getQuery();
             $query->setKeywords($suggestions['collation']);
             $markers['suggestion'] = tslib_cObj::noTrimWrap($query->getQueryLink($query->getKeywords()), $this->configuration['search.']['spellchecking.']['wrap']);
         }
     }
     return $markers;
 }
Exemplo n.º 30
0
 /**
  * Render the sp_socialsharing plug-in.
  *
  * @param string $pageTitle The value of ###TITLE###.
  * @param string $services The list of services.
  * @param array $settings The settings which override the default one.
  * @return string The SocialSharing plugin-in.
  * @author Romain Ruetschi <*****@*****.**>
  */
 public function render($pageTitle = '', $services = '', array $settings = array())
 {
     // Recursively merge the predefined settings with the
     // supplied ones.
     $settings = t3lib_div::array_merge_recursive_overrule($this->settings, $settings);
     if (trim($pageTitle)) {
         $settings['pageTitle.'] = array('value' => trim($pageTitle));
     }
     if (trim($services)) {
         $settings['serviceList'] = trim($services);
     }
     // Return the resulting code.
     return $this->cObj->cObjGetSingle('USER', $settings);
 }