*/
////////////////////////////////////////////////////////////////////////////////////////////////////
class admin_plugin_refnotes extends DokuWiki_Admin_Plugin {
use refnotes_localization_plugin;
private $locale;
/**
* Constructor
*/
public function __construct() {
refnotes_localization::initialize($this);
$this->locale = refnotes_localization::getInstance();
}
/**
* Handle user request
*/
public function handle() {
/* All handling is done using AJAX */
}
/**
* Output appropriate html
*/
public function html() {
print($this->locale_xhtml('intro'));
print('');
$this->printLanguageStrings();
print('
');
print('
' . $this->locale->getLang('noscript') . '
');
print('
');
print('
');
print('');
}
/**
* Built-in JS localization stores all language strings in the common script (produced by js.php).
* The strings used by administration plugin seem to be unnecessary in that script. Instead we print
* them as part of the page and then load them into the LANG array on the client side.
*/
private function printLanguageStrings() {
$lang = $this->locale->getByPrefix('js');
print('');
foreach ($lang as $key => $value) {
print($key . ' : ' . $value . ':eos:');
}
print('
');
}
/**
*
*/
private function printGeneral() {
$section = new refnotes_config_general();
$section->printHtml();
}
/**
*
*/
private function printNamespaces() {
$section = new refnotes_config_namespaces();
$section->printHtml();
}
/**
*
*/
private function printNotes() {
$section = new refnotes_config_notes();
$section->printHtml();
}
/**
*
*/
private function getButton($action) {
$html = ' locale->getLang('btn_' . $action) . '"';
$html .= ' />';
return $html;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_section {
protected $id;
protected $title;
/**
* Constructor
*/
public function __construct($id) {
$this->id = $id;
$this->title = 'sec_' . $id;
}
/**
*
*/
public function printHtml() {
$this->open();
$this->printFields();
$this->close();
}
/**
*
*/
protected function open() {
$title = refnotes_localization::getInstance()->getLang($this->title);
print('');
print('' . $title . ' ');
print('');
}
/**
*
*/
protected function close() {
print('
');
print(' ');
}
/**
*
*/
protected function printFields() {
$field = $this->getFields();
foreach ($field as $f) {
$this->printFieldRow($f);
}
}
/**
*
*/
protected function getFields() {
$fieldData = $this->getFieldDefinitions();
$field = array();
foreach ($fieldData as $id => $fd) {
$class = 'refnotes_config_' . $fd['class'];
$field[] = new $class($id, $fd);
}
return $field;
}
/**
*
*/
protected function printFieldRow($field, $startRow = true) {
if ($startRow) {
print('');
}
if (get_class($field) != 'refnotes_config_textarea') {
$settingName = $field->getSettingName();
if ($settingName != '') {
print('');
print($settingName);
}
else {
print(' ');
}
print($field->getLabel());
print(' ');
}
else {
print(' ');
}
print($field->getControl());
print(' ');
print(' ');
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_list_section extends refnotes_config_section {
private $listRows;
/**
* Constructor
*/
public function __construct($id, $listRows) {
parent::__construct($id);
$this->listRows = $listRows;
}
/**
*
*/
protected function close() {
print('');
$this->printListControls();
print('');
}
/**
*
*/
private function printListControls() {
print('');
print($this->getEdit());
print($this->getButton('add'));
print($this->getButton('rename'));
print($this->getButton('delete'));
print('
');
}
/**
*
*/
private function getEdit() {
$html = ' id;
$html .= ' id="' . $id . '"';
$html .= ' name="' . $id . '"';
$html .= ' value=""';
$html .= ' />';
return $html;
}
/**
*
*/
private function getButton($action) {
$label = refnotes_localization::getInstance()->getLang('btn_' . $action);
$id = $action . '-' . $this->id;
$html = ' getFields();
$fields = count($field);
print('');
print('');
print(' ');
print(' ');
$this->printFieldRow($field[0], false);
for ($f = 1; $f < $fields; $f++) {
$this->printFieldRow($field[$f]);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_general extends refnotes_config_section {
/**
* Constructor
*/
public function __construct() {
parent::__construct('general');
}
/**
*
*/
protected function getFieldDefinitions() {
static $field = array(
'replace-footnotes' => array(
'class' => 'checkbox',
'lean' => true
),
'reference-db-enable' => array(
'class' => 'checkbox',
'lean' => true
),
'reference-db-namespace' => array(
'class' => 'edit',
'lean' => true
)
);
return $field;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_namespaces extends refnotes_config_list_section {
/**
* Constructor
*/
public function __construct() {
parent::__construct('namespaces', 48);
}
/**
*
*/
protected function getFieldDefinitions() {
static $field = array(
'refnote-id' => array(
'class' => 'select',
'option' => array('numeric', 'latin-lower', 'latin-upper', 'roman-lower', 'roman-upper', 'stars', 'note-name', 'inherit')
),
'reference-base' => array(
'class' => 'select',
'option' => array('super', 'normal-text', 'inherit')
),
'reference-font-weight' => array(
'class' => 'select',
'option' => array('normal', 'bold', 'inherit')
),
'reference-font-style' => array(
'class' => 'select',
'option' => array('normal', 'italic', 'inherit')
),
'reference-format' => array(
'class' => 'select',
'option' => array('right-parent', 'parents', 'right-bracket', 'brackets', 'none', 'inherit')
),
'reference-group' => array(
'class' => 'select',
'option' => array('group-none', 'group-comma', 'group-semicolon', 'inherit')
),
'reference-render' => array(
'class' => 'select',
'option' => array('basic', 'harvard', 'inherit')
),
'multi-ref-id' => array(
'class' => 'select',
'option' => array('ref-counter', 'note-counter', 'inherit')
),
'note-preview' => array(
'class' => 'select',
'option' => array('popup', 'tooltip', 'none', 'inherit')
),
'notes-separator' => array(
'class' => 'edit_inherit'
),
'note-text-align' => array(
'class' => 'select',
'option' => array('justify', 'left', 'inherit')
),
'note-font-size' => array(
'class' => 'select',
'option' => array('normal', 'reduced', 'small', 'inherit')
),
'note-render' => array(
'class' => 'select',
'option' => array('basic', 'harvard', 'inherit')
),
'note-id-base' => array(
'class' => 'select',
'option' => array('super', 'normal-text', 'inherit')
),
'note-id-font-weight' => array(
'class' => 'select',
'option' => array('normal', 'bold', 'inherit')
),
'note-id-font-style' => array(
'class' => 'select',
'option' => array('normal', 'italic', 'inherit')
),
'note-id-format' => array(
'class' => 'select',
'option' => array('right-parent', 'parents', 'right-bracket', 'brackets', 'dot', 'none', 'inherit')
),
'back-ref-caret' => array(
'class' => 'select',
'option' => array('prefix', 'merge', 'none', 'inherit')
),
'back-ref-base' => array(
'class' => 'select',
'option' => array('super', 'normal-text', 'inherit')
),
'back-ref-font-weight' => array(
'class' => 'select',
'option' => array('normal', 'bold', 'inherit')
),
'back-ref-font-style' => array(
'class' => 'select',
'option' => array('normal', 'italic', 'inherit')
),
'back-ref-format' => array(
'class' => 'select',
'option' => array('note-id', 'latin', 'numeric', 'caret', 'arrow', 'none', 'inherit')
),
'back-ref-separator' => array(
'class' => 'select',
'option' => array('comma', 'none', 'inherit')
),
'scoping' => array(
'class' => 'select',
'option' => array('reset', 'single')
)
);
return $field;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_notes extends refnotes_config_list_section {
/**
* Constructor
*/
public function __construct() {
parent::__construct('notes', 14);
}
/**
*
*/
protected function getFieldDefinitions() {
static $field = array(
'note-text' => array(
'class' => 'textarea',
'rows' => '4',
'lean' => true
),
'inline' => array(
'class' => 'checkbox',
'lean' => true
),
'use-reference-base' => array(
'class' => 'checkbox',
'lean' => true
),
'use-reference-font-weight' => array(
'class' => 'checkbox',
'lean' => true
),
'use-reference-font-style' => array(
'class' => 'checkbox',
'lean' => true
),
'use-reference-format' => array(
'class' => 'checkbox',
'lean' => true
)
);
return $field;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_field {
protected $id;
protected $settingName;
protected $label;
/**
* Constructor
*/
public function __construct($id, $data) {
$this->id = 'field-' . $id;
$this->label = 'lbl_' . $id;
if (array_key_exists('lean', $data) && $data['lean']) {
$this->settingName = '';
}
else {
$this->settingName = $id;
}
}
/**
*
*/
public function getSettingName() {
$html = '';
if ($this->settingName != '') {
$html = '' . $this->settingName . ' ';
}
return $html;
}
/**
*
*/
public function getLabel() {
$label = refnotes_localization::getInstance()->getLang($this->label);
return '' . $label . ' ';
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_checkbox extends refnotes_config_field {
/**
* Constructor
*/
public function __construct($id, $data) {
parent::__construct($id, $data);
}
/**
*
*/
public function getControl() {
$html = '';
$html .= ' id . '"';
$html .= ' name="' . $this->id . '" value="1"';
$html .= '/>
';
return $html;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_select extends refnotes_config_field {
private $option;
/**
* Constructor
*/
public function __construct($id, $data) {
parent::__construct($id, $data);
$this->option = $data['option'];
}
/**
*
*/
public function getControl() {
$locale = refnotes_localization::getInstance();
$html = '';
$html .= 'id . '"';
$html .= ' name="' . $this->id . '">' . DOKU_LF;
foreach ($this->option as $option) {
$html .= '' . $locale->getLang('opt_' . $option) . ' ' . DOKU_LF;
}
$html .= ' ';
$html .= '
';
return $html;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_edit extends refnotes_config_field {
/**
* Constructor
*/
public function __construct($id, $data) {
parent::__construct($id, $data);
}
/**
*
*/
public function getControl() {
$html = '';
$html .= ' id . '"';
$html .= ' name="' . $this->id . '" />' . DOKU_LF;
$html .= '
';
return $html;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_edit_inherit extends refnotes_config_field {
/**
* Constructor
*/
public function __construct($id, $data) {
parent::__construct($id, $data);
}
/**
*
*/
public function getControl() {
$buttonLabel = refnotes_localization::getInstance()->getLang('opt_inherit');
$html = '';
$html .= ' id . '"';
$html .= ' name="' . $this->id . '" />' . DOKU_LF;
$html .= ' id . '-inherit"';
$html .= ' name="' . $this->id . '-inherit"';
$html .= ' value="' . $buttonLabel . '"';
$html .= ' />';
$html .= '
';
return $html;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class refnotes_config_textarea extends refnotes_config_field {
private $rows;
/**
* Constructor
*/
public function __construct($id, $data) {
parent::__construct($id, $data);
$this->rows = $data['rows'];
}
/**
*
*/
public function getControl() {
$html = '';
$html .= '
';
return $html;
}
}