/** * Populate object properties array data * * @param array $array data in array */ function populate($array, $dump = NULL) { if (is_null($dump)) { $dump = $this->dump; } if ($dump) { $missing = array(); $lang = vivvo_lang::get_instance(); } $status = true; if (is_array($array) && !empty($array)) { foreach ($array as $key => $value) { if (vivvo_property_exists(get_class($this), $key)) { if ($this->{'set_' . $key}($value) === false) { if ($dump) { $missing[] = $lang->get_value('LNG_DB_' . substr($this->_sql_table, strlen(VIVVO_DB_PREFIX)) . '_' . $key); } $status = false; } } else { $this->__set($key, $value); } } } if ($dump && !empty($missing)) { $this->set_error_code(12, implode(', ', $missing)); } return $status; }
/** * Enter description here... * * @return boolean */ function get_request_data() { if ($this->data_object instanceof vivvo_post_object) { $this->_data_in = array(); $this->id_key = $this->data_object->id_key; if ($this->_sql_table !== $this->data_object->_sql_table) { $this->_sql_table = $this->data_object->_sql_table; $this->_set_data_flags(); } foreach ($this->_data_flags as $k => $v) { $class = get_class($this->data_object); if ($k != '' && vivvo_property_exists(get_class($this->data_object), $k)) { if ($this->data_object->{$k} === null) { //$this->_data_in[$k] = null; } elseif (is_array($this->data_object->{$k})) { $this->_data_in[$k] = implode(",", $this->data_object->{$k}); } else { $this->_data_in[$k] = $this->data_object->{$k}; } } else { if (is_array($this->data_object->elem) && key_exists($k, $this->data_object->elem)) { if ($this->data_object->elem[$k] === null) { //$this->_data_in[$k] = null; } elseif (is_array($this->data_object->elem[$k])) { $this->_data_in[$k] = implode(",", $this->data_object->elem[$k]); } else { $this->_data_in[$k] = $this->data_object->elem[$k]; } } } } return true; } else { return false; } }
function &chain_value($chain, $variable = null, $instruction_param = false) { if (is_null($variable)) { if (preg_match('/^(\\w+)((\\[\\w+\\])+)$/', $chain[0], $var)) { $arr =& $this->_template->get_value($var[1]); //$variable = $arr[$var[1]] $arr_keys = preg_split("/\\[([^\\]]+)\\]/", $var[2], -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($arr_keys as $key) { if ($key !== '') { if (is_array($arr)) { if (array_key_exists($key, $arr)) { $arr =& $arr[$key]; } else { return ''; } } else { return ''; } } } $variable =& $arr; } else { $variable =& $this->_template->get_value($chain[0]); } array_shift($chain); if (!empty($chain)) { return $this->chain_value($chain, $variable, $instruction_param); } else { return $variable; } } else { if (is_object($variable)) { $property = $chain[0]; array_shift($chain); if (preg_match('/^(\\w+)((\\[\\w+\\])+)?$/', $property, $var)) { $property = $var[1]; } //method if (method_exists($variable, $property)) { if (!empty($instruction_param) && empty($chain)) { $result =& call_user_func_array(array($variable, $property), $instruction_param); } else { $result =& call_user_func(array($variable, $property)); } // property } else { if (vivvo_property_exists(get_class($variable), $property) or $variable instanceof StdClass) { $result = $variable->{$property}; //overload } else { $result = $variable->__get($property); } } if (isset($var[2])) { $arr_keys = preg_split("/\\[([^\\]]+)\\]/", $var[2], -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($arr_keys as $key) { if ($key !== '') { if (is_array($result)) { if (array_key_exists($key, $result)) { $result =& $result[$key]; } else { return ''; } } else { return ''; } } } } if (!empty($chain)) { return $this->chain_value($chain, $result, $instruction_param); } else { return $result; } } else { $value = ''; return $value; } } }