protected function outputStyle($context) { $event = $context->parent->getEvent('beforedisplay'); if ($event != false) { $styleLinks = $event->requires; $styleResources = BigPipeResource::pathToResource($styleLinks, 'css'); $styleResources = BigPipeResource::getDependResource($styleResources); } foreach ($styleResources as $resource) { echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$resource['src']}\" />"; } }
/** * 得到 pagelet 的配置,用于Quickling输出 * * @param PageletContext $pagelet * @param string $html * @param array $resourceMap * @param array $hooks */ private function getPageletConfig($pagelet, &$html, &$resourceMap, &$hooks) { $config = array(); $config["id"] = $pagelet->getParam("id"); $config["children"] = array(); foreach ($pagelet->children as $child) { $config["children"][] = $child->getParam("id"); } if ($pagelet->parent) { $config["parent"] = $pagelet->parent->getParam("id"); } if (!empty($pagelet->html)) { //生成容器ID $containerId = $this->sessionUniqId("__cnt_"); //生成注释的内容 //$html = "<code id=\"$containerId\" style=\"display:none\"><!-- "; //$html = $this->getCommentHTML($pagelet->html); $html = $pagelet->html; //$html .= " --></code>"; //设置html属性 $config["html"]["container"] = $containerId; $config["html"]["html"] = $html; } foreach (self::$knownEvents as $type) { $event = $pagelet->getEvent($type); if ($event !== false) { foreach ($event->hooks as $hook) { //$hookId = $this->sessionUniqId("__cb_"); //$hooks[$hookId] = $hook; $config["hooks"][$type][] = $hook; } //deps $requireResources = BigPipeResource::pathToResource($event->requires); $config["deps"][$type] = array_keys($requireResources); $resourceMap = array_merge($resourceMap, $event->requires, $event->requireAsyncs); } } return $config; }