25 $key1 = empty($Master1[1]) ? 2 : 1;
26 $str1 = $Master1[$key1][
'fuzzyname'];
27 $key2 = empty($Master2[1]) ? 2 : 1;
28 $str2 = $Master2[$key2][
'fuzzyname'];
29 return strcasecmp($str1, $str2);
52 if (!empty($Children1) && !empty($Children2)) {
58 foreach ($Children2 as $idx => $child) {
59 $allChildren2[$idx] = $child;
60 $byName[$child[
'ufile_name']][$idx] = $idx;
61 $byFuzzyExt[$child[
'fuzzynameext']][$idx] = $idx;
62 $byFuzzy[$child[
'fuzzyname']][$idx] = $idx;
66 foreach ($Children1 as $Child1) {
71 if (!$done && !empty($byName[$Child1[
'ufile_name']])) {
72 foreach ($byName[$Child1[
'ufile_name']] as $idx) {
73 if (!isset($consumed[$idx])) {
74 $Master[$row][1] = $Child1;
75 $Master[$row][2] = $allChildren2[$idx];
76 $consumed[$idx] =
true;
84 if (!$done && !empty($byFuzzyExt[$Child1[
'fuzzynameext']])) {
85 foreach ($byFuzzyExt[$Child1[
'fuzzynameext']] as $idx) {
86 if (!isset($consumed[$idx])) {
87 $Master[$row][1] = $Child1;
88 $Master[$row][2] = $allChildren2[$idx];
89 $consumed[$idx] =
true;
99 foreach ($byFuzzyExt as $key => $indices) {
100 if (levenshtein($Child1[
'fuzzynameext'], $key) == 1) {
101 foreach ($indices as $idx) {
102 if (!isset($consumed[$idx])) {
109 if ($best !==
null) {
110 $Master[$row][1] = $Child1;
111 $Master[$row][2] = $allChildren2[$best];
112 $consumed[$best] =
true;
118 if (!$done && !empty($byFuzzy[$Child1[
'fuzzyname']])) {
119 foreach ($byFuzzy[$Child1[
'fuzzyname']] as $idx) {
120 if (!isset($consumed[$idx])) {
121 $Master[$row][1] = $Child1;
122 $Master[$row][2] = $allChildren2[$idx];
123 $consumed[$idx] =
true;
132 $Master[$row][1] = $Child1;
133 $Master[$row][2] = array();
136 } elseif (!empty($Children1)) {
138 foreach ($Children1 as $Child1) {
140 $Master[$row][1] = $Child1;
141 $Master[$row][2] = array();
146 if (!empty($Children2)) {
147 if (!isset($consumed)) {
148 foreach ($Children2 as $Child) {
150 $Master[$row][1] =
'';
151 $Master[$row][2] = $Child;
154 foreach ($allChildren2 as $idx => $child) {
155 if (!isset($consumed[$idx])) {
157 $Master[$row][1] =
'';
158 $Master[$row][2] = $child;
165 usort($Master,
"FuzzyCmp");
184 function FileList(&$Master, $agent_pk1, $agent_pk2, $filter, $plugin, $uploadtree_pk1, $uploadtree_pk2)
188 $ModLicView = &$Plugins[plugin_find_id(
"view-license")];
190 if (! empty($Master)) {
191 foreach ($Master as &$MasterRow) {
192 if (! empty($MasterRow[1])) {
193 $MasterRow[1][
"linkurl"] =
GetDiffLink($MasterRow, 1, $agent_pk1,
194 $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2);
197 if (! empty($MasterRow[2])) {
198 $MasterRow[2][
"linkurl"] =
GetDiffLink($MasterRow, 2, $agent_pk2,
199 $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2);
220 function GetDiffLink($MasterRow, $side, $agent_pk, $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2)
225 $OppositeItem = $uploadtree_pk2;
228 $OppositeItem = $uploadtree_pk1;
231 $OppositeChild = $MasterRow[$OppositeSide];
232 $Child = $MasterRow[$side];
235 if (empty($OppositeChild)) {
236 $OppositeParm =
"&item{$OppositeSide}=$OppositeItem";
238 $OppositeParm =
"&item{$OppositeSide}=$OppositeChild[uploadtree_pk]";
241 $IsDir =
Isdir($Child[
'ufile_mode']);
245 if (! empty($Child[
'pfile_fk']) && ! empty($ModLicView)) {
247 $LinkUri .=
"?mod=view-license&napk=$agent_pk&upload=$Child[upload_fk]&item=$Child[uploadtree_pk]";
254 $Container_uploadtree_pk = $Child[
'uploadtree_pk'];
255 $LicUri =
"?mod=$plugin->Name&item{$side}=$Child[uploadtree_pk]{$OppositeParm}&col=$side";
256 if (! empty($filter)) {
257 $LicUri .=
"&filter=$filter";
267 $Flink =
"<a href='$LicUri'>";
271 }
else if (! empty($LinkUri)) {
272 $Flink .=
"<a href='$LinkUri'>";
275 $Flink .= $Child[
'ufile_name'];
303 $sql =
"SELECT ufile_name FROM uploadtree WHERE uploadtree_pk = $A_pk";
306 $row = pg_fetch_assoc($result);
307 $AName = $row[
"ufile_name"];
308 pg_free_result($result);
310 $APhon = metaphone($AName);
316 $sql =
"SELECT uploadtree_pk, ufile_name FROM uploadtree WHERE parent = $B_pk";
321 while ($row = pg_fetch_assoc($result)) {
322 $ChildName = $row[
"ufile_name"];
323 $ChildPhon = metaphone($ChildName);
324 $PhonDist = levenshtein($APhon, $ChildPhon);
325 if ($PhonDist < $BestDist) {
326 $BestDist = $PhonDist;
327 $BestPk = $row[
'uploadtree_pk'];
330 pg_free_result($result);
348 foreach ($Children as $key1 => &$Child) {
350 if (strstr($Child[
'ufile_name'],
".") !==
false) {
352 $ExtLen = strlen($Ext);
353 $NoExtName = substr($Child[
'ufile_name'], 0, - 1 * $ExtLen);
355 $NoExtName = $Child[
'ufile_name'];
358 $NoNumbName = preg_replace(
'/([0-9]|\.|-|_)/',
"", $NoExtName);
359 $NoNumbNameext = preg_replace(
'/([0-9]|\.|-|_)/',
"", $Child[
'ufile_name']);
360 $Child[
'fuzzyname'] = $NoNumbName;
361 $Child[
'fuzzynameext'] = $NoNumbNameext;
380 if ((count($Path1) < 1) || (count($Path2) < 1)) {
381 return "No path specified";
383 $filter_clause = (empty($filter)) ?
"" :
"&filter=$filter";
384 $Path = ($Column == 1) ? $Path1 : $Path2;
385 $Last = $Path[count($Path)-1];
388 $V =
"<div style='border: double gray; background-color:lightyellow'>\n";
392 $V .=
"<b>$text</b>: ";
397 $text = _(
"Freeze path");
398 $id =
"Freeze{$Column}";
399 $alt = _(
"Freeze this path so that selecting a new directory in the other path will not change this one.");
400 $Options =
"id='$id' onclick='Freeze(\"$Column\")' title='$alt'";
401 $FreezeBtn =
"<button type='button' $Options> $text </button>\n";
403 for ($i = 0; $i < count($List); $i ++) {
404 $Folder = $List[$i][
'folder_pk'];
405 $FolderName = htmlentities($List[$i][
'folder_name']);
406 $V .=
"<b>$FolderName/</b> ";
410 $V .=
" $FreezeBtn";
414 for ($PathLev = 0; $PathLev < count($Path); $PathLev ++) {
415 $PathElt1 = @$Path1[$PathLev];
416 $PathElt2 = @$Path2[$PathLev];
418 $PathElt = ($Column == 1) ? $PathElt1 : $PathElt2;
420 $UseHref = (! empty($PathElt1) && (! empty($PathElt2)));
421 if ($UseHref && ($PathElt != $Last)) {
422 $href =
"$Uri2&item1=$PathElt1[uploadtree_pk]&item2=$PathElt2[uploadtree_pk]{$filter_clause}&col=$Column";
423 $V .=
"<a href='$href'>";
428 $V .=
" <b>" . $PathElt[
'ufile_name'] .
"/</b>";
429 if ($UseHref && ($PathElt != $Last)) {
FileList(&$Master, $agent_pk1, $agent_pk2, $filter, $plugin, $uploadtree_pk1, $uploadtree_pk2)
Adds the element linkurl to the $Master elements.
Dir2BrowseDiff($Path1, $Path2, $filter, $Column, $plugin)
Return a string which is a linked path to the file.
GetDiffLink($MasterRow, $side, $agent_pk, $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2)
Generate the link for one side of a diff element.
MakeMaster($Children1, $Children2)
Generate the master array with aligned children.
NextUploadtree_pk($A_pk, $B_pk)
Given an uploadtree_pk in tree A ($A_pk), find the similarly named one that is immediately under the ...
FuzzyName(&$Children)
Add fuzzyname and fuzzynameext to $Children.
FuzzyCmp($Master1, $Master2)
FuzzyName comparison function for diff tools.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
DirGetNonArtifact($UploadtreePk, $uploadtree_tablename='uploadtree')
Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk).
FolderGetFromUpload($Uploadpk, $Folder=-1, $Stop=-1)
DEPRECATED! Given an upload number, return the folder path in an array containing folder_pk and name.
Traceback_uri()
Get the URI without query to this location.
GetFileExt($fname)
Get File Extension (text after last period)
if(!function_exists('resolve_config_value')) $Options
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN