/**
* The loginform
*
* @author Andreas Gohr
*
* @param bool $svg Whether to show svg icons in the register and resendpwd links or not
*/
function html_login($svg = false){
global $lang;
global $conf;
global $ID;
global $INPUT;
print p_locale_xhtml('login');
print ''.NL;
$form = new Doku_Form(array('id' => 'dw__login', 'action'=> $ID));
$form->startFieldset($lang['btn_login']);
$form->addHidden('id', $ID);
$form->addHidden('do', 'login');
/** ここでログイン後に引継ぎたいパラメータを追加 **/
if ($INPUT->str('test')) $form->addHidden('test', $INPUT->str('test'));
$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')){
$registerLink = (new \dokuwiki\Menu\Item\Register())->asHtmlLink('', $svg);
$form->addElement(''.$lang['reghere'].': '. $registerLink .'
');
}
if (actionOK('resendpwd')) {
$resendPwLink = (new \dokuwiki\Menu\Item\Resendpwd())->asHtmlLink('', $svg);
$form->addElement(''.$lang['pwdforget'].': '. $resendPwLink .'
');
}
html_form('login', $form);
print ''.NL;
}
/**
* Redirect to the show action, trying to jump to the previously edited section
*
* @triggers ACTION_SHOW_REDIRECT
* @throws ActionAbort
*/
public function preProcess() {
global $PRE;
global $TEXT;
global $INPUT;
global $ID;
global $ACT;
$opts = array(
'id' => $ID,
'preact' => $ACT,
'params' => []
);
/** 引継ぎたい GETパラメータを指定 **/
if ($INPUT->str('test')) $opts['params']['test'] = $INPUT->str('test');
//get section name when coming from section edit
if($INPUT->has('hid')) {
// Use explicitly transmitted header id
$opts['fragment'] = $INPUT->str('hid');
} else if($PRE && preg_match('/^\s*==+([^=\n]+)/', $TEXT, $match)) {
// Fallback to old mechanism
$check = false; //Byref
$opts['fragment'] = sectionID($match[0], $check);
}
// execute the redirect
Event::createAndTrigger('ACTION_SHOW_REDIRECT', $opts, array($this, 'redirect'));
// should never be reached
throw new ActionAbort('show');
}
/**
* Execute the redirect
*
* Default action for ACTION_SHOW_REDIRECT
*
* @param array $opts id and fragment for the redirect and the preact
*/
public function redirect($opts) {
$go = wl($opts['id'], $opts['params'], true, '&'); /** 第二引数を指定 **/
if(isset($opts['fragment'])) $go .= '#' . $opts['fragment'];
//show it
send_redirect($go);
}
===== 課題 =====
DokuWikiソースに手を加えなくていいよう、Plugin 化したい。