function __autoload($className) { try { ezcBase::autoload($className); } catch (Exception $e) { echo $e->getMessage(); } }
/** * Creates a new controller object and sets all the request variables as class variables. * * @throws ezcMvcControllerException if the action method is empty * @param string $action * @param ezcMvcRequest $request */ public function __construct($action, ezcMvcRequest $request) { if (ezcBase::inDevMode() && (!is_string($action) || strlen($action) == 0)) { throw new ezcMvcControllerException("The '" . get_class($this) . "' controller requires an action."); } $this->action = $action; $this->setRequestVariables($request); }
public static function __callstatic($name, $args) { if (ezcBase::getRunMode() == ezcBase::MODE_DEVELOPMENT) { return call_user_func_array(array(self::$ezcDebugInstance, $name), $args); } else { return null; } }
function __autoload($className) { if (strpos($className, '_') !== false) { $file = str_replace('_', '/', $className) . '.php'; @($val = (require_once $file)); return $val === true; } ezcBase::autoload($className); }
function glpiautoload($classname) { global $DEBUG_AUTOLOAD, $CFG_GLPI; static $notfound = array(); // empty classname or non concerted plugin if (empty($classname) || is_numeric($classname)) { return false; } $dir = GLPI_ROOT . "/inc/"; //$classname="PluginExampleProfile"; if ($plug = isPluginItemType($classname)) { $plugname = strtolower($plug['plugin']); $dir = GLPI_ROOT . "/plugins/{$plugname}/inc/"; $item = strtolower($plug['class']); // Is the plugin activate ? // Command line usage of GLPI : need to do a real check plugin activation if (isCommandLine()) { $plugin = new Plugin(); if (count($plugin->find("directory='{$plugname}' AND state=" . Plugin::ACTIVATED)) == 0) { // Plugin does not exists or not activated return false; } } else { // Standard use of GLPI if (!in_array($plugname, $_SESSION['glpi_plugins'])) { // Plugin not activated return false; } } } else { // Is ezComponent class ? if (preg_match('/^ezc([A-Z][a-z]+)/', $classname, $matches)) { include_once GLPI_EZC_BASE; ezcBase::autoload($classname); return true; } else { $item = strtolower($classname); } } // No errors for missing classes due to implementation if (!isset($CFG_GLPI['missingclasses']) or !in_array($item, $CFG_GLPI['missingclasses'])) { if (file_exists("{$dir}{$item}.class.php")) { include_once "{$dir}{$item}.class.php"; if ($_SESSION['glpi_use_mode'] == DEBUG_MODE) { $DEBUG_AUTOLOAD[] = $classname; } } else { if (!isset($notfound["x{$classname}"])) { // trigger an error to get a backtrace, but only once (use prefix 'x' to handle empty case) //logInFile('debug',"file $dir$item.class.php not founded trying to load class $classname\n"); trigger_error("GLPI autoload : file {$dir}{$item}.class.php not founded trying to load class '{$classname}'"); $notfound["x{$classname}"] = true; } } } }
/** * Creates a ezcBaseMetaData object * * The sole parameter $installMethod should only be used if you are really * sure that you need to use it. It is mostly there to make testing at * least slightly possible. Again, do not set it unless instructed. * * @param string $installMethod */ public function __construct($installMethod = NULL) { $installMethod = $installMethod !== NULL ? $installMethod : ezcBase::getInstallMethod(); // figure out which reader to use switch ($installMethod) { case 'tarball': $this->reader = new ezcBaseMetaDataTarballReader(); break; case 'pear': $this->reader = new ezcBaseMetaDataPearReader(); break; default: throw new ezcBaseMetaDataReaderException("Unknown install method '{$installMethod}'."); break; } }
/** * Returns routing information, including a controller classname from the set of routes. * * This method is run by the dispatcher to obtain a controller. It uses the * user implemented createRoutes() method from the inherited class to fetch the * routes. It then loops over these routes in order - the first one that * matches the request returns the routing information. The loop stops as * soon as a route has matched. In case none of the routes matched * with the request data an exception is thrown. * * @throws ezcMvcNoRoutesException when there are no routes defined. * @throws ezcBaseValueException when one of the returned routes was not * actually an object implementing the ezcMvcRoute interface. * @throws ezcMvcRouteNotFoundException when no routes matched the request URI. * @return ezcMvcRoutingInformation */ public function getRoutingInformation() { $routes = $this->createRoutes(); if (ezcBase::inDevMode() && (!is_array($routes) || !count($routes))) { throw new ezcMvcNoRoutesException(); } foreach ($routes as $route) { if (ezcBase::inDevMode() && !$route instanceof ezcMvcRoute) { throw new ezcBaseValueException('route', $route, 'instance of ezcMvcRoute'); } $routingInformation = $route->matches($this->request); if ($routingInformation !== null) { return $routingInformation; } } throw new ezcMvcRouteNotFoundException($this->request); }
/** * Returns routing information, including a controller classname from the set of routes. * * This method is run by the dispatcher to obtain a controller. It uses the * user implemented createRoutes() method from the inherited class to fetch the * routes. It then loops over these routes in order - the first one that * matches the request returns the routing information. The loop stops as * soon as a route has matched. In case none of the routes matched * with the request data an exception is thrown. * * @throws ezcMvcNoRoutesException when there are no routes defined. * @throws ezcBaseValueException when one of the returned routes was not * actually an object implementing the ezcMvcRoute interface. * @throws ezcMvcRouteNotFoundException when no routes matched the request URI. * @return ezcMvcRoutingInformation */ public function getRoutingInformation() { $routes = $this->createRoutes(); if (ezcBase::inDevMode() && (!is_array($routes) || !count($routes))) { throw new ezcMvcNoRoutesException(); } foreach ($routes as $route) { if (ezcBase::inDevMode() && !$route instanceof ezcMvcRoute) { throw new ezcBaseValueException('route', $route, 'instance of ezcMvcRoute'); } $routingInformation = $route->matches($this->request); if ($routingInformation !== null) { // Add the router to the routing information struct, so that // can be passed to the controllers for reversed route // generation. $routingInformation->router = $this; return $routingInformation; } } throw new ezcMvcRouteNotFoundException($this->request); }
public function teardown() { $options = new ezcBaseAutoloadOptions(); $options->debug = true; ezcBase::setOptions($options); }
public static function autoload($className) { if (class_exists('ezcBase')) { ezcBase::autoload($className); } }
<?php require_once 'ezc/Base/base.php'; spl_autoload_register(array('ezcBase', 'autoload')); ezcBase::addClassRepository(realpath(dirname(__FILE__) . '/../src')); $exampleFiles = glob(dirname(__FILE__) . '/dir/*.php'); $examples = array(); foreach ($exampleFiles as $exampleFile) { $examples[pathinfo($exampleFile, PATHINFO_FILENAME)] = $exampleFile; } if (isset($_GET['example']) && array_key_exists($_GET['example'], $examples)) { $example = $_GET['example']; require $examples[$example]; } else { $example = ''; } ?> <html> <head> <style> .failed { background-color: #CC0000; } </style> </head> <body> <div> <?php foreach ($examples as $key => $file) { echo '<a href="?example=', $key, '">', $key, '</a>, ';
<?php /** * WebChecker config php file * Created on January, the 12th 2010 at 21:26:14 by ronan * * @copyright Copyright (C) 2011 Ronan Guilloux. All rights reserved. * @license http://www.gnu.org/licenses/agpl.html GNU AFFERO GPL v3 * @version //autogen// * @author Ronan Guilloux - coolforest.net * @package WebChecker * @filesource config.php */ // SPL autoloading for Zeta components // see http://incubator.apache.org/zetacomponents/documentation/install.html require_once 'src/zetacomponents/Base/base.php'; spl_autoload_register( array( 'ezcBase', 'autoload' ) ); // Zeta components autoloading for the all rest : $options = new ezcBaseAutoloadOptions( array( 'debug' => false, 'preload' => true ) ); ezcBase::setOptions( $options ); ezcBase::addClassRepository( dirname( __FILE__ ) . '/src/checker', null, 'chk' ); // here you can add your own libs using addClassRepository() // App. settings $reader = new ezcConfigurationIniReader(); $reader->init( dirname( __FILE__ ), 'settings' ); $ini = $reader->load(); ?>
function __autoload($className) { ezcBase::autoload($className); }
/** * Sets the development mode to the one specified. * * @param int $runMode */ public static function setRunMode($runMode) { if (!in_array($runMode, array(ezcBase::MODE_PRODUCTION, ezcBase::MODE_DEVELOPMENT))) { throw new ezcBaseValueException('runMode', $runMode, 'ezcBase::MODE_PRODUCTION or ezcBase::MODE_DEVELOPMENT'); } self::$runMode = $runMode; }
/** * Constructor * * @param array $options Default option array * @return void * @ignore */ public function __construct(array $options = array()) { ezcBase::checkDependency('Graph', ezcBase::DEP_PHP_EXTENSION, 'dom'); $this->options = new ezcGraphSvgDriverOptions($options); $this->font = new ezcGraphSvgFont(); }
/** * Autoload ezc classes * * @param string $className */ function webdav_autoload($className) { ezcBase::autoload($className); }
static function getAutoload($className) { return 'ezcBase' == $className ? 'ezc/Base/base.php' : ezcBase::getAutoload($className); }
<?php $root = dirname(__FILE__); ini_set('include_path', "/usr/share/php/ezc:{$root}"); require 'Base/ezc_bootstrap.php'; $options = new ezcBaseAutoloadOptions(array('debug' => true)); ezcBase::setOptions($options); // Add the class repository containing our application's classes. We store // those in the /lib directory and the classes have the "tcl" prefix. ezcBase::addClassRepository($p = "{$root}/lib", null, 'tcl'); class customLazyCacheConfiguration implements ezcBaseConfigurationInitializer { public static function configureObject($id) { $options = array('ttl' => 1800); switch ($id) { case 'scrapers': ezcCacheManager::createCache('scrapers', '../cache/scrapers', 'ezcCacheStorageFilePlain', $options); break; } } } ezcBaseInit::setCallback('ezcInitCacheManager', 'customLazyCacheConfiguration');
function runResponseFilters(ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result, ezcMvcResponse $response) { if (!ezcBase::inDevMode()) { if (in_array('gzip', $request->accept->encodings)) { $filter = new ezcMvcGzipResponseFilter(); $filter->filterResponse($response); } else { if (in_array('deflate', $request->accept->encodings)) { $filter = new ezcMvcGzDeflateResponseFilter(); $filter->filterResponse($response); } } } }
#!/usr/bin/php5 <?php if (php_sapi_name() != 'cli') { echo "PHP code to execute directly on the command line\n"; exit(-1); } ini_set('error_reporting', E_ALL); ini_set('register_globals', 0); ini_set('display_errors', 1); ini_set("max_execution_time", "3600"); require_once "lib/core/lhcore/password.php"; require_once "ezcomponents/Base/src/base.php"; // dependent on installation method, see below require_once 'cli/lib/install.php'; ezcBase::addClassRepository('./', './lib/autoloads'); spl_autoload_register(array('ezcBase', 'autoload'), true, false); #erLhcoreClassSystem::init(); // your code here ezcBaseInit::setCallback('ezcInitDatabaseInstance', 'erLhcoreClassLazyDatabaseConfiguration'); $cfgSite = erConfigClassLhConfig::getInstance(); if ($cfgSite->getSetting('site', 'installed') == true) { print 'Live helper chat installation complete'; exit; } $instance = erLhcoreClassSystem::instance(); function validate_args($argv, $argc) { if ($argc != 2) { echo "Wrong number of parameters.\n"; return 1; }
function __autoload($className) { ezcBase::autoload($className); @(include SITE_ROOT . '/app/model/' . $className . '.php'); }
function ezc_autoload($className) { if (strpos($className, '_') === false) { ezcBase::autoload($className); } }
#!/usr/bin/env php <?php require_once 'ezc/Base/ezc_bootstrap.php'; ezcBase::addClassRepository(dirname(__FILE__) . '/..', dirname(__FILE__) . '/..'); $input = new ezcConsoleInput(); $helpOption = $input->registerOption(new ezcConsoleOption('h', 'help')); $helpOption->isHelpOption = true; $input->argumentDefinition = new ezcConsoleArguments(); $input->argumentDefinition[0] = new ezcConsoleArgument("infile"); $input->argumentDefinition[0]->mandatory = false; $input->argumentDefinition[0]->default = '-'; $input->argumentDefinition[0]->type = ezcConsoleInput::TYPE_STRING; $input->argumentDefinition[0]->shorthelp = "pipe definition file"; $input->argumentDefinition[0]->longhelp = "Pipe XML definition file to convert or - to read from STDIN ( not implemented yet )"; try { $input->process(); main($input); } catch (Exception $e) { echo $e->getMessage(); exit(1); } function main(ezcConsoleInput $input) { $pipe = getPipe($input->argumentDefinition["infile"]->value); $dotVisitor = new ymcPipeDotVisitor(); $pipe->accept($dotVisitor); echo $dotVisitor->getDot(); } function getPipe($infile) { // get XML String
<?php // {{{ class autoload setup define('EZC_TRUNK_PATH', join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'ezc', 'trunk'))); define('APPS_TRUNK_PATH', join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'apps'))); define('DOCTRINE_PATH', join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'doctrine'))); set_include_path(join(PATH_SEPARATOR, array(get_include_path(), EZC_TRUNK_PATH, APPS_TRUNK_PATH))); require join(DIRECTORY_SEPARATOR, array(DOCTRINE_PATH, 'lib', 'Doctrine.php')); spl_autoload_register(array('Doctrine', 'autoload')); require 'ezc/Base/src/base.php'; ezcBase::setRunMode(ezcBase::MODE_DEVELOPMENT); spl_autoload_register(array('ezcBase', 'autoload')); include dirname(__FILE__) . '/apps/dev/autoload_config.php'; // }}} Doctrine_Manager::connection("mysql://*****:*****@localhost/shared", 'main'); include 'framework_part0.php'; $project = aiiProjectConfiguration::instance(dirname(__FILE__), 'ocpsys'); $installedApps = array('core', 'admin', 'sites', 'dev', 'pages'); $appsPaths = array(); foreach ($installedApps as $appName) { // i know my apps are all in the same dir $appsPaths[] = join(DIRECTORY_SEPARATOR, array(APPS_TRUNK_PATH, $appName)); } $project->setUp($appsPaths); unset($installedApps); unset($appsPaths); unset($appName);
/** * Constructor * * @param array $options Default option array * @return void * @ignore */ public function __construct(array $options = array()) { ezcBase::checkDependency('Graph', ezcBase::DEP_PHP_EXTENSION, 'cairo'); $this->options = new ezcGraphCairoDriverOptions($options); }
<?php // build and initialize the form require_once 'ezc/Base/ezc_bootstrap.php'; ezcBase::addClassRepository('../../src'); // BEGINFORMINIT class SimpleGreetingForm extends ymcHtmlFormGeneric { public function __construct() { parent::__construct(); $this->group->add(new ymcHtmlFormElementText('forename')); $this->group->add(new ymcHtmlFormElementText('surname')); $this->init(); } } $form = new SimpleGreetingForm(); // ENDFORMINIT $input = new ymcHtmlFormInputSourceFilterExtension(); if ($input->hasData()) { $form->validate($input); } ?> <html> <head> <style> form .failed{ border:1px solid red; }
<?php require_once 'ezc/Base/base.php'; spl_autoload_register(array('ezcBase', 'autoload')); ezcBase::addClassRepository('./lib', './lib/autoload'); $options = new ezcBaseAutoloadOptions(); $options->debug = true; ezcBase::setOptions($options); $rootdir = dirname(__FILE__); $db = ezcDbFactory::create("sqlite://{$rootdir}/tmp/mergequeue.db"); ezcDbInstance::set($db);
/** * To load classes * * @param $classname : class to load **/ function glpi_autoload($classname) { global $DEBUG_AUTOLOAD, $CFG_GLPI; static $notfound = array('xStates' => true, 'xAllAssets' => true); // empty classname or non concerted plugin or classname containing dot (leaving GLPI main treee) if (empty($classname) || is_numeric($classname) || strpos($classname, '.') !== false) { die("Security die. trying to load an forbidden class name"); } $dir = GLPI_ROOT . "/inc/"; if ($plug = isPluginItemType($classname)) { $plugname = strtolower($plug['plugin']); $dir = GLPI_ROOT . "/plugins/{$plugname}/inc/"; $item = strtolower($plug['class']); // Is the plugin activate ? // Command line usage of GLPI : need to do a real check plugin activation if (isCommandLine()) { $plugin = new Plugin(); if (count($plugin->find("directory='{$plugname}' AND state=" . Plugin::ACTIVATED)) == 0) { // Plugin does not exists or not activated return false; } } else { // Standard use of GLPI if (!in_array($plugname, $_SESSION['glpi_plugins'])) { // Plugin not activated return false; } } } else { // Is ezComponent class ? if (preg_match('/^ezc([A-Z][a-z]+)/', $classname, $matches)) { include_once GLPI_EZC_BASE; ezcBase::autoload($classname); return true; } // Do not try to load phpcas using GLPI autoload if (preg_match('/^CAS_.*/', $classname)) { return false; } // Do not try to load Zend using GLPI autoload if (preg_match('/^Zend.*/', $classname)) { return false; } // Do not try to load Simplepie using GLPI autoload if (preg_match('/^SimplePie.*/', $classname)) { return false; } $item = strtolower($classname); } if (file_exists("{$dir}{$item}.class.php")) { include_once "{$dir}{$item}.class.php"; if (isset($_SESSION['glpi_use_mode']) && $_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) { $DEBUG_AUTOLOAD[] = $classname; } } else { if (!isset($notfound["x{$classname}"])) { // trigger an error to get a backtrace, but only once (use prefix 'x' to handle empty case) // trigger_error("GLPI autoload : file $dir$item.class.php not founded trying to load class '$classname'"); $notfound["x{$classname}"] = true; } } }
/** * Return the list of directories that contain class repositories. * * The path to the eZ components directory is always included in the result * array. Each element in the returned array has the format of: * packageDirectory => ezcBaseRepositoryDirectory * * @return array(string=>ezcBaseRepositoryDirectory) */ public static function getRepositoryDirectories() { $autoloadDirs = array(); ezcBase::setPackageDir(); $repositoryDir = self::$currentWorkingDirectory ? self::$currentWorkingDirectory : realpath(dirname(__FILE__) . '/../../'); $autoloadDirs['ezc'] = new ezcBaseRepositoryDirectory(ezcBaseRepositoryDirectory::TYPE_INTERNAL, $repositoryDir, $repositoryDir . "/autoload"); foreach (ezcBase::$repositoryDirs as $extraDirKey => $extraDirArray) { $repositoryDirectory = new ezcBaseRepositoryDirectory(ezcBaseRepositoryDirectory::TYPE_EXTERNAL, realpath($extraDirArray['basePath']), realpath($extraDirArray['autoloadDirPath'])); $autoloadDirs[$extraDirKey] = $repositoryDirectory; } return $autoloadDirs; }
<?php /** * Tests configurationfile */ define( 'ROOT', getcwd() ); ini_set( 'include_path', "/usr/share/php/ezc:/usr/share/php" . ROOT ); require 'Base/ezc_bootstrap.php'; $options = new ezcBaseAutoloadOptions( array( 'debug' => true ) ); ezcBase::setOptions( $options ); // Add the class repository containing our application's classes. We store // those in the /lib directory and the classes have the "tcl" prefix. ezcBase::addClassRepository( ROOT . "/lib", ROOT . "/lib/autoload", 'mm' ); class mmLazySettingsConfiguration implements ezcBaseConfigurationInitializer { public static function configureObject( $cfgManager ) { $cfgManager->init( 'ezcConfigurationIniReader', ROOT . "/tests/config" ); } } ezcBaseInit::setCallback( 'ezcInitConfigurationManager', 'mmLazySettingsConfiguration' ); ?>