/** * Display the default edit form * * Is the default action for HTML_EDIT_FORMSELECTION. */ function html_edit_form($param) { global $TEXT; if ($param['target'] !== 'section') { msg('No editor for edit target ' . hsc($param['target']) . ' found.', -1); } $attr = array('tabindex' => '1'); if (!$param['wr']) { $attr['readonly'] = 'readonly'; } $param['form']->addElement(form_makeWikiText($TEXT, $attr)); }
/** * Prints the comment form * * FIXME * allow comments only for registered users * add toolbar */ function tpl_form($page, $pid) { global $INFO; global $BLOGTNG; $form = new DOKU_Form('blogtng__comment_form', wl($page) . '#blogtng__comment_form'); $form->addHidden('pid', $pid); $form->addHidden('id', $page); $form->addHidden('btng[comment][source]', 'comment'); foreach (array('name', 'mail', 'web') as $field) { $attr = $BLOGTNG['comment_submit_errors'][$field] ? array('class' => 'edit error') : array(); if ($field == 'web' && !$this->getConf('comments_allow_web')) { continue; } else { $form->addElement(form_makeTextField('btng[comment][' . $field . ']', $BLOGTNG['comment'][$field], $this->getLang('comment_' . $field), 'blogtng__comment_' . $field, 'edit block', $attr)); } } $form->addElement(form_makeOpenTag('div', array('class' => 'blogtng__toolbar'))); $form->addElement(form_makeCloseTag('div')); if ($BLOGTNG['comment_submit_errors']['text']) { $form->addElement(form_makeWikiText($BLOGTNG['comment']['text'], array('class' => 'edit error'))); } else { $form->addElement(form_makeWikiText($BLOGTNG['comment']['text'])); } //add captcha if available $helper = null; if (@is_dir(DOKU_PLUGIN . 'captcha')) { $helper = plugin_load('helper', 'captcha'); } if (!is_null($helper) && $helper->isEnabled()) { $form->addElement($helper->getHTML()); } $form->addElement(form_makeButton('submit', 'comment_preview', $this->getLang('comment_preview'), array('class' => 'button', 'id' => 'blogtng__preview_submit'))); $form->addElement(form_makeButton('submit', 'comment_submit', $this->getLang('comment_submit'), array('class' => 'button', 'id' => 'blogtng__comment_submit'))); if ($this->getConf('comments_subscription')) { $form->addElement(form_makeCheckboxField('blogtng[subscribe]', 1, $this->getLang('comment_subscribe'))); } print '<div id="blogtng__comment_form_wrap">' . DOKU_LF; $form->printForm(); if (isset($BLOGTNG['comment_action']) && $BLOGTNG['comment_action'] == 'preview' && empty($BLOGTNG['comment_submit_errors'])) { print '<div id="blogtng__comment_preview">' . DOKU_LF; $comment = new blogtng_comment(); $comment->data = $BLOGTNG['comment']; $comment->data['cid'] = 'preview'; $comment->output('default'); print '</div>' . DOKU_LF; } print '</div>' . DOKU_LF; }
/** * This displays the edit form (lots of logic included) * * @fixme this is a huge lump of code and should be modularized * @triggers HTML_PAGE_FROMTEMPLATE * @triggers HTML_EDITFORM_INJECTION * @author Andreas Gohr <*****@*****.**> */ function html_edit($text = null, $include = 'edit') { //FIXME: include needed? global $ID; global $REV; global $DATE; global $RANGE; global $PRE; global $SUF; global $INFO; global $SUM; global $lang; global $conf; global $license; //set summary default if (!$SUM) { if ($REV) { $SUM = $lang['restored']; } elseif (!$INFO['exists']) { $SUM = $lang['created']; } } //no text? Load it! if (!isset($text)) { $pr = false; //no preview mode if ($INFO['exists']) { if ($RANGE) { list($PRE, $text, $SUF) = rawWikiSlices($RANGE, $ID, $REV); } else { $text = rawWiki($ID, $REV); } $check = md5($text); $mod = false; } else { //try to load a pagetemplate $data = array($ID); $text = trigger_event('HTML_PAGE_FROMTEMPLATE', $data, 'pageTemplate', true); $check = md5(''); $mod = $text !== ''; } } else { $pr = true; //preview mode if (isset($_REQUEST['changecheck'])) { $check = $_REQUEST['changecheck']; $mod = md5($text) !== $check; } else { // Why? Assume default text is unmodified. $check = md5($text); $mod = false; } } $wr = $INFO['writable'] && !$INFO['locked']; if ($wr) { if ($REV) { print p_locale_xhtml('editrev'); } print p_locale_xhtml($include); } else { // check pseudo action 'source' if (!actionOK('source')) { msg('Command disabled: source', -1); return; } print p_locale_xhtml('read'); } if (!$DATE) { $DATE = $INFO['lastmod']; } ?> <div style="width:99%;"> <div class="toolbar"> <div id="draft__status"><?php if (!empty($INFO['draft'])) { echo $lang['draftdate'] . ' ' . strftime($conf['dformat']); } ?> </div> <div id="tool__bar"><?php if ($wr) { ?> <a href="<?php echo DOKU_BASE; ?> lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']; ?> " target="_blank"><?php echo $lang['mediaselect']; ?> </a><?php } ?> </div> <?php if ($wr) { ?> <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!-- <?php /* sets changed to true when previewed */ ?> textChanged = <?php $mod ? print 'true' : (print 'false'); ?> ; //--><!]]></script> <span id="spell__action"></span> <div id="spell__suggest"></div> <?php } ?> </div> <div id="spell__result"></div> <?php $form = new Doku_Form('dw__editform'); $form->addHidden('id', $ID); $form->addHidden('rev', $REV); $form->addHidden('date', $DATE); $form->addHidden('prefix', $PRE); $form->addHidden('suffix', $SUF); $form->addHidden('changecheck', $check); $attr = array('tabindex' => '1'); if (!$wr) { $attr['readonly'] = 'readonly'; } $form->addElement(form_makeWikiText($text, $attr)); $form->addElement(form_makeOpenTag('div', array('id' => 'wiki__editbar'))); $form->addElement(form_makeOpenTag('div', array('id' => 'size__ctl'))); $form->addElement(form_makeCloseTag('div')); if ($wr) { $form->addElement(form_makeOpenTag('div', array('class' => 'editButtons'))); $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id' => 'edbtn__save', 'accesskey' => 's', 'tabindex' => '4'))); $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id' => 'edbtn__preview', 'accesskey' => 'p', 'tabindex' => '5'))); $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex' => '6'))); $form->addElement(form_makeCloseTag('div')); $form->addElement(form_makeOpenTag('div', array('class' => 'summary'))); $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size' => '50', 'tabindex' => '2'))); $elem = html_minoredit(); if ($elem) { $form->addElement($elem); } $form->addElement(form_makeCloseTag('div')); } $form->addElement(form_makeCloseTag('div')); if ($conf['license']) { $form->addElement(form_makeOpenTag('div', array('class' => 'license'))); $out = $lang['licenseok']; $out .= '<a href="' . $license[$conf['license']]['url'] . '" rel="license" class="urlextern"'; if ($conf['target']['external']) { $out .= ' target="' . $conf['target']['external'] . '"'; } $out .= '> ' . $license[$conf['license']]['name'] . '</a>'; $form->addElement($out); $form->addElement(form_makeCloseTag('div')); } html_form('edit', $form); print '</div>' . NL; }
/** * Display the default edit form * * Is the default action for HTML_EDIT_FORMSELECTION. * * @triggers HTML_EDITFORM_OUTPUT */ function html_edit_form($param) { extract($param); global $conf; global $license; global $lang; global $REV; global $DATE; global $PRE; global $SUF; global $INFO; global $SUM; global $ID; ?> <?php if ($wr) { ?> <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!-- <?php /* sets changed to true when previewed */ ?> textChanged = <?php $mod ? print 'true' : (print 'false'); ?> ; //--><!]]></script> <?php } ?> <div style="width:99%;"> <div class="toolbar"> <div id="draft__status"><?php if (!empty($INFO['draft'])) { echo $lang['draftdate'] . ' ' . dformat(); } ?> </div> <div id="tool__bar"><?php if ($wr) { ?> <a href="<?php echo DOKU_BASE; ?> lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']; ?> " target="_blank"><?php echo $lang['mediaselect']; ?> </a><?php } ?> </div> </div> <?php $form = new Doku_Form(array('id' => 'dw__editform')); $form->addHidden('id', $ID); $form->addHidden('rev', $REV); $form->addHidden('date', $DATE); $form->addHidden('prefix', $PRE); $form->addHidden('suffix', $SUF); $form->addHidden('changecheck', $check); $attr = array('tabindex' => '1'); if (!$wr) { $attr['readonly'] = 'readonly'; } $form->addElement(form_makeWikiText($text, $attr)); $form->addElement(form_makeOpenTag('div', array('id' => 'wiki__editbar'))); $form->addElement(form_makeOpenTag('div', array('id' => 'size__ctl'))); $form->addElement(form_makeCloseTag('div')); if ($wr) { $form->addElement(form_makeOpenTag('div', array('class' => 'editButtons'))); $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id' => 'edbtn__save', 'accesskey' => 's', 'tabindex' => '4'))); $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id' => 'edbtn__preview', 'accesskey' => 'p', 'tabindex' => '5'))); $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex' => '6'))); $form->addElement(form_makeCloseTag('div')); $form->addElement(form_makeOpenTag('div', array('class' => 'summary'))); $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size' => '50', 'tabindex' => '2'))); $elem = html_minoredit(); if ($elem) { $form->addElement($elem); } $form->addElement(form_makeCloseTag('div')); } $form->addElement(form_makeCloseTag('div')); if ($wr && $conf['license']) { $form->addElement(form_makeOpenTag('div', array('class' => 'license'))); $out = $lang['licenseok']; $out .= '<a href="' . $license[$conf['license']]['url'] . '" rel="license" class="urlextern"'; if (isset($conf['target']['external'])) { $out .= ' target="' . $conf['target']['external'] . '"'; } $out .= '> ' . $license[$conf['license']]['name'] . '</a>'; $form->addElement($out); $form->addElement(form_makeCloseTag('div')); } html_form('edit', $form); print '</div>' . NL; }