示例#1
0
 /**
  * Builds a select box with all available templates
  *  (unless excluded in 'excludeTemplates')
  *  or show only two templates for mobile switcher: standard plus mobile template
  *
  * @author Anika Henke <*****@*****.**>
  */
 public function showTemplateSwitcher()
 {
     global $conf;
     global $ID;
     global $ACT;
     if ($ACT != 'show') {
         return;
     }
     $mobileSwitch = $this->getConf('mobileSwitch');
     $mobileTpl = $this->getConf('mobileTemplate');
     if ($mobileSwitch && $mobileTpl) {
         // templates for mobile switcher
         $templates = array($mobileTpl => $this->getLang('switchMobile'), $this->origTpl => $this->getLang('switchFull'));
     } else {
         // all templates (minus excluded templates)
         $excludeTemplates = array_map('trim', explode(",", $this->getConf('excludeTemplates')));
         $templates = array_diff($this->getTemplates(), $excludeTemplates);
     }
     $form = new Doku_Form(array('id' => 'tpl__switcher', 'title' => $this->getLang('switchTpl'), 'action' => wl($ID)));
     $form->addHidden('act', 'select');
     $form->addElement(form_makeListboxField('tpl', $templates, $conf['template'], $this->getLang('template'), '', '', array('class' => 'quickselect')));
     $form->addElement(form_makeButton('submit', '', $this->getLang('switch'), array('name' => 'switch')));
     $out = '<div class="plugin_loadskin">';
     $out .= $form->getForm();
     $out .= '</div>';
     return $out;
 }
示例#2
0
 public function xhtml($editor_id, $do)
 {
     $controls = '<div>';
     if (!$this->read_only) {
         $form = new Doku_Form(array('class' => 'editor_edit_form', 'editor' => $editor_id));
         $form->addElement(form_makeButton('submit', '', 'edit'));
         $controls .= $form->getForm();
         $controls .= '<div class="editor_save_controls">';
         $form = new Doku_Form(array('class' => 'editor_save_form', 'editor' => $editor_id));
         $form->addElement(form_makeButton('submit', 'savecontent', 'save'));
         $controls .= $form->getForm() . cancel_button() . '</div>';
     }
     return $controls . $this->editor_xhtml($editor_id, $do) . '</div>';
 }
示例#3
0
 /**
  * Create output
  */
 function render($mode, Doku_Renderer $renderer, $data)
 {
     if (!$data || $mode != 'xhtml') {
         return;
     }
     $id = $data['id'];
     $from = $data['from'];
     $to = $data['to'];
     $form = new Doku_Form(array('id' => "slice_{$from_to}", "class" => "wiki_slice_form"));
     $form->addHidden('from', $from);
     $form->addHidden('to', $to);
     $form->addHidden('id', $id);
     $form->addElement(form_makeButton('submit', '', "Slice {$from}--{$to}"));
     $renderer->doc .= $form->getForm();
 }
示例#4
0
function xhtml_action($action, $title, $hidden_fields = array(), $fields = array())
{
    $hidden_fields['do'] = $action;
    $name = preg_replace('/[^0-9A-Za-z_]+/', '_', $title);
    $formID = "PROJECTS_{$name_form}";
    $form = new Doku_Form(array('id' => $formID));
    foreach ($hidden_fields as $name => $value) {
        $form->addHidden($name, $value);
    }
    foreach ($fields as $field) {
        $form->addElement($field);
    }
    $form->addElement("<a href=\"\" class=\"action_link\">{$title}</a>");
    return '<span class="action">' . $form->getForm() . '</span>';
}
示例#5
0
function action_button($button_name, $action = '', $hidden = NULL)
{
    global $ID;
    $form = new Doku_Form('Form_' . $button_name);
    if (!$action) {
        $action = $button_name;
    }
    $form->addHidden('do', $action);
    if (is_array($hidden)) {
        foreach ($hidden as $key => $value) {
            $form->addHidden($key, $value);
        }
    }
    $form->addElement(form_makeButton('submit', '', $button_name));
    return $form->getForm();
}
示例#6
0
 function preList($clist, $data)
 {
     global $ID;
     global $conf;
     // Save current request params to not loose them
     $cur_params = array();
     if (isset($_REQUEST['dataflt'])) {
         $cur_params = $this->dthlp->_a2ua('dataflt', $_REQUEST['dataflt']);
     }
     if (isset($_REQUEST['datasrt'])) {
         $cur_params['datasrt'] = $_REQUEST['datasrt'];
     }
     if (isset($_REQUEST['dataofs'])) {
         $cur_params['dataofs'] = $_REQUEST['dataofs'];
     }
     // build table
     $text = '<div class="table dataaggregation">' . '<table class="inline dataplugin_table ' . $data['classes'] . '">';
     // build column headers
     $text .= '<tr>';
     foreach ($data['headers'] as $num => $head) {
         $ckey = $clist[$num];
         $text .= '<th>';
         // add sort arrow
         if (isset($data['sort']) && $ckey == $data['sort'][0]) {
             if ($data['sort'][1] == 'ASC') {
                 $text .= '<span>&darr;</span> ';
                 $ckey = '^' . $ckey;
             } else {
                 $text .= '<span>&uarr;</span> ';
             }
         }
         // Clickable header for dynamic sorting
         $text .= '<a href="' . wl($ID, array('datasrt' => $ckey) + $cur_params) . '" title="' . $this->getLang('sort') . '">' . hsc($head) . '</a>';
         $text .= '</th>';
     }
     $text .= '</tr>';
     // Dynamic filters
     if ($data['dynfilters']) {
         $text .= '<tr class="dataflt">';
         foreach ($data['headers'] as $num => $head) {
             $text .= '<th>';
             $form = new Doku_Form(array('method' => 'GET'));
             $form->_hidden = array();
             if (!$conf['userewrite']) {
                 $form->addHidden('id', $ID);
             }
             $key = 'dataflt[' . $data['cols'][$clist[$num]]['colname'] . '*~' . ']';
             $val = isset($cur_params[$key]) ? $cur_params[$key] : '';
             // Add current request params
             foreach ($cur_params as $c_key => $c_val) {
                 if ($c_val !== '' && $c_key !== $key) {
                     $form->addHidden($c_key, $c_val);
                 }
             }
             $form->addElement(form_makeField('text', $key, $val, ''));
             $text .= $form->getForm();
             $text .= '</th>';
         }
         $text .= '</tr>';
     }
     return $text;
 }
示例#7
0
 public function __construct($parent, $file, $read_only)
 {
     parent::__construct($parent, 'Recipe');
     $editor = Projects_Editor_Manager::manager()->editor('', $file->code(), $file->highlight());
     $editor->read_only = $read_only;
     $maker = $this->newElement('div', array(), 'Maker: ');
     $this->root->appendChild($maker);
     if (auth_quickaclcheck($file->id()) >= DOKU_EDIT) {
         $makers = Projects_Maker_Manager::manager()->maker($file);
         if (count($makers) > 1) {
             $select = $this->newElement('select', array('id' => 'PROJECTS_maker', 'name' => 'maker'));
             $maker->appendChild($select);
             foreach ($makers as $m) {
                 $prop = array('value' => $m->name());
                 if ($m->name() == $file->maker()) {
                     $prop['selected'] = 1;
                 }
                 $opt = $this->newElement('option', $prop, $m->name());
                 $select->appendChild($opt);
             }
             $controls = $this->newElement('span', array('id' => 'maker_controls', 'maker' => $file->maker()));
             $maker->appendChild($controls);
             $form = new Doku_Form(array('id' => 'maker_select_form'));
             $form->addElement(form_makeButton('submit', 'set_maker', 'update', array('id' => 'set_maker')));
             $controls->appendChild($this->loadElement($form->getForm()));
             $controls->appendChild($this->loadElement(cancel_button()));
         } else {
             $m = $makers ? $makers[0]->name() : 'none';
             $maker->appendChild($this->newText($m));
         }
     } else {
         $maker->appendChild($this->newText('Maker: ' . $file->maker()));
     }
     $content = $editor->xhtml('recipe', 'savecontent');
     $this->root->appendChild($this->loadElement("<div>{$content}</div>"));
 }
示例#8
0
/**
 * Create html for revision navigation
 *
 * @param PageChangeLog $pagelog changelog object of current page
 * @param string        $type    inline vs sidebyside
 * @param int           $l_rev   left revision timestamp
 * @param int           $r_rev   right revision timestamp
 * @return string[] html of left and right navigation elements
 */
function html_diff_navigation($pagelog, $type, $l_rev, $r_rev)
{
    global $INFO, $ID;
    // last timestamp is not in changelog, retrieve timestamp from metadata
    // note: when page is removed, the metadata timestamp is zero
    if (!$r_rev) {
        if (isset($INFO['meta']['last_change']['date'])) {
            $r_rev = $INFO['meta']['last_change']['date'];
        } else {
            $r_rev = 0;
        }
    }
    //retrieve revisions with additional info
    list($l_revs, $r_revs) = $pagelog->getRevisionsAround($l_rev, $r_rev);
    $l_revisions = array();
    if (!$l_rev) {
        $l_revisions[0] = array(0, "", false);
        //no left revision given, add dummy
    }
    foreach ($l_revs as $rev) {
        $info = $pagelog->getRevisionInfo($rev);
        $l_revisions[$rev] = array($rev, dformat($info['date']) . ' ' . editorinfo($info['user'], true) . ' ' . $info['sum'], $r_rev ? $rev >= $r_rev : false);
    }
    $r_revisions = array();
    if (!$r_rev) {
        $r_revisions[0] = array(0, "", false);
        //no right revision given, add dummy
    }
    foreach ($r_revs as $rev) {
        $info = $pagelog->getRevisionInfo($rev);
        $r_revisions[$rev] = array($rev, dformat($info['date']) . ' ' . editorinfo($info['user'], true) . ' ' . $info['sum'], $rev <= $l_rev);
    }
    //determine previous/next revisions
    $l_index = array_search($l_rev, $l_revs);
    $l_prev = $l_revs[$l_index + 1];
    $l_next = $l_revs[$l_index - 1];
    if ($r_rev) {
        $r_index = array_search($r_rev, $r_revs);
        $r_prev = $r_revs[$r_index + 1];
        $r_next = $r_revs[$r_index - 1];
    } else {
        //removed page
        if ($l_next) {
            $r_prev = $r_revs[0];
        } else {
            $r_prev = null;
        }
        $r_next = null;
    }
    /*
     * Left side:
     */
    $l_nav = '';
    //move back
    if ($l_prev) {
        $l_nav .= html_diff_navigationlink($type, 'diffbothprevrev', $l_prev, $r_prev);
        $l_nav .= html_diff_navigationlink($type, 'diffprevrev', $l_prev, $r_rev);
    }
    //dropdown
    $form = new Doku_Form(array('action' => wl()));
    $form->addHidden('id', $ID);
    $form->addHidden('difftype', $type);
    $form->addHidden('rev2[1]', $r_rev);
    $form->addHidden('do', 'diff');
    $form->addElement(form_makeListboxField('rev2[0]', $l_revisions, $l_rev, '', '', '', array('class' => 'quickselect')));
    $form->addElement(form_makeButton('submit', 'diff', 'Go'));
    $l_nav .= $form->getForm();
    //move forward
    if ($l_next && ($l_next < $r_rev || !$r_rev)) {
        $l_nav .= html_diff_navigationlink($type, 'diffnextrev', $l_next, $r_rev);
    }
    /*
     * Right side:
     */
    $r_nav = '';
    //move back
    if ($l_rev < $r_prev) {
        $r_nav .= html_diff_navigationlink($type, 'diffprevrev', $l_rev, $r_prev);
    }
    //dropdown
    $form = new Doku_Form(array('action' => wl()));
    $form->addHidden('id', $ID);
    $form->addHidden('rev2[0]', $l_rev);
    $form->addHidden('difftype', $type);
    $form->addHidden('do', 'diff');
    $form->addElement(form_makeListboxField('rev2[1]', $r_revisions, $r_rev, '', '', '', array('class' => 'quickselect')));
    $form->addElement(form_makeButton('submit', 'diff', 'Go'));
    $r_nav .= $form->getForm();
    //move forward
    if ($r_next) {
        if ($pagelog->isCurrentRevision($r_next)) {
            $r_nav .= html_diff_navigationlink($type, 'difflastrev', $l_rev);
            //last revision is diff with current page
        } else {
            $r_nav .= html_diff_navigationlink($type, 'diffnextrev', $l_rev, $r_next);
        }
        $r_nav .= html_diff_navigationlink($type, 'diffbothnextrev', $l_next, $r_next);
    }
    return array($l_nav, $r_nav);
}
示例#9
0
 private function button_rename_use($range)
 {
     global $ID;
     if (auth_quickaclcheck($ID) < AUTH_EDIT) {
         return '';
     }
     $self = noNS($ID);
     $project = Project::project();
     if ($project == NULL) {
         return '';
     }
     $files = array('');
     foreach (array_keys($project->files()) as $file) {
         if ($file != $self) {
             $files[] = $file;
         }
     }
     $form = new Doku_Form("change_use");
     $form->addHidden('do', 'change_use');
     $form->addHidden('range', $range);
     $form->addElement(form_makeMenuField('use', $files, '', '', '', '', array("onchange" => "submit();")));
     return $form->getForm();
 }
示例#10
0
 /**
  * Create table header
  *
  * @param array $clist keys of the columns
  * @param array $data instruction by handler
  * @return string html of table header
  */
 function preList($clist, $data)
 {
     global $ID;
     global $conf;
     // Save current request params to not loose them
     $cur_params = $this->dthlp->_get_current_param();
     //show active filters
     $text = '<div class="table dataaggregation">';
     if (isset($_REQUEST['dataflt'])) {
         $filters = $this->dthlp->_get_filters();
         $fltrs = array();
         foreach ($filters as $filter) {
             if (strpos($filter['compare'], 'LIKE') !== false) {
                 if (strpos($filter['compare'], 'NOT') !== false) {
                     $comparator_value = '!~' . str_replace('%', '*', $filter['value']);
                 } else {
                     $comparator_value = '*~' . str_replace('%', '', $filter['value']);
                 }
                 $fltrs[] = $filter['key'] . $comparator_value;
             } else {
                 $fltrs[] = $filter['key'] . $filter['compare'] . $filter['value'];
             }
         }
         $text .= '<div class="filter">';
         $text .= '<h4>' . sprintf($this->getLang('tablefilteredby'), hsc(implode(' & ', $fltrs))) . '</h4>';
         $text .= '<div class="resetfilter">' . '<a href="' . wl($ID) . '">' . $this->getLang('tableresetfilter') . '</a>' . '</div>';
         $text .= '</div>';
     }
     // build table
     $text .= '<table class="inline dataplugin_table ' . $data['classes'] . '">';
     // build column headers
     $text .= '<tr>';
     if ($data['rownumbers']) {
         $text .= '<th>#</th>';
     }
     foreach ($data['headers'] as $num => $head) {
         $ckey = $clist[$num];
         $width = '';
         if (isset($data['widths'][$num]) and $data['widths'][$num] != '-') {
             $width = ' style="width: ' . $data['widths'][$num] . ';"';
         }
         $text .= '<th' . $width . '>';
         // add sort arrow
         if (isset($data['sort']) && $ckey == $data['sort'][0]) {
             if ($data['sort'][1] == 'ASC') {
                 $text .= '<span>&darr;</span> ';
                 $ckey = '^' . $ckey;
             } else {
                 $text .= '<span>&uarr;</span> ';
             }
         }
         // Clickable header for dynamic sorting
         $text .= '<a href="' . wl($ID, array('datasrt' => $ckey) + $cur_params) . '" title="' . $this->getLang('sort') . '">' . hsc($head) . '</a>';
         $text .= '</th>';
     }
     $text .= '</tr>';
     // Dynamic filters
     if ($data['dynfilters']) {
         $text .= '<tr class="dataflt">';
         if ($data['rownumbers']) {
             $text .= '<th></th>';
         }
         foreach ($data['headers'] as $num => $head) {
             $text .= '<th>';
             $form = new Doku_Form(array('method' => 'GET'));
             $form->_hidden = array();
             if (!$conf['userewrite']) {
                 $form->addHidden('id', $ID);
             }
             $key = 'dataflt[' . $data['cols'][$clist[$num]]['colname'] . '*~' . ']';
             $val = isset($cur_params[$key]) ? $cur_params[$key] : '';
             // Add current request params
             foreach ($cur_params as $c_key => $c_val) {
                 if ($c_val !== '' && $c_key !== $key) {
                     $form->addHidden($c_key, $c_val);
                 }
             }
             $form->addElement(form_makeField('text', $key, $val, ''));
             $text .= $form->getForm();
             $text .= '</th>';
         }
         $text .= '</tr>';
     }
     return $text;
 }
示例#11
0
 function _renderReviews($id, $meta, $parid)
 {
     # Check for permission to write reviews
     $mod = canReview($id, $meta, $parid);
     # No reviews and no moderator privileges => no review block
     if (!$mod && empty($meta[$parid]['reviews'])) {
         return '';
     }
     $ret = "<div class=\"dokutranslate_review\">\n";
     $ret .= '<h5>' . $this->getLang('review_header') . "</h5>\n";
     $ret .= "<table>\n";
     $listbox = array(array('0', $this->getLang('trans_wrong')), array('1', $this->getLang('trans_rephrase')), array('2', $this->getLang('trans_accepted')));
     # Prepare review form for current user
     if ($mod) {
         if (isset($meta[$parid]['reviews'][$_SERVER['REMOTE_USER']])) {
             $myReview = $meta[$parid]['reviews'][$_SERVER['REMOTE_USER']];
         } else {
             $myReview = array('message' => '', 'quality' => 0, 'incomplete' => false);
         }
         $form = new Doku_Form(array());
         $form->addHidden('parid', strval($parid));
         $form->addHidden('do', 'dokutranslate_review');
         $form->addElement(form_makeTextField('review', $myReview['message'], $this->getLang('trans_message'), '', 'nowrap', array('size' => '50')));
         $form->addElement(form_makeMenuField('quality', $listbox, strval($myReview['quality']), $this->getLang('trans_quality'), '', 'nowrap'));
         $args = array();
         if ($myReview['incomplete']) {
             $args['checked'] = 'checked';
         }
         $form->addElement(form_makeCheckboxField('incomplete', '1', $this->getLang('trans_incomplete'), '', 'nowrap', $args));
         $form->addElement(form_makeButton('submit', '', $this->getLang('add_review')));
     }
     # Display all reviews for this paragraph
     while (list($key, $value) = each($meta[$parid]['reviews'])) {
         $ret .= '<tr><td>' . hsc($key) . '</td><td>';
         # Moderators can modify their own review
         if ($mod && $key == $_SERVER['REMOTE_USER']) {
             $ret .= $form->getForm();
         } else {
             $ret .= '(' . $listbox[$value['quality']][1];
             if ($value['incomplete']) {
                 $ret .= ', ' . $this->getLang('rend_incomplete');
             }
             $ret .= ') ';
             $ret .= hsc($value['message']);
         }
         $ret .= "</td></tr>\n";
     }
     # Current user is a moderator who didn't write a review yet,
     # display the review form at the end
     if ($mod && !isset($meta[$parid]['reviews'][$_SERVER['REMOTE_USER']])) {
         if (empty($meta[$parid]['reviews'])) {
             $ret .= '<tr><td>';
         } else {
             $ret .= '<tr><td colspan="2">';
         }
         $ret .= $form->getForm();
         $ret .= "</td></tr>\n";
     }
     $ret .= "</table></div>\n";
     return $ret;
 }
 /**
  * Displays the Bookmanager - Let organize selections and export them
  * Only visible when a selection is loaded from the save selections or from cookie
  *
  * @param Doku_renderer_xhtml $renderer
  * @param bool                $usercansave User has permissions to save the selection
  * @return bool false: empty cookie, true: selection found and bookmanager is rendered
  */
 private function showBookManager($renderer, $usercansave)
 {
     global $ID;
     global $INPUT;
     $title = '';
     // get a saved selection array from file
     $list = $_COOKIE['bookcreator'];
     // title
     $bookcreator_title = $INPUT->post->str('bookcreator_title');
     if (!empty($bookcreator_title)) {
         $title = $bookcreator_title;
     } elseif (isset($_COOKIE['bookcreator_title'])) {
         $title = $_COOKIE['bookcreator_title'];
     }
     //start main container - open left column
     $renderer->doc .= "<div class='bookcreator__manager'><div class='bookcreator__pagelist' >";
     // Display pagelists
     // - selected pages
     $this->showPagelist($renderer, $list, 'include');
     $renderer->doc .= "<br />";
     // - excluded pages
     $renderer->doc .= '<div id="bookcreator__delpglst">';
     $this->showPagelist($renderer, $list, 'remove');
     $renderer->doc .= '</div>';
     // Reset current selection
     $form = new Doku_Form(array('method' => 'post', 'class' => 'clearactive'));
     $form->addElement(form_makeButton('submit', 'clearactiveselection', $this->getLang('reset')));
     $renderer->doc .= "<div align='center'>";
     $renderer->doc .= $form->getForm();
     $renderer->doc .= "</div>";
     //close left column - open right column
     $renderer->doc .= "</div>";
     $renderer->doc .= "<div class='bookcreator__actions'>";
     // PDF Export
     $values = array('export_html' => $this->getLang('exportprint'));
     $selected = 'export_html';
     if (file_exists(DOKU_PLUGIN . "text/renderer.php") && !plugin_isdisabled("text")) {
         $values['export_text'] = $this->getLang('exporttext');
     }
     if (file_exists(DOKU_PLUGIN . "odt/action/export.php") && !plugin_isdisabled("odt")) {
         $values['export_odtbook'] = $this->getLang('exportodt');
         $selected = 'export_odtbook';
     }
     if (file_exists(DOKU_PLUGIN . "dw2pdf/action.php") && !plugin_isdisabled("dw2pdf")) {
         $values['export_pdfbook'] = $this->getLang('exportpdf');
         $selected = 'export_pdfbook';
     }
     $form = new Doku_Form(array('method' => 'get'));
     $form->startFieldset($this->getLang('export'));
     $form->addElement($this->getLang('title') . " ");
     $form->addElement(form_makeTextField('book_title', $title, '', '', 'edit', array('size' => 40)));
     $form->addElement(form_makeListboxField('do', $values, $selected, '', '', '', array('size' => 1)));
     $form->addHidden('id', $ID);
     $form->addElement(form_makeButton('submit', '', $this->getLang('create')));
     $form->endFieldset();
     $renderer->doc .= $form->getForm();
     // Save current selection to a wikipage
     if ($usercansave) {
         $form = new Doku_Form(array('method' => 'post'));
         $form->startFieldset($this->getLang('saveselection'));
         $form->addElement(form_makeTextField('bookcreator_title', $title, '', '', 'edit'));
         $form->addHidden('task', 'save');
         $form->addElement(form_makeButton('submit', '', $this->getLang('save')));
         $form->endFieldset();
         $renderer->doc .= $form->getForm();
     }
     //close containers
     $renderer->doc .= '</div>';
     $renderer->doc .= "</div><div class='clearer'></div>";
     $renderer->doc .= "<br />";
     return true;
 }
示例#13
0
 /**
  * Displays a form to create new entries
  *
  * @param $conf
  * @return string
  */
 public function xhtml_newform($conf)
 {
     global $ID;
     // allowed to create?
     if (!$this->toolshelper) {
         $this->toolshelper = plugin_load('helper', 'blogtng_tools');
     }
     $new = $this->toolshelper->mkpostid($conf['format'], 'dummy');
     if (auth_quickaclcheck($new) < AUTH_CREATE) {
         return '';
     }
     $form = new Doku_Form($ID, wl($ID, array('do' => 'btngnew'), false, '&'));
     if ($conf['title']) {
         $form->addElement(form_makeOpenTag('h3'));
         $form->addElement(hsc($conf['title']));
         $form->addElement(form_makeCloseTag('h3'));
     }
     if (isset($conf['select'])) {
         $form->addElement(form_makeMenuField('btng[new][title]', helper_plugin_blogtng_tools::filterExplodeCSVinput($conf['select']), '', $this->getLang('title'), 'btng__nt', 'edit'));
     } else {
         $form->addElement(form_makeTextField('btng[new][title]', '', $this->getLang('title'), 'btng__nt', 'edit'));
     }
     if ($conf['tags']) {
         if ($conf['tags'][0] == '?') {
             $conf['tags'] = helper_plugin_blogtng_tools::filterExplodeCSVinput($this->getConf('default_tags'));
         }
         $form->addElement(form_makeTextField('btng[post][tags]', implode(', ', $conf['tags']), $this->getLang('tags'), 'btng__ntags', 'edit'));
     }
     if ($conf['type']) {
         if ($conf['type'][0] == '?') {
             $conf['type'] = $this->getConf('default_commentstatus');
         }
         $form->addElement(form_makeMenuField('btng[post][commentstatus]', array('enabled', 'closed', 'disabled'), $conf['type'], $this->getLang('commentstatus'), 'blogtng__ncommentstatus', 'edit'));
     }
     $form->addElement(form_makeButton('submit', null, $this->getLang('create')));
     $form->addHidden('btng[new][format]', hsc($conf['format']));
     $form->addHidden('btng[post][blog]', hsc($conf['blog'][0]));
     return '<div class="blogtng_newform">' . $form->getForm() . '</div>';
 }
示例#14
0
    /**
     * Get the HTML code of a namespace move button
     * @param string $action The desired action of the button (continue, tryagain, skip, abort)
     * @param string|null $id The id of the target page, null if $ID shall be used
     * @return bool|string The HTML of code of the form or false if an invalid action was supplied
     */
    public function getNSMoveButton($action, $id = NULL) {
        if ($id === NULL) {
            global $ID;
            $id = $ID;
        }

        $class = 'move__nsform';
        switch ($action) {
            case 'continue':
            case 'tryagain':
                $class .= ' move__nscontinue';
                break;
            case 'skip':
                $class .= ' move__nsskip';
                break;
        }

        $form = new Doku_Form(array('action' => wl($id), 'method' => 'post', 'class' => $class));
        $form->addHidden('page', $this->getPluginName());
        $form->addHidden('id', $id);
        switch ($action) {
            case 'continue':
            case 'tryagain':
                $form->addHidden('continue_namespace_move', true);
                if ($action == 'tryagain') {
                    $form->addElement(form_makeButton('submit', 'admin', $this->getLang('ns_move_tryagain')));
                } else {
                    $form->addElement(form_makeButton('submit', 'admin', $this->getLang('ns_move_continue')));
                }
                break;
            case 'skip':
                $form->addHidden('skip_continue_namespace_move', true);
                $form->addElement(form_makeButton('submit', 'admin', $this->getLang('ns_move_skip')));
                break;
            case 'abort':
                $form->addHidden('abort_namespace_move', true);
                $form->addElement(form_makeButton('submit', 'admin', $this->getLang('ns_move_abort')));
                break;
            default:
                return false;
        }
        return $form->getForm();
    }
 /**
  * Add input fields for dynamic filtering
  */
 protected function renderDynamicFilters()
 {
     if ($this->mode != 'xhtml') {
         return;
     }
     if (!$this->data['dynfilters']) {
         return;
     }
     global $conf;
     $this->renderer->doc .= '<tr class="dataflt">';
     // add extra column for row numbers
     if ($this->data['rownumbers']) {
         $this->renderer->doc .= '<th></th>';
     }
     // each column gets a form
     foreach ($this->columns as $column) {
         $this->renderer->doc .= '<th>';
         $form = new \Doku_Form(array('method' => 'GET', 'action' => wl($this->id)));
         unset($form->_hidden['sectok']);
         // we don't need it here
         if (!$conf['userewrite']) {
             $form->addHidden('id', $this->id);
         }
         // current value
         $dynamic = $this->searchConfig->getDynamicParameters();
         $filters = $dynamic->getFilters();
         if (isset($filters[$column->getFullQualifiedLabel()])) {
             list(, $current) = $filters[$column->getFullQualifiedLabel()];
             $dynamic->removeFilter($column);
         } else {
             $current = '';
         }
         // Add current request params
         $params = $dynamic->getURLParameters();
         foreach ($params as $key => $val) {
             $form->addHidden($key, $val);
         }
         // add input field
         $key = $column->getFullQualifiedLabel() . '*~';
         $form->addElement(form_makeField('text', SearchConfigParameters::$PARAM_FILTER . '[' . $key . ']', $current, ''));
         $this->renderer->doc .= $form->getForm();
         $this->renderer->doc .= '</th>';
     }
     $this->renderer->doc .= '</tr>';
 }
示例#16
0
 /**
  * Displays a form to create new entries
  */
 function xhtml_newform($conf)
 {
     global $ID;
     // allowed to create?
     if (!$this->toolshelper) {
         $this->toolshelper =& plugin_load('helper', 'blogtng_tools');
     }
     $new = $this->toolshelper->mkpostid($conf['format'], 'dummy');
     if (auth_quickaclcheck($new) < AUTH_CREATE) {
         return '';
     }
     $form = new Doku_Form($ID, wl($ID, array('do' => 'btngnew'), false, '&'));
     if ($conf['title']) {
         $form->addElement(form_makeOpenTag('h3'));
         $form->addElement(hsc($conf['title']));
         $form->addElement(form_makeCloseTag('h3'));
     }
     if (isset($conf['select'])) {
         $form->addElement(form_makeMenuField('btng[new][title]', array_filter(preg_split('/\\s*,\\s*/', $conf['select'])), '', $this->getLang('title'), 'btng__nt', 'edit'));
     } else {
         $form->addElement(form_makeTextField('btng[new][title]', '', $this->getLang('title'), 'btng__nt', 'edit'));
     }
     $form->addElement(form_makeButton('submit', null, $this->getLang('create')));
     $form->addHidden('btng[new][format]', hsc($conf['format']));
     $form->addHidden('btng[post][blog]', hsc($conf['blog'][0]));
     return '<div class="blogtng_newform">' . $form->getForm() . '</div>';
 }
示例#17
0
 /**
  * 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();
 }
示例#18
0
 public function xhtml()
 {
     global $MERGED_DIFF;
     $this->doc = new DOMDocument();
     $this->root = $this->doc->createElement('div');
     $this->doc->appendChild($this->root);
     $text = '';
     $i = 1;
     foreach ($MERGED_DIFF as $op) {
         if (!is_array($op) && $op->from == SAME_OP) {
             $text .= orig($op);
             continue;
         }
         if ($text) {
             $this->copy($text);
             $text = '';
         }
         $this->diffOpOutput($op, $i++);
     }
     if ($text) {
         $this->copy($text);
     }
     echo $this->doc->saveXML($this->root);
     $form = new Doku_Form(array('id' => 'diff_form'));
     $form->addHidden($this->new_input_name(), '');
     $form->addHidden($this->old_input_name(), '');
     $form->addElement(form_makeButton('submit', $this->action(), 'save', array('id' => 'diffsubmit')));
     echo $form->getForm();
     echo cancel_button();
 }
示例#19
0
 function _html(&$renderer, $data)
 {
     global $ID;
     // set alignment
     $align = $data['opts']['align'];
     $hlp = plugin_load('helper', 'schulzevote');
     #        dbg($hlp);
     // check if the vote is over.
     $open = $data['opts']['date'] !== null && $data['opts']['date'] > time();
     if ($open) {
         $renderer->info['cache'] = false;
         if (!isset($_SERVER['REMOTE_USER'])) {
             $open = false;
             $closemsg = $this->getLang('no_remote_user');
         } elseif ($hlp->hasVoted()) {
             $open = false;
             $closemsg = $this->getLang('already_voted');
         }
         $closemsg .= '<br />' . $this->_winnerMsg($hlp, 'leading');
     } else {
         $closemsg = $this->getLang('vote_over') . '<br />' . $this->_winnerMsg($hlp, 'has_won');
     }
     $ranks = array();
     foreach ($hlp->getRanking() as $rank => $items) {
         foreach ($items as $item) {
             $ranks[$item] = '<span class="votebar" style="width: ' . 80 / ($rank + 1) . 'px">&nbsp;</span>';
         }
     }
     $form = new Doku_Form(array('id' => 'plugin__schulzevote', 'class' => 'plugin_schulzevote_' . $align));
     $form->startFieldset($this->getLang('cast'));
     if ($open) {
         $form->addHidden('id', $ID);
     }
     $form->addElement('<table>');
     foreach ($data['candy'] as $n => $candy) {
         $form->addElement('<tr>');
         $form->addElement('<td>');
         $form->addElement($this->_render($candy));
         $form->addElement('</td>');
         if ($open) {
             $form->addElement('<td>');
             $form->addElement(form_makeTextField('vote[' . $n . ']', isset($_POST['vote']) ? $_POST['vote'][$n] : '', $this->_render($candy), '', 'block candy'));
             $form->addElement('</td>');
         }
         $form->addElement('<td>');
         $form->addElement($ranks[$candy]);
         $form->addElement('</td>');
         $form->addElement('</tr>');
     }
     $form->addElement('</table>');
     if ($open) {
         $form->addElement('<p>' . $this->getLang('howto') . '</p>');
         $form->addElement(form_makeButton('submit', '', 'Vote!'));
         $form->addElement($this->_winnerMsg($hlp, 'leading'));
         $form->addElement('</p>');
     } else {
         $form->addElement('<p>' . $closemsg . '</p>');
     }
     $form->endFieldset();
     $renderer->doc .= $form->getForm();
     return true;
 }
示例#20
0
文件: syntax.php 项目: Jocai/Door43
 /**
  * form for slack invite
  *
  *
  */
 function slackinvite_signinform()
 {
     global $ID;
     $html = '';
     $params = array();
     $params['id'] = 'slackinvite_plugin_id';
     $params['action'] = wl($ID);
     $params['method'] = 'post';
     $params['enctype'] = 'multipart/form-data';
     $params['class'] = 'slackinvite_plugin';
     // Modification of the default dw HTML upload form
     $form = new Doku_Form($params);
     $form->startFieldset($this->getLang('signup'));
     $form->addHidden('source', hsc("slackinvite"));
     //add source of call, used in action to ignore anything not from this form
     $form->addElement(form_makeTextField('first_name', '', $this->getLang('first_name'), 'first__name'));
     $form->addElement(form_makeTextField('last_name', '', $this->getLang('last_name'), 'last__name'));
     $form->addElement(form_makeTextField('email', '', $this->getLang('email'), 'email'));
     $form->addElement(form_makeButton('submit', 'slacksignup', $this->getLang('btn_signup')));
     $form->endFieldset();
     $html .= '<div class="dokuwiki"><p>' . NL;
     //$html .= '<h3>TEAM43 Slack Sign Up</h3>';
     $html .= $form->getForm();
     $html .= '</p></div>' . NL;
     return $html;
 }
示例#21
0
 /**
  * Return the search form for the namespace and the tag selection
  *
  * @return string the HTML code of the search form
  */
 private function getForm()
 {
     global $conf, $lang;
     // Get the list of all namespaces for the dropdown
     $namespaces = array();
     search($namespaces, $conf['datadir'], 'search_namespaces', array());
     // build the list in the form value => label from the namespace search result
     $ns_select = array('' => '');
     foreach ($namespaces as $ns) {
         // only display namespaces the user can access when sneaky index is on
         if ($ns['perm'] > 0 || $conf['sneaky_index'] == 0) {
             $ns_select[$ns['id']] = $ns['id'];
         }
     }
     $form = new Doku_Form(array('action' => '', 'method' => 'post', 'class' => 'plugin__tag_search'));
     // add a paragraph around the inputs in order to get some margin around the form elements
     $form->addElement(form_makeOpenTag('p'));
     // namespace select
     $form->addElement(form_makeMenuField('plugin__tag_search_namespace', $ns_select, $this->getNS(), $lang['namespaces']));
     // checkbox for AND
     $attr = array();
     if ($this->useAnd()) {
         $attr['checked'] = 'checked';
     }
     $form->addElement(form_makeCheckboxField('plugin__tag_search_and', 1, $this->getLang('use_and'), '', '', $attr));
     $form->addElement(form_makeCloseTag('p'));
     // load the tag list - only tags that actually have pages assigned that the current user can access are listed
     /* @var helper_plugin_tag $my */
     if ($my =& plugin_load('helper', 'tag')) {
         $tags = $my->tagOccurrences(array(), NULL, true);
     }
     // sort tags by name ($tags is in the form $tag => $count)
     ksort($tags);
     // display error message when no tags were found
     if (!isset($tags) || $tags == NULL) {
         $form->addElement(form_makeOpenTag('p'));
         $form->addElement($this->getLang('no_tags'));
         $form->addElement(form_makeCloseTag('p'));
     } else {
         // the tags table
         $form->addElement(form_makeOpenTag('div', array('class' => 'table')));
         $form->addElement(form_makeOpenTag('table', array('class' => 'inline')));
         // print table header
         $form->addElement(form_makeOpenTag('tr'));
         $form->addElement(form_makeOpenTag('th'));
         $form->addElement($this->getLang('include'));
         $form->addElement(form_makeCloseTag('th'));
         $form->addElement(form_makeOpenTag('th'));
         $form->addElement($this->getLang('exclude'));
         $form->addElement(form_makeCloseTag('th'));
         $form->addElement(form_makeOpenTag('th'));
         $form->addElement($this->getLang('tags'));
         $form->addElement(form_makeCloseTag('th'));
         $form->addElement(form_makeCloseTag('tr'));
         // print tag checkboxes
         foreach ($tags as $tag => $count) {
             $form->addElement(form_makeOpenTag('tr'));
             $form->addElement(form_makeOpenTag('td'));
             $attr = array();
             if ($this->isSelected($tag)) {
                 $attr['checked'] = 'checked';
             }
             $form->addElement(form_makeCheckboxField('plugin__tag_search_tags[]', $tag, '+', '', 'plus', $attr));
             $form->addElement(form_makeCloseTag('td'));
             $form->addElement(form_makeOpenTag('td'));
             $attr = array();
             if ($this->isSelected('-' . $tag)) {
                 $attr['checked'] = 'checked';
             }
             $form->addElement(form_makeCheckboxField('plugin__tag_search_tags[]', '-' . $tag, '-', '', 'minus', $attr));
             $form->addElement(form_makeCloseTag('td'));
             $form->addElement(form_makeOpenTag('td'));
             $form->addElement(hsc($tag) . ' [' . $count . ']');
             $form->addElement(form_makeCloseTag('td'));
             $form->addElement(form_makeCloseTag('tr'));
         }
         $form->addElement(form_makeCloseTag('table'));
         $form->addElement(form_makeCloseTag('div'));
         // submit button (doesn't use the button form element because it always submits an action which is not
         // recognized for $preact in inc/actions.php and thus always causes a redirect)
         $form->addElement(form_makeOpenTag('p'));
         $form->addElement(form_makeTag('input', array('type' => 'submit', 'value' => $lang['btn_search'])));
         $form->addElement(form_makeCloseTag('p'));
     }
     return $form->getForm();
 }