示例#1
0
 /**
  * Расстановка защищенных тегов параграфа (<p>...</p>) и переноса строки
  *
  * @return  void
  */
 protected function build_paragraphs()
 {
     $r = mb_strpos($this->_text, '<' . self::BASE64_PARAGRAPH_TAG . '>');
     $p = EMT_Lib::rstrpos($this->_text, '</' . self::BASE64_PARAGRAPH_TAG . '>');
     if ($r !== false && $p !== false) {
         $beg = mb_substr($this->_text, 0, $r);
         $end = mb_substr($this->_text, $p + mb_strlen('</' . self::BASE64_PARAGRAPH_TAG . '>'));
         $this->_text = (trim($beg) ? $this->do_paragraphs($beg) . "\n" : "") . '<' . self::BASE64_PARAGRAPH_TAG . '>' . mb_substr($this->_text, $r + mb_strlen('<' . self::BASE64_PARAGRAPH_TAG . '>'), $p - ($r + mb_strlen('<' . self::BASE64_PARAGRAPH_TAG . '>'))) . '</' . self::BASE64_PARAGRAPH_TAG . '>' . (trim($end) ? "\n" . $this->do_paragraphs($end) : "");
     } else {
         $this->_text = $this->do_paragraphs($this->_text);
     }
 }
示例#2
0
 /**
  * Создание защищенного тега с содержимым
  *
  * @see 	EMT_lib::build_safe_tag
  * @param 	string $content
  * @param 	string $tag
  * @param 	array $attribute
  * @return 	string
  */
 protected function tag($content, $tag = 'span', $attribute = array())
 {
     if (isset($attribute['class'])) {
         $classname = $attribute['class'];
         if ($classname == "nowrap") {
             if (!$this->is_on('nowrap')) {
                 $tag = "nobr";
                 $attribute = array();
                 $classname = "";
             }
         }
         if (isset($this->classes[$classname])) {
             $style_inline = $this->classes[$classname];
             if ($style_inline) {
                 $attribute['__style'] = $style_inline;
             }
         }
         $classname = isset($this->class_names[$classname]) ? $this->class_names[$classname] : $classname;
         $classname = ($this->class_layout_prefix ? $this->class_layout_prefix : "") . $classname;
         $attribute['class'] = $classname;
     }
     return EMT_Lib::build_safe_tag($content, $tag, $attribute, $this->use_layout === false ? EMT_Lib::LAYOUT_STYLE : $this->use_layout);
 }
示例#3
0
 /**
  * Установить настройку
  *
  * @param mixed $selector
  * @param string $setting
  * @param mixed $value
  */
 protected function doset($selector, $key, $value)
 {
     $tret_pattern = false;
     $rule_pattern = false;
     //if(($selector === false) || ($selector === null) || ($selector === false) || ($selector === "*")) $type = 0;
     if (is_string($selector)) {
         if (strpos($selector, ".") === false) {
             $tret_pattern = $selector;
         } else {
             $pa = explode(".", $selector);
             $tret_pattern = $pa[0];
             array_shift($pa);
             $rule_pattern = implode(".", $pa);
         }
     }
     EMT_Lib::_process_selector_pattern($tret_pattern);
     EMT_Lib::_process_selector_pattern($rule_pattern);
     if ($selector == "*") {
         $this->settings[$key] = $value;
     }
     foreach ($this->trets as $tret) {
         $t1 = $this->get_short_tret($tret);
         if (!EMT_Lib::_test_pattern($tret_pattern, $t1)) {
             if (!EMT_Lib::_test_pattern($tret_pattern, $tret)) {
                 continue;
             }
         }
         $tret_obj = $this->get_tret($tret);
         if ($key == "active") {
             foreach ($tret_obj->rules as $rulename => $v) {
                 if (!EMT_Lib::_test_pattern($rule_pattern, $rulename)) {
                     continue;
                 }
                 if (strtolower($value) === "on" || $value === 1 || $value === true || $value == "1") {
                     $tret_obj->enable_rule($rulename);
                 }
                 if (strtolower($value) === "off" || $value === 0 || $value === false || $value == "0") {
                     $tret_obj->disable_rule($rulename);
                 }
             }
         } else {
             if ($rule_pattern === false) {
                 $tret_obj->set($key, $value);
             } else {
                 foreach ($tret_obj->rules as $rulename => $v) {
                     if (!EMT_Lib::_test_pattern($rule_pattern, $rulename)) {
                         continue;
                     }
                     $tret_obj->set_rule($rulename, $key, $value);
                 }
             }
         }
     }
 }