public static function prepare_result($data) { if (is_string($data)) { // Remover informações sobre o URL e o path local // Isto permite validar melhor o servidor e o localhost $replace_data = array(core::get_baseurl(false) => 'http://.../core/', core::get_path_fixed(CORE_INDEX) => './core'); $data = str_replace(array_keys($replace_data), array_values($replace_data), $data); return array('string', $data); } else { if (is_bool($data)) { return array('boolean', $data); } else { if (is_int($data)) { return array('number', $data); } else { if (is_float($data)) { return array('float', $data); } else { if (is_array($data) || is_a($data, 'stdClass')) { $data_values = (array) $data; $object_type = is_array($data) ? 'array' : 'stdClass'; foreach ($data_values as &$item) { $item = self::prepare_result($item); } return array('object', $data_values, $object_type); } else { if (is_object($data)) { $data_values = array(); if (method_exists($data, '__toString') && !$data instanceof exception) { $data_values['__toString()'] = array('string', $data->__toString()); } $object_data = (array) $data; if ($data instanceof exception) { $object_data["*file"] = core::get_path_fixed($object_data["*file"]); unset($object_data['xdebug_message']); unset($object_data["Exceptionstring"]); unset($object_data["*line"]); unset($object_data["Exceptiontrace"]); unset($object_data["Exceptionprevious"]); // PHP 5.3 if (substr($object_data["*code"], 0, 2) === 'Cx') { $message_lang = lang('/core/errors/err' . substr($object_data["*code"], 2), array('en', 'pt-br')); $object_data["*message"] = $message_lang->get_value('error_message', $object_data["core_exception_error"]->get_message_args()); } unset($object_data["core_exception_error"]); } else { if ($data instanceof core_language) { unset($object_data["core_language_lang_dir"]); unset($object_data["core_language_lang_order"]); } else { if ($data instanceof core_error) { unset($object_data["core_error_globals"]); unset($object_data["core_error_backtrace"]); } else { if ($data instanceof mysqli) { static $mysqli_keys = array('affected_rows', 'connect_errno', 'connect_error', 'errno', 'error', 'field_count', 'info', 'insert_id', 'sqlstate', 'warning_count'); $object_data = array(); foreach ($mysqli_keys as $key) { $object_data[$key] = $data->{$key}; } } else { if ($data instanceof mysqli_result) { static $mysqli_result_keys = array('current_field', 'field_count', 'lengths', 'num_rows', 'type'); $object_data = array(); foreach ($mysqli_result_keys as $key) { $object_data[$key] = $data->{$key}; } } else { if ($data instanceof core_database) { unset($object_data["core_database_connection_string"], $object_data["core_database_connection_array"]); } else { if ($data instanceof core_model) { unset($object_data["core_model_keys"]); } else { if ($data instanceof core_model_row) { unset($object_data["core_model_row_model"]); unset($object_data["core_model_row_from"]); unset($object_data["core_model_row_conn"]); if (isset($object_data["core_model_row_loader_method"][0][0])) { $object_data["core_model_row_loader_method"][0][0] = null; } } else { if ($data instanceof core_model_results) { unset($object_data["core_model_results_model"]); unset($object_data["core_model_results_from"]); } } } } } } } } } foreach ($object_data as $key => $value) { $key = explode("", $key); $key = isset($key[2]) ? $key[2] : $key[0]; $data_values[$key] = $data === $value ? array('recursive', '$this') : self::prepare_result($value); } ksort($data_values); return array('object', $data_values, get_class($data)); } else { if (is_null($data)) { return array('null', $data); } else { if (is_resource($data)) { return array('resource', get_resource_type($data)); } } } } } } } } }
function baseurl($include_modular = true) { return core::get_baseurl($include_modular); }
public function test_get_baseurl() { $this->test(1, substr(core::get_baseurl(), -11), 'Path are clipped'); $this->test(2, substr(core::get_baseurl(false), -6), 'Path are clipped'); $this->test(3, substr(baseurl(), -6), 'Only for coverage'); }