diff --git a/zin/core/item.class.php b/zin/core/item.class.php index 3112d7af40..4eec23e72d 100644 --- a/zin/core/item.class.php +++ b/zin/core/item.class.php @@ -11,7 +11,6 @@ namespace zin; -require_once dirname(__DIR__) . DS . 'utils' . DS . 'flat.func.php'; require_once 'wg.class.php'; require_once 'wg.func.php'; diff --git a/zin/core/wg.class.php b/zin/core/wg.class.php index 206b6b4b5f..9e4b65be48 100644 --- a/zin/core/wg.class.php +++ b/zin/core/wg.class.php @@ -202,27 +202,19 @@ class wg } } - public function prop($name) + public function prop($name, $defaultValue = NULL) { - $args = func_get_args(); - if(count($args) > 1) - { - $name = $args; - } - - if(is_string($name)) return $this->props->get($name); - if(is_array($name)) { $values = array(); - foreach($name as $propName) + foreach($name as $index => $propName) { - $values[] = $this->props->get($propName); + $values[] = $this->props->get($propName, is_array($defaultValue) ? (isset($defaultValue[$propName]) ? $defaultValue[$propName] : $defaultValue[$index]) : $defaultValue); } return $values; } - return NULL; + return $this->props->get($name, $defaultValue); } /** diff --git a/zin/wg/actionitem/v1.php b/zin/wg/actionitem/v1.php index 3f031b0ef4..7cb00a209b 100644 --- a/zin/wg/actionitem/v1.php +++ b/zin/wg/actionitem/v1.php @@ -14,7 +14,7 @@ class actionItem extends wg protected function buildHeadingItem() { - list($icon, $text, $trailingIcon) = $this->prop('icon', 'text', 'trailingIcon'); + list($icon, $text, $trailingIcon) = $this->prop(array('icon', 'text', 'trailingIcon')); return h::span ( @@ -37,7 +37,7 @@ class actionItem extends wg $methodName = "build{$type}Item"; if(method_exists($this, $methodName)) return $this->$methodName(); - list($tagName, $icon, $text, $trailingIcon) = $this->prop('tagName', 'icon', 'text', 'trailingIcon'); + list($tagName, $icon, $text, $trailingIcon) = $this->prop(array('tagName', 'icon', 'text', 'trailingIcon')); return h::create ( @@ -52,7 +52,7 @@ class actionItem extends wg protected function build() { - list($name, $type, $outerTag, $tagName, $url, $target, $active, $disabled, $outerProps) = $this->prop('name', 'type', 'outerTag', 'tagName', 'url', 'target', 'active', 'disabled', 'outerProps'); + list($name, $type, $outerTag, $tagName, $url, $target, $active, $disabled, $outerProps) = $this->prop(array('name', 'type', 'outerTag', 'tagName', 'url', 'target', 'active', 'disabled', 'outerProps')); return h::create ( diff --git a/zin/wg/nav/v1.php b/zin/wg/nav/v1.php index e802b713cf..f4fbfb2e64 100755 --- a/zin/wg/nav/v1.php +++ b/zin/wg/nav/v1.php @@ -27,7 +27,7 @@ class nav extends wg ( setClass('nav'), set($this->props->skip(array_keys(static::getDefinedProps()))), - is_array($items) ? array_map(array($this, 'onBuildItem'), $this->prop('items')) : NULL, + is_array($items) ? array_map(array($this, 'onBuildItem'), $items) : NULL, $this->children(), ); }