. if (!defined('EG')) die('Direct access not allowed!'); $decodeCounter = 0; $decodeAnotherTime = false; //decode the text of the wiki function decodeWikiText($string) { global $decodeAnotherTime; global $decodeCounter; $decodeCounter++; $decodeAnotherTime = false; $string = preg_replace('/(\[hr\])/', '
',$string); $string = preg_replace_callback('/(\[\[)(.*?)\|(.*?)(\]\])/', 'linkToInternalPageWithText' ,$string); $string = preg_replace_callback('/(\[\[)(.*?)(\]\])/', 'linkToInternalPage' ,$string); $string = preg_replace_callback('/(\[a\])(.*?)(\[\/a\])/', 'linkTo',$string); $string = preg_replace_callback('/(\[a\])(.*?)\|(.*?)(\[\/a\])/', 'linkToWithText',$string); $string = preg_replace_callback('/(\[notebook\])([0-9]*?)(\[\/notebook\])/s', 'linkToNotebook',$string); $string = preg_replace_callback('/(\[wifi\])([0-9]*?)(\[\/wifi\])/s', 'linkToWifi',$string); $string = preg_replace_callback('/(\[videocard\])([0-9]*?)(\[\/videocard\])/s', 'linkToVideocard',$string); $string = preg_replace('/(\[b\])(.*?)(\[\/b\])/s', '${2}',$string); $string = preg_replace('/(\[u\])(.*?)(\[\/u\])/s', '${2}',$string); $string = preg_replace('/(\[i\])(.*?)(\[\/i\])/s', '${2}',$string); $string = preg_replace('/(\[del\])(.*?)(\[\/del\])/s', '${2}',$string); $string = preg_replace_callback('/(\[\*\])(.*?)(\[\/\*\])/s', 'createItem',$string); $string = preg_replace_callback('/(\[list\])(.*?)(\[\/list\])/s', 'createList',$string); $string = preg_replace_callback('/(\[enum\])(.*?)(\[\/enum\])/s', 'createEnum',$string); $string = preg_replace('/(\[code\])(.*?)(\[\/code\])/s', '
${2}
',$string); $string = preg_replace('/(\[p\])(.*?)(\[\/p\])/s', '

${2}

',$string); $string = preg_replace_callback('/(\[)(h)(1|2|3)(\])(.*?)(\[\/)(h)(1|2|3)(\])/s', 'createHeadGeneric',$string); $string = preg_replace_callback('/(\[tab )(lang=)([^\s]+)(\s*\])(.*?)(\[\/tab\])/s', 'createTabs',$string); $string = preg_replace_callback('/(__TOC__)/s', 'createToc',$string); $string = preg_replace('/(\[lang\])(.*?)(\[\/lang\])/s', '
${2}
',$string); $string = preg_replace('/(\{\{)/s', '[',$string); $string = preg_replace('/(\}\})/s', ']',$string); if ($decodeAnotherTime and $decodeCounter<=30) { return decodeWikiText(Toc::render().Tabs::render().$string); } else { return Toc::render().Tabs::render().$string; } } //create the list of the tabs in the description entry function createTabs($match) { $label = Lang::getLabel($match[3]); Tabs::$tabList[] = "
  • ".$label."
  • \n"; Tabs::$htmlList[] = "
    $label
    \n
    ".$match[5]."
    \n"; return null; } //create the HTM Lof the tabs in the description entry class Tabs { public static $tabList = array(); public static $htmlList = array(); public static function render() { $html = null; if (count(self::$tabList) > 0) { $html .= "
    \n"; $html .= "\n"; $html .= "\n
    \n"; foreach (self::$htmlList as $content) { $html .= $content; } $html .= "
    \n
    \n"; } self::$tabList = array(); self::$htmlList = array(); return $html; } } function checkUrl($url) { $match = '/^http(s)?\:\/\/(www\.)?[a-zA-Z0-9\-\_]+(\.[a-zA-Z0-9\-\_]+)*\.(com|net|it|info|org|eu|uk|ca|us|cl)((\/[a-zA-Z0-9\_\.\-\:\+]+)*(\/([a-zA-Z0-9\_\:\-\.\+]+\.(php|html|htm|asp|aspx|jsp|cgi))?)?)?(\?([a-zA-Z0-9\_\-\+\s]+\=[a-zA-Z0-9\_\-\s\+\&]+)+)?(#[a-zA-Z0-9\_\-\+\s]+)?([\s]*)?$/'; if (preg_match($match,$url)) { return true; } else { return false; } } function vitalizeUrl($string) { if (checkUrl($string)) { return "".$string.""; } return $string; } function linkTo($match) { if (checkUrl($match[2])) { return "".$match[2].""; } else { return $match[0]; } } function createNode($match,$hnodeTag,$htmlTagBegin,$htmlTagEng) { $numb = strlen($hnodeTag); global $decodeAnotherTime; if (strstr($match[2],$hnodeTag)) { $string = substr($match[0],$numb); $string = decodeWikiText($string); $decodeAnotherTime = true; return $hnodeTag.$string; } else { return $htmlTagBegin.$match[2].$htmlTagEng; } } function createToc($match) { Toc::create(); return null; } //table of contents class Toc { public static $links = array(); public static $level = 1; private static $html = null; public function create() { $c=0; foreach (self::$links as $link) { if ((int)substr($link,0,1) === 1) { break; } $c++; } self::$links = array_slice(self::$links,$c); $res = array(); if (count(self::$links) > 0) { self::$links[] = '1fine'; $res[] = "
    ".gtext("Table of contents")."
    "; } self::$links = array(); self::$html = implode('',$res); } public function render() { echo self::$html; } } //create h1, h2, h3 ($level=1,2,3) function createHead($match,$level) { Toc::$links[] = $level.$match[5]; return "
    ".$match[5]."
    "; } //create

    ,

    ,

    function createHeadGeneric($match) { if (strcmp($match[3],'1') === 0) { return createHead($match,'1'); } else if (strcmp($match[3],'2') === 0) { return createHead($match,'2'); } else { return createHead($match,'3'); } } //create
  • function createItem($match) { return createNode($match,'[*]',"
  • ","
  • "); } //create function createList($match) { return createNode($match,'[list]',""); } //create
      function createEnum($match) { return createNode($match,'[enum]',"
        ","
      "); } function linkToInternalPage($match) { return "".$match[2].""; } function linkToInternalPageWithText($match) { return "".$match[3].""; } function linkToWithText($match) { if (checkUrl($match[2])) { return "".$match[3].""; } else { return $match[0]; } } //create the link to the wiki page of the notebook function linkToNotebook($match) { $hardware = new HardwareModel(); $clean['id_hard'] = (int)$match[2]; $name = encodeUrl($hardware->getTheModelName($clean['id_hard'])); $href = "HTTP://".DOMAIN_NAME."/notebooks/view/".Lang::$current."/".$clean['id_hard']."/$name"; return (strcmp($name,'') !== 0) ? "".$name."" : $match[0]; } //create the link to the wiki page of the wifi function linkToWifi($match) { $hardware = new HardwareModel(); $clean['id_hard'] = (int)$match[2]; $name = encodeUrl($hardware->getTheModelName($clean['id_hard'])); $href = "HTTP://".DOMAIN_NAME."/wifi/view/".Lang::$current."/".$clean['id_hard']."/$name"; return (strcmp($name,'') !== 0) ? "".$name."" : $match[0]; } //create the link to the wiki page of the videocard function linkToVideocard($match) { $hardware = new HardwareModel(); $clean['id_hard'] = (int)$match[2]; $name = encodeUrl($hardware->getTheModelName($clean['id_hard'])); $href = "HTTP://".DOMAIN_NAME."/videocards/view/".Lang::$current."/".$clean['id_hard']."/$name"; return (strcmp($name,'') !== 0) ? "".$name."" : $match[0]; }