From 07f5140771388c9e0c8a99b0dd2e5d950bdb173b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 14 Oct 2021 15:16:42 +1100 Subject: moving h-source subdir out. --- h-source/Application/Include/wikiFormatting.php | 356 ------------------------ 1 file changed, 356 deletions(-) delete mode 100644 h-source/Application/Include/wikiFormatting.php (limited to 'h-source/Application/Include/wikiFormatting.php') diff --git a/h-source/Application/Include/wikiFormatting.php b/h-source/Application/Include/wikiFormatting.php deleted file mode 100644 index 6eb93f7..0000000 --- a/h-source/Application/Include/wikiFormatting.php +++ /dev/null @@ -1,356 +0,0 @@ -. - -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(Tabs::render().$string); - } - else - { - return 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 HTML of 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\-\_]+)*\.([a-z]{2,4})((\/[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 - { -// $decodeAnotherTime = false; - return $htmlTagBegin.$match[2].$htmlTagEng; - } -} - -function createToc($match) -{ - return Toc::render(); -} - -//table of contents -class Toc -{ - - public static $links = array(); - public static $level = 1; - - private static $html = null; - - public function render() - { - $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(); - return implode('',$res); - } -} - -//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 = Url::getRoot()."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 = Url::getRoot()."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 = Url::getRoot()."videocards/view/".Lang::$current."/".$clean['id_hard']."/$name"; - return (strcmp($name,'') !== 0) ? "".$name."" : $match[0]; -} \ No newline at end of file -- cgit v1.2.3