本文整理汇总了PHP中utf8_romanize函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_romanize函数的具体用法?PHP utf8_romanize怎么用?PHP utf8_romanize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_romanize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: entities_to_7bit
function entities_to_7bit($str)
{
require_once LEPTON_PATH . '/framework/summary.utf8.php';
// convert to UTF-8
$str = charset_to_utf8($str);
if (!utf8_check($str)) {
return $str;
}
// replace some specials
$str = utf8_stripspecials($str, '_');
// translate non-ASCII characters to ASCII
$str = utf8_romanize($str);
// missed some? - Many UTF-8-chars can't be romanized
// convert to HTML-entities, and replace entites by hex-numbers
$str = utf8_fast_umlauts_to_entities($str, false);
$str = str_replace(''', ''', $str);
// $str = preg_replace_callback('/&#([0-9]+);/', function($matches) {return "dechex($matches[1])";}, $str);
// $str = preg_replace_callback('/&#([0-9]+);/', function($matches) {return dechex($matches[1]);}, $str);
if (version_compare(PHP_VERSION, '5.3', '<')) {
$str = preg_replace('/&#([0-9]+);/e', "dechex('\$1')", $str);
} else {
$str = preg_replace_callback('/&#([0-9]+);/', create_function('$aMatches', 'return dechex($aMatches[1]);'), $str);
}
// maybe there are some > < ' " & left, replace them too
$str = str_replace(array('>', '<', ''', '\'', '"', '&'), '', $str);
$str = str_replace('&', '', $str);
return $str;
}
示例2: getCountriesByContinent
/**
* get Country-List
*/
public function getCountriesByContinent()
{
$return = array();
$countries = array();
$arrAux = array();
$arrTmp = array();
$this->loadLanguageFile('countries');
$this->loadLanguageFile('continents');
include TL_ROOT . '/system/config/countries.php';
include TL_ROOT . '/system/config/countriesByContinent.php';
foreach ($countriesByContinent as $strConKey => $arrCountries) {
$strConKeyTranslated = strlen($GLOBALS['TL_LANG']['CONTINENT'][$strConKey]) ? utf8_romanize($GLOBALS['TL_LANG']['CONTINENT'][$strConKey]) : $strConKey;
$arrAux[$strConKey] = $strConKeyTranslated;
foreach ($arrCountries as $key => $strCounntry) {
$arrTmp[$strConKeyTranslated][$key] = strlen($GLOBALS['TL_LANG']['CNT'][$key]) ? utf8_romanize($GLOBALS['TL_LANG']['CNT'][$key]) : $countries[$key];
}
}
ksort($arrTmp);
foreach ($arrTmp as $strConKey => $arrCountries) {
asort($arrCountries);
//get original continent key
$strOrgKey = array_search($strConKey, $arrAux);
$strConKeyTranslated = strlen($GLOBALS['TL_LANG']['CONTINENT'][$strOrgKey]) ? $GLOBALS['TL_LANG']['CONTINENT'][$strOrgKey] : $strConKey;
foreach ($arrCountries as $strKey => $strCountry) {
$return[$strConKeyTranslated][$strKey] = strlen($GLOBALS['TL_LANG']['CNT'][$strKey]) ? $GLOBALS['TL_LANG']['CNT'][$strKey] : $countries[$strKey];
}
}
$return[$GLOBALS['TL_LANG']['CONTINENT']['other']]['xx'] = strlen($GLOBALS['TL_LANG']['CNT']['xx']) ? $GLOBALS['TL_LANG']['CNT']['xx'] : 'No Country';
return $return;
}
示例3: compile
/**
* Generate module
*/
protected function compile()
{
$objTerm = $this->Database->execute("SELECT * FROM tl_glossary_term WHERE pid IN(" . implode(',', array_map('intval', $this->glossaries)) . ")" . " ORDER BY sortTerm");
if ($objTerm->numRows < 1) {
$this->Template->terms = array();
return;
}
global $objPage;
$this->import('String');
$arrTerms = array();
while ($objTerm->next()) {
$objTemp = new stdClass();
$key = utf8_strtoupper(utf8_substr($objTerm->sortTerm, 0, 1));
$objTemp->term = $objTerm->term;
$objTemp->anchor = 'gl' . utf8_romanize($key);
$objTemp->id = standardize($objTerm->term);
$objTemp->isParent = false;
$objTemp->isReference = false;
if ($objTerm->addReference) {
if ($objTerm->referenceType == 'parent') {
$objTemp->hasParent = true;
} elseif ($objTerm->referenceType == 'reference') {
$objTemp->isReference = true;
$objTemp->referenceTerm = false;
$objReference = $this->Database->prepare("SELECT `id`,`term` FROM `tl_glossary_term` WHERE `id`=?")->execute($objTerm->referenceTerm);
if ($objReference->next()) {
$objTemp->referenceTerm = $objReference->term;
$objTemp->referenceAnchor = standardize($objReference->term);
}
}
}
// Clean the RTE output
if ($objPage->outputFormat == 'xhtml') {
$objTerm->definition = $this->String->toXhtml($objTerm->definition);
} else {
$objTerm->definition = $this->String->toHtml5($objTerm->definition);
}
$objTemp->definition = $this->String->encodeEmail($objTerm->definition);
if ($objTerm->addExample) {
$objTemp->addExample = true;
$objTemp->example = $objPage->outputFormat == 'xhtml' ? $this->String->toXhtml($objTerm->example) : $this->String->toHtml5($objTerm->example);
} else {
$objTemp->addExample = false;
}
$objTemp->addImage = false;
// Add image
if ($objTerm->addImage && is_file(TL_ROOT . '/' . $objTerm->singleSRC)) {
$this->addImageToTemplate($objTemp, $objTerm->row());
}
$objTemp->enclosures = array();
// Add enclosures
if ($objTerm->addEnclosure) {
$this->addEnclosuresToTemplate($objTemp, $objTerm->row());
}
$arrTerms[$key][] = $objTemp;
}
$this->Template->terms = $arrTerms;
$this->Template->request = ampersand($this->Environment->request, true);
$this->Template->topLink = $GLOBALS['TL_LANG']['MSC']['backToTop'];
}
示例4: renderXml
public function renderXml()
{
$nameSuffix = str_replace(' ', '-', utf8_romanize(utf8_deaccent(ucfirst($this->_params['name']))));
XenForo_Application::autoload('Zend_Debug');
$this->setDownloadFileName('BBM_BbCode_' . $nameSuffix . '.xml');
return $this->_params['xml']->saveXml();
}
示例5: uploadTo
/**
* Check the uploaded files and move them to the target directory
* @param string
* @param string
* @return array
* @throws \Exception
*/
public function uploadTo($strTarget, $strKey)
{
if ($strTarget == '' || strpos($strTarget, '../') !== false) {
throw new \Exception("Invalid target path {$strTarget}");
}
if ($strKey == '') {
throw new \Exception('The key must not be empty');
}
$maxlength_kb = $this->getMaximumUploadSize();
$maxlength_kb_readable = $this->getReadableSize($maxlength_kb);
$arrUploaded = array();
$arrFiles = $this->getFilesFromGlobal($strKey);
foreach ($arrFiles as $file) {
// Romanize the filename
$file['name'] = strip_tags($file['name']);
$file['name'] = utf8_romanize($file['name']);
$file['name'] = str_replace('"', '', $file['name']);
// File was not uploaded
if (!is_uploaded_file($file['tmp_name'])) {
if ($file['error'] == 1 || $file['error'] == 2) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filesize'], $maxlength_kb_readable));
$this->log('File "' . $file['name'] . '" exceeds the maximum file size of ' . $maxlength_kb_readable, 'Uploader uploadTo()', TL_ERROR);
$this->blnHasError = true;
} elseif ($file['error'] == 3) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filepartial'], $file['name']));
$this->log('File "' . $file['name'] . '" was only partially uploaded', 'Uploader uploadTo()', TL_ERROR);
$this->blnHasError = true;
}
} elseif ($file['size'] > $maxlength_kb) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filesize'], $maxlength_kb_readable));
$this->log('File "' . $file['name'] . '" exceeds the maximum file size of ' . $maxlength_kb_readable, 'Uploader uploadTo()', TL_ERROR);
$this->blnHasError = true;
} else {
$pathinfo = pathinfo($file['name']);
$arrAllowedTypes = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['uploadTypes']));
// File type not allowed
if (!in_array(strtolower($pathinfo['extension']), $arrAllowedTypes)) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $pathinfo['extension']));
$this->log('File type "' . $pathinfo['extension'] . '" is not allowed to be uploaded (' . $file['name'] . ')', 'Uploader uploadTo()', TL_ERROR);
$this->blnHasError = true;
} else {
$this->import('Files');
$strNewFile = $strTarget . '/' . $file['name'];
// Set CHMOD and resize if neccessary
if ($this->Files->move_uploaded_file($file['tmp_name'], $strNewFile)) {
$this->Files->chmod($strNewFile, 0644);
$blnResized = $this->resizeUploadedImage($strNewFile, $file);
// Notify the user
if (!$blnResized) {
\Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['MSC']['fileUploaded'], $file['name']));
$this->log('File "' . $file['name'] . '" uploaded successfully', 'Uploader uploadTo()', TL_FILES);
}
$arrUploaded[] = $strNewFile;
}
}
}
}
return $arrUploaded;
}
示例6: saveCookieName
public function saveCookieName($strString, $ObjDataContainer)
{
$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 = utf8_romanize($strString);
$strString = preg_replace($arrSearch, $arrReplace, $strString);
return trim($strString, '-');
}
示例7: exportManager
/**
* Export a ZAD Send News manager to XML file.
* @param \DataContainer
*/
public function exportManager($dc)
{
// get the manager data
$manager = $this->Database->prepare("SELECT * FROM tl_zad_sendnews WHERE id=?")->execute($dc->id);
if ($manager->numRows < 1) {
// error, exit
return;
}
// create a new XML document
$xml = new \DOMDocument('1.0', 'UTF-8');
$xml->formatOutput = true;
// root element
$tables = $xml->createElement('tables');
$tables->setAttribute('version', '2.0');
$tables = $xml->appendChild($tables);
// add manager table
$this->exportTable('tl_zad_sendnews', $xml, $tables, $manager);
// add rules table
$rules = $this->Database->prepare("SELECT * FROM tl_zad_sendnews_rule WHERE pid=? ORDER BY sorting")->execute($manager->id);
$this->exportTable('tl_zad_sendnews_rule', $xml, $tables, $rules);
// add news_archive table
$news = $this->Database->prepare("SELECT id,title FROM tl_news_archive WHERE id=?")->execute($manager->news_archive);
$this->exportTable('tl_news_archive', $xml, $tables, $news);
// add user table
$user = $this->Database->prepare("SELECT id,username,name,email FROM tl_user WHERE id=?")->execute($manager->news_author);
$this->exportTable('tl_user', $xml, $tables, $user);
// create a zip archive
$tmp = md5(uniqid(mt_rand(), true));
$zip = new \ZipWriter('system/tmp/' . $tmp);
// add XML document
$zip->addString($xml->saveXML(), 'sendnews.xml');
// close archive
$zip->close();
// romanize the file name
$name = utf8_romanize($manager->name);
$name = strtolower(str_replace(' ', '_', $name));
$name = preg_replace('/[^A-Za-z0-9\\._-]/', '', $name);
$name = basename($name);
// open the "save as …" dialogue
$file = new \File('system/tmp/' . $tmp, true);
// send file
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . $name . '.zip"');
header('Content-Length: ' . $file->filesize);
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Expires: 0');
$fl = fopen(TL_ROOT . '/system/tmp/' . $tmp, 'rb');
fpassthru($fl);
fclose($fl);
exit;
}
示例8: slugify
/**
* Slugify a value.
*
* @param string $value Given value.
* @param string $separator Separator string.
*
* @return string
*/
private function slugify($value, $separator)
{
$arrSearch = array('/[^a-zA-Z0-9 \\.\\&\\/_-]+/', '/[ \\.\\&\\/-]+/');
$arrReplace = array('', $separator);
$value = html_entity_decode($value, ENT_QUOTES, $this->charset);
$value = strip_insert_tags($value);
$value = utf8_romanize($value);
$value = preg_replace($arrSearch, $arrReplace, $value);
if (!$this->preserveUppercase) {
$value = strtolower($value);
}
return trim($value, $separator);
}
示例9: compile
/**
* Generate module
*/
protected function compile()
{
$objTerm = $this->Database->execute("SELECT * FROM tl_glossary_term WHERE pid IN(" . implode(',', array_map('intval', $this->glossaries)) . ")" . " ORDER BY term");
if ($objTerm->numRows < 1) {
return;
}
$arrAnchor = array();
while ($objTerm->next()) {
$link = utf8_substr($objTerm->term, 0, 1);
$key = 'gl' . utf8_romanize($link);
$arrAnchor[$key] = $link;
}
$this->Template->request = ampersand($this->Environment->request, true);
$this->Template->anchors = $arrAnchor;
}
示例10: standardize
/**
* Standardize a parameter (strip special characters and convert spaces)
*
* @param string $strString
* @param boolean $blnPreserveUppercase
*
* @return string
*/
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 = strip_insert_tags($strString);
$strString = utf8_romanize($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, '-');
}
示例11: cleanID
function cleanID($raw_id)
{
$sepchar = "_";
$sepcharpat = '#\\' . $sepchar . '+#';
$id = trim((string) $raw_id);
$id = utf8_strtolower($id);
//alternative namespace seperator
$id = strtr($id, ';', ':');
$id = strtr($id, '/', $sepchar);
$id = utf8_romanize($id);
$id = utf8_deaccent($id, -1);
//remove specials
$id = utf8_stripspecials($id, $sepchar, '\\*');
$id = utf8_strip($id);
$id = preg_replace($sepcharpat, $sepchar, $id);
$id = preg_replace('#:+#', ':', $id);
$id = preg_replace('#:[:\\._\\-]+#', ':', $id);
return $id;
}
示例12: compile
/**
* Generate module
*/
protected function compile()
{
$objTerm = $this->objResult;
if ($objTerm->numRows < 1) {
return '';
}
$arrAnchor = array();
$arrLinks = array();
while ($objTerm->next()) {
$link = utf8_substr($objTerm->term, 0, 1);
$key = 'gl' . utf8_romanize($link);
$arrAnchor[$key] = $link;
$arrLinks[$key] = array('link' => $link);
if ($this->glossary_menu_filter) {
$href .= '&gl=' . $key;
$arrLinks[$key]['href'] = $this->addToUrl($href);
} else {
$arrLinks[$key]['href'] = ampersand($this->Environment->request, true) . '#' . $key;
}
}
$this->Template->request = ampersand($this->Environment->request, true);
$this->Template->anchors = $arrAnchor;
$this->Template->links = $arrLinks;
}
示例13: getCountriesList
/**
* Build up the list with all countries information and cache this information.
*
* Return all data from the cache.
*
* @return array|null
*
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public static function getCountriesList()
{
if (empty(self::$arrCountries)) {
$countries = array();
$arrTmp = array();
// Load the language files.
\System::loadLanguageFile('countries');
\System::loadLanguageFile('continents');
// Include all files with name.
require_once TL_ROOT . '/system/config/countries.php';
require_once TL_ROOT . '/system/config/countriesByContinent.php';
/** @var $countriesByContinent array */
foreach ($countriesByContinent as $strConKey => $arrCountries) {
// Add the main value.
$strParentName = strlen($GLOBALS['TL_LANG']['CONTINENT'][$strConKey]) ? utf8_romanize($GLOBALS['TL_LANG']['CONTINENT'][$strConKey]) : $strConKey;
// Add all countries.
foreach (array_keys($arrCountries) as $key) {
$arrTmp[$key] = array('name' => strlen($GLOBALS['TL_LANG']['CNT'][$key]) ? utf8_romanize($GLOBALS['TL_LANG']['CNT'][$key]) : $countries[$key], 'parent-name' => $strParentName, 'parent-short' => $strConKey);
}
}
self::$arrCountries = $arrTmp;
}
return self::$arrCountries;
}
示例14: _verifyUsername
/**
* Verification callback to check that a username is valid
*
* @param string Username
*
* @return bool
*/
protected function _verifyUsername(&$username)
{
if ($this->isUpdate() && $username === $this->getExisting('username')) {
return true;
// unchanged, always pass
}
// standardize white space in names
$username = preg_replace('/\\s+/u', ' ', $username);
try {
// if this matches, then \v isn't known (appears to be PCRE < 7.2) so don't strip
if (!preg_match('/\\v/', 'v')) {
$newName = preg_replace('/\\v+/u', ' ', $username);
if (is_string($newName)) {
$username = $newName;
}
}
} catch (Exception $e) {
}
$username = trim($username);
$usernameLength = utf8_strlen($username);
$minLength = $this->getOption(self::OPTION_USERNAME_LENGTH_MIN);
$maxLength = $this->getOption(self::OPTION_USERNAME_LENGTH_MAX);
if (!$this->getOption(self::OPTION_ADMIN_EDIT)) {
if ($minLength > 0 && $usernameLength < $minLength) {
$this->error(new XenForo_Phrase('please_enter_name_that_is_at_least_x_characters_long', array('count' => $minLength)), 'username');
return false;
}
if ($maxLength > 0 && $usernameLength > $maxLength) {
$this->error(new XenForo_Phrase('please_enter_name_that_is_at_most_x_characters_long', array('count' => $maxLength)), 'username');
return false;
}
$disallowedNames = $this->getOption(self::OPTION_USERNAME_DISALLOWED_NAMES);
if ($disallowedNames) {
foreach ($disallowedNames as $name) {
$name = trim($name);
if ($name === '') {
continue;
}
if (stripos($username, $name) !== false) {
$this->error(new XenForo_Phrase('please_enter_another_name_disallowed_words'), 'username');
return false;
}
}
}
$matchRegex = $this->getOption(self::OPTION_USERNAME_REGEX);
if ($matchRegex) {
$matchRegex = str_replace('#', '\\#', $matchRegex);
// escape delim only
if (!preg_match('#' . $matchRegex . '#i', $username)) {
$this->error(new XenForo_Phrase('please_enter_another_name_required_format'), 'username');
return false;
}
}
$censoredUserName = XenForo_Helper_String::censorString($username);
if ($censoredUserName !== $username) {
$this->error(new XenForo_Phrase('please_enter_name_that_does_not_contain_any_censored_words'), 'username');
return false;
}
}
// ignore check if unicode properties aren't compiled
try {
if (@preg_match("/\\p{C}/u", $username)) {
$this->error(new XenForo_Phrase('please_enter_name_without_using_control_characters'), 'username');
return false;
}
} catch (Exception $e) {
}
if (strpos($username, ',') !== false) {
$this->error(new XenForo_Phrase('please_enter_name_that_does_not_contain_comma'), 'username');
return false;
}
if (XenForo_Helper_Email::isEmailValid($username)) {
$this->error(new XenForo_Phrase('please_enter_name_that_does_not_resemble_an_email_address'), 'username');
return false;
}
$existingUser = $this->_getUserModel()->getUserByName($username);
if ($existingUser && $existingUser['user_id'] != $this->get('user_id')) {
$this->error(new XenForo_Phrase('usernames_must_be_unique'), 'username');
return false;
}
// compare against romanized name to help reduce confusable issues
$romanized = utf8_deaccent(utf8_romanize($username));
if ($romanized != $username) {
$existingUser = $this->_getUserModel()->getUserByName($romanized);
if ($existingUser && $existingUser['user_id'] != $this->get('user_id')) {
$this->error(new XenForo_Phrase('usernames_must_be_unique'), 'username');
return false;
}
}
return true;
}
示例15: save
/**
* Save the current value
* @param mixed
* @throws Exception
*/
protected function save($varValue)
{
if ($this->Input->post('FORM_SUBMIT') != $this->strTable || !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');
$arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField];
$varValue = utf8_romanize($varValue);
// Call save_callback
if (is_array($arrData['save_callback'])) {
foreach ($arrData['save_callback'] as $callback) {
$this->import($callback[0]);
$varValue = $this->{$callback}[0]->{$callback}[1]($varValue, $this);
}
}
$this->Files->rename($this->strPath . '/' . $this->varValue . $this->strExtension, $this->strPath . '/' . $varValue . $this->strExtension);
// Add a log entry
if (stristr($this->intId, '__new__') == true) {
$this->log('Folder "' . $this->strPath . '/' . $varValue . $this->strExtension . '" has been created', 'DC_Folder save()', TL_FILES);
} else {
$this->log('File or folder "' . $this->strPath . '/' . $this->varValue . $this->strExtension . '" has been renamed to "' . $this->strPath . '/' . $varValue . $this->strExtension . '"', 'DC_Folder save()', TL_FILES);
}
// Set the new value so the input field can show it
if ($this->Input->get('act') == 'editAll') {
$session = $this->Session->getData();
if (($index = array_search($this->urlEncode($this->strPath . '/' . $this->varValue) . $this->strExtension, $session['CURRENT']['IDS'])) !== false) {
$session['CURRENT']['IDS'][$index] = $this->urlEncode($this->strPath . '/' . $varValue) . $this->strExtension;
$this->Session->setData($session);
}
}
$this->varValue = $varValue;
}