Ejemplo n.º 1
0
/**
 * Parse a tag for attributes and hand over to the tag handler function.
 *
 * @param string $tag The tag name without '<txp:'
 * @param string $atts The attribute string
 * @param string|null $thing The tag's content in case of container tags (optional)
 * @return string Parsed tag result
 */
function processTags($tag, $atts, $thing = NULL)
{
    global $production_status, $txptrace, $txptracelevel, $txp_current_tag;
    if ($production_status !== 'live') {
        $old_tag = $txp_current_tag;
        $txp_current_tag = '<txp:' . $tag . $atts . (isset($thing) ? '>' : '/>');
        trace_add($txp_current_tag);
        ++$txptracelevel;
        if ($production_status === 'debug') {
            maxMemUsage($txp_current_tag);
        }
    }
    if ($tag === 'link') {
        $tag = 'tpt_' . $tag;
    }
    if (maybe_tag($tag)) {
        $out = $tag(splat($atts), $thing);
    } elseif (isset($GLOBALS['pretext'][$tag])) {
        $out = txpspecialchars($pretext[$tag]);
        trigger_error(gTxt('deprecated_tag'), E_USER_NOTICE);
    } else {
        $out = '';
        trigger_error(gTxt('unknown_tag'), E_USER_WARNING);
    }
    if ($production_status !== 'live') {
        --$txptracelevel;
        if (isset($thing)) {
            trace_add('</txp:' . $tag . '>');
        }
        $txp_current_tag = $old_tag;
    }
    return $out;
}
Ejemplo n.º 2
0
/**
 * Parse a tag for attributes and hand over to the tag handler function.
 *
 * @param  string      $tag   The tag name
 * @param  string      $atts  The attribute string
 * @param  string|null $thing The tag's content in case of container tags
 * @return string Parsed tag result
 * @package TagParser
 */
function processTags($tag, $atts, $thing = null)
{
    global $production_status, $txp_current_tag, $txp_current_form;
    static $registry = null;
    if ($production_status !== 'live') {
        $old_tag = $txp_current_tag;
        $txp_current_tag = '<txp:' . $tag . $atts . (isset($thing) ? '>' : '/>');
        trace_add($txp_current_tag, 1, "Form='{$txp_current_form}', Tag='{$txp_current_tag}'");
    }
    if ($registry === null) {
        $registry = Txp::get('\\Textpattern\\Tag\\Registry');
    }
    if ($registry->isRegistered($tag)) {
        $out = $registry->process($tag, splat($atts), $thing);
    } elseif (maybe_tag($tag)) {
        $out = $tag(splat($atts), $thing);
        trigger_error(gTxt('unregistered_tag'), E_USER_NOTICE);
    } elseif (isset($GLOBALS['pretext'][$tag])) {
        $out = txpspecialchars($pretext[$tag]);
        trigger_error(gTxt('deprecated_tag'), E_USER_NOTICE);
    } else {
        $out = '';
        trigger_error(gTxt('unknown_tag'), E_USER_WARNING);
    }
    if ($production_status !== 'live') {
        trace_add('', -1);
        if (isset($thing)) {
            trace_add("</txp:{$tag}>");
        }
        $txp_current_tag = $old_tag;
    }
    return $out;
}