예제 #1
0
파일: dja_utils.php 프로젝트: idlesign/dja
/**
 * Converts an Internationalized Resource Identifier (IRI) portion to a URI
 * portion that is suitable for inclusion in a URL.
 *
 * @param string $iri
 * @return mixed|string
 */
function iri_to_uri($iri)
{
    return py_urllib_quote($iri, "/#%[]=:;\$&()+,!?*@'~");
}
예제 #2
0
    }
    $length = $arg;
    $tr_ = new Truncator($value);
    return $tr_->words($length, ' ...');
}, array('is_safe' => True));
// TODO truncatewords_html
//stringfilter
$lib->filter('upper', function ($value) {
    return strtoupper($value);
}, array('is_safe' => False));
//stringfilter
$lib->filter('urlencode', function ($value, $safe = null) {
    if ($safe === null) {
        $safe = '/';
    }
    return py_urllib_quote($value, $safe);
}, array('is_safe' => False));
//stringfilter
$lib->filter('urlize', function ($value, $autoescape = null) {
    $urlize_impl = '';
    // TODO implement
    return mark_safe($urlize_impl($value, True, $autoescape));
}, array('is_safe' => True, 'needs_autoescape' => True));
// TODO urlizetrunc
//stringfilter
$lib->filter('wordcount', function ($value) {
    return count(py_str_split($value));
}, array('is_safe' => False));
//stringfilter
$lib->filter('wordwrap', function ($value, $arg) {
    return wordwrap($value, (string) $arg);