From f3f0262c480d7e509b008d37c90aed884532bba8 Mon Sep 17 00:00:00 2001 From: andi Date: Wed, 12 Jan 2005 21:24:54 +0100 Subject: Initial revision. darcs-hash:20050112202454-9977f-60936f24fe2092a30223627e0683de2df61d0c4a.gz --- inc/html.php | 970 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 970 insertions(+) create mode 100644 inc/html.php (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php new file mode 100644 index 000000000..a28bd2dca --- /dev/null +++ b/inc/html.php @@ -0,0 +1,970 @@ + +
+
+
+ + + +
+
+ +
+
+ '; + print $lang['reghere']; + print ': '.$lang['register'].''; + print '

'; + } + ?> +
+ 'edit','rev' => $REV),'post'); + }else{ + $r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); + } + }else{ + $r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); + } + }else{ + $r = html_btn('show',$ID,'v',array('do' => 'show')); + } + return $r; +} + +function html_secedit_button($section,$p){ + global $ID; + global $lang; + $secedit = ''; + if($p) $secedit .= "

\n"; + $secedit .= '
'; + $secedit .= html_btn('secedit',$ID,'', + array('do' => 'edit', + 'lines' => "$section"), + 'post'); + $secedit .= '
'; + if($p) $secedit .= "\n

"; + return $secedit; +} + +function html_secedit($text,$show=true){ + global $INFO; + if($INFO['writable'] && $show){ + $text = preg_replace('##e', + "html_secedit_button('\\1',true)", + $text); + $text = preg_replace('##e', + "html_secedit_button('\\1',false)", + $text); + }else{ + $text = preg_replace('##e','',$text); + } + return $text; +} + +/** + * displays the breadcrumbs trace + */ +function html_breadcrumbs(){ + global $lang; + global $conf; + + //check if enabled + if(!$conf['breadcrumbs']) return; + + $crumbs = breadcrumbs(); //setup crumb trace + print '

'; +} + +/** + * display the HTML head and metadata + */ +function html_head(){ + global $ID; + global $ACT; + global $INFO; + global $conf; + global $lang; + + print '<'.'?xml version="1.0"?'.">\n"; + print ''; + print "\n"; +?> + + + <?=$ID?> [<?=$conf['title']?>] + + + + + + + + + + + +'."\n"; + print ' '."\n"; + }else{ + print ' '."\n"; + } + }else{ + print ' '."\n"; + } +?> + + + + + + + + +'; + + reset($params); + while (list($key, $val) = each($params)) { + $ret .= ''; + } + + $ret .= '= $perm) return true; + + print parsedLocale('denied'); + return false; +} + +/** + * Displays the page header and calls html_head() + */ +function html_header(){ + global $ID; + global $REV; + global $lang; + global $conf; + html_head(); +?> + +
+ +
+
+ [[]] +
+ +
+ + +
+
+ + 'revisions'))?> +
+ +
+ 'recent'))?> +
+ + + +
  +
+
+ + +
+ +'; + if($_SERVER['REMOTE_USER']){ + print '
'; + print $lang['loggedinas'].': '.$_SERVER['REMOTE_USER']; + print '
'; + } + print '   '; + if($INFO['exists']){ + print $fn; + print ' · '; + print $lang['lastmod']; + print ': '; + print $date; + if($INFO['locked']){ + print ' · '; + print $lang['lockedby']; + print ': '; + print $INFO['locked']; + } + } + print '
'; +} + +function html_footer(){ + global $ID; + global $REV; + global $INFO; + global $lang; + global $conf; +?> + +
+
 
+ +
+
+ + 'revisions'))?> +
+ +
+ 'logout',)); + }else{ + print html_btn('login',$ID,'',array('do' => 'login')); + } + } + ?> + 'index'))?> +   +
+
+ + + + +'; + $ret .= '
'; + $ret .= $lang['toc']; + $ret .= ' '; + $ret .= '
'; + $ret .= '
'; + $ret .= html_buildlist($toc,'toc','html_list_toc'); + $ret .= '
'; + $ret .= ''; + return $ret; +} + +/** + * User function for html_buildlist() + */ +function html_list_toc($item){ + $ret = ''; + $ret .= ''; + $ret .= $item['name']; + $ret .= ''; + return $ret; +} + +function html_show($text=''){ + global $ID; + global $REV; + global $HIGH; + //disable section editing for old revisions or in preview + if($text || $REV){ + global $parser; + $parser['secedit'] = false; + } + + if ($text){ + //PreviewHeader + print parsedLocale('preview'); + print '
'; + print html_secedit(parse($text),false); + print '
'; + }else{ + if ($REV) print parsedLocale('showrev'); + $html = parsedWiki($ID,$REV,true); + $html = html_secedit($html); + print html_hilight($html,$HIGH); + } +} + +/** + * Highlights searchqueries in HTML code + */ +function html_hilight($html,$query){ + $queries = preg_split ("/\s/",$query,-1,PREG_SPLIT_NO_EMPTY); + foreach ($queries as $q){ + $q = preg_quote($q,'/'); + $html = preg_replace("/((<[^>]*)|$q)/ie", '"\2"=="\1"? "\1":"\1"', $html); + } + return $html; +} + +/** + * This function runs a search and displays the result + */ +function html_search(){ + require_once("inc/search.php"); + global $conf; + global $QUERY; + global $ID; + global $lang; + + print parsedLocale('searchpage'); + flush(); + + //do quick pagesearch + $data = array(); + search($data,$conf['datadir'],'search_pagename',array(query => $QUERY)); + if(count($data)){ + sort($data); + print '
'; + print ''.$lang[quickhits].':
'; + foreach($data as $row){ + print '
'; + print html_wikilink(':'.$row['id'],$row['id']); + print '
'; + } + //clear float (see http://www.complexspiral.com/publications/containing-floats/) + print '
 
'; + print '
'; + } + flush(); + + //do fulltext search + $data = array(); + search($data,$conf['datadir'],'search_fulltext',array(query => $QUERY)); + if(count($data)){ + usort($data,'sort_search_fulltext'); + foreach($data as $row){ + print '
'; + print html_wikilink(':'.$row['id'],$row['id'],$QUERY); + print ': '.$row['count'].' '.$lang['hits'].'
'; + print '
'.$row['snippet'].'
'; + print '
'; + } + }else{ + print '
'.$lang['nothingfound'].'
'; + } +} + +function html_locked($ip){ + global $ID; + global $conf; + global $lang; + + $locktime = filemtime(wikiFN($ID).'.lock'); + $expire = @date($conf['dformat'], $locktime + $conf['locktime'] ); + $min = round(($conf['locktime'] - (time() - $locktime) )/60); + + print parsedLocale('locked'); + print ''; +} + +function html_revisions(){ + global $ID; + global $INFO; + global $conf; + global $lang; + $revisions = getRevisions($ID); + $date = @date($conf['dformat'],$INFO['lastmod']); + + print parsedLocale('revisions'); + print ''; +} + +function html_recent(){ + global $conf; + $recents = getRecents(0,true); + + print parsedLocale('recent'); + print ''; +} + +function html_index($ns){ + require_once("inc/search.php"); + global $conf; + global $ID; + $dir = $conf['datadir']; + $ns = cleanID($ns); + if(empty($ns)){ + $ns = dirname(str_replace(':','/',$ID)); + if($ns == '.') $ns =''; + } + $ns = str_replace(':','/',$ns); + + print parsedLocale('index'); + + $data = array(); + search($data,$conf['datadir'],'search_index',array('ns' => $ns)); + print html_buildlist($data,'idx','html_list_index'); +} + +/** + * User function for html_buildlist() + */ +function html_list_index($item){ + $ret = ''; + $base = ':'.$item['id']; + $base = substr($base,strrpos($base,':')+1); + if($item['type']=='d'){ + $ret .= ''; + $ret .= $base; + $ret .= ''; + }else{ + $ret .= html_wikilink(':'.$item['id']); + } + return $ret; +} + +/** + * Build an unordered list from the given $data array + * Each item in the array has to have a 'level' property + * the item itself gets printed by the given $func user + * function + */ +function html_buildlist($data,$class,$func){ + $level = 0; + $opens = 0; + $ret = ''; + + foreach ($data as $item){ + + if( $item['level'] > $level ){ + //open new list + $ret .= "\n\n\n"; + } + }else{ + //close last item + $ret .= "\n"; + } + + //remember current level + $level = $item['level']; + + //print item + $ret .= '
  • '; + $ret .= ''; + $ret .= $func($item); //user function + $ret .= ''; + } + + //close remaining items and lists + for ($i=0; $i < $level; $i++){ + $ret .= "
  • \n"; + } + + return $ret; +} + +function html_backlinks(){ + require_once("inc/search.php"); + global $ID; + global $conf; + + if(preg_match('#^(.*):(.*)$#',$ID,$matches)){ + $opts['ns'] = $matches[1]; + $opts['name'] = $matches[2]; + }else{ + $opts['ns'] = ''; + $opts['name'] = $ID; + } + + print parsedLocale('backlinks'); + + $data = array(); + search($data,$conf['datadir'],'search_backlinks',$opts); + sort($data); + + print ''; +} + +function html_diff($text='',$intro=true){ + require_once("inc/DifferenceEngine.php"); + global $ID; + global $REV; + global $lang; + global $conf; + if($text){ + $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))), + split("\n",htmlspecialchars(cleanText($text)))); + $left = ''. + $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).''. + $lang['current']; + $right = $lang['yours']; + }else{ + $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$REV))), + split("\n",htmlspecialchars(rawWiki($ID,'')))); + $left = ''. + $ID.' '.date($conf['dformat'],$REV).''; + $right = ''. + $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).' '. + $lang['current']; + } + $tdf = new TableDiffFormatter(); + if($intro) print parsedLocale('diff'); + ?> + + + + + + format($df)?> +
    + + + +
    + +
    + + + + +
    + + +
    +
    +



    + '; + print $msg['msg']; + print ''; + } +} + +/** + * Prints the registration form + */ +function html_register(){ + global $lang; + global $ID; + + print parsedLocale('register'); +?> +
    +
    + + +
    + +
    +
    +
    + +
    +
    +
    + +
    + + + + + + + + + + + + + + + + + +
    + + + +
    + +
    + + + + + + + + : + + + + +
    +
    +'; + + print '

    When reporting bugs please send all the following '; + print 'output as a mail to andi@splitbrain.org '; + print 'The best way to do this is to save this page in your browser

    '; + + print '$_SERVER:
    ';
    +  print_r($_SERVER);
    +  print '
    '; + + print '$conf:
    ';
    +  print_r($conf);
    +  print '
    '; + + print 'abs baseURL:
    ';
    +  print getBaseURL(true);
    +  print '
    '; + + print 'rel baseURL:
    ';
    +  print dirname($_SERVER['PHP_SELF']).'/';
    +  print '
    '; + + print 'PHP Version:
    ';
    +  print phpversion();
    +  print '
    '; + + print 'locale:
    ';
    +  print setlocale(LC_ALL,0);
    +  print '
    '; + + print 'Environment:
    ';
    +  print_r($_ENV);
    +  print '
    '; + + print 'PHP settings:
    ';
    +  $inis = ini_get_all();
    +  print_r($inis);
    +  print '
    '; + + print ''; +} + +?> -- cgit v1.2.3