/** * WIDGET END * 收集html,收集静态资源 */ public static function end() { $ret = true; $context = self::$_context; $widget_mode = $context['mode']; $has_parent = $context['parent_id']; if ($widget_mode == self::MODE_NOSCRIPT) { if (self::$_pagelet_id) { echo '</div>'; } } else { if ($context['hit']) { //close buffer $html = ob_get_clean(); if (!$has_parent) { $widget = FISResource::widgetEnd(); // end if ($widget_mode == self::MODE_BIGRENDER) { $widget_style = $widget['style']; $widget_script = $widget['script']; //内联css和script放到注释里面, 不需要收集 unset($widget['style']); unset($widget['script']); $out = ''; if ($widget_style) { $out .= '<style type="text/css">' . implode('', $widget_style) . '</style>'; } $out .= $html; if ($widget_script) { $out .= '<script type="text/javascript">' . implode('', $widget_script) . '</script>'; } echo str_replace(array('\\', '-->'), array('\\\\', '--\\>'), $out); $html = ''; echo '--></code></div>'; //收集外链的js和css self::$inner_widget[self::$mode][] = $widget; } else { $context['html'] = $html; //删除不需要的信息 unset($context['mode']); unset($context['hit']); //not parent unset($context['parent_id']); self::$_pagelets[] = $context; self::$inner_widget[$widget_mode][] = $widget; } } else { // end if ($widget_mode == self::MODE_BIGRENDER) { echo $html; } else { $context['html'] = $html; //删除不需要的信息 unset($context['mode']); unset($context['hit']); self::$_pagelets[] = $context; } } } if ($widget_mode != self::MODE_BIGRENDER) { echo '</div>'; } } //切换context self::$_context = self::$_contextMap[$context['parent_id']]; unset(self::$_contextMap[$context['parent_id']]); if (!$has_parent) { self::$_context = null; } return $ret; }
/** * WIDGET END * 收集html,收集静态资源 */ public static function end() { $ret = true; if (self::$widget_mode !== self::MODE_NOSCRIPT) { $html = ob_get_clean(); $pagelet = self::$_context; //end if (isset($pagelet['parent_id'])) { $parent = self::$_contextMap[$pagelet['parent_id']]; if (!$parent['hit'] && $pagelet['hit']) { self::$inner_widget[self::$widget_mode][] = FISResource::widgetEnd(); } } else { if ($pagelet['hit']) { self::$inner_widget[self::$widget_mode][] = FISResource::widgetEnd(); } } if ($pagelet['hit'] && !$pagelet['async']) { unset($pagelet['hit']); unset($pagelet['async']); $pagelet['html'] = $html; self::$_pagelets[] =& $pagelet; unset($pagelet); } else { $ret = false; } $parent_id = self::$_context['parent_id']; if (isset($parent_id)) { self::$_context = self::$_contextMap[$parent_id]; unset(self::$_contextMap[$parent_id]); } else { self::$_context = null; } self::$widget_mode = self::$mode; //指定渲染的位置 if (!empty(self::$rend_div)) { echo '</div>'; } else { self::$rend_div = true; } } return $ret; }