require_once dirname(__FILE__) . '/../settings/environment.php'; if (defined('EZC_ROOT')) { set_include_path(EZC_ROOT . ":" . EZC_ROOT . "/trunk:" . ini_get("include_path")); } require_once EZC_BASE; function __autoload($className) { ezcBase::autoload($className); @(include SITE_ROOT . '/app/model/' . $className . '.php'); } define('SITE_ROOT', dirname(__FILE__) . '/..'); define('APP_ROOT', dirname(__FILE__) . '/../app'); $cfg = ezcConfigurationManager::getInstance(); $cfg->init('ezcConfigurationIniReader', SITE_ROOT . '/settings'); define('DIR_DEFINITIONS', SITE_ROOT . '/app/model/definitions'); ezcBase::addClassRepository('.', SITE_ROOT . '/core/autoloads'); $driver = $cfg->getSetting('config', 'Database', 'Driver'); $host = $cfg->getSetting('config', 'Database', 'Host'); $port = $cfg->getSetting('config', 'Database', 'Port'); $username = $cfg->getSetting('config', 'Database', 'User'); $password = $cfg->getSetting('config', 'Database', 'Password'); $database = $cfg->getSetting('config', 'Database', 'Database'); $dsn = $driver . '://' . $username . ':' . $password . '@' . $host . '/' . $database; define('DB_DSN', $dsn); $dbInstance = ezcDbFactory::create(DB_DSN); ezcDbInstance::set($dbInstance); @(include_once SITE_ROOT . '/settings/log.php'); /* $dbSession = new ezcPersistentSession( $dbInstance, new ezcPersistentCacheManager( new ezcPersistentCodeManager( DIR_DEFINITIONS ) ) ); */
#!/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 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>, ';
public function testNoPrefixAutoload() { ezcBase::addClassRepository('./Base/tests/test_repository', './Base/tests/test_repository/autoload_files'); __autoload('Object'); if (!class_exists('Object')) { $this->fail("Autoload does not handle classes with no prefix"); } }
<?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(); ?>
<?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');
<?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; }
public function testNoPrefixAutoload2() { ezcBase::addClassRepository(__DIR__ . '/issue15896'); ezc_autoload('ab'); }
<?php $appsPath = realpath(dirname(__FILE__) . '/..'); set_include_path(get_include_path() . PATH_SEPARATOR . $appsPath); ezcBase::addClassRepository($appsPath);
public function testNoPrefixAutoload2() { ezcBase::addClassRepository('./Base/tests/issue15896'); __autoload('ab'); }
/** * Register extensions "the YMC way". * * * @return void * @access public * @author ymc-dabe * @see eZExtension::activateExtensions() * @link http://issues.ez.no/IssueView.php?Id=2709 */ public function registerExtensions($virtual_siteaccess = false) { if (!$this->attribute('is_enabled')) { eZDebug::writeError("The ymcExtensionLoader is disabled, but " . __METHOD__ . " has just been called (which really shouldn't be done)!", __METHOD__); } $siteaccess = self::getCurrentSiteaccess(); $isBasicLoad = true; $is_virtual_load = false; $cache_hit = false; $defaultActiveExtensions = self::$alwaysEnabledExtensions; if (!in_array('ymcextensionloader', $defaultActiveExtensions)) { $defaultActiveExtensions[] = 'ymcextensionloader'; } if ($this->standardLoadingCompleted === true and $virtual_siteaccess !== false and $siteaccess !== $virtual_siteaccess) { if ($this->virtualLoadingCompleted === true) { eZDebug::writeError("Unnecessary call to 'ymcExtensionLoader::registerExtensions('.{$virtual_siteaccess}.')'!", __METHOD__); return; } $siteaccess = $virtual_siteaccess; self::setInternalSiteaccess($siteaccess); eZDebug::accumulatorStart('OpenVolanoExtensionLoader_VirtualSiteaccess', 'OpenVolano: Enhanced Extension Loader', "After virtual siteaccess '{$siteaccess}' initialised "); $isBasicLoad = false; $is_virtual_load = true; $this->rebuildIniOverrideArray($siteaccess, $isBasicLoad); } else { if (null !== $siteaccess) { if ($this->standardLoadingCompleted === true) { eZDebug::writeError("Unnecessary call to " . __METHOD__ . "!", __METHOD__); return; } $isBasicLoad = false; eZDebug::accumulatorStart('OpenVolanoExtensionLoader_Siteaccess', 'OpenVolano: Enhanced Extension Loader', "After siteaccess '{$siteaccess}' initialised "); } else { if (self::$earlyLoadingCompleted === true) { eZDebug::writeWarning("Force registering additional extensions - please keep in mind, that it is not possible to unload extensions", __METHOD__); } eZDebug::accumulatorStart('OpenVolanoExtensionLoader_Basic', 'OpenVolano: Enhanced Extension Loader', 'Pre siteaccess initialised'); } } $ini = eZINI::instance(); $allExtensionsRegistered = false; if ($isBasicLoad) { self::$globalCacheDirectory = eZSys::cacheDirectory(); $cacheFileName = 'basic'; $cache_var_name = 'ymcExtensionLoaderRegisterExtensionBasicLoadInformation'; } else { if ($is_virtual_load) { $cacheFileName = 'siteaccess-' . $this->attribute('non_virtual_siteaccess') . '-virtualsiteaccess-' . $siteaccess; $cache_var_name = 'ymcExtensionLoaderRegisterExtensionVirtualSiteaccessLoadInformation'; } else { $cacheFileName = 'siteaccess-' . $siteaccess; $cache_var_name = 'ymcExtensionLoaderRegisterExtensionSiteaccessLoadInformation'; } } $write_cache = false; $can_write_cache = true; $cacheDir = eZSys::cacheDirectory() . '/openvolano/extensions'; if (!is_writable($cacheDir)) { if (!eZDir::mkdir($cacheDir, 0777, true)) { $can_write_cache = false; eZDebug::writeError("Couldn't create cache directory '{$cacheDir}', perhaps wrong permissions", __METHOD__); } } $cacheFilePath = $cacheDir . '/' . $cacheFileName; if (!file_exists($cacheFilePath)) { $write_cache = $can_write_cache; if ($isBasicLoad) { eZDebug::writeNotice("No cache found for loading basic set of extensions", __METHOD__); } else { eZDebug::writeNotice("No cache found for loading per siteaccess set of extensions for siteaccess '{$siteaccess}'", __METHOD__); } } else { include $cacheFilePath; if (!isset(${$cache_var_name})) { eZDebug::writeWarning("Cache '{$cache_var_name}' in file '{$cacheFilePath}' not found. Trying to force rewrite of this cache file...", __METHOD__); $write_cache = $can_write_cache; } else { eZDebug::writeNotice("Cache hit: {$cacheFilePath}", __METHOD__); $defaultActiveExtensions = ${$cache_var_name}; $cache_hit = true; unset($cache_var_name); } } $additional_lookups = 0; //Loop registering of extensions until all are loaded while (!$allExtensionsRegistered) { //First we asume we do not need to check for new extensions $allExtensionsRegistered = true; //these extensions are always active $activeExtensions = $defaultActiveExtensions; //Get all active extension $activeExtensions = array_unique(array_merge($activeExtensions, eZExtension::activeExtensions())); foreach ($activeExtensions as $activeExtension) { //only activate an extension if it has not been registered, yet if (!in_array($activeExtension, $this->registeredExtensions)) { $this->registeredExtensions[] = $activeExtension; $fullExtensionPath = eZExtension::baseDirectory() . '/' . $activeExtension; if (!file_exists($fullExtensionPath)) { eZDebug::writeWarning("Extension '{$activeExtension}' does not exist, looked for directory '{$fullExtensionPath}'", __METHOD__); } else { $fullExtensionAutoloadPath = $fullExtensionPath . '/autoload'; if ($activeExtension !== 'ymcextensionloader' and !in_array($activeExtension, self::$noAutoloadExtensions) and file_exists($fullExtensionAutoloadPath)) { //add the new extension's autoload-dir to the eZ compontents autoload system (if needed) ezcBase::addClassRepository($fullExtensionPath, $fullExtensionAutoloadPath); } //We are about to activate a new extension which might need to load one ore more other extension (if we do not have a cached info about this) $allExtensionsRegistered = $cache_hit; } } } $this->rebuildIniOverrideArray($siteaccess, $isBasicLoad); if (!$allExtensionsRegistered) { $additional_lookups++; } } if (!$cache_hit) { if ($isBasicLoad) { eZDebug::writeNotice("Loaded all basic extensions in {$additional_lookups} additional lookups...", __METHOD__); } else { if ($is_virtual_load) { eZDebug::writeNotice("Loaded all virtual siteaccess extensions in {$additional_lookups} additional lookups...", __METHOD__); } else { eZDebug::writeNotice("Loaded all siteaccess extensions in {$additional_lookups} additional lookups...", __METHOD__); } } } if ($write_cache) { if ($isBasicLoad) { eZDebug::writeNotice("Storing basic extension load information into cache file '{$cacheFilePath}'...", __METHOD__); } else { if ($is_virtual_load) { eZDebug::writeNotice("Storing virtual siteaccess extension load information into cache file '{$cacheFilePath}'...", __METHOD__); } else { eZDebug::writeNotice("Storing siteaccess extension load information into cache file '{$cacheFilePath}'...", __METHOD__); } } $php = new eZPHPCreator($cacheDir, $cacheFileName); $php->addRawVariable($cache_var_name, $this->registeredExtensions); $php->store(); } if ($is_virtual_load) { $this->virtualLoadingCompleted = true; eZDebug::accumulatorStop('OpenVolanoExtensionLoader_VirtualSiteaccess'); } else { if (!$isBasicLoad) { $this->standardLoadingCompleted = true; $this->non_virtual_siteaccess_name = $siteaccess; eZDebug::accumulatorStop('OpenVolanoExtensionLoader_Siteaccess'); } else { self::$earlyLoadingCompleted = true; eZDebug::accumulatorStop('OpenVolanoExtensionLoader_Basic'); } } //Use the following line to take a look into the ini-hierarchy... //ymc_pr($GLOBALS["eZINIOverrideDirList"], $siteaccess.'|'.self::getCurrentSiteaccess()); if (!$is_virtual_load and !$isBasicLoad and $ini->hasVariable('SiteAccessSettings', 'VirtualSiteaccessSystem') and $ini->variable('SiteAccessSettings', 'VirtualSiteaccessSystem') !== 'disabled') { $allowLoadingOfPreviouslyKnownSiteaccesses = false; if ($ini->hasVariable('SiteAccessSettings', 'VirtualSiteaccessSystem') and $ini->variable('VirtualSiteaccessSettings', 'AllowLoadingOfPerviouslyKnowSiteaccesses') === 'enabled') { $allowLoadingOfPreviouslyKnownSiteaccesses = true; } if (isset($GLOBALS['eZURIRequestInstance']) and is_object($GLOBALS['eZURIRequestInstance'])) { $uri = eZURI::instance(); $elements = $uri->elements(false); if (count($elements) > 0 and $elements[0] != '') { $goInVirtualSiteaccessMode = true; if ($ini->hasVariable('VirtualSiteaccessSettings', 'SkipLoadingForUri') and is_array($ini->variable('VirtualSiteaccessSettings', 'SkipLoadingForUri')) and count($ini->variable('VirtualSiteaccessSettings', 'SkipLoadingForUri')) > 0) { $uri_string = $uri->elements(true); foreach ($ini->variable('VirtualSiteaccessSettings', 'SkipLoadingForUri') as $ignoreUriForVirtualSiteaccess) { if (strpos($uri_string, $ignoreUriForVirtualSiteaccess) === 0) { $goInVirtualSiteaccessMode = false; break; } } unset($uri_string); } } else { $goInVirtualSiteaccessMode = false; } if ($goInVirtualSiteaccessMode) { $matchIndex = 1; $name = $elements[0]; //by ymc-dabe //Code taken from /access.php line 241-249 of eZ publish v4.1.3 //KEEP IT IN SYNC! //start $name = preg_replace(array('/[^a-zA-Z0-9]+/', '/_+/', '/^_/', '/_$/'), array('_', '_', '', ''), $name); //by ymc-dabe //Code taken from /access.php line 241-249 of eZ publush v4.1.3 //KEEP IT IN SYNC! //end if ($allowLoadingOfPreviouslyKnownSiteaccesses or !in_array($name, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { eZSys::addAccessPath($name); $uri->increase($matchIndex); $uri->dropBase(); $this->registerExtensions($name); //die if virtual siteaccess is not found if (!in_array($name, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { header($_SERVER['SERVER_PROTOCOL'] . " 400 Bad Request"); header("Status: 400 Bad Request"); eZExecution::cleanExit(); } } unset($name); } } else { if (isset($GLOBALS['ymcEnhancedExtensionLoaderVirtualSiteaccess']) and $GLOBALS['ymcEnhancedExtensionLoaderVirtualSiteaccess'] != '') { $virtualSiteaccessName = $GLOBALS['ymcEnhancedExtensionLoaderVirtualSiteaccess']; if ($allowLoadingOfPreviouslyKnownSiteaccesses or !in_array($virtualSiteaccessName, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { eZSys::addAccessPath($virtualSiteaccessName); $this->registerExtensions($virtualSiteaccessName); if (!in_array($virtualSiteaccessName, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { fputs(STDERR, "\n----------\nError: Invalid siteaccess '{$virtualSiteaccessName}'!\n----------\n\n"); eZExecution::cleanExit(); } } unset($virtualSiteaccessName); } } } else { if ($this->standardLoadingCompleted === true) { $this->virtualLoadingCompleted = true; } } if ($this->standardLoadingCompleted === true) { $this->loadingCompleted = true; if ($this->originalNonVirtualSiteaccessName === false) { $this->originalNonVirtualSiteaccessName = $this->attribute('non_virtual_siteaccess'); if ($this->originalVirtualSiteaccessName === false and $siteaccess != $this->attribute('non_virtual_siteaccess')) { $this->originalVirtualSiteaccessName = $siteaccess; } } } }
<?php //ini_set( 'include_path', ini_get( 'include_path' ) . ':/htdocs/ezc_trunk/:.' ); ini_set('session.gc_maxlifetime', 864000); require 'Base/src/ezc_bootstrap.php'; // ezcDbInstance::set( ezcDbFactory::create( 'sqlite://'. dirname( __FILE__ ) . '/share.sqlite' ) ); ezcDbInstance::set(ezcDbFactory::create('mysql://*****:*****@127.0.0.1/UnTrucBien')); $options = new ezcBaseAutoloadOptions(array('debug' => true)); ezcBase::setOptions($options); ezcBase::addClassRepository(dirname(__FILE__) . '/lib/share', null, 'share'); ezcBase::addClassRepository(dirname(__FILE__) . '/lib/debug', null, 'debug'); $log = ezcLog::getInstance(); $mapper = $log->getMapper(); $writer = new ezcLogUnixFileWriter("/tmp", "thewire-web.log"); $filter = new ezcLogFilter(); $rule = new ezcLogFilterRule($filter, $writer, true); $mapper->appendRule($rule); $reader = new ezcConfigurationIniReader(); $reader->init(dirname(__FILE__), 'settings'); $ini = $reader->load(); if ($ini->getBoolSetting('DevelopmentSettings', 'Debug')) { ezcBase::setRunMode(ezcBase::MODE_DEVELOPMENT); $debugHandler = ezcDebug::getInstance(); $debugHandler->setOutputFormatter(new debugHtmlFormatter()); debugLogger::setHandler($debugHandler); } $tc = ezcTemplateConfiguration::getInstance(); $tc->templatePath = dirname(__FILE__) . '/templates'; $tc->compilePath = dirname(__FILE__) . '/cache'; $tc->addExtension("shareTemplateFunctions");
<?php // Set the include path to the eZ Components location, and bootstrap the // library. The two lines below assume that you're using eZ Components from // SVN -- see the installation guide at http://ezcomponents.org/docs/install. ini_set('include_path', '/home/derick/dev/ezcomponents/trunk:.'); require 'Base/src/ezc_bootstrap.php'; // Add the class repository containing our application's classes. We store // those in the /lib directory and the classes have the "hello" prefix. ezcBase::addClassRepository(dirname(__FILE__) . '/lib', null, 'hello'); // Configure the template system by telling it where to find templates, and // where to put the compiled templates. $tc = ezcTemplateConfiguration::getInstance(); $tc->templatePath = dirname(__FILE__) . '/templates'; $tc->compilePath = dirname(__FILE__) . '/cache';
<?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);
<?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' ); ?>
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ ini_set('error_reporting', E_ALL); ini_set('register_globals', 0); ini_set('display_errors', 1); ini_set("max_execution_time", "3600"); require_once dirname(__FILE__) . "/ezcomponents/Base/src/base.php"; function __autoload($className) { ezcBase::autoload($className); } ezcBase::addClassRepository(dirname(__FILE__) . '/', dirname(__FILE__) . '/lib/autoloads'); $input = new ezcConsoleInput(); $helpOption = $input->registerOption(new ezcConsoleOption('s', 'siteaccess', ezcConsoleInput::TYPE_STRING)); $cronjobPartOption = $input->registerOption(new ezcConsoleOption('c', 'cronjob', ezcConsoleInput::TYPE_STRING)); $cronjobPathOption = $input->registerOption(new ezcConsoleOption('p', 'path', ezcConsoleInput::TYPE_STRING)); $extensionPartOption = $input->registerOption(new ezcConsoleOption('e', 'extension', ezcConsoleInput::TYPE_STRING)); try { $input->process(); } catch (ezcConsoleOptionException $e) { die($e->getMessage()); } ezcBaseInit::setCallback('ezcInitDatabaseInstance', 'erLhcoreClassLazyDatabaseConfiguration'); $instance = erLhcoreClassSystem::instance(); $instance->SiteAccess = $helpOption->value; $instance->SiteDir = dirname(__FILE__) . '/'; $cfgSite = erConfigClassLhConfig::getInstance();
<?php require_once 'tutorial_autoload.php'; ezcBase::addClassRepository('./repos', './repos/autoloads'); $myVar1 = new erMyClass2(); $myVar1->toString(); $yourVar1 = new erYourClass1(); $yourVar1->toString();