Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 52d854f

Browse files
author
Charles Ma
committed
ENH: refs #301 Added job related items in item view
Improved "Same folder" list.
1 parent 71ec689 commit 52d854f

File tree

5 files changed

+119
-22
lines changed

5 files changed

+119
-22
lines changed

core/AppController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public function preDispatch()
3939
$this->coreWebroot = $this->view->webroot.'/core';
4040
$this->view->coreWebroot = $this->coreWebroot;
4141

42+
Zend_Registry::set('webroot', $this->view->webroot);
43+
Zend_Registry::set('coreWebroot', $this->view->coreWebroot);
44+
4245
$this->view->demoMode = $this->isDemoMode();
4346

4447
$this->view->title = Zend_Registry::get('configGlobal')->application->name;

core/controllers/ItemController.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ function viewAction()
210210
else
211211
{
212212
$parents = $itemDao->getFolders();
213-
if(isset($this->userSession->recentFolders))
213+
if(count($parents) == 1)
214+
{
215+
$currentFolder = $parents[0];
216+
}
217+
elseif(isset($this->userSession->recentFolders))
214218
{
215219
foreach($parents as $p)
216220
{
@@ -220,11 +224,12 @@ function viewAction()
220224
break;
221225
}
222226
}
223-
if(isset($currentFolder))
224-
{
225-
$items = $this->Folder->getItemsFiltered($currentFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
226-
$this->view->currentFolder = $currentFolder;
227-
}
227+
228+
}
229+
if(isset($currentFolder))
230+
{
231+
$items = $this->Folder->getItemsFiltered($currentFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
232+
$this->view->currentFolder = $currentFolder;
228233
}
229234
}
230235

core/views/item/view.phtml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,6 @@ if($this->preview) // module visualize
208208
<a href='javascript:;' type='item' element='{$this->itemDao->getKey()}' class='uploadRevisionLink' ><img alt='' src='{$this->coreWebroot}/public/images/icons/upload.png'/> {$this->t('Upload new revision')}</a>
209209
</li>
210210
";
211-
$tmp = Zend_Registry::get('notifier')->callback("CALLBACK_REMOTEPROCESSING_IS_EXECUTABLE", array('item' => $this->itemDao));
212-
if(isset($tmp['remoteprocessing']) && $tmp['remoteprocessing'])
213-
{
214-
echo
215-
"<li>
216-
<a href='".$this->webroot."/remoteprocessing/executable/define/?itemId=".$this->itemDao->getKey()."'><img alt='' src='{$this->coreWebroot}/public/images/icons/xml.png'/> {$this->t('Define Executable')}</a>
217-
</li>
218-
";
219-
echo
220-
"<li>
221-
<a href='".$this->webroot."/remoteprocessing/job/manage/?itemId=".$this->itemDao->getKey()."'><img alt='' src='{$this->coreWebroot}/public/images/icons/job.png'/> {$this->t('Manage Processing Jobs')}</a>
222-
</li>
223-
";
224-
}
225211
}
226212
if($this->isAdmin)
227213
{
@@ -241,6 +227,14 @@ if($this->preview) // module visualize
241227
</li>
242228
";
243229
}
230+
$htmltArray = Zend_Registry::get('notifier')->callback("CALLBACK_CORE_ITEM_VIEW_ACTIONMENU", array('item' => $this->itemDao, 'isModerator' => $this->isModerator, 'isAdmin' => $this->isAdmin));
231+
foreach($htmltArray as $html)
232+
{
233+
if(!empty($html))
234+
{
235+
echo $html;
236+
}
237+
}
244238
?>
245239
</ul>
246240
</div>
@@ -279,7 +273,15 @@ if($this->preview) // module visualize
279273
}
280274
?>
281275
</div>
282-
<?php
276+
<?php
277+
$htmltArray = Zend_Registry::get('notifier')->callback("CALLBACK_CORE_ITEM_VIEW_INFO", array('item' => $this->itemDao, 'isModerator' => $this->isModerator, 'isAdmin' => $this->isAdmin));
278+
foreach($htmltArray as $html)
279+
{
280+
if(!empty($html))
281+
{
282+
echo $html;
283+
}
284+
}
283285
if(count($this->sameLocation) > 1)
284286
{?>
285287
<div class='sideElementLast viewSameLocation'>

modules/remoteprocessing/Notification.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public function init()
1616
$this->enableWebAPI($this->moduleName);
1717
$this->addTask("TASK_REMOTEPROCESSING_ADD_JOB", 'addJob', "");
1818
$this->addCallBack('CALLBACK_REMOTEPROCESSING_IS_EXECUTABLE', 'isExecutable');
19+
$this->addCallBack('CALLBACK_CORE_ITEM_VIEW_ACTIONMENU', 'getActionMenu');
20+
$this->addCallBack('CALLBACK_CORE_ITEM_VIEW_INFO', 'getItemInfo');
1921
$this->addCallBack('CALLBACK_REMOTEPROCESSING_EXECUTABLE_RESULTS', 'processProcessingResults');
2022
$this->addCallBack('CALLBACK_REMOTEPROCESSING_ADD_JOB', 'addJob');
2123
}//end init
@@ -38,6 +40,90 @@ public function isExecutable($params)
3840
return false;
3941
}
4042

43+
/** get action menu*/
44+
public function getActionMenu($params)
45+
{
46+
if($this->isExecutable($params) && $params['isModerator'] && $params['item'] instanceof ItemDao)
47+
{
48+
$html = "<li>
49+
<a href='".Zend_Registry::get('webroot')."/remoteprocessing/executable/define/?itemId=".$params['item']->getKey()."'><img alt='' src='".Zend_Registry::get('coreWebroot')."/public/images/icons/xml.png'/> ".$this->t('Define Executable')."</a>
50+
</li>
51+
<li>
52+
<a href='".Zend_Registry::get('webroot')."/remoteprocessing/job/manage/?itemId=".$params['item']->getKey()."'><img alt='' src='".Zend_Registry::get('coreWebroot')."/public/images/icons/job.png'/> ".$this->t('Manage Processing Jobs')."</a>
53+
</li> ";
54+
return $html;
55+
}
56+
return "";
57+
}
58+
59+
/** get action menu*/
60+
public function getItemInfo($params)
61+
{
62+
if($params['item'] instanceof ItemDao)
63+
{
64+
$jobs = $this->Remoteprocessing_Job->getRelatedJob($params['item']);
65+
$items = array();
66+
foreach($jobs as $job)
67+
{
68+
$items = array_merge($items, $job->getItems());
69+
}
70+
71+
Zend_Loader::loadClass('UtilityComponent', BASE_PATH . '/core/controllers/components');
72+
$component = new UtilityComponent();
73+
74+
$html = "<div class='sideElementLast'>
75+
<h1>".$this->t('Related Items')."</h1>
76+
<ul>";
77+
$itemIds = array();
78+
$i = 0;
79+
$nameArrayCurrent = explode('.', $params['item']->getName());
80+
foreach($items as $item)
81+
{
82+
$nameArrayItem = explode('.', $item->getName());
83+
// remove doublons
84+
if(in_array($item->getKey(), $itemIds))
85+
{
86+
continue;
87+
}
88+
$itemIds[] = $item->getKey();
89+
90+
//policy check
91+
if(!$this->Item->policyCheck($item, $this->userSession->Dao))
92+
{
93+
continue;
94+
}
95+
// don't show current item
96+
if($params['item']->getKey() == $item->getKey())
97+
{
98+
continue;
99+
}
100+
// don't show related results
101+
if($nameArrayCurrent[0] == $nameArrayItem[0] && end($nameArrayItem) == end($nameArrayCurrent))
102+
{
103+
continue;
104+
}
105+
106+
$html .= "<li>";
107+
$html .= "<a element='".$item->getKey()."' href='".Zend_Registry::get('webroot')."/item/".$item->getKey()."'>".$component->slicename($item->getName(),25)."</a>";
108+
$html .= "</li>";
109+
if($i > 10)
110+
{
111+
$html .= "<li>...</li>";
112+
break;
113+
}
114+
$i++;
115+
}
116+
if($i == 0)
117+
{
118+
return "";
119+
}
120+
$html .= "</ul>";
121+
$html .= "</div>";
122+
return $html;
123+
}
124+
return "";
125+
}
126+
41127
/** Process results*/
42128
public function processProcessingResults($params)
43129
{
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Statistics;Statistiques
2-
Define Executable;D�finir l'�x�cutable
2+
Define Executable;D�finir l'�x�cutable
3+
Related Items;Documents li�s

0 commit comments

Comments
 (0)