Exemplo n.º 1
0
/**
 * Internal callback function.
 */
function uu_process_template_callback($username, $firstname, $lastname, $block)
{
    switch ($block[3]) {
        case 'u':
            $repl = $username;
            break;
        case 'f':
            $repl = $firstname;
            break;
        case 'l':
            $repl = $lastname;
            break;
        default:
            return $block[0];
    }
    switch ($block[1]) {
        case '+':
            $repl = textlib::strtoupper($repl);
            break;
        case '-':
            $repl = textlib::strtolower($repl);
            break;
        case '~':
            $repl = textlib::strtotitle($repl);
            break;
    }
    if (!empty($block[2])) {
        $repl = textlib::substr($repl, 0, $block[2]);
    }
    return $repl;
}
Exemplo n.º 2
0
/**
 * Function that returns the name that should be displayed for a specific tag
 *
 * @package  core_tag
 * @category tag
 * @access   public
 * @param    object   $tagobject a line out of tag table, as returned by the adobd functions
 * @param    int      $html TAG_RETURN_HTML (default) will return htmlspecialchars encoded string, TAG_RETURN_TEXT will not encode.
 * @return   string
 */
function tag_display_name($tagobject, $html=TAG_RETURN_HTML) {
    global $CFG;

    if (!isset($tagobject->name)) {
        return '';
    }

    if (empty($CFG->keeptagnamecase)) {
        //this is the normalized tag name
        $tagname = textlib::strtotitle($tagobject->name);
    } else {
        //original casing of the tag name
        $tagname = $tagobject->rawname;
    }

    // clean up a bit just in case the rules change again
    $tagname = clean_param($tagname, PARAM_TAG);

    if ($html == TAG_RETURN_TEXT) {
        return $tagname;
    } else { // TAG_RETURN_HTML
        return htmlspecialchars($tagname);
    }
}
Exemplo n.º 3
0
 /**
  * Tests the static strtotitle method
  * @return void
  */
 public function test_strtotitle()
 {
     $str = "žluťoučký koníček";
     $this->assertSame(textlib::strtotitle($str), "Žluťoučký Koníček");
 }
Exemplo n.º 4
0
/**
 * Internal callback function.
 */
function process_template_callback($block)
{
    global $template_globals;
    $textlib = textlib::get_instance();
    $repl = $block[0];
    switch ($block[3]) {
        case 'u':
            $repl = $template_globals->username;
            break;
        case 'f':
            $repl = $template_globals->firstname;
            break;
        case 'l':
            $repl = $template_globals->lastname;
            break;
    }
    switch ($block[1]) {
        case '+':
            $repl = textlib::strtoupper($repl);
            break;
        case '-':
            $repl = textlib::strtolower($repl);
            break;
        case '~':
            $repl = textlib::strtotitle($repl);
            break;
    }
    if (!empty($block[2])) {
        $repl = textlib::substr($repl, 0, $block[2]);
    }
    return $repl;
}