/** * Export var as string then highlight it. * * @param mixed $var variable to be exported * @param string $format data format, array|json * @param boolean $label if add label to field * @return string */ protected function _highlight($var, $format = "array", $label = false) { import("classes.VarExportor"); $exportor = new VarExportor($this->_mongo->selectDB("admin"), $var); $varString = $exportor->export($format, $label); $string = null; if ($format == "array") { $string = highlight_string("<?php " . $varString, true); $string = preg_replace("/" . preg_quote('<span style="color: #0000BB"><?php </span>', "/") . "/", '', $string, 1); } else { $string = json_format_html($varString); } if ($label) { $id = addslashes(isset($var["_id"]) ? rock_id_string($var["_id"]) : ""); $string = preg_replace_callback("/(['\"])rockfield\\.(.+)\\.rockfield(['\"])/U", create_function('$match', ' $fields = explode(".rockfield.", $match[2]); return "<span class=\\"field\\" field=\\"" . implode(".", $fields) . "\\">" . $match[1] . array_pop($fields) . $match[3] . "</span>";'), $string); $string = preg_replace_callback("/__rockmore\\.(.+)\\.rockmore__/U", create_function('$match', ' $field = str_replace("rockfield.", "", $match[1]); return "<a href=\\"#\\" onclick=\\"fieldOpMore(\'" . $field . "\',\'' . $id . '\');return false;\\" title=\\"More text\\">[...]</a>";'), $string); } return $string; }
/** * Export var as string then highlight it. * * @param mixed $var variable to be exported * @param string $format data format, array|json * @param boolean $label if add label to field * @return string */ protected function _highlight($var, $format = "array", $label = false) { import("classes.VarExportor"); $exportor = new VarExportor($this->_mongo->selectDB("admin"), $var); $varString = null; $highlight = true; $mixed = false; switch ($this->_server->docsRender()) { case "default": $varString = $exportor->export($format, $label); break; case "plain": $varString = $exportor->export($format, false); $label = false; $highlight = false; break; case "mixed": $varString = $exportor->export($format, false); if (strlen($varString) > $this->_server->docsRenderLimit()) { $highlight = false; } else { $highlight = true; } $label = false; $mixed = true; break; default: $varString = $exportor->export($format, $label); break; } $string = null; if ($highlight) { if ($format == "array") { $string = highlight_string("<?php " . $varString, true); $string = preg_replace("/" . preg_quote('<span style="color: #0000BB"><?php </span>', "/") . "/", '', $string, 1); } else { $string = json_format_html($varString); } } else { $string = "<div><xmp style='width:600px;overflow:auto'>" . $varString . "</xmp></div>"; } if ($label) { $id = addslashes(isset($var["_id"]) ? rock_id_string($var["_id"]) : ""); $string = preg_replace_callback("/(['\"])rockfield\\.(.+)\\.rockfield(['\"])/U", create_function('$match', ' $fields = explode(".rockfield.", $match[2]); return "<span class=\\"field\\" field=\\"" . implode(".", $fields) . "\\">" . $match[1] . array_pop($fields) . $match[3] . "</span>";'), $string); $string = preg_replace_callback("/__rockmore\\.(.+)\\.rockmore__/U", create_function('$match', ' $field = str_replace("rockfield.", "", $match[1]); return "<a href=\\"#\\" onclick=\\"fieldOpMore(\'" . $field . "\',\'' . $id . '\');return false;\\" title=\\"More text\\">[...]</a>";'), $string); } return $string; }