mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-01 15:54:34 +00:00
introduced new abstract type to streamline multiedit fields
This commit is contained in:
@ -29,7 +29,7 @@ $lang['assign_del'] = 'Delete';
|
||||
$lang['assign_assign'] = 'Page/Namespace';
|
||||
$lang['assign_tbl'] = 'Schema';
|
||||
|
||||
|
||||
$lang['multi'] = 'Enter multiple values separated by commas.';
|
||||
$lang['duplicate_label'] = "Label <code>%s</code> already exists in schema, second occurance was renamed it to <code>%s</code>.";
|
||||
|
||||
$lang['emptypage'] = 'Struct data has not been saved for an empty page';
|
||||
|
36
types/AbstractMultiBaseType.php
Normal file
36
types/AbstractMultiBaseType.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\struct\types;
|
||||
|
||||
use plugin\struct\meta\StructException;
|
||||
use plugin\struct\meta\ValidationException;
|
||||
|
||||
/**
|
||||
* Class AbstractBaseType
|
||||
*
|
||||
* This class implements a standard multi editor that can be reused by user types. The multi-
|
||||
* edit simply joins all values with commas
|
||||
*
|
||||
* @package plugin\struct\types
|
||||
* @see Column
|
||||
*/
|
||||
abstract class AbstractMultiBaseType extends AbstractBaseType {
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \string[] $values
|
||||
* @return string
|
||||
*/
|
||||
public function multiValueEditor($name, $values) {
|
||||
$value = join(', ', $values);
|
||||
|
||||
return
|
||||
'<div class="multiwrap">' .
|
||||
$this->valueEditor($name, $value) .
|
||||
'</div>' .
|
||||
'<small>' .
|
||||
$this->getLang('multi') .
|
||||
'</small>';
|
||||
}
|
||||
|
||||
}
|
@ -10,7 +10,7 @@ use plugin\struct\meta\ValidationException;
|
||||
*
|
||||
* @package plugin\struct\types
|
||||
*/
|
||||
class Integer extends Text {
|
||||
class Integer extends AbstractMultiBaseType {
|
||||
|
||||
protected $config = array(
|
||||
'format' => '%d',
|
||||
@ -31,16 +31,6 @@ class Integer extends Text {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \string[] $values
|
||||
* @return string
|
||||
*/
|
||||
public function multiValueEditor($name, $values) {
|
||||
$value = join(', ', $values);
|
||||
return $this->valueEditor($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|string $value
|
||||
* @throws ValidationException
|
||||
|
@ -8,7 +8,7 @@ namespace plugin\struct\types;
|
||||
*
|
||||
* @package plugin\struct\types
|
||||
*/
|
||||
class Page extends Text {
|
||||
class Page extends AbstractMultiBaseType {
|
||||
|
||||
/**
|
||||
* Output the stored data
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace plugin\struct\types;
|
||||
|
||||
class Text extends AbstractBaseType {
|
||||
class Text extends AbstractMultiBaseType {
|
||||
|
||||
protected $config = array(
|
||||
'prefix' => '',
|
||||
@ -20,15 +20,4 @@ class Text extends AbstractBaseType {
|
||||
$R->cdata($this->config['prefix'] . $value . $this->config['postfix']);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \string[] $values
|
||||
* @return string
|
||||
*/
|
||||
public function multiValueEditor($name, $values) {
|
||||
$value = join(', ', $values);
|
||||
return $this->valueEditor($name, $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user