/** * @param array $variables * @param string $template * * @return \TYPO3\CMS\Fluid\View\StandaloneView */ public function getStandaloneView(array $variables, $template) { $viewObject = $this->objectManager->create('TYPO3\\CMS\\Fluid\\View\\StandaloneView'); $viewObject->setFormat('html'); $templatePathAndFilename = $this->templateRootPath . $template; $viewObject->setTemplatePathAndFilename($templatePathAndFilename); $viewObject->assignMultiple($variables); return $viewObject; }
/** * Loads module data for user settings or returns a fresh object initially * * @return \TYPO3\CMS\Beuser\Domain\Model\ModuleData */ public function loadModuleData() { $moduleData = $GLOBALS['BE_USER']->getModuleData(self::KEY); if (empty($moduleData) || !$moduleData) { $moduleData = $this->objectManager->create('TYPO3\\CMS\\Beuser\\Domain\\Model\\ModuleData'); } else { $moduleData = @unserialize($moduleData); } return $moduleData; }
/** * Loads module data for user settings or returns a fresh object initially * * @return \ApacheSolrForTypo3\Solr\Domain\Model\ModuleData */ public function loadModuleData() { $moduleData = $GLOBALS['BE_USER']->getModuleData(self::KEY); if (empty($moduleData) || !$moduleData) { $moduleData = $this->objectManager->create('ApacheSolrForTypo3\\Solr\\Domain\\Model\\ModuleData'); } else { $moduleData = unserialize($moduleData); } return $moduleData; }
/** * Returns all objects of this repository. * * @return array */ public function findAll() { if (!count($this->extensions)) { $availableExtensions = $this->listUtility->getAvailableExtensions(); $availableAndInstalledExtensions = $this->listUtility->getAvailableAndInstalledExtensions($availableExtensions); $availableAndInstalledExtensions = $this->listUtility->enrichExtensionsWithEmConfAndTerInformation($availableAndInstalledExtensions); foreach ($availableAndInstalledExtensions as $entry) { /** @var $extension \TYPO3\CMS\Lang\Domain\Model\Extension */ $extension = $this->objectManager->create('TYPO3\\CMS\\Lang\\Domain\\Model\\Extension', $entry['key'], $entry['title'], $this->getExtensionIconWithPath($entry)); $extension->setVersionFromString($entry['version']); $this->extensions[$entry['key']] = $extension; } // Sort the list by extension key ksort($this->extensions); } return $this->extensions; }
/** * Finds all loaded extensions * * @return Tx_Extbase_Persistence_ObjectStorage<Tx_About_Domain_Model_Extension> */ public function findAllLoaded() { $loadedExtensions = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\ObjectStorage'); $loadedExtensionsArray = $GLOBALS['TYPO3_LOADED_EXT']; foreach ($loadedExtensionsArray as $extensionKey => $extension) { if (is_array($extension) && $extension['type'] != 'S') { $emconfPath = PATH_site . $extension['siteRelPath'] . 'ext_emconf.php'; include $emconfPath; $extension = $this->objectManager->create('TYPO3\\CMS\\About\\Domain\\Model\\Extension'); $extension->setKey($extensionKey); $extension->setTitle($EM_CONF['']['title']); $extension->setAuthor($EM_CONF['']['author']); $extension->setAuthorEmail($EM_CONF['']['author_email']); $loadedExtensions->attach($extension); } } return $loadedExtensions; }
/** * Merge $ColumnTypes with $ColumnConfig * * @param array $columnTypes Column types * @param string $columnConfiguration Column configuration * @return array $types */ private function mergeColumnTypesWithColumnConfig($columnTypes, $columnConfiguration) { $languageUtility = $this->objectManager->create('Frohland\\Ezqueries\\Utility\\LanguageUtility'); $types = $columnTypes; $config = explode('-->', $columnConfiguration); array_pop($config); foreach ($config as $conf) { $confColumn = trim(substr($conf, 0, strpos($conf, '<--'))); $confValues = trim(substr($conf, strpos($conf, '<--') + 3, strlen($conf) - (strpos($conf, '<--') + 3))); $confValues = explode(';', $confValues); $confValue = array_shift($confValues); $confValue = trim(substr($confValue, strpos($confValue, ':') + 1, strlen($confValue) - (strpos($confValue, ':') + 1))); if ($types[$confColumn]['type'] == 'varchar' || $types[$confColumn]['type'] == 'text' || $types[$confColumn]['type'] == 'boolean') { $types[$confColumn]['render'] = $confValue; } if ($types[$confColumn]['type'] == 'int' || $types[$confColumn]['type'] == 'numeric') { $types[$confColumn]['numberformat'] = $confValue; $types[$confColumn]['decimals'] = intval($confValue[0]); if ($confValue[1] == 'x') { $types[$confColumn]['dec_point'] = ''; } else { if ($confValue[1] == '_') { $types[$confColumn]['dec_point'] = ' '; } else { $types[$confColumn]['dec_point'] = $confValue[1]; } } if ($confValue[2] == 'x') { $types[$confColumn]['thousands_sep'] = ''; } else { if ($confValue[2] == '_') { $types[$confColumn]['thousands_sep'] = ' '; } else { $types[$confColumn]['thousands_sep'] = $confValue[2]; } } } if ($types[$confColumn]['type'] == 'date') { $types[$confColumn]['dateformat'] = $confValue; } if ($types[$confColumn]['type'] == 'year') { $types[$confColumn]['yearformat'] = $confValue; } if (!isset($types[$confColumn]['type'])) { $types[$confColumn]['type'] = $confValue; } foreach ($confValues as $additionalConfig) { $additionalConfigName = trim(substr($additionalConfig, 0, strpos($additionalConfig, ':'))); $additionalConfigValue = trim(substr($additionalConfig, strpos($additionalConfig, ':') + 1, strlen($additionalConfig) - (strpos($additionalConfig, ':') + 1))); if ($additionalConfigValue !== '') { $additionalConfigValue = $languageUtility->translateValue($additionalConfigValue, TRUE); $types[$confColumn][$additionalConfigName] = $additionalConfigValue; } } } return $types; }
/** * Get the typo3-supported locale options * * @return array An array of language objects */ public function getLocales() { $localeArray = array(); $locales = $this->objectManager->get('TYPO3\\CMS\\Core\\Localization\\Locales'); $languages = $locales->getLanguages(); foreach ($languages as $locale => $language) { // No language pack for English if ($locale != 'default') { $languageObject = $this->objectManager->create('SJBR\\StaticInfoTables\\Domain\\Model\\Language'); $languageObject->setCollatingLocale($locale); $localizedLanguage = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('lang_' . $locale, $this->extensionName); $label = ($localizedLanguage ? $localizedLanguage : $language) . ' (' . $locale . ')'; $languageObject->setNameEn($label); $localeArray[$label] = $languageObject; } } ksort($localeArray); return $localeArray; }
/** * Instanciates a registered administration module. * * @param string $moduleName Administration module name * @return \ApacheSolrForTypo3\Solr\Backend\SolrModule\AdministrationModuleInterface Instance of the requested administration module * @throws \InvalidArgumentException if $moduleName is not a registered administration module * @throws \RuntimeException if the class registered for $moduleName is not an implementation of \ApacheSolrForTypo3\Solr\Backend\SolrModule\ModuleInterface */ public function getModule($moduleName) { $this->validateModuleIsRegistered($moduleName); $module = $this->objectManager->create($this->getModuleControllerClassName($moduleName)); $module->setExtensionKey(self::$modules[$moduleName]['extensionKey']); if (!$module instanceof AdministrationModuleInterface) { throw new \RuntimeException('Class ' . self::$modules[$moduleName] . ' must implement interface \\ApacheSolrForTypo3\\Solr\\Backend\\Module\\ModuleInterface', 1360373784); } return $module; }
/** * @param array $recipient recipient of the email in the format array('*****@*****.**' => 'Recipient Name') * @param array $sender sender of the email in the format array('*****@*****.**' => 'Sender Name') * @param string $subject subject of the email * @param string $templateName template name (UpperCamelCase) * @param array $variables variables to be passed to the Fluid view * @return boolean TRUE on success, otherwise false */ protected function sendTemplateEmail(array $recipient, array $sender, $subject, $templateName, array $variables = array()) { $emailView = $this->objectManager->create('TYPO3\\CMS\\Fluid\\View\\StandaloneView'); $emailView->setFormat('html'); $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $templateRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']); $templatePathAndFilename = $templateRootPath . '/Email/' . $templateName; $emailView->setTemplatePathAndFilename($templatePathAndFilename); $emailView->assignMultiple($variables); $emailBody = $emailView->render(); $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_mail_Message'); $message->setTo($recipient)->setFrom($sender)->setSubject($subject); // Plain text example #$message->setBody($emailBody, 'text/plain'); // HTML Email $message->setBody($emailBody, 'text/html'); $message->send(); return $message->isSent(); }
private function checkEmail($email) { $valid = true; if (strlen($email) == 0) { //echo 'Ein error ist aufgertererten.<br />'; $valid = false; $this->addError('Sie müssen eine gültige Mailadresse eingeben', 1415260669); } else { /** @var $validator \TYPO3\CMS\Extbase\Validation\Validator\EmailAddressValidator */ $validator = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Validation\\Validator\\EmailAddressValidator'); $valid = $validator->isValid($email); if (!$valid) { $valid = false; $result = $validator->getErrors(); $errors[] = $result[0]->getMessage(); $this->addError($result[0]->getMessage(), 1415260302); } } return $valid; }
/** * Returns all objects of this repository. * * @return array */ public function findAll() { if (!count($this->languages)) { $languages = $this->locales->getLanguages(); array_shift($languages); foreach ($languages as $locale => $language) { $label = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:setup/mod/locallang.xml:lang_' . $locale)); if ($label === '') { $label = htmlspecialchars($language); } $this->languages[$locale] = $this->objectManager->create('TYPO3\\CMS\\Lang\\Domain\\Model\\Language', $locale, $label, in_array($locale, $this->selectedLanguages)); } usort($this->languages, function ($a, $b) { /** @var $a \TYPO3\CMS\Lang\Domain\Model\Language */ /** @var $b \TYPO3\CMS\Lang\Domain\Model\Language */ if ($a->getLanguage() == $b->getLanguage()) { return 0; } return $a->getLanguage() < $b->getLanguage() ? -1 : 1; }); } return $this->languages; }
/** * Generate value * * @param string $column Name of the column where to insert the value * @param array $record The record * @param array $columnTypes Column types * @param array $search Search arguments * @param UriBuilder $uriBuilder UriBuilder * @param \Frohland\Ezqueries\Utility\TemplateUtility $templateUtility TemplateUtility * @param \Frohland\Ezqueries\Domain\Repository\RecordManagementRepository $recordManagementRepository RecordManagementRepository * @param array $arguments Arguments * @return string $code */ public function generateValue($column, $record, $columnTypes, $search, $uriBuilder, $templateUtility = NULL, $recordManagementRepository = NULL, $arguments = NULL) { $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $conversionUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\ConversionUtility'); $urlUtility = $this->objectManager->create('Frohland\\Ezqueries\\Utility\\URLUtility', $uriBuilder); if ($templateUtility == NULL) { $templateUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\TemplateUtility'); } $languageUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\LanguageUtility'); $code = ''; // Value settings if (isset($columnTypes[$column]['value'])) { $value = $columnTypes[$column]['value']; if (!isset($columnTypes[$column]['valueType'])) { $value = $record[$value]; } if (isset($columnTypes[$column]['valueFunction'])) { if ($columnTypes[$column]['valueFunction'] == 'convertUmlaute') { $search = explode(",", "ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ë,ï,ÿ,â,ê,î,ô,û,å,e,i,ø,u"); $replace = explode(",", "c,ae,oe,a,e,i,o,u,a,e,i,o,u,e,i,y,a,e,i,o,u,a,e,i,o,u"); $value = str_replace($search, $replace, $value); $search = array('ä', 'Ä', 'ö', 'Ö', 'ü', 'Ü', 'ß', ' '); $replace = array('ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss', ''); $value = str_replace($search, $replace, $value); $value = preg_replace('([^a-z^A-Z])', '_', $value); } if ($columnTypes[$column]['valueFunction'] == 'htmlentities') { $value = htmlentities($value); } if ($columnTypes[$column]['valueFunction'] == 'htmlspecialchars') { $value = htmlspecialchars($value); } if ($columnTypes[$column]['valueFunction'] == 'uppercase') { $value = mb_strtoupper($value); } } } else { if (isset($columnTypes[$column]['valueSQL'])) { $data = array(); foreach ($record as $recordColumn => $recordValue) { if ($columnTypes[$recordColumn]['type'] != 'numeric' && $columnTypes[$recordColumn]['type'] != 'int' && $columnTypes[$recordColumn]['type'] != 'boolean') { $data[$recordColumn]['value'] = $recordValue; $data[$recordColumn]['type'] = 'text'; } else { $data[$recordColumn]['value'] = $recordValue; $data[$recordColumn]['type'] = 'numeric'; } } $sqlQuery = $templateUtility->fillMarkersInSQLStatement($columnTypes[$column]['valueSQL'], $arguments, $data, $recordManagementRepository); $records = $recordManagementRepository->getRecordsBySQLQuery($sqlQuery); if ($records !== FALSE) { $value = $records[0][0]; } } else { if (isset($columnTypes[$column]['filter'])) { $data = array(); foreach ($record as $recordColumn => $recordValue) { if ($columnTypes[$recordColumn]['type'] != 'numeric' && $columnTypes[$recordColumn]['type'] != 'int' && $columnTypes[$recordColumn]['type'] != 'boolean') { $data[$recordColumn]['value'] = $recordValue; $data[$recordColumn]['type'] = 'text'; } else { $data[$recordColumn]['value'] = $recordValue; $data[$recordColumn]['type'] = 'numeric'; } } $value = $record[$column]; } else { $value = $record[$column]; } } } // Include hook to set a different value (return FALSE to hide value in template) if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['valueUtility']['hookSetValue'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['valueUtility']['hookSetValue'] as $_classRef) { $_procObj =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); $value = $_procObj->hookSetValue($column, $record, $columnTypes, $value, $arguments); } } if ($value !== FALSE && $value !== '') { $value = $languageUtility->translateValue($value); $originalValue = $value; // Highlight search strings in $value $searchString = $search[$column]['value']; $searchString = str_replace('\\"', '"', $searchString); $searchString = preg_quote($searchString, '/'); $searchArray = array('ä', 'Ä', 'ö', 'Ö', 'ü', 'Ü', 'ß'); $replaceArray = array('a', 'A', 'o', 'O', 'u', 'U', 'ss'); $searchStringConverted = str_replace($searchArray, $replaceArray, $searchString); if ($searchStringConverted == $searchString) { if ($searchString !== '' && $searchString !== NULL && $search['highlighting'] == 'true') { if (isset($columnTypes[$column]['searchHighlightWrap'])) { $wrapString = trim($columnTypes[$column]['searchHighlightWrap']); $wrapBefore = $languageUtility->translateValue(substr($wrapString, 0, strpos($wrapString, '|'))); $wrapAfter = $languageUtility->translateValue(substr($wrapString, strpos($wrapString, '|') + 1, strlen($wrapString) - strpos($wrapString, '|') - 1)); $value = preg_replace('/(' . $searchString . ')/iu', '' . $wrapBefore . '${1}' . $wrapAfter . '', $value); } else { $value = preg_replace('/(' . $searchString . ')/iu', '<span class="tx_ezqueries_search_mark">${1}</span>', $value); } } } else { if ($searchString !== '' && $searchString !== NULL && $search['highlighting'] == 'true') { if (isset($columnTypes[$column]['searchHighlightWrap'])) { $wrapString = trim($columnTypes[$column]['searchHighlightWrap']); $wrapBefore = $languageUtility->translateValue(substr($wrapString, 0, strpos($wrapString, '|'))); $wrapAfter = $languageUtility->translateValue(substr($wrapString, strpos($wrapString, '|') + 1, strlen($wrapString) - strpos($wrapString, '|') - 1)); $value = preg_replace('/(' . $searchString . ')/iu', '' . $wrapBefore . '${1}' . $wrapAfter . '', $value); $value = preg_replace('/(' . $searchStringConverted . ')/iu', '' . $wrapBefore . '${1}' . $wrapAfter . '', $value); } else { $value = preg_replace('/(' . $searchString . ')/iu', '<span class="tx_ezqueries_search_mark">${1}</span>', $value); $value = preg_replace('/(' . $searchStringConverted . ')/iu', '<span class="tx_ezqueries_search_mark">${1}</span>', $value); } } } switch ($columnTypes[$column]['type']) { // Boolean column case 'boolean': // Checkbox if ($columnTypes[$column]['render'] == 'checkbox') { if ($originalValue == 1) { $code .= '<input class="tx_ezqueries_checkbox" type="checkbox" value="' . $originalValue . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" checked="checked" onclick="return false;" />'; } else { $code .= '<input class="tx_ezqueries_checkbox" type="checkbox" value="' . $originalValue . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" onclick="return false;" />'; } } // Yes/No if ($columnTypes[$column]['render'] == 'yesno') { if ($originalValue == 1) { $code .= \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('template_bool_yes', 'ezqueries'); } else { $code .= \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('template_bool_no', 'ezqueries'); } } // Number if ($columnTypes[$column]['render'] == 'number') { $code .= $value; } // Number - value only if ($columnTypes[$column]['valueRender'] == 'number') { $code = $value; } break; // Varchar column // Varchar column case 'varchar': // Text if ($columnTypes[$column]['render'] == 'text' || $columnTypes[$column]['render'] == 'text_long' || $columnTypes[$column]['render'] == 'text_editor') { $code .= $value; } // Email if ($columnTypes[$column]['render'] == 'email') { $code .= '<a class="tx_ezqueries_data_link" href="mailto:' . $originalValue . '">' . $value . '</a>'; } // Link if ($columnTypes[$column]['render'] == 'link') { $code .= '<a class="tx_ezqueries_data_link" href="' . $originalValue . '" target="_blank" >' . $value . '</a>'; } // Image if ($columnTypes[$column]['render'] == 'image') { $altText = substr(strrchr($originalValue, '/'), 1); $code .= '<img class="tx_ezqueries_data_image" src="' . $originalValue . '" alt="' . $altText . '" />'; } // Document if ($columnTypes[$column]['render'] == 'document') { if (isset($columnTypes[$column]['linkText']) && $originalValue !== '' && $originalValue !== NULL) { $linkText = $columnTypes[$column]['linkText']; } else { $linkText = substr(strrchr($originalValue, '/'), 1); } $code .= '<a class="tx_ezqueries_data_link" href="' . $originalValue . '" target="_blank" >' . $linkText . '</a>'; } break; // Date column // Date column case 'date': $code .= $conversionUtility->convertDate($columnTypes[$column]['dateformat'], $originalValue); break; // Time column // Time column case 'time': if (isset($columnTypes[$column]['dateformat'])) { $code .= $conversionUtility->convertDate($columnTypes[$column]['dateformat'], $originalValue); } else { $code .= $value; } break; // Timestamp column // Timestamp column case 'timestamp': if (isset($columnTypes[$column]['dateformat'])) { $code .= $conversionUtility->convertDate($columnTypes[$column]['dateformat'], $originalValue); } else { $code .= $value; } break; // Int column // Int column case 'int': $code .= $conversionUtility->convertNumber($columnTypes[$column]['decimals'], $columnTypes[$column]['dec_point'], $columnTypes[$column]['thousands_sep'], $originalValue); break; // Numeric column // Numeric column case 'numeric': $code .= $conversionUtility->convertNumber($columnTypes[$column]['decimals'], $columnTypes[$column]['dec_point'], $columnTypes[$column]['thousands_sep'], $originalValue); break; // Default // Default default: $code .= $value; break; } $displayElement = TRUE; // Hook for setting display status of additional element (return FALSE to hide element) if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['valueUtility']['hookSetDisplayStatus'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['valueUtility']['hookSetDisplayStatus'] as $_classRef) { $_procObj =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); $displayElement = $_procObj->hookSetDisplayStatus($column, $record); } } // Link to another page with ezqueries plugin / Content from another page via AJAX container if (isset($columnTypes[$column]['linkTo']) || isset($columnTypes[$column]['contentFrom']) and $displayElement === TRUE) { $linkClass = ''; $contentClass = ''; $linkText = $code; $linkIcon = ''; $linkTarget = ''; $view = NULL; $loading = 'data-ezqueries-ajax-loading="true"'; // View if (isset($columnTypes[$column]['linkToView'])) { $view = $columnTypes[$column]['linkToView']; } if (isset($columnTypes[$column]['contentFromView'])) { $view = $columnTypes[$column]['contentFromView']; } // Link label if (isset($columnTypes[$column]['linkLabel'])) { $linkText = $columnTypes[$column]['linkLabel']; } // link icon if (isset($columnTypes[$column]['linkIcon'])) { $linkIcon = $columnTypes[$column]['linkIcon']; } // Link design if (isset($columnTypes[$column]['linkDesign'])) { if ($columnTypes[$column]['linkDesign'] == 'button') { $linkClass .= ' tx_ezqueries_link_button tx_ezqueries_custom_button '; } } // Link type if (isset($columnTypes[$column]['linkType'])) { if ($columnTypes[$column]['linkType'] == 'popup') { $linkClass .= ' tx_ezqueries_link_popup '; $redirect = 'false'; } else { if ($columnTypes[$column]['linkType'] == 'noRedirect') { $linkClass .= ''; $redirect = 'false'; } } } else { // Link target if (isset($columnTypes[$column]['linkTarget'])) { $linkTarget = ' data-ezqueries-link-target="' . $columnTypes[$column]['linkTarget'] . '"'; } else { $linkClass .= ' tx_ezqueries_link_redirect '; $redirect = 'false'; } } // Link parameters general if (isset($columnTypes[$column]['filter'])) { if (isset($columnTypes[$column]['filterColumn'])) { $filters[$columnTypes[$column]['filter']] = $record[$columnTypes[$column]['filterColumn']]; } else { if (isset($columnTypes[$column]['filterValue'])) { $filters[$columnTypes[$column]['filter']] = $columnTypes[$column]['filterValue']; } else { $filters[$columnTypes[$column]['filter']] = $originalValue; } } if (isset($columnTypes[$column]['filterType'])) { $filters['filterType'] = $columnTypes[$column]['filterType']; if ($filters['filterType'] == 'custom') { $customFilter = $templateUtility->fillMarkersInSQLStatement($columnTypes[$column]['filterValue'], $arguments, $data, $recordManagementRepository); $filters[$columnTypes[$column]['filter']] = $customFilter; } } $arguments = array('filters' => $filters); } else { $arguments = array(); } // Link parameters additional if (isset($columnTypes[$column]['parameters'])) { $parameters = explode(',', $columnTypes[$column]['parameters']); foreach ($parameters as $parameter) { $parameter = trim($parameter); $parameterName = trim(substr($parameter, 0, strpos($parameter, '='))); $parameterValue = trim(substr($parameter, strpos($parameter, '=') + 1, strlen($parameter) - strpos($parameter, '=') - 1)); if ($parameterValue[0] != '"') { $arguments[$parameterName] = $record[$parameterValue]; } else { $arguments[$parameterName] = trim(substr($parameterValue, 1, strpos($parameterValue, '"', 1) - 1)); } } } if (isset($columnTypes[$column]['primaryKey'])) { $parameters = explode(',', $columnTypes[$column]['primaryKey']); foreach ($parameters as $parameter) { $parameter = trim($parameter); $parameterName = trim(substr($parameter, 0, strpos($parameter, '='))); $parameterValue = trim(substr($parameter, strpos($parameter, '=') + 1, strlen($parameter) - strpos($parameter, '=') - 1)); if ($parameterValue[0] != '"') { $arguments['primaryKeys'][$parameterName] = $record[$parameterValue]; } else { $arguments['primaryKeys'][$parameterName] = trim(substr($parameterValue, 1, strpos($parameterValue, '"', 1) - 1)); } } } // Custom link class if (isset($columnTypes[$column]['linkClass'])) { $linkClass .= ' ' . $columnTypes[$column]['linkClass']; } // Custom content class if (isset($columnTypes[$column]['contentClass'])) { $contentClass .= ' ' . $columnTypes[$column]['contentClass']; } // Tooltip? if (isset($columnTypes[$column]['tooltip'])) { if ($columnTypes[$column]['tooltip'] == 'true') { $linkClass .= ' tooltip'; } } // Show loading status if (isset($columnTypes[$column]['loading'])) { $loading = 'data-ezqueries-ajax-loading="' . $columnTypes[$column]['loading'] . '"'; } // Generate content if (isset($columnTypes[$column]['linkTo'])) { if (!is_numeric($columnTypes[$column]['linkTo'])) { $sqlQuery = 'SELECT uid FROM pages WHERE subtitle="' . $columnTypes[$column]['linkTo'] . '"'; $records = $recordManagementRepository->getRecordsBySQLQueryTypo3($sqlQuery); $columnTypes[$column]['linkTo'] = $records[0]['uid']; } $url = $urlUtility->createURL($view, $arguments, $columnTypes[$column]['linkTo']); if ($columnTypes[$column]['linkType'] == 'url') { $code = $url; } else { $jsonConfig = ''; if ($columnTypes[$column]['linkType'] == 'JSON') { $jsonConfig = 'data-ezqueries-json="true" data-ezqueries-json-id="' . $columnTypes[$column]['jsonID'] . '"'; } if (isset($columnTypes[$column]['linkIcon'])) { $code = '<a class="tx_ezqueries_link ' . $linkClass . '" href="' . $url . '" ' . $linkTarget . ' data-title="' . $linkText . '" title="' . $linkText . '" ' . $jsonConfig . '><img src="' . $linkIcon . '" alt="' . $linkText . '" /></a>'; } else { $code = '<a class="tx_ezqueries_link ' . $linkClass . '" href="' . $url . '" ' . $linkTarget . ' data-title="' . $linkText . '" title="' . $linkText . '" ' . $jsonConfig . '>' . $linkText . '</a>'; } } } else { if (!is_numeric($columnTypes[$column]['contentFrom'])) { $sqlQuery = 'SELECT uid FROM pages WHERE subtitle="' . $columnTypes[$column]['contentFrom'] . '"'; $records = $recordManagementRepository->getRecordsBySQLQueryTypo3($sqlQuery); $columnTypes[$column]['contentFrom'] = $records[0]['uid']; } $url = $urlUtility->createURL($view, $arguments, $columnTypes[$column]['contentFrom']); $randomNumber = mt_rand(0, 1000); if (isset($columnTypes[$column]['contentType'])) { if ($columnTypes[$column]['contentType'] == 'replace') { $code = '<div id="tx_ezqueries_ajax_content_' . $randomNumber . '" class="tx_ezqueries_ajax_content ' . $contentClass . '" data-ezqueries-ajax-url="' . $url . '" data-ezqueries-replace="true" ' . $loading . ' data-pid="' . $columnTypes[$column]['contentFrom'] . '"></div>'; } if ($columnTypes[$column]['contentType'] == 'JSON') { $code = '<div id="tx_ezqueries_ajax_content_' . $randomNumber . '" class="tx_ezqueries_ajax_content ' . $contentClass . '" data-ezqueries-ajax-url="' . $url . '" data-ezqueries-json="true" data-ezqueries-json-id="' . $columnTypes[$column]['jsonID'] . '" ' . $loading . ' data-pid="' . $columnTypes[$column]['contentFrom'] . '"></div>'; } } else { $code = '<div id="tx_ezqueries_ajax_content_' . $randomNumber . '" class="tx_ezqueries_ajax_content ' . $contentClass . '" data-ezqueries-ajax-url="' . $url . '" ' . $loading . ' data-pid="' . $columnTypes[$column]['contentFrom'] . '"></div>'; } } } // Additional Value if (isset($columnTypes[$column]['additionalValue']) && $code != '') { $code .= ' ' . $columnTypes[$column]['additionalValue']; } // Wrap Value if (isset($columnTypes[$column]['wrap']) && trim($code) != '') { $wrapString = trim($columnTypes[$column]['wrap']); $wrapBefore = $languageUtility->translateValue(substr($wrapString, 0, strpos($wrapString, '|'))); $wrapAfter = $languageUtility->translateValue(substr($wrapString, strpos($wrapString, '|') + 1, strlen($wrapString) - strpos($wrapString, '|') - 1)); $code = $wrapBefore . $code . $wrapAfter; } } return $code; }
/** * Generate form element * * @param string $column Column name * @param string $value Value * @param array $columnTypes Column types * @param string $view View * @param array $record The record * @return string $code */ public function generateFormElement($column, $value, $columnTypes, $view, $record = NULL) { $code = ''; $validationAttr = ''; $primaryClass = ''; $conversionUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\ConversionUtility'); $valueUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\ValueUtility'); $languageUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\LanguageUtility'); $urlUtility = $this->objectManager->create('Frohland\\Ezqueries\\Utility\\URLUtility', $this->uriBuilder); $id = str_replace('.', '_', $column); $helpText = ''; $placeholder = $languageUtility->translateValue($columnTypes[$column]['placeholder']); // Set default value if (isset($columnTypes[$column]['defaultValue']) && ($value === '' || $value === NULL || $value === '0000-00-00' || $columnTypes[$column]['defaultValueMode'] === 'overwrite')) { $value = $columnTypes[$column]['defaultValue']; } // Set type - when additional type is set if (isset($columnTypes[$column]['additionalType'])) { $columnTypes[$column]['type'] = $columnTypes[$column]['additionalType']; } // UserID form element if (isset($columnTypes[$column]['userID'])) { $code .= '<div class="tx_ezqueries_input">'; $code .= '<input class="tx_ezqueries_input" id="' . $id . '" type="hidden" value="' . $columnTypes[$column]['userID'] . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" />'; $code .= '</div>'; return $code; } $readOnly = FALSE; // Hook for setting form value if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['formUtilty']['hookSetFormValue'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['formUtilty']['hookSetFormValue'] as $_classRef) { $_procObj =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); $value = $_procObj->hookSetFormValue($value, $column, $view, $record); } } // Hook for setting readonly status (return TRUE if the field status is readonly) if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['formUtilty']['hookSetReadOnlyStatus'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['formUtilty']['hookSetReadOnlyStatus'] as $_classRef) { $_procObj =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); $readOnly = $_procObj->hookSetReadOnlyStatus($column, $view, $record); } } // Readonly form element if ($readOnly == TRUE || $columnTypes[$column]['readOnly'] == 'true' || $columnTypes[$column]['edit_readOnly'] == 'true' && $view == 'edit' || $columnTypes[$column]['new_readOnly'] == 'true' && $view == 'new') { if ($columnTypes[$column]['primary_key'] == TRUE) { $primaryClass .= ' tx_ezqueries_input_primary_key '; } if ($columnTypes[$column]['render'] == 'text_long' || $columnTypes[$column]['render'] == 'text_editor') { if ($columnTypes[$column]['render'] == 'text_long') { $code .= '<div class="tx_ezqueries_input tx_ezqueries_disabled_element">'; $code .= '<textarea class="tx_ezqueries_textarea ' . $primaryClass . '" id="' . $id . '" readonly="readonly" disabled="disabled">' . $value . '</textarea>'; $value = htmlspecialchars($value); $code .= '<input class="tx_ezqueries_input_hidden" type="hidden" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; return $code; } else { $code .= '<div class="tx_ezqueries_input tx_ezqueries_disabled_element">'; $code .= '<div class="tx_ezqueries_textarea_editor_disabled" id="' . $id . '">' . $value . '</div>'; $code .= '</div>'; return $code; } } else { // Checkbox if ($columnTypes[$column]['render'] == 'checkbox') { $code .= '<div class="tx_ezqueries_checkbox_div tx_ezqueries_disabled_element">'; if ($value == 1) { $code .= '<input class="tx_ezqueries_checkbox" id="' . $id . '" type="checkbox" value="' . $value . '" checked="checked" readonly="readonly" disabled="disabled" />'; } else { $code .= '<input class="tx_ezqueries_checkbox" id="' . $id . '" type="checkbox" value="' . $value . '" readonly="readonly" disabled="disabled" />'; } $code .= '<input class="tx_ezqueries_checkbox_hidden" type="hidden" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" />'; $code .= '</div>'; return $code; } else { // Yes/No if ($columnTypes[$column]['render'] == 'yesno') { $code .= '<div class="tx_ezqueries_input tx_ezqueries_disabled_element">'; if ($value == 1) { $code .= '<input class="tx_ezqueries_input ' . $primaryClass . '" id="' . $id . '" type="text" value="' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_yes', 'ezqueries') . '" readonly="readonly" disabled="disabled" />'; } else { $code .= '<input class="tx_ezqueries_input ' . $primaryClass . '" id="' . $id . '" type="text" value="' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_no', 'ezqueries') . '" readonly="readonly" disabled="disabled" />'; } $code .= '<input class="tx_ezqueries_input_hidden" type="hidden" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" />'; $code .= '</div>'; return $code; } else { if (isset($columnTypes[$column]['dropDownList'])) { // Do nothing here } else { if ($columnTypes[$column]['type'] == 'date') { $convertedValue = $conversionUtility->convertDate($columnTypes[$column]['dateformat'], $value); $code .= '<div class="tx_ezqueries_input tx_ezqueries_disabled_element">'; $code .= '<input class="tx_ezqueries_input ' . $primaryClass . '" id="' . $id . '" type="text" value="' . $convertedValue . '" readonly="readonly" disabled="disabled" />'; $code .= '<input class="tx_ezqueries_input_hidden" type="hidden" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" />'; $code .= '</div>'; return $code; } else { $code .= '<div class="tx_ezqueries_input tx_ezqueries_disabled_element">'; $code .= '<input class="tx_ezqueries_input ' . $primaryClass . '" id="' . $id . '" type="text" value="' . $value . '" readonly="readonly" disabled="disabled" />'; $value = htmlspecialchars($value); $code .= '<input class="tx_ezqueries_input_hidden" type="hidden" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" />'; $code .= '</div>'; return $code; } } } } } } // Select form element if (isset($columnTypes[$column]['dropDownList'])) { $options = ''; if ($readOnly == TRUE || $columnTypes[$column]['readOnly'] == 'true' || $columnTypes[$column]['edit_readOnly'] == 'true' && $view == 'edit' || $columnTypes[$column]['new_readOnly'] == 'true' && $view == 'new') { $code .= '<input class="tx_ezqueries_input_hidden" type="hidden" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" />'; $code .= '<select id="' . $id . '" class="tx_ezqueries_select tx_ezqueries_disabled_element" size="1" disabled="disabled">'; } else { $code .= '<div class="tx_ezqueries_select_wrapper">'; if ($columnTypes[$column]['dropDownListFilter'] == 'true') { $code .= '<div class="tx_ezqueries_select_filter">'; $code .= '<input name="regexp" class="tx_ezqueries_select_filter_input" placeholder="' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('select_filter_label', 'ezqueries') . '" autocomplete="off" />'; $code .= '</div>'; } if ($columnTypes[$column]['not_null'] == TRUE || $columnTypes[$column]['required'] == 'true') { $code .= '<select id="' . $id . '" class="tx_ezqueries_select" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" size="1" data-rule-required="true">'; } else { $code .= '<select id="' . $id . '" class="tx_ezqueries_select" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" size="1">'; } } $isValueIncluded = FALSE; if ($columnTypes[$column]['not_null'] == FALSE && $columnTypes[$column]['required'] != 'true') { $options .= '<option value=""></option>'; } $items = explode('###', $columnTypes[$column]['dropDownList']); foreach ($items as $item) { if (strpos($item, '[')) { $itemName = trim(substr($item, 0, strpos($item, '['))); $itemValue = substr($item, strpos($item, '[') + 1, strpos($item, ']') - strpos($item, '[') - 1); } else { $itemName = trim($item); $itemValue = trim($item); } if ($itemValue == $value) { $isValueIncluded = TRUE; $options .= '<option selected="selected" value="' . $itemValue . '">' . $languageUtility->translateValue($itemName) . '</option>'; } else { $options .= '<option value="' . $itemValue . '">' . $languageUtility->translateValue($itemName) . '</option>'; } } if ($isValueIncluded == FALSE && !$columnTypes[$column]['noCurrent'] == 'true') { $options = '<option selected="selected" value="">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_select_choose', 'ezqueries') . '</option>' . $options; } $code .= $options; $code .= '</select></div>'; if ($columnTypes[$column]['readOnly'] == 'true' || $columnTypes[$column]['edit_readOnly'] == 'true' && $view == 'edit' || $columnTypes[$column]['new_readOnly'] == 'true' && $view == 'new') { return $code; } } else { // Set validation classes // Required if ($columnTypes[$column]['not_null'] == TRUE && $columnTypes[$column]['auto_increment'] == FALSE) { $validationAttr .= 'data-rule-required="true" '; } else { if ($columnTypes[$column]['required'] == 'true') { $validationAttr .= 'data-rule-required="true" '; } } // Max length $maxLength = -1; if (isset($columnTypes[$column]['maxLength'])) { $maxLength = $columnTypes[$column]['maxLength']; $validationAttr .= 'data-rule-maxlength="' . $columnTypes[$column]['maxLength'] . '" '; } else { if ($columnTypes[$column]['max_length'] != '-1') { $maxLength = $columnTypes[$column]['max_length']; $validationAttr .= 'data-rule-maxlength="' . $columnTypes[$column]['max_length'] . '" '; } } // Min length if (isset($columnTypes[$column]['minLength'])) { $validationAttr .= 'data-rule-minlength="' . $columnTypes[$column]['minLength'] . '" '; } // Range length if (isset($columnTypes[$column]['rangeLength'])) { $min = substr($columnTypes[$column]['rangeLength'], 0, strpos($columnTypes[$column]['rangeLength'], '-')); $max = substr($columnTypes[$column]['rangeLength'], strpos($columnTypes[$column]['rangeLength'], '-') + 1, strlen($columnTypes[$column]['rangeLength']) - strpos($columnTypes[$column]['rangeLength'], '-')); $validationAttr .= 'data-rule-rangelength="' . $min . ',' . $max . '" '; } // Max words if (isset($columnTypes[$column]['maxWords'])) { $validationAttr .= 'data-rule-maxWords="' . $columnTypes[$column]['maxWords'] . '" '; } // Min words if (isset($columnTypes[$column]['minWords'])) { $validationAttr .= 'data-rule-minWords="' . $columnTypes[$column]['minWords'] . '" '; } // Range words if (isset($columnTypes[$column]['rangeWords'])) { $min = substr($columnTypes[$column]['rangeWords'], 0, strpos($columnTypes[$column]['rangeWords'], '-')); $max = substr($columnTypes[$column]['rangeWords'], strpos($columnTypes[$column]['rangeWords'], '-') + 1, strlen($columnTypes[$column]['rangeWords']) - strpos($columnTypes[$column]['rangeWords'], '-')); $validationAttr .= 'data-rule-rangeWords="' . $min . ',' . $max . '" '; } // Max if (isset($columnTypes[$column]['max'])) { $validationAttr .= 'data-rule-max="' . $columnTypes[$column]['max'] . '" '; } // Min if (isset($columnTypes[$column]['min'])) { $validationAttr .= 'data-rule-min="' . $columnTypes[$column]['min'] . '" '; } // Range if (isset($columnTypes[$column]['range'])) { $min = substr($columnTypes[$column]['range'], 0, strpos($columnTypes[$column]['range'], '-')); $max = substr($columnTypes[$column]['range'], strpos($columnTypes[$column]['range'], '-') + 1, strlen($columnTypes[$column]['range']) - strpos($columnTypes[$column]['range'], '-')); if ($max == 'actYear') { $max = date("Y"); } if ($max == 'nextYear') { $max = intval(date("Y")) + 1; } $validationAttr .= 'data-rule-range="' . $min . ',' . $max . '" '; } // Email if ($columnTypes[$column]['render'] == 'email') { $validationAttr .= 'data-rule-email="true" '; } // URL if ($columnTypes[$column]['render'] == 'link') { $validationAttr .= 'data-rule-url="true" '; } // Digits if ($columnTypes[$column]['render'] == 'number' || $columnTypes[$column]['type'] == 'year') { $validationAttr .= 'data-rule-digits="true" '; } // Number if ($columnTypes[$column]['type'] == 'numeric') { $validationAttr .= 'data-rule-number="true" '; } // Integer if ($columnTypes[$column]['type'] == 'int') { $validationAttr .= 'data-rule-digits="true" '; } // Alphanumeric if (isset($columnTypes[$column]['alphanumeric'])) { $validationAttr .= 'data-rule-alphanumeric="true" '; } // Set primary key class if ($columnTypes[$column]['primary_key'] == TRUE) { $primaryClass .= ' tx_ezqueries_input_primary_key '; } // Varchar form element if ($columnTypes[$column]['type'] == 'varchar') { // Upload element if ($columnTypes[$column]['render'] == 'image' || $columnTypes[$column]['render'] == 'document') { $fileName = $value; $url = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath("ezqueries") . 'Classes/Utility/UploadUtility.php'; $code .= '<div class="' . $url . '">'; $code .= '<div class="tx_ezqueries_input">'; $code .= '<input class="' . $primaryClass . 'tx_ezqueries_input tx_ezqueries_input_upload tx_ezqueries_input_upload_' . $columnTypes[$column]['render'] . '" id="' . $id . '" type="text" value="' . $fileName . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; $code .= '<div class="tx_ezqueries_upload_button"> <noscript> <p>Please enable JavaScript to use file uploader.</p> </noscript> </div>'; $code .= '</div>'; } else { if ($columnTypes[$column]['render'] == 'text_long') { $code .= '<div class="tx_ezqueries_input">'; $code .= '<textarea class="' . $primaryClass . 'tx_ezqueries_textarea tx_ezqueries_textarea_noeditor" id="' . $id . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . '>' . $value . '</textarea>'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } else { if ($columnTypes[$column]['render'] == 'text_editor') { $randomNumber = mt_rand(0, 100); $code .= '<div class="tx_ezqueries_input" data-max-length="' . $maxLength . '">'; $code .= '<div class="tx_ezqueries_textarea_editor" id="' . $id . '_' . $randomNumber . '">' . $value . '</div>'; $code .= '<textarea style="display: none;" class="' . $primaryClass . 'tx_ezqueries_textarea tx_ezqueries_textarea_editor" id="' . $id . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . '>' . $value . '</textarea>'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } else { $code .= '<div class="tx_ezqueries_input">'; $value = htmlspecialchars($value); $code .= '<input class="' . $primaryClass . 'tx_ezqueries_input" id="' . $id . '" type="text" placeholder="' . $placeholder . '" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } } } } // Text form element if ($columnTypes[$column]['type'] == 'text') { if ($columnTypes[$column]['render'] == 'text_long') { $code .= '<div class="tx_ezqueries_input">'; $code .= '<textarea class="' . $primaryClass . 'tx_ezqueries_textarea tx_ezqueries_textarea_noeditor" id="' . $id . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . '>' . $value . '</textarea>'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } else { if ($columnTypes[$column]['render'] == 'text_editor') { $randomNumber = mt_rand(0, 100); $code .= '<div class="tx_ezqueries_input" data-max-length="' . $maxLength . '">'; $code .= '<div class="tx_ezqueries_textarea_editor" id="' . $id . '_' . $randomNumber . '">' . $value . '</div>'; $code .= '<textarea style="display: none;" class="' . $primaryClass . 'tx_ezqueries_textarea tx_ezqueries_textarea_editor" id="' . $id . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . '>' . $value . '</textarea>'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } else { $code .= '<div class="tx_ezqueries_input">'; $value = htmlspecialchars($value); $code .= '<input class="' . $primaryClass . 'tx_ezqueries_input" id="' . $id . '" type="text" placeholder="' . $placeholder . '" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } } } // Boolean form element if ($columnTypes[$column]['type'] == 'boolean') { // Checkbox if ($columnTypes[$column]['render'] == 'checkbox') { $code .= '<div class="tx_ezqueries_checkbox_div">'; if ($value == 1) { $code .= '<input class="tx_ezqueries_checkbox" id="' . $id . '" type="checkbox" value="' . $value . '" checked="checked" />'; } else { $code .= '<input class="tx_ezqueries_checkbox" id="' . $id . '" type="checkbox" value="' . $value . '" />'; } $code .= '<input class="tx_ezqueries_checkbox_hidden" type="hidden" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" />'; $code .= '</div>'; } // Yes/No select if ($columnTypes[$column]['render'] == 'yesno') { $code .= '<select class="tx_ezqueries_select" id="' . $id . '" size="1" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" >'; if ($value == 1) { $code .= '<option value="1" selected="selected">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_yes', 'ezqueries') . '</option>'; $code .= '<option value="0">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_no', 'ezqueries') . '</option>'; } else { $code .= '<option value="1">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_yes', 'ezqueries') . '</option>'; $code .= '<option value="0" selected="selected">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_no', 'ezqueries') . '</option>'; } $code .= '</select>'; } // Choose/Yes/No select if ($columnTypes[$column]['render'] == 'chooseyesno') { $code .= '<select class="tx_ezqueries_select" id="' . $id . '" size="1" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" data-rule-required="true">'; if ($value == '' || $value == NULL) { $code .= '<option selected="selected" value="">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_select_choose', 'ezqueries') . '</option>'; } if ($value == '1') { $code .= '<option selected="selected" value="1">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_yes', 'ezqueries') . '</option>'; } else { $code .= '<option value="1">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_yes', 'ezqueries') . '</option>'; } if ($value == '0') { $code .= '<option selected="selected" value="0">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_no', 'ezqueries') . '</option>'; } else { $code .= '<option value="0">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('form_bool_no', 'ezqueries') . '</option>'; } $code .= '</select>'; } // Number if ($columnTypes[$column]['render'] == 'number') { $code .= '<div class="tx_ezqueries_input">'; $code .= '<input class="' . $primaryClass . 'tx_ezqueries_input" id="' . $id . '" type="text" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } } // Int form element if ($columnTypes[$column]['type'] == 'int') { $code .= '<div class="tx_ezqueries_input">'; $code .= '<input class="' . $primaryClass . 'tx_ezqueries_input" id="' . $id . '" type="text" placeholder="' . $placeholder . '" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } // Numeric form element if ($columnTypes[$column]['type'] == 'numeric') { $convertedValue = $conversionUtility->convertNumber($columnTypes[$column]['decimals'], '.', '', $value); $code .= '<div class="tx_ezqueries_input">'; $code .= '<input class="' . $primaryClass . 'tx_ezqueries_input" id="' . $id . '" type="text" placeholder="' . $placeholder . '" value="' . $convertedValue . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } // Date form element if ($columnTypes[$column]['type'] == 'date') { $convertedValue = $conversionUtility->convertDate($columnTypes[$column]['dateformat'], $value); $code .= '<div class="tx_ezqueries_datepicker">'; $code .= '<div class="tx_ezqueries_input">'; $code .= '<input id="' . $id . '" class="' . $primaryClass . 'tx_ezqueries_input tx_ezqueries_input_readonly tx_ezqueries_input_date" type="text" placeholder="' . $placeholder . '" value="' . $convertedValue . '" data-ezqueries-dateformat="' . $conversionUtility->convertDateFormat($columnTypes[$column]['dateformat']) . '" name="' . $id . '" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; $code .= '<input class="tx_ezqueries_input_hidden tx_ezqueries_input_date_hidden" type="hidden" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" />'; $code .= '</div>'; } // Timestamp form element if ($columnTypes[$column]['type'] == 'timestamp') { $code .= '<div class="tx_ezqueries_input">'; $code .= '<input class="' . $primaryClass . 'tx_ezqueries_input" id="' . $id . '" type="text" placeholder="' . $placeholder . '" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } // Time form element if ($columnTypes[$column]['type'] == 'time') { $code .= '<div class="tx_ezqueries_input">'; $code .= '<input class="' . $primaryClass . 'tx_ezqueries_input" id="' . $id . '" type="text" placeholder="' . $placeholder . '" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } // Year form element if ($columnTypes[$column]['type'] == 'year') { $code .= '<div class="tx_ezqueries_input">'; $code .= '<input class="' . $primaryClass . 'tx_ezqueries_input" id="' . $id . '" type="text" placeholder="' . $placeholder . '" value="' . $value . '" name="tx_ezqueries_ezqueriesplugin[' . $column . ']" ' . $validationAttr . ' />'; $code .= '<div class="tx_ezqueries_image_delete"></div></div>'; } } // Help text if (isset($columnTypes[$column]['helpText'])) { $helpText = $columnTypes[$column]['helpText']; } if (isset($columnTypes[$column]['edit_helpText']) && $view == 'edit') { $helpText = $columnTypes[$column]['edit_helpText']; } if (isset($columnTypes[$column]['new_helpText']) && $view == 'new') { $helpText = $columnTypes[$column]['new_helpText']; } if (isset($columnTypes[$column]['helpText']) || isset($columnTypes[$column]['edit_helpText']) && $view == 'edit' || isset($columnTypes[$column]['new_helpText']) && $view == 'new') { if ($columnTypes[$column]['helpTextPosition'] == 'top') { $code = '<div class="tx_ezqueries_help_text tx_ezqueries_help_text_top">' . $helpText . '</div>' . $code; } else { if ($columnTypes[$column]['helpTextPosition'] == 'bottom') { $code .= '<div class="tx_ezqueries_help_text tx_ezqueries_help_text_bottom">' . $helpText . '</div>'; } else { if ($columnTypes[$column]['helpTextPosition'] == 'custom') { $code .= '<div class="tx_ezqueries_help_text_custom" data-ezqueries-helptext="' . $helpText . '"></div>'; } else { $code .= '<div class="tx_ezqueries_help_text_icon" data-ezqueries-helptext="' . $helpText . '"></div>'; } } } } return $code; }
/** * Search for markers in a code (template) and replace them with content * * @param string $code Any code * @return string $code */ public function fillMarkers($code) { // Markers $formValueMarkerStart = '<formelement'; $formValueMarkerEnd = '</formelement>'; $valueMarkerStart = '<value>'; $valueMarkerEnd = '</value>'; $sortMarkerStart = '<sort'; $sortMarkerEnd = '</sort>'; $submitMarkerStart = '<submit'; $submitMarkerEnd = '</submit>'; $detailMarkerStart = '<detail'; $detailMarkerEnd = '</detail>'; $editMarkerStart = '<edit'; $editMarkerEnd = '</edit>'; $previousMarkerStart = '<previous'; $previousMarkerEnd = '</previous>'; $nextMarkerStart = '<next'; $nextMarkerEnd = '</next>'; $closeMarkerStart = '<close'; $closeMarkerEnd = '</close>'; $deleteMarkerStart = '<delete'; $deleteMarkerEnd = '</delete>'; $newMarkerStart = '<new'; $newMarkerEnd = '</new>'; $searchMarkerStart = '<search'; $searchMarkerEnd = '</search>'; $listMarkerStart = '<list'; $listMarkerEnd = '</list>'; $parityMarker = '<parity />'; $indexMarker = '<index />'; $recordCountMarker = '<recordcount />'; $contentMarkerStart = '<content'; $contentMarkerEnd = '</content>'; $labelMarkerStart = '<columnlabel>'; $labelMarkerEnd = '</columnlabel>'; $loclabelMarkerStart = '<locallang>'; $loclabelMarkerEnd = '</locallang>'; $argumentMarkerStart = '<parameter>'; $argumentMarkerEnd = '</parameter>'; $pageBrowserMarker = '<pagebrowser />'; $conversionUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\ConversionUtility'); $valueUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\ValueUtility'); $languageUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\LanguageUtility'); $filterUtility = $this->objectManager->get('Frohland\\Ezqueries\\Utility\\FilterUtility'); $recordBrowser = $this->objectManager->get('Frohland\\Ezqueries\\ViewHelpers\\PageBrowserViewHelper'); $urlUtility = $this->objectManager->create('Frohland\\Ezqueries\\Utility\\URLUtility', $this->uriBuilder); $formUtility = $this->objectManager->create('Frohland\\Ezqueries\\Utility\\FormUtility', $this->uriBuilder); $this->data = array(); $this->primaryKeys = array(); if ($this->record) { $this->data = $this->record->getData(); $this->primaryKeys = $this->record->getPrimaryKeys(); } // Template type? switch ($this->templateType) { // #### Edit #### case 'edit': // Form value if (strpos($code, $formValueMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $formValueMarkerStart), strpos($code, $formValueMarkerEnd) + strlen($formValueMarkerEnd) - strpos($code, $formValueMarkerStart)); $formValueMarkerAttributes = $this->getMarkerAttributes($markerCode, $formValueMarkerStart); $formValueMarkerValue = $this->getMarkerValue($markerCode, $formValueMarkerEnd); $replaceCode = ''; // Form value without attributes if ($formValueMarkerAttributes['type'] == NULL) { if ($this->columnTypes[$formValueMarkerValue]['type'] !== 'additional' || isset($this->columnTypes[$formValueMarkerValue]['additionalType'])) { $replaceCode .= $formUtility->generateFormElement($formValueMarkerValue, $this->data[$formValueMarkerValue], $this->columnTypes, 'edit', $this->data); } else { $replaceCode = $valueUtility->generateValue($formValueMarkerValue, $this->data, $this->columnTypes, $this->search, $this->uriBuilder, $this, $this->recordManagementRepository, $this->arguments); } } else { // Form value with attributes if ($formValueMarkerAttributes['type'] == 'select') { $options = explode(',', $formValueMarkerAttributes['options']); $replaceCode .= '<select class="tx_ezqueries_select" id="' . $formValueMarkerValue . '" size="1" name="tx_ezqueries_ezqueriesplugin[' . $formValueMarkerValue . ']">'; $replaceCode .= '<option selected="selected">' . $this->data[$formValueMarkerValue] . '</option>'; foreach ($options as $option) { $replaceCode .= '<option>' . $option . '</option>'; } $replaceCode .= '</select>'; } } $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Edit submit if (strpos($code, $submitMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $submitMarkerStart), strpos($code, $submitMarkerEnd) + strlen($submitMarkerEnd) - strpos($code, $submitMarkerStart)); $submitMarkerAttributes = $this->getMarkerAttributes($markerCode, $submitMarkerStart); $submitMarkerValue = $this->getMarkerValue($markerCode, $submitMarkerEnd); $replaceCode = ''; $submitClass = ''; if ($submitMarkerAttributes['onSubmit'] == 'dontClosePopup') { $submitClass = 'tx_ezqueries_submit_popup'; } $arguments = array("primaryKeys" => $this->primaryKeys, "search" => $this->search, "filters" => $this->filters); $url = $urlUtility->createURL("update", $arguments); $replaceCode = '<input class="tx_ezqueries_submit tx_ezqueries_submit_edit ' . $submitClass . '" name="' . $url . '" type="submit" value="' . $languageUtility->translateValue($submitMarkerValue) . '" />'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Value if (strpos($code, $valueMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $valueMarkerStart), strpos($code, $valueMarkerEnd) + strlen($valueMarkerEnd) - strpos($code, $valueMarkerStart)); $valueMarkerValue = $this->getMarkerValue($markerCode, $valueMarkerEnd); $replaceCode = $valueUtility->generateValue($valueMarkerValue, $this->data, $this->columnTypes, $this->search, $this->uriBuilder, $this, $this->recordManagementRepository, $this->arguments); $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { break; } } } // #### New #### // #### New #### case 'new': // Form value if (strpos($code, $formValueMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $formValueMarkerStart), strpos($code, $formValueMarkerEnd) + strlen($formValueMarkerEnd) - strpos($code, $formValueMarkerStart)); $formValueMarkerAttributes = $this->getMarkerAttributes($markerCode, $formValueMarkerStart); $formValueMarkerValue = $this->getMarkerValue($markerCode, $formValueMarkerEnd); $replaceCode = ''; // Form value without attributes if ($formValueMarkerAttributes['type'] == NULL) { $replaceCode .= $formUtility->generateFormElement($formValueMarkerValue, $this->data[$formValueMarkerValue], $this->columnTypes, 'new', $this->data); } else { // Form value with attributes if ($formValueMarkerAttributes['type'] == 'select') { $options = explode(',', $formValueMarkerAttributes['options']); $replaceCode .= '<select class="tx_ezqueries_select" id="' . $formValueMarkerValue . '" size="1" name="tx_ezqueries_ezqueriesplugin[' . $formValueMarkerValue . ']">'; $replaceCode .= '<option selected="selected">' . $this->data[$formValueMarkerValue] . '</option>'; foreach ($options as $option) { $replaceCode .= '<option>' . $option . '</option>'; } $replaceCode .= '</select>'; } } $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // New submit if (strpos($code, $submitMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $submitMarkerStart), strpos($code, $submitMarkerEnd) + strlen($submitMarkerEnd) - strpos($code, $submitMarkerStart)); $submitMarkerAttributes = $this->getMarkerAttributes($markerCode, $submitMarkerStart); $submitMarkerValue = $this->getMarkerValue($markerCode, $submitMarkerEnd); $replaceCode = ''; $submitClass = ''; if ($submitMarkerAttributes['onSubmit'] == 'dontClosePopup') { $submitClass = 'tx_ezqueries_submit_popup'; } $arguments = array("search" => $this->search, "filters" => $this->filters); $url = $urlUtility->createURL("create", $arguments); $replaceCode = '<input class="tx_ezqueries_submit tx_ezqueries_submit_new ' . $submitClass . '" name="' . $url . '" type="submit" value="' . $languageUtility->translateValue($submitMarkerValue) . '" />'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Value if (strpos($code, $valueMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $valueMarkerStart), strpos($code, $valueMarkerEnd) + strlen($valueMarkerEnd) - strpos($code, $valueMarkerStart)); $valueMarkerValue = $this->getMarkerValue($markerCode, $valueMarkerEnd); $replaceCode = $valueUtility->generateValue($valueMarkerValue, $this->data, $this->columnTypes, $this->search, $this->uriBuilder, $this, $this->recordManagementRepository, $this->arguments); $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { break; } } } // #### Search #### // #### Search #### case 'search': // Form value if (strpos($code, $formValueMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $formValueMarkerStart), strpos($code, $formValueMarkerEnd) + strlen($formValueMarkerEnd) - strpos($code, $formValueMarkerStart)); $formValueMarkerAttributes = $this->getMarkerAttributes($markerCode, $formValueMarkerStart); $formValueMarkerValue = $this->getMarkerValue($markerCode, $formValueMarkerEnd); $replaceCode = ''; $replaceCode = $filterUtility->generateFilterElement($formValueMarkerValue, $this->columnTypes, $formValueMarkerAttributes['placeholder']); $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Search submit if (strpos($code, $submitMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $submitMarkerStart), strpos($code, $submitMarkerEnd) + strlen($submitMarkerEnd) - strpos($code, $submitMarkerStart)); $submitMarkerAttributes = $this->getMarkerAttributes($markerCode, $submitMarkerStart); $submitMarkerValue = $this->getMarkerValue($markerCode, $submitMarkerEnd); $replaceCode = ''; $submitClass = ''; if ($submitMarkerAttributes['onSubmit'] == 'dontClosePopup') { $submitClass = 'tx_ezqueries_submit_popup'; } $arguments = array("filters" => $this->filters); $url = $urlUtility->createURL("list", $arguments); $replaceCode = '<input class="tx_ezqueries_submit tx_ezqueries_submit_search ' . $submitClass . '" name="' . $url . '" type="submit" value="' . $languageUtility->translateValue($submitMarkerValue) . '" />'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Value if (strpos($code, $valueMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $valueMarkerStart), strpos($code, $valueMarkerEnd) + strlen($valueMarkerEnd) - strpos($code, $valueMarkerStart)); $valueMarkerValue = $this->getMarkerValue($markerCode, $valueMarkerEnd); $replaceCode = $valueUtility->generateValue($valueMarkerValue, $this->data, $this->columnTypes, $this->search, $this->uriBuilder, $this, $this->recordManagementRepository, $this->arguments); $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { break; } } } // #### Detail #### // #### Detail #### case 'detail': // Value if (strpos($code, $valueMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $valueMarkerStart), strpos($code, $valueMarkerEnd) + strlen($valueMarkerEnd) - strpos($code, $valueMarkerStart)); $valueMarkerValue = $this->getMarkerValue($markerCode, $valueMarkerEnd); $replaceCode = $valueUtility->generateValue($valueMarkerValue, $this->data, $this->columnTypes, $this->search, $this->uriBuilder, $this, $this->recordManagementRepository, $this->arguments); $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Content if (strpos($code, $contentMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $contentMarkerStart), strpos($code, $contentMarkerEnd) + strlen($contentMarkerEnd) - strpos($code, $contentMarkerStart)); $contentMarkerAttributes = $this->getMarkerAttributes($markerCode, $contentMarkerStart); $contentMarkerValue = $this->getMarkerValue($markerCode, $contentMarkerEnd); $replaceCode = ''; $filters = array(); if (isset($contentMarkerAttributes['filter'])) { $filters[$contentMarkerAttributes['filter']] = $contentMarkerAttributes['filterValue']; } $arguments = array('filters' => $filters); $url = $urlUtility->createURL(NULL, $arguments, $contentMarkerValue); $replaceCode = '<div class="tx_ezqueries_ajax_content" id="' . $url . '"></div>'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } } break; // #### List #### // #### List #### case 'list': // Value if (strpos($code, $valueMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $valueMarkerStart), strpos($code, $valueMarkerEnd) + strlen($valueMarkerEnd) - strpos($code, $valueMarkerStart)); $valueMarkerValue = $this->getMarkerValue($markerCode, $valueMarkerEnd); $replaceCode = $valueUtility->generateValue($valueMarkerValue, $this->data, $this->columnTypes, $this->search, $this->uriBuilder, $this, $this->recordManagementRepository, $this->arguments); $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // New link if (strpos($code, $newMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $newMarkerStart), strpos($code, $newMarkerEnd) + strlen($newMarkerEnd) - strpos($code, $newMarkerStart)); $newMarkerAttributes = $this->getMarkerAttributes($markerCode, $newMarkerStart); $newMarkerValue = $this->getMarkerValue($markerCode, $newMarkerEnd); $replaceCode = ''; $linkClass = ''; $linkTitle = ''; if ($newMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } if (isset($newMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($newMarkerAttributes['title']); } $arguments = array("search" => $this->search, "filters" => $this->filters); $url = $urlUtility->createURL("new", $arguments); $replaceCode = '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . ' tx_ezqueries_link_new tx_ezqueries_' . $this->templateType . '_link_new" href="' . $url . '" >' . $languageUtility->translateValue($newMarkerValue) . '</a>'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Sort if (strpos($code, $sortMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $sortMarkerStart), strpos($code, $sortMarkerEnd) + strlen($sortMarkerEnd) - strpos($code, $sortMarkerStart)); $sortMarkerAttributes = $this->getMarkerAttributes($markerCode, $sortMarkerStart); $sortMarkerValue = $this->getMarkerValue($markerCode, $sortMarkerEnd); $replaceCode = ''; $linkTitle = ''; $arguments = array("orderBy" => $sortMarkerValue, "order" => 'ASC', "search" => $this->search, "filters" => $this->filters); $imgClass = 'tx_ezqueries_image_order'; if ($sortMarkerValue == $this->orderBy) { if ($this->order == 'ASC') { $arguments = array("orderBy" => $sortMarkerValue, "order" => 'DESC', "search" => $this->search, "filters" => $this->filters); $imgClass = 'tx_ezqueries_image_order tx_ezqueries_image_order_asc'; } else { $arguments = array("orderBy" => $sortMarkerValue, "order" => 'ASC', "search" => $this->search, "filters" => $this->filters); $imgClass = 'tx_ezqueries_image_order tx_ezqueries_image_order_desc'; } } $url = $urlUtility->createURL("list", $arguments); if (isset($sortMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($sortMarkerAttributes['title']); } if ($sortMarkerAttributes['as'] == NULL) { $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link tx_ezqueries_link_sort tx_ezqueries_list_link_sort ' . $imgClass . '" href="' . $url . '"><span class="tx_ezqueries_link_sort_text">' . $sortMarkerValue . '</span></a>'; } else { $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link tx_ezqueries_link_sort tx_ezqueries_list_link_sort ' . $imgClass . '" href="' . $url . '"><span class="tx_ezqueries_link_sort_text">' . $languageUtility->translateValue($sortMarkerAttributes['as']) . '</span></a>'; } $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Parity if (strpos($code, $parityMarker) !== FALSE) { $markerCode = $parityMarker; if ($this->recordNumber % 2 == 0) { $replaceCode = 'odd'; } else { $replaceCode = 'even'; } $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Record count if (strpos($code, $recordCountMarker) !== FALSE) { $markerCode = $recordCountMarker; $replaceCode = $this->recordManagement->getConditions()->getRecordsCount(); $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Search link if (strpos($code, $searchMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $searchMarkerStart), strpos($code, $searchMarkerEnd) + strlen($searchMarkerEnd) - strpos($code, $searchMarkerStart)); $searchMarkerAttributes = $this->getMarkerAttributes($markerCode, $searchMarkerStart); $searchMarkerValue = $this->getMarkerValue($markerCode, $searchMarkerEnd); $replaceCode = ''; $linkClass = ''; $linkTitle = ''; if ($searchMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } if (isset($searchMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($searchMarkerAttributes['title']); } $arguments = array("filters" => $this->filters); $url = $urlUtility->createURL("search", $arguments); $replaceCode = '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . ' tx_ezqueries_link_search tx_ezqueries_' . $this->templateType . '_link_search" href="' . $url . '" >' . $languageUtility->translateValue($searchMarkerValue) . '</a>'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Index if (strpos($code, $indexMarker) !== FALSE) { $markerCode = $indexMarker; $replaceCode = $this->recordNumber; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Page browser if (strpos($code, $pageBrowserMarker) !== FALSE) { $markerCode = $pageBrowserMarker; $replaceCode = $recordBrowser->render($this->recordManagement, $this->uriBuilder); $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { break; } } } } } } } } } // Detail link if (strpos($code, $detailMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $detailMarkerStart), strpos($code, $detailMarkerEnd) + strlen($detailMarkerEnd) - strpos($code, $detailMarkerStart)); $detailMarkerAttributes = $this->getMarkerAttributes($markerCode, $detailMarkerStart); $detailMarkerValue = $this->getMarkerValue($markerCode, $detailMarkerEnd); $replaceCode = ''; $linkClass = ''; $linkTitle = ''; if ($detailMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } if (isset($detailMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($detailMarkerAttributes['title']); } if ($this->templateType == 'list') { $arguments = array("primaryKeys" => $this->primaryKeysArray[$this->recordNumber], "search" => $this->search, "orderBy" => $this->orderBy, "order" => $this->order, "filters" => $this->filters); } else { $arguments = array("primaryKeys" => $this->primaryKeys, "search" => $this->search, "orderBy" => $this->orderBy, "order" => $this->order, "filters" => $this->filters); } $url = $urlUtility->createURL("detail", $arguments); $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . ' tx_ezqueries_link_detail tx_ezqueries_' . $this->templateType . '_link_detail" href="' . $url . '" >' . $languageUtility->translateValue($detailMarkerValue) . '</a>'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Edit link if (strpos($code, $editMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $editMarkerStart), strpos($code, $editMarkerEnd) + strlen($editMarkerEnd) - strpos($code, $editMarkerStart)); $editMarkerAttributes = $this->getMarkerAttributes($markerCode, $editMarkerStart); $editMarkerValue = $this->getMarkerValue($markerCode, $editMarkerEnd); $replaceCode = ''; $linkClass = ''; $linkTitle = ''; if ($editMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } if (isset($editMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($editMarkerAttributes['title']); } if ($this->templateType == 'list') { $arguments = array("primaryKeys" => $this->primaryKeysArray[$this->recordNumber], "search" => $this->search, "orderBy" => $this->orderBy, "order" => $this->order, "filters" => $this->filters); } else { $arguments = array("primaryKeys" => $this->primaryKeys, "search" => $this->search, "orderBy" => $this->orderBy, "order" => $this->order, "filters" => $this->filters); } $url = $urlUtility->createURL("edit", $arguments); $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . ' tx_ezqueries_link_edit tx_ezqueries_' . $this->templateType . '_link_edit" href="' . $url . '" >' . $languageUtility->translateValue($editMarkerValue) . '</a>'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Delete link if (strpos($code, $deleteMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $deleteMarkerStart), strpos($code, $deleteMarkerEnd) + strlen($deleteMarkerEnd) - strpos($code, $deleteMarkerStart)); $deleteMarkerAttributes = $this->getMarkerAttributes($markerCode, $deleteMarkerStart); $deleteMarkerValue = $this->getMarkerValue($markerCode, $deleteMarkerEnd); $replaceCode = ''; $linkClass = ''; $linkTitle = ''; if ($deleteMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } if (isset($deleteMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($deleteMarkerAttributes['title']); } if ($this->templateType == 'list') { $arguments = array("primaryKeys" => $this->primaryKeysArray[$this->recordNumber], "search" => $this->search, "filters" => $this->filters); } else { $arguments = array("primaryKeys" => $this->primaryKeys, "search" => $this->search, "filters" => $this->filters); } $url = $urlUtility->createURL("delete", $arguments); $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . ' tx_ezqueries_link_delete tx_ezqueries_' . $this->templateType . '_link_delete" href="' . $url . '" >' . $languageUtility->translateValue($deleteMarkerValue) . '</a>'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } } } if ($this->templateType == 'detail' || $this->templateType == 'edit' || $this->templateType == 'new' || $this->templateType == 'search') { // Close link if (strpos($code, $closeMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $closeMarkerStart), strpos($code, $closeMarkerEnd) + strlen($closeMarkerEnd) - strpos($code, $closeMarkerStart)); $closeMarkerAttributes = $this->getMarkerAttributes($markerCode, $closeMarkerStart); $closeMarkerValue = $this->getMarkerValue($markerCode, $closeMarkerEnd); $replaceCode = ''; $linkClass = ''; $linkTitle = ''; if ($closeMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } if (isset($closeMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($closeMarkerAttributes['title']); } if ($this->templateType == 'detail' || $this->templateType == 'edit') { $arguments = array("search" => $this->search, "orderBy" => $this->orderBy, "order" => $this->order, "filters" => $this->filters); } else { $arguments = array("search" => $this->search, "filters" => $this->filters); } $url = $urlUtility->createURL("list", $arguments); $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . ' tx_ezqueries_link_' . $this->templateType . ' tx_ezqueries_link_abort" href="' . $url . '" >' . $languageUtility->translateValue($closeMarkerValue) . '</a>'; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } } if ($this->templateType == 'detail' || $this->templateType == 'edit') { // Previous link if (strpos($code, $previousMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $previousMarkerStart), strpos($code, $previousMarkerEnd) + strlen($previousMarkerEnd) - strpos($code, $previousMarkerStart)); $previousMarkerAttributes = $this->getMarkerAttributes($markerCode, $previousMarkerStart); $previousMarkerValue = $this->getMarkerValue($markerCode, $previousMarkerEnd); $replaceCode = ''; $linkClass = ''; $linkTitle = ''; if ($previousMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } if (isset($previousMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($previousMarkerAttributes['title']); } if ($this->recordPosition != 0) { $arguments = array("primaryKeys" => $this->primaryKeysArray[$this->recordPosition - 1], "search" => $this->search, "orderBy" => $this->orderBy, "order" => $this->order, "filters" => $this->filters); $url = $urlUtility->createURL($this->templateType, $arguments); $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . ' tx_ezqueries_link_' . $this->templateType . '" href="' . $url . '">' . $languageUtility->translateValue($previousMarkerValue) . '</a>'; } $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } else { // Next link if (strpos($code, $nextMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $nextMarkerStart), strpos($code, $nextMarkerEnd) + strlen($nextMarkerEnd) - strpos($code, $nextMarkerStart)); $nextMarkerAttributes = $this->getMarkerAttributes($markerCode, $nextMarkerStart); $nextMarkerValue = $this->getMarkerValue($markerCode, $nextMarkerEnd); $replaceCode = ''; $linkClass = ''; $linkTitle = ''; if ($nextMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } if (isset($nextMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($nextMarkerAttributes['title']); } if ($this->recordPosition < count($this->primaryKeysArray) - 1) { $arguments = array("primaryKeys" => $this->primaryKeysArray[$this->recordPosition + 1], "search" => $this->search, "orderBy" => $this->orderBy, "order" => $this->order, "filters" => $this->filters); $url = $urlUtility->createURL($this->templateType, $arguments); $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . ' tx_ezqueries_link_' . $this->templateType . '" href="' . $url . '">' . $languageUtility->translateValue($nextMarkerValue) . '</a>'; } $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } } } // Labels if (strpos($code, $labelMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $labelMarkerStart), strpos($code, $labelMarkerEnd) + strlen($labelMarkerEnd) - strpos($code, $labelMarkerStart)); $labelMarkerValue = $this->getMarkerValue($markerCode, $labelMarkerEnd); $replaceCode = '<label for="' . str_replace('.', '_', $labelMarkerValue) . '">' . $this->selectedColumns[$labelMarkerValue]['columnName']; if (($this->columnTypes[$labelMarkerValue]['not_null'] == TRUE || $this->columnTypes[$labelMarkerValue]['required'] == 'true') && ($this->templateType == 'edit' || $this->templateType == 'new')) { $replaceCode .= '<span class="tx_ezqueries_required_mark"></span>'; } $replaceCode .= '</label>'; // Hook for setting a custom label (label, column, view) if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['templateUtilty']['hookSetCustomLabel'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ezqueries']['templateUtilty']['hookSetCustomLabel'] as $_classRef) { $_procObj =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); $replaceCode = $_procObj->hookSetCustomLabel($replaceCode, $labelMarkerValue, $this->templateType, $this->data); } } $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } if (strpos($code, $loclabelMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $loclabelMarkerStart), strpos($code, $loclabelMarkerEnd) + strlen($loclabelMarkerEnd) - strpos($code, $loclabelMarkerStart)); $labelMarkerValue = $this->getMarkerValue($markerCode, $loclabelMarkerEnd); $replaceCode = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($labelMarkerValue, 'ezqueries'); $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } // Arguments if (strpos($code, $argumentMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $argumentMarkerStart), strpos($code, $argumentMarkerEnd) + strlen($argumentMarkerEnd) - strpos($code, $argumentMarkerStart)); $argumentMarkerValue = $this->getMarkerValue($markerCode, $argumentMarkerEnd); $replaceCode = $this->arguments[$argumentMarkerValue]; $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } // List link if (strpos($code, $listMarkerStart) !== FALSE) { $markerCode = substr($code, strpos($code, $listMarkerStart), strpos($code, $listMarkerEnd) + strlen($listMarkerEnd) - strpos($code, $listMarkerStart)); $listMarkerAttributes = $this->getMarkerAttributes($markerCode, $listMarkerStart); $listMarkerValue = $this->getMarkerValue($markerCode, $listMarkerEnd); $linkClass = ''; $linkTitle = ''; if (isset($listMarkerAttributes['title'])) { $linkTitle = $languageUtility->translateValue($listMarkerAttributes['title']); } if (isset($listMarkerAttributes['linkTo'])) { $page = $listMarkerAttributes['linkTo']; $redirect = 'true'; // Link type if (isset($listMarkerAttributes['type'])) { if ($listMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } } // Redirect if (isset($listMarkerAttributes['redirect'])) { $redirect = $listMarkerAttributes['redirect']; } if ($redirect == 'true') { $linkClass .= ' tx_ezqueries_link_redirect '; } // Filter column if (isset($listMarkerAttributes['filter'])) { if (isset($listMarkerAttributes['filterColumn'])) { $filters[$listMarkerAttributes['filter']] = $this->data[$listMarkerAttributes['filterColumn']]; } else { $filters[$listMarkerAttributes['filter']] = $this->data[$listMarkerAttributes['filter']]; } $arguments = array('filters' => $filters); } else { $arguments = array(); } $url = $urlUtility->createURL('list', $arguments, $page); $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . '" onclick="return ' . $redirect . ';" href="' . $url . '">' . $languageUtility->translateValue($listMarkerValue) . '</a>'; } else { // Link type if (isset($listMarkerAttributes['type'])) { if ($listMarkerAttributes['type'] == 'button') { $linkClass = 'tx_ezqueries_link_button'; } } $arguments = array("filters" => $this->filters); $url = $urlUtility->createURL('list', $arguments); $replaceCode .= '<a title="' . $linkTitle . '" class="tx_ezqueries_link ' . $linkClass . '" href="' . $url . '">' . $languageUtility->translateValue($listMarkerValue) . '</a>'; } $newCode = str_replace($markerCode, $replaceCode, $code); $code = $this->fillMarkers($newCode); return $code; } return $code; }