Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
b9553eb5
Commit
b9553eb5
authored
Aug 19, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced diff vendor.
parent
c7c7683f
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
114 additions
and
46 deletions
+114
-46
composer.json
apps/advanced/composer.json
+0
-6
composer.json
apps/basic/composer.json
+0
-6
composer.json
framework/composer.json
+1
-7
CodeFile.php
framework/yii/gii/CodeFile.php
+1
-2
main.css
framework/yii/gii/assets/main.css
+85
-0
diff.php
framework/yii/gii/views/default/diff.php
+1
-3
StringHelperBase.php
framework/yii/helpers/StringHelperBase.php
+26
-22
No files found.
apps/advanced/composer.json
View file @
b9553eb5
...
@@ -13,12 +13,6 @@
...
@@ -13,12 +13,6 @@
"source"
:
"https://github.com/yiisoft/yii2"
"source"
:
"https://github.com/yiisoft/yii2"
},
},
"minimum-stability"
:
"dev"
,
"minimum-stability"
:
"dev"
,
"repositories"
:
[
{
"type"
:
"pear"
,
"url"
:
"http://pear.horde.org"
}
],
"require"
:
{
"require"
:
{
"php"
:
">=5.3.0"
,
"php"
:
">=5.3.0"
,
"yiisoft/yii2"
:
"dev-master"
,
"yiisoft/yii2"
:
"dev-master"
,
...
...
apps/basic/composer.json
View file @
b9553eb5
...
@@ -13,12 +13,6 @@
...
@@ -13,12 +13,6 @@
"source"
:
"https://github.com/yiisoft/yii2"
"source"
:
"https://github.com/yiisoft/yii2"
},
},
"minimum-stability"
:
"dev"
,
"minimum-stability"
:
"dev"
,
"repositories"
:
[
{
"type"
:
"pear"
,
"url"
:
"http://pear.horde.org"
}
],
"require"
:
{
"require"
:
{
"php"
:
">=5.3.0"
,
"php"
:
">=5.3.0"
,
"yiisoft/yii2"
:
"dev-master"
,
"yiisoft/yii2"
:
"dev-master"
,
...
...
framework/composer.json
View file @
b9553eb5
...
@@ -63,17 +63,11 @@
...
@@ -63,17 +63,11 @@
"irc"
:
"irc://irc.freenode.net/yii"
,
"irc"
:
"irc://irc.freenode.net/yii"
,
"source"
:
"https://github.com/yiisoft/yii2"
"source"
:
"https://github.com/yiisoft/yii2"
},
},
"repositories"
:
[
{
"type"
:
"pear"
,
"url"
:
"http://pear.horde.org"
}
],
"require"
:
{
"require"
:
{
"php"
:
">=5.3.7"
,
"php"
:
">=5.3.7"
,
"ext-mbstring"
:
"*"
,
"ext-mbstring"
:
"*"
,
"lib-pcre"
:
"*"
,
"lib-pcre"
:
"*"
,
"p
ear-pear.horde.org/horde_text_diff"
:
"2
.0.*"
,
"p
hpspec/php-diff"
:
"1
.0.*"
,
"ezyang/htmlpurifier"
:
"4.5.*"
"ezyang/htmlpurifier"
:
"4.5.*"
},
},
"autoload"
:
{
"autoload"
:
{
...
...
framework/yii/gii/CodeFile.php
View file @
b9553eb5
...
@@ -143,8 +143,7 @@ class CodeFile extends Object
...
@@ -143,8 +143,7 @@ class CodeFile extends Object
if
(
in_array
(
$type
,
array
(
'jpg'
,
'gif'
,
'png'
,
'exe'
)))
{
if
(
in_array
(
$type
,
array
(
'jpg'
,
'gif'
,
'png'
,
'exe'
)))
{
return
false
;
return
false
;
}
elseif
(
$this
->
operation
===
self
::
OP_OVERWRITE
)
{
}
elseif
(
$this
->
operation
===
self
::
OP_OVERWRITE
)
{
list
(
$diff
,
$addedLines
,
$deletedLines
)
=
StringHelper
::
diff
(
file
(
$this
->
path
),
$this
->
content
);
return
StringHelper
::
diff
(
file
(
$this
->
path
),
$this
->
content
);
return
$diff
;
}
else
{
}
else
{
return
''
;
return
''
;
}
}
...
...
framework/yii/gii/assets/main.css
View file @
b9553eb5
...
@@ -111,3 +111,88 @@ body {
...
@@ -111,3 +111,88 @@ body {
background
:
lightgreen
;
background
:
lightgreen
;
text-decoration
:
none
;
text-decoration
:
none
;
}
}
.Differences
{
width
:
100%
;
border-collapse
:
collapse
;
border-spacing
:
0
;
empty-cells
:
show
;
}
.Differences
thead
{
display
:
none
;
}
.Differences
tbody
th
{
text-align
:
right
;
background
:
#FAFAFA
;
padding
:
1px
2px
;
border-right
:
1px
solid
#eee
;
vertical-align
:
top
;
font-size
:
13px
;
font-family
:
Monaco
,
Menlo
,
Consolas
,
'Courier New'
,
monospace
;
font-weight
:
normal
;
color
:
#999
;
width
:
5px
;
}
.Differences
td
{
padding
:
1px
2px
;
font-size
:
13px
;
font-family
:
Monaco
,
Menlo
,
Consolas
,
'Courier New'
,
monospace
;
}
.DifferencesSideBySide
.ChangeInsert
td
.Left
{
background
:
#dfd
;
}
.DifferencesSideBySide
.ChangeInsert
td
.Right
{
background
:
#cfc
;
}
.DifferencesSideBySide
.ChangeDelete
td
.Left
{
background
:
#f88
;
}
.DifferencesSideBySide
.ChangeDelete
td
.Right
{
background
:
#faa
;
}
.DifferencesSideBySide
.ChangeReplace
.Left
{
background
:
#fe9
;
}
.DifferencesSideBySide
.ChangeReplace
.Right
{
background
:
#fd8
;
}
.Differences
ins
,
.Differences
del
{
text-decoration
:
none
;
}
.DifferencesSideBySide
.ChangeReplace
ins
,
.DifferencesSideBySide
.ChangeReplace
del
{
background
:
#fc0
;
}
.Differences
.Skipped
{
background
:
#f7f7f7
;
}
.DifferencesInline
.ChangeReplace
.Left
,
.DifferencesInline
.ChangeDelete
.Left
{
background
:
#fdd
;
}
.DifferencesInline
.ChangeReplace
.Right
,
.DifferencesInline
.ChangeInsert
.Right
{
background
:
#dfd
;
}
.DifferencesInline
.ChangeReplace
ins
{
background
:
#9e9
;
}
.DifferencesInline
.ChangeReplace
del
{
background
:
#e99
;
}
framework/yii/gii/views/default/diff.php
View file @
b9553eb5
...
@@ -10,8 +10,6 @@
...
@@ -10,8 +10,6 @@
<?php
elseif
(
empty
(
$diff
))
:
?>
<?php
elseif
(
empty
(
$diff
))
:
?>
<div
class=
"alert alert-success"
>
Identical.
</div>
<div
class=
"alert alert-success"
>
Identical.
</div>
<?php
else
:
?>
<?php
else
:
?>
<div
class=
"content"
>
<?php
echo
$diff
;
?>
<pre>
<?php
echo
$diff
;
?>
</pre>
</div>
<?php
endif
;
?>
<?php
endif
;
?>
</div>
</div>
framework/yii/helpers/StringHelperBase.php
View file @
b9553eb5
...
@@ -71,18 +71,17 @@ class StringHelperBase
...
@@ -71,18 +71,17 @@ class StringHelperBase
/**
/**
* Compares two strings or string arrays, and return their differences.
* Compares two strings or string arrays, and return their differences.
* This is a wrapper of the
Horde_Text_Diff
package.
* This is a wrapper of the
[phpspec/php-diff](https://packagist.org/packages/phpspec/php-diff)
package.
* @param string|array $lines1 the first string or string array to be compared. If it is a string,
* @param string|array $lines1 the first string or string array to be compared. If it is a string,
* it will be converted into a string array by breaking at newlines.
* it will be converted into a string array by breaking at newlines.
* @param string|array $lines2 the second string or string array to be compared. If it is a string,
* @param string|array $lines2 the second string or string array to be compared. If it is a string,
* it will be converted into a string array by breaking at newlines.
* it will be converted into a string array by breaking at newlines.
* @param string $format the output format. It must be 'context', 'inline', or 'unified'.
* @param string $format the output format. It must be 'inline', 'unified', 'context', 'side-by-side', or 'array'.
* @param string $engine the diff engine to be used. It must be 'auto', 'native', 'shell', 'string', or 'xdiff'.
* @return string|array the comparison result. An array is returned if `$format` is 'array'. For all other
* @return array the comparison result. The first element is a string representing the detailed comparison result.
* formats, a string is returned.
* The second and the third elements represent the number of added lines and deleted lines, respectively.
* @throws InvalidParamException if the format is invalid.
* @throws InvalidParamException if the format or the engine is invalid.
*/
*/
public
static
function
diff
(
$lines1
,
$lines2
,
$format
=
'inline'
,
$engine
=
'auto'
)
public
static
function
diff
(
$lines1
,
$lines2
,
$format
=
'inline'
)
{
{
if
(
!
is_array
(
$lines1
))
{
if
(
!
is_array
(
$lines1
))
{
$lines1
=
explode
(
"
\n
"
,
$lines1
);
$lines1
=
explode
(
"
\n
"
,
$lines1
);
...
@@ -90,27 +89,32 @@ class StringHelperBase
...
@@ -90,27 +89,32 @@ class StringHelperBase
if
(
!
is_array
(
$lines2
))
{
if
(
!
is_array
(
$lines2
))
{
$lines2
=
explode
(
"
\n
"
,
$lines2
);
$lines2
=
explode
(
"
\n
"
,
$lines2
);
}
}
foreach
(
$lines1
as
$i
=>
$line
)
{
$lines1
[
$i
]
=
rtrim
(
$line
,
"
\r\n
"
);
}
foreach
(
$lines2
as
$i
=>
$line
)
{
$lines2
[
$i
]
=
rtrim
(
$line
,
"
\r\n
"
);
}
switch
(
$format
)
{
switch
(
$format
)
{
case
'context'
:
$renderer
=
new
\Horde_Text_Diff_Renderer_Context
();
break
;
case
'inline'
:
case
'inline'
:
$renderer
=
new
\Horde_Text_Diff_Renderer_Inline
();
$renderer
=
new
\Diff_Renderer_Html_Inline
();
break
;
case
'array'
:
$renderer
=
new
\Diff_Renderer_Html_Array
();
break
;
case
'side-by-side'
:
$renderer
=
new
\Diff_Renderer_Html_SideBySide
();
break
;
case
'context'
:
$renderer
=
new
\Diff_Renderer_Text_Context
();
break
;
break
;
case
'unified'
:
case
'unified'
:
$renderer
=
new
\
Horde_Text_Diff_Renderer
_Unified
();
$renderer
=
new
\
Diff_Renderer_Text
_Unified
();
break
;
break
;
default
:
default
:
throw
new
InvalidParamException
(
"Output format must be 'context', 'inline' or 'unified'."
);
throw
new
InvalidParamException
(
"Output format must be 'inline', 'side-by-side', 'array', 'context' or 'unified'."
);
}
if
(
!
in_array
(
$engine
,
array
(
'auto'
,
'native'
,
'shell'
,
'string'
,
'xdiff'
)))
{
throw
new
InvalidParamException
(
"Engine must be 'auto', 'native', 'shell', 'string' or 'xdiff'."
);
}
}
$diff
=
new
\Horde_Text_Diff
(
$engine
,
array
(
$lines1
,
$lines2
));
$diff
=
new
\Diff
(
$lines1
,
$lines2
);
return
array
(
return
$diff
->
render
(
$renderer
);
$renderer
->
render
(
$diff
),
$diff
->
countAddedLines
(),
$diff
->
countDeletedLines
(),
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment