diff --git a/core/Object.php b/core/Object.php index db91914c7..532888f19 100755 --- a/core/Object.php +++ b/core/Object.php @@ -554,7 +554,8 @@ abstract class Object { ); } } else { - throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'"); + // Please do not change the exception code number below. + throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175); } } diff --git a/core/model/VirtualPage.php b/core/model/VirtualPage.php index cd2561ea7..ebdd222cb 100755 --- a/core/model/VirtualPage.php +++ b/core/model/VirtualPage.php @@ -138,8 +138,39 @@ class VirtualPage extends Page { $return = $this->copyContentFrom()->getField($field); } } + return $return; } + + /** + * Pass unrecognized method calls on to the original data object + * + * @param string $method + * @param string $args + */ + function __call($method, $args) { + try { + return parent::__call($method, $args); + } catch (Exception $e) { + // Hack... detect exception type. We really should use exception subclasses. + // if the exception isn't a 'no method' error, rethrow it + if ($e->getCode() !== 2175) throw $e; + $original = $this->copyContentFrom(); + return call_user_func_array(array($original, $method), $args); + } + } + + /** + * Overwrite to also check for method on the original data object + * + * @param string $method + * @return bool + */ + function hasMethod($method) { + $haveIt = parent::hasMethod($method); + if (!$haveIt) $haveIt = $this->copyContentFrom()->hasMethod($method); + return $haveIt; + } } /** @@ -147,7 +178,7 @@ class VirtualPage extends Page { * @package cms */ class VirtualPage_Controller extends Page_Controller { - + static $allowed_actions = array( 'loadcontentall' => 'ADMIN', ); @@ -192,6 +223,40 @@ class VirtualPage_Controller extends Page_Controller { echo "