Dieser Commit ist enthalten in:
Ursprung
2b21070b1a
Commit
f7a7c71f86
1583 geänderte Dateien mit 454759 neuen und 0 gelöschten Zeilen
116
library/Msd/Form/Decorator/Abstract.php
Normale Datei
116
library/Msd/Form/Decorator/Abstract.php
Normale Datei
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Abstract decorator for form elements of Msd_Form
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
*/
|
||||
abstract class Msd_Form_Decorator_Abstract extends Zend_Form_Decorator_Abstract
|
||||
{
|
||||
/**
|
||||
* Build and translate the label of an element.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildLabel()
|
||||
{
|
||||
$element = $this->getElement();
|
||||
$label = $element->getLabel();
|
||||
if (empty($label)) {
|
||||
return '';
|
||||
}
|
||||
$translator = $element->getTranslator();
|
||||
if ($translator !== null) {
|
||||
$label = $translator->translate($label);
|
||||
}
|
||||
$attribs = $element->getAttribs();
|
||||
if (!isset($attribs['noColon']) || $attribs['noColon'] != true) {
|
||||
$label .= ':';
|
||||
}
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the HTML-Code of the element.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildInput()
|
||||
{
|
||||
$element = $this->getElement();
|
||||
$helper = $element->helper;
|
||||
$value = $element->getValue();
|
||||
$translator = $element->getTranslator();
|
||||
if ($translator !== null) {
|
||||
$value = $translator->translate($value);
|
||||
}
|
||||
$ret = $element->getView()->$helper(
|
||||
$element->getName(),
|
||||
$value,
|
||||
$this->_getCleanAttribs(),
|
||||
$element->options
|
||||
);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the error message, if there is any.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildErrors()
|
||||
{
|
||||
$lang = Msd_Language::getInstance();
|
||||
$element = $this->getElement();
|
||||
$messages = $element->getMessages();
|
||||
if (empty($messages)) {
|
||||
return '';
|
||||
}
|
||||
$html = '<ul>';
|
||||
foreach (array_keys($messages) as $messageId) {
|
||||
$html .= '<li>' . $lang->translateZendId($messageId) . '</li>';
|
||||
}
|
||||
$html .= '<ul>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildDescription()
|
||||
{
|
||||
$element = $this->getElement();
|
||||
$desc = $element->getDescription();
|
||||
return $desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up attributes we don't want to appear in Html code.
|
||||
*
|
||||
* @return array Array with allowed attributes
|
||||
*/
|
||||
private function _getCleanAttribs()
|
||||
{
|
||||
$attribsToRemove = array(
|
||||
'noColon', 'helper', 'secondLabel' , 'rowclass'
|
||||
);
|
||||
$attribsOfElement = $this->getElement()->getAttribs();
|
||||
foreach ($attribsToRemove as $attrib) {
|
||||
if (isset($attribsOfElement[$attrib])) {
|
||||
unset($attribsOfElement[$attrib]);
|
||||
}
|
||||
}
|
||||
return $attribsOfElement;
|
||||
}
|
||||
}
|
||||
48
library/Msd/Form/Decorator/ConfigForm.php
Normale Datei
48
library/Msd/Form/Decorator/ConfigForm.php
Normale Datei
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Decorator for main ConfigForm.
|
||||
*
|
||||
* Fetches all sub forms, renders all sub elements and returns
|
||||
* the complete form.
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
*/
|
||||
class Msd_Form_Decorator_ConfigForm extends Msd_Form_Decorator_Abstract
|
||||
{
|
||||
/**
|
||||
* Render the form
|
||||
*
|
||||
* @param string $content HTML content rendered so far
|
||||
*
|
||||
* @return string HTML content after decorating the complete form
|
||||
*/
|
||||
public function render($content)
|
||||
{
|
||||
$element = $this->getElement();
|
||||
$form = '';
|
||||
if (!empty($content)) {
|
||||
$form .= $content;
|
||||
} else {
|
||||
$subForms = $element->getSubForms();
|
||||
foreach (array_keys($subForms) as $subFormKey) {
|
||||
$form .= (string) $subForms[$subFormKey];
|
||||
}
|
||||
$subElements = $element->getElements();
|
||||
foreach (array_keys($subElements) as $subElementKey) {
|
||||
$form .= (string) $subElements[$subElementKey];
|
||||
}
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
65
library/Msd/Form/Decorator/Default.php
Normale Datei
65
library/Msd/Form/Decorator/Default.php
Normale Datei
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default decorator for form elements
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
*/
|
||||
class Msd_Form_Decorator_Default extends Msd_Form_Decorator_Abstract
|
||||
{
|
||||
/**
|
||||
* Render the element.
|
||||
*
|
||||
* @param string $content HTML content so far
|
||||
*
|
||||
* @return string HTML content after decorating
|
||||
*/
|
||||
public function render($content)
|
||||
{
|
||||
$element = $this->getElement();
|
||||
if (! $element instanceof Zend_Form_Element) {
|
||||
return $content;
|
||||
}
|
||||
if (null === $element->getView()) {
|
||||
return $content;
|
||||
}
|
||||
$label = $this->buildLabel();
|
||||
$input = $this->buildInput();
|
||||
$errors = strip_tags($this->buildErrors());
|
||||
$desc = $this->buildDescription();
|
||||
$descOutput = '';
|
||||
if ($desc != '') {
|
||||
$descOutput = sprintf('<span class="description">%s</span>', $desc);
|
||||
}
|
||||
$attribs = $element->getAttribs();
|
||||
$output = '<tr>';
|
||||
$rowclass = '';
|
||||
if (isset($attribs['rowclass'])) {
|
||||
$rowclass = $attribs['rowclass'];
|
||||
$output = '<tr class="' . $rowclass . '">';
|
||||
}
|
||||
$output .= ' <td>%s</td>
|
||||
<td>%s '. $descOutput . '</td>
|
||||
</tr>';
|
||||
$output = sprintf($output, $label, $input);
|
||||
$separator = $this->getSeparator();
|
||||
$placement = $this->getPlacement();
|
||||
switch ($placement) {
|
||||
case (self::PREPEND):
|
||||
return $output . $separator . $content;
|
||||
case (self::APPEND):
|
||||
default:
|
||||
return $content . $separator . $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
66
library/Msd/Form/Decorator/DisplayGroup.php
Normale Datei
66
library/Msd/Form/Decorator/DisplayGroup.php
Normale Datei
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Decorator for display groups
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
*/
|
||||
class Msd_Form_Decorator_DisplayGroup extends Msd_Form_Decorator_Abstract
|
||||
{
|
||||
/**
|
||||
* Decorator for display groups.
|
||||
*
|
||||
* Walks through all sub elements and decorates them.
|
||||
*
|
||||
* @param string $content HTML content so far
|
||||
*
|
||||
* @return string HTML content after decorating all sub elements
|
||||
*/
|
||||
public function render($content)
|
||||
{
|
||||
$element = $this->getElement();
|
||||
$legend = $element->getLegend();
|
||||
$translator = $element->getTranslator();
|
||||
$attributes = $element->getAttribs();
|
||||
if ($translator !== null) {
|
||||
$legend = $translator->translate($legend);
|
||||
}
|
||||
$sElements = '<fieldset';
|
||||
if (isset($attributes['class'])) {
|
||||
$sElements .= ' class="' . $attributes['class'] . '"';
|
||||
}
|
||||
if (isset($attributes['id'])) {
|
||||
$sElements .= ' id="' . $attributes['id'] . '"';
|
||||
}
|
||||
if (isset($attributes['style'])) {
|
||||
$sElements .= ' style="' . $attributes['style'] . '"';
|
||||
}
|
||||
$sElements .= '>';
|
||||
$sElements .= '<legend>' . $legend . '</legend>';
|
||||
$sElements .= '<table summary="">';
|
||||
$formElements = $element->getElements();
|
||||
foreach (array_keys($formElements) as $formElementKey) {
|
||||
$sElements .= (string) $formElements[$formElementKey];
|
||||
}
|
||||
$sElements .= '</table></fieldset>';
|
||||
|
||||
$placement = $this->getPlacement();
|
||||
$separator = $this->getSeparator();
|
||||
switch ($placement) {
|
||||
case (self::PREPEND):
|
||||
return $sElements . $separator . $content;
|
||||
case (self::APPEND):
|
||||
default:
|
||||
return $content . $separator . $sElements;
|
||||
}
|
||||
}
|
||||
}
|
||||
95
library/Msd/Form/Decorator/DoubleLabel.php
Normale Datei
95
library/Msd/Form/Decorator/DoubleLabel.php
Normale Datei
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Decorator for an element with two labels
|
||||
*
|
||||
* (label -> text input -> second label (unit)) or
|
||||
* (Label -> select box -> second label (unit)
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
*/
|
||||
class Msd_Form_Decorator_DoubleLabel extends Msd_Form_Decorator_Abstract
|
||||
{
|
||||
/**
|
||||
* Build the second label.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildSecondLabel()
|
||||
{
|
||||
$element = $this->getElement();
|
||||
$label = $element->getAttrib('secondLabel');
|
||||
if (empty($label)) {
|
||||
return '';
|
||||
}
|
||||
$translator = $element->getTranslator();
|
||||
if ($translator !== null) {
|
||||
$label = $translator->translate($label);
|
||||
}
|
||||
if ($element->isRequired()) {
|
||||
$label .= '*';
|
||||
}
|
||||
$label .= '';
|
||||
return '<label for="' . $element->getId() . '">' . $label . '</label>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the form element.
|
||||
*
|
||||
* @param string $content HTML content so far
|
||||
*
|
||||
* @return string HTML content after decorating
|
||||
*/
|
||||
public function render($content)
|
||||
{
|
||||
$element = $this->getElement();
|
||||
if (! $element instanceof Zend_Form_Element) {
|
||||
return $content;
|
||||
}
|
||||
if (null === $element->getView()) {
|
||||
return $content;
|
||||
}
|
||||
$separator = $this->getSeparator();
|
||||
$placement = $this->getPlacement();
|
||||
$label = $this->buildLabel();
|
||||
$secondLabel = $this->buildSecondLabel();
|
||||
$input = $this->buildInput();
|
||||
|
||||
$errorOutput = '';
|
||||
/*
|
||||
// error output is handled by validators
|
||||
$errors = $this->buildErrors();
|
||||
if ($errors != '') {
|
||||
$errorOutput = sprintf('<span class="error">%s</span>', $errors);
|
||||
}
|
||||
*/
|
||||
|
||||
$descOutput = '';
|
||||
$desc = $this->buildDescription();
|
||||
if ($desc != '') {
|
||||
$descOutput = sprintf('<span class="description">%s</span>', $desc);
|
||||
}
|
||||
|
||||
$output = ' <tr>
|
||||
<td>%s</td>
|
||||
<td>%s %s' . $errorOutput . $descOutput .'</td>
|
||||
</tr>';
|
||||
$output = sprintf($output, $label, $input, $secondLabel);
|
||||
switch ($placement) {
|
||||
case (self::PREPEND):
|
||||
return $output . $separator . $content;
|
||||
case (self::APPEND):
|
||||
default:
|
||||
return $content . $separator . $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
library/Msd/Form/Decorator/LineEnd.php
Normale Datei
43
library/Msd/Form/Decorator/LineEnd.php
Normale Datei
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Decorator for an element at the end of a table row
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
*/
|
||||
class Msd_Form_Decorator_LineEnd extends Msd_Form_Decorator_Abstract
|
||||
{
|
||||
/**
|
||||
* Render Element
|
||||
*
|
||||
* @param string $content HTML content so far
|
||||
*
|
||||
* @return string HTML content after decorating
|
||||
*/
|
||||
public function render($content)
|
||||
{
|
||||
$label = $this->buildLabel();
|
||||
if ($label != '' ) {
|
||||
$label = ' ' . $label;
|
||||
}
|
||||
$output = $label . $this->buildInput() . '</td></tr>';
|
||||
$separator = $this->getSeparator();
|
||||
$placement = $this->getPlacement();
|
||||
switch ($placement) {
|
||||
case (self::PREPEND):
|
||||
return $output . $separator . $content;
|
||||
case (self::APPEND):
|
||||
default:
|
||||
return $content . $separator . $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
library/Msd/Form/Decorator/LineMiddle.php
Normale Datei
44
library/Msd/Form/Decorator/LineMiddle.php
Normale Datei
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Decorator for table data between start and end of a table row
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
*/
|
||||
class Msd_Form_Decorator_LineMiddle extends Msd_Form_Decorator_Abstract
|
||||
{
|
||||
/**
|
||||
* Render element
|
||||
*
|
||||
* @param string $content HTML content so far
|
||||
*
|
||||
* @return string HTML content after decorating
|
||||
*/
|
||||
public function render($content)
|
||||
{
|
||||
$label = $this->buildLabel();
|
||||
if ($label != '' ) {
|
||||
$label = ' ' . $label;
|
||||
}
|
||||
$output = $label . $this->buildInput() . ' ';
|
||||
$separator = $this->getSeparator();
|
||||
$placement = $this->getPlacement();
|
||||
switch ($placement) {
|
||||
case (self::PREPEND):
|
||||
return $output . $separator . $content;
|
||||
case (self::APPEND):
|
||||
default:
|
||||
return $content . $separator . $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
48
library/Msd/Form/Decorator/LineStart.php
Normale Datei
48
library/Msd/Form/Decorator/LineStart.php
Normale Datei
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Decorator for the beginning of a table row
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
*/
|
||||
class Msd_Form_Decorator_LineStart extends Msd_Form_Decorator_Abstract
|
||||
{
|
||||
/**
|
||||
* Render the element.
|
||||
*
|
||||
* @param string $content HTML content so far
|
||||
*
|
||||
* @return string HTML content after decorating
|
||||
*/
|
||||
public function render($content)
|
||||
{
|
||||
$element = $this->getElement();
|
||||
if (! $element instanceof Zend_Form_Element) {
|
||||
return $content;
|
||||
}
|
||||
if (null === $element->getView()) {
|
||||
return $content;
|
||||
}
|
||||
$separator = $this->getSeparator();
|
||||
$placement = $this->getPlacement();
|
||||
$label = $this->buildLabel();
|
||||
$input = $this->buildInput();
|
||||
$output = '<tr><td>' . $label . '</td>' . '<td>' . $input;
|
||||
switch ($placement) {
|
||||
case (self::PREPEND):
|
||||
return $output . $separator . $content;
|
||||
case (self::APPEND):
|
||||
default:
|
||||
return $content . $separator . $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
55
library/Msd/Form/Decorator/SubForm.php
Normale Datei
55
library/Msd/Form/Decorator/SubForm.php
Normale Datei
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Decorator for a complete sub form
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Form_Decorator
|
||||
*/
|
||||
class Msd_Form_Decorator_SubForm extends Msd_Form_Decorator_Abstract
|
||||
{
|
||||
/**
|
||||
* Render content
|
||||
*
|
||||
* @param string $content The HTML content rendered so far
|
||||
*
|
||||
* @return string The HTML content after decorating
|
||||
*/
|
||||
public function render($content)
|
||||
{
|
||||
$element = $this->getElement();
|
||||
$htmlOutput = '<div id="tab_' . $element->getId() . '">';
|
||||
$headElement = $element->getElement('headElement');
|
||||
if ($headElement !== null) {
|
||||
$htmlOutput .='<table summary="">';
|
||||
$htmlOutput .= (string) $headElement;
|
||||
$htmlOutput .= '</table>' . "\n";
|
||||
$htmlOutput .= '<br/><br/>' . "\n";
|
||||
}
|
||||
$displayGroups = $element->getDisplayGroups();
|
||||
foreach (array_keys($displayGroups) as $displayGroupKey) {
|
||||
$htmlOutput .= (string) $displayGroups[$displayGroupKey];
|
||||
}
|
||||
$htmlOutput .= '</div>';
|
||||
|
||||
$separator = $this->getSeparator();
|
||||
$placement = $this->getPlacement();
|
||||
switch ($placement) {
|
||||
case (self::PREPEND):
|
||||
return $htmlOutput . $separator . $content;
|
||||
case (self::APPEND):
|
||||
default:
|
||||
return $content . $separator . $htmlOutput;
|
||||
}
|
||||
|
||||
return $htmlOutput;
|
||||
}
|
||||
}
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren