/** * @todo docblock */ public function __call($name, $args) { if ($this->_subject && method_exists($this->_subject, $name)) { // @todo probably not necessary, investigate later return call_user_func_array(array($this->_subject, $name), $args); } $upperName = strtoupper($name); $uname = ucfirst($name); $clsName = $this->_prefix . $uname; $methodName = $name; $formElement = false; if (substr($upperName, -9) == 'VALIDATOR') { $newObject = ZFormFactory::loadValidator($clsName, $this->_subject); $this->_subject->addValidator($newObject); } elseif (substr($upperName, -8) == 'BEHAVIOR') { $newObject = ZFormFactory::loadBehavior($clsName, $this->_subject); $this->_subject->addBehavior($newObject); } elseif (substr($upperName, 0, 9) == 'LISTENFOR') { $eventName = substr($name, 9); array_unshift($args, $eventName); // @todo probably not necessary, investigate later call_user_func_array(array($this->_subject, 'addEventListener'), $args); return $this; } else { try { $formElement = true; $newObject = ZFormFactory::loadElement($clsName, null, $this->_subject); if ($newObject) { $wrappedObject = new ZFormDynamicElement($newObject, null, $this->_prefix); $result = $wrappedObject; } } catch (Exception $ex) { // Eat class not found // @todo what's this? } } if ($newObject) { if (method_exists($newObject, $uname)) { // @todo probably not necessary, investigate later call_user_func_array(array($newObject, $uname), $args); } return $formElement ? $result : $this; } throw new ZFormElementException("Method not found:{$name} on instanceof " . get_class($this->_subject)); }
public static function init($initObject = null) { global $FRAMEWORK_URI; if (!self::$INITED) { // @todo fix this echo "<SCRIPT SRC='{$FRAMEWORK_URI}/ZForm/javascript/class.js'>" . "</SCRIPT>\n"; echo "<SCRIPT SRC='{$FRAMEWORK_URI}/ZForm/javascript/ZAjax.js'>" . "</SCRIPT>\n"; self::$INITED = true; } if ($initObject) { if (isset($initObject[self::$ELEMENT_DIR_NAMES])) { self::$ELEMENT_FACTORY_DIRS = $initObject[self::$ELEMENT_DIR_NAMES]; } if (isset($initObject[self::$VALIDATOR_DIR_NAMES])) { self::$VALIDATOR_FACTORY_DIRS = $initObject[self::$VALIDATOR_DIR_NAMES]; } if (isset($initObject[self::$BEHAVIOR_DIR_NAMES])) { self::$BEHAVIOR_FACTORY_DIRS = $initObject[self::$BEHAVIOR_DIR_NAMES]; } } }