introduced new abstract type to streamline multiedit fields

This commit is contained in:
Andreas Gohr
2016-03-01 16:07:01 +01:00
parent c5827bd5f7
commit 5c36a1f658
5 changed files with 40 additions and 25 deletions

View File

@ -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';

View 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>';
}
}

View File

@ -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

View File

@ -8,7 +8,7 @@ namespace plugin\struct\types;
*
* @package plugin\struct\types
*/
class Page extends Text {
class Page extends AbstractMultiBaseType {
/**
* Output the stored data

View File

@ -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);
}
}