예제 #1
0
파일: Html.php 프로젝트: floxim/floxim
 public function addMetaWrapper($meta)
 {
     $tag = self::getWrapperTag($this->_string);
     $wrapper = HtmlToken::createStandalone('<' . $tag . ' class="fx_wrapper">');
     $wrapper->addMeta($meta);
     return $wrapper->serialize() . $this->_string . "</" . $tag . ">";
 }
예제 #2
0
파일: Entity.php 프로젝트: floxim/floxim
 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;
 }
예제 #3
0
파일: Template.php 프로젝트: floxim/floxim
 protected static function replaceAreasInText($html)
 {
     $html = preg_replace_callback("~###fxa(\\d+)\\|?(.*?)###~", function ($matches) {
         $mode = $matches[2];
         $replacement = Template::$area_replacements[$matches[1]];
         if ($mode == 'data') {
             if (!$replacement[1]) {
                 return '<span class="fx_area_marker"></span>';
             }
             return $replacement[1];
         }
         $tag_name = 'div';
         $tag = HtmlToken::createStandalone('<' . $tag_name . '>');
         $tag->addMeta(array('class' => 'fx_area fx_wrapper', 'data-fx_area' => $replacement[0]));
         $tag = $tag->serialize();
         Template::$area_replacements[$matches[1]] = null;
         return $tag . $replacement[1] . '</' . $tag_name . '>';
     }, $html);
     return $html;
 }
예제 #4
0
 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;
 }
예제 #5
0
 protected static function replaceFieldsInText($html)
 {
     $html = preg_replace_callback("~###fxf(\\d+)###~", function ($matches) {
         $replacement = Field::$replacements[$matches[1]];
         if (isset($replacement[1]['html']) && $replacement[1]['html'] || isset($replacement[1]['type']) && $replacement[1]['type'] == 'html') {
             $tag_name = 'div';
         } else {
             $tag_name = Html::getWrapperTag($replacement[2]);
         }
         $tag = HtmlToken::createStandalone('<' . $tag_name . '>');
         $tag->addMeta(array('class' => 'fx_template_var', 'data-fx_var' => $replacement[1]));
         //fx_template_field::$replacements[$matches[1]] = null;
         Field::$fields_to_drop[] = $matches[1];
         $res = $tag->serialize() . self::replaceFields($replacement[2]) . '</' . $tag_name . '>';
         return $res;
     }, $html);
     return $html;
 }