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


PHP SEFTools::ReplaceAll方法代码示例

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


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

示例1: _storeLocation


//.........这里部分代码省略.........
         $location[] = JoomSEF::_titleToLocation($titlePart);
     }
     // remove unwanted characters.
     $finalstrip = explode('|', $sefConfig->stripthese);
     $takethese = str_replace('|', '', $sefConfig->friendlytrim);
     if (strstr($takethese, $sefConfig->replacement) === FALSE) {
         $takethese .= $sefConfig->replacement;
     }
     $imptrim = implode('/', $location);
     if (!is_null($task)) {
         $task = str_replace($sefConfig->replacement . '-' . $sefConfig->replacement, $sefConfig->replacement, $task);
         $task = str_replace($finalstrip, '', $task);
         $task = trim($task, $takethese);
     }
     $imptrim = str_replace($sefConfig->replacement . '-' . $sefConfig->replacement, $sefConfig->replacement, $imptrim);
     $suffixthere = 0;
     $regexSuffix = str_replace('.', '\\.', $sefConfig->suffix);
     $pregSuffix = addcslashes($regexSuffix, '/');
     //if (eregi($regexSuffix.'$', $imptrim)) {
     if (preg_match('/' . $pregSuffix . '$/i', $imptrim)) {
         $suffixthere = strlen($sefConfig->suffix);
     }
     $imptrim = str_replace($finalstrip, $sefConfig->replacement, substr($imptrim, 0, strlen($imptrim) - $suffixthere));
     $imptrim = str_replace($sefConfig->replacement . $sefConfig->replacement, $sefConfig->replacement, $imptrim);
     $suffixthere = 0;
     //if (eregi($regexSuffix.'$', $imptrim)) {
     if (preg_match('/' . $pregSuffix . '$/i', $imptrim)) {
         $suffixthere = strlen($sefConfig->suffix);
     }
     $imptrim = trim(substr($imptrim, 0, strlen($imptrim) - $suffixthere), $takethese);
     // add the task if set
     $imptrim .= !is_null($task) ? '/' . $task . $sefConfig->suffix : '';
     // remove all the -/
     $imptrim = SEFTools::ReplaceAll($sefConfig->replacement . '/', '/', $imptrim);
     // remove all the /-
     $imptrim = SEFTools::ReplaceAll('/' . $sefConfig->replacement, '/', $imptrim);
     // Remove all the //
     $location = SEFTools::ReplaceAll('//', '/', $imptrim);
     // check if the location isn't too long for database storage and truncate it in that case
     $suffixthere = 0;
     //if (eregi($regexSuffix.'$', $location)) {
     if (preg_match('/' . $pregSuffix . '$/i', $location)) {
         $suffixthere = strlen($sefConfig->suffix);
     }
     $suffixLen = strlen($sefConfig->suffix);
     $maxlen = 240 + $suffixthere - $suffixLen;
     // Leave some space for language and numbers
     if (strlen($location) > $maxlen) {
         // Temporarily remove the suffix
         //$location = ereg_replace($regexSuffix.'$', '', $location);
         $location = preg_replace('/' . $pregSuffix . '$/', '', $location);
         // Explode the location to parts
         $parts = explode('/', $location);
         do {
             // Find the key of the longest part
             $key = 0;
             $len = strlen($parts[0]);
             for ($i = 1, $n = count($parts); $i < $n; $i++) {
                 $tmpLen = strlen($parts[$i]);
                 if ($tmpLen > $len) {
                     $key = $i;
                     $len = $tmpLen;
                 }
             }
             // Truncate the longest part
             $truncBy = strlen($location) - $maxlen;
开发者ID:01J,项目名称:bealtine,代码行数:67,代码来源:joomsef.php


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