function setUp() { parent::setup(); I2CE::setupFileSearch(); $store = new I2CE_MagicDataStorageMem(); self::$md = TestMagicDataTearDown::instance("config"); self::$md->addStorage($store); I2CE::setConfig(self::$md); self::$c = new I2CE_Configurator(self::$md); self::$c->resetCheckedPaths(); }
getAvailableModules(); if (count($found_modules) == 0) { usage("No modules found"); } $forms = array(); $formClasses = array(); $classMap = array(); foreach ($found_modules as $module => $top) { $file = null; $storage->setIfIsSet($file, "/config/data/{$module}/file"); if (!$file) { echo "No config file for {$module} -- Skipping\n"; continue; } $mod_storage = I2CE_MagicData::instance("tmp_{$module}"); I2CE::setConfig($mod_storage); $mod_configurator = new I2CE_Configurator($mod_storage, false); ob_start(); $s = $mod_configurator->processConfigFile($file, '0', false, false); //process the configGroups but not the meta data. dont show verbose errors. if ($s != $module) { echo "Module mismatch on {$s}!={$module} in {$file}-- Skipping\n"; continue; } if (!$mod_storage->pathExists("/modules/forms/forms") && !$mod_storage->pathExists("/modules/forms/formClasses")) { $mod_configurator->__destruct(); $mod_configurator = null; $mod_storage->erase(); $mod_storage = null; continue; }
/** *Setup the magic data storage * @param array $old_config_values. If non-null set the new storage to have these magic data values * @returns boolean. True on success */ function setupMagicDataStorage($old_config_values = null) { I2CE::raiseError("Setting up magic data in I2CE Core module"); $new_config = I2CE::setupMagicData(false, true); if (!$new_config instanceof I2CE_MagicData) { I2CE::raiseError("Could not setup magic data storage"); return false; } if (is_array($old_config_values)) { // If setting from the old values it will already be stored // in the temporary storage caches so those need to be cleared // or things won't get saved in the new permanent storage so clear // them all out first. $new_config->clearCache(); $new_config->setValue($old_config_values); } I2CE::setConfig($new_config); I2CE_ModuleFactory::instance()->setStorage(); return true; }
#!/usr/bin/php <?php $path_to_i2ce_root = '..'; $path_to_i2ce_root = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . $path_to_i2ce_root) . DIRECTORY_SEPARATOR; require_once $path_to_i2ce_root . 'lib' . DIRECTORY_SEPARATOR . 'I2CE.php'; require_once $path_to_i2ce_root . 'lib' . DIRECTORY_SEPARATOR . 'I2CE_Configurator.php'; require_once $path_to_i2ce_root . 'lib' . DIRECTORY_SEPARATOR . 'I2CE_MagicData.php'; require_once $path_to_i2ce_root . 'lib' . DIRECTORY_SEPARATOR . 'I2CE_FileSearch.php'; require_once "Console/Getopt.php"; $cg = new Console_Getopt(); $args = $cg->readPHPArgv(); $dir = getcwd(); array_shift($args); $config = I2CE_MagicData::instance("check_validity"); I2CE::setConfig($config); foreach ($args as $file) { $file = realpath($file); echo "Checking the validity of {$file}\n"; chdir($path_to_i2ce_root . 'lib'); $config = I2CE_MagicData::instance("config"); $configurator = new I2CE_Configurator($config); if ($configurator->processConfigFile(I2CE_FileSearch::absolut($file), true, true)) { echo "\tThe file {$file} is valid\n"; } chdir($dir); } # Local Variables: # mode: php # c-default-style: "bsd" # indent-tabs-mode: nil # c-basic-offset: 4
} $usage[] = "[--modules=\$module1,\$module2..\$moduleN]: The module(s) for which we wish to operate on\n" . "\tIf not specified, it uses every valid module\n"; $usage[] = "[--search_dirs=\$dir1,\$dir2]: Set the search directories for modules\n" . "\tIf not specified, we search " . implode(',', $search_dirs) . "\n"; $usage[] = "[--limit_search=T/F]: Limit the module search results of found sub-modules of a top-level module to those that are real subdirectories of top-level's given directory\n" . "\tDefaults to T.\n"; if (!isset($booleans) || !is_array($booleans)) { $booleans[] = array(); } $booleans['limit_search'] = true; require_once "CLI.php"; require_once "I2CE_MagicData.php"; require_once "I2CE.php"; require_once "I2CE_ModuleFactory.php"; require_once "I2CE_Configurator.php"; require_once "I2CE_FileSearch.php"; $storage = I2CE_MagicData::instance("CLI_application"); I2CE::setConfig($storage); $mod_factory = I2CE_ModuleFactory::instance(); $configurator = new I2CE_Configurator($storage, false); $found_modules = false; function getAvailableModules() { global $configurator; global $modules; global $search_dirs; global $found_modules; global $booleans; if (is_array($found_modules)) { return $found_modules; } $found_modules = array(); $bad_modules = array();
/** * Constructor * * @param I2CE_MagicData $storage -- if none is passed in, * then a simple MagicData and config storage object using * MagicDataStorageMem will be set up. * * @param boolean $set_last_access */ public function __construct($storage = null, $set_last_access = true) { $this->locales = array(I2CE_Locales::DEFAULT_LOCALE); if (null !== $storage) { $this->storage = $storage; } else { $store = new I2CE_MagicDataStorageMem(); $config = I2CE_MagicData::instance("config"); $config->addStorage($store); $this->storage = $config; I2CE::setConfig($config); } $this->resetMerges(); $this->checked_paths = array(); $this->set_last_access = $set_last_access; $this->setRoot(); }