Skip to content
Browse files

Integrated with ThePixelDeveloper's admin template as a theme

  • Loading branch information...
1 parent 798ae4b commit e03f1af23d87e9604b8330b4202bab601d314241 @vimofthevine committed Mar 17, 2010
View
3 .gitmodules
@@ -0,0 +1,3 @@
+[submodule "media/ThePixelDeveloper_Admin-Template"]
+ path = media/ThePixelDeveloper_Admin-Template
+ url = git://github.com/ThePixelDeveloper/Admin-Template.git
View
4 classes/controller/admin/auth.php
@@ -54,7 +54,9 @@ public function action_login() {
}
}
- $view = new View('admin/auth/login');
+ $view = $this->internal_request
+ ? new View('admin/auth/widget/login')
+ : new View('admin/auth/login');
$form = $errors = array(
'username' => '',
'password' => '',
View
35 classes/controller/admin/media.php
@@ -0,0 +1,35 @@
+<?php defined('SYSPATH') OR die('No direct script access.');
+
+/**
+ * Admin media controller
+ *
+ * @package Admin
+ * @author Kyle Treubig
+ * @copyright (c) 2010 Kyle Treubig
+ * @license MIT
+ */
+class Controller_Admin_Media extends Controller {
+
+ public function action_file() {
+ $request = Request::instance();
+ $file = $request->param('file');
+
+ $ext = pathinfo($file, PATHINFO_EXTENSION);
+
+ $file = substr($file, 0, -(strlen($ext) + 1));
+
+ if ($file = Kohana::find_file('media', $file, $ext))
+ {
+ $request->response = file_get_contents($file);
+ }
+ else
+ {
+ Kohana::$log->add(Kohana::ERROR, 'Admin media controller error while loading file, '.$file);
+ $request->status = 404;
+ }
+
+ $request->headers['Content-Type'] = File::mime_by_ext($ext);
+ }
+
+}
+
View
47 classes/controller/admin/users.php
@@ -15,10 +15,14 @@ public function before() {
parent::before();
$this->restrict('user', 'manage');
- $this->add_menu('users', array(
+ $this->add_menu('Users', array(
'create' => Route::get('admin_main')->uri(array('controller'=>'users', 'action'=>'new')),
'edit profile' => Route::get('admin_main')->uri(array('controller'=>'users', 'action'=>'profile')),
));
+ if ( ! $this->internal_request)
+ {
+ unset($this->template->menu->menu['Users'][0]);
+ }
}
/**
@@ -29,14 +33,27 @@ public function action_index() {
}
/**
+ * Display menu for user management
+ */
+ public function action_menu() {
+ if ( ! $this->internal_request)
+ {
+ Request::instance()->redirect(Route::get('admin_main')->uri(array('controller'=>'users')));
+ }
+ $this->template->content = new View('admin/users/widget/menu');
+ }
+
+ /**
* Display list of users
*/
public function action_list() {
$users = Sprig::factory('user')->load(NULL, FALSE);
if (count($users) == 0)
{
- $this->template->content = new View('admin/users/none');
+ $this->template->content = $this->internal_request
+ ? new View('admin/users/widget/none')
+ : new View('admin/users/none');
return;
}
@@ -46,15 +63,15 @@ public function action_list() {
->action(Route::get('admin_main')->uri(array('controller'=>'users', 'action'=>'view')));
$grid->column()->field('role')->title('Role');
$grid->column()->field('email')->title('Email');
- $grid->column('action')->title('Edit')->text('edit')
+ $grid->column('action')->title('Actions')->text('Edit')->class('edit')
->action(Route::get('admin_main')->uri(array('controller'=>'users', 'action'=>'edit')));
- $grid->column('action')->title('Del')->text('del')
+ $grid->column('action')->title('')->text('Delete')->class('delete')
->action(Route::get('admin_main')->uri(array('controller'=>'users', 'action'=>'delete')));
- $grid->link()->text('Add User')
- ->action(Route::get('admin_main')->uri(array('controller'=>'users', 'action'=>'new')));
$grid->data($users);
- $this->template->content = new View('admin/users/list');
+ $this->template->content = $this->internal_request
+ ? new View('admin/users/widget/list')
+ : new View('admin/users/list');
$this->template->content->grid = $grid;
}
@@ -79,7 +96,9 @@ public function action_view() {
Request::instance()->redirect( Route::get('admin_main')->uri(array('controller'=>'users')) );
}
- $view = new View('admin/users/view');
+ $view = $this->internal_request
+ ? new View('admin/users/widget/view')
+ : new View('admin/users/view');
$view->user = $user;
$this->template->content = $view;
}
@@ -105,7 +124,9 @@ public function action_new() {
}
catch (Validate_Exception $e)
{
- $view = new View('admin/users/form');
+ $view = $this->internal_request
+ ? new View('admin/users/widget/form')
+ : new View('admin/users/create');
$view->legend = __('Create User');
$view->submit = __('Create');
$view->user = $user;
@@ -156,7 +177,9 @@ public function action_edit() {
}
$user->values($_POST);
- $view = new View('admin/users/form');
+ $view = $this->internal_request
+ ? new View('admin/users/widget/form')
+ : new View('admin/users/edit');
$view->legend = __('Modify User');
$view->submit = __('Save');
$view->user = $user;
@@ -245,7 +268,9 @@ public function action_delete() {
}
}
- $view = new View('admin/users/delete');
+ $view = $this->internal_request
+ ? new View('admin/users/widget/delete')
+ : new View('admin/users/delete');
$view->user = $user;
$this->template->content = $view;
}
View
20 classes/controller/template/admin.php
@@ -19,6 +19,11 @@
protected $_config;
/**
+ * @var Internal request
+ */
+ protected $internal_request = FALSE;
+
+ /**
* Configure admin controller
*/
public function before() {
@@ -32,6 +37,14 @@ public function before() {
$this->a1 = $this->a2->a1;
$this->session = Session::instance();
+ // Check if internal request
+ if ($this->request !== Request::instance())
+ {
+ //$this->auto_render = FALSE;
+ $this->internal_request = TRUE;
+ //$this->template = View::factory('admin/internal');
+ }
+
if ($this->auto_render)
{
// Prepare templates
@@ -62,6 +75,13 @@ public function after() {
$this->template->header->scripts = array_merge($this->template->scripts, $scripts);
}
+ if ($this->internal_request)
+ {
+ //$this->auto_render = TRUE;
+ $content = $this->template->content;
+ $this->template = $content;
+ }
+
parent::after();
}
View
8 config/admin.php → config/admin-example.php
@@ -2,13 +2,13 @@
return array(
// Admin template folder path
- 'template' => 'admin/themes/default',
+ 'template' => 'admin/themes/tpd',
// Admin menu hierarchy array
'menu' => array(
- 'home' => array('admin/main'),
- 'users' => array('admin/users'),
- 'logout' => array('admin/logout'),
+ 'Home' => array('admin/main'),
+ 'Users' => array('admin/users'),
+ 'Logout' => array('admin/logout'),
),
);
View
12 config/message.php
@@ -3,12 +3,16 @@
return array(
'tags' => array(
'error' => array(
- 'open' => '<span class="error">',
- 'close' => '</span>',
+ 'open' => '<p class="error">',
+ 'close' => '</p>',
+ //'open' => '<span class="error">',
+ //'close' => '</span>',
),
'info' => array(
- 'open' => '<span class="info">',
- 'close' => '</span>',
+ 'open' => '<p class="success">',
+ 'close' => '</p>',
+ //'open' => '<span class="info">',
+ //'close' => '</span>',
),
),
'session_type' => 'native',
View
8 init.php
@@ -15,6 +15,14 @@
'action' => 'index',
));
+Route::set('admin_media', 'admin/media(/<file>)', array('file'=>'.+'))
+ ->defaults(array(
+ 'directory' => 'admin',
+ 'controller' => 'media',
+ 'action' => 'file',
+ 'file' => NULL,
+ ));
+
// Static file serving (CSS, JS, images)
//Route::set('docs/media', 'guide/media(/<file>)', array('file' => '.+'))
//->defaults(array(
1 media/ThePixelDeveloper_Admin-Template
@@ -0,0 +1 @@
+Subproject commit 0f02a32e5d6c3212933cc40d4dda83e46248b56f
View
28 views/admin/auth/login.php
@@ -1,24 +1,8 @@
-<section>
- <h1>Login</h1>
+<div class="grid_4">&nbsp;</div>
+<div class="grid_8">
<?php
- echo Form::open();
-
- echo empty($errors['username']) ? '' : '<h2>'.$errors['username'].'</h2>'.PHP_EOL;
- echo Form::label('username', 'Username');
- echo Form::input('username', $form['username']), PHP_EOL;
- echo '<br />', PHP_EOL;
-
- echo empty($errors['password']) ? '' : '<h2>'.$errors['password'].'</h2>'.PHP_EOL;
- echo Form::label('password', 'Password');
- echo Form::password('password', $form['password']), PHP_EOL;
- echo '<br />', PHP_EOL;
-
- echo empty($errors['remember']) ? '' : '<h2>'.$errors['remember'].'</h2>'.PHP_EOL;
- echo Form::label('remember', 'Remember Me');
- echo Form::checkbox('remember', 'true', (bool) $form['remember']);
- echo '<br />', PHP_EOL;
-
- echo Form::submit('submit', 'Login');
- echo Form::close();
+ $url = Route::get('admin_auth')->uri(array('action' => 'login'));
+ echo Request::factory($url)->execute()->response;
?>
-</section>
+</div>
+<div class="grid_4">&nbsp;</div>
View
26 views/admin/auth/widget/login.php
@@ -0,0 +1,26 @@
+<h1>Login</h1>
+<?php echo Form::open(); ?>
+
+<?php echo empty($errors['username']) ? '' : '<p class="error">'.$errors['username'].'</p>'; ?>
+<p>
+ <?php echo Form::label('username', 'Username'); ?>
+ <?php echo Form::input('username', $form['username']); ?>
+</p>
+
+<?php echo empty($errors['password']) ? '' : '<p class="error">'.$errors['password'].'</p>'.PHP_EOL; ?>
+<p>
+ <?php echo Form::label('password', 'Password'); ?>
+ <?php echo Form::password('password', $form['password']), PHP_EOL; ?>
+</p>
+
+<?php echo empty($errors['remember']) ? '' : '<p class="error">'.$errors['remember'].'</p>'.PHP_EOL; ?>
+<p>
+ <?php echo Form::label('remember', 'Remember Me'); ?>
+ <?php echo Form::checkbox('remember', 'true', (bool) $form['remember']); ?>
+</p>
+
+<p class="submit">
+ <?php echo Form::submit('submit', 'Login'); ?>
+</p>
+
+<?php echo Form::close(); ?>
View
2 views/admin/themes/default/header.php
@@ -24,6 +24,8 @@
table.sortable thead tr { background:#ddd; }
table.sortable tbody tr:nth-child(even) { background:#eee; }
</style>
+<?php foreach ($styles as $style => $media) echo HTML::style($style, array('media' => $media), TRUE), "\n" ?>
+<?php foreach ($scripts as $script) echo HTML::script($script, NULL, TRUE), "\n" ?>
</head>
<?php
echo '<body';
View
6 views/admin/themes/tpd/footer.php
@@ -0,0 +1,6 @@
+ <div id="foot">
+ <i>Designed by </i><a href="http://mathew-davies.co.uk/">Mathew Davies</a>
+ </div>
+
+ </body>
+</html>
View
15 views/admin/themes/tpd/header.php
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <title>Administrative Control Panel</title>
+ <?php echo HTML::style(Route::get('admin_media')->uri(array('file'=>'ThePixelDeveloper_Admin-Template/css/960.css')), array('media'=>'screen')) ?>
+ <?php echo HTML::style(Route::get('admin_media')->uri(array('file'=>'ThePixelDeveloper_Admin-Template/css/template.css')), array('media'=>'screen')) ?>
+ <?php echo HTML::style(Route::get('admin_media')->uri(array('file'=>'ThePixelDeveloper_Admin-Template/css/colour.css')), array('media'=>'screen')) ?>
+ <?php foreach ($styles as $style => $media) echo HTML::style($style, array('media' => $media), TRUE), "\n" ?>
+ <?php foreach ($scripts as $script) echo HTML::script($script, NULL, TRUE), "\n" ?>
+ </head>
+ <body>
+
+ <h1 id="head">Administrative Control Panel</h1>
View
9 views/admin/themes/tpd/menu.php
@@ -0,0 +1,9 @@
+ <ul id="navigation">
+ <?php foreach($menu as $topic=>$item): ?>
+ <li id="nav_<?php echo URL::title($topic) ?>">
+ <?php echo empty($item[0])
+ ? '<span class="active">'.$topic.'</span>'
+ : HTML::anchor($item[0], $topic); ?>
+ </li>
+ <?php endforeach; ?>
+ </ul>
View
16 views/admin/themes/tpd/template.php
@@ -0,0 +1,16 @@
+<!-- should be no reason to edit this file -->
+<?php echo $header; ?>
+<?php echo $menu; ?>
+
+<div id="content" class="container_16 clearfix">
+<?php $msg = Message::instance()->get();
+ if ( ! empty($msg)): ?>
+ <div class="grid_16">
+ <?php echo $msg; ?>
+ </div>
+<?php endif; ?>
+
+ <?php echo $content; ?>
+</div>
+
+<?php echo $footer; ?>
View
21 views/admin/users/create.php
@@ -0,0 +1,21 @@
+<div class="grid_4">
+<?php
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'menu',
+ ));
+ echo Request::factory($url)->execute()->response;
+?>
+</div>
+
+<div class="grid_8">
+<?php
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'new',
+ ));
+ echo Request::factory($url) ->execute()->response;
+?>
+</div>
+
+<div class="grid_4">&nbsp;</div>
View
28 views/admin/users/delete.php
@@ -1,13 +1,19 @@
-<section>
- <h1>Delete <?php echo $user->username ?>?</h1>
- <p>
- Are you sure you want to delete <?php echo $user->username ?>?
- This action cannot be undone.
- </p>
+<div class="grid_4">
<?php
- echo Form::open();
- echo Form::submit('yes', 'Yes');
- echo Form::submit('no', 'No');
- echo Form::close();
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'menu',
+ ));
+ echo Request::factory($url)->execute()->response;
?>
-</section>
+</div>
+
+<div class="grid_12">
+<?php
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'delete',
+ ));
+ echo Request::factory($url)->execute()->response;
+?>
+</div>
View
22 views/admin/users/edit.php
@@ -0,0 +1,22 @@
+<div class="grid_4">
+<?php
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'menu',
+ ));
+ echo Request::factory($url)->execute()->response;
+?>
+</div>
+
+<div class="grid_8">
+<?php
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'edit',
+ 'id' => $user->id,
+ ));
+ echo Request::factory($url) ->execute()->response;
+?>
+</div>
+
+<div class="grid_4">&nbsp;</div>
View
19 views/admin/users/form.php
@@ -1,19 +0,0 @@
-<section>
- <h1><?php echo $legend; ?></h1>
-<?php
-
- echo Form::open();
-
- foreach ($user->inputs(FALSE) as $field=>$input)
- {
- echo isset($errors[$field]) ? '<h2>'.$errors[$field].'</h2>' : '';
- echo $user->label($field),PHP_EOL;
- echo $input,PHP_EOL;
- echo '<br />',PHP_EOL;
- }
-
- echo Form::submit('submit', $submit);
- echo Form::close();
-
-?>
-</section>
View
23 views/admin/users/list.php
@@ -1,4 +1,19 @@
-<section>
- <h1>Users List</h1>
- <?php echo $grid; ?>
-</section>
+<div class="grid_4">
+<?php
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'menu',
+ ));
+ echo Request::factory($url)->execute()->response;
+?>
+</div>
+
+<div class="grid_12">
+<?php
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'list',
+ ));
+ echo Request::factory($url) ->execute()->response;
+?>
+</div>
View
7 views/admin/users/none.php
@@ -1,7 +0,0 @@
-<section>
- <h1>Users List</h1>
- <p>
- There are no users at this time
- (<?php echo Html::anchor('admin/users/new', 'create one') ?>).
- </p>
-</section>
View
32 views/admin/users/view.php
@@ -1,14 +1,20 @@
-<section>
- <h1><?php echo $user->username ?></h1>
- <dl>
- <dt>Username:</dt>
- <dd><?php echo $user->username ?></dd>
- <dt>Email:</dt>
- <dd><?php echo $user->email ?></dd>
- <dt>Role:</dt>
- <dd><?php echo $user->role ?></dd>
- <dt>Last Login:</dt>
- <dd><?php echo $user->last_login ?></dd>
- </dl>
-</section>
+<div class="grid_4">
+<?php
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'menu',
+ ));
+ echo Request::factory($url)->execute()->response;
+?>
+</div>
+<div class="grid_12">
+<?php
+ $url = Route::get('admin_main')->uri(array(
+ 'controller' => 'users',
+ 'action' => 'view',
+ 'id' => $user->id,
+ ));
+ echo Request::factory($url) ->execute()->response;
+?>
+</div>
View
11 views/admin/users/widget/delete.php
@@ -0,0 +1,11 @@
+<h1>Delete <?php echo $user->username ?>?</h1>
+<p>
+ Are you sure you want to delete <?php echo $user->username ?>?
+ This action cannot be undone.
+</p>
+<?php
+ echo Form::open();
+ echo Form::submit('yes', 'Yes');
+ echo Form::submit('no', 'No');
+ echo Form::close();
+?>
View
15 views/admin/users/widget/form.php
@@ -0,0 +1,15 @@
+<h2><?php echo $legend; ?></h2>
+<?php echo Form::open(); ?>
+
+<?php foreach ($user->inputs(FALSE) as $field=>$input): ?>
+<?php echo isset($errors[$field]) ? '<p class="error">'.$errors[$field].'</p>' : ''; ?>
+<p>
+ <?php echo $user->label($field); ?>
+ <?php echo $input; ?>
+</p>
+<?php endforeach; ?>
+
+<p class="submit">
+ <?php echo Form::submit('submit', $submit); ?>
+</p>
+<?php echo Form::close(); ?>
View
2 views/admin/users/widget/list.php
@@ -0,0 +1,2 @@
+<h1>Users List</h1>
+<?php echo $grid; ?>
View
10 views/admin/users/widget/menu.php
@@ -0,0 +1,10 @@
+<div class="box">
+ <h2>User Management</h2>
+ <p>
+ <ul>
+ <li><?php echo HTML::anchor(Route::get('admin_main')->uri(array('controller'=>'users','action'=>'list')), 'User List') ?></li>
+ <li><?php echo HTML::anchor(Route::get('admin_main')->uri(array('controller'=>'users','action'=>'new')), 'Add User') ?></li>
+ <li><?php echo HTML::anchor(Route::get('admin_main')->uri(array('controller'=>'users','action'=>'profile')), 'Edit Profile') ?></li>
+ </ul>
+ </p>
+</div>
View
5 views/admin/users/widget/none.php
@@ -0,0 +1,5 @@
+<h1>Users List</h1>
+<p>
+ There are no users at this time
+ (<?php echo Html::anchor('admin/users/new', 'create one') ?>).
+</p>
View
11 views/admin/users/widget/view.php
@@ -0,0 +1,11 @@
+<h1><?php echo $user->username ?></h1>
+<dl>
+ <dt>Username:</dt>
+ <dd><?php echo $user->username ?></dd>
+ <dt>Email:</dt>
+ <dd><?php echo $user->email ?></dd>
+ <dt>Role:</dt>
+ <dd><?php echo $user->role ?></dd>
+ <dt>Last Login:</dt>
+ <dd><?php echo $user->last_login ?></dd>
+</dl>

0 comments on commit e03f1af

Please sign in to comment.
Something went wrong with that request. Please try again.