/** * @param int $uploadTreeId * @param int $Folder * @param int $Upload * @return string */ function outputItemHtml($uploadTreeId, $Folder, $Upload) { global $container; $dbManager = $container->get('db.manager'); $show = 'quick'; $html = ''; $uploadtree_tablename = ""; if (!empty($uploadTreeId)) { $sql = "SELECT ufile_mode, upload_fk FROM uploadtree WHERE uploadtree_pk = \$1"; $row = $dbManager->getSingleRow($sql, array($uploadTreeId)); $Upload = $row['upload_fk']; if (!$this->uploadDao->isAccessible($Upload, Auth::getGroupId())) { $this->vars['message'] = _("Permission Denied"); return $this->render('include/base.html.twig'); } if (!Iscontainer($row['ufile_mode'])) { global $Plugins; $View =& $Plugins[plugin_find_id("view")]; if (!empty($View)) { $this->vars['content'] = $View->ShowView(NULL, "browse"); return $this->render('include/base.html.twig'); } } $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($row['upload_fk']); $html .= Dir2Browse($this->Name, $uploadTreeId, NULL, 1, "Browse", -1, '', '', $uploadtree_tablename) . "\n"; } else { if (!empty($Upload)) { $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($Upload); $html .= Dir2BrowseUpload($this->Name, $Upload, NULL, 1, "Browse", $uploadtree_tablename) . "\n"; } } if (empty($Upload)) { $this->vars['show'] = $show; $this->ShowFolder($Folder); return $html; } if (empty($uploadTreeId)) { try { $uploadTreeId = $this->uploadDao->getUploadParent($Upload); } catch (Exception $e) { $this->vars['message'] = $e->getMessage(); return $this->render('include/base.html.twig'); } } $html .= $this->ShowItem($Upload, $uploadTreeId, $show, $Folder, $uploadtree_tablename); $this->vars['content'] = $html; return $this->render('include/base.html.twig'); }
/** * \brief This function returns the output html */ function Output() { global $PG_CONN; global $Plugins; if ($this->State != PLUGIN_STATE_READY) { return 0; } $V = ""; $folder_pk = GetParm("folder", PARM_INTEGER); $Upload = GetParm("upload", PARM_INTEGER); // upload_pk to browse $Item = GetParm("item", PARM_INTEGER); // uploadtree_pk to browse /* check permission if $Upload is given */ if (!empty($Upload)) { $UploadPerm = GetUploadPerm($Upload); if ($UploadPerm < PERM_READ) { $text = _("Permission Denied"); echo "<h2>{$text}<h2>"; return; } } /* kludge for plugins not supplying a folder parameter. * Find what folder this upload is in. Error if in multiple folders. */ if (empty($folder_pk)) { if (empty($Upload)) { $folder_pk = GetUserRootFolder(); } else { /* Make sure the upload record exists */ $sql = "select upload_pk from upload where upload_pk={$Upload}"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); if (pg_num_rows($result) < 1) { echo "This upload no longer exists on this system."; return; } $sql = "select parent_fk from foldercontents where child_id={$Upload} and foldercontents_mode=2"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); if (pg_num_rows($result) > 1) { Fatal("Upload {$Upload} found in multiple folders.", __FILE__, __LINE__); } if (pg_num_rows($result) < 1) { Fatal("Upload {$Upload} missing from foldercontents.", __FILE__, __LINE__); } $row = pg_fetch_assoc($result); $folder_pk = $row['parent_fk']; pg_free_result($result); } } $Folder = $folder_pk; $Show = 'detail'; // always use detail switch ($this->OutputType) { case "XML": break; case "HTML": /************************/ /* Show the folder path */ /************************/ $uploadtree_tablename = ""; if (!empty($Item)) { /* Make sure the item is not a file */ $sql = "SELECT ufile_mode, upload_fk FROM uploadtree WHERE uploadtree_pk = '{$Item}';"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $row = pg_fetch_assoc($result); pg_free_result($result); $Upload = $row['upload_fk']; $UploadPerm = GetUploadPerm($Upload); if ($UploadPerm < PERM_READ) { $text = _("Permission Denied"); echo "<h2>{$text}<h2>"; return; } if (!Iscontainer($row['ufile_mode'])) { /* Not a container! */ $View =& $Plugins[plugin_find_id("view")]; if (!empty($View)) { return $View->ShowView(NULL, "browse"); } } $V .= "<font class='text'>\n"; $uploadtree_tablename = GetUploadtreeTableName($row['upload_fk']); $V .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse", -1, '', '', $uploadtree_tablename) . "\n"; } else { if (!empty($Upload)) { $V .= "<font class='text'>\n"; $uploadtree_tablename = GetUploadtreeTableName($Upload); $V .= Dir2BrowseUpload($this->Name, $Upload, NULL, 1, "Browse", $uploadtree_tablename) . "\n"; } else { $V .= "<font class='text'>\n"; } } /******************************/ /* Get the folder description */ /******************************/ if (!empty($Upload)) { if (empty($Item)) { $sql = "select uploadtree_pk from uploadtree\n where parent is NULL and upload_fk={$Upload} "; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); if (pg_num_rows($result)) { $row = pg_fetch_assoc($result); $Item = $row['uploadtree_pk']; } else { $text = _("Missing upload tree parent for upload"); $V .= "<hr><h2>{$text} {$Upload}</h2><hr>"; break; } pg_free_result($result); } $V .= $this->ShowItem($Upload, $Item, $Show, $Folder, $uploadtree_tablename); } else { $V .= $this->ShowFolder($Folder, $Show); } $V .= "</font>\n"; break; case "Text": break; default: break; } if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }