<?php require 'config.php'; require $ConfigArray['LIB'] . 'A/Locator.php'; $Locator = new A_Locator(); $Locator->autoload(); // initializing autoloading $Config = new A_Collection($ConfigArray); $Request = new A_Http_Request(); $Response = new A_Http_Response(); $Response->setTemplate('layouts/main.php'); $Response->set('BASE', $ConfigArray['BASE']); $Response->set('title', $ConfigArray['TITLE']); $Response->set('head', ''); $Session = new A_Session(); $UserSession = new A_User_Session($Session); $Locator->set('Config', $Config); $Locator->set('Request', $Request); $Locator->set('Response', $Response); $Locator->set('Session', $Session); $Locator->set('UserSession', $UserSession); $Router = new A_Http_Pathinfo(); $Router->run($Request); $Mapper = new A_Controller_Mapper($ConfigArray['APP'], array('', 'home', '')); $Controller = new A_Controller_Front($Mapper, array('', 'error', '')); $Controller->addPreFilter(new A_User_Prefilter_Group($Session, array('', 'user', 'login'))); $Controller->run($Locator); $Response->run($Locator); echo $Response->render(); echo $Controller->getErrorMsg(', ');
ini_set('error_reporting', $Config->get('ERROR')); // Create HTTP Request object $Request = new A_Http_Request(); // Start Sessions $Session = new A_Session(); //$Session->start(); $UserSession = new A_User_Session($Session); // Dbh $dbconfig = array('phptype' => $Config->get('phptype'), 'database' => $Config->get('database'), 'hostspec' => $Config->get('hostspec'), 'username' => $Config->get('username'), 'password' => $Config->get('password'), 'attr' => array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC)); $Db = new A_Db_Pdo($dbconfig); $Db->connect(); #$Db = new A_Db_MySQL($dbconfig); // Create HTTP Response object and set default template and valuesS $Response = new A_Http_Response(); $Response->setTemplate('mainlayout', 'module'); $Response->set('BASE', $ConfigArray['BASE']); $Response->set('title', 'Default Title'); $Response->set('head', ''); $Response->set('maincontent', 'Default main content.'); $Response->set('user', $UserSession); // Add common objects to registry $Locator->set('Config', $Config); $Locator->set('Request', $Request); $Locator->set('Response', $Response); $Locator->set('Session', $Session); $Locator->set('UserSession', $UserSession); $Locator->set('Db', $Db); // Create router and have it modify request $map = array('' => array('controller', 'action'), 'blog' => array('' => array(array('name' => 'module', 'default' => 'blog'), array('name' => 'controller', 'default' => 'index'), array('name' => 'action', 'default' => 'index'))), 'admin' => array('' => array(array('name' => 'module', 'default' => 'admin'), array('name' => 'controller', 'default' => 'admin'), array('name' => 'action', 'default' => 'index')))); $Pathinfo = new A_Http_Pathinfo($map); $Pathinfo->run($Request);
<?php include 'config.php'; include '../../A/Locator.php'; $Locator = new A_Locator(); $Locator->autoload(); $Response = new A_Http_Response(); $view1 = new A_Http_View(); $view1->set('title', 'Block One'); $view1->set('content', 'This is the content for block one. '); $view1->setTemplate('block1.php'); // MVC objects assume a templates/ directory $view2 = new A_Http_View('block2'); $template2 = new A_Template_Strreplace('templates/block2.html'); $template2->set('title', 'Block Two'); $template2->set('content', 'This is the content for block two. '); $view2->setRenderer($template2); $layout = new A_Http_View('layout'); $layout->set('block1', $view1); $layout->set('block2', $view2); $layout->set('content', 'This is the content for the layout. '); $layout->setRenderer(new A_Template_Strreplace('templates/layout.html')); #$doc = new A_Html_Doc(array('doctype'=>'HTML_5')); $doc = new A_Html_Doc(); $doc->setDoctype(A_Html_Doctype::HTML_5); $Response->set('layout', $layout); $Response->set('title', 'Response Example'); $Response->set('BASE', 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME'])); $Response->setRenderer($doc); $Response->set('body', '<h1>This content goes in the body.</h1>'); echo $Response->render();
<?php include 'config.php'; // Init autoload using Locator require $ConfigArray['LIB'] . 'A/Locator.php'; $Locator = new A_Locator(); $Locator->autoload(); $Config = new A_Collection($ConfigArray); // Create HTTP Request object $Request = new A_Http_Request(); // Start Sessions $Session = new A_Session(); // Create HTTP Response object and set default template and valuesS $Response = new A_Http_Response(); $Response->setTemplate('layoutmain'); $Response->set('BASE', $ConfigArray['BASE']); $Response->set('title', 'Cart Example'); $Response->set('head', ''); $Response->set('content', ''); // Add common objects to registry $Locator->set('Config', $Config); $Locator->set('Request', $Request); $Locator->set('Response', $Response); $Locator->set('Session', $Session); $Pathinfo = new A_Http_Pathinfo(); $Pathinfo->run($Request); $Controller = new A_Controller_Front($Config->get('APP'), array('', 'product_category', 'index')); $Controller->run($Locator); // Finally, display echo $Response->render(); #dump($_SESSION, '_SESSION: ');
<?php include 'config.php'; include '../../A/Locator.php'; $Locator = new A_Locator(); $Locator->autoload(); $Response = new A_Http_Response(); $view1 = new A_Http_View(); $view1->set('title', 'Block One'); $view1->set('content', 'This is the content for block one. '); $view1->setTemplate('block1.php'); // MVC objects assume a templates/ directory $view2 = new A_Http_View(); $template2 = new A_Template_Strreplace('templates/block2.html'); $template2->set('title', 'Block Two'); $template2->set('content', 'This is the content for block two. '); $view2->setRenderer($template2); $layout = new A_Http_View(); $layout->set('block1', $view1); $layout->set('block2', $view2); $layout->set('content', 'This is the content for the layout. '); $layout->setRenderer(new A_Template_Strreplace('templates/layout.html')); $Response->set('layout', $layout); $Response->set('title', 'Response Example'); $Response->set('BASE', 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME'])); $Response->setRenderer(new A_Template_Strreplace('templates/main.html')); echo $Response->render();
set_include_path($ConfigArray['LIB'] . PATH_SEPARATOR . get_include_path()); // Init autoload using Locator require_once $ConfigArray['LIB'] . 'A/Locator.php'; $Locator = new A_Locator(); $Locator->autoload(); // Load application config data $Config = new A_Config_Ini('config/example.ini', 'production'); $Config->loadFile(); // import base config array into config object $Config->import($ConfigArray); // Create HTTP Request object $Request = new A_Http_Request(); // Create HTTP Response object and set default template and valuesS $Response = new A_Http_Response(); $Response->setTemplate('mainlayout', 'module'); $Response->set('BASE', $ConfigArray['BASE']); $Response->set('title', 'Default Title'); $Response->set('maincontent', 'Default main content set in index.php. If you can see this then none of your controllers gave a value to maincontent or, more likely, you put in a url for which no module/controller/action could be found. I think you should be looking at a 404 page here.'); // Start Sessions $Session = new A_Session(); //$Session->start(); $UserSession = new A_User_Session($Session); // Add common objects to registry $Locator->set('Config', $Config); $Locator->set('Request', $Request); $Locator->set('Response', $Response); $Locator->set('Session', $Session); $Locator->set('UserSession', $UserSession); // Create router and have it modify request $map = array('' => array('controller', 'action'), 'blog' => array('' => array(array('name' => 'module', 'default' => 'blog'), array('name' => 'controller', 'default' => 'index'), array('name' => 'action', 'default' => 'index'))), 'admin' => array('' => array(array('name' => 'module', 'default' => 'admin'), array('name' => 'controller', 'default' => 'admin'), array('name' => 'action', 'default' => 'index')))); $Pathinfo = new A_Http_Pathinfo($map);