本文整理汇总了PHP中StringUtils::explodeMarkup方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtils::explodeMarkup方法的具体用法?PHP StringUtils::explodeMarkup怎么用?PHP StringUtils::explodeMarkup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtils
的用法示例。
在下文中一共展示了StringUtils::explodeMarkup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doTableStuff
/**
* parse the wiki syntax used to render tables
*
* @private
* @return string
*/
function doTableStuff($text)
{
wfProfileIn(__METHOD__);
$lines = StringUtils::explode("\n", $text);
$out = '';
$td_history = array();
# Is currently a td tag open?
$last_tag_history = array();
# Save history of last lag activated (td, th or caption)
$tr_history = array();
# Is currently a tr tag open?
$tr_attributes = array();
# history of tr attributes
$has_opened_tr = array();
# Did this table open a <tr> element?
$indent_level = 0;
# indent level of the table
foreach ($lines as $outLine) {
$line = trim($outLine);
if ($line === '') {
# empty line, go to next line
$out .= $outLine . "\n";
continue;
}
$first_character = $line[0];
$matches = array();
if (preg_match('/^(:*)\\{\\|(.*)$/', $line, $matches)) {
# First check if we are starting a new table
$indent_level = strlen($matches[1]);
$attributes = $this->mStripState->unstripBoth($matches[2]);
$attributes = Sanitizer::fixTagAttributes($attributes, 'table');
$outLine = str_repeat('<dl><dd>', $indent_level) . "<table{$attributes}>";
array_push($td_history, false);
array_push($last_tag_history, '');
array_push($tr_history, false);
array_push($tr_attributes, '');
array_push($has_opened_tr, false);
} elseif (count($td_history) == 0) {
# Don't do any of the following
$out .= $outLine . "\n";
continue;
} elseif (substr($line, 0, 2) === '|}') {
# We are ending a table
$line = '</table>' . substr($line, 2);
$last_tag = array_pop($last_tag_history);
if (!array_pop($has_opened_tr)) {
$line = "<tr><td></td></tr>{$line}";
}
if (array_pop($tr_history)) {
$line = "</tr>{$line}";
}
if (array_pop($td_history)) {
$line = "</{$last_tag}>{$line}";
}
array_pop($tr_attributes);
$outLine = $line . str_repeat('</dd></dl>', $indent_level);
} elseif (substr($line, 0, 2) === '|-') {
# Now we have a table row
$line = preg_replace('#^\\|-+#', '', $line);
# Whats after the tag is now only attributes
$attributes = $this->mStripState->unstripBoth($line);
$attributes = Sanitizer::fixTagAttributes($attributes, 'tr');
array_pop($tr_attributes);
array_push($tr_attributes, $attributes);
$line = '';
$last_tag = array_pop($last_tag_history);
array_pop($has_opened_tr);
array_push($has_opened_tr, true);
if (array_pop($tr_history)) {
$line = '</tr>';
}
if (array_pop($td_history)) {
$line = "</{$last_tag}>{$line}";
}
$outLine = $line;
array_push($tr_history, false);
array_push($td_history, false);
array_push($last_tag_history, '');
} elseif ($first_character === '|' || $first_character === '!' || substr($line, 0, 2) === '|+') {
# This might be cell elements, td, th or captions
if (substr($line, 0, 2) === '|+') {
$first_character = '+';
$line = substr($line, 1);
}
$line = substr($line, 1);
if ($first_character === '!') {
$line = str_replace('!!', '||', $line);
}
# Split up multiple cells on the same line.
# FIXME : This can result in improper nesting of tags processed
# by earlier parser steps, but should avoid splitting up eg
# attribute values containing literal "||".
$cells = StringUtils::explodeMarkup('||', $line);
$outLine = '';
//.........这里部分代码省略.........
示例2: wfExplodeMarkup
/**
* @deprecated use StringUtils::explodeMarkup
*/
function wfExplodeMarkup($separator, $text)
{
return StringUtils::explodeMarkup($separator, $text);
}
示例3: doTableStuff
//.........这里部分代码省略.........
}
# RTE - end
$attributes = Sanitizer::fixTagAttributes($attributes, 'tr');
array_pop($tr_attributes);
array_push($tr_attributes, $attributes);
$line = '';
$last_tag = array_pop($last_tag_history);
array_pop($has_opened_tr);
array_push($has_opened_tr, true);
if (array_pop($tr_history)) {
$line = '</tr>';
}
if (array_pop($td_history)) {
$line = "</{$last_tag}>{$line}";
}
$outLine = $line;
array_push($tr_history, false);
array_push($td_history, false);
array_push($last_tag_history, '');
} elseif ($first_character === '|' || $first_character === '!' || substr($line, 0, 2) === '|+') {
# This might be cell elements, td, th or captions
if (substr($line, 0, 2) === '|+') {
$first_character = '+';
$line = substr($line, 1);
}
$line = substr($line, 1);
if ($first_character === '!') {
$line = str_replace('!!', '||', $line);
}
# Split up multiple cells on the same line.
# FIXME : This can result in improper nesting of tags processed
# by earlier parser steps, but should avoid splitting up eg
# attribute values containing literal "||".
$cells = StringUtils::explodeMarkup('||', $line);
$outLine = '';
# Loop through each table cell
foreach ($cells as $cell) {
$previous = '';
if ($first_character !== '+') {
$tr_after = array_pop($tr_attributes);
if (!array_pop($tr_history)) {
$previous = "<tr{$tr_after}>\n";
}
array_push($tr_history, true);
array_push($tr_attributes, '');
array_pop($has_opened_tr);
array_push($has_opened_tr, true);
}
$last_tag = array_pop($last_tag_history);
if (array_pop($td_history)) {
$previous = "</{$last_tag}>{$previous}";
}
if ($first_character === '|') {
$last_tag = 'td';
} elseif ($first_character === '!') {
$last_tag = 'th';
} elseif ($first_character === '+') {
$last_tag = 'caption';
} else {
$last_tag = '';
}
array_push($last_tag_history, $last_tag);
# A cell could contain both parameters and data
$cell_data = explode('|', $cell, 2);
# Bug 553: Note that a '|' inside an invalid link should not
# be mistaken as delimiting cell parameters
示例4: externalTableHelper
//.........这里部分代码省略.........
array_push($has_opened_tr, true);
if (array_pop($tr)) {
$t[$k - 1] = $t[$k - 1] . '\\tabularnewline \\hline' . $add_hline;
}
array_pop($ltr);
$t[$k] = $z;
array_push($tr, false);
array_push($ltd, '');
// end-of-row
$cellcount_max[$in_table] = max($cellcount_max[$in_table], $cellcount_current[$in_table]);
// start-of-row
$cellcount_current[$in_table] = 0;
$attributes = $this->unstripForHTML($x);
array_push($ltr, Sanitizer::fixTagAttributes($attributes, 'tr'));
$firstCellOfRow = true;
$add_hline = '';
//$cellcounter[] = 0;
} else {
if (('|' === $fc || '!' === $fc || '|+' === substr($x, 0, 2)) && $in_table != 0) {
# Caption
# $x is a table row
if ('|+' == substr($x, 0, 2)) {
$fc = '+';
$x = substr($x, 1);
}
$after = substr($x, 1);
if ($fc == '!') {
$after = str_replace('!!', '||', $after);
}
// Split up multiple cells on the same line.
// FIXME: This can result in improper nesting of tags processed
// by earlier parser steps, but should avoid splitting up eg
// attribute values containing literal "||".
$cells = StringUtils::explodeMarkup('||', $after);
$t[$k] = '';
# Loop through each table cell
foreach ($cells as $theline) {
$z = '';
if ($fc != '+') {
$tra = array_pop($ltr);
if (!array_pop($tr)) {
$z = "\n";
}
// has been: "\n"
array_push($tr, true);
array_push($ltr, '');
// current-row-cell
$cellcount_current[$in_table]++;
array_pop($has_opened_tr);
array_push($has_opened_tr, true);
}
$l = array_pop($ltd);
//heading cells and normal cells are equal in LaTeX:
if (($fc == '|' || $fc == '!') && !$firstCellOfRow) {
$l = ' & ';
} else {
if ($fc == '+') {
$ltx_caption .= $theline;
continue;
//Missing support for caption here!
} else {
$l = '';
}
}
//$firstCellOfRow = false;
array_push($ltd, $l);