本文整理汇总了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;