/** * @return array */ public function getCurrencies() { $return = array(); $arrAux = array(); \Contao\System::loadLanguageFile('currencies'); $this->loadCurrencies(); if (is_array($this->arrCurrencies)) { foreach ($this->arrCurrencies as $strKey => $strName) { $arrAux[$strKey] = isset($GLOBALS['TL_LANG']['CUR'][$strKey]) ? Utf8::toAscii($GLOBALS['TL_LANG']['CUR'][$strKey]) : $strName; } } asort($arrAux); if (is_array($arrAux)) { foreach (array_keys($arrAux) as $strKey) { $return[$strKey] = isset($GLOBALS['TL_LANG']['CUR'][$strKey]) ? $GLOBALS['TL_LANG']['CUR'][$strKey] : $this->arrCurrencies[$strKey]; } } // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['getCurrencies']) && is_array($GLOBALS['TL_HOOKS']['getCurrencies'])) { foreach ($GLOBALS['TL_HOOKS']['getCurrencies'] as $callback) { $return = static::importStatic($callback[0])->{$callback}[1]($return, $this->arrCurrencies); } } return $return; }
/** * Standardize a parameter (strip special characters and convert spaces) * * @param string $strString The input string * @param boolean $blnPreserveUppercase True to preserver uppercase characters * * @return string The converted string */ public static function standardize($strString, $blnPreserveUppercase = false) { $arrSearch = array('/[^a-zA-Z0-9 \\.\\&\\/_-]+/', '/[ \\.\\&\\/-]+/'); $arrReplace = array('', '-'); $strString = html_entity_decode($strString, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']); $strString = static::stripInsertTags($strString); $strString = Utf8::toAscii($strString); $strString = preg_replace($arrSearch, $arrReplace, $strString); if (is_numeric(substr($strString, 0, 1))) { $strString = 'id-' . $strString; } if (!$blnPreserveUppercase) { $strString = strtolower($strString); } return trim($strString, '-'); }
/** * Generate the filter panel and return it as HTML string * * @param integer $intFilterPanel * * @return string */ protected function filterMenu($intFilterPanel) { /** @var AttributeBagInterface $objSessionBag */ $objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend'); $fields = ''; $this->bid = 'tl_buttons_a'; $sortingFields = array(); $session = $objSessionBag->all(); $filter = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 4 ? $this->strTable . '_' . CURRENT_ID : $this->strTable; // Get the sorting fields foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'] as $k => $v) { if (intval($v['filter']) == $intFilterPanel) { $sortingFields[] = $k; } } // Return if there are no sorting fields if (empty($sortingFields)) { return ''; } // Set filter from user input if (\Input::post('FORM_SUBMIT') == 'tl_filters') { foreach ($sortingFields as $field) { if (\Input::post($field, true) != 'tl_' . $field) { $session['filter'][$filter][$field] = \Input::post($field, true); } else { unset($session['filter'][$filter][$field]); } } $objSessionBag->replace($session); } else { foreach ($sortingFields as $field) { if (isset($session['filter'][$filter][$field])) { // Sort by day if (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(5, 6))) { if ($session['filter'][$filter][$field] == '') { $this->procedure[] = $field . "=''"; } else { $objDate = new \Date($session['filter'][$filter][$field]); $this->procedure[] = $field . ' BETWEEN ? AND ?'; $this->values[] = $objDate->dayBegin; $this->values[] = $objDate->dayEnd; } } elseif (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(7, 8))) { if ($session['filter'][$filter][$field] == '') { $this->procedure[] = $field . "=''"; } else { $objDate = new \Date($session['filter'][$filter][$field]); $this->procedure[] = $field . ' BETWEEN ? AND ?'; $this->values[] = $objDate->monthBegin; $this->values[] = $objDate->monthEnd; } } elseif (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(9, 10))) { if ($session['filter'][$filter][$field] == '') { $this->procedure[] = $field . "=''"; } else { $objDate = new \Date($session['filter'][$filter][$field]); $this->procedure[] = $field . ' BETWEEN ? AND ?'; $this->values[] = $objDate->yearBegin; $this->values[] = $objDate->yearEnd; } } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['multiple']) { // CSV lists (see #2890) if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['csv'])) { $this->procedure[] = $this->Database->findInSet('?', $field, true); $this->values[] = $session['filter'][$filter][$field]; } else { $this->procedure[] = $field . ' LIKE ?'; $this->values[] = '%"' . $session['filter'][$filter][$field] . '"%'; } } else { $this->procedure[] = $field . '=?'; $this->values[] = $session['filter'][$filter][$field]; } } } } // Add sorting options foreach ($sortingFields as $cnt => $field) { $arrValues = array(); $arrProcedure = array(); if ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 4) { $arrProcedure[] = 'pid=?'; $arrValues[] = CURRENT_ID; } if (!empty($this->root) && is_array($this->root)) { $arrProcedure[] = "id IN(" . implode(',', array_map('intval', $this->root)) . ")"; } // Check for a static filter (see #4719) if (!empty($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']) && is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter'])) { foreach ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter'] as $fltr) { $arrProcedure[] = $fltr[0]; $arrValues[] = $fltr[1]; } } // Support empty ptable fields if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dynamicPtable']) { $arrProcedure[] = $this->ptable == 'tl_article' ? "(ptable=? OR ptable='')" : "ptable=?"; $arrValues[] = $this->ptable; } $objFields = $this->Database->prepare("SELECT DISTINCT " . $field . " FROM " . $this->strTable . (is_array($arrProcedure) && strlen($arrProcedure[0]) ? ' WHERE ' . implode(' AND ', $arrProcedure) : ''))->execute($arrValues); // Begin select menu $fields .= ' <select name="' . $field . '" id="' . $field . '" class="tl_select' . (isset($session['filter'][$filter][$field]) ? ' active' : '') . '"> <option value="tl_' . $field . '">' . (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['label']) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['label'][0] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['label']) . '</option> <option value="tl_' . $field . '">---</option>'; if ($objFields->numRows) { $options = $objFields->fetchEach($field); // Sort by day if (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(5, 6))) { $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'] == 6 ? rsort($options) : sort($options); foreach ($options as $k => $v) { if ($v == '') { $options[$v] = '-'; } else { $options[$v] = \Date::parse(\Config::get('dateFormat'), $v); } unset($options[$k]); } } elseif (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(7, 8))) { $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'] == 8 ? rsort($options) : sort($options); foreach ($options as $k => $v) { if ($v == '') { $options[$v] = '-'; } else { $options[$v] = date('Y-m', $v); $intMonth = date('m', $v) - 1; if (isset($GLOBALS['TL_LANG']['MONTHS'][$intMonth])) { $options[$v] = $GLOBALS['TL_LANG']['MONTHS'][$intMonth] . ' ' . date('Y', $v); } } unset($options[$k]); } } elseif (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(9, 10))) { $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'] == 10 ? rsort($options) : sort($options); foreach ($options as $k => $v) { if ($v == '') { $options[$v] = '-'; } else { $options[$v] = date('Y', $v); } unset($options[$k]); } } // Manual filter if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['multiple']) { $moptions = array(); // TODO: find a more effective solution foreach ($options as $option) { // CSV lists (see #2890) if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['csv'])) { $doptions = trimsplit($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['csv'], $option); } else { $doptions = deserialize($option); } if (is_array($doptions)) { $moptions = array_merge($moptions, $doptions); } } $options = $moptions; } $options = array_unique($options); $options_callback = array(); // Call the options_callback if ((is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback']) || is_callable($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback'])) && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['reference']) { if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback'])) { $strClass = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback'][0]; $strMethod = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback'][1]; $this->import($strClass); $options_callback = $this->{$strClass}->{$strMethod}($this); } elseif (is_callable($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback'])) { $options_callback = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback']($this); } // Sort options according to the keys of the callback array $options = array_intersect(array_keys($options_callback), $options); } $options_sorter = array(); $blnDate = in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(5, 6, 7, 8, 9, 10)); // Options foreach ($options as $kk => $vv) { $value = $blnDate ? $kk : $vv; // Options callback if (!empty($options_callback) && is_array($options_callback)) { $vv = $options_callback[$vv]; } elseif (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['foreignKey'])) { $key = explode('.', $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['foreignKey'], 2); $objParent = $this->Database->prepare("SELECT " . $key[1] . " AS value FROM " . $key[0] . " WHERE id=?")->limit(1)->execute($vv); if ($objParent->numRows) { $vv = $objParent->value; } } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['isBoolean'] || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['multiple']) { $vv = $vv != '' ? $GLOBALS['TL_LANG']['MSC']['yes'] : $GLOBALS['TL_LANG']['MSC']['no']; } elseif ($field == 'pid') { $this->loadDataContainer($this->ptable); $showFields = $GLOBALS['TL_DCA'][$this->ptable]['list']['label']['fields']; if (!$showFields[0]) { $showFields[0] = 'id'; } $objShowFields = $this->Database->prepare("SELECT " . $showFields[0] . " FROM " . $this->ptable . " WHERE id=?")->limit(1)->execute($vv); if ($objShowFields->numRows) { $vv = $objShowFields->{$showFields[0]}; } } $option_label = ''; // Use reference array if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['reference'])) { $option_label = is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['reference'][$vv]) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['reference'][$vv][0] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['reference'][$vv]; } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options'])) { $option_label = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options'][$vv]; } // No empty options allowed if (!strlen($option_label)) { $option_label = $vv ?: '-'; } $options_sorter[' <option value="' . specialchars($value) . '"' . (isset($session['filter'][$filter][$field]) && $value == $session['filter'][$filter][$field] ? ' selected="selected"' : '') . '>' . $option_label . '</option>'] = Utf8::toAscii($option_label); } // Sort by option values if (!$blnDate) { natcasesort($options_sorter); if (in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(2, 4, 12))) { $options_sorter = array_reverse($options_sorter, true); } } $fields .= "\n" . implode("\n", array_keys($options_sorter)); } // End select menu $fields .= ' </select> '; // Force a line-break after six elements (see #3777) if (($cnt + 1) % 6 == 0) { $fields .= '<br>'; } } return ' <div class="tl_filter tl_subpanel"> <strong>' . $GLOBALS['TL_LANG']['MSC']['filter'] . ':</strong> ' . $fields . ' </div>'; }
/** * Transliterate a UTF-8 value to ASCII. * * @param string $value * @return string */ public static function ascii($value) { return \Patchwork\Utf8::toAscii($value); }
/** * @covers Patchwork\Utf8::toAscii */ function testToASCII() { $this->assertSame('', u::toAscii('')); $this->assertSame('deja vu', u::toAscii('déjà vu')); }
/** * Return the available languages as array * * @param boolean $blnInstalledOnly If true, return only installed languages * * @return array An array of languages */ public static function getLanguages($blnInstalledOnly = false) { $return = array(); $languages = array(); $arrAux = array(); $langsNative = array(); static::loadLanguageFile('languages'); include __DIR__ . '/../../config/languages.php'; foreach ($languages as $strKey => $strName) { $arrAux[$strKey] = isset($GLOBALS['TL_LANG']['LNG'][$strKey]) ? Utf8::toAscii($GLOBALS['TL_LANG']['LNG'][$strKey]) : $strName; } asort($arrAux); $arrBackendLanguages = scan(__DIR__ . '/../../languages'); foreach (array_keys($arrAux) as $strKey) { if ($blnInstalledOnly && !in_array($strKey, $arrBackendLanguages)) { continue; } $return[$strKey] = isset($GLOBALS['TL_LANG']['LNG'][$strKey]) ? $GLOBALS['TL_LANG']['LNG'][$strKey] : $languages[$strKey]; if (isset($langsNative[$strKey]) && $langsNative[$strKey] != $return[$strKey]) { $return[$strKey] .= ' - ' . $langsNative[$strKey]; } } // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['getLanguages']) && is_array($GLOBALS['TL_HOOKS']['getLanguages'])) { foreach ($GLOBALS['TL_HOOKS']['getLanguages'] as $callback) { static::importStatic($callback[0])->{$callback[1]}($return, $languages, $langsNative, $blnInstalledOnly); } } return $return; }
/** * Transliterate a UTF-8 value to ASCII. * * @param string $value * @return string */ public static function ascii($value) { return Utf8::toAscii($value); }
/** * Save the current value * * @param mixed $varValue * * @throws \Exception */ protected function save($varValue) { if (\Input::post('FORM_SUBMIT') != $this->strTable) { return; } $arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]; // File names if ($this->strField == 'name') { if (!file_exists(TL_ROOT . '/' . $this->strPath . '/' . $this->varValue . $this->strExtension) || !$this->isMounted($this->strPath . '/' . $this->varValue . $this->strExtension) || $this->varValue === $varValue) { return; } $this->import('Files'); $varValue = Utf8::toAscii($varValue); // Trigger the save_callback if (is_array($arrData['save_callback'])) { foreach ($arrData['save_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $varValue = $this->{$callback[0]}->{$callback[1]}($varValue, $this); } elseif (is_callable($callback)) { $varValue = $callback($varValue, $this); } } } // The target exists if (strcasecmp($this->strPath . '/' . $this->varValue . $this->strExtension, $this->strPath . '/' . $varValue . $this->strExtension) !== 0 && file_exists(TL_ROOT . '/' . $this->strPath . '/' . $varValue . $this->strExtension)) { throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['fileExists'], $varValue)); } $arrImageTypes = trimsplit(',', strtolower(\Config::get('validImageTypes'))); // Remove potentially existing thumbnails (see #6641) if (in_array(substr($this->strExtension, 1), $arrImageTypes)) { foreach (glob(TL_ROOT . '/' . \System::getContainer()->getParameter('contao.image.target_path') . '/*/' . $this->varValue . '-*' . $this->strExtension) as $strThumbnail) { $this->Files->delete(str_replace(TL_ROOT . '/', '', $strThumbnail)); } } // Rename the file $this->Files->rename($this->strPath . '/' . $this->varValue . $this->strExtension, $this->strPath . '/' . $varValue . $this->strExtension); // New folders if (stristr($this->intId, '__new__') !== false) { // Update the database if ($this->blnIsDbAssisted && \Dbafs::shouldBeSynchronized($this->strPath . '/' . $varValue . $this->strExtension)) { $this->objActiveRecord = \Dbafs::addResource($this->strPath . '/' . $varValue . $this->strExtension); } $this->log('Folder "' . $this->strPath . '/' . $varValue . $this->strExtension . '" has been created', __METHOD__, TL_FILES); } else { // Update the database if ($this->blnIsDbAssisted) { $syncSource = \Dbafs::shouldBeSynchronized($this->strPath . '/' . $this->varValue . $this->strExtension); $syncTarget = \Dbafs::shouldBeSynchronized($this->strPath . '/' . $varValue . $this->strExtension); if ($syncSource && $syncTarget) { \Dbafs::moveResource($this->strPath . '/' . $this->varValue . $this->strExtension, $this->strPath . '/' . $varValue . $this->strExtension); } elseif ($syncSource) { \Dbafs::deleteResource($this->strPath . '/' . $this->varValue . $this->strExtension); } elseif ($syncTarget) { \Dbafs::addResource($this->strPath . '/' . $varValue . $this->strExtension); } } $this->log('File or folder "' . $this->strPath . '/' . $this->varValue . $this->strExtension . '" has been renamed to "' . $this->strPath . '/' . $varValue . $this->strExtension . '"', __METHOD__, TL_FILES); } // Update the symlinks if (is_link(TL_ROOT . '/web/' . $this->strPath . '/' . $this->varValue . $this->strExtension)) { $this->Files->delete('web/' . $this->strPath . '/' . $this->varValue . $this->strExtension); SymlinkUtil::symlink($this->strPath . '/' . $varValue . $this->strExtension, 'web/' . $this->strPath . '/' . $varValue . $this->strExtension, TL_ROOT); } // Set the new value so the input field can show it if (\Input::get('act') == 'editAll') { /** @var SessionInterface $objSession */ $objSession = \System::getContainer()->get('session'); $session = $objSession->all(); if (($index = array_search($this->strPath . '/' . $this->varValue . $this->strExtension, $session['CURRENT']['IDS'])) !== false) { $session['CURRENT']['IDS'][$index] = $this->strPath . '/' . $varValue . $this->strExtension; $objSession->replace($session); } } $this->varValue = $varValue; } elseif ($this->blnIsDbAssisted && $this->objActiveRecord !== null) { // Convert date formats into timestamps if ($varValue != '' && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim'))) { $objDate = new \Date($varValue, \Date::getFormatFromRgxp($arrData['eval']['rgxp'])); $varValue = $objDate->tstamp; } // Make sure unique fields are unique if ($arrData['eval']['unique'] && $varValue != '' && !$this->Database->isUniqueValue($this->strTable, $this->strField, $varValue, $this->objActiveRecord->id)) { throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $arrData['label'][0] ?: $this->strField)); } // Handle multi-select fields in "override all" mode if (\Input::get('act') == 'overrideAll' && ($arrData['inputType'] == 'checkbox' || $arrData['inputType'] == 'checkboxWizard') && $arrData['eval']['multiple']) { if ($this->objActiveRecord !== null) { $new = deserialize($varValue, true); $old = deserialize($this->objActiveRecord->{$this->strField}, true); switch (\Input::post($this->strInputName . '_update')) { case 'add': $varValue = array_values(array_unique(array_merge($old, $new))); break; case 'remove': $varValue = array_values(array_diff($old, $new)); break; case 'replace': $varValue = $new; break; } if (!is_array($varValue) || empty($varValue)) { $varValue = ''; } elseif (isset($arrData['eval']['csv'])) { $varValue = implode($arrData['eval']['csv'], $varValue); // see #2890 } else { $varValue = serialize($varValue); } } } // Convert arrays (see #2890) if ($arrData['eval']['multiple'] && isset($arrData['eval']['csv'])) { $varValue = implode($arrData['eval']['csv'], deserialize($varValue, true)); } // Trigger the save_callback if (is_array($arrData['save_callback'])) { foreach ($arrData['save_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $varValue = $this->{$callback[0]}->{$callback[1]}($varValue, $this); } elseif (is_callable($callback)) { $varValue = $callback($varValue, $this); } } } // Save the value if there was no error if (($varValue != '' || !$arrData['eval']['doNotSaveEmpty']) && ($this->varValue != $varValue || $arrData['eval']['alwaysSave'])) { // If the field is a fallback field, empty all other columns if ($arrData['eval']['fallback'] && $varValue != '') { $this->Database->execute("UPDATE " . $this->strTable . " SET " . $this->strField . "=''"); } // Set the correct empty value (see #6284, #6373) if ($varValue === '') { $varValue = \Widget::getEmptyValueByFieldType($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['sql']); } $this->objActiveRecord->{$this->strField} = $varValue; $this->objActiveRecord->save(); $this->blnCreateNewVersion = true; $this->varValue = deserialize($varValue); } } }
public function test_nul() { $str = "abc"; $this->assertEquals($str, u::toAscii($str)); }
/** * Transliterate to ASCII. * * @param string $value * @return RobClancy\String\String */ public function ascii() { $this->string = u::toAscii($this->string); return $this; }
/** * Export a theme * * @param DataContainer $dc */ public function exportTheme(DataContainer $dc) { // Get the theme meta data $objTheme = $this->Database->prepare("SELECT * FROM tl_theme WHERE id=?")->limit(1)->execute($dc->id); if ($objTheme->numRows < 1) { return; } // Romanize the name $strName = Utf8::toAscii($objTheme->name); $strName = strtolower(str_replace(' ', '_', $strName)); $strName = preg_replace('/[^A-Za-z0-9._-]/', '', $strName); $strName = basename($strName); // Create a new XML document $xml = new \DOMDocument('1.0', 'UTF-8'); $xml->formatOutput = true; // Root element $tables = $xml->createElement('tables'); $tables = $xml->appendChild($tables); // Add the tables $this->addTableTlTheme($xml, $tables, $objTheme); $this->addTableTlStyleSheet($xml, $tables, $objTheme); $this->addTableTlImageSize($xml, $tables, $objTheme); $this->addTableTlModule($xml, $tables, $objTheme); $this->addTableTlLayout($xml, $tables, $objTheme); // Generate the archive $strTmp = md5(uniqid(mt_rand(), true)); $objArchive = new \ZipWriter('system/tmp/' . $strTmp); // Add the files $this->addTableTlFiles($xml, $tables, $objTheme, $objArchive); // Add the template files $this->addTemplatesToArchive($objArchive, $objTheme->templates); // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['exportTheme']) && is_array($GLOBALS['TL_HOOKS']['exportTheme'])) { foreach ($GLOBALS['TL_HOOKS']['exportTheme'] as $callback) { \System::importStatic($callback[0])->{$callback[1]}($xml, $objArchive, $objTheme->id); } } // Add the XML document $objArchive->addString($xml->saveXML(), 'theme.xml'); // Close the archive $objArchive->close(); // Open the "save as …" dialogue $objFile = new \File('system/tmp/' . $strTmp); $objFile->sendToBrowser($strName . '.cto'); }
/** * Standardize a parameter (strip special characters and convert spaces) * * @param string $strString * @param boolean $blnPreserveUppercase * * @return string */ function standardize($strString, $blnPreserveUppercase = false) { @trigger_error('Using standardize() has been deprecated and will no longer work in Contao 5.0. Use StringUtil::standardize() instead.', E_USER_DEPRECATED); $arrSearch = array('/[^a-zA-Z0-9 \\.\\&\\/_-]+/', '/[ \\.\\&\\/-]+/'); $arrReplace = array('', '-'); $strString = html_entity_decode($strString, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']); $strString = strip_insert_tags($strString); $strString = Patchwork\Utf8::toAscii($strString); $strString = preg_replace($arrSearch, $arrReplace, $strString); if (is_numeric(substr($strString, 0, 1))) { $strString = 'id-' . $strString; } if (!$blnPreserveUppercase) { $strString = strtolower($strString); } return trim($strString, '-'); }
/** * Romanize a string * * @param string $str * * @return string * * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0. * Use Patchwork\Utf8::toAscii() instead. */ function utf8_romanize($str) { @trigger_error('Using utf8_romanize() has been deprecated and will no longer work in Contao 5.0. Use Patchwork\\Utf8::toAscii() instead.', E_USER_DEPRECATED); return Utf8::toAscii($str); }
/** * Generate a URL friendly "slug" from a given string. * * @param string $title * @param string $separator * * @return string * * @author Taylor Otwell */ protected static function slug($title, $separator = '-') { $title = Utf8::toAscii($title); // Convert all dashes/underscores into separator $flip = $separator === '-' ? '_' : '-'; $title = preg_replace('![' . preg_quote($flip) . ']+!u', $separator, $title); // Remove all characters that are not the separator, letters, numbers, or whitespace. $title = preg_replace('![^' . preg_quote($separator) . '\\pL\\pN\\s]+!u', '', mb_strtolower($title)); // Replace all separator characters and whitespace by a single separator $title = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $title); return trim($title, $separator); }