Exemplo n.º 1
0
 /**
  * @test
  */
 public function convertsCommaSeparatedListFromValueToSerializedArrayOfTrimmedValues()
 {
     $list = 'abc, def, ghi, jkl, mno, pqr, stu, vwx, yz';
     $expected = 'a:9:{i:0;s:3:"abc";i:1;s:3:"def";i:2;s:3:"ghi";i:3;s:3:"jkl";i:4;s:3:"mno";i:5;s:3:"pqr";i:6;s:3:"stu";i:7;s:3:"vwx";i:8;s:2:"yz";}';
     $this->contentObject->start(array());
     $actual = $this->contentObject->cObjGetSingle(\Tx_Solr_contentobject_Multivalue::CONTENT_OBJECT_NAME, array('value' => $list, 'separator' => ','));
     $this->assertEquals($expected, $actual);
 }
 /**
  * Manipulate values through TypoScript before rendering
  *
  * @param Answer $answer
  * @param string $type "createAction", "confirmationAction", "sender", "receiver"
  * @return string
  */
 public function render(Answer $answer, $type)
 {
     $value = $this->renderChildren();
     if ($answer->getField()) {
         if (!empty($this->typoScriptContext[$this->typeToTsType[$type] . '.'][$answer->getField()->getMarker()])) {
             $this->contentObjectRenderer->start($answer->_getProperties());
             $value = $this->contentObjectRenderer->cObjGetSingle($this->typoScriptContext[$this->typeToTsType[$type] . '.'][$answer->getField()->getMarker()], $this->typoScriptContext[$this->typeToTsType[$type] . '.'][$answer->getField()->getMarker() . '.']);
         }
     }
     return $value;
 }
Exemplo n.º 3
0
 /**
  * Return an URL to the scaled image
  *
  * @param string $originalFile uid or path of the file
  * @param array $imageSize width and height as keys
  * @return string
  */
 protected function getScaledImagePath($originalFile, $imageSize)
 {
     $conf = array('file' => $originalFile, 'file.' => array('height' => $imageSize['height'], 'width' => $imageSize['width']));
     $imgUri = $this->cObj->cObjGetSingle('IMG_RESOURCE', $conf);
     $conf = array('parameter' => $imgUri, 'forceAbsoluteUrl' => 1);
     return $this->cObj->typoLink_URL($conf);
 }
Exemplo n.º 4
0
 /**
  * Make content object
  *
  * @return string
  */
 protected function makeContentObject($isSent)
 {
     $message = NULL;
     $type = NULL;
     if ($this->typoScript['messages.'][$isSent]) {
         $type = $this->typoScript['messages.'][$isSent];
     }
     if ($this->typoScript['messages.'][$isSent . '.']) {
         $message = $this->typoScript['messages.'][$isSent . '.'];
     }
     if (empty($message)) {
         if (!empty($type)) {
             $message = $type;
             $type = 'TEXT';
         } else {
             $type = 'TEXT';
             $message = $this->getLocalLanguageLabel($isSent);
         }
         $value['value'] = $message;
         $value['wrap'] = '<p>|</p>';
     } elseif (!is_array($message)) {
         $value['value'] = $message;
         $value['wrap'] = '<p>|</p>';
     } else {
         $value = $message;
     }
     return $this->localCobj->cObjGetSingle($type, $value);
 }
Exemplo n.º 5
0
 /**
  * Return the image crop suffix ("c") if set for the current imageorient
  *
  * @param $conf
  * @return mixed
  */
 public function getCropValue($conf)
 {
     $conf = $conf['userFunc.'];
     $imageorient = $this->cObj->cObjGetSingle($conf['imageorient'], $conf['imageorient.']);
     $crop = $this->collections['cropConfiguration'][$imageorient];
     return $crop;
 }
Exemplo n.º 6
0
 /**
  * Renders the application defined cObject FORM
  * which overrides the TYPO3 default cObject FORM
  *
  * Convert FORM to COA_INT - COA_INT.10 = FORM_INT
  * If FORM_INT is also dedected by the ContentObjectRenderer, and now
  * the Extbaseplugin "Form" is initalized. At this time the
  * controller "Frontend" action "execute" do the rest.
  *
  * @param string $typoScriptObjectName Name of the object
  * @param array $typoScript TS configuration for this cObject
  * @param string $typoScriptKey A string label used for the internal debugging tracking.
  * @param ContentObjectRenderer $contentObject reference
  * @return string HTML output
  */
 public function cObjGetSingleExt($typoScriptObjectName, array $typoScript, $typoScriptKey, ContentObjectRenderer $contentObject)
 {
     $content = '';
     if ($typoScriptObjectName === 'FORM' && !empty($typoScript['useDefaultContentObject']) && ExtensionManagementUtility::isLoaded('compatibility6')) {
         $content = $contentObject->getContentObject($typoScriptObjectName)->render($typoScript);
     } elseif ($typoScriptObjectName === 'FORM') {
         $mergedTypoScript = null;
         if ($contentObject->data['CType'] === 'mailform') {
             $bodytext = $contentObject->data['bodytext'];
             /** @var $typoScriptParser TypoScriptParser */
             $typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class);
             $typoScriptParser->parse($bodytext);
             $mergedTypoScript = (array) $typoScriptParser->setup;
             ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, $typoScript);
             // Disables content elements since TypoScript is handled that could contain insecure settings:
             $mergedTypoScript[Configuration::DISABLE_CONTENT_ELEMENT_RENDERING] = true;
         }
         $newTypoScript = array('10' => 'FORM_INT', '10.' => is_array($mergedTypoScript) ? $mergedTypoScript : $typoScript);
         $content = $contentObject->cObjGetSingle('COA_INT', $newTypoScript);
         // Only apply stdWrap to TypoScript that was NOT created by the wizard:
         if (isset($typoScript['stdWrap.'])) {
             $content = $contentObject->stdWrap($content, $typoScript['stdWrap.']);
         }
     } elseif ($typoScriptObjectName === 'FORM_INT') {
         $extbase = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
         $content = $extbase->run('', array('pluginName' => 'Form', 'extensionName' => 'Form', 'vendorName' => 'TYPO3\\CMS', 'controller' => 'Frontend', 'action' => 'show', 'settings' => array('typoscript' => $typoScript), 'persistence' => array(), 'view' => array()));
     }
     return $content;
 }
 /**
  * Get from TypoScript content object like
  *
  *        # direct value
  *        plugin.tx_powermail.settings.setup.prefill.marker = TEXT
  *        plugin.tx_powermail.settings.setup.prefill.marker.value = red
  *
  *        # multiple value
  *        plugin.tx_powermail.settings.setup.prefill.marker.0 = TEXT
  *        plugin.tx_powermail.settings.setup.prefill.marker.0.value = red
  *
  * @return bool
  */
 protected function getFromTypoScriptContentObject()
 {
     $selected = false;
     if (isset($this->settings['prefill.'][$this->getMarker() . '.']) && is_array($this->settings['prefill.'][$this->getMarker() . '.'])) {
         $this->contentObjectRenderer->start(ObjectAccess::getGettableProperties($this->getField()));
         // Multivalue
         if (isset($this->settings['prefill.'][$this->getMarker() . '.']['0'])) {
             foreach (array_keys($this->settings['prefill.'][$this->getMarker() . '.']) as $key) {
                 if (stristr($key, '.')) {
                     continue;
                 }
                 $prefill = $this->contentObjectRenderer->cObjGetSingle($this->settings['prefill.'][$this->getMarker() . '.'][$key], $this->settings['prefill.'][$this->getMarker() . '.'][$key . '.']);
                 if ($prefill === $this->options[$this->index]['value'] || $prefill === $this->options[$this->index]['label']) {
                     $selected = true;
                 }
             }
         } else {
             // Single value
             $prefill = $this->contentObjectRenderer->cObjGetSingle($this->settings['prefill.'][$this->getMarker()], $this->settings['prefill.'][$this->getMarker() . '.']);
             if ($prefill === $this->options[$this->index]['value'] || $prefill === $this->options[$this->index]['label']) {
                 $selected = true;
             }
         }
     }
     return $selected;
 }
Exemplo n.º 8
0
 /**
  * renders the columns of the grid container and returns the actual content
  *
  * @param $columns
  * @param array $child
  * @param array $parentGridData
  * @param array $parentRecordNumbers
  * @param array $typoScriptSetup
  *
  * @return void
  */
 public function renderChildIntoParentColumn($columns, &$child, &$parentGridData, &$parentRecordNumbers, $typoScriptSetup = array())
 {
     $column_number = (int) $child['tx_gridelements_columns'];
     $columnKey = $column_number . '.';
     if (!isset($typoScriptSetup['columns.'][$columnKey])) {
         $columnSetupKey = 'default.';
     } else {
         $columnSetupKey = $columnKey;
     }
     if ($child['uid'] > 0) {
         // update SYS_LASTCHANGED if necessary
         $this->cObj->lastChanged($child['tstamp']);
         $this->cObj->start(array_merge($child, $parentGridData), 'tt_content');
         $parentRecordNumbers[$columnKey]++;
         $this->cObj->parentRecordNumber = $parentRecordNumbers[$columnKey];
         // we render each child into the children key to provide them prerendered for usage with your own templating
         $child = $this->cObj->cObjGetSingle($typoScriptSetup['columns.'][$columnSetupKey]['renderObj'], $typoScriptSetup['columns.'][$columnSetupKey]['renderObj.']);
         // then we assign the prerendered child to the appropriate column
         if (isset($columns[$column_number])) {
             $parentGridData['tx_gridelements_view_columns'][$column_number] .= $child;
         }
         unset($columns);
     }
     unset($typoScriptSetup);
 }
Exemplo n.º 9
0
 /**
  * Returns the avatar of the user as a <img...> HTML tag
  *
  * @param  array	the user data array
  * @return string   the HTML tag
  */
 function getUserAvatar($userData)
 {
     $avatarImg = trim($userData['tx_mmforum_avatar']);
     $feuserImg = trim($userData['image']);
     $imgConf = $this->conf['list_posts.']['userinfo.']['avatar_cObj.'];
     $img = '';
     if ($avatarImg || $feuserImg) {
         if ($avatarImg) {
             $imgConf['file'] = $this->conf['path_avatar'] . $avatarImg;
         } else {
             // only take the first image, if there are multiple ones
             if (strpos($feuserImg, ',') !== false) {
                 list($feuserImg) = GeneralUtility::trimExplode(',', $feuserImg);
             }
             if (file_exists('uploads/pics/' . $feuserImg)) {
                 $imgConf['file'] = 'uploads/pics/' . $feuserImg;
             } else {
                 if (file_exists('uploads/tx_srfeuserregister/' . $feuserImg)) {
                     $imgConf['file'] = 'uploads/tx_srfeuserregister/' . $feuserImg;
                 }
             }
         }
         $img = $this->cObj->cObjGetSingle($this->conf['list_posts.']['userinfo.']['avatar_cObj'], $imgConf);
     }
     return $img;
 }
Exemplo n.º 10
0
 /**
  * @return DateConverter
  */
 protected function setOutputFormat()
 {
     $outputFormat = $this->cObj->cObjGetSingle($this->configuration['outputFormat'], $this->configuration['outputFormat.']);
     if (!empty($outputFormat)) {
         $this->outputFormat = $outputFormat;
     }
     return $this;
 }
 /**
  * Get target from overwrite settings in TypoScript
  *
  *      plugin.tx_powermail.settings.setup.thx.overwrite.redirect = TEXT
  *      plugin.tx_powermail.settings.setup.thx.overwrite.redirect.value = 123
  *
  * @return string|null
  */
 protected function getTargetFromTypoScript()
 {
     $target = null;
     $overwriteConfig = $this->getOverwriteTypoScript();
     if (!empty($overwriteConfig['redirect.'])) {
         $target = $this->contentObject->cObjGetSingle($overwriteConfig['redirect'], $overwriteConfig['redirect.']);
     }
     return $target;
 }
Exemplo n.º 12
0
 /**
  * Renders the canvas
  *
  * @return string
  */
 public function render()
 {
     foreach ($this->layers as $index => $layer) {
         $layerIndex = ($index + 1) * self::$layerIndexIncrement;
         list($layerType, $layerConfiguration) = $layer->toArray();
         $this->configuration['file.'][$layerIndex] = $layerType;
         $this->configuration['file.'][$layerIndex . '.'] = $layerConfiguration;
     }
     return $this->contentObject->cObjGetSingle('IMG_RESOURCE', $this->configuration);
 }
Exemplo n.º 13
0
 /**
  * Renders a given typoscript configuration and returns the whole array with
  * calculated values.
  *
  * @param array $settings the typoscript configuration array
  * @return array the configuration array with the rendered typoscript
  */
 public function renderConfigurationArray(array $settings)
 {
     $settings = $this->enhanceSettingsWithTypoScript($this->makeConfigurationArrayRenderable($settings));
     $result = array();
     foreach ($settings as $key => $value) {
         if (substr($key, -1) === '.') {
             $keyWithoutDot = substr($key, 0, -1);
             if (array_key_exists($keyWithoutDot, $settings)) {
                 $result[$keyWithoutDot] = $this->contentObject->cObjGetSingle($settings[$keyWithoutDot], $value);
             } else {
                 $result[$keyWithoutDot] = $this->renderConfigurationArray($value);
             }
         } else {
             if (!array_key_exists($key . '.', $settings)) {
                 $result[$key] = $value;
             }
         }
     }
     return $result;
 }
Exemplo n.º 14
0
 /**
  * Renders the wrapped term using the plugin settings
  *
  * @param \Dpn\DpnGlossary\Domain\Model\Term
  * @return string
  */
 protected function termWrapper(Term $term)
 {
     // get content object type
     $contentObjectType = $this->tsConfig['settings.']['termWraps'];
     // get term wrapping settings
     $wrapSettings = $this->tsConfig['settings.']['termWraps.'];
     // pass term data to the cObject pseudo constructor
     $this->cObj->start($term->toArray());
     // return the wrapped term
     return $this->cObj->cObjGetSingle($contentObjectType, $wrapSettings);
 }
Exemplo n.º 15
0
 /**
  * @param string $name
  * @param array $configuration
  * @param string $typoscriptKey
  * @param ContentObjectRenderer $contentObject
  * @return string
  */
 public function cObjGetSingleExt($name, array $configuration, $typoscriptKey, $contentObject)
 {
     $result = [];
     foreach ($configuration as $key => $contentObjectName) {
         if (strpos($key, '.') === false) {
             $conf = $configuration[$key . '.'];
             $content = $contentObject->cObjGetSingle($contentObjectName, $conf, $contentObjectName);
             $result[$key] = str_replace(array("\r", "\n", "\t"), '', $content);
         }
     }
     return json_encode($result);
 }
Exemplo n.º 16
0
 /**
  * Set Sender Header according to RFC 2822 - 3.6.2 Originator fields
  *
  * @param MailMessage $message
  * @return MailMessage
  */
 protected function addSenderHeader(MailMessage $message)
 {
     $senderHeaderConfig = $this->configuration[$this->type . '.']['senderHeader.'];
     $email = $this->contentObject->cObjGetSingle($senderHeaderConfig['email'], $senderHeaderConfig['email.']);
     $name = $this->contentObject->cObjGetSingle($senderHeaderConfig['name'], $senderHeaderConfig['name.']);
     if (GeneralUtility::validEmail($email)) {
         if (empty($name)) {
             $name = null;
         }
         $message->setSender($email, $name);
     }
     return $message;
 }
Exemplo n.º 17
0
	/**
	 * Construct the message
	 *
	 * The message is a cObj, which can be overriden using the typoscript
	 * setting confirmation.message, like
	 *
	 * confirmation.message = TEXT
	 * confirmation.message.value = Here some text
	 * confirmation.message.wrap = <p>|</p>
	 *
	 * @return string XHTML string containing the message
	 */
	protected function getMessage() {
		if (isset($this->typoscript['message']) && isset($this->typoscript['message.'])) {
			$value = $this->typoscript['message.'];
			$type = $this->typoscript['message'];
		} elseif (isset($this->typoscript['message.'])) {
			$value = $this->typoscript['message.'];
			$type = 'TEXT';
		} else {
			$value['wrap'] = '<p>|</p>';
			$value['value'] = $this->getLocalLanguageLabel('message');
			$type = 'TEXT';
		}
		return $this->localCobj->cObjGetSingle($type, $value);
	}
Exemplo n.º 18
0
 /**
  * This function renders an array of tt_content record into an array of rendered content
  * it returns a list of elements rendered by typoscript RECORD function
  *
  * @param array $rows database rows of records (each item is a tt_content table record)
  * @return array
  */
 protected function getRenderedRecords(array $rows)
 {
     if (FALSE === empty($this->arguments['loadRegister'])) {
         $this->contentObject->cObjGetSingle('LOAD_REGISTER', $this->arguments['loadRegister']);
     }
     $elements = array();
     foreach ($rows as $row) {
         array_push($elements, $this->renderRecord($row));
     }
     if (FALSE === empty($this->arguments['loadRegister'])) {
         $this->contentObject->cObjGetSingle('RESTORE_REGISTER', '');
     }
     return $elements;
 }
Exemplo n.º 19
0
 /**
  * Add attachments from TypoScript definition
  *
  * @param MailMessage $message
  * @return MailMessage
  */
 protected function addAttachmentsFromTypoScript(MailMessage $message)
 {
     $filesValue = $this->contentObject->cObjGetSingle($this->configuration[$this->type . '.']['addAttachment'], $this->configuration[$this->type . '.']['addAttachment.']);
     if (!empty($filesValue)) {
         $files = GeneralUtility::trimExplode(',', $filesValue, true);
         foreach ($files as $file) {
             if (file_exists(GeneralUtility::getFileAbsFileName($file))) {
                 $message->attach(\Swift_Attachment::fromPath($file));
             } else {
                 GeneralUtility::devLog('Error: File to attach does not exist', 'powermail', 2, $file);
             }
         }
     }
     return $message;
 }
Exemplo n.º 20
0
 /**
  * Get license information for the image
  *
  * @param array $image
  * @return string
  */
 protected function getImageInformation($image)
 {
     $imageUrl = '';
     $imageTitleText = [];
     $imageTitleText[] = $image['caption'];
     $imageTitleText[] = 'Urheber: ' . $image['original']['creator'];
     $imageTitleText[] = 'Copyright: ' . $image['original']['copyright'];
     $imageTitleText = implode(PHP_EOL, $imageTitleText);
     $licenseImagePath = 'typo3conf/ext/tmpl_sub/Resources/Public/Img';
     if ($image['original']['wiki_commons'] != '') {
         $imagePath = self::WIKICOMMONSIMG;
         $cssClass = 'wc';
         $imageUrl = $image['original']['copyright_url'];
         $imageTitleText .= PHP_EOL . $image['original']['wiki_commons'];
     } elseif ($image['original']['creative_commons'] == 1 && $image['original']['wiki_commons'] == '') {
         $imagePath = self::CCIMG;
         $cssClass = 'cc';
         $imageUrl = 'http://creativecommons.org/licenses/by-nc-nd/3.0/';
     } else {
         $imagePath = self::NURINFOIMG;
         $cssClass = 'info';
         if ($image['original']['copyright_url']) {
             $imageUrl = $image['original']['copyright_url'];
         }
     }
     $completeImagePath = $licenseImagePath . '/' . $imagePath;
     $bild = [];
     $bild['file'] = $completeImagePath;
     // Configuration for the image link
     if ($imageUrl != '') {
         $bild['imageLinkWrap'] = 1;
         $bild['imageLinkWrap.']['enable'] = 1;
         $bild['imageLinkWrap.']['typolink.']['parameter'] = $imageUrl;
         $bild['imageLinkWrap.']['typolink.']['extTarget'] = '_blank';
         $bild['imageLinkWrap.']['JSWindow.'] = 0;
     }
     // add title to the image
     $bild['titleText'] = $imageTitleText;
     $bild['altText'] = "";
     $imageInformation = $this->local_cObj->cObjGetSingle('IMAGE', $bild);
     // return with a special css class for that particular image
     return '<div class=" bigpicture-license bigpicture-license-' . $cssClass . '">' . $imageInformation . '</div>';
 }
 /**
  * Get from TypoScript content object like
  *
  *        # direct value
  *        plugin.tx_powermail.settings.setup.prefill.marker = TEXT
  *        plugin.tx_powermail.settings.setup.prefill.marker.value = red
  *
  *        # multiple value
  *        plugin.tx_powermail.settings.setup.prefill.marker.0 = TEXT
  *        plugin.tx_powermail.settings.setup.prefill.marker.0.value = red
  *
  * @return array|string
  */
 protected function getFromTypoScriptContentObject()
 {
     $value = '';
     if (isset($this->settings['prefill.'][$this->getMarker() . '.']) && is_array($this->settings['prefill.'][$this->getMarker() . '.'])) {
         $this->contentObjectRenderer->start(ObjectAccess::getGettableProperties($this->getField()));
         // Multivalue
         if (isset($this->settings['prefill.'][$this->getMarker() . '.']['0'])) {
             $value = array();
             foreach (array_keys($this->settings['prefill.'][$this->getMarker() . '.']) as $key) {
                 if (stristr($key, '.')) {
                     continue;
                 }
                 $value[] = $this->contentObjectRenderer->cObjGetSingle($this->settings['prefill.'][$this->getMarker() . '.'][$key], $this->settings['prefill.'][$this->getMarker() . '.'][$key . '.']);
             }
         } else {
             // Single value
             $value = $this->contentObjectRenderer->cObjGetSingle($this->settings['prefill.'][$this->getMarker()], $this->settings['prefill.'][$this->getMarker() . '.']);
         }
     }
     return $value;
 }
Exemplo n.º 22
0
 /**
  * Renders the TypoScript object in the given TypoScript setup path.
  *
  * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
  * @return string the content of the rendered TypoScript object
  */
 public function render()
 {
     $typoscriptObjectPath = $this->arguments['typoscriptObjectPath'];
     $data = $this->arguments['data'];
     $currentValueKey = $this->arguments['currentValueKey'];
     $table = $this->arguments['table'];
     if (TYPO3_MODE === 'BE') {
         $this->simulateFrontendEnvironment();
     }
     if ($data === null) {
         $data = $this->renderChildren();
     }
     $currentValue = null;
     if (is_object($data)) {
         $data = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGettableProperties($data);
     } elseif (is_string($data) || is_numeric($data)) {
         $currentValue = (string) $data;
         $data = [$data];
     }
     $this->contentObjectRenderer->start($data, $table);
     if ($currentValue !== null) {
         $this->contentObjectRenderer->setCurrentVal($currentValue);
     } elseif ($currentValueKey !== null && isset($data[$currentValueKey])) {
         $this->contentObjectRenderer->setCurrentVal($data[$currentValueKey]);
     }
     $pathSegments = GeneralUtility::trimExplode('.', $typoscriptObjectPath);
     $lastSegment = array_pop($pathSegments);
     $setup = $this->typoScriptSetup;
     foreach ($pathSegments as $segment) {
         if (!array_key_exists($segment . '.', $setup)) {
             throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('TypoScript object path "' . htmlspecialchars($typoscriptObjectPath) . '" does not exist', 1253191023);
         }
         $setup = $setup[$segment . '.'];
     }
     $content = $this->contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.']);
     if (TYPO3_MODE === 'BE') {
         $this->resetFrontendEnvironment();
     }
     return $content;
 }
Exemplo n.º 23
0
 /**
  * Display a poll.
  * This function displays a poll. Depending on whether the user that is
  * currently logged in is allowed to vote on this poll (this will be the
  * case if the user has not already voted in this poll and if the poll is
  * not yet expired), the user will see a set of radio buttons allowing him/her
  * to choose an answering possibility, or the poll results.
  *
  * @return  string The poll content
  * @version 2007-05-22
  */
 function objDisplay()
 {
     if ($this->piVars['poll']['vote'] == '1') {
         $this->objVote();
     }
     $template = $this->cObj->fileResource($this->conf['template.']['polls']);
     $template = $this->cObj->getSubpart($template, '###POLL_DISPLAY###');
     $vote = $this->getMayVote();
     if (!$vote) {
         $template = $this->cObj->substituteSubpart($template, '###POLL_SUBMIT###', '');
         $row_template = $this->cObj->getSubpart($template, '###POLL_ANSWER_2###');
     } else {
         $row_template = $this->cObj->getSubpart($template, '###POLL_ANSWER_1###');
     }
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_polls_answers', 'poll_id=' . intval($this->data['uid']) . ' AND deleted=0');
     $i = 1;
     $aContent = '';
     while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) {
         $pAnswers = $arr['votes'] > 0 ? round($arr['votes'] / $this->data['votes'] * 100) : 0;
         if ($this->conf['polls.']['pollBar_colorMap.'][$i]) {
             $color = $this->conf['polls.']['pollBar_colorMap.'][$i];
         } else {
             $color = $this->conf['polls.']['pollBar_colorMap.']['default'];
         }
         $aMarker = array('###ANSWER_UID###' => $arr['uid'], '###ANSWER_TEXT###' => $this->p->escape($arr['answer']), '###ANSWER_COUNT###' => sprintf($this->p->pi_getLL('poll.replies'), $arr['votes'], $this->data['votes'], $pAnswers . '%'), '###ANSWER_ANSWERS###' => '<div style="width: ' . $pAnswers . '%; height:10px; background-color: ' . $color . ';">&nbsp;</div>', '###ENABLE###' => '');
         $aContent .= $this->cObj->substituteMarkerArray($row_template, $aMarker);
         $i++;
     }
     $actionParams[$this->p->prefixId] = array('tid' => $this->p->piVars['tid'], 'fid' => $this->p->piVars['fid'], 'action' => 'list_post');
     $actionLink = $this->p->pi_getPageLink($GLOBALS['TSFE']->id, '', $actionParams);
     $marker = array('###LABEL_POLL###' => $this->p->pi_getLL('poll.title'), '###LABEL_VOTE###' => $this->p->pi_getLL('poll.vote'), '###LABEL_QUESTION###' => $this->p->pi_getLL('poll.question'), '###QUESTION###' => $this->p->escape($this->data['question']), '###EXPIRES###' => $this->data['endtime'] ? $this->p->pi_getLL('poll.expires') . ' ' . date('d. m. Y, H:i', $this->data['endtime']) : '', '###ACTION###' => $this->p->escapeURL($actionLink), '###ICON###' => $this->cObj->cObjGetSingle($this->conf['polls.']['poll_icon'], $this->conf['polls.']['poll_icon.']));
     $marker['###EXPIRES###'] = $this->cObj->stdWrap($marker['###EXPIRES###'], $this->conf['polls.']['expired_stdWrap.']);
     $template = $this->cObj->substituteMarkerArray($template, $marker);
     $template = $this->cObj->substituteSubpart($template, '###POLL_ANSWER_1###', $aContent);
     $template = $this->cObj->substituteSubpart($template, '###POLL_ANSWER_2###', '');
     return $template;
 }
 /**
  * Check if sendPost is activated
  *      - if it's enabled via TypoScript
  *      - if form was final submitted (without optin)
  *
  * @return bool
  */
 protected function isEnabled()
 {
     return $this->contentObject->cObjGetSingle($this->configuration['_enable'], $this->configuration['_enable.']) === '1' && $this->isFormSubmitted();
 }
Exemplo n.º 25
0
 /**
  * Returns the Backend User edit panel for the $row from $tablename
  *
  * @param array $row Record array.
  * @param string $tablename Table name
  * @param string $label A label to show with the panel.
  * @param array $conf TypoScript parameters to pass along to the EDITPANEL content Object that gets rendered. The property "allow" WILL get overridden/set though.
  * @return string Returns FALSE/blank if no BE User login and of course if the panel is not shown for other reasons. Otherwise the HTML for the panel (a table).
  * @see ContentObjectRenderer::EDITPANEL()
  */
 public function pi_getEditPanel($row = array(), $tablename = '', $label = '', $conf = array())
 {
     $panel = '';
     if (!$row || !$tablename) {
         $row = $this->internal['currentRow'];
         $tablename = $this->internal['currentTable'];
     }
     if ($this->frontendController->beUserLogin) {
         // Create local cObj if not set:
         if (!is_object($this->pi_EPtemp_cObj)) {
             $this->pi_EPtemp_cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
             $this->pi_EPtemp_cObj->setParent($this->cObj->data, $this->cObj->currentRecord);
         }
         // Initialize the cObj object with current row
         $this->pi_EPtemp_cObj->start($row, $tablename);
         // Setting TypoScript values in the $conf array. See documentation in TSref for the EDITPANEL cObject.
         $conf['allow'] = 'edit,new,delete,move,hide';
         $panel = $this->pi_EPtemp_cObj->cObjGetSingle('EDITPANEL', $conf, 'editpanel');
     }
     if ($panel) {
         if ($label) {
             return '<!-- BEGIN: EDIT PANEL --><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top">' . $label . '</td><td valign="top" align="right">' . $panel . '</td></tr></table><!-- END: EDIT PANEL -->';
         } else {
             return '<!-- BEGIN: EDIT PANEL -->' . $panel . '<!-- END: EDIT PANEL -->';
         }
     } else {
         return $label;
     }
 }
Exemplo n.º 26
0
 /**
  * Check if this table is enabled in TypoScript
  *
  * @param string $table
  * @return bool
  */
 protected function isTableEnabled($table)
 {
     return $this->contentObject->cObjGetSingle($this->configuration[$table]['_enable'], $this->configuration[$table]['_enable.']) === '1';
 }
 /**
  * Parse a content element
  *
  * @param int $uid UID of any content element
  * @return string Parsed Content Element
  */
 public function render($uid)
 {
     $configuration = array('tables' => 'tt_content', 'source' => (int) $uid, 'dontCheckPid' => 1);
     return $this->contentObject->cObjGetSingle('RECORDS', $configuration);
 }
 /**
  * Parsed TypoScript Objekte
  *
  * @param string $objType
  * @param array $objArray
  * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj
  */
 public static function parseTypoScriptObj($objType, $objArray, $cObj)
 {
     if (!empty($objType) && sizeof($objArray) > 0) {
         return $cObj->cObjGetSingle($objType, $objArray);
     } else {
         return FALSE;
     }
 }
Exemplo n.º 29
0
	/**
	 * Renders the application defined cObject FORM
	 * which overrides the TYPO3 default cObject FORM
	 *
	 * First we make a COA_INT out of it, because it does not need to be cached
	 * Then we send a FORM_INT to the COA_INT
	 * When this is read, it will call the FORM class again.
	 *
	 * It simply calls execute because this function name is not really descriptive
	 * but is needed by the core of TYPO3
	 *
	 * @param string $typoScriptObjectName Name of the object
	 * @param array $typoScript TS configuration for this cObject
	 * @param string $typoScriptKey A string label used for the internal debugging tracking.
	 * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject reference
	 * @return string HTML output
	 */
	public function cObjGetSingleExt($typoScriptObjectName, array $typoScript, $typoScriptKey, \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject) {
		$content = '';
		if ($typoScriptObjectName === 'FORM' && !empty($typoScript['useDefaultContentObject'])) {
			$content = $contentObject->getContentObject($typoScriptObjectName)->render($typoScript);
		} elseif ($typoScriptObjectName === 'FORM') {
			if ($contentObject->data['CType'] === 'mailform') {
				$bodytext = $contentObject->data['bodytext'];
				/** @var $typoScriptParser \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */
				$typoScriptParser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
				$typoScriptParser->parse($bodytext);
				$mergedTypoScript = (array)$typoScriptParser->setup;
				\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, (array)$typoScript);
				// Disables content elements since TypoScript is handled that could contain insecure settings:
				$mergedTypoScript[\TYPO3\CMS\Form\Domain\Factory\TypoScriptFactory::PROPERTY_DisableContentElement] = TRUE;
			}
			$newTypoScript = array(
				'10' => 'FORM_INT',
				'10.' => is_array($mergedTypoScript) ? $mergedTypoScript : $typoScript,
			);
			$content = $contentObject->cObjGetSingle('COA_INT', $newTypoScript);
			// Only apply stdWrap to TypoScript that was NOT created by the wizard:
			if (isset($typoScript['stdWrap.'])) {
				$content = $contentObject->stdWrap($content, $typoScript['stdWrap.']);
			}
		} elseif ($typoScriptObjectName === 'FORM_INT') {
			$this->initialize($typoScript);
			$content = $this->execute();
		}
		return $content;
	}
Exemplo n.º 30
0
 /**
  * @param Request $request
  * @param Response $response
  * @param RenderingContext $renderingContext
  * @return void
  */
 public function renderRequest(Request $request, Response $response, RenderingContext $renderingContext)
 {
     $contentObjectRenderer = new ContentObjectRenderer();
     $content = $contentObjectRenderer->cObjGetSingle('RECORDS', $this->resolveRenderingConfiguration($request, $renderingContext));
     $response->setContent($content);
 }