/** * \brief This function returns the FOSSology logo and * Folder Navigation bar */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return 0; } $V = ""; global $Plugins; switch ($this->OutputType) { case "XML": break; case "HTML": /* Load the logo image */ $Uri = Traceback_uri(); $V .= "<center><a href='http://fossology.org' target='_top'><img alt='FOSSology' title='FOSSology' src='{$Uri}images/fossology-logo.gif' align=absmiddle border=0></a></center><br>\n"; $V .= FolderListScript(); $V .= "<small><center>"; $text = _("Expand"); $V .= "<a href='javascript:Expand();'>{$text}</a> |"; $text = _("Collapse"); $V .= "<a href='javascript:Collapse();'>{$text}</a> |"; $text = _("Refresh"); $V .= "<a href='" . Traceback() . "'>{$text}</a>"; $V .= "</center></small>"; $V .= "<P>\n"; /* Display the tree */ $V .= "<form>\n"; $V .= FolderListDiv(-1, 0); $V .= "</form>\n"; break; case "Text": break; default: break; } if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
/** * \brief Given a Folder_pk, list every upload in the folder. */ function ShowFolder($Folder, $Show) { global $Plugins; global $PG_CONN; $V = ""; /* Get list of uploads in this folder */ $sql = "SELECT * FROM upload\n INNER JOIN uploadtree ON upload_fk = upload_pk\n AND upload.pfile_fk = uploadtree.pfile_fk\n AND parent IS NULL\n AND lft IS NOT NULL \n WHERE upload_pk IN\n (SELECT child_id FROM foldercontents WHERE foldercontents_mode & 2 != 0 AND parent_fk = {$Folder})\n ORDER BY upload_filename,upload_desc,upload_pk,upload_origin;"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $Uri = Traceback_uri() . "?mod=" . $this->Name; $V .= "<table border=1 width='100%'>"; $V .= "<tr><td valign='top' width='20%'>\n"; $V .= FolderListScript(); $text = _("Folder Navigation"); $V .= "<center><H3>{$text}</H3></center>\n"; $V .= "<center><small>"; if ($Folder != GetUserRootFolder()) { $text = _("Top"); $V .= "<a href='" . Traceback_uri() . "?mod=" . $this->Name . "'>{$text}</a> |"; } $text = _("Expand"); $V .= "<a href='javascript:Expand();'>{$text}</a> |"; $text = _("Collapse"); $V .= "<a href='javascript:Collapse();'>{$text}</a> |"; $text = _("Refresh"); $V .= "<a href='" . Traceback() . "'>{$text}</a>"; $V .= "</small></center>"; $V .= "<P>\n"; $V .= "<form>\n"; $V .= FolderListDiv($Folder, 0, $Folder, 1); $V .= "</form>\n"; $V .= "</td><td valign='top'>\n"; $text = _("Uploads"); $V .= "<center><H3>{$text}</H3></center>\n"; $V .= "<table class='text' id='browsetbl' border=0 width='100%' cellpadding=0>\n"; $text = _("Upload Name and Description"); $text1 = _("Upload Date"); $V .= "<th>{$text}</th><th>{$text1}</th></tr>\n"; /* Browse-Pfile menu */ $MenuPfile = menu_find("Browse-Pfile", $MenuDepth); /* Browse-Pfile menu without the compare menu item */ $MenuPfileNoCompare = menu_remove($MenuPfile, "Compare"); while ($Row = pg_fetch_assoc($result)) { if (empty($Row['upload_pk'])) { continue; } $Desc = htmlentities($Row['upload_desc']); $UploadPk = $Row['upload_pk']; /* check permission on upload */ $UploadPerm = GetUploadPerm($UploadPk); if ($UploadPerm < PERM_READ) { continue; } $Name = $Row['ufile_name']; if (empty($Name)) { $Name = $Row['upload_filename']; } /* If UploadtreePk is not an artifact, then use it as the root. Else get the first non artifact under it. */ if (Isartifact($Row['ufile_mode'])) { $UploadtreePk = DirGetNonArtifact($Row['uploadtree_pk'], $uploadtree_tablename); } else { $UploadtreePk = $Row['uploadtree_pk']; } $V .= "<tr><td>"; if (IsContainer($Row['ufile_mode'])) { $V .= "<a href='{$Uri}&upload={$UploadPk}&folder={$Folder}&item={$UploadtreePk}&show={$Show}'>"; $V .= "<b>" . $Name . "</b>"; $V .= "</a>"; } else { $V .= "<b>" . $Name . "</b>"; } $V .= "<br>"; if (!empty($Desc)) { $V .= "<i>" . $Desc . "</i><br>"; } $Upload = $Row['upload_pk']; $Parm = "upload={$Upload}&show={$Show}&item=" . $Row['uploadtree_pk']; if (Iscontainer($Row['ufile_mode'])) { $V .= menu_to_1list($MenuPfile, $Parm, " ", " ", 1, $UploadPk); } else { $V .= menu_to_1list($MenuPfileNoCompare, $Parm, " ", " ", 1, $UploadPk); } /* Job queue link */ $text = _("History"); if (plugin_find_id('showjobs') >= 0) { $V .= "<a href='" . Traceback_uri() . "?mod=showjobs&upload={$UploadPk}'>[{$text}]</a>"; $V .= "</td>\n"; $V .= "<td align='right'>" . substr($Row['upload_ts'], 0, 19) . "</td>"; } $V .= "<tr><td colspan=2> </td></tr>\n"; } pg_free_result($result); $V .= "</table>\n"; $V .= "</td></tr>\n"; $V .= "</table>\n"; return $V; }