public function addTemplateRecordMeta($html, $collection, $index, $is_subroot) { // do nothing if html is empty if (!trim($html)) { return $html; } $entity_atts = $this->getTemplateRecordAtts($collection, $index); if ($is_subroot) { $html = preg_replace_callback("~^(\\s*?)(<[^>]+>)~", function ($matches) use($entity_atts) { $tag = Template\HtmlToken::createStandalone($matches[2]); $tag->addMeta($entity_atts); return $matches[1] . $tag->serialize(); }, $html); return $html; } $proc = new Template\Html($html); $html = $proc->addMeta($entity_atts); return $html; }
protected function addInfoblockMeta($html_result) { $controller_meta = $this->getResultMeta(); if (!fx::isAdmin() && (!isset($controller_meta['ajax_access']) || !$controller_meta['ajax_access'])) { return $html_result; } $ib_info = array('id' => $this['id']); if (($vis = $this->getVisual()) && $vis['id']) { $ib_info['visual_id'] = $vis['id']; } $ib_info['controller'] = $this->getPropInherited('controller') . ':' . $this->getPropInherited('action'); $ib_info['name'] = $this['name']; $meta = array('data-fx_infoblock' => $ib_info, 'class' => 'fx_infoblock fx_infoblock_' . $this['id']); foreach ($this->infoblock_meta as $meta_key => $meta_val) { // register only non-empty props if ($meta_val && !is_array($meta_val) || count($meta_val) > 0) { $meta['data-fx_' . $meta_key] = $meta_val; } } if (isset($_POST['_ajax_base_url'])) { $meta['data-fx_ajax_base_url'] = $_POST['_ajax_base_url']; } if ($this->isFake()) { $meta['class'] .= ' fx_infoblock_fake'; if (!$this->getIbController()) { $controller_meta['hidden_placeholder'] = fx::alang('Fake infoblock data', 'system'); } } if (isset($controller_meta['hidden']) && $controller_meta['hidden']) { $meta['class'] .= ' fx_infoblock_hidden'; } if (count($controller_meta) > 0 && fx::isAdmin()) { $meta['data-fx_controller_meta'] = $controller_meta; } if ($this->isLayout()) { $meta['class'] .= ' fx_unselectable'; $html_result = preg_replace_callback('~<body[^>]*?>~is', function ($matches) use($meta) { $body_tag = Template\HtmlToken::createStandalone($matches[0]); $body_tag->addMeta($meta); return $body_tag->serialize(); }, $html_result); } elseif ($this->output_is_subroot && preg_match("~^(\\s*?)(<[^>]+?>)~", $html_result)) { $html_result = preg_replace_callback("~^(\\s*?)(<[^>]+?>)~", function ($matches) use($meta) { $tag = Template\HtmlToken::createStandalone($matches[2]); $tag->addMeta($meta); return $matches[1] . $tag->serialize(); }, $html_result); } else { $html_proc = new Template\Html($html_result); $html_result = $html_proc->addMeta($meta, mb_strlen($html_result) > 10000); } return $html_result; }