/** * Singleton * * @param array $params Configuration params * * @return Qadwa */ public static function getInstance(array $params = array()) { if (!self::$_instance) { self::$_instance = new self($params); } elseif (count($params)) { foreach ($params as $key => $value) { self::$_instance->__set($key, $value); } } return self::$_instance; }
<?php require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/src/Qadwa.php'; print Qadwa::getInstance(array('baseUrl' => '/examples/03_simplesite/'));
<?php // this is only to show how Qadwa::getInstance()->redirect('qadwa/show');
<?php // Include the class require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/src/Qadwa.php'; // Just print the Qadwa instance print Qadwa::getInstance(array('baseUrl' => '/examples/01_helloworld/'));
<?php require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/src/Qadwa.php'; print Qadwa::getInstance(array('baseUrl' => '/examples/05_controller/'));
<?php require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/src/Qadwa.php'; // This is the same case that the hello world example but now // you must ensure to have the .htacess and the Apache Rewrite module print Qadwa::getInstance(array('baseUrl' => '/examples/02_static/'));
<?php session_start(); require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/src/Qadwa.php'; if (!isset($_SESSION['debug'])) { $_SESSION['debug'] = 0; } print Qadwa::getInstance(array('baseUrl' => '/examples/06_errors/', 'debug' => $_SESSION['debug'], 'error400Template' => 'error/not-found', 'error500Template' => 'error/internal'));
<?php // here we check if a POST is received. if (Qadwa::getInstance()->isPost()) { $body = ''; foreach (array('name', 'email', 'message') as $name) { $value = $_POST[$name]; $body .= "{$name}: {$value}\n"; } // Here fetch the user defined configuration // it is in the etc/defaul.ini file $contactMail = Qadwa::getInstance()->contact_mail; $result = mail($contactMail, 'Contact', $body); $message = $result ? 'Form sended ok!' : 'There was an error while sending the form'; } else { $message = null; } // Set the var to the template // yes! is a return without any function, // it terminates the processing in this file // you can check more info in http://php.net/include return array('message' => $message);
<?php require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/src/Qadwa.php'; print Qadwa::getInstance(array('baseUrl' => '/examples/04_views/', 'templateFile' => 'templates/%s.html', 'layoutFile' => 'templates/%s.html', 'defaultModule' => 'home', 'layout' => false));