Exemplo n.º 1
0
 function run()
 {
     global $SITE, $DB, $Templates;
     $_POST->setType('vis', 'any', true);
     $_POST->setType('def', 'string', true);
     $_REQUEST->setType('upd', 'any');
     $properties = $DB->setset->asArray(false, false, false, false, 'property');
     if ($_POST['def']) {
         $vis = $_POST['vis'];
         $def = $_POST['def'];
         foreach ($properties as $property) {
             $property = $property['property'];
             Settings::changeSetting($property, false, false, $vis[$property]);
             $SITE->settings[$property] = $def[$property];
         }
         redirect(url(array('upd' => 1), true));
     }
     if ($_REQUEST['upd']) {
         Flash::create(__('Settings updated'), 'confirmation');
     }
     __autoload('Form');
     $TRs = array();
     $settings_types = array(__('Administrator-specified'), __('User level, pre-specified'), __('User level, self-specified'), __('User- or group level, pre-specified'), __('User- or group level , self-specified'), __('Group level, pre-specified'), __('Group level, self-specified'));
     foreach ($properties as $property) {
         $TRs[] = new Tablerow(Settings::name($property['property']), new Select(false, 'vis[' . $property['property'] . ']', $settings_types, $property['visible']), Settings::display($property['type'], false, 'def[' . $property['property'] . ']', $SITE->settings[$property['property']], $property['description'], $property['set']));
     }
     $form = new Form('sitesettings');
     $this->setContent('header', __('Default user settings'));
     $this->setContent('main', $form->collection(new Table(new Tableheader(__('Property'), __('Type'), __('Property default')), $TRs)));
     $Templates->admin->render();
 }
Exemplo n.º 2
0
 function tabularize($ids, $fields)
 {
     global $Controller;
     __autoload('Table');
     $r = array(new Tableheader($fields));
     foreach ($ids as $id) {
         $row = array();
         foreach ($fields as $field) {
             switch ($field) {
                 case 'attendance':
                     $row[] = new Table(new Tablerow(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null));
                     break;
                 case 'group':
                     $s = (array) @$this->interesting_groups;
                     $ig = array();
                     foreach ($s as $g) {
                         $g = $Controller->get($g, OVERRIDE, false, true, 'Group');
                         if ($g && $g->isMember($id)) {
                             $ig[] = $g;
                         }
                     }
                     $row[] = implode(',', $ig);
                     break;
                 default:
                     $row[] = $Controller->get($id)->userinfo[$field];
                     break;
             }
         }
         $r[] = new Tablerow($row);
     }
     return new Table($r);
 }
Exemplo n.º 3
0
 /**
  * Craft new object
  *
  * @param string $name
  * @param array $params
  * @param string $func
  * @return object
  */
 public static function factory($name, $params = null, $func = '__instance')
 {
     if (!class_exists($name) && is_callable("__autoload")) {
         __autoload($name);
     }
     if (class_exists($name)) {
         if (is_callable(array($name, $func))) {
             return call_user_func_array(array($name, $func), $params);
             // метод $name::$func вызван статично
         } else {
             if (!$params) {
                 // пытаемся сэкономить время
                 return new $name();
             } else {
                 $reflection = new ReflectionClass($name);
                 return $reflection->newInstanceArgs($params);
             }
         }
     } else {
         $factory = ucfirst($name) . "Factory";
         if (!class_exists($factory) && is_callable("__autoload")) {
             __autoload($factory);
         }
         if (class_exists($factory) && is_callable(array($factory, "factory"), true)) {
             return call_user_func_array(array($factory, "factory"), $params);
         }
     }
     // если мы до сюда дошли и ничего не вернули то бросаем исключение
     throw new FactoryException("Class '{$name}' doesn't declared and can't be loaded so does it's factory");
 }
Exemplo n.º 4
0
/**
 * Gets called, when an undefined class is being instanciated
 *d
 * @param_string $load_class_name
 */
function feng__autoload($load_class_name)
{
    static $loader = null;
    $class_name = strtoupper($load_class_name);
    // Try to get this data from index...
    if (isset($GLOBALS[AutoLoader::GLOBAL_VAR])) {
        if (isset($GLOBALS[AutoLoader::GLOBAL_VAR][$class_name])) {
            return include $GLOBALS[AutoLoader::GLOBAL_VAR][$class_name];
        }
        // if
    }
    // if
    if (!$loader) {
        $loader = new AutoLoader();
        $loader->addDir(ROOT . '/application');
        $loader->addDir(ROOT . '/environment');
        $loader->addDir(ROOT . '/library');
        $loader->setIndexFilename(ROOT . '/cache/autoloader.php');
    }
    // if
    try {
        $loader->loadClass($class_name);
    } catch (Exception $e) {
        try {
            if (function_exists("__autoload")) {
                __autoload($class_name);
            }
        } catch (Exception $ex) {
            die('Caught Exception in AutoLoader: ' . $ex->__toString());
        }
    }
    // try
}
Exemplo n.º 5
0
 function mover()
 {
     __autoload('Form');
     $this->setContent('header', __('Moving ' . strtolower(get_class($this->that))) . ': ' . $this->that->basename);
     $_REQUEST->addType('to', '#^\\$$#');
     // Placeholder
     return new Formsection(__('Select destination'), $this->fullStructure(url(array('to' => '$'), array('id', 'action'))));
 }
Exemplo n.º 6
0
/**
 * Checks to see if the specified model exists.
 */
function model_exists($model)
{
    try {
        __autoload(ucfirst($model));
    } catch (ClassException $e) {
        return false;
    }
    return true;
}
Exemplo n.º 7
0
 function run()
 {
     __autoload('Form');
     if ($this->saveChanges()) {
         redirect(array('id' => $this->that->ID));
     }
     global $Templates;
     $this->setContent('main', Form::quick(false, null, $this->editTab()));
     $Templates->render();
 }
Exemplo n.º 8
0
 /**
  * Constructor - Extracts its name and instanciates the corresponding model
  */
 public function __construct()
 {
     // Détection du nom du contrôleur
     preg_match('#^(.*)_Controller$#', get_class($this), $match);
     $this->name = $match[1];
     // Chargement du modèle s'il existe
     $model_name = $this->name . '_Model';
     if (__autoload($model_name)) {
         $this->model = new $model_name();
     }
 }
 function run()
 {
     __autoload('Form');
     if ($this->saveChanges()) {
         redirect(array('id' => $this->that->ID));
     }
     global $Templates;
     $this->setContent('header', __('Edit calendar-viewer settings'));
     $this->setContent('main', Form::quick(false, null, $this->editTab()));
     $Templates->admin->render();
 }
Exemplo n.º 10
0
 /**
  * This is a simple registry of objects created by the application. This
  * method makes use of the registry design pattern to create objects
  * @param string $name The class name
  * @return object Will return an object of the class
  */
 public function registry($name)
 {
     # Check if the object has already been created
     if (!isset($this->objects[$name])) {
         # Load the class
         __autoload($name);
         # Create an object of the class
         $this->objects[$name] = new $name();
     }
     # Return the object of the class
     return $this->objects[$name];
 }
 function getLogger()
 {
     if (isset($this->logger)) {
         return $this->logger;
     }
     isset(self::$logStream) || (self::$logStream = fopen(self::$logFile, 'ab'));
     // http://bugs.php.net/42098 workaround
     class_exists('Patchwork\\Logger') || eval(';') || __autoload('Patchwork\\Logger');
     $l = new Logger(self::$logStream, $_SERVER['REQUEST_TIME_FLOAT']);
     $l->lock = false;
     $l->lineFormat = sprintf('%010d', substr(mt_rand(), -10)) . ": %s";
     return $this->logger = $l;
 }
Exemplo n.º 12
0
function maksa_ps_autoload($className)
{
    $path = str_replace(array("_", "\\"), "/", $className);
    $parts = explode('/', $path);
    if ($parts[0] == 'Ulink') {
        require_once '../ulink/src/' . $path . ".php";
        return true;
    } else {
        if (function_exists('__autoload') and __autoload($className)) {
            return true;
        }
    }
    return false;
}
Exemplo n.º 13
0
 public function GetPager($PagerType, $Sender)
 {
     $PagerType = $PagerType . 'Module';
     if (!class_exists($PagerType, FALSE)) {
         __autoload($PagerType);
     }
     if (!class_exists($PagerType, FALSE)) {
         $PagerType = 'PagerModule';
         __autoload($PagerType);
     }
     if (!class_exists($PagerType, FALSE)) {
         return FALSE;
     }
     return new $PagerType($Sender);
 }
Exemplo n.º 14
0
 function writeEvent($type, $data)
 {
     if ('php-error' === $type || 'php-exception' === $type) {
         \Patchwork::setMaxage(0);
         \Patchwork::setExpires('onmaxage');
         $GLOBALS['patchwork_private'] = true;
     }
     if ($this->isFirstEvent) {
         // http://bugs.php.net/42098 workaround
         class_exists('Patchwork\\PHP\\Walker') || eval(';') || __autoload('Patchwork\\PHP\\Walker');
         class_exists('Patchwork\\PHP\\Dumper') || eval(';') || __autoload('Patchwork\\PHP\\Dumper');
         class_exists('Patchwork\\PHP\\JsonDumper') || eval(';') || __autoload('Patchwork\\PHP\\JsonDumper');
         $data['patchwork'] = array('i18n' => PATCHWORK_I18N, 'debug' => DEBUG, 'turbo' => Superloader::$turbo, 'level' => PATCHWORK_PATH_LEVEL, 'zcache' => PATCHWORK_ZCACHE, 'paths' => $GLOBALS['patchwork_path']);
     }
     return parent::writeEvent($type, $data);
 }
Exemplo n.º 15
0
/**
 * Gets called, when an undefined class is being instanciated
 *d
 * @param_string $load_class_name
 */
function feng__autoload($load_class_name) {
	static  $loader ;
	//$loader = null;
	$class_name = strtoupper($load_class_name);

	// Try to get this data from index...
	if(isset($GLOBALS[AutoLoader::GLOBAL_VAR])) {
		if(isset($GLOBALS[AutoLoader::GLOBAL_VAR][$class_name])) {
			return include $GLOBALS[AutoLoader::GLOBAL_VAR][$class_name];
		} // if
	} // if
	//pre_print_r($loader) ;exit;
	
	if(!$loader) {
		$loader = new AutoLoader();
		$loader->addDir(ROOT . '/application');
		$loader->addDir(ROOT . '/environment');
		$loader->addDir(ROOT . '/library');
		
		//TODO Pepe: No tengo la conexion ni las clases de DB en este momento.. me conecto derecho 
		$temp_link  = mysql_connect(DB_HOST, DB_USER, DB_PASS) ;
		mysql_select_db(DB_NAME) ;
		$res = mysql_query("SELECT name FROM ".TABLE_PREFIX."plugins WHERE is_installed = 1 AND is_activated = 1;");
		while ($row = mysql_fetch_object($res)) {	
			$plugin_name =  strtolower($row->name) ;
			$dir  = ROOT . '/plugins/'.$plugin_name.'/application' ;
			if (is_dir($dir)) {
				$loader->addDir($dir); 
			}
		}
		mysql_close($temp_link);
		
		
		$loader->setIndexFilename(CACHE_DIR . '/autoloader.php');
		
	} // if

	try {
		$loader->loadClass($class_name);
	} catch(Exception $e) {
		try {
			if (function_exists("__autoload")) __autoload($class_name);
		} catch(Exception $ex) {
			die('Caught Exception in AutoLoader: ' . $ex->__toString());
		}
	} // try
} // __autoload
Exemplo n.º 16
0
 public function GetPager($PagerType, $Sender)
 {
     if (substr($PagerType, -6) != 'Module') {
         $PagerType .= 'Module';
     }
     if (!class_exists($PagerType)) {
         __autoload($PagerType);
     }
     if (!class_exists($PagerType)) {
         $PagerType = 'PagerModule';
         __autoload($PagerType);
     }
     if (!class_exists($PagerType)) {
         return FALSE;
     }
     return new $PagerType($Sender);
 }
Exemplo n.º 17
0
function unserializer($class_name)
{
    echo __METHOD__ . "({$class_name})\n";
    switch ($class_name) {
        case 'TestNAOld':
            eval("class TestNAOld extends TestOld {}");
            break;
        case 'TestNANew':
            eval("class TestNANew extends TestNew {}");
            break;
        case 'TestNANew2':
            eval("class TestNANew2 extends TestNew {}");
            break;
        default:
            echo "Try __autoload()\n";
            __autoload($class_name);
            break;
    }
}
Exemplo n.º 18
0
/** Autoload any classes that are required **/
function __autoload($className)
{
    if (file_exists(ROOT . DS . 'application' . DS . 'library' . DS . $className . '.class.php')) {
        require_once ROOT . DS . 'application' . DS . 'library' . DS . $className . '.class.php';
    } else {
        if (file_exists(ROOT . DS . 'application' . DS . 'controllers' . DS . $className . '.php')) {
            require_once ROOT . DS . 'application' . DS . 'controllers' . DS . $className . '.php';
        } else {
            if (file_exists(ROOT . DS . 'application' . DS . 'models' . DS . $className . '.php')) {
                require_once ROOT . DS . 'application' . DS . 'models' . DS . $className . '.php';
            } else {
                if ($className != strtolower($className)) {
                    __autoload(strtolower($className));
                } else {
                    /* Error Generation Code Here */
                }
            }
        }
    }
}
Exemplo n.º 19
0
 /**
  * Retorna a instância única do objecto solicitado (Singleton)
  * @param string $NameClass
  * @return object
  */
 public static function getInstance($NameClass, $Path = null, array $Parametros = [])
 {
     # Chave da instancia
     $key = $NameClass;
     if (isset(self::$Instances[$key])) {
         return self::$Instances[$key];
     } else {
         # Adicionando Barra ao Final
         if (!preg_match('/[\\/\\\\]$/', $Path)) {
             $Path .= '/';
         }
         # Criando
         if (__autoload("{$Path}{$NameClass}")) {
             return APP::$Instances[$key] = (new ReflectionClass($NameClass))->newInstanceArgs($Parametros);
         } else {
             throw new Exception("A class `{$NameClass}` não existe.");
         }
     }
     return null;
 }
Exemplo n.º 20
0
 /**
  * method for laoding core config
  * @param  array $cfg default configuration
  * @return array throw an exception if core is not defined in db
  */
 public static function load($cfg = array())
 {
     $instance = static::getInstance();
     // merging configs from platform, from casebox database and from core itself
     $cfg = array_merge($cfg, static::getPlatformDBConfig());
     $cfg = array_merge($cfg, static::getPlatformConfigForCore($cfg['core_name']));
     $coreDBConfig = static::getCoreDBConfig();
     $propertiesToMerge = array('files');
     //detect available languages
     $languages = empty($coreDBConfig['languages']) ? $cfg['languages'] : $coreDBConfig['languages'];
     //prepare language properties to be decoded and merged
     $languages = explode(',', $languages);
     foreach ($languages as $l) {
         $l = 'language_' . $l;
         if (isset($cfg[$l])) {
             $cfg[$l] = Util\toJSONArray($cfg[$l]);
         }
         if (isset($coreDBConfig[$l])) {
             $coreDBConfig[$l] = Util\toJSONArray($coreDBConfig[$l]);
         }
         $propertiesToMerge[] = $l;
     }
     $cfg = static::mergeConfigs($cfg, $coreDBConfig, $propertiesToMerge);
     static::$config = static::adjustConfig($cfg);
     static::$environmentVars = static::getEnvironmentVars(static::$config);
     // add core path to include path
     set_include_path(INCLUDE_PATH . PATH_SEPARATOR . static::$environmentVars['core_dir']);
     // set max file version count
     if (isset(static::$config['files']['max_versions'])) {
         __autoload('CB\\Files');
         Files::setMFVC(static::$config['files']['max_versions']);
     } elseif (isset(static::$config['max_files_version_count'])) {
         //backward compatibility check
         __autoload('CB\\Files');
         Files::setMFVC(static::$config['max_files_version_count']);
     }
     // set temp upload directory
     ini_set('upload_tmp_dir', static::$environmentVars['upload_temp_dir']);
     ini_set('error_log', static::$environmentVars['error_log']);
     return static::$config;
 }
Exemplo n.º 21
0
 /**
  * Autoloader for this module classes
  */
 function currencyByCountryAutoload($class_name)
 {
     $module_name = 'currencybycountry';
     $class_name = ltrim($class_name, '\\');
     $file_name = '';
     $namespace = '';
     if ($last_ns_post = strrpos($class_name, '\\')) {
         $namespace = Tools::substr($class_name, 0, $last_ns_post);
         $class_name = Tools::substr($class_name, $last_ns_post + 1);
         $file_name = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
     }
     $file_name .= str_replace('_', DIRECTORY_SEPARATOR, $class_name) . '.php';
     $file_name = _PS_MODULE_DIR_ . $module_name . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . $file_name;
     if (file_exists($file_name)) {
         return require_once $file_name;
     } elseif (version_compare(_PS_VERSION_, '1.4.0.0', '>=') && function_exists('__autoload')) {
         return __autoload($class_name);
     } elseif (version_compare(_PS_VERSION_, '1.4.0.0', '<') && is_readable(_PS_ROOT_DIR_ . '/classes/' . $class_name . '.php')) {
         require_once _PS_ROOT_DIR_ . '/classes/' . $class_name . '.php';
     }
 }
Exemplo n.º 22
0
<?php

__autoload('DataSource');
__autoload('PreparedStatement');
class ExportBillDAO
{
    private $ds;
    public function ExportBillDAO($ds)
    {
        $this->ds = $ds;
    }
    public function checkExisted($stock_id)
    {
        $ps = new PreparedStatement('SELECT id FROM export_bills WHERE stock_id = ?');
        $ps->setInt(1, $stock_id);
        $rs = $this->ds->execute($ps->getSql());
        $ret = FALSE;
        if (mysql_fetch_array($rs)) {
            $ret = TRUE;
        }
        mysql_free_result($rs);
        return $ret;
    }
}
Exemplo n.º 23
0
 /**
  * Adds the specified module to the specified asset target. If no asset
  * target is defined, it will use the asset target defined by the module's
  * AssetTarget method.
  *
  * @param mixed $Module A module or the name of a module to add to the page.
  * @param string $AssetTarget
  * @todo $AssetTarget need the correct variable type and description.
  */
 public function AddModule($Module, $AssetTarget = '')
 {
     $this->FireEvent('BeforeAddModule');
     if (!is_object($Module)) {
         if (property_exists($this, $Module) && is_object($this->{$Module})) {
             $Module = $this->{$Module};
         } else {
             if (!class_exists($Module)) {
                 __autoload($Module);
             }
             if (class_exists($Module)) {
                 // Make sure that the class implements Gdn_IModule
                 $ReflectionClass = new ReflectionClass($Module);
                 if ($ReflectionClass->implementsInterface("Gdn_IModule")) {
                     $Module = new $Module($this);
                 }
             }
         }
     }
     if (is_object($Module)) {
         $AssetTarget = $AssetTarget == '' ? $Module->AssetTarget() : $AssetTarget;
         // echo '<div>adding: '.$Module->Name().' ('.(property_exists($Module, 'HtmlId') ? $Module->HtmlId : '').') to '.$AssetTarget.' <textarea>'.$Module->ToString().'</textarea></div>';
         $this->AddAsset($AssetTarget, $Module->ToString(), $Module->Name());
     }
     $this->FireEvent('AfterAddModule');
 }
Exemplo n.º 24
0
 public static function autoloadProxy($class)
 {
     __autoload($class);
 }
Exemplo n.º 25
0
 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");
     }
 }
Exemplo n.º 26
0
 /**
  * Handle the instantiation of the passed object from the .yaml file.
  * 
  * The .yaml mechanism simply looks for a file named <pageName>.yaml in your module's templates directory.
  * The .your contains a list of all WFView instances for the page, in a hierarchical tree, and the configuration / binding information for each instance.
  *
  * <code>
  * form:
  *   class: WFForm
  *   properties:
  *     method: post
  *   children:
  *     aField:
  *       class: WFTextField
  *       properties:
  *         maxLength: 50
  *       bindings:
  *         value:
  *           instanceID: customer
  *           controllerKey: selection
  *           modelKeyPath: creationDTS
  *           options:
  * </code>
  *
  * For each instance id, an instance of the listed class will be added to the view hierarchy. If children are listed, they will be added as well
  * at the appropriate place in the hierarchy.
  *
  * @param string The ID of the instance.
  * @param assoc_array The manifest info for the instance.
  * @return object The instantiated object.
  */
 protected function initInstanceYAML($id, $instanceManifest)
 {
     // determine the class
     if (!isset($instanceManifest['class'])) {
         throw new Exception("Instance ID '{$id}' declared without a class. FATAL!");
     }
     $class = $instanceManifest['class'];
     WFLog::log("Instantiating object id '{$id}'", WFLog::TRACE_LOG);
     // we want to see if the class is a WFView subclass before instantiating (so that we can be sure our 'new' call below calls an existing prototype).
     // bug in PHP's is_subclass_of() causes segfault sometimes if the class needs to be autoloaded, so in 5.1.0 PHP stops calling autoload.
     // Thus, the fix is to load the class ourselves if needed before checking the inheritance.
     if (!class_exists($class) && function_exists('__autoload')) {
         __autoload($class);
     }
     if (!is_subclass_of($class, 'WFView')) {
         throw new Exception("Only WFView objects can be instantiated in the .yaml file. Object id '{$id}' is of class '{$class}'.");
     }
     // NOTE!! We don't need to call addInstance() for widgets, as the WFWidget constructor does this automatically.
     // instantiate widget
     $object = new $class($id, $this);
     // set up object properties
     if (isset($instanceManifest['properties'])) {
         // configure widget
         WFLog::log("loading properties for id '{$id}'", WFLog::TRACE_LOG);
         // atrributes
         foreach ($instanceManifest['properties'] as $keyPath => $value) {
             switch (gettype($value)) {
                 case "boolean":
                 case "integer":
                 case "double":
                 case "string":
                 case "NULL":
                     // these are all OK, fall through
                     break;
                 default:
                     throw new Exception("Config value for WFView instance id::property '{$id}::{$keyPath}' is not a vaild type (" . gettype($value) . "). Only boolean, integer, double, string, or NULL allowed.");
                     break;
             }
             if (is_string($value) and strncmp($value, "#module#", 8) === 0) {
                 $module_prop_name = substr($value, 8);
                 WFLog::log("Setting '{$id}' property, {$keyPath} => shared object: {$module_prop_name}", WFLog::TRACE_LOG);
                 $object->setValueForKeyPath($this->module->valueForKey($module_prop_name), $keyPath);
             } else {
                 if (is_string($value) and strncmp($value, "#constant#", 10) === 0) {
                     $constant_name = substr($value, 10);
                     if (!defined($constant_name)) {
                         throw new WFException("Undefined constant: {$constant_name}");
                     }
                     WFLog::log("Setting '{$id}' property, {$keyPath} => constant({$constant_name})", WFLog::TRACE_LOG);
                     $object->setValueForKeyPath(constant($constant_name), $keyPath);
                 } else {
                     WFLog::log("Setting '{$id}' property, {$keyPath} => {$value}", WFLog::TRACE_LOG);
                     $object->setValueForKeyPath($value, $keyPath);
                 }
             }
         }
     }
     // set up bindings
     if (isset($instanceManifest['bindings'])) {
         foreach ($instanceManifest['bindings'] as $bindProperty => $bindingInfo) {
             if (!isset($bindingInfo['modelKeyPath'])) {
                 $bindingInfo['modelKeyPath'] = '';
             }
             WFLog::log("Binding '{$id}' property '{$bindProperty}' to {$bindingInfo['instanceID']} => {$bindingInfo['modelKeyPath']}", WFLog::TRACE_LOG);
             // determine object to bind to:
             if (!is_string($bindingInfo['instanceID'])) {
                 throw new Exception("'{$bindProperty}' binding parameter instanceID is not a string.");
             }
             if (!isset($bindingInfo['instanceID'])) {
                 throw new Exception("No instance id specified for binding object id '{$id}', property '{$bindProperty}'.");
             }
             // let objects be bound to the module, like "File's Owner" kinda thing...
             if ($bindingInfo['instanceID'] == '#module#') {
                 $bindToObject = $this->module;
             } else {
                 $bindToObject = $this->module->valueForKey($bindingInfo['instanceID']);
             }
             // at this point we should have an object...
             if (!is_object($bindToObject)) {
                 throw new Exception("Module instance var '{$bindingInfo['instanceID']}' does not exist for binding object id '{$id}', property '{$bindProperty}'.");
             }
             // now calculate full modelKeyPath from controllerKey and modelKeyPath (simple concatenation).
             $fullKeyPath = '';
             if (isset($bindingInfo['controllerKey'])) {
                 if (!is_string($bindingInfo['controllerKey'])) {
                     throw new Exception("'{$bindProperty}' binding parameter controllerKey is not a string.");
                 }
                 $fullKeyPath .= $bindingInfo['controllerKey'];
             }
             if (isset($bindingInfo['modelKeyPath'])) {
                 if (!is_string($bindingInfo['modelKeyPath'])) {
                     throw new Exception("'{$bindProperty}' binding parameter modelKeyPath is not a string.");
                 }
                 if (!empty($fullKeyPath)) {
                     $fullKeyPath .= '.';
                 }
                 $fullKeyPath .= $bindingInfo['modelKeyPath'];
             }
             if (empty($fullKeyPath)) {
                 throw new Exception("No keyPath specified for binding object id '{$id}', property '{$bindProperty}'.");
             }
             // process options
             $options = NULL;
             if (isset($bindingInfo['options'])) {
                 // check type of all options
                 foreach ($bindingInfo['options'] as $key => $value) {
                     switch (gettype($value)) {
                         case "boolean":
                         case "integer":
                         case "double":
                         case "string":
                         case "NULL":
                             // these are all OK, fall through
                             break;
                         default:
                             throw new Exception("Binding option '{$key}' for WFView instance id::property '{$id}::{$bindProperty}' is not a vaild type (" . gettype($value) . "). Only boolean, integer, double, string, or NULL allowed.");
                             break;
                     }
                 }
                 $options = $bindingInfo['options'];
             }
             try {
                 $object->bind($bindProperty, $bindToObject, $fullKeyPath, $options);
             } catch (Exception $e) {
                 print_r($bindingInfo);
                 throw $e;
             }
         }
     }
     // set up children
     if (isset($instanceManifest['children'])) {
         if (!is_array($instanceManifest['children'])) {
             throw new Exception("Widget ID '{$id}' children list is not an array.");
         }
         // recurse into children
         foreach ($instanceManifest['children'] as $id => $childInstanceManifest) {
             $childInstance = $this->initInstanceYAML($id, $childInstanceManifest);
             $object->addChild($childInstance);
         }
     }
     return $object;
 }
Exemplo n.º 27
0
<?php

require_once 'includes/utils.php';
__autoload('DataSource');
__autoload('MemberDAO');
__autoload('PromoDAO');
class loginController extends BaseController
{
    // 0: guest
    // 1: admin
    // 2: mod
    public function getPermissionDefine()
    {
        return array('index' => array(0, 1, 2));
    }
    public function isAllowCountStats()
    {
        return FALSE;
    }
    public function index()
    {
        echo 'zzzzzzzzzzz 1';
        if ($this->findGroupId() > 0) {
            header('Location: ' . __SITE_CONTEXT . 'admin/dashboard/');
            return;
        }
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $username = remove_slashes($_POST['username']);
            $password = remove_slashes($_POST['password']);
            $memberDAO = new MemberDAO(DataSource::getInstance());
            $group_id = $memberDAO->checkLogin($username, $password);
Exemplo n.º 28
0
function error($message, $url = '', $time = 3)
{
    $status = 'error';
    include ROOT . '/public/tpl/error.html.php';
    exit;
}
function error_404($message)
{
    include ROOT . '/public/tpl/error_404.html.php';
    exit;
}
//+---------------------------------------------------------------
//| 实例化默认需要加载的类
//+---------------------------------------------------------------
__autoload('mysql');
__autoload('common');
$db = new common();
//+---------------------------------------------------------------
//| 模块加载
//+---------------------------------------------------------------
$a = $db->get('a') == '' ? 'index' : $db->get('a');
$a_file = ROOT . '/' . APP . '/' . $a . '.php';
if (!file_exists($a_file)) {
    error_404('The requested page was not found on this server!');
    // 模块操作文件找不到
} else {
    // 开启缓冲
    ob_start();
    // 加载模块操作文件
    require_once $a_file;
    $content = '';
Exemplo n.º 29
0
<?php

require_once 'includes/utils.php';
__autoload('DataSource');
__autoload('PreparedStatement');
__autoload('CartItemDAO');
class CartDAO
{
    private $ds;
    public function CartDAO($ds)
    {
        $this->ds = $ds;
    }
    public function insert($listItem)
    {
        $ps = new PreparedStatement('INSERT carts(checkout_datetime) VALUES(?)');
        $ps->setString(1, get_cur_datetime());
        if ($this->ds->execute($ps->getSql())) {
            $cart_id = $this->ds->getLastId();
            $cartItemDAO = new CartItemDAO($this->ds);
            foreach ($listItem as $key => $value) {
                $cartItemDAO->insert($cart_id, $key, $value);
            }
            return $cart_id;
        } else {
            return -1;
        }
    }
    public function findById($id)
    {
        $sql = 'SELECT * FROM carts WHERE id = ?';
Exemplo n.º 30
0
 /**
  * Php errors' handler. Convert errors to exceptions
  *
  * @param int $errno
  * @param string $errstr
  * @param string $errfile
  * @param int $errline
  */
 static function phpErrorHandler($errno, $errstr, $errfile, $errline)
 {
     if ($errno & error_reporting()) {
         if (!class_exists('Naf_Exception_Php', false)) {
             __autoload('Naf_Exception_Php');
         }
         if (class_exists('Naf_Exception_Php', false)) {
             throw new Naf_Exception_Php($errstr);
         }
     } else {
         return true;
     }
 }