예제 #1
0
 function AddSource($sourcetype, $cfg)
 {
     if (!empty($cfg)) {
         Profiler::StartTimer("DataManager::Init() - Add source: {$sourcetype}", 3);
         // Check to see if we have a wrapper for this sourcetype in include/datawrappers/*wrapper_class.php
         // If it exists, include the code for it and initialize
         $includefile = "include/datawrappers/" . strtolower($sourcetype) . "wrapper_class.php";
         if (file_exists_in_path($includefile)) {
             include_once $includefile;
             foreach ($cfg as $sourcename => $sourcecfg) {
                 Profiler::StartTimer(" - {$sourcetype}({$sourcename})", 3);
                 // Server groups get special handling at this level so they can be applied to all types
                 if (!empty($sourcecfg["group"]) && ($group = $this->GetGroup($sourcecfg["group"])) !== NULL) {
                     Logger::Notice("Merged source group '{$sourcecfg['group']}' into {$sourcename}");
                     $sourcecfg = array_merge_recursive($sourcecfg, $group);
                 }
                 $classname = $sourcetype . "wrapper";
                 $sourcewrapper = new $classname($sourcename, $sourcecfg, true);
                 if (!empty($sourcecfg["cache"]) && $sourcecfg["cache"] != "none") {
                     if ($cacheobj = array_get($this->caches, $sourcecfg["cache"])) {
                         $sourcewrapper->SetCacheServer($cacheobj, any($sourcecfg["cachepolicy"], true));
                     }
                 }
                 array_set($this->sources, $sourcetype . "." . $sourcename, $sourcewrapper);
                 $sourcelocation = isset($sourcecfg["host"]) ? $sourcecfg["host"] : $sourcecfg["file"];
                 Logger::Notice("Added source '{$sourcetype}.{$sourcename}': " . $sourcelocation);
                 Profiler::StopTimer(" - {$sourcetype}({$sourcename})");
             }
         } else {
             Logger::Debug("Tried to instantiate source '{$sourcetype}', but couldn't find class");
         }
         Profiler::StopTimer("DataManager::Init() - Add source: {$sourcetype}");
     }
 }
예제 #2
0
 function HasComponent($name, $args = NULL)
 {
     $ret = false;
     if (!empty($name) && is_string($name)) {
         if (!empty($this->components[$name])) {
             $ret = true;
         } else {
             $thisname = $this->GetFullName(".");
             $componentname = (!empty($thisname) ? str_replace(".", "_", $thisname) . "_" : "") . $name;
             $componentclassname = "Component_" . str_replace(".", "_", $componentname);
             if (method_exists($this, "controller_" . $name)) {
                 $ret = $this->CreateComponent($name, "ComponentFunction", array($this, "controller_" . $name), $this->path, $args);
             } else {
                 $componentdir = $this->GetComponentDirectory();
                 if (!empty($componentdir)) {
                     $fname = sprintf("%s/components/%s/%s.php", $componentdir, $name, $componentname);
                 } else {
                     $fname = sprintf("components/%s/%s.php", $name, $componentname);
                 }
                 if (($path = file_exists_in_path($fname, true)) !== false) {
                     try {
                         include_once $fname;
                         $ret = $this->CreateComponent($name, $componentclassname, NULL, $path, $args);
                     } catch (Exception $e) {
                         //print_pre($e);
                         print "[Could not load component: " . htmlspecialchars($name) . "]";
                     }
                 } else {
                     if ($this->HasTemplate("./" . $name . ".tpl")) {
                         $ret = $this->CreateComponent($name, "ComponentTemplate", $this->path . "/" . $componentdir . "/templates/" . $name . ".tpl", $path, $args);
                     } else {
                         if ($this->HasTemplate("./" . $name . ".tpl", "components/{$name}")) {
                             $ret = $this->CreateComponent($name, "ComponentTemplate", "components/" . $name . "/templates/" . $name . ".tpl", $path, $args);
                         }
                     }
                 }
             }
             if ($ret === false) {
                 $ret = $this->CreateComponent($name, "ComponentMissing");
             }
         }
     }
     return $ret;
 }
예제 #3
0
 public static function autoloadElation($class)
 {
     //    print "$class <br />";
     if (file_exists_in_path("include/" . strtolower($class) . "_class.php")) {
         require_once "include/" . strtolower($class) . "_class.php";
     } else {
         if (file_exists_in_path("include/model/" . strtolower($class) . "_class.php")) {
             require_once "include/model/" . strtolower($class) . "_class.php";
         } else {
             if (file_exists_in_path("include/Smarty/{$class}.class.php")) {
                 require_once "include/Smarty/{$class}.class.php";
             } else {
                 try {
                     if (class_exists('Zend_Loader', false)) {
                         @Zend_Loader::loadClass($class);
                         //TODO: for f***s sake remove the @ ... just a tmp measure while porting ... do it or i will chum kiu you!
                     }
                     return;
                 } catch (Exception $e) {
                 }
             }
         }
     }
 }
예제 #4
0
 function controller_inspect_component($args, $output = "inline")
 {
     $user = User::singleton();
     if (!$user->HasRole("inspect")) {
         return;
     }
     $components = explode(",", $args["components"]);
     sort($components);
     $vars["components"] = array();
     foreach ($components as $component) {
         $fname = "components/" . implode("/components/", explode(".", $component)) . "/" . str_replace(".", "_", $component) . ".php";
         if ($path = file_exists_in_path($fname)) {
             $fcontents = file_get_contents("{$path}/{$fname}");
             $funcs = $this->parseControllerFunctions($fcontents, false);
             if (!empty($funcs)) {
                 foreach ($funcs as $func) {
                     $vars["components"][] = $this->parseControllerArguments($component, $func);
                 }
             }
         }
     }
     return $this->GetComponentResponse("./inspect_component.tpl", $vars);
 }
예제 #5
0
<?php

if (file_exists_in_path("outlet/Outlet.php")) {
    include_once "outlet/Outlet.php";
}
/**
 * class OrmManager
 * Singleton object for fetching ORM model information
 * @package Framework
 * @subpackage ORM
 */
class OrmManager
{
    protected static $instance;
    public static function singleton($args = NULL)
    {
        $name = __CLASS__;
        if (!self::$instance) {
            self::$instance = new $name($args);
        }
        return self::$instance;
    }
    public $outlet;
    function __construct($locations = NULL)
    {
        $dbdir = any($locations['tmp'], 'tmp');
        if (class_exists("Outlet")) {
            Outlet::init(array('connection' => array('type' => 'datamanager'), 'classes' => array()));
            $this->outlet =& Outlet::getInstance();
        }
    }
예제 #6
0
function dir_exists_in_path($dir, $realpath = false)
{
    return file_exists_in_path($dir, $realpath, true);
}
예제 #7
0
                }
                function assign_by_ref()
                {
                }
                function template_exists()
                {
                }
            }
        }
    }
}
if (!empty($path)) {
    define("SMARTY_PATH", $path);
}
// Form validation
if (file_exists_in_path("include/smarty/SmartyValidate.class.php")) {
    include_once "include/smarty/SmartyValidate.class.php";
}
class TemplateManager extends Smarty
{
    private $_template_exists_cache = array();
    private $_is_combined_cache = array();
    protected static $instance;
    public $varreplace = array();
    public $currenttpl = null;
    public static function singleton($args = NULL)
    {
        $name = __CLASS__;
        if (!self::$instance) {
            self::$instance = new $name($args);
        }