From 9bdf825a947ea4758b1f86100c05f62582edc0a6 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 25 Nov 2008 09:15:45 +0000
Subject: Add a "Access" tab to the scaffolding and list users and groups.
Refactor welcome.php a little bit to make index() more readable.
---
core/controllers/welcome.php | 65 ++++++++++++++++++++++----------
core/views/welcome.html.php | 90 +++++++++++++++++++++++++++++++++++---------
2 files changed, 117 insertions(+), 38 deletions(-)
(limited to 'core')
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index c62ccbc8..6d0399dc 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -39,26 +39,10 @@ class Welcome_Controller extends Template_Controller {
$this->template->deepest_photo = null;
}
- try {
- $this->template->comment_count = ORM::factory("comment")->count_all();
- } catch (Exception $e) {
- $this->template->comment_count = 0;
- }
-
- try {
- $this->template->tag_count = ORM::factory("tag")->count_all();
- $this->template->most_tagged = Database::instance()
- ->select("item_id AS id", "COUNT(tag_id) AS count")
- ->from("items_tags")
- ->groupby("item_id")
- ->orderby("count", "DESC")
- ->limit(1)
- ->get()
- ->current();
- } catch (Exception $e) {
- $this->template->tag_count = 0;
- $this->template->most_tagged = 0;
- }
+ $this->_load_user_info();
+ $this->_load_group_info();
+ $this->_load_comment_info();
+ $this->_load_tag_info();
set_error_handler($old_handler);
@@ -341,4 +325,45 @@ class Welcome_Controller extends Template_Controller {
ksort($modules);
return $modules;
}
+
+ private function _load_group_info() {
+ try {
+ $this->template->groups = ORM::factory("group")->find_all();
+ } catch (Exception $e) {
+ $this->template->groups = array();
+ }
+ }
+
+ private function _load_user_info() {
+ try {
+ $this->template->users = ORM::factory("user")->find_all();
+ } catch (Exception $e) {
+ $this->template->users = array();
+ }
+ }
+
+ private function _load_comment_info() {
+ try {
+ $this->template->comment_count = ORM::factory("comment")->count_all();
+ } catch (Exception $e) {
+ $this->template->comment_count = 0;
+ }
+ }
+
+ private function _load_tag_info() {
+ try {
+ $this->template->tag_count = ORM::factory("tag")->count_all();
+ $this->template->most_tagged = Database::instance()
+ ->select("item_id AS id", "COUNT(tag_id) AS count")
+ ->from("items_tags")
+ ->groupby("item_id")
+ ->orderby("count", "DESC")
+ ->limit(1)
+ ->get()
+ ->current();
+ } catch (Exception $e) {
+ $this->template->tag_count = 0;
+ $this->template->most_tagged = 0;
+ }
+ }
}
diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php
index 7b34927f..0eca24fc 100644
--- a/core/views/welcome.html.php
+++ b/core/views/welcome.html.php
@@ -70,26 +70,37 @@
display: none;
}
- ul#tabs {
+ ul.tabs {
margin-left: 0;
padding: 1em 0 2px 1em;
white-space: nowrap;
border-bottom: 1px solid black;
}
- ul#tabs li {
+ ul.tabs li {
display: inline;
list-style-type: none;
}
- ul#tabs a {
+ ul.tabs a {
padding: 3px 10px;
color: #fff;
background-color: #036;
text-decoration: none;
}
- ul#tabs a:hover {
+ div#access {
+ margin-top: -20px;
+ padding: 0px;
+ padding-left: 20px;
+ }
+
+ div#access ul.tabs a {
+ background-color: #830;
+ border: 1px solid white;
+ }
+
+ ul.tabs a:hover {
background-color: #369;
}
@@ -108,7 +119,6 @@
tr.core td {
border-bottom: 1px solid black;
-
}
a {
@@ -141,9 +151,10 @@
meantime, here are some useful links to get you started.
-
+
- Configuration
- Actions
+ - Access
- Info
- Benchmarks
- Docs
@@ -151,21 +162,34 @@
@@ -218,6 +242,36 @@
+
+
+
+
+
+ foreach ($users as $user): ?>
+ - = $user->name ?>
+ endforeach ?>
+
+
+
+
+
+ foreach ($groups as $group): ?>
+ - = $group->name ?>
+ endforeach ?>
+
+
+
+
+
+
- = html::anchor("welcome/mptt?type=text", "MPTT tree (text)") ?>
--
cgit v1.2.3