function object_alter_render_late($args)
{
    $elem = $args['elem'];
    $html =& $args['html'];
    $obj = $args['obj'];
    if (!elem_has_class($args['elem'], 'object')) {
        return false;
    }
    if (!$args['edit']) {
        // add links only for viewing
        if (!empty($obj['object-link'])) {
            $link = $obj['object-link'];
            // resolve any aliases
            $link = resolve_aliases($link, $obj['name']);
            if (!is_url($link) && substr($link, 0, 1) != '#') {
                // add base url for relative links that are not directed towards anchors
                if (SHORT_URLS) {
                    $link = base_url() . urlencode($link);
                } else {
                    $link = base_url() . '?' . urlencode($link);
                }
            }
            // <a> can include block elements in html5
            if (substr($html, -1) == "\n") {
                $html = substr($html, 0, -1);
            }
            $html = '<a href="' . htmlspecialchars($link, ENT_COMPAT, 'UTF-8') . '">' . "\n\t" . str_replace("\n", "\n\t", $html) . "\n" . '</a>' . "\n";
            return true;
        }
    }
    return false;
}
Пример #2
0
/**
 *	helper function for rendering the content of a text object for use in 
 *	editing (outside the textarea) and viewing
 *
 *	@param string $s content
 *	@param string $name object name
 *	@return html-encoded content
 */
function _text_render_content($s, $name)
{
    // resolve any aliases
    $s = resolve_aliases($s, $name);
    $s = html_encode_str_smart($s);
    // automatically add <br> elements for newlines
    if (TEXT_AUTO_BR) {
        $s = str_replace("\r\n", "\n", $s);
        $s = str_replace("\n", "<br>\n", $s);
    }
    // encode non-breakable spaces (160, 0xc2 0xa0 in utf-8)
    $s = str_replace(" ", '&nbsp;', $s);
    // resolve any relative urls
    $s = resolve_relative_urls($s);
    return $s;
}