47 protected $optionName;
49 protected $ajaxAction;
55 protected $copyrightDao;
59 protected $highlightRenderer;
61 protected $decisionTypes;
63 protected $decisionTableName;
69 protected $highlightTypeToStringMap;
71 protected $typeToHighlightTypeMap;
73 protected $skipOption;
77 function __construct($name, $params)
79 $mergedParams = array_merge($params, array(self::DEPENDENCIES=>array(
"browse",
"view"),
82 parent::__construct($name, $mergedParams);
83 $this->agentName = $this->tableName;
85 $this->uploadDao = $this->
getObject(
'dao.upload');
86 $this->copyrightDao = $this->
getObject(
'dao.copyright');
87 $this->agentDao = $this->
getObject(
'dao.agent');
88 $this->highlightRenderer = $this->
getObject(
'view.highlight_renderer');
89 $this->decisionTypes = $this->
getObject(
'decision.types');
96 protected function handle(Request $request)
99 $uploadId = intval($request->get(
'upload'));
100 $uploadTreeId = intval($request->get(
'item'));
101 if (empty($uploadTreeId) || empty($uploadId))
103 $text = _(
"Empty Input");
104 $vars[
'message']=
"<h2>$text</h2>";
109 $text = _(
"Permission Denied");
110 $vars[
'message']=
"<h2>$text</h2>";
114 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
115 $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId, $uploadTreeTableName);
116 if (
Isdir($uploadEntry[
'ufile_mode']) ||
Iscontainer($uploadEntry[
'ufile_mode']))
118 $parent = $this->uploadDao->getUploadParent($uploadEntry[
'upload_fk']);
124 $uploadTree = $this->uploadDao->getNextItem($uploadEntry[
'upload_fk'], $parent);
125 if ($uploadTree === UploadDao::NOT_FOUND)
129 $uploadTreeId = $uploadTree->getId();
133 if (empty($uploadTreeId))
138 $copyrightDecisionMap = $this->decisionTypes->getMap();
139 $vars[
'micromenu'] =
Dir2Browse($this->modBack, $uploadTreeId, NULL, $showBox = 0,
"View", -1,
'',
'', $uploadTreeTableName);
144 if (!empty($lastItem) && $changed ==
"true")
146 $lastUploadEntry = $this->uploadDao->getUploadEntry($lastItem, $uploadTreeTableName);
152 if (empty($clearingType) || empty($textFinding)) {
153 if (empty($clearingType)) {
154 $text = _(
"The clearing type cannot be empty. " .
155 "Please choose a value and submit again.");
157 $text = _(
"The text finding cannot be empty. " .
158 "Please enter a text and submit again.");
160 $vars[
'message']=
"<strong>$text</strong>";
162 $this->copyrightDao->saveDecision($this->decisionTableName,
163 $lastUploadEntry[
'pfile_fk'], $userId , $clearingType, $description,
164 $textFinding, $comment, $decision_pk);
168 $scanJobProxy =
new ScanJobProxy($this->agentDao, $uploadId);
169 $scanJobProxy->createAgentStatus(array($this->agentName));
170 $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds();
171 $highlights = array();
172 if(array_key_exists($this->agentName, $selectedScanners))
174 $latestXpAgentId = $selectedScanners[$this->agentName];
175 $highlights = $this->copyrightDao->getHighlights($uploadTreeId, $this->tableName, $latestXpAgentId, $this->typeToHighlightTypeMap);
178 if (count($highlights) < 1)
180 $vars[
'message'] = _(
"No ").$this->tableName ._(
" data is available for this file.");
185 $theView = $view->getView(null, null, $showHeader=0,
"", $highlights,
false,
true);
186 list($pageMenu, $textView) = $theView;
188 $decisions = $this->copyrightDao->getDecisions($this->decisionTableName, $uploadEntry[
'pfile_fk']);
190 $vars[
'agentName'] = $this->agentName;
191 $vars[
'decisions'] = $decisions;
192 $vars[
'decisionsTable'] = $this->decisionTableName;
193 $vars[
'itemId'] = $uploadTreeId;
194 $vars[
'uploadId'] = $uploadId;
195 $vars[
'pfile'] = $uploadEntry[
'pfile_fk'];
196 $vars[
'pageMenu'] = $pageMenu;
197 $vars[
'textView'] = $textView;
200 $vars[
'optionName'] = $this->optionName;
201 $vars[
'formName'] =
"CopyRightForm";
202 $vars[
'ajaxAction'] = $this->ajaxAction;
203 $vars[
'skipOption'] =$this->skipOption;
204 $vars[
'clearingTypes'] = $copyrightDecisionMap;
205 $vars[
'xptext'] = $this->xptext;
207 $agentId = intval($request->get(
"agent"));
208 $vars = array_merge($vars,$this->
additionalVars($uploadId, $uploadTreeId, $agentId));
232 $allVars[
'styles'] .=
"<link rel='stylesheet' href='css/highlights.css'>\n";
243 $vars[
'content'] =
'This upload contains no files!<br><a href="' .
Traceback_uri() .
'?mod=browse">Go back to browse view</a>';
244 return $this->
render(
"include/base.html.twig",$vars);
253 $output = _(
"file text");
254 foreach ($this->highlightTypeToStringMap as $colorKey => $txt)
256 $output .=
'<br/>' . $this->highlightRenderer->createStartSpan($colorKey, $txt) . $txt .
'</span>';
267 $tooltipText = _(
"Copyright/Email/Url/Author");
268 menu_insert(
"Browse-Pfile::Copyright/Email/Url", 0,
'copyright-view', $tooltipText);
271 $textFormat = $this->microMenu->getFormatParameter($itemId);
273 $this->microMenu->addFormatMenuEntries($textFormat, $pageNumber);
277 if (!empty($itemId) && !empty($uploadId))
279 $menuText =
"Copyright/Email/Url/Author";
281 $tooltipText = _(
"View Copyright/Email/Url/Author info");
283 $this->microMenu->insert(MicroMenu::TARGET_DEFAULT, $menuText, $menuPosition, $this->
getName(), $URI, $tooltipText);
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.
static getUserId()
Get the current user's id.
responseBad($vars=array())
Call on bad uploads.
render($templateName, $vars=null, $headers=null)
Namespace for Copyright agent's UI components.
RegisterMenus()
Customize submenus.
legendBox()
Create legend box.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
additionalVars($uploadId, $uploadTreeId, $agentId)
Get additional variables for a give item.
static getGroupId()
Get the current user's group id.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
char * trim(char *ptext)
Trimming whitespace.