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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
<div id="overlay_bg"></div> <div id="overlay_bg"></div>
<div id="overlay"></div> <div id="overlay"></div>
<h5>Queries:</h5> <?php /*<h5>Queries:</h5>
<?php unset($queries['total_time']); ?> <?php unset($queries['total_time']); ?>
<?php foreach($queries as $q): ?> <?php foreach($queries as $q): ?>
<pre><code class="language-sql"><?= $q['sql'] ?></code></pre><br /> <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; z-index:3;
} }
form dd input {
width:90%;
}
li:hover > .modify, dt:hover > .modify, dd:hover > .modify { li:hover > .modify, dt:hover > .modify, dd:hover > .modify {
display:inline-block; display:inline-block;
vertical-align:top; vertical-align:top;

View File

@ -51,7 +51,7 @@ $_.ext('center', function (sel){
var meta = {}; var meta = {};
w.meta = meta; w.meta = meta;
/** /**
* Create the WYSIWYG editor box * Create the WYSIWYG editor box
*/ */
@ -221,10 +221,10 @@ $_.ext('center', function (sel){
// Edit form submission // Edit form submission
$_.event.live('#edit_form', 'submit', meta.update_item); $_.event.live('#edit_form', 'submit', meta.update_item);
// WYSIWYG on section/data pages // WYSIWYG on section/data pages
if (document.getElementById('textarea') != null) if (document.getElementsByTagName('textarea') != null)
{ {
meta.initTINY('textarea'); meta.initTINY('val');
} }
}(window, $_)); }(window, $_));

View File

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

View File

@ -300,7 +300,8 @@ function route()
// 404 Condition // 404 Condition
if (empty($route)) if (empty($route))
{ {
show_404(); throw new \Exception("404: Page not found.");
//show_404();
return; 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 * Output String
* *