Example #1
0
 static function getConnection($params, $name)
 {
     if (isset(self::$modules[$params['driver']])) {
         Zinc::loadLib(self::$modules[$params['driver']]);
     }
     if (!isset(self::$classMap[$params['driver']])) {
         trigger_error("unknown driver type: " . $params['driver']);
     } else {
         $className = self::$classMap[$params['driver']];
     }
     return new $className($params, $name);
 }
Example #2
0
 public function handleRequest($p)
 {
     Zinc::loadLib('migration');
     $methodName = "handle" . $p[1];
     // var_dump($methodName);
     // die();
     if (method_exists($this, $methodName)) {
         $this->{$methodName}($p);
     } else {
         trigger_error("invalid command\n\n");
     }
 }
Example #3
0
 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);
 }
Example #4
0
File: App.php Project: rgigger/zinc
 public function init()
 {
     Zinc::loadLib('zone');
     Zinc::loadLib('db');
     //if(php_sapi_name() != "cli")
     //	Zinc::loadLib('session');
     Zinc::loadLib('form');
     Zinc::loadLib('mail');
     //	register classess
     Zinc::reg('AppZone', 'domain');
     Zinc::reg('AppGui', 'domain');
     Zinc::reg('Person', 'domain');
     Zinc::reg('Token', 'domain');
     //	register zones
     Zinc::reg('ZoneUser', 'zones');
 }
Example #5
0
 function init()
 {
     $this->smarty = new Smarty();
     $config = $this->params;
     $tmpPath = Zinc::getTmpDir();
     $this->smarty->template_dir = array();
     //	set the default for the base template dir
     //	this should be using the new config stuff, not defines
     if (!defined("gui_template_dir")) {
         define("gui_template_dir", app_dir . "/templates");
     }
     //	set the standard template directory and any others registerd with zoop
     $this->addTemplateDir(gui_template_dir);
     //	set the compile directory
     $modTmpDir = $tmpPath . '/smarty3';
     if (!is_dir($modTmpDir)) {
         mkdir($modTmpDir);
     }
     $this->setCompileDir($modTmpDir);
     //	set the cache_dir directory
     //	what does this even do?  I'm pretty sure that is not set up
     $this->setCacheDir($tmpPath . "/guicache");
     //	set the config directory
     //	what does this even do?  I'm pretty sure that is not set up
     $this->setConfigDir(app_dir . "/guiconfig");
     //	set the plugin directories
     $this->addPluginDir(zinc_dir . '/vendor/smarty3/plugins');
     //	one for plugins added into gui
     $this->addPluginDir(app_dir . "/helpers/smarty3");
     //	one or plugins specific to the app
     $this->addPluginDir(app_dir . "/guiplugins");
     //	one or plugins specific to the app
     //		$this->smarty->default_modifiers = array('escape:"htmlall"');
     $this->smarty->error_reporting = E_ALL;
     $this->smarty->template_class = 'SmartyCustomInternalTemplate';
     //	we shouldn't use the blanket app_status define any more, we should use specific varabiles
     //	for each behavior, and it should use the new config system
     // $smarty->debugging = defined('app_status') && app_status == 'dev' ? true : false;
     // $smarty->compile_check = defined('app_status') && app_status == 'dev' ? true : false;
     //	we want to run this filter on every single smarty script that we execute
     //	it finds all places where we echo out a simple variable and escapes the html
     //
     //	unfortunately this filters everything.  The entire contents if the template.  I think it is escaping include.
     //	If we can get it to not do that then we can put this back in.
     //
     //$this->smarty->autoload_filters = array('pre' => array("strip_html"));
 }
Example #6
0
<?php

include 'const.php';
include '[[$zincDir]]/Zinc.php';
Zinc::loadLib('app');
Zinc::loadLib('zone');
$i = new ApplicationInstance();
Example #7
0
File: zn.php Project: rgigger/zinc
<?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++;
        }
    }
Example #8
0
<?php

// include('config.php');
define('app_dir', __DIR__);
include dirname(dirname(__DIR__)) . '/framework/Zinc.php';
Zinc::loadLib('app');
Zinc::loadLib('db');
$map = SqlFetchSimpleMap('select * from test', 'one', 'two', array());
echo_r($map);
$rows = SqlFetchRows('select * from test', array());
echo_r($rows);
Example #9
0
    public static function reg($className, $dirPath = null)
    {
        if ($dirPath) {
            if ($dirPath[0] == '/') {
                $fullPath = "{$dirPath}/{$className}.php";
            } else {
                $fullPath = app_dir . "/{$dirPath}/{$className}.php";
            }
        } else {
            $fullPath = app_dir . "/{$className}.php";
        }
        self::registerClass($className, $fullPath);
    }
    /**
     * Register a "domain" class for autoload (a domain class is a
     * class that is located in the "domains" directory under
     * the project root with the filename <classname>.php)
     *
     * @param unknown_type $className
     */
    public static function registerDomain($className)
    {
        self::registerClass($className, app_dir . '/domain/' . $className . '.php');
    }
}
Zinc::registerLib('boot');
Zinc::registerLib('core');
Zinc::registerLib('experimental');
Zinc::registerLib('vendor');
Zinc::loadLib('boot');
Example #10
0
 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}");
         }
     });
 }
Example #11
0
<?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));
    }
}