/** * Render the field as XHTML * * Outputs the represented field using the passed Doku_Form object. * Additional parameters (CSS class & HTML name) are passed in $params. * * @params array $params Additional HTML specific parameters * @params Doku_Form $form The target Doku_Form object * @params int $formid unique identifier of the form which contains this field */ public function renderfield($params, Doku_Form $form, $formid) { $this->_handlePreload(); if (!$form->_infieldset) { $form->startFieldset(''); } if ($this->error) { $params['class'] = 'bureaucracy_error'; } $params = array_merge($this->opt, $params); list($name, $entries, $value, $label, $id, $class) = $this->_parse_tpl(array('@@NAME@@', $params['args'], '@@VALUE@@', '@@DISPLAY@@', '@@ID@@', '@@CLASS@@'), $params); $value = in_array($value, $entries) ? $value : null; $valueoffieldwithid = $value !== null ? $value : current($entries); // label $s = '<label'; $s .= ' class="radiolabel ' . $class . '"'; $s .= '><span>' . $label . '</span>'; $s .= '</label>'; $form->addElement($s); // radio fields foreach ($entries as $val) { if ($value === $val) { $attrs = array('checked' => 'checked'); } else { $attrs = array(); } if ($valueoffieldwithid === $val) { $_id = $id; //e.g. autofocus with 'focus__this' id } else { $_id = ''; } $form->addElement(form_makeRadioField($name, $val, $val, $_id, $class, $attrs)); } }
protected function getBackupForm() { $form = new \Doku_Form(['id' => 'mybackup_form']); $form->startFieldset('Folders to Backup'); foreach (Backup::allowedDirectories() as $dir => $desc) { $form->addElement(form_makeCheckboxField('dirs[]', $dir, "<b>{$dir}</b> {$desc}", null, null, ['checked' => 'checked'])); } $form->endFieldset(); $form->startFieldset('Options'); $form->addElement('<b>Logging Output</b>'); $form->addElement(form_makeCheckboxField('verbose', 1, 'verbose (it can be very long)')); $form->addElement('<br /><b>Archive Format</b>'); foreach (Backup::supportedFormats() as $ext => $enabled) { $disabled = $enabled ? [] : ['disabled' => 'disabled']; $selected = $ext != 'zip' ? [] : ['checked' => 'checked']; $form->addElement(form_makeRadioField('archive_format', $ext, strtoupper($ext), 'archive_format', '', array_merge([], $selected, $disabled))); } $form->endFieldset(); $form->addElement('<br />'); //$form->addElement(form_makeButton('button', null, 'check size')); $form->addElement(form_makeButton('submit', null, 'backup now')); return $form; }
/** * Add a radio set * * This function adds a set of radio buttons to the form. If $_POST[$name] * is set, this radio is preselected, else the first radio button. * * @param string $name The HTML field name * @param array $entries An array of entries $value => $caption * * @author Adrian Lang <*****@*****.**> */ function addRadioSet($name, $entries) { $value = isset($_POST[$name]) && isset($entries[$_POST[$name]]) ? $_POST[$name] : key($entries); foreach ($entries as $val => $cap) { $data = $value === $val ? array('checked' => 'checked') : array(); $this->addElement(form_makeRadioField($name, $val, $cap, '', '', $data)); } }
/** * Add a radio set * * This function adds a set of radio buttons to the form. If $_POST[$name] * is set, this radio is preselected, else the first radio button. * * @param string $name The HTML field name * @param array $entries An array of entries $value => $caption * * @author Adrian Lang <*****@*****.**> */ function addRadioSet($name, $entries) { global $INPUT; $value = array_key_exists($INPUT->post->str($name), $entries) ? $INPUT->str($name) : key($entries); foreach ($entries as $val => $cap) { $data = $value === $val ? array('checked' => 'checked') : array(); $this->addElement(form_makeRadioField($name, $val, $cap, '', '', $data)); } }
/** * Prints options for the tab that displays a list of all files * * @author Kate Arzamastseva <*****@*****.**> */ function media_tab_files_options() { global $lang; global $INPUT; global $ID; $form = new Doku_Form(array('class' => 'options', 'method' => 'get', 'action' => wl($ID))); $media_manager_params = media_managerURL(array(), '', false, true); foreach ($media_manager_params as $pKey => $pVal) { $form->addHidden($pKey, $pVal); } $form->addHidden('sectok', null); if ($INPUT->has('q')) { $form->addHidden('q', $INPUT->str('q')); } $form->addElement('<ul>' . NL); foreach (array('list' => array('listType', array('thumbs', 'rows')), 'sort' => array('sortBy', array('name', 'date'))) as $group => $content) { $checked = "_media_get_{$group}_type"; $checked = $checked(); $form->addElement('<li class="' . $content[0] . '">'); foreach ($content[1] as $option) { $attrs = array(); if ($checked == $option) { $attrs['checked'] = 'checked'; } $form->addElement(form_makeRadioField($group . '_dwmedia', $option, $lang['media_' . $group . '_' . $option], $content[0] . '__' . $option, $option, $attrs)); } $form->addElement('</li>' . NL); } $form->addElement('<li>'); $form->addElement(form_makeButton('submit', '', $lang['btn_apply'])); $form->addElement('</li>' . NL); $form->addElement('</ul>' . NL); $form->printForm(); }
/** * Prints options for the tab that displays a list of all files * * @author Kate Arzamastseva <*****@*****.**> */ function media_tab_files_options() { global $lang, $NS; $form = new Doku_Form(array('class' => 'options', 'method' => 'get', 'action' => media_managerURL(array(), '&'))); $form->addHidden('sectok', null); if (isset($_REQUEST['q'])) { $form->addHidden('q', $_REQUEST['q']); } $form->addElement('<ul>' . NL); foreach (array('list' => array('listType', array('thumbs', 'rows')), 'sort' => array('sortBy', array('name', 'date'))) as $group => $content) { $checked = "_media_get_{$group}_type"; $checked = $checked(); $form->addElement('<li class="' . $content[0] . '">'); foreach ($content[1] as $option) { $attrs = array(); if ($checked == $option) { $attrs['checked'] = 'checked'; } $form->addElement(form_makeRadioField($group, $option, $lang['media_' . $group . '_' . $option], $content[0] . '__' . $option, $option, $attrs)); } $form->addElement('</li>' . NL); } $form->addElement('<li>'); $form->addElement(form_makeButton('submit', '', $lang['btn_apply'])); $form->addElement('</li>' . NL); $form->addElement('</ul>' . NL); $form->printForm(); }
/** * Display the simple move form */ protected function GUI_simpleForm() { global $ID; echo $this->locale_xhtml('move'); $treelink = wl($ID, array('do' => 'admin', 'page' => 'move_tree')); echo '<p id="plugin_move__treelink">'; printf($this->getLang('treelink'), $treelink); echo '</p>'; $form = new Doku_Form(array('action' => wl($ID), 'method' => 'post', 'class' => 'plugin_move_form')); $form->addHidden('page', 'move_main'); $form->addHidden('id', $ID); $form->startFieldset($this->getLang('legend')); $form->addElement(form_makeRadioField('class', 'page', $this->getLang('movepage') . ' <code>' . $ID . '</code>', '', 'block radio click-page', array('checked' => 'checked'))); $form->addElement(form_makeRadioField('class', 'namespace', $this->getLang('movens') . ' <code>' . getNS($ID) . '</code>', '', 'block radio click-ns')); $form->addElement(form_makeTextField('dst', $ID, $this->getLang('dst'), '', 'block indent')); $form->addElement(form_makeMenuField('type', array('pages' => $this->getLang('move_pages'), 'media' => $this->getLang('move_media'), 'both' => $this->getLang('move_media_and_pages')), 'both', $this->getLang('content_to_move'), '', 'block indent select')); $form->addElement(form_makeCheckboxField('autoskip', '1', $this->getLang('autoskip'), '', 'block', $this->getConf('autoskip') ? array('checked' => 'checked') : array())); $form->addElement(form_makeCheckboxField('autorewrite', '1', $this->getLang('autorewrite'), '', 'block', $this->getConf('autorewrite') ? array('checked' => 'checked') : array())); $form->addElement(form_makeButton('submit', 'admin', $this->getLang('btn_start'))); $form->endFieldset(); $form->printForm(); }
/** * render the manage_files action * */ function render(&$event, $param) { global $ID; $perm = auth_quickaclcheck($ID); if ($event->data != 'manage_files') { return; } $event->preventDefault(); if ($perm < AUTH_READ) { echo '<h1>Error</h1><p>You do not have permission to view this page</p>'; return; } $project = Project::project(); if ($project == NULL) { echo '<h1>Error</h1>'; $project = getNS($ID); $path = explode(":", $project); if (!$project || $path[0] != PROJECTS_NAMESPACE) { echo "<p>Projects wiki has to work under the " . PROJECTS_NAMESPACE . " namespace</p>"; return; } $parent = getNS($project); if (!$parent) { echo "<p>The namespace " . PROJECTS_NAMESPACE . " has not been created yet!</p>"; return; } echo "<p>This project does not exist!</p>"; $name = noNS($parent); $link = DOKU_URL . "/doku.php?id={$parent}:{$name}&do=manage_files"; echo "<p>Go back to <a href=\"{$link}\">{$parent}</a>"; return; } echo '<h1>Manage Project ' . $project->name() . '</h1>'; $files = $project->files(); ksort($files); echo "<h1>Manage Files</h1>"; echo "<table>"; foreach (array(SOURCE, TARGET, CROSSLINK) as $type) { $count = 0; $utype = ucfirst($type); echo "<tr><td></td><td></td><td><h2>{$utype} Files</h2></td></tr>"; foreach ($files as $file) { if ($file->type() != $type) { continue; } echo "<tr>"; $name = $file->name(); echo "<td>"; if ($file->is_target() && $perm > AUTH_READ) { echo button_remake($project->id($name)); } echo "</td>"; echo "<td>"; if ($perm >= AUTH_DELETE) { echo button_delete($project->id($name)); } echo "</td>"; echo "<td>"; echo html_wikilink($project->id($name)); if ($project->error($name) != NULL) { echo "<img src=\"" . DOKU_URL . "/lib/images/error.png\"></img>"; } echo "</td>"; echo "</tr>"; $count++; } if ($count == 0) { echo "<tr><td></td><td></td><td>No {$type} files in this project</td></tr>"; } } $files = $project->subprojects(); if ($files) { sort($files); echo "<tr><td></td><td></td><td><h2>Subprojects</h2></td></tr>"; foreach ($files as $file) { $id = $project->name() . ":{$file}"; $link = DOKU_URL . "/doku.php?id={$id}:{$file}&do=manage_files"; echo "<tr><td></td><td></td><td>"; echo "<a href=\"{$link}\">{$file}</a>"; echo "</td>"; echo "</tr>"; } } echo "</table>"; $parent = $project->parent(); if ($parent != NULL) { echo "<h1>Parent project</h1>"; $name = $parent->name(); $file = end(explode(":", $name)); $link = DOKU_URL . "/doku.php?id={$name}:{$file}&do=manage_files"; echo "<a href=\"{$link}\">{$name}</a>"; } if ($perm <= AUTH_READ) { return; } echo "<p/><h1>Create Files</h1>"; $create = new Doku_Form("Create"); $create->addHidden("do", "create"); $create->addHidden("page", "projects_manage_files"); $create->addHidden("id", $ID); $create->startFieldSet('Create a new file'); $create->addElement(form_makeOpenTag("p")); $create->addElement(form_makeField('text', 'File name')); $create->addElement(form_makeCloseTag("p")); $create->addElement(form_makeOpenTag("p")); $create->addElement(form_makeRadioField('Type', SOURCE, "Source", "", "", array('checked' => "true"))); $create->addElement(form_makeRadioField('Type', TARGET, 'Generated')); $create->addElement(form_makeRadioField('Type', CROSSLINK, 'Crosslink')); $create->addElement(form_makeCloseTag("p")); $create->addElement(form_makeButton("submit", '', "Create")); $create->endFieldSet(); echo $create->getForm(); echo "<h1>Create subproject</h1>"; $subproject = new Doku_Form("Subproject"); $subproject->addHidden("do", "create_subproject"); $subproject->addHidden("page", "projects_manage_files"); $subproject->addHidden("id", $ID); $subproject->startFieldSet('Create a new subproject'); $subproject->addElement(form_makeOpenTag("p")); $subproject->addElement(form_makeField('text', 'Project name')); $subproject->addElement(form_makeCloseTag("p")); $subproject->addElement(form_makeButton("submit", '', "Create sub-project")); $subproject->endFieldSet(); echo $subproject->getForm(); echo "<h1>Clean up</h1>"; $clean = new Doku_Form("Clean"); $clean->addHidden("do", "clean"); $clean->addHidden("page", "projects_manage_files"); $clean->addHidden("id", $ID); $clean->startFieldSet('Clean the project'); $clean->addElement(form_makeCheckboxField("Recursive")); $clean->addElement(form_makeButton("submit", "", "Clean")); $clean->endFieldSet(); echo $clean->getForm(); if ($perm < AUTH_ADMIN) { return; } echo "<h1>Rebuild the project</h1>"; $rebuild = new Doku_Form("rebuild"); $rebuild->addHidden("do", "rebuild"); $rebuild->addHidden("page", "projects_manage_files"); $rebuild->addHidden("id", $ID); $rebuild->startFieldSet('Rebuild the project'); $rebuild->addElement(form_makeButton("submit", '', "Rebuild")); $rebuild->endFieldSet(); echo $rebuild->getForm(); }