36 $key1 = empty($Master1[1]) ? 2 : 1;
37 $str1 = $Master1[$key1][
'fuzzyname'];
38 $key2 = empty($Master2[1]) ? 2 : 1;
39 $str2 = $Master2[$key2][
'fuzzyname'];
40 return strcasecmp($str1, $str2);
63 if (! empty($Children1) && (! empty($Children2))) {
64 foreach ($Children1 as $Child1) {
69 foreach ($Children2 as $key => $Child2) {
70 if ($Child1[
'ufile_name'] == $Child2[
'ufile_name']) {
71 $Master[$row][1] = $Child1;
72 $Master[$row][2] = $Child2;
73 unset($Children2[$key]);
81 foreach ($Children2 as $key => $Child2) {
82 if ($Child1[
'fuzzynameext'] == $Child2[
'fuzzynameext']) {
83 $Master[$row][1] = $Child1;
84 $Master[$row][2] = $Child2;
85 unset($Children2[$key]);
94 foreach ($Children2 as $key => $Child2) {
95 if (levenshtein($Child1[
'fuzzynameext'], $Child2[
'fuzzynameext']) == 1) {
96 $Master[$row][1] = $Child1;
97 $Master[$row][2] = $Child2;
98 unset($Children2[$key]);
107 foreach ($Children2 as $key => $Child2) {
108 if ($Child1[
'fuzzyname'] == $Child2[
'fuzzyname']) {
109 $Master[$row][1] = $Child1;
110 $Master[$row][2] = $Child2;
111 unset($Children2[$key]);
120 $Master[$row][1] = $Child1;
121 $Master[$row][2] = array();
127 foreach ($Children2 as $Child) {
129 $Master[$row][1] =
'';
130 $Master[$row][2] = $Child;
134 usort($Master,
"FuzzyCmp");
153 function FileList(&$Master, $agent_pk1, $agent_pk2, $filter, $plugin, $uploadtree_pk1, $uploadtree_pk2)
157 $ModLicView = &$Plugins[plugin_find_id(
"view-license")];
159 if (! empty($Master)) {
160 foreach ($Master as &$MasterRow) {
161 if (! empty($MasterRow[1])) {
162 $MasterRow[1][
"linkurl"] =
GetDiffLink($MasterRow, 1, $agent_pk1,
163 $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2);
166 if (! empty($MasterRow[2])) {
167 $MasterRow[2][
"linkurl"] =
GetDiffLink($MasterRow, 2, $agent_pk2,
168 $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2);
189 function GetDiffLink($MasterRow, $side, $agent_pk, $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2)
194 $OppositeItem = $uploadtree_pk2;
197 $OppositeItem = $uploadtree_pk1;
200 $OppositeChild = $MasterRow[$OppositeSide];
201 $Child = $MasterRow[$side];
204 if (empty($OppositeChild)) {
205 $OppositeParm =
"&item{$OppositeSide}=$OppositeItem";
207 $OppositeParm =
"&item{$OppositeSide}=$OppositeChild[uploadtree_pk]";
210 $IsDir =
Isdir($Child[
'ufile_mode']);
214 if (! empty($Child[
'pfile_fk']) && ! empty($ModLicView)) {
216 $LinkUri .=
"?mod=view-license&napk=$agent_pk&upload=$Child[upload_fk]&item=$Child[uploadtree_pk]";
223 $Container_uploadtree_pk = $Child[
'uploadtree_pk'];
224 $LicUri =
"?mod=$plugin->Name&item{$side}=$Child[uploadtree_pk]{$OppositeParm}&col=$side";
225 if (! empty($filter)) {
226 $LicUri .=
"&filter=$filter";
236 $Flink =
"<a href='$LicUri'>";
240 }
else if (! empty($LinkUri)) {
241 $Flink .=
"<a href='$LinkUri'>";
244 $Flink .= $Child[
'ufile_name'];
272 $sql =
"SELECT ufile_name FROM uploadtree WHERE uploadtree_pk = $A_pk";
273 $result = pg_query($PG_CONN, $sql);
275 $row = pg_fetch_assoc($result);
276 $AName = $row[
"ufile_name"];
277 pg_free_result($result);
279 $APhon = metaphone($AName);
285 $sql =
"SELECT uploadtree_pk, ufile_name FROM uploadtree WHERE parent = $B_pk";
286 $result = pg_query($PG_CONN, $sql);
290 while ($row = pg_fetch_assoc($result)) {
291 $ChildName = $row[
"ufile_name"];
292 $ChildPhon = metaphone($ChildName);
293 $PhonDist = levenshtein($APhon, $ChildPhon);
294 if ($PhonDist < $BestDist) {
295 $BestDist = $PhonDist;
296 $BestPk = $row[
'uploadtree_pk'];
299 pg_free_result($result);
317 foreach ($Children as $key1 => &$Child) {
319 if (strstr($Child[
'ufile_name'],
".") !==
false) {
321 $ExtLen = strlen($Ext);
322 $NoExtName = substr($Child[
'ufile_name'], 0, - 1 * $ExtLen);
324 $NoExtName = $Child[
'ufile_name'];
327 $NoNumbName = preg_replace(
'/([0-9]|\.|-|_)/',
"", $NoExtName);
328 $NoNumbNameext = preg_replace(
'/([0-9]|\.|-|_)/',
"", $Child[
'ufile_name']);
329 $Child[
'fuzzyname'] = $NoNumbName;
330 $Child[
'fuzzynameext'] = $NoNumbName;
349 if ((count($Path1) < 1) || (count($Path2) < 1)) {
350 return "No path specified";
352 $filter_clause = (empty($filter)) ?
"" :
"&filter=$filter";
353 $Path = ($Column == 1) ? $Path1 : $Path2;
354 $Last = $Path[count($Path)-1];
357 $V =
"<div style='border: double gray; background-color:lightyellow'>\n";
361 $V .=
"<b>$text</b>: ";
366 $text = _(
"Freeze path");
367 $id =
"Freeze{$Column}";
368 $alt = _(
"Freeze this path so that selecting a new directory in the other path will not change this one.");
369 $Options =
"id='$id' onclick='Freeze(\"$Column\")' title='$alt'";
370 $FreezeBtn =
"<button type='button' $Options> $text </button>\n";
372 for ($i = 0; $i < count($List); $i ++) {
373 $Folder = $List[$i][
'folder_pk'];
374 $FolderName = htmlentities($List[$i][
'folder_name']);
375 $V .=
"<b>$FolderName/</b> ";
379 $V .=
" $FreezeBtn";
383 for ($PathLev = 0; $PathLev < count($Path); $PathLev ++) {
384 $PathElt1 = @$Path1[$PathLev];
385 $PathElt2 = @$Path2[$PathLev];
387 $PathElt = ($Column == 1) ? $PathElt1 : $PathElt2;
389 $UseHref = (! empty($PathElt1) && (! empty($PathElt2)));
390 if ($UseHref && ($PathElt != $Last)) {
391 $href =
"$Uri2&item1=$PathElt1[uploadtree_pk]&item2=$PathElt2[uploadtree_pk]{$filter_clause}&col=$Column";
392 $V .=
"<a href='$href'>";
397 $V .=
" <b>" . $PathElt[
'ufile_name'] .
"/</b>";
398 if ($UseHref && ($PathElt != $Last)) {
FuzzyName(&$Children)
Add fuzzyname and fuzzynameext to $Children.
Traceback_uri()
Get the URI without query to this location.
FolderGetFromUpload($Uploadpk, $Folder=-1, $Stop=-1)
DEPRECATED! Given an upload number, return the folder path in an array containing folder_pk and name...
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 ...
FuzzyCmp($Master1, $Master2)
FuzzyName comparison function for diff tools.
MakeMaster($Children1, $Children2)
Generate the master array with aligned children.
DirGetNonArtifact($UploadtreePk, $uploadtree_tablename='uploadtree')
Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk)...
FileList(&$Master, $agent_pk1, $agent_pk2, $filter, $plugin, $uploadtree_pk1, $uploadtree_pk2)
Adds the element linkurl to the $Master elements.
GetDiffLink($MasterRow, $side, $agent_pk, $filter, $plugin, $ModLicView, $uploadtree_pk1, $uploadtree_pk2)
Generate the link for one side of a diff element.
GetFileExt($fname)
Get File Extension (text after last period)
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Dir2BrowseDiff($Path1, $Path2, $filter, $Column, $plugin)
Return a string which is a linked path to the file.