Beispiel #1
0
 function html()
 {
     $sqlite = $this->dthlp->_getDB();
     if (!$sqlite) {
         return false;
     }
     echo $this->locale_xhtml('admin_intro');
     $sql = "SELECT * FROM aliases ORDER BY name";
     $res = $sqlite->query($sql);
     $rows = $sqlite->res2arr($res);
     $form = new Doku_Form(array('method' => 'post'));
     $form->addHidden('page', 'data');
     $form->addElement('<table class="inline">' . '<tr>' . '<th>' . $this->getLang('name') . '</th>' . '<th>' . $this->getLang('type') . '</th>' . '<th>' . $this->getLang('prefix') . '</th>' . '<th>' . $this->getLang('postfix') . '</th>' . '<th>' . $this->getLang('enum') . '</th>' . '</tr>');
     // add empty row for adding a new entry
     $rows[] = array('name' => '', 'type' => '', 'prefix' => '', 'postfix' => '', 'enum' => '');
     $cur = 0;
     foreach ($rows as $row) {
         $form->addElement('<tr>');
         $form->addElement('<td>');
         $form->addElement(form_makeTextField('d[' . $cur . '][name]', $row['name'], ''));
         $form->addElement('</td>');
         $form->addElement('<td>');
         $form->addElement(form_makeMenuField('d[' . $cur . '][type]', array('', 'page', 'title', 'mail', 'url', 'dt'), $row['type'], ''));
         $form->addElement('</td>');
         $form->addElement('<td>');
         $form->addElement(form_makeTextField('d[' . $cur . '][prefix]', $row['prefix'], ''));
         $form->addElement('</td>');
         $form->addElement('<td>');
         $form->addElement(form_makeTextField('d[' . $cur . '][postfix]', $row['postfix'], ''));
         $form->addElement('</td>');
         $form->addElement('<td>');
         $form->addElement(form_makeTextField('d[' . $cur . '][enum]', $row['enum'], ''));
         $form->addElement('</td>');
         $form->addElement('</tr>');
         $cur++;
     }
     $form->addElement('</table>');
     $form->addElement(form_makeButton('submit', 'admin', $this->getLang('submit')));
     $form->printForm();
 }
Beispiel #2
0
 function _editData($data, &$renderer)
 {
     $renderer->form->startFieldset($this->getLang('dataentry'));
     $renderer->form->_content[count($renderer->form->_content) - 1]['class'] = 'plugin__data';
     if ($this->getConf('edit_content_only')) {
         $renderer->form->addHidden('data_edit[classes]', $data['classes']);
         $renderer->form->addElement('<table>');
     } else {
         $renderer->form->addElement(form_makeField('text', 'data_edit[classes]', $data['classes'], $this->getLang('class'), 'data__classes'));
         $renderer->form->addElement('<table>');
         $text = '<tr>';
         foreach (array('title', 'type', 'multi', 'value', 'comment') as $val) {
             $text .= '<th>' . $this->getLang($val) . '</th>';
         }
         $renderer->form->addElement($text . '</tr>');
         // New line
         $data['data'][''] = '';
         $data['cols'][''] = array('type' => '', 'multi' => false);
     }
     $n = 0;
     foreach ($data['cols'] as $key => $vals) {
         $fieldid = 'data_edit[data][' . $n++ . ']';
         $content = $vals['multi'] ? implode(', ', $data['data'][$key]) : $data['data'][$key];
         if (is_array($vals['type'])) {
             $vals['basetype'] = $vals['type']['type'];
             if (isset($vals['type']['enum'])) {
                 $vals['enum'] = $vals['type']['enum'];
             }
             $vals['type'] = $vals['origtype'];
         } else {
             $vals['basetype'] = $vals['type'];
         }
         $renderer->form->addElement('<tr>');
         if ($this->getConf('edit_content_only')) {
             if (isset($vals['enum'])) {
                 $values = preg_split('/\\s*,\\s*/', $vals['enum']);
                 if (!$vals['multi']) {
                     array_unshift($values, '');
                 }
                 $content = form_makeListboxField($fieldid . '[value][]', $values, $data['data'][$key], $vals['title'], '', '', $vals['multi'] ? array('multiple' => 'multiple') : array());
             } else {
                 $classes = 'data_type_' . $vals['type'] . ($vals['multi'] ? 's' : '') . ' ' . 'data_type_' . $vals['basetype'] . ($vals['multi'] ? 's' : '');
                 $attr = array();
                 if ($vals['basetype'] == 'date' && !$vals['multi']) {
                     $attr['class'] = 'datepicker';
                 }
                 $content = form_makeField('text', $fieldid . '[value]', $content, $vals['title'], '', $classes, $attr);
             }
             $cells = array($vals['title'] . ':', $content, $vals['comment']);
             foreach (array('title', 'multi', 'comment', 'type') as $field) {
                 $renderer->form->addHidden($fieldid . "[{$field}]", $vals[$field]);
             }
         } else {
             $check_data = $vals['multi'] ? array('checked' => 'checked') : array();
             $cells = array(form_makeField('text', $fieldid . '[title]', $vals['title'], $this->getLang('title')), form_makeMenuField($fieldid . '[type]', array_merge(array('', 'page', 'nspage', 'title', 'img', 'mail', 'url', 'tag', 'wiki', 'dt'), array_keys($this->dthlp->_aliases())), $vals['type'], $this->getLang('type')), form_makeCheckboxField($fieldid . '[multi]', array('1', ''), $this->getLang('multi'), '', '', $check_data), form_makeField('text', $fieldid . '[value]', $content, $this->getLang('value')), form_makeField('text', $fieldid . '[comment]', $vals['comment'], $this->getLang('comment'), '', 'data_comment', array('readonly' => 1)));
         }
         foreach ($cells as $cell) {
             $renderer->form->addElement('<td>');
             $renderer->form->addElement($cell);
             $renderer->form->addElement('</td>');
         }
         $renderer->form->addElement('</tr>');
     }
     $renderer->form->addElement('</table>');
     $renderer->form->endFieldset();
 }
Beispiel #3
0
    /**
     * show the move and/or rename a page form
     *
     * @author  Michael Hamann <*****@*****.**>
     * @author  Gary Owen <*****@*****.**>
     */
    function printForm() {
        global $ID;

        $ns = getNS($ID);

        $ns_select_data = $this->build_namespace_select_content($ns);

        $form = new Doku_Form(array('action' => wl($ID), 'method' => 'post', 'class' => 'move__form'));
        $form->addHidden('page', $this->getPluginName());
        $form->addHidden('id', $ID);
        $form->addHidden('move_type', 'page');
        $form->startFieldset($this->getLang('movepage'));
        $form->addElement(form_makeMenuField('ns_for_page', $ns_select_data, $this->opts['ns_for_page'], $this->getLang('targetns'), '', 'block'));
        $form->addElement(form_makeTextField('newns', $this->opts['newns'], $this->getLang('newtargetns'), '', 'block'));
        $form->addElement(form_makeTextField('newname', $this->opts['newname'], $this->getLang('newname'), '', 'block'));
        $form->addElement(form_makeButton('submit', 'admin', $this->getLang('submit')));
        $form->endFieldset();
        $form->printForm();

        if ($this->ns_opts !== false) {
            ptln('<fieldset>');
            ptln('<legend>');
            ptln($this->getLang('movens'));
            ptln('</legend>');
            ptln('<p>');
            ptln(sprintf($this->getLang('ns_move_in_progress'), $this->ns_opts['num_pages'], $this->ns_opts['num_media'], ':'.hsc($this->ns_opts['ns']), ':'.hsc($this->ns_opts['newns'])));
            ptln('</p>');
            ptln($this->helper->getNSMoveButton('continue'));
            ptln($this->helper->getNSMoveButton('abort'));
            ptln('</fieldset>');
        } else {
            $form = new Doku_Form(array('action' => wl($ID), 'method' => 'post', 'class' => 'move__form'));
            $form->addHidden('page', $this->getPluginName());
            $form->addHidden('id', $ID);
            $form->addHidden('move_type', 'namespace');
            $form->startFieldset($this->getLang('movens'));
            $form->addElement(form_makeMenuField('targetns', $ns_select_data, $this->opts['targetns'], $this->getLang('targetns'), '', 'block'));
            $form->addElement(form_makeTextField('newnsname', $this->opts['newnsname'], $this->getLang('newnsname'), '', 'block'));
            $form->addElement(form_makeMenuField('contenttomove', array('pages' => $this->getLang('move_pages'), 'media' => $this->getLang('move_media'), 'both' => $this->getLang('move_media_and_pages')), $this->opts['contenttomove'], $this->getLang('content_to_move'), '', 'block'));
            $form->addElement(form_makeButton('submit', 'admin', $this->getLang('submit')));
            $form->endFieldset();
            $form->printForm();
        }
    }
Beispiel #4
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();
 }
Beispiel #5
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;
 }
 /**
  * Output html of the admin page
  */
 public function html()
 {
     global $ID;
     global $INPUT;
     if (is_null($this->_auth)) {
         print $this->lang['badauth'];
         return false;
     }
     $sqlite = $this->hlp->_getDB();
     if (!$sqlite) {
         return;
     }
     $fn = $INPUT->param('fn');
     if (is_array($fn)) {
         $cmd = key($fn);
         $param = is_array($fn[$cmd]) ? key($fn[$cmd]) : null;
     } else {
         $cmd = $fn;
         $param = null;
     }
     $user_list = $this->_auth->retrieveUsers($this->_start, $this->_pagesize, $this->_filter);
     echo $this->locale_xhtml('admin_intro');
     $form = new Doku_Form(array('method' => 'post'));
     $form->addHidden('page', 'userprofile_users');
     // List registered users
     $form->addElement('<table>' . '<tr>' . '<th>' . $this->getLang('username') . '</th>' . '<th>' . $this->getLang('realname') . '</th>' . '<th>' . $this->getLang('email') . '</th>' . '</tr>');
     foreach ($user_list as $user => $userinfo) {
         extract($userinfo);
         /**
          * @var string $name
          * @var string $pass
          * @var string $mail
          * @var array  $grps
          */
         if (!in_array('noprofile', $grps)) {
             $form->addElement('<tr>' . '<td><a href="' . wl($ID, array('fn[edit][' . $user . ']' => 1, 'do' => 'admin', 'page' => 'userprofile_users', 'sectok' => getSecurityToken())) . '" title="' . $this->lang['edit_prompt'] . '">' . hsc($user) . '</a></td>' . '<td>' . hsc($name) . '</td>' . '<td>' . hsc($mail) . '</td>' . '</tr>');
         }
     }
     $form->addElement('</table>');
     // Edit table
     if ($cmd == "edit") {
         $user = $param;
         $profile = $this->hlp->getProfile($user);
         // create hidden fields
         $form->addHidden('up[user][user]', $user);
         $form->addHidden('up[user][name]', $user_list[$user]['name']);
         $form->addHidden('up[user][email]', $user_list[$user]['mail']);
         $sql = "SELECT * FROM fields";
         $res = $sqlite->query($sql);
         $fields = $sqlite->res2arr($res);
         $form->addElement('<table>' . '<tr>' . '<th colspan="2">' . $this->getLang('th_edit') . '</th>' . '</tr>' . '<tr>' . '<td>' . $this->getLang('realname') . '</td>' . '<td>' . hsc($user_list[$user]['name']) . '</td>' . '</tr>' . '<tr>' . '<td>' . $this->getLang('email') . '</td>' . '<td>' . hsc($user_list[$user]['mail']) . '</td>' . '</tr>');
         foreach ($fields as $field) {
             $form->addElement('<tr>');
             $form->addElement('<td>' . hsc($field['title']) . '</td>');
             $form->addElement('<td>');
             $defaults_array = explode('|', $field['defaultval']);
             if (count($defaults_array) > 1) {
                 // create select field
                 $defaults_array = array_map('trim', $defaults_array);
                 $form->addElement(form_makeMenuField('up[data][' . $field['name'] . ']', $defaults_array, $profile[$field['name']], ''));
             } else {
                 // create regular text field
                 $form->addElement(form_makeTextField('up[data][' . $field['name'] . ']', $profile[$field['name']], ''));
             }
             $form->addElement('</td>');
             $form->addElement('</tr>');
         }
         $form->addElement('<tr>' . '<td colspan="2">');
         $form->addElement(form_makeButton('submit', 'admin', $this->getLang('submit')));
         $form->addElement('</td>');
         $form->addElement('</table>');
     }
     $form->printForm();
 }
 /**
  * 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();
 }
Beispiel #8
0
 /**
  * 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();
 }
Beispiel #9
0
 /**
  * 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());
 }
Beispiel #10
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>';
 }
 /**
  * The custom editor for editing data entries
  *
  * Gets called from action_plugin_data::_editform() where also the form member is attached
  *
  * @param array                          $data
  * @param Doku_Renderer_plugin_data_edit $renderer
  */
 function _editData($data, &$renderer)
 {
     $renderer->form->startFieldset($this->getLang('dataentry'));
     $renderer->form->_content[count($renderer->form->_content) - 1]['class'] = 'plugin__data';
     $renderer->form->addHidden('range', '0-0');
     // Adora Belle bugfix
     if ($this->getConf('edit_content_only')) {
         $renderer->form->addHidden('data_edit[classes]', $data['classes']);
         $columns = array('title', 'value', 'comment');
         $class = 'edit_content_only';
     } else {
         $renderer->form->addElement(form_makeField('text', 'data_edit[classes]', $data['classes'], $this->getLang('class'), 'data__classes'));
         $columns = array('title', 'type', 'multi', 'value', 'comment');
         $class = 'edit_all_content';
         // New line
         $data['data'][''] = '';
         $data['cols'][''] = array('type' => '', 'multi' => false);
     }
     $renderer->form->addElement("<table class=\"{$class}\">");
     //header
     $header = '<tr>';
     foreach ($columns as $column) {
         $header .= '<th class="' . $column . '">' . $this->getLang($column) . '</th>';
     }
     $header .= '</tr>';
     $renderer->form->addElement($header);
     //rows
     $n = 0;
     foreach ($data['cols'] as $key => $vals) {
         $fieldid = 'data_edit[data][' . $n++ . ']';
         $content = $vals['multi'] ? implode(', ', $data['data'][$key]) : $data['data'][$key];
         if (is_array($vals['type'])) {
             $vals['basetype'] = $vals['type']['type'];
             if (isset($vals['type']['enum'])) {
                 $vals['enum'] = $vals['type']['enum'];
             }
             $vals['type'] = $vals['origtype'];
         } else {
             $vals['basetype'] = $vals['type'];
         }
         if ($vals['type'] === 'hidden') {
             $renderer->form->addElement('<tr class="hidden">');
         } else {
             $renderer->form->addElement('<tr>');
         }
         if ($this->getConf('edit_content_only')) {
             if (isset($vals['enum'])) {
                 $values = preg_split('/\\s*,\\s*/', $vals['enum']);
                 if (!$vals['multi']) {
                     array_unshift($values, '');
                 }
                 $content = form_makeListboxField($fieldid . '[value][]', $values, $data['data'][$key], $vals['title'], '', '', $vals['multi'] ? array('multiple' => 'multiple') : array());
             } else {
                 $classes = 'data_type_' . $vals['type'] . ($vals['multi'] ? 's' : '') . ' ' . 'data_type_' . $vals['basetype'] . ($vals['multi'] ? 's' : '');
                 $attr = array();
                 if ($vals['basetype'] == 'date' && !$vals['multi']) {
                     $attr['class'] = 'datepicker';
                 }
                 $content = form_makeField('text', $fieldid . '[value]', $content, $vals['title'], '', $classes, $attr);
             }
             $cells = array(hsc($vals['title']) . ':', $content, '<span title="' . hsc($vals['comment']) . '">' . hsc($vals['comment']) . '</span>');
             foreach (array('multi', 'comment', 'type') as $field) {
                 $renderer->form->addHidden($fieldid . "[{$field}]", $vals[$field]);
             }
             $renderer->form->addHidden($fieldid . "[title]", $vals['origkey']);
             //keep key as key, even if title is translated
         } else {
             $check_data = $vals['multi'] ? array('checked' => 'checked') : array();
             $cells = array(form_makeField('text', $fieldid . '[title]', $vals['origkey'], $this->getLang('title')), form_makeMenuField($fieldid . '[type]', array_merge(array('', 'page', 'nspage', 'title', 'img', 'mail', 'url', 'tag', 'wiki', 'dt', 'hidden'), array_keys($this->dthlp->_aliases())), $vals['type'], $this->getLang('type')), form_makeCheckboxField($fieldid . '[multi]', array('1', ''), $this->getLang('multi'), '', '', $check_data), form_makeField('text', $fieldid . '[value]', $content, $this->getLang('value')), form_makeField('text', $fieldid . '[comment]', $vals['comment'], $this->getLang('comment'), '', 'data_comment', array('readonly' => 1, 'title' => $vals['comment'])));
         }
         foreach ($cells as $index => $cell) {
             $renderer->form->addElement("<td class=\"{$columns[$index]}\">");
             $renderer->form->addElement($cell);
             $renderer->form->addElement('</td>');
         }
         $renderer->form->addElement('</tr>');
     }
     $renderer->form->addElement('</table>');
     $renderer->form->endFieldset();
 }
Beispiel #12
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>';
 }