public function loadMod($name) { // if this library doesn't have this module then Zinc will have to figure out which one does if (!$this->hasMod($name)) { return Zinc::loadMod($name); } if (isset($this->mods[$name]) && $this->mods[$name]) { return; } $modName = ucfirst($name) . 'Module'; include $this->getModDir($name) . "/{$modName}.php"; $this->mods[$name] = new $modName("{$this->path}/{$name}", $this); }
<?php // get the location of the init.php file according to the following rules // 1. if there is one in the current directory then use it // 2. check for a -D flag. If it is set then use that as the directory // 3. check for a -I flag. If it is set then check for the user config to see if // there is an instance name and directory set up. If so use that // 4. if there is an environmental variable INSTANCE_DIR set then use that // 2-4 above not done // include the basic Zinc stuff if (file_exists('./init.php')) { include 'init.php'; } else { include dirname(dirname(__DIR__)) . '/Zinc.php'; Zinc::registerLib('core'); Zinc::loadMod('cli'); } // load the default zn config Config::suggest(__DIR__ . '/config.yaml'); // process the command line args and determine which Command* class to use $args = $argv; array_shift($args); $wordlist = Config::get('zn.commands'); $counts = array(); foreach (Config::get('zn.commands') as $commandName => $keywords) { $count = 0; foreach ($keywords as $word) { if (in_array($word, $args)) { $count++; } }
public static function gen_r($name, $statName, $params) { Zinc::loadMod('app'); Zinc::loadMod('gui'); $statPath = dirname(zinc_dir) . "/stationary/{$statName}"; // get a list of all the files that need to be processed as templates $raw = file_get_contents($statPath . '/stationary'); // replace any separators that may have been used with just single spaces $stripped = preg_replace('/[\\s,;:]+/', ' ', $raw); $templateFiles = explode(' ', $stripped); if (!file_exists($name)) { mkdir($name); } // go through each file, if it is a template process it, otherwise just copy it dir_r($statPath, function ($it, $info) use($templateFiles, $statPath, $name, $params) { $filename = $it->getSubPathName(); if ($filename == 'stationary' && $it->isFile() || $it->isDot()) { return; } $path = "{$name}/" . $it->getSubPath(); if ($path && !file_exists($path)) { mkdir($path, 0775, true); } if (in_array($filename, $templateFiles)) { echo "processing template {$filename}\n"; CommandStationary::gen("{$statPath}/{$filename}", "{$name}/{$filename}", $params); } else { echo "copying file {$filename}\n"; copy("{$statPath}/{$filename}", "{$name}/{$filename}"); } }); }
<?php Zinc::loadMod('sfyaml'); class Yaml { static function read($filename) { return sfYaml::load(file_get_contents($filename)); // return Spyc::YAMLLoad($filename); } static function write($filename, $data) { file_put_contents($filename, Spyc::YAMLDump($data, 4, 0)); } }