*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
require_once(DOKU_INC.'inc/format.php');
/**
* Convenience function to quickly build a wikilink
*
* @author Andreas Gohr
*/
function html_wikilink($url,$name='',$search=''){
global $conf;
$link = array();
$link['url'] = $url;
$link['name'] = $name;
$link = format_link_wiki($link);
if($search){
($conf['userewrite']) ? $link['url'].='?s=' : $link['url'].='&s=';
$link['url'] .= urlencode($search);
}
return format_link_build($link);
}
/**
* Helps building long attribute lists
*
* @author Andreas Gohr
*/
function html_attbuild($attributes){
$ret = '';
foreach ( $attributes as $key => $value ) {
$ret .= $key.'="'.formtext($value).'" ';
}
return trim($ret);
}
/**
* The loginform
*
* @author Andreas Gohr
*/
function html_login(){
global $lang;
global $conf;
global $ID;
print parsedLocale('login');
?>
if($conf['openregister']){
print '
';
print $lang['reghere'];
print ': '.$lang['register'].'';
print '
';
}
?>
if(@file_exists('includes/login.txt')){
print io_cacheParse('includes/login.txt');
}
}
/**
* shows the edit/source/show button dependent on current mode
*
* @author Andreas Gohr
*/
function html_editbutton(){
global $ID;
global $REV;
global $ACT;
global $INFO;
if($ACT == 'show' || $ACT == 'search'){
if($INFO['writable']){
if($INFO['exists']){
$r = html_btn('edit',$ID,'e',array('do' => '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;
}
/**
* prints a section editing button
*
* @author Andreas Gohr
*/
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;
}
/**
* inserts section edit buttons if wanted or removes the markers
*
* @author Andreas Gohr
*/
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;
}
/**
* Just the back to top button (in it's own form)
*
* @author Andreas Gohr
*/
function html_topbtn(){
global $lang;
$ret = '';
$ret .= '';
return $ret;
}
/**
* Displays a button (using it's own form)
*
* @author Andreas Gohr
*/
function html_btn($name,$id,$akey,$params,$method='get'){
global $conf;
global $lang;
$label = $lang['btn_'.$name];
$ret = '';
//filter id (without urlencoding)
$id = idfilter($id,false);
//make nice URLs even for buttons
if(!$conf['userewrite']){
$script = DOKU_BASE.DOKU_SCRIPT;
$params['id'] = $id;
}else{
$script = DOKU_BASE.$id;
}
$ret .= '