/* Author : Romain Boisnard */
/* Liscenced under the LGPL GNU Lesser General Public Liscence, report the actual liscence for details.
/* LinkedException */
// Java-like exception with a cause
class LinkedException extends Exception {
private $cause;
function __construct($_message = null, $_code = 0, Exception $_cause = null) {
parent::__construct($_message, $_code);
$this->cause = $_cause;
}
public function getCause() {
return $this->cause;
}
public function getStackTrace() {
if ($this->cause !== null) {
$arr = array();
$trace = $this->getTrace();
array_push($arr, $trace[0]);
unset($trace);
if (get_class($this->cause) == "LinkedException") {
foreach ($this->cause->getStackTrace() as $key => $trace) {
array_push($arr, $trace);
}
}
else {
foreach ($this->cause->getTrace() as $key => $trace) {
array_push($arr, $trace);
}
}
return $arr;
}
else {
return $this->getTrace();
}
}
public function showStackTrace() {
$htmldoc = "
An exception was thrown :";
$htmldoc.= "Exception code : $this->code
";
$htmldoc.= "Exception message : $this->message
";
$htmldoc.= "";
$i = 0;
foreach ($this->getStackTrace() as $key => $trace) {
$htmldoc.= $this->showTrace($trace, $i);
$i++;
}
$htmldoc.= "#$i {main}
";
unset($i);
$htmldoc.= "
";return $htmldoc;
}
private function showTrace($_trace, $_i) {
$htmldoc = "#$_i ";
if (array_key_exists("file",$_trace)) {
$htmldoc.= $_trace["file"];
}
if (array_key_exists("line",$_trace)) {
$htmldoc.= "(".$_trace["line"]."): ";
}
if (array_key_exists("class",$_trace) && array_key_exists("type",$_trace)) {
$htmldoc.= $_trace["class"].$_trace["type"];
}
if (array_key_exists("function",$_trace)) {
$htmldoc.= $_trace["function"]."(";
if (array_key_exists("args",$_trace)) {
if (count($_trace["args"]) > 0) {
$args = $_trace["args"];
$type = gettype($args[0]);
$value = $args[0];
unset($args);
if ($type == "boolean") {
if ($value) {
$htmldoc.= "true";
}
else {
$htmldoc.= "false";
}
}
elseif ($type == "integer" || $type == "double") {
if (settype($value, "string")) {
if (strlen($value) <= 20) {
$htmldoc.= $value;
}
else {
$htmldoc.= substr($value,0,17)."...";
}
}
else {
if ($type == "integer" ) {
$htmldoc.= "? integer ?";
}
else {
$htmldoc.= "? double or float ?";
}
}
}
elseif ($type == "string") {
if (strlen($value) <= 18) {
$htmldoc.= "'$value'";
}
else {
$htmldoc.= "'".substr($value,0,15)."...'";
}
}
elseif ($type == "array") {
$htmldoc.= "Array";
}
elseif ($type == "object") {
$htmldoc.= "Object";
}
elseif ($type == "resource") {
$htmldoc.= "Resource";
}
elseif ($type == "NULL") {
$htmldoc.= "null";
}
elseif ($type == "unknown type") {
$htmldoc.= "? unknown type ?";
}
unset($type);
unset($value);
}
if (count($_trace["args"]) > 1) {
$htmldoc.= ",...";
}
}
$htmldoc.= ")
";
}
return $htmldoc;
}
}
2
顶
1
踩
分享到:
2010-05-03 23:47
浏览 2950
评论
3 楼
rtxbc
2011-03-26
bardo 写道
zend framework有没有生成静态页面的方法
freedomstyle 写道
不知道zend framework有没有生成静态页面的方法
那是没有的。静态页面规则较为复杂。这方面倒现在没有统一的方案。
另一方面,zend不会推出,因为,它不会排斥官方的smarty,这个是能生成页面缓存的。
在controller类里面使用$html = $this->view->render('xml/codec.xml') ;可以把渲染后的结果放入到$html里,然后你可以用file_put_content()或者其他文件操作方式,生成你所需要的文件.
2 楼
bardo
2010-05-26
zend framework有没有生成静态页面的方法
freedomstyle 写道
不知道zend framework有没有生成静态页面的方法
那是没有的。静态页面规则较为复杂。这方面倒现在没有统一的方案。
另一方面,zend不会推出,因为,它不会排斥官方的smarty,这个是能生成页面缓存的。
1 楼
freedomstyle
2010-05-24
不知道zend framework有没有生成静态页面的方法