Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pagelet_id lost bug #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler.widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function smarty_compiler_widget($arrParams, $smarty){
$strCode .= '}';
$strCode .= 'FISPagelet::load('.$strName.', $_smarty_tpl->smarty);';
$strCode .= '}';
$strCode .= 'FISPagelet::end();';
$strCode .= 'FISPagelet::end('.$strPageletId.');';
} else {
trigger_error('undefined widget name in file "' . $smarty->_current_file . '"', E_USER_ERROR);
}
Expand Down
3 changes: 2 additions & 1 deletion compiler.widget_block.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ function smarty_compiler_widget_block($arrParams, $smarty){
}

function smarty_compiler_widget_blockclose($arrParams, $smarty){
$pageletId = $arrParams['pagelet_id'];
$strCode = '';
$strCode .= '<?php ';
$strCode .= 'if(class_exists(\'FISPagelet\', false)){';
$strCode .= ' FISPagelet::end();';
$strCode .= ' FISPagelet::end('.$pageletId.');';
$strCode .= '}';
$strCode .= '?>';
return $strCode;
Expand Down
33 changes: 18 additions & 15 deletions lib/FISPagelet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static public function start($id, $mode = null, $group = null) {
$parent_id = $has_parent ? self::$_context['id'] : '';
$qk_flag = self::$mode == self::MODE_QUICKLING ? '_qk_' : '';
$id = empty($id) ? '__elm_' . $parent_id . '_' . $qk_flag . self::$_session_id ++ : $id;


$parent = self::$_context;

Expand All @@ -254,14 +254,14 @@ static public function start($id, $mode = null, $group = null) {
$hit = true;

$context = array(
'id' => $id, //widget id
'id' => $id, //widget id
'mode' => $widget_mode, //当前widget的mode
'hit' => $hit // 是否命中
'hit' => $hit // 是否命中
);

if ($has_parent) {
$context['parent_id'] = $parent['id'];
self::$_contextMap[$parent['id']] = $parent;
self::$_contextMap[$parent['id']] = $parent;
}

if ($widget_mode == self::MODE_NOSCRIPT) {
Expand All @@ -270,7 +270,7 @@ static public function start($id, $mode = null, $group = null) {
echo '<div id="' . $id . '">';
}
} else {

if ($widget_mode == self::MODE_BIGRENDER) {
//widget 为bigrender时,将内容渲染到html注释里面
if (!$has_parent) {
Expand Down Expand Up @@ -313,7 +313,7 @@ static public function start($id, $mode = null, $group = null) {

$context['hit'] = $hit;

if ($hit) {
if ($hit) {
if (!$has_parent) {
//获取widget内部的静态资源
FISResource::widgetStart();
Expand All @@ -337,9 +337,12 @@ static public function end() {
$ret = true;

$context = self::$_context;
$widget_mode = $context['mode'];
$widget_mode = $context['mode'];
$has_parent = $context['parent_id'];


if ($id) {
self::$_pagelet_id = $id;
}

if ($widget_mode == self::MODE_NOSCRIPT) {
if (self::$_pagelet_id) {
Expand Down Expand Up @@ -379,7 +382,7 @@ static public function end() {
echo '--></code></div>';

//收集外链的js和css
self::$inner_widget[self::$mode][] = $widget;
self::$inner_widget[self::$mode][] = $widget;

} else {
$context['html'] = $html;
Expand All @@ -388,19 +391,19 @@ static public function end() {
unset($context['hit']);
//not parent
unset($context['parent_id']);
self::$_pagelets[] = $context;
self::$inner_widget[$widget_mode][] = $widget;
self::$_pagelets[] = $context;
self::$inner_widget[$widget_mode][] = $widget;
}
} else {
// end
if ($widget_mode == self::MODE_BIGRENDER) {
echo $html;
echo $html;
} else {
$context['html'] = $html;
//删除不需要的信息
unset($context['mode']);
unset($context['hit']);
self::$_pagelets[] = $context;
self::$_pagelets[] = $context;
}
}
}
Expand Down Expand Up @@ -577,14 +580,14 @@ static public function display($html) {
case self::MODE_NOSCRIPT:
//渲染widget以外静态文件
$all_static = FISResource::getArrStaticCollection();
$all_static = self::merge_resource($all_static, $res);
$all_static = self::merge_resource($all_static, $res);

$html = self::renderStatic(
$html,
$all_static,
true
);

break;
case self::MODE_QUICKLING:
header('Content-Type: text/json; charset=utf-8');
Expand Down