Example #1
0
function navbar()
{
    $routes = translateRoutes();
    $navbar_setup['home'] = '';
    // Get data from routes:
    foreach ($routes as $id => $route) {
        if (isset($route['navbar'])) {
            $data = $route['navbar'];
            $url = '';
            if ($route['request'] != 'home') {
                $url = $id;
            }
            // Set view navbar with a sngle page link:
            if ($data['type'] == 'link') {
                // To set single link within a group of navbar links:
                if (!empty($data['group'])) {
                    $navbar_setup[$data['group']]['type'] = 'list';
                    $navbar_setup[$data['group']]['name'] = $data['group'];
                    $navbar_setup[$data['group']]['items'][$id] = array('url' => $id, 'name' => $data['name']);
                } else {
                    $navbar_setup[$id] = array('type' => 'link', 'url' => $url, 'name' => $data['name']);
                }
                // Set view navbar with a menu of sub-section links:
            } elseif ($data['type'] == 'list') {
                $navbar_setup[$id] = array('type' => 'list', 'name' => $id, 'items' => array());
                foreach ($data['list'] as $key => $list_item_name) {
                    $navbar_setup[$id]['items'][$list_item_name] = array('url' => $id . '/item=' . ($key + 1) . '/', 'name' => $list_item_name);
                }
                // Where the menu items are in a database table and accessd via a model:
            } elseif ($data['type'] == 'model') {
                /* **** Needs recoding ****
                				$data_filter = 0;
                				require('app/models/'.$data['source']['model']['name'].'.php');
                				foreach($model as $item_id => $item) {
                					$navbar_setup[$id]['items'][] = array('url' => $route['request'].$item_id, 'name' => $item[$data['source']['model']['field']]);
                				}
                			*/
            }
        }
    }
    return $navbar_setup;
}
Example #2
0
 require_once 'config/global.php';
 require_once 'app/core/functions.php';
 $GLOBALS['debug'] = true;
 // Set core variables from user request:
 $uri = array($argv[0], $argv[1], $argv[2]);
 $command = $uri[1];
 $section = $uri[2];
 $GLOBALS['model'] = $section;
 // Set allowed commands:
 $command_routines = array('create', 'delete');
 // Set MVC naming protocol:
 $mvc_elements = array('controllers', 'models', 'views');
 // Set file paths:
 $app_paths = array('config' => 'config/global.php', 'routes' => 'config/routes.json', 'functions' => 'app/core/functions.php', 'db_sql' => 'db/migrate.php', 'htaccess_rules' => '.htaccess');
 // Build Routes from app/config/routes.json
 $routes = translateRoutes();
 // Set procedure and default error logs:
 $procedure_elements = array('mvc_status', 'write_routes', 'db_action1', 'db_action2', 'write_htaccess');
 // Check MySQL config is set:
 if (empty($db_config['db_server']) or empty($db_config['db_user']) or empty($db_config['db_pass']) or empty($db_config['db'])) {
     $mysql = false;
     unset($procedure_elements[2]);
     unset($procedure_elements[3]);
 } else {
     $mysql = true;
 }
 // Declare functions to load for each procedure:
 $procedure = array('mvc_status' => array(array('function' => 'createMVC', 'args' => array($mvc_elements, $section, $mysql)), array('function' => 'removeMVC', 'args' => array($mvc_elements, $section))), 'write_routes' => array(array('function' => 'updateRoutes', 'args' => array($config, $app_paths, $routes, $section)), array('function' => 'resetRoutes', 'args' => array($app_paths, $routes, $section))), 'db_action1' => array(array('function' => 'dbRequest', 'args' => array(array('db' => 'mysql', 'mode' => 'CREATE', 'fields' => array('title' => 'varchar(255) NOT NULL DEFAULT \'\'', 'content' => 'varchar(255) NOT NULL DEFAULT \'\'')))), array('function' => 'dbRequest', 'args' => array(array('db' => 'mysql', 'mode' => 'DELETE')))), 'db_action2' => array(array('function' => 'dbRequest', 'args' => array(array('db' => 'mysql', 'mode' => 'INSERT', 'fields' => array('title' => '"' . ucfirst(preg_replace('@_@', ' ', $section)) . '"', 'content' => '"' . preg_replace('@_@', ' ', $section) . ' content"')))), array('function' => 'dbRequest', 'args' => array(array('db' => 'mysql', 'mode' => 'DROP')))), 'write_htaccess' => array(array('function' => 'updateHTaccessRules', 'args' => array($app_paths, $section, 'include')), array('function' => 'updateHTaccessRules', 'args' => array($app_paths, $section, 'remove'))));
 // Function to call each process according to section procedure:
 function runProcess($procedure_report, $procedure, $element, $mysql)
 {