8 namespace Fossology\SoftwareHeritage\UI;
14 use \Fossology\Lib\Plugin\DefaultPlugin;
16 use Symfony\Component\HttpFoundation\RedirectResponse;
17 use \Symfony\Component\HttpFoundation\Request;
27 public $AgentName =
"agent_softwareHeritage";
29 private $uploadtree_tablename =
"";
52 protected $agentNames = array(
'softwareHeritage' =>
'SH');
54 public function __construct()
56 parent::__construct(self::NAME, array(
57 self::TITLE => _(
"Software Heritage details"),
59 self::REQUIRES_LOGIN =>
false
61 $this->Title = _(
"Software Heritage");
62 $this->dbManeger = $this->container->get(
'db.manager');
63 $this->uploadDao = $this->container->get(
'dao.upload');
64 $this->shDao = $this->container->get(
'dao.softwareHeritage');
65 $this->agentDao = $this->container->get(
'dao.agent');
79 if (empty($Item) || empty($Upload)) {
82 $viewLicenseURI =
"view-license" .
Traceback_parm_keep(array(
"show",
"format",
"page",
"upload",
"item"));
83 $menuName = $this->Title;
89 $text = _(
"Software Heritage");
91 menu_insert(
"View::$menuName", 101, $viewLicenseURI, $text);
92 menu_insert(
"View-Meta::$menuName", 101, $viewLicenseURI, $text);
96 public function handle(Request $request)
98 $upload = intval($request->get(
"upload"));
100 if (!$this->uploadDao->isAccessible($upload, $groupId)) {
101 return $this->flushContent(_(
"Permission Denied"));
103 $item = intval($request->get(
"item"));
105 $vars[
'uploadId'] = $upload;
107 if ($request->get(
'show')==
'quick') {
110 $vars[
'itemId'] = $item;
111 $vars[
'micromenu'] =
Dir2Browse($this->Name, $item, NULL, $showBox = 0,
"Browse", -1,
114 $left = $itemTreeBounds->getLeft();
116 return $this->flushContent(_(
"Job unpack/adj2nest hasn't completed."));
119 if (is_a($histVars,
'Symfony\\Component\\HttpFoundation\\RedirectResponse')) {
122 $vars = array_merge($vars, $histVars);
123 return $this->
render(
"softwareHeritage.html.twig",$this->mergeWithDefault($vars));
134 $agentId = $this->agentDao->getCurrentAgentId(
"softwareHeritage");
137 $scannerAgents = array_keys($this->agentNames);
138 $scanJobProxy =
new ScanJobProxy($this->agentDao, $uploadId);
139 $scannerVars = $scanJobProxy->createAgentStatus($scannerAgents);
140 $agentMap = $scanJobProxy->getAgentMap();
143 'agentId' => $agentId,
144 'agentMap' => $agentMap,
145 'scanners'=>$scannerVars
148 $selectedAgentIds = empty($selectedAgentId) ? $scanJobProxy->getLatestSuccessfulAgentIds() : $agentId;
150 $this->licenseProjector =
new LicenseMap($this->
getObject(
'db.manager'),$groupId,LicenseMap::CONCLUSION,
true);
152 $childCount = $dirVars[
'iTotalRecords'];
162 if ($childCount == 0) {
163 return new RedirectResponse(
"?mod=view-license" .
Traceback_parm_keep(array(
"upload",
"item")));
165 return array_merge($vars, $dirVars);
174 $isFlat = isset($_GET[
'flatten']);
175 $vars[
'isFlat'] = $isFlat;
176 $vars[
'iTotalRecords'] = $this->uploadDao->countNonArtifactDescendants($itemTreeBounds, $isFlat);
177 $uri =
Traceback_uri().
'?mod='.$this->Name.Traceback_parm_keep(array(
'upload',
'folder',
'show',
'item'));
178 $vars[
'fileSwitch'] = $isFlat ? $uri : $uri.
"&flatten=yes";
189 return $this->renderer->load($templateName)->render($vars);
192 register_plugin(
new softwareHeritagePlugin());
char * uploadtree_tablename
upload.uploadtree_tablename
Contains the constants and helpers for authentication of user.
static getGroupId()
Get the current user's group id.
Wrapper class for license map.
render($templateName, $vars=null, $headers=null)
renderString($templateName, $vars)
countFileListing(ItemTreeBounds $itemTreeBounds)
showUploadHist(ItemTreeBounds $itemTreeBounds)
Given an $Uploadtree_pk, display:
RegisterMenus()
Customize submenus.
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
Traceback_uri()
Get the URI without query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.