77 include_once (
'Class.Log.php');
78 include_once (
'Class.Action.php');
79 include_once (
'Class.Application.php');
108 $this->LOG =
new Log(
"",
"Layout");
109 if (($template ==
"[OUT]") && ($caneva !=
"")) $this->
template = sprintf(_(
"Template [%s] not found") , $caneva);
110 else $this->
template = $template;
112 $this->generation =
"";
116 if ((!file_exists(
$file)) && (
$file[0] !=
'/')) {
117 $file = GetParam(
"CORE_PUBDIR") .
"/$file";
120 if (file_exists(
$file)) {
122 $this->
template = file_get_contents(
$file);
133 if (isset($this->zone[$key]))
return $this->zone[$key];
146 $this->corresp[
"$p_nom_block"][
"[$p_nom_modele]"] = ($p_nom == NULL ? $p_nom_modele :
"$p_nom");
151 $this->data[
"$p_nom_block"] = $data;
153 if (is_array($data)) {
156 if (isset($elem) && is_array($elem)) {
158 while (list($k, $v) = each($elem)) {
159 if (!isset($this->corresp[
"$p_nom_block"][
"[$k]"])) {
169 if (isset($this->data[
"$p_nom_block"]))
return $this->data[
"$p_nom_block"];
174 if ($this->strip ==
'Y') {
176 $block = str_replace(
"\\\"",
"\"", $block);
180 if (isset($this->data) && isset($this->data[
"$name"]) && is_array($this->data[
"$name"])) {
181 foreach ($this->data[
"$name"] as $k => $v) {
183 if (!is_array($this->corresp[
"$name"]))
return sprintf(_(
"SetBlock:error [%s]") ,
$name);
184 foreach ($this->corresp[
"$name"] as $k2 => $v2) {
185 if ((!is_object($v[$v2])) && (!is_array($v[$v2]))) $loc = str_replace($k2, $v[$v2], $loc);
198 $out = preg_replace(
"/(?m)\[BLOCK\s*([^\]]*)\](.*?)\[ENDBLOCK\s*\\1\]/se",
"\$this->SetBlock('\\1','\\2')",
$out);
204 if (array_key_exists(
$name, $this->rif) || isset($this->rkey[
$name])) {
205 $n = (array_key_exists($name, $this->rif)) ? $this->rif[$name] : $this->rkey[$name];
207 if ($this->strip ==
'Y') {
208 $block = str_replace(
"\\\"",
"\"", $block);
215 if ($this->strip ==
'Y') $block = str_replace(
"\\\"",
"\"", $block);
217 if ($not)
$out =
"[IFNOT $name]" . $block .
"[ENDIF $name]";
218 else $out =
"[IF $name]" . $block .
"[ENDIF $name]";
224 $out = preg_replace(
"/(?m)\[IF(NOT)?\s+([^\]]*)\](.*?)\[ENDIF\s*\\2\]/se",
"\$this->TestIf('\\2','\\3','\\1')",
$out);
229 $out = preg_replace(
"/\[ZONE\s+([^:]*):([^\]]*)\]/e",
"\$this->execute('\\1','\\2')",
$out);
234 if (isset($this->rkey)) {
235 $out = str_replace($this->pkey, $this->rkey,
$out);
244 if ($enc ==
"utf-8") {
245 $this->encoding = $enc;
253 $limit =
getParam(
'CORE_LAYOUT_EXECUTE_RECURSION_LIMIT', 0);
254 if (is_numeric($limit) && $limit > 0) {
256 if ($loop[
'count'] >= $limit) {
261 if ($this->action ==
"")
return (
"Layout not used in a core environment");
263 $actionargn = str_replace(
":",
"--", $actionargn);
264 $acturl = parse_url($actionargn);
268 $OLD_ZONE_ARGS = $ZONE_ARGS;
269 if (isset($acturl[
"query"])) {
270 $acturl[
"query"] = str_replace(
"--",
":", $acturl[
"query"]);
271 $zargs = explode(
"&", $acturl[
"query"]);
272 while (list($k, $v) = each($zargs)) {
273 if (preg_match(
"/([^=]*)=(.*)/", $v, $regs)) {
275 $ZONE_ARGS[$regs[1]] = urldecode($regs[2]);
280 if (
$appname != $this->action->parent->name) {
284 $appl = & $this->action->parent;
287 if ((
$actionname != $this->action->name) || ($OLD_ZONE_ARGS != $ZONE_ARGS)) {
297 $res = $act->CompleteSet(
$appl);
300 $res = $act->execute();
302 $ZONE_ARGS = $OLD_ZONE_ARGS;
305 return (
"Fatal loop : $actionname is called in $actionname");
309 function set($tag, $val)
311 $this->pkey[$tag] =
"[$tag]";
312 $this->rkey[$tag] = $val;
317 if (isset($this->rkey))
return $this->rkey[$tag];
324 $out = preg_replace(
"/\[IMG:([^\|\]]+)\|([0-9]+)\]/e",
"\$this->action->GetImageUrl('\\1',true,'\\2')",
$out);
326 $out = preg_replace(
"/\[IMG:([^\]\|]+)\]/e",
"\$this->action->GetImageUrl('\\1')",
$out);
328 $out = preg_replace(
"/\[IMGF:([^\]]*)\]/e",
"\$this->action->GetFilteredImageUrl('\\1')",
$out);
330 $out = preg_replace(
"/\[SCRIPT:([^\]]*)\]/e",
"\$this->action->GetScriptUrl('\\1')",
$out);
336 $out = preg_replace(
"/\[TEXT:([^\]]*)\]/e",
"\$this->Text('\\1')",
$out);
340 if (
$s ==
"")
return $s;
347 $list[] = $this->action->GetParam(
"CORE_JSURL") .
"/logmsg.js?wv=" . $this->action->GetParam(
"WVERSION");
348 $list = array_merge(
$list, $this->action->parent->GetJsRef());
351 while (list($k, $v) = each(
$list)) {
352 $js.=
"<script type=\"text/javascript\" language=\"JavaScript\" src=\"$v\"></script>\n";
361 $list = $this->action->parent->GetJsCode();
362 foreach (
$list as $k => $v) {
368 $list = $this->action->parent->GetLogMsg();
370 $out.=
"var logmsg=new Array();\n";
371 while (list($k, $v) = each(
$list)) {
372 if (($v[0] ==
'{'))
$out.=
"logmsg[$k]=$v;\n";
373 else $out.=
"logmsg[$k]=" . json_encode($v) .
";\n";
376 $out.=
"if ('displayLogMsg' in window) displayLogMsg(logmsg);\n";
377 $this->action->parent->ClearLogMsg();
379 $list = $this->action->parent->GetWarningMsg();
380 if (count(
$list) > 0)
$out.=
"displayWarningMsg('" . implode(
"\\n---------\\n",
$list) .
"');\n";
381 $this->action->parent->ClearWarningMsg();
385 $this->action->getActionDone($actcode, $actarg);
386 if (count($actcode) > 0) {
387 $out.=
"var actcode=new Array();\n";
388 $out.=
"var actarg=new Array();\n";
389 foreach ($actcode as $k => $v) {
390 $out.=
"actcode[$k]='$v';\n";
391 $out.=
"actarg[$k]='" . $actarg[$k] .
"';\n";
393 $out.=
"sendActionNotification(actcode,actarg);\n";
394 $this->action->clearActionDone();
402 $out = preg_replace(
"/\[JS:REF\]/e",
"\$this->GenJsRef()",
$out);
404 $out = preg_replace(
"/\[JS:CODE\]/e",
"\$this->GenJsCode(true)",
$out);
406 $out = preg_replace(
"/\[JS:CODENLOG\]/e",
"\$this->GenJsCode(false)",
$out);
412 $list = $this->action->parent->GetCssRef();
414 foreach (
$list as $k => $v) {
415 $js.=
"<link rel=\"stylesheet\" type=\"text/css\" href=\"$v\">\n";
422 $list = $this->action->parent->GetCssCode();
425 while (list($k, $v) = each(
$list)) {
432 $out = preg_replace(
"/\[CSS:REF\]/e",
"\$this->GenCssRef()",
$out);
434 $out = preg_replace(
"/\[CSS:CODE\]/e",
"\$this->GenCssCode()",
$out);
438 if ($this->noparse)
return $this->template;
440 if (is_object($this->action)) {
441 $list = $this->action->parent->GetAllParam();
442 while (list($k, $v) = each(
$list)) {
446 $out = $this->template;
449 $this->rif = & $this->rkey;
474 $bt = debug_backtrace(
false);
475 $btCount = count($bt);
476 for ($i = $btCount - 2; $i >= 0; $i--) {
478 if (
$class == $bt[$i][
'class'] && $function == $bt[$i][
'function']) {
479 $delta = $curDepth - $prevDepth;
480 $prevDepth = $curDepth;
499 include_once (
'WHAT/Lib.Prefix.php');
502 $http_reason =
"Recursion Count Error";
503 header(sprintf(
"HTTP/1.1 %s %s", $http_code, $http_reason));
505 print
"<html><head>\n";
506 print
"<title>" . htmlspecialchars($http_reason) .
"</title>\n";
507 print
"</head></body>\n";
509 print
"<h1>" . sprintf(
"%s %s", htmlspecialchars($http_code) , htmlspecialchars($http_reason)) .
"</h1>\n";
511 $message = sprintf(
"Infinite recursive loop in %s::%s() (call count = '%s')",
$class, $function, $count);
512 print
"<h2>" . htmlspecialchars($message) .
"</h2>\n";
513 error_log(sprintf(
"%s::%s Error: %s",
$class, $function, $message));
515 print
"</body></html>\n";