Simplify and add lightness

This commit is contained in:
Timothy Warren 2015-06-04 14:30:42 -04:00
parent c37c050548
commit 140fef2cda
50 changed files with 824 additions and 1890 deletions

4
.gitignore vendored Normal file → Executable file
View File

@ -1,3 +1,5 @@
sys/*.sqlite
docs/*
assets/js/cache/*
assets/js/cache/*
vendor/*
composer.lock

0
README.md Normal file → Executable file
View File

34
app/classes/controller.php Normal file → Executable file
View File

@ -29,37 +29,9 @@ abstract class Controller extends \miniMVC\Controller {
{
parent::__construct();
$this->load_model('meta\data_model');
$this->load_model('meta\user_model');
$this->session =& \miniMVC\Session::get_instance();
// Check if user is logged in
$this->check_login_status();
$this->page->build_header();
}
/**
* Require user login for access
*/
private function check_login_status()
{
if ( ! isset($this->session->uid))
{
// Redirect to login
}
return;
}
/**
* Destruct controller and build page footer
*/
public function __destruct()
{
$this->page->set_foot_js_group('js');
$this->page->build_footer();
$db = \miniMVC\db::get_instance();
$this->page->queries =& $db->queries;
}
}

9
app/config/config.php Normal file → Executable file
View File

@ -31,12 +31,7 @@
| slash.
|
*/
// Determine the default site url
$ri = $_SERVER['REQUEST_URI'];
$ind_pos = stripos($ri, "index.php");
$default_path = ($ind_pos !== FALSE) ? substr($ri, 0, $ind_pos) : $ri;
$default_baseurl = "//" . str_replace("//", "/", $_SERVER['HTTP_HOST']. $default_path);
define('BASE_URL', $default_baseurl);
define('BASE_URL', '//' . $_SERVER['HTTP_HOST'] . '/');
/*
|--------------------------------------------------------------------------
@ -46,7 +41,7 @@ define('BASE_URL', $default_baseurl);
| This determines whether "index.php" is in generated urls
|
*/
define('URL_INDEX_FILE', 'index.php/');
define('URL_INDEX_FILE', '');
/*
|--------------------------------------------------------------------------

28
app/config/routes.php Normal file → Executable file
View File

@ -29,20 +29,22 @@
// --------------------------------------------------------------------------
return array(
$routes = [
// Default Paths
'default_controller' => 'welcome',
'default_module' => 'meta',
'delete' => 'meta/welcome/delete',
'update' => 'meta/welcome/update_item',
'genre' => 'meta/genre/index',
'genre/add' => 'meta/genre/add',
'genre/add_category' => 'meta/genre/add_category',
'category' => 'meta/category/index',
'category/add_section' => 'meta/category/add_section',
'section' => 'meta/section/index',
'section/add_data' => 'meta/section/add_data',
'default_controller' => 'genre',
'404_route' => '',
);
];
// Add default routes
$router->add('home', '/');
$router->add(null, '/{controller}/{action}/{id}');
$router->add('no_id', '/{controller}/{action}');
// Custom routes
$router->add('outline', '/outline');
$router->add('edit', '/edit');
$router->add('delete', '/delete');
$router->addPost('data_add', '/section/add_data');
$router->addPost('update', '/update');
// End of routes.php

6
app/modules/meta/controllers/category.php Normal file → Executable file
View File

@ -31,7 +31,7 @@ class category extends meta\controller {
/**
* Returns the sections / editing options for a category
*/
public function index($id = 0)
public function detail($id = 0)
{
if ($id === 0)
{
@ -50,7 +50,7 @@ class category extends meta\controller {
'category_id' => $id
);
$this->load_view('category_detail', $data);
$this->render('category_detail', $data);
}
/**
@ -74,7 +74,7 @@ class category extends meta\controller {
$this->page->set_message('error', 'Section already exists for this category');
}
$this->index($id);
$this->detail($id);
}
}

139
app/modules/meta/controllers/genre.php Normal file → Executable file
View File

@ -20,39 +20,20 @@
*/
class genre extends meta\controller {
/**
* Initialize the Controller
*/
public function __construct()
{
parent::__construct();
}
/**
* Default controller method
*/
public function index($id = 0)
public function index()
{
if ($id === 0)
{
// Re-route to detail page if the last segment
// is a valid integer
$id = (int) miniMVC\get_last_segment();
}
$data = array();
$data['genres'] = $this->data_model->get_genres();
if ($id === 0)
{
// Otherwise, display list of genres
$data = array();
$data['genres'] = $this->data_model->get_genres();
$this->render('genres', $data);
$this->load_view('genres', $data);
return;
}
return $this->detail($id);
return;
}
// --------------------------------------------------------------------------
/**
* Adds a new genre
@ -77,14 +58,23 @@ class genre extends meta\controller {
// Render the basic page
$this->index();
}
// --------------------------------------------------------------------------
/**
* Returns the categories / editing options for a genre
*
* @param int
*/
public function detail($id)
public function detail($id = 0)
{
if ($id === 0)
{
// Re-route to detail page if the last segment
// is a valid integer
$id = (int) miniMVC\get_last_segment();
}
$genre = $this->data_model->get_genre_by_id($id);
$categories = $this->data_model->get_categories($id);
@ -94,8 +84,10 @@ class genre extends meta\controller {
'genre_id' => $id
);
$this->load_view('genre_detail', $data);
$this->render('genre_detail', $data);
}
// --------------------------------------------------------------------------
/**
* Adds a category to the current genre
@ -120,6 +112,97 @@ class genre extends meta\controller {
$this->detail($id);
}
// --------------------------------------------------------------------------
/**
* Display an outline of the data for a table of contents
*/
public function outline()
{
$outline_data = $this->data_model->get_outline_data();
$this->render('outline', array('outline' => $outline_data));
}
// --------------------------------------------------------------------------
/**
* Get a message for ajax insertion
*/
public function message()
{
$type = strip_tags($_GET['type']);
$message = $_GET['message'];
$this->page->set_output(
$this->page->set_message($type, $message, TRUE)
);
}
// --------------------------------------------------------------------------
public function delete()
{
$type = strip_tags($_POST['type']);
$valid_types = ['genre', 'category', 'section', 'data'];
$res = (in_array($type, $valid_types))
? $this->data_model->delete($type, (int) $_POST['id'])
: 0;
exit(mb_trim($res));
}
// --------------------------------------------------------------------------
public function edit()
{
$type = strip_tags($_GET['type']);
$id = (int) $_GET['id'];
if ($this->data_model->is_valid_type($type))
{
$data = call_user_func(array($this->data_model, "get_{$type}_by_id"), $id);
$form_array = array(
'name' => is_array($data) ? $data['key'] : "",
'val' => is_array($data) ? $data['value'] : $data,
'type' => $type,
'id' => $id
);
exit($this->load_view('edit_form', $form_array, TRUE));
}
}
// --------------------------------------------------------------------------
public function update()
{
$id = (int) $_POST['id'];
$type = strip_tags($_POST['type']);
$name = strip_tags($_POST['name']);
$val = (isset($_POST['val'])) ? $_POST['val'] : NULL;
if ($this->data_model->is_valid_type($type))
{
if ($type != 'data')
{
$res = $this->data_model->update($type, $id, $name);
}
else
{
$res = $this->data_model->update_data($id, $name, $val);
}
$res = (int) $res;
exit(mb_trim($res));
}
exit(0);
}
}
// End of genre.php

6
app/modules/meta/controllers/section.php Normal file → Executable file
View File

@ -31,7 +31,7 @@ class section extends meta\controller {
/**
* Default controller method
*/
public function index($id=0)
public function detail($id=0)
{
if ($id === 0)
{
@ -50,7 +50,7 @@ class section extends meta\controller {
'section_id' => $id
);
$this->load_view('section_detail', $data);
$this->render('section_detail', $data);
}
/**
@ -77,7 +77,7 @@ class section extends meta\controller {
? $this->page->set_message('success', 'Added data')
: $this->page->set_message('error', 'Data already exists');
$this->index($section_id);
$this->detail($section_id);
}
}

View File

@ -1,167 +0,0 @@
<?php
/**
* meta
*
* Hierarchial data tool
*
* @package meta
* @author Timothy J. Warren
* @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/meta
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
/**
* Default Controller class
*
* @package meta
*/
class welcome extends \meta\controller {
/**
* Initialize the constructor
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
// --------------------------------------------------------------------------
/**
* Default route for the controller
*
* @return void
*/
public function index()
{
$data = array();
$data['genres'] = $this->data_model->get_genres();
$this->load_view('genres', $data);
}
// --------------------------------------------------------------------------
/**
* Authenticate a user
*/
public function login()
{
$this->load_view('login');
}
// --------------------------------------------------------------------------
/**
* Logout
*/
public function logout()
{
}
// --------------------------------------------------------------------------
/**
* Display an outline of the data for a table of contents
*/
public function outline()
{
$outline_data = $this->data_model->get_outline_data();
$this->load_view('outline', array('outline' => $outline_data));
}
// --------------------------------------------------------------------------
/**
* Get a message for ajax insertion
*/
public function message()
{
$type = strip_tags($_GET['type']);
$message = $_GET['message'];
$this->page->set_output(
$this->page->set_message($type, $message, TRUE)
);
}
// --------------------------------------------------------------------------
public function delete()
{
$type = strip_tags($_POST['type']);
switch($type)
{
case "genre":
case "category":
case "section":
case "data":
$res = (int) $this->data_model->delete($type, (int) $_POST['id']);
break;
default:
$res = 0;
break;
}
die(trim($res));
}
// --------------------------------------------------------------------------
public function edit()
{
$type = strip_tags($_GET['type']);
$id = (int) $_GET['id'];
if ($this->data_model->is_valid_type($type))
{
$data = call_user_func(array($this->data_model, "get_{$type}_by_id"), $id);
$form_array = array(
'name' => is_array($data) ? $data['key'] : "",
'val' => is_array($data) ? $data['value'] : $data,
'type' => $type,
'id' => $id
);
exit($this->load_view('edit_form', $form_array, TRUE));
}
}
// --------------------------------------------------------------------------
public function update_item()
{
$id = (int) $_POST['id'];
$type = strip_tags($_POST['type']);
$name = strip_tags($_POST['name']);
$val = (isset($_POST['val'])) ? $_POST['val'] : NULL;
if ($this->data_model->is_valid_type($type))
{
if ($type != 'data')
{
$res = $this->data_model->update($type, $id, $name);
}
else
{
$res = $this->data_model->update_data($id, $name, $val);
}
$res = (int) $res;
exit(trim($res));
}
exit(0);
}
}
// End of welcome.php

216
app/modules/meta/models/data_model.php Normal file → Executable file
View File

@ -15,6 +15,8 @@
namespace meta;
use \miniMVC\db;
/**
* Main Model for database interaction
*
@ -42,9 +44,7 @@ class data_model extends \miniMVC\Model {
public function __construct()
{
parent::__construct();
$this->session =& \miniMVC\Session::get_instance();
$this->db =& \miniMVC\db::get_instance();
$this->db = db::get_instance();
}
// --------------------------------------------------------------------------
@ -113,7 +113,7 @@ class data_model extends \miniMVC\Model {
->where('id', (int) $id)
->update($type);
return ( ! empty($query)) ;
return (bool) $query;
}
// --------------------------------------------------------------------------
@ -128,19 +128,13 @@ class data_model extends \miniMVC\Model {
*/
public function update_data($data_id, $key, $val)
{
try{
// Save the data
$this->db->set('key', $key)
->set('value', $val)
->where('id', (int) $data_id)
->update('data');
}
catch(\PDOException $e)
{
return FALSE;
}
// Save the data
$query = $this->db->set('key', $key)
->set('value', $val)
->where('id', (int) $data_id)
->update('data');
return TRUE;
return (bool) $query;
}
// --------------------------------------------------------------------------
@ -161,13 +155,13 @@ class data_model extends \miniMVC\Model {
->limit(1)
->get();
// Fetch the data as a workaround
// for databases that do not support
// grabbing result counts (SQLite / Firebird)
$array = $query->fetchAll(\PDO::FETCH_ASSOC);
if (count($array) < 1)
$res = $query->fetch();
if (count($res) < 1)
{
$this->db->set('genre', $genre)
$id = $this->get_next_id("genre");
$this->db->set('id', $id)
->set('genre', $genre)
->insert('genre');
return TRUE;
@ -195,13 +189,13 @@ class data_model extends \miniMVC\Model {
->limit(1)
->get();
// Fetch the data as a workaround
// for databases that do not support
// grabbing result counts (SQLite / Firebird)
$array = $query->fetchAll();
if (count($array)< 1)
$res = $query->fetch();
if (count($res) < 1)
{
$this->db->set('category', $cat)
$id = $this->get_next_id('category');
$this->db->set('id', $id)
->set('category', $cat)
->set('genre_id', $genre_id)
->insert('category');
@ -234,7 +228,9 @@ class data_model extends \miniMVC\Model {
$array = $q->fetchAll();
if (count($array) < 1)
{
$this->db->set('section', $section)
$id = $this->get_next_id('section');
$this->db->set('id', $id)
->set('section', $section)
->set('category_id', (int) $category_id)
->insert('section');
@ -262,10 +258,14 @@ class data_model extends \miniMVC\Model {
->where('key', $key)
->get();
if ($this->db->num_rows() > 0) return FALSE;
$res = $q->fetch();
if (count($res) > 0) return FALSE;
// Save the data
$this->db->set('key', $key)
$id = $this->get_next_id('data');
$this->db->set('id', $id)
->set('key', $key)
->set('value', $val)
->set('section_id', (int) $section_id)
->insert('data');
@ -274,8 +274,6 @@ class data_model extends \miniMVC\Model {
return TRUE;
}
// --------------------------------------------------------------------------
// ! Data Retrieval
// --------------------------------------------------------------------------
@ -290,8 +288,8 @@ class data_model extends \miniMVC\Model {
{
$query = $this->db->select('genre, genre_id, category, category_id')
->from('section s')
->join('category c', 'c.id=s.category_id')
->join('genre g', 'g.id=c.genre_id')
->join('category c', 'c.id=s.category_id', 'inner')
->join('genre g', 'g.id=c.genre_id', 'inner')
->where('s.id', $section_id)
->get();
@ -310,7 +308,7 @@ class data_model extends \miniMVC\Model {
$genres = array();
$query = $this->db->select('id, genre')
->from('genre')
->order_by('genre', 'asc')
->orderBy('genre', 'asc')
->get();
while($row = $query->fetch(\PDO::FETCH_ASSOC))
@ -377,6 +375,7 @@ class data_model extends \miniMVC\Model {
$query = $this->db->select('id, category')
->from('category')
->where('genre_id', (int) $genre_id)
->orderBy('category', 'asc')
->get();
while($row = $query->fetch(\PDO::FETCH_ASSOC))
@ -422,6 +421,7 @@ class data_model extends \miniMVC\Model {
$query = $this->db->select('id, section')
->from('section')
->where('category_id', (int) $category_id)
->orderBy('section', 'asc')
->get();
while($row = $query->fetch(\PDO::FETCH_ASSOC))
@ -467,6 +467,7 @@ class data_model extends \miniMVC\Model {
$query = $this->db->select('id, key, value')
->from('data')
->where('section_id', (int) $section_id)
->orderBy('key', 'asc')
->get();
while($row = $query->fetch(\PDO::FETCH_ASSOC))
@ -510,6 +511,7 @@ class data_model extends \miniMVC\Model {
// Get the sections
$s_query = $this->db->from('section')
->where('category_id', (int) $category_id)
->orderBy('section', 'asc')
->get();
$sections = array();
@ -525,7 +527,8 @@ class data_model extends \miniMVC\Model {
if ( ! empty($sections))
{
$d_query = $this->db->from('data')
->where_in('section_id', array_keys($sections))
->whereIn('section_id', array_keys($sections))
->orderBy('key', 'asc')
->get();
while($row = $d_query->fetch(\PDO::FETCH_ASSOC))
@ -557,62 +560,24 @@ class data_model extends \miniMVC\Model {
public function get_outline_data()
{
// Get the genres
$g_query = $this->db->from('genre')
$query = $this->db->select('g.id, genre,
c.id AS cat_id, category,
s.id AS section_id, section')
->from('genre g')
->join('category c', 'c.genre_id=g.id', 'inner')
->join('section s', 's.category_id=c.id', 'inner')
->orderBy('genre', 'asc')
->orderBy('category', 'asc')
->orderBy('section', 'asc')
->get();
$genres = array();
$return = array();
while ($row = $g_query->fetch(\PDO::FETCH_ASSOC))
// Create the nested array
while ($row = $query->fetch(\PDO::FETCH_ASSOC))
{
$genres[$row['id']] = $row['genre'];
}
// Get the categories
$c_query = $this->db->from('category')
->get();
$categories = array();
while($row = $c_query->fetch(\PDO::FETCH_ASSOC))
{
$categories[$row['genre_id']][$row['id']] = $row['category'];
}
// Get the sections
$s_query = $this->db->from('section')
->get();
$sections = array();
while($row = $s_query->fetch(\PDO::FETCH_ASSOC))
{
$sections[$row['category_id']][$row['id']] = $row['section'];
}
// Organize into a nested array
foreach($genres as $genre_id => $genre)
{
$return[$genre_id][$genre] = array();
$g =& $return[$genre_id][$genre];
// Categories for this genre
if (isset($categories[$genre_id]))
{
$g = $categories[$genre_id];
foreach($categories[$genre_id] as $category_id => $category)
{
$g[$category_id] = array($category => array());
$c =& $g[$category_id][$category];
// Sections for this category
if (isset($sections[$category_id]))
{
$c = $sections[$category_id];
}
}
}
extract($row);
$return[$id][$genre][$cat_id][$category][$section_id] = $section;
}
return $return;
@ -649,7 +614,7 @@ class data_model extends \miniMVC\Model {
{
$query = $this->db->select('id')
->from($type)
->order_by('id', 'DESC')
->orderBy('id', 'DESC')
->limit(1)
->get();
@ -660,6 +625,77 @@ class data_model extends \miniMVC\Model {
// --------------------------------------------------------------------------
/**
* Get the next id for database insertion
*
* @param string $table_name
* @param string $field
* @return int
*/
public function get_next_id($table_name, $field="id")
{
$query = $this->db->select("MAX($field) as last_id")
->from($table_name)
->limit(1)
->get();
$row = $query->fetch(\PDO::FETCH_ASSOC);
if (empty($row))
{
$id = 1;
}
else
{
$id = intval($row['last_id']) + 1;
}
return $id;
}
// --------------------------------------------------------------------------
public function create_tables()
{
$tables = [
'genre' => $this->db->util->create_table('genre', [
'id' => 'INT NOT NULL PRIMARY KEY',
'genre' => 'VARCHAR(255)'
]),
'category' => $this->db->util->create_table('category', [
'id' => 'INT NOT NULL PRIMARY KEY',
'genre_id' => 'INT NOT NULL',
'category' => 'VARCHAR(255)'
],[
'genre_id' => ' REFERENCES "genre" '
]),
'section' => $this->db->util->create_table('section', [
'id' => 'INT NOT NULL PRIMARY KEY',
'category_id' => 'INT NOT NULL',
'section' => 'VARCHAR(255)'
],[
'category_id' => ' REFERENCES "category" '
]),
'data' => $this->db->util->create_table('data', [
'id' => 'INT NOT NULL PRIMARY KEY',
'section_id' => 'INT NOT NULL',
'key' => 'VARCHAR(255)',
'value' => 'BLOB SUB_TYPE TEXT'
],[
'section_id' => ' REFERENCES "section"'
])
];
foreach($tables as $table => $sql)
{
// Add the table
$this->db->query($sql);
echo "{$sql};<br />";
}
}
}
// End of data_model.php

View File

@ -1,120 +0,0 @@
<?php
/**
* meta
*
* Simple hierarchial data management
*
* @package meta
* @author Timothy J. Warren
* @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/meta
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
namespace meta;
/**
* Model for dealing with user logins / permissions
*
* @package meta
*/
class user_model extends \miniMVC\Model {
/**
* Reference to database connection
*
* @var Query_Builder
*/
protected $db;
/**
* Reference to bcrypt object
*
* @var Bcrypt
*/
protected $bcrypt;
/**
* Reference to session
*
* @var Session
*/
protected $session;
/**
* Initialize the User model
*/
public function __construct()
{
parent::__construct();
$this->bcrypt = new \Bcrypt(15);
$this->db =& \miniMVC\db::get_instance();
$this->session =& \miniMVC\Session::get_instance();
}
// --------------------------------------------------------------------------
/**
* Add a user for access
*
* @param string
* @param string
* @param string
*/
public function add_user($username, $pass1, $pass2)
{
// Check for the existing username
$query = $this->db->select('username')
->from('user')
->where('username', $username)
->get();
$res = $query->fetch(\PDO::FETCH_ASSOC);
if (empty($res)) return FALSE;
// Verify that passwords match
if ($pass1 !== $pass2) return FALSE;
// Add user
$hashed = $this->bcrypt->hash($pass1);
$this->db->set('username', $username)
->set('hash', $hashed)
->insert('user');
return TRUE;
}
// --------------------------------------------------------------------------
/**
* Check and see if the login is valid
*
* @param string
* @param string
* @return bool
*/
public function check_login($username, $pass)
{
$query = $this->db->from('user')
->where('username', $username)
->get();
$row = $query->fetch(\PDO::FETCH_ASSOC);
// The user does not exist
if (empty($row))
{
return FALSE;
}
return $this->bcrypt->verify($pass, $row['hash']);
}
}
// End of user_model.php

26
app/modules/meta/views/category_detail.php Normal file → Executable file
View File

@ -1,5 +1,5 @@
<p class="breadcrumbs">
<a href="<?= miniMVC\site_url('') ?>">Genres</a> > <a href="<?= miniMVC\site_url('genres/detail/'.$genre['id']) ?>"><?= $genre['genre'] ?></a> > <?= $category ?>
<a href="<?= miniMVC\site_url('') ?>">Genres</a> > <a href="<?= miniMVC\site_url('genre/detail/'.$genre['id']) ?>"><?= $genre['genre'] ?></a> > <?= $category ?>
</p>
<form class="add" action="<?= miniMVC\site_url("category/add_section") ?>" method="post">
@ -22,27 +22,23 @@
<?php if (is_array($section)) list($section, $d) = $section ?>
<li>
<h4><a href="<?= miniMVC\site_url("section/detail/{$id}") ?>"><?= $section ?></a></h4>
<span class="modify" id="section_<?=$id ?>">
<span class="modify" data-id="<?= $id ?>" data-type="section" data-parent="<?= $category_id ?>">
<button class="edit">Edit</button>
<button class="delete">Delete</button>
</span>
<?php if ( ! empty($d)): ?>
<?php foreach($d as $did => $dd): ?>
<?php foreach($dd as $k => $v): ?>
<?php $class = (strpos($v, "<br />") !== FALSE) ? 'multiline' : 'pair' ?>
<dl class="<?= $class ?>">
<dt><?= $k ?></dt>
<dd>
<?= $v ?>
</dd>
</dl>
<?php foreach($dd as $k => $v): ?>
<?php $class = (strpos($v, "<ul>") !== FALSE || strpos($v, "<br />") !== FALSE) ? 'multiline' : 'pair' ?>
<dl class="<?= $class ?>">
<dt><?= $k ?></dt>
<dd>
<?= $v ?>
</dd>
</dl>
<?php endforeach ?>
<?php endforeach ?>
<?php endforeach ?>
<?php endif ?>
<?php $d = array(); // Don't let data linger ?>

0
app/modules/meta/views/edit_form.php Normal file → Executable file
View File

16
app/modules/meta/views/genre_detail.php Normal file → Executable file
View File

@ -19,23 +19,11 @@
<ul class="list">
<?php foreach($categories as $id => $cat): ?>
<li>
<a href="<?= miniMVC\site_url("category/{$id}") ?>"><?= $cat ?></a>
<span class="modify" id="category_<?=$id ?>">
<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>
</span>
<ul>
<?php /* $sarray = $this->data_model->get_sections($id); ?>
<?php foreach($sarray as $sid => $section): ?>
<li>
<a href="<?= miniMVC\site_url("section/{$sid}") ?>"><?= $section ?></a>
<span class="modify" id="section_<?=$id ?>">
<button class="edit">Edit</button>
<button class="delete">Delete</button>
</span>
</li>
<?php endforeach */ ?>
</ul>
</li>
<?php endforeach ?>
</ul>

4
app/modules/meta/views/genres.php Normal file → Executable file
View File

@ -18,10 +18,10 @@
<ul class="list">
<?php foreach($genres as $id => $name): ?>
<li>
<a href="<?= miniMVC\site_url("genre/{$id}") ?>">
<a href="<?= miniMVC\site_url("genre/detail/{$id}") ?>">
<?= $name ?>
</a>
<span class="modify" id="genre_<?=$id ?>">
<span class="modify" data-id="<?= $id ?>" data-type="genre" data-parent="<?=$id ?>">
<button class="edit">Edit</button>
<button class="delete">Delete</button>
</span>

View File

@ -1,14 +0,0 @@
<h3>Login</h3>
<form action="<?= miniMVC\site_url('welcome/login') ?>" method="post">
<dl>
<dt><label for="user">Username:</label></dt>
<dd><input type="text" id="user" name="user" /></dd>
<dt><label for="pass">Password:</label></dt>
<dd><input type="password" id="pass" name="pass" /></dd>
<dt>&nbsp;</dt>
<dd><button type="submit">Login</button></dd>
</dl>
</form>

6
app/modules/meta/views/outline.php Normal file → Executable file
View File

@ -20,7 +20,7 @@
<!-- Genres -->
<?php foreach($genre_array as $genre => $cat_array): ?>
<dt>
<a href="<?= \miniMVC\site_url("genre/{$genre_id}") ?>"><?= $genre ?></a>
<a href="<?= \miniMVC\site_url("genre/detail/{$genre_id}") ?>"><?= $genre ?></a>
</dt>
<dd>
@ -29,14 +29,14 @@
<!-- Categories -->
<?php foreach($cname_array as $category => $sect_array): ?>
<li>
<a href="<?= \miniMVC\site_url("category/{$cat_id}") ?>"><?= $category ?></a>
<a href="<?= \miniMVC\site_url("category/detail/{$cat_id}") ?>"><?= $category ?></a>
<?php if ( ! empty($sect_array)): ?>
<ul>
<!-- Sections -->
<?php foreach($sect_array as $section_id => $section): ?>
<li>
<a href="<?= \miniMVC\site_url("section/{$section_id}") ?>">
<a href="<?= \miniMVC\site_url("section/detail/{$section_id}") ?>">
<?= $section ?>
</a>
</li>

44
app/modules/meta/views/section_detail.php Normal file → Executable file
View File

@ -4,8 +4,8 @@
<a href="<?= miniMVC\site_url('category/detail/'.$p['category_id']) ?>"><?= $p['category'] ?></a> >
<?= $section ?>
</p>
<form class="add" action="<?= miniMVC\site_url("section/add_data") ?>" method="post">
<script src="<?= SCRIPT_PATH.'wysiwyg'; ?>"></script>
<form class="add" action="<?= miniMVC\site_url("section/add_data") ?>" method="post" onsubmit="window.edit_wysiwyg.toggle()">
<fieldset>
<legend>Add Data</legend>
<dl>
@ -21,56 +21,22 @@
</dl>
</fieldset>
</form>
<script src="<?= SCRIPT_PATH.'wysiwyg'; ?>"></script>
<script type="text/javascript">
// WYSIWYG
new TINY.editor.edit('editor',
{
id:'input',
width:450,
height:175,
cssclass:'te',
controlclass:'tecontrol',
rowclass:'teheader',
dividerclass:'tedivider',
controls:['bold','italic','underline','strikethrough','|','subscript','superscript','|',
'orderedlist','unorderedlist','|','leftalign',
'centeralign','rightalign','blockjustify','|','unformat','n','undo','redo','|',
'image','hr','link','unlink','|'],
footer:true,
fonts:['Verdana','Arial','Georgia','Trebuchet MS'],
xhtml:true,
cssfile:ASSET_URL+'css.php/g/css',
bodyid:'editor',
footerclass:'tefooter',
toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'},
resize:{cssclass:'resize'}
});
// Make sure the WYSIWYG submits the text
// This just copies the text from the WYSIWYG into the textbox
document.querySelector('form').onsubmit = function(e) {
window.editor.toggle();
};
</script>
<h3>Data</h3>
<?php if ( ! empty($sdata)): ?>
<?php foreach($sdata as $d_id => $d): ?>
<?php foreach($d as $k => $v): ?>
<?php $class = (strpos($v, "<br />") !== FALSE) ? 'multiline' : 'pair' ?>
<?php $class = (strpos($v, "<ul>") !== FALSE || strpos($v, "<br />") !== FALSE) ? 'multiline' : 'pair' ?>
<dl class="<?= $class ?>">
<dt>
<?= $k ?>
<span class="modify" id="data_<?=$d_id ?>">
<span class="modify" data-type="data" data-id="<?=$d_id ?>" data-parent="<?= $section_id ?>">
<button class="edit">Edit</button>
<button class="delete">Delete</button>
</span>
</dt>
<dd><?= $v ?></dd>
</dl>
<?php endforeach ?>
<?php endforeach ?>
<?php endif ?>

View File

@ -1,33 +0,0 @@
<?php
/**
* meta
*
* Hierarchial data tool
*
* @package meta
* @author Timothy J. Warren
* @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/meta
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
/**
* Setup Controller
*
* @package meta
*/
class setup extends \meta\controller {
/**
* Constuctor
*/
public function __construct()
{
}
}
// End of setup.php

0
app/views/errors/error_404.php Normal file → Executable file
View File

0
app/views/errors/error_db.php Normal file → Executable file
View File

0
app/views/errors/error_general.php Normal file → Executable file
View File

0
app/views/errors/error_php_exception.php Normal file → Executable file
View File

2
app/views/footer.php Normal file → Executable file
View File

@ -1,4 +1,4 @@
<?php $this->load_view('theme_footer'); ?>
<?= $this->load_view('theme_footer', ['queries' => $this->queries], TRUE); ?>
<?php if ($foot_js != ""): ?>
<?= $foot_js ?>
<?php endif ?>

5
app/views/header.php Normal file → Executable file
View File

@ -1,12 +1,13 @@
<head>
<?= $meta ?>
<title><?= $title ?></title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<?= $css ?>
<?= $head_tags ?>
<title><?= $title ?></title>
<?php if (!empty($base)) { ?><base href="<?=$base ?>" /><?php } ?>
<?= $head_tags ?>
<?= $head_js ?>
</head>
<body<?= (!empty($body_class)) ? "class=\"" . $body_class . "\"" : ""; ?><?= (!empty($body_id)) ? " id=\"" . $body_id . "\"" : ""; ?>>
<?php $this->load_view('theme_header'); ?>
<?= $this->load_view('theme_header', [], TRUE); ?>

0
app/views/message.php Normal file → Executable file
View File

7
app/views/theme_footer.php Normal file → Executable file
View File

@ -1,2 +1,7 @@
<div id="overlay_bg"></div>
<div id="overlay"></div>
<div id="overlay"></div>
<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 ?>

4
app/views/theme_header.php Normal file → Executable file
View File

@ -1,6 +1,6 @@
<script type="text/javascript">
var APP_URL = '<?= \miniMVC\site_url(); ?>';
var ASSET_URL = APP_URL.replace('index.php/', '') + 'assets/';
var APP_URL = '<?= \miniMVC\site_url(''); ?>';
var ASSET_URL = APP_URL.replace('index.php/', '') + '/assets/';
</script>
<h1><a href="<?= miniMVC\site_url('') ?>">Meta</a></h1>
<span id="outline">[<a href="<?= miniMVC\site_url('outline')?>">Data Outline</a>]</span>

3
assets/config/css_groups.php Normal file → Executable file
View File

@ -24,7 +24,8 @@ return array(
'normalize.css',
'message.css',
'theme.css',
'tinyeditor.css'
'tinyeditor.css',
'prism.css'
)