Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
rWatcher authored and Tim Almdal committed Jun 18, 2010
1 parent 0ec53f5 commit eb1632d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
36 changes: 36 additions & 0 deletions modules/database_info/helpers/database_info_block.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class database_info_block_Core {
static function get_admin_list() {
return array("database_info" => t("Database info"));
}

static function get($block_id) {
$block = new Block();
switch ($block_id) {
case "database_info":
$block->css_id = "g-database-info";
$block->title = t("Database information");
$block->content = new View("admin_block_db.html");
break;
}
return $block;
}
}
3 changes: 3 additions & 0 deletions modules/database_info/module.info
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "Database Info"
description = "View information about your Gallery 3 database on the admin dashboard."
version = 1
18 changes: 18 additions & 0 deletions modules/database_info/views/admin_block_db.html.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?
$db = Database::instance();
$tables = $db->query("SHOW TABLE STATUS");
$database_size = 0;
foreach($tables as $table) {
$database_size += ($table->Data_length + $table->Index_length);
}
$database_size = $database_size / 1024 / 1024;
?>
<ul>
<li>
<?= t("Database size: %dbsize MB", array("dbsize" => number_format($database_size, 2))) ?>
</li>
<li>
<?= t("Number of tables: %dbtables", array("dbtables" => count($tables))) ?>
</li>
</ul>

0 comments on commit eb1632d

Please sign in to comment.