当前位置: 首页>>代码示例>>PHP>>正文


PHP Utf8::toAscii方法代码示例

本文整理汇总了PHP中Patchwork\Utf8::toAscii方法的典型用法代码示例。如果您正苦于以下问题:PHP Utf8::toAscii方法的具体用法?PHP Utf8::toAscii怎么用?PHP Utf8::toAscii使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Patchwork\Utf8的用法示例。


在下文中一共展示了Utf8::toAscii方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCurrencies

 /**
  * @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;
 }
开发者ID:Craffft,项目名称:currencies-bundle,代码行数:28,代码来源:Currencies.php

示例2: standardize

 /**
  * 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, '-');
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:24,代码来源:StringUtil.php

示例3: filterMenu


//.........这里部分代码省略.........
                            $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>';
    }
开发者ID:Mozan,项目名称:core-bundle,代码行数:101,代码来源:DC_Table.php

示例4: ascii

 /**
  * Transliterate a UTF-8 value to ASCII.
  *
  * @param  string  $value
  * @return string
  */
 public static function ascii($value)
 {
     return \Patchwork\Utf8::toAscii($value);
 }
开发者ID:LuckyCyborg,项目名称:simple-mvc-framework,代码行数:10,代码来源:Str.php

示例5: testToASCII

 /**
  * @covers Patchwork\Utf8::toAscii
  */
 function testToASCII()
 {
     $this->assertSame('', u::toAscii(''));
     $this->assertSame('deja vu', u::toAscii('déjà vu'));
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:8,代码来源:Utf8Test.php

示例6: getLanguages

 /**
  * 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;
 }
开发者ID:contao,项目名称:core-bundle,代码行数:37,代码来源:System.php

示例7: ascii

 /**
  * Transliterate a UTF-8 value to ASCII.
  *
  * @param  string  $value
  * @return string
  */
 public static function ascii($value)
 {
     return Utf8::toAscii($value);
 }
开发者ID:visualturk,项目名称:framework,代码行数:10,代码来源:Str.php

示例8: save

 /**
  * 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)));
//.........这里部分代码省略.........
开发者ID:Mozan,项目名称:core-bundle,代码行数:101,代码来源:DC_Folder.php

示例9: test_nul

 public function test_nul()
 {
     $str = "abc";
     $this->assertEquals($str, u::toAscii($str));
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:5,代码来源:Utf8ToAsciiTest.php

示例10: ascii

 /**
  * Transliterate to ASCII.
  *
  * @param  string  $value
  * @return RobClancy\String\String
  */
 public function ascii()
 {
     $this->string = u::toAscii($this->string);
     return $this;
 }
开发者ID:robclancy,项目名称:string,代码行数:11,代码来源:String.php

示例11: exportTheme

 /**
  * 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');
 }
开发者ID:contao,项目名称:core-bundle,代码行数:50,代码来源:Theme.php

示例12: standardize

/**
 * 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, '-');
}
开发者ID:contao,项目名称:core-bundle,代码行数:25,代码来源:functions.php

示例13: utf8_romanize

/**
 * 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);
}
开发者ID:contao,项目名称:core-bundle,代码行数:15,代码来源:functions.php

示例14: slug

 /**
  * 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);
 }
开发者ID:LandPotential,项目名称:LandPKS_DataPortal_ExportLandPKSData_JS,代码行数:22,代码来源:StringsMethods.php


注:本文中的Patchwork\Utf8::toAscii方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。