*/ if(!defined('DOKU_INC')) die('meh.'); if(!defined('NL')) define('NL',"\n"); /** * Convenience function to quickly build a wikilink * * @author Andreas Gohr * @param string $id id of the target page * @param string $name the name of the link, i.e. the text that is displayed * @param string|array $search search string(s) that shall be highlighted in the target page * @return string the HTML code of the link */ function html_wikilink($id,$name=null,$search=''){ /** @var Doku_Renderer_xhtml $xhtml_renderer */ static $xhtml_renderer = null; if(is_null($xhtml_renderer)){ $xhtml_renderer = p_get_renderer('xhtml'); } return $xhtml_renderer->internallink($id,$name,$search,true,'navigation'); } /** * The loginform * * @author Andreas Gohr */ function html_login(){ global $lang; global $conf; global $ID; global $INPUT; print p_locale_xhtml('login'); print '
'.NL; $form = new Doku_Form(array('id' => 'dw__login')); $form->startFieldset($lang['btn_login']); $form->addHidden('id', $ID); $form->addHidden('do', 'login'); $form->addElement(form_makeTextField('u', ((!$INPUT->bool('http_credentials')) ? $INPUT->str('u') : ''), $lang['user'], 'focus__this', 'block')); $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block')); if($conf['rememberme']) { $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple')); } $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); $form->endFieldset(); if(actionOK('register')){ $form->addElement('

'.$lang['reghere'].': '.tpl_actionlink('register','','','',true).'

'); } if (actionOK('resendpwd')) { $form->addElement('

'.$lang['pwdforget'].': '.tpl_actionlink('resendpwd','','','',true).'

'); } html_form('login', $form); print '
'.NL; } /** * Denied page content * * @return string html */ function html_denied() { print p_locale_xhtml('denied'); if(!$_SERVER['REMOTE_USER']){ html_login(); } } /** * inserts section edit buttons if wanted or removes the markers * * @author Andreas Gohr * * @param string $text * @param bool $show show section edit buttons? * @return string */ function html_secedit($text,$show=true){ global $INFO; $regexp = '##'; if(!$INFO['writable'] || !$show || $INFO['rev']){ return preg_replace($regexp,'',$text); } return preg_replace_callback($regexp, 'html_secedit_button', $text); } /** * prepares section edit button data for event triggering * used as a callback in html_secedit * * @author Andreas Gohr * * @param array $matches matches with regexp * @return string * @triggers HTML_SECEDIT_BUTTON */ function html_secedit_button($matches){ $data = array('secid' => $matches[1], 'target' => strtolower($matches[2]), 'range' => $matches[count($matches) - 1]); if (count($matches) === 5) { $data['name'] = $matches[3]; } return trigger_event('HTML_SECEDIT_BUTTON', $data, 'html_secedit_get_button'); } /** * prints a section editing button * used as default action form HTML_SECEDIT_BUTTON * * @author Adrian Lang * * @param array $data name, section id and target * @return string html */ function html_secedit_get_button($data) { global $ID; global $INFO; if (!isset($data['name']) || $data['name'] === '') return ''; $name = $data['name']; unset($data['name']); $secid = $data['secid']; unset($data['secid']); return "
" . html_btn('secedit', $ID, '', array_merge(array('do' => 'edit', 'rev' => $INFO['lastmod'], 'summary' => '['.$name.'] '), $data), 'post', $name) . '
'; } /** * Just the back to top button (in its own form) * * @author Andreas Gohr * * @return string html */ function html_topbtn(){ global $lang; $ret = ''; return $ret; } /** * Displays a button (using its own form) * If tooltip exists, the access key tooltip is replaced. * * @author Andreas Gohr * * @param string $name * @param string $id * @param string $akey access key * @param string[] $params key-value pairs added as hidden inputs * @param string $method * @param string $tooltip * @param bool|string $label label text, false: lookup btn_$name in localization * @return string */ function html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label=false){ global $conf; global $lang; if (!$label) $label = $lang['btn_'.$name]; $ret = ''; //filter id (without urlencoding) $id = idfilter($id,false); //make nice URLs even for buttons if($conf['userewrite'] == 2){ $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; }elseif($conf['userewrite']){ $script = DOKU_BASE.$id; }else{ $script = DOKU_BASE.DOKU_SCRIPT; $params['id'] = $id; } $ret .= '
'; if(is_array($params)){ reset($params); while (list($key, $val) = each($params)) { $ret .= ''; } } if ($tooltip!='') { $tip = htmlspecialchars($tooltip); }else{ $tip = htmlspecialchars($label); } $ret .= '