Your IP : 216.73.217.68


Current Path : /home/wuectly/www/03cbe/
Upload File :
Current File : /home/wuectly/www/03cbe/extendable.tar

extendable.php000060400000003605152456111250007372 0ustar00<?php
 /** 
  *------------------------------------------------------------------------
  * T3 Framework for Joomla!
  * ------------------------------------------------------------------------
  * Copyright (C) 2004-2013 JoomlArt.com, Ltd. All Rights Reserved.
  * License - GNU/GPL, http://www.gnu.org/licenses/gpl.html
  * Authors:  JoomlArt, JoomlaBamboo 
  * If you want to be come co-authors of this project, please follow our guidelines at http://t3-framework.org/contribute
  * ------------------------------------------------------------------------
  */

// No direct access
defined('_JEXEC') or die();

define('_PHP_', intval(phpversion()));

if (! function_exists('property_exists')) {
    /**
     * Check property of object exists or not
     *
     * @param object $oObject    Checked object
     * @param string $sProperty  Property name
     *
     * @return bool  TRUE if exists, otherwise FALSE
     */
    function property_exists($oObject, $sProperty)
    {
        if (is_object($oObject)) {
            $oObject = get_class($oObject);
        }

        return array_key_exists($sProperty, get_class_vars($oObject));
    }
}

/**
 * Check method of object is callable or not
 *
 * @param object $oObject  Checked object
 * @param string $sMethod  Method name
 *
 * @return bool  TRUE if exists, otherwise FALSE
 */
function method_callable($oObject, $sMethod)
{
    // must be object or string
    if (! is_object($oObject) && ! is_string($oObject)) {
        return false;
    }

    return array_key_exists($sMethod, array_flip(get_class_methods($oObject)));
}

/**
 * Make object extendable
 *
 * @param string $classname  Class name
 *
 * @return void
 */
function make_object_extendable($classname)
{
    if (_PHP_ < 5) {
        overload($classname);
    }
}

if (_PHP_ >= 5) {
    include_once dirname(__FILE__) . '/object.5.php';
} else {
    include_once dirname(__FILE__) . '/object.4.php';
}object.5.php000060400000004064152456111250006670 0ustar00<?php
 /** 
  *------------------------------------------------------------------------
  * T3 Framework for Joomla!
  * ------------------------------------------------------------------------
  * Copyright (C) 2004-2013 JoomlArt.com, Ltd. All Rights Reserved.
  * License - GNU/GPL, http://www.gnu.org/licenses/gpl.html
  * Authors:  JoomlArt, JoomlaBamboo 
  * If you want to be come co-authors of this project, please follow our guidelines at http://t3-framework.org/contribute
  * ------------------------------------------------------------------------
  */

// No direct access
defined('_JEXEC') or die();

class ObjectExtendable extends JObject
{
    var $_extendableObjects = array();

    function _extend($oObject)
    {
        if (is_object($oObject)) {
            $this->_extendableObjects[] = $oObject;
        } else if (is_array($oObject)) {
            $this->_extendableObjects = array_merge($this->_extendableObjects, $oObject);
        }
    }

    function __get($sName)
    {
        foreach ($this->_extendableObjects as $oObject) {
            if (property_exists($oObject, $sName)) {
                $sValue = $oObject->$sName;
                return $sValue;
            }
        }

        return null;
    }

    function __set($sName, $sValue)
    {
        foreach ($this->_extendableObjects as $oObject) {
            if (property_exists($oObject, $sName)) {
                return $oObject->$sName = $sValue;
            }
        }
    }

    function __call($sName, $aArgs = array())
    {
        // try call itself method
        if (method_exists($this, $sName)) {
            $return = call_user_func_array(array($this, $sName), $aArgs);
            return $return;
        }

        // try to call method extended from objects
        foreach ($this->_extendableObjects as $oObject) {
            //if (method_callable($oObject, $sName)) {
            if (method_exists($oObject, $sName)) {
                $return = call_user_func_array(array($oObject, $sName), $aArgs);
                return $return;
            }
        }

        return NULL;
    }
}object.4.php000060400000004152152456111250006665 0ustar00<?php
 /** 
  *------------------------------------------------------------------------
  * T3 Framework for Joomla!
  * ------------------------------------------------------------------------
  * Copyright (C) 2004-2013 JoomlArt.com, Ltd. All Rights Reserved.
  * License - GNU/GPL, http://www.gnu.org/licenses/gpl.html
  * Authors:  JoomlArt, JoomlaBamboo 
  * If you want to be come co-authors of this project, please follow our guidelines at http://t3-framework.org/contribute
  * ------------------------------------------------------------------------
  */

// No direct access
defined('_JEXEC') or die();

class ObjectExtendable extends JObject
{
    var $_extendableObjects = array();

    function _extend($oObject)
    {
        $this->_extendableObjects = $oObject;
    }

    function __get($sName, &$sValue)
    {
        for ($i = 0; $i < count($this->_extendableObjects); $i++) {
            if (property_exists($this->_extendableObjects[$i], $sName)) {
                $sValue = $this->_extendableObjects[$i]->$sName;
                return true;
            }
        }

        return false;
    }

    function __set($sName, &$sValue)
    {
        for ($i = 0; $i < count($this->_extendableObjects); $i++) {
            if (property_exists($this->_extendableObjects[$i], $sName)) {
                $this->_extendableObjects[$i]->$sName = $sValue;
                return true;
            }
        }
        return false;
    }

    function __call($sName, $aArgs = array(), &$return)
    {
        // try call itself method
        if (method_exists($this, $sName)) {
            $return = call_user_func_array(array($this, $sName), $aArgs);
            return true;
        }

        // try to call method extended from objects
        for ($i = 0; $i < count($this->_extendableObjects); $i++) {
            //if (method_callable($this->_extendableObjects[$i], $sName)) {
            if (method_exists($this->_extendableObjects[$i], $sName)) {
                $return = call_user_func_array(array(&$this->_extendableObjects[$i], $sName), $aArgs);
                return true;
            }
        }

        return false;
    }
}