mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-28 20:40:24 +02:00
Merge most changes from 3.0.x branch since the 25th december.
(Captcha changes for refreshing captcha image not included) git-svn-id: file:///svn/phpbb/trunk@9404 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -17,7 +17,7 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* Code from pear.php.net, Text_Diff-1.0.0 package
|
||||
* Code from pear.php.net, Text_Diff-1.1.0 package
|
||||
* http://pear.php.net/package/Text_Diff/
|
||||
*
|
||||
* Modified by phpBB Group to meet our coding standards
|
||||
@@ -60,6 +60,48 @@ class diff
|
||||
return $this->_edits;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of new (added) lines in a given diff.
|
||||
*
|
||||
* @since Text_Diff 1.1.0
|
||||
*
|
||||
* @return integer The number of new lines
|
||||
*/
|
||||
function count_added_lines()
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
foreach ($this->_edits as $edit)
|
||||
{
|
||||
if (is_a($edit, 'diff_op_add') || is_a($edit, 'diff_op_change'))
|
||||
{
|
||||
$count += $edit->nfinal();
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of deleted (removed) lines in a given diff.
|
||||
*
|
||||
* @since Text_Diff 1.1.0
|
||||
*
|
||||
* @return integer The number of deleted lines
|
||||
*/
|
||||
function count_deleted_lines()
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
foreach ($this->_edits as $edit)
|
||||
{
|
||||
if (is_a($edit, 'diff_op_delete') || is_a($edit, 'diff_op_change'))
|
||||
{
|
||||
$count += $edit->norig();
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a reversed diff.
|
||||
*
|
||||
@@ -427,31 +469,35 @@ class diff3 extends diff
|
||||
}
|
||||
|
||||
/**
|
||||
* Return merged output
|
||||
* Return number of conflicts
|
||||
*/
|
||||
function get_num_conflicts()
|
||||
{
|
||||
$conflicts = 0;
|
||||
|
||||
foreach ($this->_edits as $edit)
|
||||
{
|
||||
if ($edit->is_conflict())
|
||||
{
|
||||
$conflicts++;
|
||||
}
|
||||
}
|
||||
|
||||
return $conflicts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get conflicts content for download. This is generally a merged file, but preserving conflicts and adding explanations to it.
|
||||
* A user could then go through this file, search for the conflicts and changes the code accordingly.
|
||||
*
|
||||
* @param string $label1 the cvs file version/label from the original set of lines
|
||||
* @param string $label2 the cvs file version/label from the new set of lines
|
||||
* @param string $label_sep the explanation between label1 and label2 - more of a helper for the user
|
||||
* @param bool $get_conflicts if set to true only the number of conflicts is returned
|
||||
* @param bool $merge_new if set to true the merged output will have the new file contents on a conflicting merge
|
||||
*
|
||||
* @return mixed the merged output
|
||||
*/
|
||||
function merged_output($label1 = 'CURRENT_FILE', $label2 = 'NEW_FILE', $label_sep = 'DIFF_SEP_EXPLAIN', $get_conflicts = false, $merge_new = false)
|
||||
function get_conflicts_content($label1 = 'CURRENT_FILE', $label2 = 'NEW_FILE', $label_sep = 'DIFF_SEP_EXPLAIN')
|
||||
{
|
||||
if ($get_conflicts)
|
||||
{
|
||||
foreach ($this->_edits as $edit)
|
||||
{
|
||||
if ($edit->is_conflict())
|
||||
{
|
||||
$this->_conflicting_blocks++;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_conflicting_blocks;
|
||||
}
|
||||
|
||||
$label1 = (!empty(phpbb::$user->lang[$label1])) ? phpbb::$user->lang[$label1] : $label1;
|
||||
$label2 = (!empty(phpbb::$user->lang[$label2])) ? phpbb::$user->lang[$label2] : $label2;
|
||||
$label_sep = (!empty(phpbb::$user->lang[$label_sep])) ? phpbb::$user->lang[$label_sep] : $label_sep;
|
||||
@@ -462,15 +508,12 @@ class diff3 extends diff
|
||||
{
|
||||
if ($edit->is_conflict())
|
||||
{
|
||||
if (!$merge_new)
|
||||
{
|
||||
$lines = array_merge($lines, array('<<<<<<<' . ($label1 ? ' ' . $label1 : '')), $edit->final1, array('=======' . ($label_sep ? ' ' . $label_sep : '')), $edit->final2, array('>>>>>>>' . ($label2 ? ' ' . $label2 : '')));
|
||||
}
|
||||
else
|
||||
{
|
||||
$lines = array_merge($lines, $edit->final1);
|
||||
}
|
||||
$this->_conflicting_blocks++;
|
||||
// Start conflict label
|
||||
$label_start = array('<<<<<<< ' . $label1);
|
||||
$label_mid = array('======= ' . $label_sep);
|
||||
$label_end = array('>>>>>>> ' . $label2);
|
||||
|
||||
$lines = array_merge($lines, $label_start, $edit->final1, $label_mid, $edit->final2, $label_end);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user