function processTags($matches) { global $pretext, $production_status, $txptrace, $txptracelevel, $txp_current_tag; $tag = $matches[1]; $trouble_makers = array('link'); if (in_array($tag, $trouble_makers)) { $tag = 'tpt_' . $tag; } $atts = isset($matches[2]) ? splat($matches[2]) : ''; $thing = isset($matches[4]) ? $matches[4] : null; $old_tag = @$txp_current_tag; $txp_current_tag = '<txp:' . $tag . ($atts ? $matches[2] : '') . ($thing ? '>' : '/>'); trace_add($txp_current_tag); @++$txptracelevel; if ($production_status == 'debug') { maxMemUsage(trim($matches[0])); } $out = ''; if (function_exists($tag)) { $out = $tag($atts, $thing, $matches[0]); } elseif (isset($pretext[$tag])) { $out = $pretext[$tag]; } else { trigger_error(gTxt('unknown_tag', array('{tag}' => $tag)), E_USER_WARNING); } @--$txptracelevel; if (isset($matches[4])) { trace_add('</txp:' . $tag . '>'); } $txp_current_tag = $old_tag; return $out; }
/** * 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; }
function _getValue($entry, $names) { foreach (splat($names) as $n) { // Support multi-value attributes foreach (splat($entry->getValue($n)) as $val) { // Return the first non-bool-false value of the entries if ($val) { return $val; } } } }
/** * 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; }
function processTags($matches) { global $pretext, $production_status, $txptrace, $txp_current_tag; $tag = $matches[1]; $atts = isset($matches[2]) ? splat($matches[2]) : ''; $thing = isset($matches[4]) ? $matches[4] : ''; $old_tag = @$txp_current_tag; $txp_current_tag = '<txp:' . $tag . ($atts ? ' ' . $matches[2] : '') . ($thing ? '>' : ' />'); if ($production_status == 'debug') { @($txptrace[] = trim($matches[0])); maxMemUsage(trim($matches[0])); } $out = ''; if ($thing) { if (function_exists($tag)) { $out = $tag($atts, $thing, $matches[0]); } elseif (isset($pretext[$tag])) { $out = $pretext[$tag]; } else { trigger_error(gTxt('unknown_tag'), E_USER_WARNING); } } else { if (function_exists($tag)) { $out = $tag($atts, null, $matches[0]); } elseif (isset($pretext[$tag])) { $out = $pretext[$tag]; } else { trigger_error(gTxt('unknown_tag'), E_USER_WARNING); } } $txp_current_tag = $old_tag; return $out; }
function processTags($matches) { global $pretext, $production_status, $txptrace; $tag = $matches[1]; $atts = isset($matches[2]) ? splat($matches[2]) : ''; $thing = isset($matches[4]) ? $matches[4] : ''; if ($production_status == 'debug') { @($txptrace[] = trim($matches[0])); maxMemUsage(trim($matches[0])); } if ($thing) { if (function_exists($tag)) { return $tag($atts, $thing, $matches[0]); } if (isset($pretext[$tag])) { return $pretext[$tag]; } } else { if (function_exists($tag)) { return $tag($atts); } if (isset($pretext[$tag])) { return $pretext[$tag]; } } if ($production_status == 'debug') { // return unknown Tag with removed attributes return htmlspecialchars(preg_replace('#\\"[^"]*\\"#i', '"***"', $matches[0])); } }
function processTag($matches) { list($all, $tag, $atts, $content) = $matches; $a = splat($atts); # dump($tag); dump($content); dump($a); $phr = array('em' => '_', 'i' => '__', 'b' => '**', 'strong' => '*', 'cite' => '??', 'del' => '-', 'ins' => '+', 'sup' => '^', 'sub' => '~', 'span' => '%'); $blk = array('p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'); if (isset($phr[$tag])) { return $phr[$tag] . sci($a) . $content . $phr[$tag]; } elseif ($tag == 'blockquote') { return 'bq.' . sci($a) . ' ' . $content; } elseif (in_array($tag, $blk)) { return $tag . sci($a) . '. ' . $content; } elseif ($tag == 'a') { $t = filterAtts($a, array('href', 'title')); $out = '"' . $content; $out .= isset($t['title']) ? ' (' . $t['title'] . ')' : ''; $out .= '":' . $t['href']; return $out; } else { return $all; } }
function processTags($matches) { global $pretext; $tag = $matches[1]; $atts = isset($matches[2]) ? splat($matches[2]) : ''; $thing = isset($matches[4]) ? $matches[4] : ''; if ($thing) { if (function_exists($tag)) { return $tag($atts, $thing, $matches[0]); } if (isset($pretext[$tag])) { return $pretext[$tag]; } } else { if (function_exists($tag)) { return $tag($atts); } if (isset($pretext[$tag])) { return $pretext[$tag]; } } }