Location: PHPKode > projects > Course-manager > courseman-0.1.1/objects.php
<?php
  $max_oid = 0;
  $objects = array();
  function &registered_object($unregistered) {
    global $max_oid,$objects;
    $unregistered['oid'] = $max_oid++;
    $objects[$unregistered['oid']] =& $unregistered;
    return $unregistered;
  }
  function &reregistered_object($registered) {
    global $objects;
    $objects[$registered['oid']] =& $registered;
    return $registered;
  }
  function copied_object($independent) {
    return registered_object($independent);
  }
  function method_call($object,$method,$arguments) {
    global $debug,$objects;
    if($debug["old-debug"]) {
?>
<pre>
method_call($object,<?=$method?>)
</pre>
<?php
    }
    $object =& $objects[$object['oid']];
    if(isset($object[$method])) {
      return $object[$method]($object,$arguments);
    } else {
?>
<span class='fehler'>method '<?=$method?>' not defined</span>
<?php
    }
  }
  function defines_method(&$object,$method) {
    global $debug;
    if($debug["old-debug"]) {
?>
<pre>
defines_method
</pre>
<?php
    }
    return isset($object[$method]);
  }
  function inherits_method(&$object,$method) {
    global $debug;
    if($debug["old-debug"]) {
?>
<pre>
inherits_method
</pre>
<?php
    }
    foreach ($object['inherited'] as $inherited) {
      if($inherited['has_method']($inherited,$method)) {
        return true;
      }
    }
    return false;
  }
  function has_method(&$object,$method) {
    global $debug;
    if($debug["old-debug"]) {
?>
<pre>
has_method
</pre>
<?php
    }
    return defines_method($object,$method)
		|| inherits_method($object,$method);
  }
  function inherited_method_call($object,$method,$arguments) {
    global $debug,$objects;
    if($debug["old-debug"]) {
?>
<pre>
inherited_method_call
</pre>
<?php
    }
    $object =& $objects[$object['oid']];
    foreach ($object['inherited'] as $inherited) {
      if($inherited['has_method']($inherited,$method)) {
        return $inherited[$method]($object,$arguments);
      }
    }
  }
?>
Return current item: Course-manager