more && $this->from < 0 && $this->more = preg_match('/\[\[(header_level|html_data|post_data|data_dictionary|wdictionaries|wmonitor|ignore|links_groups?|i|icon|\!|wdoc|plain) ?(([^\]"\']+|[\r\n]+|"(([^\\\\"]+|\\\\(.|[\r\n]))*)"|\'(([^\\\\\']+|\\\\(.|[\r\n]))*)\'|\]([^\]]))+)\]\]/', $string, $this->matches, PREG_OFFSET_CAPTURE) ) $this->from = $this->matches[0][1]; } public function process($string, $modules, $level){ $this->order = $this->matches[1][0]; switch($key = strtolower($this->matches[1][0])){ case "header_level": try{ $symbol = $this->matches[2][0][0]; $level = $this->matches[2][0]; if($string == "[[header_level 2]]") print_r([$symbol, $level]); $modules->menu_level = strpos("+-", $symbol) !== false ? $modules->menu_level + intval(substr($level, 1)) * ($symbol == "-" ? -1 : 1) : intval($level); }catch(\Exception $exception){}; $this->html = ''; break; case "html_data": try{ $modules->html_data = json_decode(\WMarkDown::string_variables($this->matches[2][0], [ "now" => (new \DateTime())->format('Ymd') ]), true); }catch(\Exception $exception){}; $this->html = ''; break; case "post_data": $this->html = ''; try{ $data = json_decode(\WMarkDown::string_variables($this->matches[2][0], [ "now" => (new \DateTime())->format('Ymd') ]), true); if(!isset($data["since"])) $data["since"] = (new \DateTime())->format('Ymd'); foreach(["since", "version"] as $key) if(isset($data[$key])) $data[$key] = preg_replace('/^(\d{4})(\d{2})(\d{2})$/', "$1/$2/$3", $data[$key]); if(!isset($data["version"])) $data["version"] = $data["since"]; if(!isset($data["author"])) $data["author"] = "Anonymous"; $i18n_data = base64_encode(json_encode($data)); $this->html = \WMarkDown::string_variables(('
Por {author}. Creado a fecha {since}. Última modificación a fecha {version}.
'), $data); }catch(\Exception $exception){}; break; case "data_dictionary": try{ $this->html = json_decode($this->matches[2][0], true); }catch(\Exception $exception){}; $this->html = $this->html ? 'matches[2][0])) . '" />' : ''; break; case "wdictionaries": $this->html = ''; if( $this->matches[2][0] && preg_match('/^([^"\' ]+|"(([^\\\\"]+|\\\\.)*)"|\'(([^\\\\\']+|\\\\.)*)\')((.+|[\r\n]+)+)?$/', $this->matches[2][0], $matches) && count($matches) >= 6 && !empty($files = preg_split('/([\s\t]+|[\r\n]+)+/', trim($matches[6]))) ) $this->html = $files ? (' ' . \WMarkDown\Modules::format($this->wmarkdown, '# ' . $matches[$matches[4] ? 4 : ($matches[2] ? 2 : 1)], ["wdictionaries", "paragraph"], $modules)["content"] . ' ') : ''; break; case "wmonitor": $this->html = $this->matches[2][0] ? 'WMonitor' : ''; break; case "ignore": $this->html = '' . $this->matches[2][0] . ''; break; case "links_group": case "links_groups": $html = ''; break; case "i": case "!": case "icon": $this->html = preg_match('/^([^ ]+)( ((.+|[\r\n]+)+)?)?/', $this->matches[2][0], $matches) ? ( '' . '' . (empty($matches[3]) ? '' : '' . $matches[3] . '') . '' ) : $this->matches[0][0]; break; case "wdoc": $html = ''; $name = 'UNKNOWN'; $description = ''; $attributes = [[]]; $return = [null]; $data = []; $language = "unknown"; $deprecated = false; preg_replace_callback('/([\@\#]([^\s\t\r\n]+)([ \t]+([^\s\t\r\n]+)([ \t]+([^\s\t\r\n]+)([ \t]+([^\r\n]*))?)?)?|[^\@\r\n][^\r\n]+)/', function($values) use( &$name, &$description, &$attributes, &$return, &$language, &$deprecated, &$data ){ switch($values[0][0]){ case "@": switch(strtolower($values[2])){ case "lang": $language = $values[4]; $data[] = ["language", $values[4]]; break; case "deprecated": $deprecated = true; $data[] = ["deprecated", true]; break; case "name": $name = $values[4]; $data[] = ["name", $values[4]]; break; case "overload": $attributes[] = []; $return[] = null; break; case "see": // Mirar porque algunos SEE salen mal. count($values) >= 5 && ($data[] = [$values[2], '' . $values[4] . '']); break; default: $data[] = [$values[2], count($values) > 3 ? $values[4] : null]; break; }; break; case "#": switch(strtolower($values[2])){ case "return": $return[count($attributes) - 1] = [$values[4], count($values) > 8 && $values[8] ? $values[8] : '']; break; default: $l = count($values); if($l > 5) $attributes[count($attributes) - 1][] = [ $values[2], $values[4], $values[6], $l > 8 && $values[8] ? $values[8] : '' ]; else $data[] = [$values[2], $l > 3 ? $values[4] : null]; break; }; break; default: $description .= $values[0] . " "; break; }; }, $this->matches[2][0]); $l = count($attributes); $data_html = ''; foreach($data as $value){ $is_bool = is_bool($value[1]) || $value[1] === null; if(is_string($value[1])) $value[1] = explode(",", $value[1]); $data_html .= ( '
  • ' . '' . $value[0] . '' . '' . (is_array($value[1]) ? '' . implode('', $value[1]) . '' : $value[1]) . '' . '
  • ' ); }; for($i = 0; $i < $l; $i ++){ $overload = $attributes[$i]; $attributes_html = ''; $return_type = $return[$i] ? $return[$i][0] : 'void'; foreach($attributes[$i] as $attribute) $attributes_html .= ( '' . '' . $attribute[0] . '' . '' . preg_replace('/,/', '', $attribute[1] == "-" ? "ANY" : $attribute[1]) . '' . '' . $attribute[2] . '' . '' . ($attribute[3] ? $attribute[3] : '') . '' . '' ); $attributes_html .= ( '' . 'return' . '' . ($return_type == "-" ? "ANY" : $return_type) . '' . '' . '' . ($return[$i] && $return[$i][1] ? $return[$i][1] : '') . '' . '' ); $html .= ( '
    ' . '
    ' . '' . ($return_type == "-" ? "ANY" : $return_type) . '' . '' . $name . '' . '' . $attributes_html . '' . '
    ' . '
    ' . $attributes_html . '
    ' . '
    ' ); }; $this->html = ( '
    ' . '' . ($deprecated ? ( '' . '' . 'Deprecated' . '' ) : '') . '' . $name . '' . '' . $language . '' . '' . '

    ' . $description . '

    ' . $html . '' . '
    ' ); break; case "plain": $this->html = $this->matches[2][0]; break; default: $this->html = $this->matches[0][0]; break; }; $this->length = strlen($this->matches[0][0]); $this->to = $this->from + $this->length; $this->content = $this->matches[2][0]; } public function get_menu(){return "" . $this->menu;} public function get_title(){return "" . $this->title;} public function get_order(){return "" . $this->order;} };