/** * Return the assembled HTML for the form. * * Each element in the form will be passed to a function named * 'form_$type'. The function should return the HTML to be printed. * * @author Tom N Harris <*****@*****.**> */ function getForm() { global $lang; $form = ''; $this->params['accept-charset'] = $lang['encoding']; $form .= '<form ' . html_attbuild($this->params) . '><div class="no">' . DOKU_LF; if (!empty($this->_hidden)) { foreach ($this->_hidden as $name => $value) { $form .= form_hidden(array('name' => $name, 'value' => $value)); } } foreach ($this->_content as $element) { if (is_array($element)) { $elem_type = $element['_elem']; if (function_exists('form_' . $elem_type)) { $form .= call_user_func('form_' . $elem_type, $element) . DOKU_LF; } } else { $form .= $element; } } if ($this->_infieldset) { $form .= form_closefieldset() . DOKU_LF; } $form .= '</div></form>' . DOKU_LF; return $form; }
/** * Adds additional fields of used by the BlogTNG plugin to the editor. */ function handle_editform_output(&$event, $param) { global $ID; $pos = $event->data->findElementByAttribute('type', 'submit'); if (!$pos) { return; } // no submit button found, source view $pos -= 1; $pid = md5($ID); $this->entryhelper->load_by_pid($pid); $blog = $this->tools->getParam('post/blog'); if (!$blog) { $blog = $this->entryhelper->get_blog(); } $blogs = $this->entryhelper->get_blogs(); $event->data->insertElement($pos, form_openfieldset(array('_legend' => 'BlogTNG', 'class' => 'edit', 'id' => 'blogtng__edit'))); $pos += 1; $event->data->insertElement($pos, form_makeMenuField('btng[post][blog]', $blogs, $blog, 'Blog', 'blogtng__blog', 'edit')); $pos += 1; $this->taghelper->load($pid); $allowed_tags = $this->_get_allowed_tags(); $tags = $this->_get_post_tags(); if (!$tags) { $tags = $this->taghelper->tags; } if (count($allowed_tags) > 0) { $event->data->insertElement($pos++, form_makeOpenTag('div')); foreach ($this->_get_allowed_tags() as $val) { $data = array('style' => 'margin-top: 0.3em;'); if (in_array($val, $tags)) { $data['checked'] = 'checked'; } $event->data->insertElement($pos++, form_makeCheckboxField('btng[post][tags][]', $val, $val, '', '', $data)); } $event->data->insertElement($pos++, form_makeCloseTag('div')); } else { $event->data->insertElement($pos, form_makeTextField('btng[post][tags]', join(', ', $tags), 'Tags', 'blogtng__tags', 'edit')); $pos += 1; } if ($this->getConf('editform_set_date')) { $postdate = $this->tools->getParam('post/date'); if ($postdate) { $YY = $postdate['YY']; $MM = $postdate['MM']; $DD = $postdate['DD']; $hh = $postdate['hh']; $mm = $postdate['mm']; } else { $created = $this->entryhelper->entry['created']; if ($created) { $YY = strftime('%Y', $created); $MM = strftime('%m', $created); $DD = strftime('%d', $created); $hh = strftime('%H', $created); $mm = strftime('%M', $created); } else { $time = mktime(); $YY = strftime('%Y', $time); $MM = strftime('%m', $time); $DD = strftime('%d', $time); $hh = strftime('%H', $time); $mm = strftime('%M', $time); } } $event->data->insertElement($pos, form_makeTextField('btng[post][date][YY]', $YY, 'YYYY', 'blogtng__date_YY', 'edit', array('maxlength' => 4))); $pos += 1; $event->data->insertElement($pos, form_makeTextField('btng[post][date][MM]', $MM, 'MM', 'blogtng__date_MM', 'edit', array('maxlength' => 2))); $pos += 1; $event->data->insertElement($pos, form_makeTextField('btng[post][date][DD]', $DD, 'DD', 'blogtng__date_DD', 'edit', array('maxlength' => 2))); $pos += 1; $event->data->insertElement($pos, form_makeTextField('btng[post][date][hh]', $hh, 'hh', 'blogtng__date_hh', 'edit', array('maxlength' => 2))); $pos += 1; $event->data->insertElement($pos, form_makeTextField('btng[post][date][mm]', $mm, 'mm', 'blogtng__date_mm', 'edit', array('maxlength' => 2))); $pos += 1; } $event->data->insertElement($pos, form_makeMenuField('btng[post][commentstatus]', array('enabled', 'closed', 'disabled'), $this->entryhelper->entry['commentstatus'], $this->getLang('commentstatus'), 'blogtng__commentstatus', 'edit')); $pos += 1; $event->data->insertElement($pos, form_closefieldset()); }
/** * printForm * * Output the form. * Each element in the form will be passed to a function named * 'form_$type'. The function should return the HTML to be printed. * * @author Tom N Harris <*****@*****.**> */ function printForm() { global $lang; print '<form action="' . $this->action . '" method="' . $this->method . '" accept-charset="' . $lang['encoding'] . '"'; if (!empty($this->id)) { print ' id="' . $this->id . '"'; } if (!empty($this->enctype)) { print ' enctype="' . $this->enctype . '"'; } print '><div class="no">' . NL; if (!empty($this->_hidden)) { foreach ($this->_hidden as $name => $value) { print form_hidden(array('name' => $name, 'value' => $value)); } } foreach ($this->_content as $element) { if (is_array($element)) { $elem_type = $element['_elem']; if (function_exists('form_' . $elem_type)) { print call_user_func('form_' . $elem_type, $element) . NL; } } else { print $element; } } if ($this->_infieldset) { print form_closefieldset() . NL; } print '</div></form>' . NL; }
/** * Add the oAuth login links * * @param Doku_Event $event event object by reference * @param mixed $param [the parameters passed as fifth argument to register_hook() when this * handler was registered] * @return void */ public function handle_loginform(Doku_Event &$event, $param) { global $conf; /** @var helper_plugin_oauth $hlp */ $hlp = plugin_load('helper', 'oauth'); $singleService = $this->getConf('singleService'); $enabledServices = $hlp->listServices(); /** @var Doku_Form $form */ $form =& $event->data; $html = ''; if ($singleService == '') { foreach ($hlp->listServices() as $service) { $html .= $this->service_html($service); } if (!$html) { return; } } else { if (in_array($singleService, $enabledServices, true) === false) { msg($this->getLang('wrongConfig'), -1); return; } $form->_content = array(); $html = $this->service_html($singleService); } $form->_content[] = form_openfieldset(array('_legend' => $this->getLang('loginwith'), 'class' => 'plugin_oauth')); $form->_content[] = $html; $form->_content[] = form_closefieldset(); }