24 use Symfony\Component\HttpFoundation\RedirectResponse;
25 use Symfony\Component\HttpFoundation\Request;
26 use Symfony\Component\HttpFoundation\Response;
36 protected $optionName;
38 protected $ajaxAction;
44 protected $copyrightDao;
48 protected $highlightRenderer;
50 protected $decisionTypes;
52 protected $decisionTableName;
58 protected $highlightTypeToStringMap;
60 protected $typeToHighlightTypeMap;
62 protected $skipOption;
66 function __construct($name, $params)
68 $mergedParams = array_merge($params, array(self::DEPENDENCIES=>array(
"browse",
"view"),
71 parent::__construct($name, $mergedParams);
72 $this->agentName = $this->tableName;
74 $this->uploadDao = $this->
getObject(
'dao.upload');
75 $this->copyrightDao = $this->
getObject(
'dao.copyright');
76 $this->agentDao = $this->
getObject(
'dao.agent');
77 $this->highlightRenderer = $this->
getObject(
'view.highlight_renderer');
78 $this->decisionTypes = $this->
getObject(
'decision.types');
85 protected function handle(Request $request)
88 $uploadId = intval($request->get(
'upload'));
89 $uploadTreeId = intval($request->get(
'item'));
90 if (empty($uploadTreeId) || empty($uploadId)) {
91 $text = _(
"Empty Input");
92 $vars[
'message']=
"<h2>$text</h2>";
97 $text = _(
"Permission Denied");
98 $vars[
'message']=
"<h2>$text</h2>";
102 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
103 $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId, $uploadTreeTableName);
104 if (
Isdir($uploadEntry[
'ufile_mode']) ||
Iscontainer($uploadEntry[
'ufile_mode'])) {
105 $parent = $this->uploadDao->getUploadParent($uploadEntry[
'upload_fk']);
106 if (!isset($parent)) {
110 $uploadTree = $this->uploadDao->getNextItem($uploadEntry[
'upload_fk'], $parent);
111 if ($uploadTree === UploadDao::NOT_FOUND) {
114 $uploadTreeId = $uploadTree->getId();
118 if (empty($uploadTreeId)) {
122 $copyrightDecisionMap = $this->decisionTypes->getMap();
123 $vars[
'micromenu'] =
Dir2Browse($this->modBack, $uploadTreeId, NULL, $showBox = 0,
"View", -1,
'',
'', $uploadTreeTableName);
128 if (!empty($lastItem) && $changed ==
"true") {
129 $lastUploadEntry = $this->uploadDao->getUploadEntry($lastItem, $uploadTreeTableName);
135 if (empty($clearingType) || empty($textFinding)) {
136 if (empty($clearingType)) {
137 $text = _(
"The clearing type cannot be empty. " .
138 "Please choose a value and submit again.");
140 $text = _(
"The text finding cannot be empty. " .
141 "Please enter a text and submit again.");
143 $vars[
'message']=
"<strong>$text</strong>";
145 $this->copyrightDao->saveDecision($this->decisionTableName,
146 $lastUploadEntry[
'pfile_fk'], $userId , $clearingType, $description,
147 $textFinding, $comment, $decision_pk);
151 $scanJobProxy =
new ScanJobProxy($this->agentDao, $uploadId);
152 if ($this->agentName ==
"copyright") {
153 $scanJobProxy->createAgentStatus(array($this->agentName,
'reso'));
155 $scanJobProxy->createAgentStatus(array($this->agentName));
157 $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds();
158 $highlights = array();
159 if (array_key_exists(
'reso', $selectedScanners)) {
160 $latestXpAgentId[] = $selectedScanners[
'reso'];
162 if (array_key_exists($this->agentName, $selectedScanners)) {
163 $latestXpAgentId[] = $selectedScanners[$this->agentName];
164 $highlights = $this->copyrightDao->getHighlights($uploadTreeId, $this->tableName, $latestXpAgentId, $this->typeToHighlightTypeMap);
167 if (count($highlights) < 1) {
168 $vars[
'message'] = _(
"No ").$this->tableName ._(
" data is available for this file.");
173 $theView = $view->getView(
null,
null, $showHeader=0,
"", $highlights,
false,
true);
174 list($pageMenu, $textView) = $theView;
176 $decisions = $this->copyrightDao->getDecisions($this->decisionTableName, $uploadEntry[
'pfile_fk']);
178 $vars[
'agentName'] = $this->agentName;
179 $vars[
'decisions'] = $decisions;
180 $vars[
'decisionsTable'] = $this->decisionTableName;
181 $vars[
'itemId'] = $uploadTreeId;
182 $vars[
'uploadId'] = $uploadId;
183 $vars[
'pfile'] = $uploadEntry[
'pfile_fk'];
184 $vars[
'pageMenu'] = $pageMenu;
185 $vars[
'textView'] = $textView;
188 $vars[
'optionName'] = $this->optionName;
189 $vars[
'formName'] =
"CopyRightForm";
190 $vars[
'ajaxAction'] = $this->ajaxAction;
191 $vars[
'skipOption'] =$this->skipOption;
192 $vars[
'clearingTypes'] = $copyrightDecisionMap;
193 $vars[
'xptext'] = $this->xptext;
195 $agentId = strval($request->get(
"agent"));
196 $vars = array_merge($vars,$this->
additionalVars($uploadId, $uploadTreeId, $agentId));
220 $allVars[
'styles'] .=
"<link rel='stylesheet' href='css/highlights.css'>\n";
231 $vars[
'content'] =
'This upload contains no files!<br><a href="' .
Traceback_uri() .
'?mod=browse">Go back to browse view</a>';
232 return $this->
render(
"include/base.html.twig",$vars);
241 $output = _(
"file text");
242 foreach ($this->highlightTypeToStringMap as $colorKey => $txt) {
243 $output .=
'<br/>' . $this->highlightRenderer->createStartSpan($colorKey, $txt) . $txt .
'</span>';
254 $tooltipText = _(
"Copyright/Email/Url/Author");
255 menu_insert(
"Browse-Pfile::Copyright/Email/Url", 0,
'copyright-view', $tooltipText);
258 $textFormat = $this->microMenu->getFormatParameter($itemId);
260 $this->microMenu->addFormatMenuEntries($textFormat, $pageNumber);
264 if (!empty($itemId) && !empty($uploadId)) {
265 $menuText =
"Copyright/Email/Url/Author";
267 $tooltipText = _(
"View Copyright/Email/Url/Author info");
269 $this->microMenu->insert(MicroMenu::TARGET_DEFAULT, $menuText, $menuPosition, $this->
getName(), $URI, $tooltipText);
272 if (!empty($licId)) {
responseBad($vars=array())
Call on bad uploads.
legendBox()
Create legend box.
RegisterMenus()
Customize submenus.
additionalVars($uploadId, $uploadTreeId, $agentId)
Get additional variables for a give item.
Contains the constants and helpers for authentication of user.
static getUserId()
Get the current user's id.
static getGroupId()
Get the current user's group id.
render($templateName, $vars=null, $headers=null)
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.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
char * trim(char *ptext)
Trimming whitespace.
Namespace for Copyright agent's UI components.