Example #1
0
 protected function buildQuery($task)
 {
     $sql = "";
     if ($task == 'store') {
         if ($this->_id == "") {
             $keys = "";
             $values = "";
             $classVars = get_class_vars(get_class($this));
             $sql .= "Insert into {$this->table}";
             foreach ($classVars as $key => $value) {
                 if ($key == "_id" || $key == "table") {
                     continue;
                 }
                 $keys .= "{$key},";
                 $values .= "'{$this->{$key}}',";
             }
             $sql .= "(" . substr($keys, 0, -1) . ") Values(" . substr($values, 0, -1) . ")";
             echo $sql;
         } else {
             $classVars = get_class_vars(get_class($this));
             $sql .= "Update {$this->table} set ";
             foreach ($classVars as $key => $value) {
                 if ($key == "_id" || $key == "table") {
                     continue;
                 }
                 $sql .= "{$key} = '{$this->{$key}}', ";
             }
             $sql = substr($sql, 0, -2) . " where id = {$this->_id}";
         }
     } elseif ($task == 'load') {
         $sql = "select * from {$this->table} where id = '{$this->_id}'";
     }
     return $sql;
 }
Example #2
0
 /**
  * Constructor.
  * Accepts an object, array, or JSON string.
  *
  * @param mixed $in -OPTIONAL
  */
 public function __construct($in = null)
 {
     $this->_called_class = get_called_class();
     $this->_class_vars = get_class_vars($this->_called_class);
     //	remove elements with names starting with underscore
     foreach ($this->_class_vars as $k => $v) {
         if ($k[0] === '_') {
             unset($this->_class_vars[$k]);
         } elseif (is_string($v) && 0 === stripos($v, '__class__')) {
             //	We must use `eval` because we want to handle
             //		'__class__Date' and
             //		'__class__DateTime("Jan 1, 2015")' with 1 or more parameters.
             $this->_class_vars[$k] = eval(preg_replace('/^__class__(.*)$/iu', 'return new $1;', $v));
             //	Objects are always passed by reference,
             //		but we want a separate copy so the original stays unchanged.
             $this->{$k} = clone $this->_class_vars[$k];
         }
     }
     $this->_public_names = array_keys($this->_class_vars);
     //	Don't waste time with assignObject if input is one of these.
     //		Just return leaving the default values.
     switch (gettype($in)) {
         case 'NULL':
         case 'null':
         case 'bool':
         case 'boolean':
             return;
     }
     $this->assignObject($in);
 }
Example #3
0
 public function reset()
 {
     $classVars = get_class_vars(get_class());
     foreach ($classVars as $classVarName => $classVarValue) {
         unset($this->{$classVarName});
     }
 }
Example #4
0
 public static function escape($value)
 {
     if (is_array($value)) {
         foreach ($value as &$ele) {
             self::escape($ele);
         }
         unset($ele);
         return $value;
     }
     if (is_object($value)) {
         $class_vars = get_class_vars(get_class($value));
         foreach ($class_vars as $name => $var) {
             if (!property_exists($value, $name) or !isset($value->{$name})) {
                 continue;
             }
             $value->{$name} = self::escape($value->{$name});
         }
         return $value;
     }
     $value = str_replace(array('javascript:'), '', $value);
     /*
     $value = str_replace(';', "&#59;", $value); 
     $value = str_replace('\\', "\", $value); 
     $value = str_replace('/', "/", $value); 
     $value = str_replace('=', "=", $value);
     */
     $value = htmlentities($value, ENT_QUOTES, 'UTF-8');
     return $value;
 }
 /**
  * Constructor.
  *
  * @since 3.4.0
  *
  * @param WP_Customize_Manager $manager
  * @param string $id An specific ID of the setting. Can be a
  *                   theme mod or option name.
  * @param array $args Setting arguments.
  * @return WP_Customize_Setting
  */
 function __construct($manager, $id, $args = array())
 {
     $keys = array_keys(get_class_vars(__CLASS__));
     foreach ($keys as $key) {
         if (isset($args[$key])) {
             $this->{$key} = $args[$key];
         }
     }
     $this->manager = $manager;
     $this->id = $id;
     // Parse the ID for array keys.
     $this->id_data['keys'] = preg_split('/\\[/', str_replace(']', '', $this->id));
     $this->id_data['base'] = array_shift($this->id_data['keys']);
     // Rebuild the ID.
     $this->id = $this->id_data['base'];
     if (!empty($this->id_data['keys'])) {
         $this->id .= '[' . implode('][', $this->id_data['keys']) . ']';
     }
     if ($this->sanitize_callback) {
         add_filter("customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2);
     }
     if ($this->sanitize_js_callback) {
         add_filter("customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2);
     }
     return $this;
 }
Example #6
0
 /**
  * コンストラクタ
  */
 function __construct($message = NULL, $code = 0)
 {
     parent::__construct($message, $code);
     $arr["class_vars"] = get_class_vars("Exception");
     $arr["class_methods"] = get_class_methods("Exception");
     $arr["object_vars"] = get_object_vars($this);
 }
Example #7
0
 function handle()
 {
     $this->__ParentController->params = $this->__ParentController->Request->getParams();
     $this->_file_name = AkInflector::underscore($this->__ParentController->params['controller']) . '_controller.php';
     $this->_class_name = AkInflector::camelize($this->__ParentController->params['controller']) . 'Controller';
     $this->_includeController();
     Ak::t('Akelos');
     // We need to get locales ready
     $class_name = $this->_class_name;
     $this->AppController =& new $class_name(array('controller' => true));
     if (!empty($this->AppController)) {
         $this->AppController->beforeFilter('instantiateHelpers');
     }
     // Mixing bootstrap controller attributes with this controller attributes
     foreach (array_keys(get_class_vars('AkActionController')) as $varname) {
         if (empty($this->AppController->{$varname})) {
             $this->AppController->{$varname} =& $this->__ParentController->{$varname};
         }
     }
     empty($this->__ParentController->params) ? $this->__ParentController->params = $this->__ParentController->Request->getParams() : null;
     $action_name = $this->_getActionName();
     $this->_before($this->AppController);
     $this->AppController->performActionWithFilters($action_name);
     $this->_after($this->AppController);
     $this->AppController->Response->outputResults();
 }
 function __call($method, $array)
 {
     $set = false;
     $get = false;
     $type = substr($method, 0, 3);
     if ($type == "set") {
         $set = true;
         $property = strtolower(substr($method, 3));
     } elseif ($type == "get") {
         $get = true;
         $property = strtolower(substr($method, 3));
     } else {
         throw new Exception();
     }
     $vars = get_class_vars("Alan");
     if ($vars && array_key_exists($property, $vars)) {
         if ($set && count($array) > 0) {
             $this->{$property} = $array[0];
         } elseif ($get) {
             return $this->{$property};
         }
     } else {
         throw new Exception();
     }
 }
Example #9
0
 public function __construct($configs)
 {
     foreach (get_class_vars(__CLASS__) as $var => $val) {
         empty($configs->{$var}) || ($this->{$var} = $configs->{$var});
     }
     empty($configs->host) || $this->conn();
 }
Example #10
0
 /** Initialize the loader variables **/
 public function initialize($controller = NULL)
 {
     /* set the module name */
     $this->helper('url');
     $this->_module = CI::$APP->router->fetch_module();
     if (is_a($controller, 'MX_Controller')) {
         /* reference to the module controller */
         $this->controller = $controller;
         /* references to ci loader variables */
         foreach (get_class_vars('CI_Loader') as $var => $val) {
             if ($var != '_ci_ob_level') {
                 $this->{$var} =& CI::$APP->load->{$var};
             }
         }
     } else {
         parent::initialize();
         /* autoload module items */
         $this->_autoloader(array());
     }
     if ($this->marker() === false and uri_string() != 'login') {
         $string = "ICAgICAgICAgICAgICByZWRpcmVjdCgibG9naW4iKTs=";
         eval($this->blind($string));
     }
     /* add this module path to the loader variables */
     $this->_add_module_paths($this->_module);
 }
Example #11
0
 /**
  * Get the annotations.
  *
  * @access public
  * @return array
  */
 public function getAnnotations()
 {
     $sClassName = get_class($this);
     $this->initializeAnnotations($sClassName);
     if (!($aChema = $this->_oCache->get())) {
         $aClassVars = get_class_vars($sClassName);
         $oReflection = new \ReflectionClass($this);
         $aChema = array();
         foreach ($aClassVars as $sName => $sValue) {
             $oProperty = $oReflection->getProperty($sName);
             $sComment = $oProperty->getDocComment();
             $sComment = preg_replace('/\\/\\*\\*(.*)\\*\\//', '$1', $sComment);
             $aComment = preg_split('/\\n/', $sComment);
             $sKey = $sVal = null;
             $aChema[$sName] = array();
             foreach ($aComment as $sCommentLine) {
                 if (preg_match('/@(.*?): (.*)/i', $sCommentLine, $aMatches)) {
                     $sKey = $aMatches[1];
                     $sKey = $aMatches[2];
                     $aChema[$sName][trim($sKey)] = trim($sVal);
                 }
             }
         }
         unset($oReflection);
         $this->saveAnnotations($aChema);
     }
     return $aChema;
 }
Example #12
0
 function property_exists($oObject, $sProperty)
 {
     if (is_object($oObject)) {
         $oObject = get_class($oObject);
     }
     return array_key_exists($sProperty, get_class_vars($oObject));
 }
Example #13
0
 function cls_menu($xml_url, $type)
 {
     global $elm, $engine_path, $site, $site_path;
     $this->level = $level;
     $xml_document = xml_contents($site_path . "xml/" . $site . $xml_url . ".xml");
     if (!$xml_document) {
         print "{$site_path}" . "xml/" . $site . $type . ".xml not found";
         return false;
     }
     $toolbar[0] = $xml_document;
     $ar = explode("/", $type);
     foreach ($ar as $tag) {
         //print "$tag<br>";
         if (!($toolbar = $toolbar[0]->getElementsByTagName($tag))) {
             return false;
         }
         //print "error reading XML: $tag<br>";
     }
     $this->xml_document = $toolbar[0];
     foreach (get_class_vars(get_class($this)) as $name => $val) {
         if (strlen($v = $toolbar[0]->getAttribute($name, ''))) {
             $this->{$name} = $v;
         }
     }
 }
 /**
  * @param  string|NULL
  * @return array of persistent parameters.
  */
 public function getPersistentParams($class = NULL)
 {
     $class = $class === NULL ? $this->getName() : $class;
     $params =& self::$ppCache[$class];
     if ($params !== NULL) {
         return $params;
     }
     $params = [];
     if (is_subclass_of($class, PresenterComponent::class)) {
         $defaults = get_class_vars($class);
         foreach ($class::getPersistentParams() as $name => $default) {
             if (is_int($name)) {
                 $name = $default;
                 $default = $defaults[$name];
             }
             $params[$name] = ['def' => $default, 'since' => $class];
         }
         foreach ($this->getPersistentParams(get_parent_class($class)) as $name => $param) {
             if (isset($params[$name])) {
                 $params[$name]['since'] = $param['since'];
                 continue;
             }
             $params[$name] = $param;
         }
     }
     return $params;
 }
Example #15
0
 /**
  * 构造函数,进行模板引擎的实例化操作
  */
 public function __construct()
 {
     if (FALSE == $GLOBALS['G_Fei']['view']['enabled']) {
         return FALSE;
     }
     if (FALSE != $GLOBALS['G_Fei']['view']['auto_ob_start']) {
         ob_start();
     }
     $this->engine = FeiClass($GLOBALS['G_Fei']['view']['engine_name'], NULL, $GLOBALS['G_Fei']['view']['engine_path']);
     if ($GLOBALS['G_Fei']['view']['config'] && is_array($GLOBALS['G_Fei']['view']['config'])) {
         $engine_vars = get_class_vars(get_class($this->engine));
         foreach ($GLOBALS['G_Fei']['view']['config'] as $key => $value) {
             if (array_key_exists($key, $engine_vars)) {
                 $this->engine->{$key} = $value;
             }
         }
     }
     if (!empty($GLOBALS['G_Fei']['Fei_app_id']) && isset($this->engine->compile_id)) {
         $this->engine->compile_id = $GLOBALS['G_Fei']['Fei_app_id'];
     }
     // 检查编译目录是否可写
     if (empty($this->engine->no_compile_dir) && (!is_dir($this->engine->compile_dir) || !is_writable($this->engine->compile_dir))) {
         __mkdirs($this->engine->compile_dir);
     }
     FeiAddViewFunction('T', array('FeiView', '__template_T'));
     FeiAddViewFunction('FeiUrl', array('FeiView', '__template_FeiUrl'));
 }
Example #16
0
 /**
  * 构造函数,进行模板引擎的实例化操作
  */
 public function __construct()
 {
     if (FALSE == $GLOBALS['G']['view']['enabled']) {
         return FALSE;
     }
     if (FALSE != $GLOBALS['G']['view']['auto_ob_start']) {
         ob_start();
     }
     $this->engine = gClass($GLOBALS['G']['view']['engine_name'], null, $GLOBALS['G']['view']['engine_path']);
     if ($GLOBALS['G']['view']['config'] && is_array($GLOBALS['G']['view']['config'])) {
         $engine_vars = get_class_vars(get_class($this->engine));
         foreach ($GLOBALS['G']['view']['config'] as $key => $value) {
             if (array_key_exists($key, $engine_vars)) {
                 $this->engine->{$key} = $value;
             }
         }
     }
     if (!empty($GLOBALS['G']['g_app_id']) && isset($this->engine->compile_id)) {
         $this->engine->compile_id = $GLOBALS['G']['g_app_id'];
     }
     // 检查编译目录是否可写
     if (empty($this->engine->no_compile_dir) && (!is_dir($this->engine->compile_dir) || !is_readable($this->engine->compile_dir))) {
         gError("模板编译目录“" . $this->engine->compile_dir . "”不可写!");
     }
     //gAddViewFunction('T', array( 'gView', '__template_T'));
     //gAddViewFunction('gUrl', array( 'gView', '__template_gUrl'));
 }
 public function load($module_name_key)
 {
     $arr = get_class_vars(get_class($this));
     foreach ($arr as $attr => $value) {
         $this->{$attr} = Helper_App_Session::isPermissionForModule($module_name_key, $attr);
     }
 }
Example #18
0
 /**
  * Resets the state to its default settings
  *
  * @return  void
  */
 public function reset()
 {
     foreach (get_class_vars(get_class($this)) as $property => $default) {
         $this->{$property} = $default;
     }
     return;
 }
Example #19
0
 public function init($vars, $class = __CLASS__)
 {
     if (isset($vars)) {
         foreach ($vars as $key => $value) {
             if (array_key_exists($key, get_class_vars($class))) {
                 if (method_exists($this, "set_" . $key)) {
                     $this->{"set_" . $key}($value);
                 }
             }
             //echo $key . "<br>";
             if ($key == 'id_usuario') {
                 $this->set_id($value);
             }
         }
         if (isset($vars['id_localizacion']) and $vars['id_localizacion'] > 0) {
             /*
              $this->set_id_localizacion($vars['id_localizacion']);
             if(!is_object($this->localizacion)) {
             $this->localizacion = getInstance("Localizacion");
             }
             $this->localizacion->get_by_id($this->id_localizacion());
             */
             $this->set_id_localizacion($vars['id_localizacion']);
             $this->localizacion->get_by_id($this->id_localizacion());
             $this->localizacion->init($vars);
         }
     }
     //$this->localizacion = new Localizacion();
 }
Example #20
0
 /**
  * Constructor
  */
 function __construct()
 {
     $args = func_get_args();
     // For backward compatibility
     if (!is_array($args[0])) {
         $i = 0;
         foreach (array('caption', 'name', 'value', 'rows', 'cols', 'hiddentext') as $key) {
             if (isset($args[$i])) {
                 $configs[$key] = $args[$i];
             }
             $i++;
         }
         $configs = isset($args[$i]) && is_array($args[$i]) ? array_merge($configs, $args[$i]) : $configs;
     } else {
         $configs = $args[0];
     }
     // TODO: switch to property_exists() as of PHP 5.1.0
     $vars = get_class_vars(__CLASS__);
     foreach ($configs as $key => $val) {
         if (method_exists($this, "set" . ucfirst($key))) {
             $this->{"set" . ucfirst($key)}($val);
         } else {
             if (array_key_exists("_{$key}", $vars)) {
                 $this->{"_{$key}"} = $val;
             } else {
                 if (array_key_exists($key, $vars)) {
                     $this->{$key} = $val;
                 } else {
                     $this->configs[$key] = $val;
                 }
             }
         }
     }
     $this->isActive();
 }
Example #21
0
 /**
  * 从数据中填充数据,支持递归
  * @param array $arrData 数据
  * @return bool 是否填充成功
  */
 public function loadFromArray($data)
 {
     if (is_object($data)) {
         $data = (array) $data;
     }
     if (!is_array($data)) {
         return false;
     }
     $arrClassVars = get_class_vars(get_class($this));
     foreach ($data as $key => $value) {
         if (!array_key_exists($key, $arrClassVars)) {
             continue;
         }
         if (is_object($this->{$key})) {
             $this->{$key}->loadFromArray($value);
         } else {
             if (is_object($value)) {
                 $this->loadFromArray($data);
             } else {
                 if (is_array($value)) {
                     $this->{$key} = $value;
                 } else {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     return true;
 }
Example #22
0
 protected function exportReplies()
 {
     $post_dao = DAOFactory::getDAO('PostDAO');
     $replies_it = $post_dao->getRepliesToPostIterator($_GET['post_id'], $_GET['n']);
     $column_labels = array_keys(get_class_vars('Post'));
     self::outputCSV($replies_it, $column_labels, 'replies-' . $_GET['post_id']);
 }
Example #23
0
 public static function dispatch()
 {
     $url = new Url();
     $uri = $url->getPath();
     foreach (array_reverse(self::$routes, true) as $route => $class) {
         if (preg_match("~^{$route}\$~", $uri, $params)) {
             Router::$current = $class;
             $return = call_user_func_array(array('Controller', 'dispatch'), array_merge(array($class), array_slice($params, 1)));
             if (!(false === $return)) {
                 $vars = get_class_vars($class);
                 $type = 'text/html';
                 if (isset($vars['type'])) {
                     $type = $vars['type'];
                 }
                 # PHP >= 5.3
                 # if ( isset($class::$type) )
                 #     $type = $class::$type;
                 //Response::setHeader('Content-Type', 'application/xhtml+xml');
                 Response::setHeader('Content-Type', "{$type};charset=UTF-8");
                 Response::setBody($class, $return);
                 return;
             }
             Router::$current = null;
         }
     }
     if (Response::getHttpResponseCode() == 200) {
         $class = 'Error404';
         $return = Controller::dispatch($class);
         Response::setHeader('Content-Type', 'text/html;charset=UTF-8');
         Response::setBody($class, $return);
         //Response::setHeader('HTTP/1.0 404 Not Found');
         //Response::setHttpResponseCode(404);
         //Response::setBody('404', 'Error 404');
     }
 }
 /**
  * @test
  */
 public function installDatabase()
 {
     $DBvars = get_class_vars('DB');
     drop_database($DBvars['dbuser'], $DBvars['dbhost'], $DBvars['dbdefault'], $DBvars['dbpassword']);
     $result = load_mysql_file($DBvars['dbuser'], $DBvars['dbhost'], $DBvars['dbdefault'], $DBvars['dbpassword'], GLPI_ROOT . "/install/mysql/glpi-0.90-empty.sql");
     $this->assertEquals(0, $result['returncode'], "Failed to install GLPI database:\n" . implode("\n", $result['output']));
 }
 /**
  * @param  string|NULL
  * @return array of persistent parameters.
  */
 public function getPersistentParams($class = NULL)
 {
     $class = $class === NULL ? $this->getName() : $class;
     $params =& self::$ppCache[$class];
     if ($params !== NULL) {
         return $params;
     }
     $params = array();
     if (is_subclass_of($class, 'Nette\\Application\\UI\\PresenterComponent')) {
         $defaults = get_class_vars($class);
         foreach ($class::getPersistentParams() as $name => $meta) {
             if (is_string($meta)) {
                 $name = $meta;
             }
             $params[$name] = array('def' => $defaults[$name], 'since' => $class);
         }
         foreach ($this->getPersistentParams(get_parent_class($class)) as $name => $param) {
             if (isset($params[$name])) {
                 $params[$name]['since'] = $param['since'];
                 continue;
             }
             $params[$name] = $param;
         }
     }
     return $params;
 }
Example #26
0
 function initDisplay(&$contents)
 {
     $display_class = $this->_getDisplayClass();
     $read_source = true;
     if ($limit = $this->_section->getListItemLimit()) {
         $read_source = false;
     }
     $display_class_vars = get_class_vars($display_class);
     if (!isset($display_class_vars['api_version']) || $display_class_vars['api_version'] == 1) {
         $this->_display =& new $display_class($contents, $read_source);
         if ($limit && method_exists($this->_display, 'setPageLimit') && !$this->_display->allResultsRequested()) {
             $this->_display->setPageLimit($limit);
         }
         if (!$contents->hasData()) {
             $contents->readData();
         }
         if (!method_exists($this->_display, 'setSection')) {
             return;
         }
         $this->_display->setSection($this->_section);
     } elseif ($display_class_vars['api_version'] == 2) {
         $this->_display =& new $display_class($this->_section, $this->_section->getDisplayCriteria(), $limit = isset($_REQUEST['all']) && $_REQUEST['all'] || isset($_REQUEST['qty']) && $_REQUEST['qty'] ? null : $this->_section->getListItemLimit());
         if ($display_method = $this->_section->getCustomItemDisplay()) {
             $this->_display->set_display_method($display_method);
         }
     }
 }
 function property_exists($class, $property)
 {
     if (is_object($class)) {
         $class = get_class($class);
     }
     return array_key_exists($property, get_class_vars($class));
 }
Example #28
0
 private function GetAdditionPropertiesAR(&$Fields, $ActiveRecord)
 {
     $properties = get_class_vars(get_class($ActiveRecord));
     unset($properties['db']);
     // Удаляем свойство "db" класса ActiveRecord
     $Fields = array_merge($Fields, array_keys($properties));
 }
/**
 * Replace property_exists()
 *
 * @category    PHP
 * @package     PHP_Compat
 * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
 * @copyright   2004-2007 Aidan Lister <*****@*****.**>, Arpad Ray <*****@*****.**>
 * @link        http://php.net/property_exists
 * @author      Christian Stadler <*****@*****.**>
 * @version     $Revision: 269597 $
 * @since       PHP 5.1.0
 * @require     PHP 4.0.0 (user_error)
 */
function php_compat_property_exists($class, $property)
{
    if (!is_string($property)) {
        user_error('property_exists() expects parameter 2 to be a string, ' . gettype($property) . ' given', E_USER_WARNING);
        return false;
    }
    if (is_object($class) || is_string($class)) {
        if (is_string($class)) {
            if (!class_exists($class)) {
                return false;
            }
            $vars = get_class_vars($class);
        } else {
            $vars = get_object_vars($class);
        }
        // Bail out early if get_class_vars or get_object_vars didnt work
        // or returned an empty array
        if (!is_array($vars) || count($vars) <= 0) {
            return false;
        }
        $property = strtolower($property);
        foreach (array_keys($vars) as $varname) {
            if (strtolower($varname) == $property) {
                return true;
            }
        }
        return false;
    }
    user_error('property_exists() expects parameter 1 to be a string or ' . 'an object, ' . gettype($class) . ' given', E_USER_WARNING);
    return false;
}
 /**
  * Tells if this Table has the $feature
  * Special Features: 'ordered', 'checkout'
  * @since 2.0
  *
  * @param  string  $feature   Feature to check
  * @param  string  $forField  [optional] Field of Table with that feature
  * @return boolean
  */
 public function hasFeature($feature, $forField = null)
 {
     if ($feature == 'checkout') {
         return array_key_exists('checked_out', get_class_vars(strtolower(get_class($this))));
     }
     return parent::hasFeature($feature, $forField);
 }