public function __get($name) { $v = parent::__get($name); return isset($v) ? $v : $this->_property($name); }
<?php require_once "../raxan/pdi/autostart.php"; class MyPage extends RaxanWebPage { function _init() { $this->source('views/custom-methods.html'); // call custom zerba function $this->table1->zebra('softyellow', 'white'); } } // add custom methods to RaxanElement RaxanElement::addMethod('zebra', 'zebra_tables_extension'); // Zebra Table Custom Method function zebra_tables_extension($elm, $args) { $t1 = isset($args[0]) ? $args[0] : ''; $t2 = isset($args[1]) ? $args[1] : ''; if ($t2) { $elm->find('tr:odd')->addClass($t2)->end(); } return $elm->find('tr:even')->addClass($t1)->end(); }
/** * Adds a custom method to the RaxanElement Class. Use addMethod($object) to add multiple methods from an object */ public static function addMethod($name, $callback = null) { if (!self::$callMethods) { self::$callMethods = array(); } if ($callback === null && is_object($name)) { // add methods from an object $obj = $name; $names = get_class_methods($obj); foreach ($names as $name) { if ($name[0] != '_') { self::$callMethods[$name] = array($obj, $name); } } // don't add names that begins with '_' } else { if (!is_callable($callback)) { Raxan::throwCallbackException($callback); } self::$callMethods[$name] = $callback; } }