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

Commit 25b2ee0

Browse files
committed
ENH: refs #0339. Use callback to add item action menu link for statistics
1 parent 8f7920d commit 25b2ee0

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif()
2323
#-----------------------------------------------------------------------------
2424
# Drop all tables from the testing DB
2525
# Then re-install the DB, set a Default assetstore, and install all modules
26-
26+
message(STATUS "Setting up database for module testing, please wait...")
2727
execute_process(
2828
COMMAND ${PHP} ${CMAKE_CURRENT_SOURCE_DIR}/tests/DatabaseSetup.php
2929
RESULT_VARIABLE databaseSetup_RESULT
@@ -35,6 +35,7 @@ if(${databaseSetup_RESULT})
3535
message(FATAL_ERROR "DatabaseSetup error: ${databaseSetup_ERR}")
3636
endif()
3737

38+
message(STATUS "Database setup is complete")
3839

3940
#-----------------------------------------------------------------------------
4041
# This should be at the top level for warning suppression

core/views/item/view.phtml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ if($this->preview) // module visualize
111111
<table style='display:block;' id="metadataTable" class="midasTree">
112112
<thead>
113113
<tr>
114-
<th ><?php echo $this->t('Element');?></th>
115-
<th ><?php echo $this->t('Qualifier');?></th>
116-
<th ><?php echo $this->t('Value');?></th>
114+
<th class='elementHeader'><?php echo $this->t('Element');?></th>
115+
<th class='qualifierHeader'><?php echo $this->t('Qualifier');?></th>
116+
<th class='valueHeader'><?php echo $this->t('Value');?></th>
117117
</tr>
118118
</thead>
119119
<tbody>
@@ -174,9 +174,7 @@ if($this->preview) // module visualize
174174
</div>
175175
<div class="viewSideBar">
176176
<?php
177-
$modules = Zend_Registry::get('modulesEnable');
178-
$statisticsEnabled = in_array('statistics', $modules);
179-
if($this->preview || $this->isModerator ||$this->isAdmin || $statisticsEnabled)
177+
if($this->preview || $this->isModerator || $this->isAdmin)
180178
{?>
181179
<div class="sideElementFirst viewAction">
182180

@@ -204,7 +202,7 @@ if($this->preview) // module visualize
204202
<a href='javascript:;' class='addMetadataLink' ><img alt='' src='{$this->coreWebroot}/public/images/icons/metadata.png'/> {$this->t('Add Metadata')}</a>
205203
</li>
206204
<li>
207-
<a href='javascript:;' type='item' element='{$this->itemDao->getKey()}' class='sharingLink' ><img alt='' src='{$this->coreWebroot}/public/images/icons/share.png'/> {$this->t('Share')}</a>
205+
<a href='javascript:;' type='item' element='{$this->itemDao->getKey()}' class='sharingLink' ><img alt='' src='{$this->coreWebroot}/public/images/icons/share.png'/> {$this->t('Permissions')}</a>
208206
</li>
209207
<li>
210208
<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>
@@ -220,10 +218,14 @@ if($this->preview) // module visualize
220218
</li>
221219
";
222220
}
223-
echo
224-
"<li>
225-
<a href='".$this->webroot."/statistics/item?id=".$this->itemDao->getKey()."'><img alt='' src='{$this->coreWebroot}/public/images/icons/metadata.png'/> {$this->t('Statistics')}</a>
226-
</li>";
221+
$htmltArray = Zend_Registry::get('notifier')->callback("CALLBACK_CORE_ITEM_VIEW_ACTIONMENU", array('item' => $this->itemDao, 'isModerator' => $this->isModerator, 'isAdmin' => $this->isAdmin));
222+
foreach($htmltArray as $html)
223+
{
224+
if(!empty($html))
225+
{
226+
echo $html;
227+
}
228+
}
227229
?>
228230
</ul>
229231
</div>
@@ -262,7 +264,15 @@ if($this->preview) // module visualize
262264
}
263265
?>
264266
</div>
265-
<?php
267+
<?php
268+
$htmltArray = Zend_Registry::get('notifier')->callback("CALLBACK_CORE_ITEM_VIEW_INFO", array('item' => $this->itemDao, 'isModerator' => $this->isModerator, 'isAdmin' => $this->isAdmin));
269+
foreach($htmltArray as $html)
270+
{
271+
if(!empty($html))
272+
{
273+
echo $html;
274+
}
275+
}
266276
if(count($this->sameLocation) > 1)
267277
{?>
268278
<div class='sideElementLast viewSameLocation'>
@@ -282,7 +292,3 @@ if($this->preview) // module visualize
282292
}
283293
?>
284294
</div>
285-
286-
287-
288-

modules/statistics/Notification.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public function init()
1111
{
1212
$this->addCallBack('CALLBACK_CORE_GET_FOOTER_LAYOUT', 'getFooter');
1313
$this->addCallBack('CALLBACK_CORE_GET_USER_MENU', 'getUserMenu');
14+
$this->addCallBack('CALLBACK_CORE_ITEM_VIEW_ACTIONMENU', 'getItemMenuLink');
1415
$this->addCallBack('CALLBACK_CORE_PLUS_ONE_DOWNLOAD', 'addDownload');
1516

1617
$this->addTask('TASK_STATISTICS_SEND_REPORT', 'sendReport', 'Send a daily report');
@@ -46,6 +47,17 @@ public function getUserMenu()
4647
}
4748
}
4849

50+
/** Get the link to place in the item action menu */
51+
public function getItemMenuLink($params)
52+
{
53+
$fc = Zend_Controller_Front::getInstance();
54+
$coreWebroot = $fc->getBaseUrl().'/core';
55+
$moduleWebroot = $fc->getBaseUrl().'/'.$this->moduleName;
56+
return '<li><a href="'.$moduleWebroot.'/item?id='.$params['item']->getKey().
57+
'"><img alt="" src="'.$coreWebroot.'/public/images/icons/metadata.png" /> '.
58+
$this->t('Statistics').'</a></li>';
59+
}
60+
4961
/** get layout footer */
5062
public function getFooter()
5163
{

0 commit comments

Comments
 (0)