示例#1
0
 function processMatch(&$string, &$match, $area = 'articles')
 {
     $html = '';
     if ($this->params->message != '') {
         if ($this->params->place_comments) {
             $html = $this->params->message_start . $this->params->message . $this->params->message_end;
         }
     } else {
         if (count($match) < 10) {
             array_unshift($match, $match['0'], '');
             $match['2'] = '';
             array_push($match, '', '');
         }
         $p_start = $match['1'];
         $br1a = $match['2'];
         $div_start = $match['3'];
         $br2a = $match['4'];
         $type = trim($match['5']);
         $id = trim($match['6']);
         $br2a = $match['7'];
         $div_end = $match['8'];
         $br2b = $match['9'];
         $p_end = $match['10'];
         $type = trim($type);
         $id = trim($id);
         $chrome = '';
         $forcetitle = 0;
         $ignores = array();
         $overrides = array();
         $vars = str_replace('\\|', '[:MA_BAR:]', $id);
         $vars = explode('|', $vars);
         $id = array_shift($vars);
         foreach ($vars as $var) {
             $var = trim(str_replace('[:MA_BAR:]', '|', $var));
             if (!$var) {
                 continue;
             }
             if (strpos($var, '=') === false) {
                 if ($this->params->override_style) {
                     $chrome = $var;
                 }
             } else {
                 if ($type == $this->params->module_tag) {
                     list($key, $val) = explode('=', $var, 2);
                     $val = str_replace(array('\\{', '\\}'), array('{', '}'), $val);
                     if ($key == 'style') {
                         $chrome = $val;
                     } else {
                         if (in_array($key, array('ignore_access', 'ignore_state', 'ignore_assignments', 'ignore_caching'))) {
                             $ignores[$key] = $val;
                         } else {
                             if ($key == 'showtitle') {
                                 $overrides['showtitle'] = $val;
                                 $forcetitle = $val;
                             }
                         }
                     }
                 }
             }
         }
         if (!$chrome) {
             $chrome = $forcetitle ? 'xhtml' : $this->params->style;
         }
         if ($type == $this->params->module_tag) {
             // module
             $html = $this->processModule($id, $chrome, $ignores, $overrides, $area);
             if ($html == 'MA_IGNORE') {
                 return 0;
             }
         } else {
             // module position
             $html = $this->processPosition($id, $chrome);
         }
         if ($p_start && $p_end) {
             $p_start = '';
             $p_end = '';
         }
         $html = $br1a . $br2a . $html . $br2a . $br2b;
         if ($div_start) {
             $extra = trim(preg_replace('#\\{div(.*)\\}#si', '\\1', $div_start));
             $div = '';
             if ($extra) {
                 $extra = explode('|', $extra);
                 $extras = new stdClass();
                 foreach ($extra as $e) {
                     if (strpos($e, ':') !== false) {
                         list($key, $val) = explode(':', $e, 2);
                         $extras->{$key} = $val;
                     }
                 }
                 if (isset($extras->class)) {
                     $div .= 'class="' . $extras->class . '"';
                 }
                 $style = array();
                 if (isset($extras->width)) {
                     if (is_numeric($extras->width)) {
                         $extras->width .= 'px';
                     }
                     $style[] = 'width:' . $extras->width;
                 }
                 if (isset($extras->height)) {
                     if (is_numeric($extras->height)) {
                         $extras->height .= 'px';
                     }
                     $style[] = 'height:' . $extras->height;
                 }
                 if (isset($extras->align)) {
                     $style[] = 'float:' . $extras->align;
                 } else {
                     if (isset($extras->float)) {
                         $style[] = 'float:' . $extras->float;
                     }
                 }
                 if (!empty($style)) {
                     $div .= ' style="' . implode(';', $style) . ';"';
                 }
             }
             $html = trim('<div ' . trim($div)) . '>' . $html . '</div>';
             $html = $p_end . $html . $p_start;
         } else {
             $html = $p_start . $html . $p_end;
         }
         nnText::fixHtmlTagStructure($html);
     }
     if ($this->params->place_comments) {
         $html = $this->params->comment_start . $html . $this->params->comment_end;
     }
     $string = str_replace($match['0'], $html, $string);
     unset($match);
     return 1;
 }
示例#2
0
 public function processMatch(&$string, &$art, &$match, &$ignores, &$count = 0, $first = 0, $last = 0, $type = 'article')
 {
     if ($this->params->message != '') {
         if ($this->params->place_comments) {
             return $this->params->comment_start . $this->params->message_start . $this->params->message . $this->params->message_end . $this->params->comment_end;
         }
         return '';
     }
     $p1_start = $match['1'];
     $br1a = $match['2'];
     //$type		= $match['3'];
     $id = $match['4'];
     $br1b = $match['5'];
     $p1_end = $match['6'];
     $html = $match['7'];
     $p2_start = $match['8'];
     $br2a = $match['9'];
     // end tag
     $br2b = $match['10'];
     $p2_end = $match['11'];
     $html = trim($html);
     preg_match('#^' . $this->params->breaks_start . '(.*?)' . $this->params->breaks_end . '$#s', trim($html), $text_match);
     $p1_start = $p1_end || $text_match['1'] ? '' : $p1_start;
     $p2_end = $p2_start || $text_match['5'] ? '' : $p2_end;
     if (strpos($string, '{/div}') !== false && preg_match('#^' . $this->params->breaks_start . '(\\{div[^\\}]*\\})' . $this->params->breaks_end . '(.*?)' . $this->params->breaks_start . '(\\{/div\\})' . $this->params->breaks_end . '#s', $html, $div_match)) {
         if ($div_match['1'] && $div_match['5']) {
             $div_match['1'] = '';
         }
         if ($div_match['7'] && $div_match['11']) {
             $div_match['11'] = '';
         }
         $html = $div_match['2'] . $div_match['3'] . $div_match['4'] . $div_match['1'] . $div_match['6'] . $div_match['11'] . $div_match['8'] . $div_match['9'] . $div_match['10'];
     }
     $type = $type ?: 'article';
     if (strpos($id, ':') !== false) {
         $type = explode(':', $id, 2);
         if ($type['0'] == 'k2') {
             $id = trim($type['1']);
         }
     }
     $html = $this->processArticle($id, $art, $html, $type, $ignores, $count, $first, $last);
     if ($this->params->place_comments) {
         $html = $this->params->comment_start . $html . $this->params->comment_end;
     }
     $html = $p1_start . $br1a . $br1b . $html . $br2a . $br2b . $p2_end;
     nnText::fixHtmlTagStructure($html, false);
     return $html;
 }