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

Commit d126461

Browse files
author
Charles Marion
committed
ENH: added dashboard
1 parent 22a2da3 commit d126461

File tree

13 files changed

+155
-11
lines changed

13 files changed

+155
-11
lines changed

core/Notification.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/** notification manager*/
3+
class Notification extends MIDAS_Notification
4+
{
5+
public $_components = array('Utility');
6+
/** init notification process*/
7+
public function init($type, $params)
8+
{
9+
switch ($type)
10+
{
11+
case MIDAS_NOTIFY_GET_DASBOARD:
12+
return $this->_getDasboard();
13+
break;
14+
15+
default:
16+
break;
17+
}
18+
}//end init
19+
20+
/** generate Dasboard information */
21+
private function _getDasboard()
22+
{
23+
$return = array();
24+
$return['Database'] = array(true); //If you are here it works...
25+
$return['Image Magick'] = array($this->Component->Utility->isImageMagickWorking());
26+
$return['Config Folder Writable'] = array(is_writable(BASE_PATH.'/core/configs'));
27+
$return['Data Folder Writable'] = array(is_writable(BASE_PATH.'/data'));
28+
$return['Temporary Folder Writable'] = array(is_writable(BASE_PATH.'/tmp'));
29+
30+
return $return;
31+
}//end _getDasboard
32+
} //end class
33+
?>

core/constant/notification.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
22
define("MIDAS_NOTIFY_LOGIN", 0);
33
define("MIDAS_NOTIFY_GET_CONFIG_TABS", 1);
4+
define("MIDAS_NOTIFY_GET_DASBOARD", 2);
45
?>

core/controllers/AdminController.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,24 @@ function showlogAction()
258258
$this->view->modulesLog = $modules;
259259
}//showlogAction
260260

261+
/** function dashboard*/
262+
function dashboardAction()
263+
{
264+
if(!$this->logged || !$this->userSession->Dao->getAdmin() == 1)
265+
{
266+
throw new Zend_Exception("You should be an administrator");
267+
}
268+
if(!$this->getRequest()->isXmlHttpRequest())
269+
{
270+
throw new Zend_Exception("Why are you here ? Should be ajax.");
271+
}
272+
273+
$this->_helper->layout->disableLayout();
274+
275+
$this->view->dashboard = Zend_Registry::get('notifier')->notify(MIDAS_NOTIFY_GET_DASBOARD);
276+
277+
}//end dashboardAction
278+
261279
/** upgrade database*/
262280
function upgradeAction()
263281
{

core/controllers/InstallController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ function indexAction()
3232
$this->view->header = "Step1: Server Configuration";
3333
// Check PHP extension / function
3434
$phpextensions = array (
35-
"curl_init" => array(false, "Certain features, such as statistics won't be available. It is recommended to enable/install cURL."),
36-
"openssl" => array(false, "Bitstreams signature won't be available. It is recommended to enable/install OpenSSL."),
3735
"simplexml" => array(false, ""),
3836
);
3937
$this->view->phpextension_missing = $this->Component->Utility->checkPhpExtensions($phpextensions);

core/layouts/layout.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
}
157157
if($this->highNumberError)
158158
{
159-
echo '<span style="color:red;">More thant 5 errors occured during the last 24 hours. <a href="'.$this->webroot.'/admin/#ui-tabs-2">Cherck the logs</a></span><br/><br/>';
159+
echo '<span style="color:red;">More thant 5 errors occured during the last 24 hours. <a href="'.$this->webroot.'/admin/#ui-tabs-2">Check the logs</a></span><br/><br/>';
160160
}
161161
?>
162162
<div class=SubWrapper">

core/public/css/admin/admin.dashboard.css

Whitespace-only changes.

core/public/js/admin/admin.dashboard.js

Whitespace-only changes.

core/views/admin/dashboard.phtml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<link type="text/css" rel="stylesheet" href="<?php echo $this->coreWebroot?>/public/css/admin/admin.dashboard.css" />
2+
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/admin/admin.dashboard.js"></script>
3+
4+
5+
<?php
6+
foreach($this->dashboard as $module => $dasboard)
7+
{
8+
echo "<h3>".ucfirst($module)."</h3>";
9+
echo "<table>";
10+
foreach($dasboard as $name => $status)
11+
{
12+
echo "<tr>";
13+
echo " <td>$name</td>";
14+
if($status)
15+
{
16+
echo " <td><img src='{$this->coreWebroot}/public/images/icons/ok.png' /></td>";
17+
}
18+
else
19+
{
20+
echo " <td><img src='{$this->coreWebroot}/public/images/icons/nok.png' /></td>";
21+
}
22+
if(isset($status[1]))
23+
{
24+
echo " <td>$status[1]</td>";
25+
}
26+
echo "</tr>";
27+
}
28+
echo "</table>";
29+
}
30+
?>
31+

core/views/admin/index.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ $this->headScript()->appendFile($this->coreWebroot . '/public/js/admin/admin.ind
1212
<li><a href="#tabs-configuration">Configuration</a></li>
1313
<li><a href="#tabs-modules">Modules</a></li>
1414
<li><a href="#tabs-assetstore">Assetstores</a></li>
15-
<li><a href="#tabs-maintenance">Maintenance</a></li>
1615
<li><a href="<?php echo $this->webroot?>/admin/upgrade">Upgrade</a></li>
16+
<li><a href="<?php echo $this->webroot?>/admin/dashboard">Dasboard</a></li>
1717
<li><a href="<?php echo $this->webroot?>/admin/showlog">Logs</a></li>
1818
</ul>
1919
<div id="tabs-configuration">

library/MIDAS/MIDASNotifier.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@ public function __construct()
3232
{
3333
throw new Zend_Exception('Unable to find notification class: '.$name);
3434
}
35-
$this->modules[$module] = new $name();
35+
$this->modules['core'] = new $name();
3636
}
3737
}//end contruct()
3838

3939
/** notify enabled modules*/
40-
public function notify($type, $params)
40+
public function notify($type, $params = null)
4141
{
4242
$return = array();
4343
foreach($this->modules as $key => $module)
4444
{
45-
$return[$key] = call_user_func(array($module, 'init'), $type, $params);
45+
$tmp = call_user_func(array($module, 'init'), $type, $params);
46+
if($tmp != null)
47+
{
48+
$return[$key] = $tmp;
49+
}
4650
}
4751
return $return;
4852
}//end notify

0 commit comments

Comments
 (0)