예제 #1
0
파일: output.php 프로젝트: socialweb/PiGo
/**
 * When given a title, returns a version suitable for inclusion in a URL
 *
 * @param string $title The title
 *
 * @return string The optimised title
 * @since 1.7.2
 */
function elgg_get_friendly_title($title)
{
    // return a URL friendly title to short circuit normal title formatting
    $params = array('title' => $title);
    $result = elgg_trigger_plugin_hook('format', 'friendly:title', $params, NULL);
    if ($result) {
        return $result;
    }
    // titles are often stored HTML encoded
    $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
    $title = ElggTranslit::urlize($title);
    return $title;
}
예제 #2
0
 /**
  * http://trac.elgg.org/ticket/3210 - Don't remove -s in friendly titles
  * http://trac.elgg.org/ticket/2276 - improve char encoding
  */
 public function test_friendly_title()
 {
     $cases = array("B&N > Amazon, OK? <bold> 'hey!' \$34" => "b-and-n-greater-than-amazon-ok-bold-hey-34", "a-a_a a\na\ra\ta\va!a\"a#a\$a%a&a'a(a)a*a+a,a.a/a:a;a=a?a@a[a\\a]a^a`a{a|a}a~a" => "a-a-a-a-a-a-aaaaaaa-and-aaaaaaaaaaaaaaaaaaaaaaa", "-_ hello _-" => "hello", "Iñtërnâtiônàlizætiøn, AND 日本語" => 'internationalizaetion-and-%E6%97%A5%E6%9C%AC%E8%AA%9E');
     // where available, string is converted to NFC before transliteration
     if (ElggTranslit::hasNormalizerSupport()) {
         $form_d = "Å";
         // A followed by 'COMBINING RING ABOVE' (U+030A)
         $cases[$form_d] = "a";
     }
     foreach ($cases as $case => $expected) {
         $friendly_title = elgg_get_friendly_title($case);
         $this->assertIdentical($expected, $friendly_title);
     }
 }
예제 #3
0
파일: output.php 프로젝트: nogsus/Elgg
/**
 * When given a title, returns a version suitable for inclusion in a URL
 *
 * @param string $title The title
 *
 * @return string The optimised title
 * @since 1.7.2
 */
function elgg_get_friendly_title($title)
{
    // return a URL friendly title to short circuit normal title formatting
    $params = array('title' => $title);
    $result = elgg_trigger_plugin_hook('format', 'friendly:title', $params, NULL);
    if ($result) {
        return $result;
    }
    // handle some special cases
    $title = str_replace('&amp;', 'and', $title);
    $title = ElggTranslit::urlize($title);
    return $title;
}