Support event handler (trigger) to customize the content of the admin dashboard

This commit is contained in:
Kijin Sung 2023-10-27 00:22:12 +09:00
parent 72ab8ea8fc
commit 286dc76e78
4 changed files with 54 additions and 24 deletions

View file

@ -2,7 +2,7 @@
<load target="js/dashboard_default.js" />
<load target="js/dashboard_counter.js" />
<div>
{@ ob_start()}
<section class="status">
<h2>{$lang->uv}</h2>
<div style="margin:10px 15px;height:142px" id="visitors"></div>
@ -13,7 +13,10 @@
<a href="{getUrl('', 'module', 'admin', 'act', 'dispCounterAdminIndex')}"><i>&rsaquo;</i> {$lang->details}</a>
</div>
</section>
<section class="status">
{@ $dashboard_stack->left[] = ob_get_clean()}
{@ ob_start()}
<section class="status">
<h2>{$lang->pv}</h2>
<div style="margin:10px 15px;height:142px" id="page_views"></div>
<div class="more">
@ -24,9 +27,9 @@
</div>
</section>
<style scoped>.jqplot-table-legend{background:#fff;top:13px!important}</style>
</div>
{@ $dashboard_stack->left[] = ob_get_clean()}
<div>
{@ ob_start()}
<section class="document">
<h2>{$lang->latest_documents}</h2>
<ul>
@ -47,6 +50,9 @@
</ul>
<p class="more"><a href="{getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList')}"><i>&rsaquo;</i> {$lang->more}</a></p>
</section>
{@ $dashboard_stack->right[] = ob_get_clean()}
{@ ob_start()}
<section class="reply">
<h2>{$lang->latest_comments}</h2>
<ul>
@ -66,7 +72,7 @@
</ul>
<p class="more"><a href="{getUrl('', 'module', 'admin', 'act', 'dispCommentAdminList')}"><i>&rsaquo;</i> {$lang->more}</a></p>
</section>
</div>
{@ $dashboard_stack->right[] = ob_get_clean()}
<script>
xe.lang.this_week = '{$lang->this_week}';

View file

@ -1,7 +1,7 @@
<config autoescape="on" />
<load target="js/dashboard_default.js" />
<div>
{@ ob_start()}
<section class="member">
<h2>{$lang->member}</h2>
<ul>
@ -17,9 +17,9 @@
<a href="{getUrl('', 'module', 'admin', 'act', 'dispMemberAdminList')}"><i class="xi-angle-right"></i><span>{$lang->more}</span></a>
</div>
</section>
</div>
{@ $dashboard_stack->left[] = ob_get_clean()}
<div>
{@ ob_start()}
<section class="document">
<h2>{$lang->latest_documents}</h2>
<ul>
@ -45,6 +45,9 @@
<a href="{getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList')}"><i class="xi-angle-right"></i><span>{$lang->more}</span></a>
</div>
</section>
{@ $dashboard_stack->right[] = ob_get_clean()}
{@ ob_start()}
<section class="reply">
<h2>{$lang->latest_comments}</h2>
<ul>
@ -65,4 +68,5 @@
<p class="more"><a href="{getUrl('', 'module', 'admin', 'act', 'dispCommentAdminList')}"><i class="xi-angle-right"></i><span>{$lang->more}</span></a></p>
</section>
</div>
{@ $dashboard_stack->right[] = ob_get_clean()}

View file

@ -1281,19 +1281,21 @@ margin-bottom: 10px;
/* Dashboard */
.x .dashboard {
display: flex;
align-items: flex-start;
justify-content: space-between;
}
.x .dashboard:after {
content: "";
display: block;
clear: both;
.x .dashboard > div {
width: calc(50% - 12.5px);
}
.x .dashboard>div {
float: right;
width: 49%;
}
.x .dashboard>div:first-child {
float: left;
@media all and (max-width: 800px) {
.x .dashboard {
flex-direction: column;
align-items: stretch;
}
.x .dashboard > div {
width: 100%;
}
}
.x .dashboard>div>section {
position: relative;

View file

@ -52,7 +52,7 @@
<h2>{$lang->update_available}</h2>
<p>{$lang->core_update_available} <a href="https://rhymix.org/" target="_blank">{$lang->core_update_link}</a></p>
</div>
<!--// Notice about cleaning up unnecessary core files -->
<div class="message update cleanup_list" cond="$cleanup_list">
<h2>{$lang->msg_cleanup_notice_title}</h2>
@ -91,12 +91,30 @@
<!--// Real dashboard begins here -->
<div class="dashboard">
<block cond="$counterAddonActivated">
{@
$dashboard_stack = new stdClass;
$dashboard_stack->left = [];
$dashboard_stack->right = [];
}
<!--@if($counterAddonActivated)-->
<include target="./_dashboard_counter.html" />
</block>
<block cond="!$counterAddonActivated">
<!--@else-->
<include target="./_dashboard_default.html" />
</block>
<!--@endif-->
<!--// Call event handler -->
{@ ModuleHandler::triggerCall('admin.dashboard', 'before', $dashboard_stack)}
<!--// Left stack -->
<div>
{implode("\n", $dashboard_stack->left)|noescape}
</div>
<!--// Right stack -->
<div>
{implode("\n", $dashboard_stack->right)|noescape}
</div>
</div>
</div>