Step 3. Modify generated code to fit your needs
Folder Structure
- index.php (edit) Main structure of each page
- home.php (edit) Content of home page
- config (edit) Contains configuration files
- paths.cfg.php
- database.cfg.php
- security.cfg.php
- app (edit) MVCs that extends the core maya MVCs
- model
- MayaModel.php
- MenuElement.php
- Role.php
- view
- controller
- Maya.php
- usr (edit) MVCs that extends the core generated models from tables
- model
- view
- controller
- view_bak
- uploads (files uploaded by the MVC above will be placed here)
- Admin.dir (edit) Admin's List, View, Edit interface for all tables
- Users.dir
- List Users.rest.php - includes usr/view/users/list_users.rest.php
- Edit User.hid.rest.php - includes usr/view/users/edit_user.rest.php
- New User.rest.php - includes usr/view/users/new_user.rest.php
- [Other Tables]
- css (edit)
- js (edit) For jquery and javascript plugins
- lib (edit) For php plugins
- images (edit) Images needed by developer for website.
- img (edit) Images default to maya
- usr_generated (do not edit) Generated MVC from tables
- model
- controller
- model_bak
- controller_bak
- maya (do not edit) Core MVC of maya
- util (do not edit) Utilities for generating MVCs from tables
Rules which files should be edited
1) Files from index.php down to the images are the files that can be edited
2) Foldes from img,usr_generated,maya and util should not be edited
3) usr_generated are files automatically generated by the utilities which will be discussed later.
Modify Basic Structure of Page
The index.php determines the basic structure of the page. You can basically placed maya in any html theme structure.
Quick Summary of Process to Integrate Maya into a theme index.php
1. Call the core maya files and instatiate core objects on top of the file
2. Call the maya framework to load css/jquery inside the header section of the html
3. Configure menu based on login conditions
4. Render hidden login form and notice form after the menu section
5. Prepare the div.page where to display the dynamically loaded pages
6. Call display controller and all other javascript before the end marker of the html body section.
A very simple structure is shown below:
<?php
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
require_once 'maya/Maya.php';
$maya = new Maya();
$role= new Role();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Maya Framework</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="" name="keywords">
<meta content="" name="description">
<!-- Favicons -->
<link href="img/favicon.png" rel="icon">
<link href="img/apple-touch-icon.png" rel="apple-touch-icon">
<!-- Csss File -->
<link href="css/xxxx.css" rel="stylesheet">
<?php $maya->view->initializeCssAndJquery();?>
</head>
<body>
<div>SECTION FOR LOGO MENU HEADERS</div>
<div>
<!--- FOR LOGIN FORMS AND MESSAGES -->
<?php $maya->view->generateLoginAndNotice(); ?>
</div>
<div class="container page">
<!--- Main section for displaying contents of the site -->
<?php
$maya->controller->display()
?>
</div>
<div>FOOTER AREA</div>
<!-- Javascript Files -->
<script src="js/main.js"></script>
<?php
$maya->view->initializeScripts(array('mathjax'=>false,'speak'=>false,'chosen'=>true,'wysiwyg'=>true,'datetimepicker'=>true));
?>
</body>
</html>
Detailed Process to Integrate Maya into a theme index.php
1) You must insert the following on the top most part of the index.php the calls of maya core files
<?php
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
require_once 'maya/Maya.php';
$maya = new Maya();
$user= new User()//Optional if you need User object to test for login status;
$role= new Role()//Optional if you need to check roles;
?>
2) You must insert the following right befor end of head section </head>
<?php $maya->view->initializeCssAndJquery();?>
3) You may have to include the default login and notice form right after the headers, but you could also make your own
<?php $maya->view->generateLoginAndNotice(); ?>
4) You may override some menus like
<ul class="nav-menu">
<li class="menu-active"><a href="#hero">Home</a></li>
<?php
if (!$role->isUserLoggedIn())
{
?>
<li class="dropdown"> <a data-toggle="dropdown" href="#" onclick="showLogin()" ><i class="fa fa-user-plus"></i> LOGIN</a></li>
<?php
} else
{
?>
<li><a href="#" class="mx-" mx-container="div.page" mx-click="?command=display_rest&path=Admin.dir/Informations.dir/List Informations.rest.php">Informations</a></li>
<li><a href="#" class="mx-" mx-container="div.page" mx-click="?command=display_rest&path=Admin.dir/Users.dir/List Users.rest.php">Users</a></li>
<li><a href="?command=logout" class="" style=""><i class="fa fa-user-times"></i>LOGOUT</a></li>
<?php
}?>
</ul>
5) You must insert this code inside the div.page where you need to load dynamically loaded pages. The else portion is the default home page like /home1.php
<?php $maya->controller->display(); ?>
6. All other js files should be called at the end of the html before the </body> as shown below
<?php $maya->view->initializeScripts(array("mathjax"=>false,"speak"=>false,"chosen"=>true,"wysiwyg"=>true,"datetimepicker"=>true));?>
The resulting integration of Maya into a more complex theme index.php is shown below:
<?php
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
require_once 'maya/Maya.php';
$maya = new Maya();
$rolw = new Role();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Maya Framework</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="" name="keywords">
<meta content="" name="description">
<!-- Favicons -->
<link href="img/favicon.png" rel="icon">
<link href="img/apple-touch-icon.png" rel="apple-touch-icon">
<?php $maya->view->initializeCssAndJquery();?>
</head>
<body>
<header id="header" class="header header-hide">
<div class="container">
<div id="logo" class="pull-left">
<h1><a href="#body" class="scrollto"><img src="img/maya.png" alt="" style="height:40px;vertical-align:middle" title="" /><span>M</span>aya</a></h1>
</div>
<nav id="nav-menu-container">
<ul class="nav-menu">
<li ><a href="#" class="mx-" mx-container="div.page" mx-click="?command=display_rest&path=home.pub.htm" ><i class="fa fa-home"></i> Home</a></li>
<li><a href="#" class="mx-" mx-container="div.page" mx-click="?command=display_rest&path=advance.pub.htm"><i class="fa fa-star"></i> Advance Topic </a></li>
<?php
if (!$role->isUserLoggedIn())
{
?>
<li class="dropdown"> <a data-toggle="dropdown" href="#" onclick="showLogin()" ><i class="fa fa-user-plus"></i> LOGIN</a></li>
<?php
} else
{
?>
<li><a href="#" class='mx-' mx-container='div.page' mx-click="?command=display_rest&path=Admin.dir/Informations.dir/List Informations.rest.php"><i class="fa fa-database"></i> Informations</a></li>
<li><a href="#" class='mx-' mx-container='div.page' mx-click="?command=display_rest&path=Admin.dir/Finances.dir/List Finances.rest.php"><i class="fa fa-dollar"></i> Finances</a></li>
<li><a href="#"><i class="fa fa-user" ></i> <?php echo $_SESSION['user_name'];?></a>
<ul>
<li><a href="#" class='mx-' mx-container='div.page' mx-click="?command=display_rest&path=Admin.dir/Users.dir/List Users.rest.php"><i class="fa fa-group"></i> Users</a></li>
<li><a href="#" class='mx-' mx-container='div.page' mx-click="?command=display_rest&path=Admin.dir/Tickets.dir/List Tickets.rest.php"><i class="fa fa-bug"></i> Tickets</a></li>
<li><a href="?command=logout" class="" style=""><i class="fa fa-user-times"></i>LOGOUT</a></li>
</ul>
</li>
<?php
}?>
</ul>
</nav><!-- #nav-menu-container -->
</div>
</header><!-- #header -->
<?php $maya->view->generateLoginAndNotice(); ?>
<section class="<?php echo ($role->isUserLoggedIn()?'padd-section':'');?> text-center wow fadeInUp" style="margin-top:100px">
<div class="container page">
<?php
$maya->controller->display()
?>
</div>
</section>
<footer class="footer">
<div class="copyrights">
<div class="container">
<p>© Copyrights Maya. All rights reserved. Author: Edgardo Fabian Since: 2007</p>
<div class="credits">
Framework powered by <a href="https://maya.docph.net">Maya</a>
Html Template by <a href="https://bootstrapmade.com/">BootstrapMade</a>
</div>
</div>
</div>
</footer>
<a href="#" class="back-to-top"><i class="fa fa-chevron-up"></i></a>
<!-- JavaScript Libraries -->
<script src="lib/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Template Main Javascript File -->
<script src="js/main.js"></script>
<?php
$maya->view->initializeScripts(array('mathjax'=>false,'speak'=>false,'chosen'=>true,'wysiwyg'=>true,'datetimepicker'=>true));
?>
</body>
</html>
9) All php codes marked by
<?php ....?>
are required
10) There should always be a
<div class='page'> </div>
because this is where other pages are loaded via restful process.
Modify Models
1) You should only modify the extended versions of models at usr/model folder. This is to insure that when you change your db and update your models
the changes you added will not be overwritten by generaModel.php. The generateModel.php will only overwrite the models at usr_generate/model folders
2) You may override functions from the usr_generated/model folder
3) You should add user functions only to the models at usr/model folder.
Modify Controllers
1) You should only modify the extended versions of controllers at usr/controller folder. This is to insure that when you change your db and update your controllers the changes you added will not be overwritten by generaController.php. The generateController.php will only overwrite the controllers at usr_generate/model folders
2) You may override functions from the usr_generated/controller folder
3) You should add user controller functions only to the controllers at usr/controller folder.
Modify Views
1) Views (List, Edit, New) and View models are automatically generated at usr_generated/view folder by generateView.php.
2) generateView.php also places a default extensions of view models and files at usr/views if not yet available. This is the portion that you can edit.
3) generateView.php also places a default file at the Administration directory for listing, adding and editing of table items. These views simple include the views at usr/view/.
The above is terminal command in linux that assumes the folder structure defined above executed at ../Admin.dir/Users.dir/ directory