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))) {
53 foreach ($Children1 as $Child1) {
58 foreach ($Children2 as $key => $Child2) {
59 if ($Child1[
'ufile_name'] == $Child2[
'ufile_name']) {
60 $Master[$row][1] = $Child1;
61 $Master[$row][2] = $Child2;
62 unset($Children2[$key]);
70 foreach ($Children2 as $key => $Child2) {
71 if ($Child1[
'fuzzynameext'] == $Child2[
'fuzzynameext']) {
72 $Master[$row][1] = $Child1;
73 $Master[$row][2] = $Child2;
74 unset($Children2[$key]);
83 foreach ($Children2 as $key => $Child2) {
84 if (levenshtein($Child1[
'fuzzynameext'], $Child2[
'fuzzynameext']) == 1) {
85 $Master[$row][1] = $Child1;
86 $Master[$row][2] = $Child2;
87 unset($Children2[$key]);
96 foreach ($Children2 as $key => $Child2) {
97 if ($Child1[
'fuzzyname'] == $Child2[
'fuzzyname']) {
98 $Master[$row][1] = $Child1;
99 $Master[$row][2] = $Child2;
100 unset($Children2[$key]);
109 $Master[$row][1] = $Child1;
110 $Master[$row][2] = array();
116 foreach ($Children2 as $Child) {
118 $Master[$row][1] =
'';
119 $Master[$row][2] = $Child;
123 usort($Master,
"FuzzyCmp");
142 function FileList(&$Master, $agent_pk1, $agent_pk2, $filter, $plugin, $uploadtree_pk1, $uploadtree_pk2)
146 $ModLicView = &$Plugins[plugin_find_id(
"view-license")];
148 if (! empty($Master)) {
149 foreach ($Master as &$MasterRow) {
150 if (! empty($MasterRow[1])) {
151 $MasterRow[1][
"linkurl"] =
GetDiffLink($MasterRow, 1, $agent_pk1,
152 $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2);
155 if (! empty($MasterRow[2])) {
156 $MasterRow[2][
"linkurl"] =
GetDiffLink($MasterRow, 2, $agent_pk2,
157 $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2);
178 function GetDiffLink($MasterRow, $side, $agent_pk, $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2)
183 $OppositeItem = $uploadtree_pk2;
186 $OppositeItem = $uploadtree_pk1;
189 $OppositeChild = $MasterRow[$OppositeSide];
190 $Child = $MasterRow[$side];
193 if (empty($OppositeChild)) {
194 $OppositeParm =
"&item{$OppositeSide}=$OppositeItem";
196 $OppositeParm =
"&item{$OppositeSide}=$OppositeChild[uploadtree_pk]";
199 $IsDir =
Isdir($Child[
'ufile_mode']);
203 if (! empty($Child[
'pfile_fk']) && ! empty($ModLicView)) {
205 $LinkUri .=
"?mod=view-license&napk=$agent_pk&upload=$Child[upload_fk]&item=$Child[uploadtree_pk]";
212 $Container_uploadtree_pk = $Child[
'uploadtree_pk'];
213 $LicUri =
"?mod=$plugin->Name&item{$side}=$Child[uploadtree_pk]{$OppositeParm}&col=$side";
214 if (! empty($filter)) {
215 $LicUri .=
"&filter=$filter";
225 $Flink =
"<a href='$LicUri'>";
229 }
else if (! empty($LinkUri)) {
230 $Flink .=
"<a href='$LinkUri'>";
233 $Flink .= $Child[
'ufile_name'];
261 $sql =
"SELECT ufile_name FROM uploadtree WHERE uploadtree_pk = $A_pk";
264 $row = pg_fetch_assoc($result);
265 $AName = $row[
"ufile_name"];
266 pg_free_result($result);
268 $APhon = metaphone($AName);
274 $sql =
"SELECT uploadtree_pk, ufile_name FROM uploadtree WHERE parent = $B_pk";
279 while ($row = pg_fetch_assoc($result)) {
280 $ChildName = $row[
"ufile_name"];
281 $ChildPhon = metaphone($ChildName);
282 $PhonDist = levenshtein($APhon, $ChildPhon);
283 if ($PhonDist < $BestDist) {
284 $BestDist = $PhonDist;
285 $BestPk = $row[
'uploadtree_pk'];
288 pg_free_result($result);
306 foreach ($Children as $key1 => &$Child) {
308 if (strstr($Child[
'ufile_name'],
".") !==
false) {
310 $ExtLen = strlen($Ext);
311 $NoExtName = substr($Child[
'ufile_name'], 0, - 1 * $ExtLen);
313 $NoExtName = $Child[
'ufile_name'];
316 $NoNumbName = preg_replace(
'/([0-9]|\.|-|_)/',
"", $NoExtName);
317 $NoNumbNameext = preg_replace(
'/([0-9]|\.|-|_)/',
"", $Child[
'ufile_name']);
318 $Child[
'fuzzyname'] = $NoNumbName;
319 $Child[
'fuzzynameext'] = $NoNumbName;
338 if ((count($Path1) < 1) || (count($Path2) < 1)) {
339 return "No path specified";
341 $filter_clause = (empty($filter)) ?
"" :
"&filter=$filter";
342 $Path = ($Column == 1) ? $Path1 : $Path2;
343 $Last = $Path[count($Path)-1];
346 $V =
"<div style='border: double gray; background-color:lightyellow'>\n";
350 $V .=
"<b>$text</b>: ";
355 $text = _(
"Freeze path");
356 $id =
"Freeze{$Column}";
357 $alt = _(
"Freeze this path so that selecting a new directory in the other path will not change this one.");
358 $Options =
"id='$id' onclick='Freeze(\"$Column\")' title='$alt'";
359 $FreezeBtn =
"<button type='button' $Options> $text </button>\n";
361 for ($i = 0; $i < count($List); $i ++) {
362 $Folder = $List[$i][
'folder_pk'];
363 $FolderName = htmlentities($List[$i][
'folder_name']);
364 $V .=
"<b>$FolderName/</b> ";
368 $V .=
" $FreezeBtn";
372 for ($PathLev = 0; $PathLev < count($Path); $PathLev ++) {
373 $PathElt1 = @$Path1[$PathLev];
374 $PathElt2 = @$Path2[$PathLev];
376 $PathElt = ($Column == 1) ? $PathElt1 : $PathElt2;
378 $UseHref = (! empty($PathElt1) && (! empty($PathElt2)));
379 if ($UseHref && ($PathElt != $Last)) {
380 $href =
"$Uri2&item1=$PathElt1[uploadtree_pk]&item2=$PathElt2[uploadtree_pk]{$filter_clause}&col=$Column";
381 $V .=
"<a href='$href'>";
386 $V .=
" <b>" . $PathElt[
'ufile_name'] .
"/</b>";
387 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)
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN