Source for file gloobject.php
Documentation is available at gloobject.php
* GloryLands, a Web-Based, Massive Multiplayer Online RPG/Strategy Game
* Copyright (C) 2008-09 John Haralampidis <jïhnys2[at]gmail.cïm>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For any help/suggestions or troubleshooting you can see the
* project community website at <http://www.glorylands.gr>
* @license GNU/GPLv3 GNU General Public License version 3
* @author John Haralampidis <jïhnys2[at]gmail.cïm>
* @copyright Copyright (C) 2007-2009, John Haralampidis
* This class provides the basic class that implements
* @example sample_proxy.php An example of how to extend a GLOOObject
* A reference to the root module object
* The Link synchronization number between PHP and Javscript object
* The Unit configuration, as obtained from the config.xml
* A flag that defines that objec variables are synced with the JS
// Remove the reference to the $module. We don't need it and
// it also causes trouble on serialization
// Re-load the $module reference
// Initialize my variables
// (Instead of using $v = GLMOdule::fetch(Class) we can directly instance this class, using $v = new Class()
// and let the GLModule::mine() function to do the detection of the appropriate module.
// Initialize the GLDOMElement, using this class name for the DOM class name.
// You can also provide an optional ID by the constructor
// If we have client script, make the PHP-JS binding by allocating
// a link ID and registering this class to the GLOOLink structure.
if (isset ($this->config['client'])) {
$client_class = $this->config['client'][0]['class'];
private function encode_structure($struct) {
foreach ($struct as $k => $v) {
$struct[$k] = $this->flatten_structure($v);
* An inheritable function to notify a variable update
* [INHERITED FROM GLDataset]
* @param string $name The variable name that was updated
* @param mixed $value The variable value
$this->_call('__set', $name, $this->encode_structure($value));
* An inheritable function to notify a variable removal
* [INHERITED FROM GLDataset]
* @param string $name The variable name that was removed
$this->_call('__unset', $name);
* An inheritable function to notify an object attachment
* [INHERITED FROM GLDataset]
* @param string $name The variable name that was updated
* @param object $object The object that was added
* An inheritable function to notify an object detachment
* [INHERITED FROM GLDataset]
* @param string $name The variable name that was updated
* @param object $object The object that was removed
* Prepare the variables that will be sent to the JS interface
public function _vars() {
* Bind the object into the rendering template
public function _bind($template) {
* Perform a call to the JS interface
public final function _call($call) {
if ($this->linkID === false) return;
|