<?php /** * @package wo2009 * @subpackage library */ SomeLoader::import('library.some.database.irow', SOME_PATH . DS . 'interface', null); /** * SomeRow is factory class to create specialized SomeRow___ objects. * * <p>SomeRow povides getRow factory method. It gets arguments that is the suffix of the class extending SomeRow. * Extending class must be on subfolder rows/ in a file named exactly as class prefix. Example: * <code> * get class SomeRowDemo from file rows/demo.php * This is NOT singleton * SomeRow::getRow('demo'); * * </code> * </p> * <p>Extendng class MUST implement getTable(), getPrimary() and getColumns methods. See methods for explanation.</p> * * @package wo2009 * @subpackage library */ class SomeRow implements ISomeRow { public $sql; public $columnsdebug; protected function __construct() { }
* Usage example, get database settings. * <code> * $conf = SomeFactory::getConfiguration(); * $database_host = $conf->get('databasehost','database'); * $database_name = $conf->get('database','database'); * $database_dbuser = $conf->get('dbuser','database'); * $database_dbpass = $conf->get('dbpass','database'); * </code> * </p> * * @author Hannu Lohtander * @package wo2009 * @subpackage library * */ SomeLoader::import('library.some.configuration.iconfiguration', SOME_PATH . DS . 'interface', null); /** * SomeConfiguration serves as wrapper class aroung configuration.php. * * <p>It would be difficult to every time use xml apis to get values from Configuration. * That is why this class provides easy api to configuration data. * Class is used through SomeFactory. * </p> * <p> * Usage example, get database settings. * <code> * $conf = SomeFactory::getConfiguration(); * $database_host = $conf->get('databasehost','database'); * $database_name = $conf->get('database','database'); * $database_dbuser = $conf->get('dbuser','database'); * $database_dbpass = $conf->get('dbpass','database');
<?php /** * * @author Hannu Lohtander * @package wo2009 * @subpackage mvc * */ SomeLoader::import('library.some.application.iview', SOME_PATH . DS . 'interface', null); /** * * @package wo2009 * @subpackage mvc * */ class SomeView implements ISomeView { /** */ private $_name; /** */ private $model; /** * defautl constructor. * @param array $options * @return ISomeView */ public function __construct(array $options = array()) { if (isset($options['name'])) { $this->_name = $options['name'];
*/ if (!class_exists('SomeLoader')) { require_once SOME_LIBRARY . DS . 'loader.php'; } SomeLoader::register('JFilterInput', SOME_LIBRARY . DS . 'some' . DS . 'filter' . DS . 'filterinput.php'); //Environment classes SomeLoader::import('some.environment.request'); SomeRequest::clean(); SomeLoader::import('some.environment.response'); SomeLoader::import('some.factory'); SomeLoader::import('some.user.user'); //register exception classes SomeLoader::register('SomeFrameworkException', SOME_LIBRARY . DS . 'some' . DS . 'exception' . DS . 'frameworkexception.php'); SomeLoader::register('SomeDatabaseException', SOME_LIBRARY . DS . 'some' . DS . 'exception' . DS . 'databaseexception.php'); SomeLoader::register('SomeFileNotFoundException', SOME_LIBRARY . DS . 'some' . DS . 'exception' . DS . 'filenotfoundexception.php'); SomeLoader::register('SomeClassNotFoundException', SOME_LIBRARY . DS . 'some' . DS . 'exception' . DS . 'classnotfoundexception.php'); //class SomeText /** * class to help translations of strings. * @package wo2009 */ class SomeText { /** * Translates a string into the current language * * @access public * @param string $string The string to translate * @param boolean $jsSafe Make the result javascript safe * */
<?php /** * @package wo2009 * @subpackage library */ /** */ require 'storage.php'; SomeLoader::import('library.some.session.isession', SOME_PATH . DS . 'interface', null); /** * @package wo2009 * @subpackage library */ class SomeSession implements ISomeSession { public function __construct($store = 'none', $options = array()) { //get the correct storage, and register it. $this->_store = SomeSessionStorage::getInstance($store, $options); session_name('wo' . md5('wocookie')); session_start(); ini_set('session.gc_divisor', 40); // Send modified header for IE 6.0 Security Policy header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); } public static function getInstance($driver, $options = array()) { static $instance; if (!$instance) { $instance = new self($driver, $options); }
<?php /** * @package wo2009 * @subpackage library */ SomeLoader::import('library.some.user.iuser', SOME_PATH . DS . 'interface', null); /** * Example usage. * <code> * You can get SomeUser object instance using SomeFactory: * * $user = SomeFactory::getUser(); * * Creating new user * * When you get id, username, password, email and homepage from SomeRequest, and have validated those, you can set them to $user: * $user->setId(null); * $user->setPassword($password); * $user->setUsername($username); * $user->setEmail($email); * $user->setHomepage($homepage); * //if you need to set userrole, and when user registers you must, then you set userrole * $user->setUserrole('registered'); * //before user has been logged in, userrole is 'guest'. * $userrole = $user->getUserrole(); //is 'guest' unless registered and logged in. * //and finally create * $user->create(); * if ($user->getId() > 0) { echo "user created succesfully"; } * Reading user from database *
<?php /** * SomeLanguage class is storage for language tokens. * * @package wo2009 * @subpackage library * */ SomeLoader::import('library.some.language.ilanguage', SOME_PATH . DS . 'interface', null); /** * SomeLanguage * * @package wo2009 * @subpackage library * */ class SomeLanguage implements ISomeLanguage { private $language; private $strings = array(); public function __construct($language = 'en_GB') { $this->language = $language; $this->load('site'); } /** * default language translation function. * * @param string $str token * @param boolean $jssafe javascript safe
/** * Load the file for a class * * @access public * @param string $class The class that will be loaded * @return boolean True on success * @since 1.5 */ public static function load($class) { $class = strtolower($class); //force to lower case if (class_exists($class)) { return; } $classes = SomeLoader::register(); if (array_key_exists(strtolower($class), $classes)) { include $classes[$class]; return true; } return false; }
<?php /** * SomeDocumentHTML. * * @package wo2009 * @subpackage library * @author Hannu Lohtander */ SomeLoader::import('library.some.document.idocumenthtml', SOME_PATH . DS . 'interface', null); /** * SomeDocumentHTML. * * @package wo2009 * @subpackage library */ class SomeDocumentHTML { private $buffer; private $template = 'default'; private $file = 'index'; public function __construct() { } public static function getInstance() { static $instance; if (!$instance) { $instance = new self(); } return $instance;
<?php /** * @package wo2009 * @subpackage library */ //if this interface is not imported, them must remove implements from class declaration SomeLoader::import('library.some.ifactory', SOME_PATH . DS . 'interface' . DS, null); /** * @package wo2009 * @subpackage library */ class SomeFactory implements ISomeFactory { /** * @return SomeSession instance */ public static function getSession() { someloader('some.session.session'); $conf = SomeFactory::getConfiguration(); $session_handler = $conf->get('session_handler', 'session'); //only on postgres if ($session_handler !== 'file' && $conf->get('databasedriver', 'database') === 'pdopostgres') { try { $database = SomeFactory::getDBO(); if (!$database) { $session_handler = 'file'; } else { $session_table = $conf->get('session_table', 'session'); $sql = "select * from information_schema.tables where table_schema='public' " . "and table_type='BASE TABLE' AND table_name='{$session_table}'";