本文整理汇总了PHP中html_diff_head函数的典型用法代码示例。如果您正苦于以下问题:PHP html_diff_head函数的具体用法?PHP html_diff_head怎么用?PHP html_diff_head使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了html_diff_head函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: html_diff
/**
* Show diff
* between current page version and provided $text
* or between the revisions provided via GET or POST
*
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $text when non-empty: compare with this text with most current version
* @param bool $intro display the intro text
* @param string $type type of the diff (inline or sidebyside)
*/
function html_diff($text = '', $intro = true, $type = null)
{
global $ID;
global $REV;
global $lang;
global $INPUT;
global $INFO;
$pagelog = new PageChangeLog($ID);
/*
* Determine diff type
*/
if (!$type) {
$type = $INPUT->str('difftype');
if (empty($type)) {
$type = get_doku_pref('difftype', $type);
if (empty($type) && $INFO['ismobile']) {
$type = 'inline';
}
}
}
if ($type != 'inline') {
$type = 'sidebyside';
}
/*
* Determine requested revision(s)
*/
// we're trying to be clever here, revisions to compare can be either
// given as rev and rev2 parameters, with rev2 being optional. Or in an
// array in rev2.
$rev1 = $REV;
$rev2 = $INPUT->ref('rev2');
if (is_array($rev2)) {
$rev1 = (int) $rev2[0];
$rev2 = (int) $rev2[1];
if (!$rev1) {
$rev1 = $rev2;
unset($rev2);
}
} else {
$rev2 = $INPUT->int('rev2');
}
/*
* Determine left and right revision, its texts and the header
*/
$r_minor = '';
$l_minor = '';
if ($text) {
// compare text to the most current revision
$l_rev = '';
$l_text = rawWiki($ID, '');
$l_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' ' . dformat((int) @filemtime(wikiFN($ID))) . '</a> ' . $lang['current'];
$r_rev = '';
$r_text = cleanText($text);
$r_head = $lang['yours'];
} else {
if ($rev1 && isset($rev2) && $rev2) {
// two specific revisions wanted
// make sure order is correct (older on the left)
if ($rev1 < $rev2) {
$l_rev = $rev1;
$r_rev = $rev2;
} else {
$l_rev = $rev2;
$r_rev = $rev1;
}
} elseif ($rev1) {
// single revision given, compare to current
$r_rev = '';
$l_rev = $rev1;
} else {
// no revision was given, compare previous to current
$r_rev = '';
$revs = $pagelog->getRevisions(0, 1);
$l_rev = $revs[0];
$REV = $l_rev;
// store revision back in $REV
}
// when both revisions are empty then the page was created just now
if (!$l_rev && !$r_rev) {
$l_text = '';
} else {
$l_text = rawWiki($ID, $l_rev);
}
$r_text = rawWiki($ID, $r_rev);
list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev, null, false, $type == 'inline');
}
/*
* Build navigation
*/
$l_nav = '';
//.........这里部分代码省略.........
示例2: html_diff
/**
* show diff
*
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $text - compare with this text with most current version
* @param bool $intr - display the intro text
*/
function html_diff($text = '', $intro = true, $type = null)
{
global $ID;
global $REV;
global $lang;
global $conf;
if (!$type) {
$type = $_REQUEST['difftype'];
}
if ($type != 'inline') {
$type = 'sidebyside';
}
// we're trying to be clever here, revisions to compare can be either
// given as rev and rev2 parameters, with rev2 being optional. Or in an
// array in rev2.
$rev1 = $REV;
if (is_array($_REQUEST['rev2'])) {
$rev1 = (int) $_REQUEST['rev2'][0];
$rev2 = (int) $_REQUEST['rev2'][1];
if (!$rev1) {
$rev1 = $rev2;
unset($rev2);
}
} else {
$rev2 = (int) $_REQUEST['rev2'];
}
$r_minor = '';
$l_minor = '';
if ($text) {
// compare text to the most current revision
$l_rev = '';
$l_text = rawWiki($ID, '');
$l_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' ' . dformat((int) @filemtime(wikiFN($ID))) . '</a> ' . $lang['current'];
$r_rev = '';
$r_text = cleanText($text);
$r_head = $lang['yours'];
} else {
if ($rev1 && $rev2) {
// two specific revisions wanted
// make sure order is correct (older on the left)
if ($rev1 < $rev2) {
$l_rev = $rev1;
$r_rev = $rev2;
} else {
$l_rev = $rev2;
$r_rev = $rev1;
}
} elseif ($rev1) {
// single revision given, compare to current
$r_rev = '';
$l_rev = $rev1;
} else {
// no revision was given, compare previous to current
$r_rev = '';
$revs = getRevisions($ID, 0, 1);
$l_rev = $revs[0];
$REV = $l_rev;
// store revision back in $REV
}
// when both revisions are empty then the page was created just now
if (!$l_rev && !$r_rev) {
$l_text = '';
} else {
$l_text = rawWiki($ID, $l_rev);
}
$r_text = rawWiki($ID, $r_rev);
list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev);
}
$df = new Diff(explode("\n", htmlspecialchars($l_text)), explode("\n", htmlspecialchars($r_text)));
if ($type == 'inline') {
$tdf = new InlineDiffFormatter();
} else {
$tdf = new TableDiffFormatter();
}
if ($intro) {
print p_locale_xhtml('diff');
}
if (!$text) {
ptln('<div class="diffoptions">');
$form = new Doku_Form(array('action' => wl()));
$form->addHidden('id', $ID);
$form->addHidden('rev2[0]', $l_rev);
$form->addHidden('rev2[1]', $r_rev);
$form->addHidden('do', 'diff');
$form->addElement(form_makeListboxField('difftype', array('sidebyside' => $lang['diff_side'], 'inline' => $lang['diff_inline']), $type, $lang['diff_type'], '', '', array('class' => 'quickselect')));
$form->addElement(form_makeButton('submit', 'diff', 'Go'));
$form->printForm();
$diffurl = wl($ID, array('do' => 'diff', 'rev2[0]' => $l_rev, 'rev2[1]' => $r_rev, 'difftype' => $type));
ptln('<p><a class="wikilink1" href="' . $diffurl . '">' . $lang['difflink'] . '</a></p>');
ptln('</div>');
}
?>
<table class="diff diff_<?php
//.........这里部分代码省略.........
示例3: media_file_diff
/**
* Shows difference between two revisions of image
*
* @author Kate Arzamastseva <pshns@ukr.net>
*/
function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax)
{
global $lang;
global $INPUT;
$l_meta = new JpegMeta(mediaFN($image, $l_rev));
$r_meta = new JpegMeta(mediaFN($image, $r_rev));
$is_img = preg_match('/\\.(jpe?g|gif|png)$/', $image);
if ($is_img) {
$l_size = media_image_preview_size($image, $l_rev, $l_meta);
$r_size = media_image_preview_size($image, $r_rev, $r_meta);
$is_img = $l_size && $r_size && ($l_size[0] >= 30 || $r_size[0] >= 30);
$difftype = $INPUT->str('difftype');
if (!$fromajax) {
$form = new Doku_Form(array('action' => media_managerURL(array(), '&'), 'method' => 'get', 'id' => 'mediamanager__form_diffview', 'class' => 'diffView'));
$form->addHidden('sectok', null);
$form->addElement('<input type="hidden" name="rev2[]" value="' . $l_rev . '" ></input>');
$form->addElement('<input type="hidden" name="rev2[]" value="' . $r_rev . '" ></input>');
$form->addHidden('mediado', 'diff');
$form->printForm();
echo NL . '<div id="mediamanager__diff" >' . NL;
}
if ($difftype == 'opacity' || $difftype == 'portions') {
media_image_diff($image, $l_rev, $r_rev, $l_size, $r_size, $difftype);
if (!$fromajax) {
echo '</div>';
}
return;
}
}
list($l_head, $r_head) = html_diff_head($l_rev, $r_rev, $image, true);
?>
<div class="table">
<table>
<tr>
<th><?php
echo $l_head;
?>
</th>
<th><?php
echo $r_head;
?>
</th>
</tr>
<?php
echo '<tr class="image">';
echo '<td>';
media_preview($image, $auth, $l_rev, $l_meta);
echo '</td>';
echo '<td>';
media_preview($image, $auth, $r_rev, $r_meta);
echo '</td>';
echo '</tr>' . NL;
echo '<tr class="actions">';
echo '<td>';
media_preview_buttons($image, $auth, $l_rev);
echo '</td>';
echo '<td>';
media_preview_buttons($image, $auth, $r_rev);
echo '</td>';
echo '</tr>' . NL;
$l_tags = media_file_tags($l_meta);
$r_tags = media_file_tags($r_meta);
// FIXME r_tags-only stuff
foreach ($l_tags as $key => $l_tag) {
if ($l_tag['value'] != $r_tags[$key]['value']) {
$r_tags[$key]['highlighted'] = true;
$l_tags[$key]['highlighted'] = true;
} else {
if (!$l_tag['value'] || !$r_tags[$key]['value']) {
unset($r_tags[$key]);
unset($l_tags[$key]);
}
}
}
echo '<tr>';
foreach (array($l_tags, $r_tags) as $tags) {
echo '<td>' . NL;
echo '<dl class="img_tags">';
foreach ($tags as $tag) {
$value = cleanText($tag['value']);
if (!$value) {
$value = '-';
}
echo '<dt>' . $lang[$tag['tag'][1]] . '</dt>';
echo '<dd>';
if ($tag['highlighted']) {
echo '<strong>';
}
if ($tag['tag'][2] == 'date') {
echo dformat($value);
} else {
echo hsc($value);
}
if ($tag['highlighted']) {
echo '</strong>';
//.........这里部分代码省略.........