Misc improvements

This commit is contained in:
Timothy Warren 2015-06-04 16:25:47 -04:00
parent 906bec446f
commit cd14bede74
13 changed files with 64 additions and 31 deletions

View File

@ -38,11 +38,6 @@ class category extends \miniMVC\Controller {
$id = (int) miniMVC\get_last_segment();
}
if ($id === 0)
{
miniMVC\show_404();
}
$data = array(
'category' => $this->data_model->get_category_by_id($id),
'sections' => $this->data_model->get_category_outline_data($id),
@ -50,6 +45,12 @@ class category extends \miniMVC\Controller {
'category_id' => $id
);
if (empty($data['category']))
{
$this->page->render_message('error', "Category doesn't exist.");
return;
}
$this->render('category_detail', $data);
}

View File

@ -78,6 +78,14 @@ class genre extends \miniMVC\Controller {
$genre = $this->data_model->get_genre_by_id($id);
$categories = $this->data_model->get_categories($id);
if (empty($genre))
{
$this->page->render_message('error', "Genre doesn't exist.");
return;
return;
}
$data = array(
'genre' => $genre,
'categories' => $categories,

View File

@ -38,11 +38,6 @@ class section extends \miniMVC\Controller {
$id = (int) miniMVC\get_last_segment();
}
if ($id === 0)
{
miniMVC\show_404();
}
$data = array(
'section' => $this->data_model->get_section_by_id($id),
'sdata' => $this->data_model->get_data($id),
@ -50,6 +45,12 @@ class section extends \miniMVC\Controller {
'section_id' => $id
);
if (empty($data['section']))
{
$this->page->render_message('error', "Section doesn't exist.");
return;
}
$this->render('section_detail', $data);
}

View File

@ -23,8 +23,8 @@
<li>
<h4><a href="<?= miniMVC\site_url("section/detail/{$id}") ?>"><?= $section ?></a></h4>
<span class="modify" data-id="<?= $id ?>" data-type="section" data-parent="<?= $category_id ?>">
<button class="edit">Edit</button>
<button class="delete">Delete</button>
<button class="edit">Edit Section</button>
<button class="delete">Delete Section</button>
</span>
<?php if ( ! empty($d)): ?>

View File

@ -21,8 +21,8 @@
<li>
<a href="<?= miniMVC\site_url("category/detail/{$id}") ?>"><?= $cat ?></a>
<span class="modify" data-type="category" data-id="<?=$id ?>" data-parent="<?=$genre_id ?>">
<button class="edit">Edit</button>
<button class="delete">Delete</button>
<button class="edit">Edit Category</button>
<button class="delete">Delete Category</button>
</span>
</li>
<?php endforeach ?>

View File

@ -22,8 +22,8 @@
<?= $name ?>
</a>
<span class="modify" data-id="<?= $id ?>" data-type="genre" data-parent="<?=$id ?>">
<button class="edit">Edit</button>
<button class="delete">Delete</button>
<button class="edit">Edit Genre</button>
<button class="delete">Delete Genre</button>
</span>
</li>
<?php endforeach ?>

View File

@ -13,7 +13,7 @@
<input type="text" name="name[]" id="section" /></dd>
<dt><label for="val">Value:</label></dt><dd>
<textarea id="input" name="val[]" rows="5" cols="40"></textarea></dd>
<textarea id="val" name="val[]" rows="5" cols="40"></textarea></dd>
<dt><input type="hidden" name="section_id" value="<?= $section_id ?>" /></dt><dd>
<button type="submit" class="save">Save Data</button></dd>
@ -30,8 +30,8 @@
<dt>
<?= $k ?>
<span class="modify" data-type="data" data-id="<?=$d_id ?>" data-parent="<?= $section_id ?>">
<button class="edit">Edit</button>
<button class="delete">Delete</button>
<button class="edit">Edit Data</button>
<button class="delete">Delete Data</button>
</span>
</dt>
<dd><?= $v ?></dd>

View File

@ -1,7 +1,7 @@
<div id="overlay_bg"></div>
<div id="overlay"></div>
<h5>Queries:</h5>
<?php /*<h5>Queries:</h5>
<?php unset($queries['total_time']); ?>
<?php foreach($queries as $q): ?>
<pre><code class="language-sql"><?= $q['sql'] ?></code></pre><br />
<?php endforeach ?>
<?php endforeach ?> */ ?>

View File

@ -120,6 +120,10 @@ li li, li dt {
z-index:3;
}
form dd input {
width:90%;
}
li:hover > .modify, dt:hover > .modify, dd:hover > .modify {
display:inline-block;
vertical-align:top;

View File

@ -223,8 +223,8 @@ $_.ext('center', function (sel){
$_.event.live('#edit_form', 'submit', meta.update_item);
// WYSIWYG on section/data pages
if (document.getElementById('textarea') != null)
if (document.getElementsByTagName('textarea') != null)
{
meta.initTINY('textarea');
meta.initTINY('val');
}
}(window, $_));

View File

@ -37,6 +37,12 @@ define('MM_APP_PATH', __DIR__.'/app/');
// Autoload vendors
require(MM_BASE_PATH . '/vendor/autoload.php');
// Setup error handling
$whoops = new \Whoops\Run();
$defaultHandler = new PrettyPageHandler();
$whoops->pushHandler($defaultHandler);
$whoops->register();
// Require the basic configuration file
require(MM_APP_PATH . 'config/config.php');
@ -46,11 +52,6 @@ require(MM_SYS_PATH . 'common.php');
// Start the autoloader
spl_autoload_register('miniMVC\autoload');
// Setup error handling
$whoops = new \Whoops\Run();
$defaultHandler = new PrettyPageHandler();
$whoops->pushHandler($defaultHandler);
// And away we go!
init();

View File

@ -300,7 +300,8 @@ function route()
// 404 Condition
if (empty($route))
{
show_404();
throw new \Exception("404: Page not found.");
//show_404();
return;
}

View File

@ -543,6 +543,23 @@ class Page {
// --------------------------------------------------------------------------
/**
* Render Message
*
* Render a full page message
* @param string $type
* @param string $message
*/
public function render_message($type, $message)
{
$this->render('message', [
'stat_class' => $type,
'message' => $message
]);
}
// --------------------------------------------------------------------------
/**
* Output String
*