Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Permalinks: better behavior to release 1.3 - Ticket #309

  • Loading branch information...
commit c3636a717111ffb0ce39964163c381d0ba231118 1 parent 84799bc
N. Petkov authored

Showing 1 changed file with 23 additions and 1 deletion. Show diff stats Hide diff stats

  1. +23 1 src/lib/util/DataUtil.php
24 src/lib/util/DataUtil.php
@@ -469,7 +469,7 @@ public static function formatPermalink($var)
469 469 $permasearch = explode(',', System::getVar('permasearch'));
470 470 $permareplace = explode(',', System::getVar('permareplace'));
471 471 foreach ($permasearch as $key => $value) {
472   - $var = mb_ereg_replace("[$value]", $permareplace[$key], $var);
  472 + $var = mb_ereg_replace($value, $permareplace[$key], $var);
473 473 }
474 474
475 475 $var = preg_replace("#(\s*\/\s*|\s*\+\s*|\s+)#", '-', strtolower($var));
@@ -477,12 +477,34 @@ public static function formatPermalink($var)
477 477 // final clean
478 478 $permalinksseparator = System::getVar('shorturlsseparator');
479 479 $var = mb_ereg_replace("[^a-z0-9_{$permalinksseparator}]", '', $var, "imsr");
  480 + $var = preg_replace('/'.$permalinksseparator.'+/', $permalinksseparator, $var); // remove replicated separator
480 481 $var = trim($var, $permalinksseparator);
481 482
482 483 return $var;
483 484 }
484 485
485 486 /**
  487 + * Transliterate a variable.
  488 + *
  489 + * @param string $var The variable to format.
  490 + *
  491 + * @return string The formatted variable.
  492 + */
  493 + public static function formatTransliterate($var)
  494 + {
  495 + $strIsUpper = (strcmp($var, mb_strtoupper($var)) == 0);
  496 + // replace all chars $permasearch with the one in $permareplace
  497 + $permasearch = explode(',', System::getVar('permasearch'));
  498 + $permareplace = explode(',', System::getVar('permareplace'));
  499 + foreach ($permasearch as $key => $value) {
  500 + $var = mb_ereg_replace($value, $permareplace[$key], $var);
  501 + }
  502 + if ($strIsUpper) $var = mb_strtoupper($var);
  503 +
  504 + return $var;
  505 + }
  506 +
  507 + /**
486 508 * Censor variable contents. This method is recursive array safe.
487 509 *
488 510 * @param string $var The variable to censor.

0 comments on commit c3636a7

Please sign in to comment.
Something went wrong with that request. Please try again.