コード例 #1
0
 /**
  * Convenience method to access plugin language strings
  *
  * @param string $string
  * @return string
  */
 public function getLang($string)
 {
     if (is_null($this->hlp)) {
         $this->hlp = plugin_load('helper', 'struct');
     }
     return $this->hlp->getLang($string);
 }
コード例 #2
0
 /**
  * Returns the Admin Form to edit the schema
  *
  * This data is processed by the SchemaBuilder class
  *
  * @return string the HTML for the editor form
  * @see SchemaBuilder
  */
 public function getEditor()
 {
     $form = new Form(array('method' => 'POST', 'id' => 'plugin__struct_editor'));
     $form->setHiddenField('do', 'admin');
     $form->setHiddenField('page', 'struct_schemas');
     $form->setHiddenField('table', $this->schema->getTable());
     $form->setHiddenField('schema[id]', $this->schema->getId());
     $form->setHiddenField('schema[islookup]', $this->schema->isLookup());
     $form->addHTML('<table class="inline">');
     $form->addHTML("<tr>\n            <th>{$this->hlp->getLang('editor_sort')}</th>\n            <th>{$this->hlp->getLang('editor_label')}</th>\n            <th>{$this->hlp->getLang('editor_multi')}</th>\n            <th>{$this->hlp->getLang('editor_conf')}</th>\n            <th>{$this->hlp->getLang('editor_type')}</th>\n            <th>{$this->hlp->getLang('editor_enabled')}</th>\n        </tr>");
     foreach ($this->schema->getColumns() as $key => $col) {
         $form->addHTML($this->adminColumn($col->getColref(), $col));
     }
     // FIXME new one needs to be added dynamically, this is just for testing
     $form->addHTML($this->adminColumn('new1', new Column($this->schema->getMaxsort() + 10, new Text()), 'new'));
     $form->addHTML('</table>');
     $form->addFieldsetOpen();
     $form->addTextInput('schema[editors]', $this->hlp->getLang('editor_editors'))->val($this->schema->getEditors());
     $form->addFieldsetClose();
     $form->addButton('save', 'Save')->attr('type', 'submit');
     return $form->toHTML() . $this->initJSONEditor();
 }
コード例 #3
0
 /**
  * Build html for label and input of setting
  *
  * @param DokuWiki_Plugin $plugin object of config plugin
  * @param bool            $echo   true: show input value, when error occurred, otherwise the stored setting
  * @return string[] with content array(string $label_html, string $input_html)
  */
 function html(&$plugin, $echo = false)
 {
     $disable = '';
     if ($this->is_protected()) {
         $value = $this->_protected;
         $disable = 'disabled="disabled"';
     } else {
         if ($echo && $this->_error) {
             $value = $this->_input;
         } else {
             $value = is_null($this->_local) ? $this->_default : $this->_local;
         }
     }
     $key = htmlspecialchars($this->_key);
     // convert from comma separated list into array + combine complimentary actions
     $value = $this->_str2array($value);
     $default = $this->_str2array($this->_default);
     $input = '';
     foreach ($this->_choices as $choice) {
         $idx = array_search($choice, $value);
         $idx_default = array_search($choice, $default);
         $checked = $idx !== false ? 'checked="checked"' : '';
         // ideally this would be handled using a second class of "default", however IE6 does not
         // correctly support CSS selectors referencing multiple class names on the same element
         // (e.g. .default.selection).
         $class = ($idx !== false) == (false !== $idx_default) ? " selectiondefault" : "";
         $prompt = $plugin->getLang($this->_key . '_' . $choice) ? $plugin->getLang($this->_key . '_' . $choice) : htmlspecialchars($choice);
         $input .= '<div class="selection' . $class . '">' . "\n";
         $input .= '<label for="config___' . $key . '_' . $choice . '">' . $prompt . "</label>\n";
         $input .= '<input id="config___' . $key . '_' . $choice . '" name="config[' . $key . '][]" type="checkbox" class="checkbox" value="' . $choice . '" ' . $disable . ' ' . $checked . "/>\n";
         $input .= "</div>\n";
         // remove this action from the disabledactions array
         if ($idx !== false) {
             unset($value[$idx]);
         }
         if ($idx_default !== false) {
             unset($default[$idx_default]);
         }
     }
     // handle any remaining values
     $other = join(',', $value);
     $class = count($default) == count($value) && count($value) == count(array_intersect($value, $default)) ? " selectiondefault" : "";
     $input .= '<div class="other' . $class . '">' . "\n";
     $input .= '<label for="config___' . $key . '_other">' . $plugin->getLang($key . '_other') . "</label>\n";
     $input .= '<input id="config___' . $key . '_other" name="config[' . $key . '][other]" type="text" class="edit" value="' . htmlspecialchars($other) . '" ' . $disable . " />\n";
     $input .= "</div>\n";
     $label = '<label>' . $this->prompt($plugin) . '</label>';
     return array($label, $input);
 }
コード例 #4
0
ファイル: config.class.php プロジェクト: janzoner/dokuwiki
 /**
  * Build html for label and input of setting
  *
  * @param DokuWiki_Plugin $plugin object of config plugin
  * @param bool            $echo   true: show input value, when error occurred, otherwise the stored setting
  * @return string[] with content array(string $label_html, string $input_html)
  */
 function html(&$plugin, $echo = false)
 {
     $disable = '';
     if ($this->is_protected()) {
         $value = $this->_protected;
         $disable = 'disabled="disabled"';
     } else {
         if ($echo && $this->_error) {
             $value = $this->_input;
         } else {
             $value = is_null($this->_local) ? $this->_default : $this->_local;
         }
     }
     $key = htmlspecialchars($this->_key);
     // convert from comma separated list into array + combine complimentary actions
     $value = $this->_str2array($value);
     $default = $this->_str2array($this->_default);
     $input = '';
     foreach ($this->_choices as $choice) {
         $idx = array_search($choice, $value);
         $idx_default = array_search($choice, $default);
         $checked = $idx !== false ? 'checked="checked"' : '';
         // @todo ideally this would be handled using a second class of "default"
         $class = ($idx !== false) == (false !== $idx_default) ? " selectiondefault" : "";
         $prompt = $plugin->getLang($this->_key . '_' . $choice) ? $plugin->getLang($this->_key . '_' . $choice) : htmlspecialchars($choice);
         $input .= '<div class="selection' . $class . '">' . "\n";
         $input .= '<label for="config___' . $key . '_' . $choice . '">' . $prompt . "</label>\n";
         $input .= '<input id="config___' . $key . '_' . $choice . '" name="config[' . $key . '][]" type="checkbox" class="checkbox" value="' . $choice . '" ' . $disable . ' ' . $checked . "/>\n";
         $input .= "</div>\n";
         // remove this action from the disabledactions array
         if ($idx !== false) {
             unset($value[$idx]);
         }
         if ($idx_default !== false) {
             unset($default[$idx_default]);
         }
     }
     // handle any remaining values
     if ($this->_other != 'never') {
         $other = join(',', $value);
         // test equivalent to ($this->_other == 'always' || ($other && $this->_other == 'exists')
         // use != 'exists' rather than == 'always' to ensure invalid values default to 'always'
         if ($this->_other != 'exists' || $other) {
             $class = count($default) == count($value) && count($value) == count(array_intersect($value, $default)) ? " selectiondefault" : "";
             $input .= '<div class="other' . $class . '">' . "\n";
             $input .= '<label for="config___' . $key . '_other">' . $plugin->getLang($key . '_other') . "</label>\n";
             $input .= '<input id="config___' . $key . '_other" name="config[' . $key . '][other]" type="text" class="edit" value="' . htmlspecialchars($other) . '" ' . $disable . " />\n";
             $input .= "</div>\n";
         }
     }
     $label = '<label>' . $this->prompt($plugin) . '</label>';
     return array($label, $input);
 }
コード例 #5
0
ファイル: config.class.php プロジェクト: yjliugit/dokuwiki
 /**
  * Returns the localized prompt
  *
  * @param DokuWiki_Plugin $plugin object of config plugin
  * @return string text
  */
 public function prompt(&$plugin)
 {
     $prompt = $plugin->getLang($this->_key);
     if (!$prompt) {
         $prompt = htmlspecialchars(str_replace(array('____', '_'), ' ', $this->_key));
     }
     return $prompt;
 }