Skip to content

Loading…

some tiny changes #1

Closed
wants to merge 2 commits into from

1 participant

@gusano
EasyBib member

No description provided.

@gusano
EasyBib member

obsolete now

@gusano gusano closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 14, 2011
  1. @gusano

    typo

    gusano committed
  2. @gusano

    whitespaces and tabs

    gusano committed
This page is out of date. Refresh to see the latest.
View
16 library/EasyBib/Form.php
@@ -20,7 +20,7 @@
* DEALINGS IN THE SOFTWARE.
*
* PHP Version 5
- *
+ *
* @category EasyBib
* @package Form
* @author Michael Scholl <michael@sch0ll.de>
@@ -32,9 +32,9 @@
/**
* EasyBib_Form
*
- * Extends Zend_Form
+ * Extends Zend_Form
* - provides model support
- * - provides buildBootstrapErrorDecorators method
+ * - provides buildBootstrapErrorDecorators method
* for adding css error classes to form if not valid
*
* @category EasyBib
@@ -44,11 +44,11 @@
* @version Release: @package_version@
* @link https://github.com/easybib/EasyBib_Form_Decorator
*/
- */
-class EasyBib_Form extends Zend_Form
+
+class EasyBib_Form extends Zend_Form
{
protected $model;
-
+
/**
* @return the $model
*/
@@ -57,7 +57,7 @@ public function getModel()
return $this->model;
}
- /**
+ /**
* @param $model
*/
public function setModel($model)
@@ -65,7 +65,7 @@ public function setModel($model)
$this->model = $model;
}
- /**
+ /**
* Build Bootstrap Error Decorators
*/
public function buildBootstrapErrorDecorators() {
View
562 library/EasyBib/Form/Decorator.php
@@ -31,19 +31,19 @@
/**
* Default Decorators Set
- *
+ *
* General usage:
* EasyBib_Form_Decorator::setFormDecorator($form, 'div', 'submit', 'cancel');
* EasyBib_Form_Decorator::setFormDecorator(
- * Instance of form,
+ * Instance of form,
* Decorator Mode - 3 different options:
- * - EasyBib_Form_Decorator::TABLE (html table style)
- * - EasyBib_Form_Decorator::DIV (div style)
- * - EasyBib_Form_Decorator::BOOTSTRAP (twitter bootstrap style)
- * Name of submit button,
+ * - EasyBib_Form_Decorator::TABLE (html table style)
+ * - EasyBib_Form_Decorator::DIV (div style)
+ * - EasyBib_Form_Decorator::BOOTSTRAP (twitter bootstrap style)
+ * Name of submit button,
* Name of cancel button
* );
- *
+ *
* @category EasyBib
* @package EasyBib_Form
* @author Michael Scholl <michael@sch0ll.de>
@@ -54,285 +54,285 @@
class EasyBib_Form_Decorator
{
/**
- * Constants Definition for Decorator
- */
- const TABLE = 'table';
+ * Constants Definition for Decorator
+ */
+ const TABLE = 'table';
+
+ const DIV = 'div';
- const DIV = 'div';
-
- const BOOTSTRAP = 'bootstrap';
+ const BOOTSTRAP = 'bootstrap';
+
+ /**
+ * Element Decorator
+ *
+ * @staticvar array
+ */
+ protected static $_ElementDecorator = array(
+ 'table' => array(
+ 'ViewHelper',
+ array(
+ 'Description',
+ array(
+ 'tag' => '',
+ 'escape' => false,
+ 'image' => '/images/icons/information.png'
+ )
+ ),
+ 'Errors',
+ array(
+ array(
+ 'data' => 'HtmlTag'
+ ),
+ array(
+ 'tag' => 'td'
+ )
+ ),
+ array(
+ 'Label',
+ array(
+ 'tag' => 'td'
+ )
+ ),
+ array(
+ array(
+ 'row' => 'HtmlTag'
+ ),
+ array(
+ 'tag' => 'tr'
+ )
+ )
+ ),
+ 'div' => array(
+ array(
+ 'ViewHelper'
+ ),
+ array(
+ 'Errors'
+ ),
+ array(
+ 'Description',
+ array(
+ 'tag' => 'span',
+ 'class' => 'hint'
+ )
+ ),
+ array(
+ 'Label'
+ ),
+ array(
+ 'HtmlTag',
+ array(
+ 'tag' => 'div'
+ )
+ )
+ ),
+ 'bootstrap' => array(
+ array(
+ 'ViewHelper'
+ ),
+ array(
+ 'BootstrapErrors'
+ ),
+ array(
+ 'Description',
+ array(
+ 'tag' => 'span',
+ 'class' => 'help-inline'
+ )
+ ),
+ array(
+ 'BootstrapTag',
+ array(
+ 'class' => 'input'
+ )
+ ),
+ array(
+ 'Label'
+ ),
+ array(
+ 'HtmlTag',
+ array(
+ 'tag' => 'div',
+ 'class' => 'clearfix'
+ )
+ )
+ )
+ );
+
+ /**
+ * Submit Element Decorator
+ *
+ * @staticvar array
+ */
+ protected static $_SubmitDecorator = array(
+ 'table' => array(
+ 'ViewHelper'
+ ),
+ 'div' => array(
+ 'ViewHelper'
+ ),
+ 'bootstrap' => array(
+ 'ViewHelper',
+ array(
+ 'HtmlTag',
+ array(
+ 'tag' => 'div',
+ 'class' => 'actions',
+ 'openOnly' => false
+ )
+ )
+ )
+ );
+
+ /**
+ * Reset Element Decorator
+ *
+ * @staticvar array
+ */
+ protected static $_ResetDecorator = array(
+ 'table' => array(
+ 'ViewHelper'
+ ),
+ 'div' => array(
+ 'ViewHelper'
+ ),
+ 'bootstrap' => array(
+ 'ViewHelper',
+ array(
+ 'HtmlTag',
+ array(
+ 'closeOnly' => false
+ )
+ )
+ )
+ );
- /**
- * Element Decorator
- *
- * @staticvar array
- */
- protected static $_ElementDecorator = array(
- 'table' => array(
- 'ViewHelper',
- array(
- 'Description',
- array(
- 'tag' => '',
- 'escape' => false,
- 'image' => '/images/icons/information.png'
- )
- ),
- 'Errors',
- array(
- array(
- 'data' => 'HtmlTag'
- ),
- array(
- 'tag' => 'td'
- )
- ),
- array(
- 'Label',
- array(
- 'tag' => 'td'
- )
- ),
- array(
- array(
- 'row' => 'HtmlTag'
- ),
- array(
- 'tag' => 'tr'
- )
- )
- ),
- 'div' => array(
- array(
- 'ViewHelper'
- ),
- array(
- 'Errors'
- ),
- array(
- 'Description',
- array(
- 'tag' => 'span',
- 'class' => 'hint'
- )
- ),
- array(
- 'Label'
- ),
- array(
- 'HtmlTag',
- array(
- 'tag' => 'div'
- )
- )
- ),
- 'bootstrap' => array(
- array(
- 'ViewHelper'
- ),
- array(
- 'BootstrapErrors'
- ),
- array(
- 'Description',
- array(
- 'tag' => 'span',
- 'class' => 'help-inline'
- )
- ),
- array(
- 'BootstrapTag',
- array(
- 'class' => 'input'
- )
- ),
- array(
- 'Label'
- ),
- array(
- 'HtmlTag',
- array(
- 'tag' => 'div',
- 'class' => 'clearfix'
- )
- )
- )
- );
+ /**
+ * Hiden Element Decorator
+ *
+ * @staticvar array
+ */
+ protected static $_HiddenDecorator = array(
+ 'table' => array(
+ 'ViewHelper'
+ ),
+ 'div' => array(
+ 'ViewHelper'
+ ),
+ 'bootstrap' => array(
+ 'ViewHelper'
+ )
+ );
+
+ /**
+ * Form Element Decorator
+ *
+ * @staticvar array
+ */
+ protected static $_FormDecorator = array(
+ 'table' => array(
+ 'FormElements',
+ 'Form'
+ ),
+ 'div' => array(
+ 'FormElements',
+ 'Form'
+ ),
+ 'bootstrap' => array(
+ 'FormElements',
+ 'Form'
+ )
+ );
+
+ /**
+ * DisplayGroup Decorator
+ *
+ * @staticvar array
+ */
+ protected static $_DisplayGroupDecorator = array(
+ 'table' => array(
+ 'FormElements',
+ array(
+ 'HtmlTag',
+ array(
+ 'tag' => 'table',
+ 'summary' => ''
+ )
+ ),
+ 'Fieldset'
+ ),
+ 'div' => array(
+ 'FormElements',
+ 'Fieldset'
+ ),
+ 'bootstrap' => array(
+ 'FormElements',
+ 'Fieldset'
+ )
+
+ );
+
+ /**
+ * Set the form decorators by the given string format or by the default div style
+ *
+ * @param object $objForm Zend_Form pointer-reference
+ * @param string $constFormat Project_Plugin_FormDecoratorDefinition constants
+ * @return NULL
+ */
+ public static function setFormDecorator(Zend_Form $form, $format = self::BOOTSTRAP, $submit_str = 'submit', $cancel_str = 'cancel') {
+ /**
+ * - disable default decorators
+ * - set form & displaygroup decorators
+ */
+ $form->setDisableLoadDefaultDecorators(true);
+ $form->setDisplayGroupDecorators(self::$_DisplayGroupDecorator[$format]);
+ $form->setDecorators(self::$_FormDecorator[$format]);
- /**
- * Submit Element Decorator
- *
- * @staticvar array
- */
- protected static $_SubmitDecorator = array(
- 'table' => array(
- 'ViewHelper'
- ),
- 'div' => array(
- 'ViewHelper'
- ),
- 'bootstrap' => array(
- 'ViewHelper',
- array(
- 'HtmlTag',
- array(
- 'tag' => 'div',
- 'class' => 'actions',
- 'openOnly' => false
- )
- )
- )
- );
-
- /**
- * Reset Element Decorator
- *
- * @staticvar array
- */
- protected static $_ResetDecorator = array(
- 'table' => array(
- 'ViewHelper'
- ),
- 'div' => array(
- 'ViewHelper'
- ),
- 'bootstrap' => array(
- 'ViewHelper',
- array(
- 'HtmlTag',
- array(
- 'closeOnly' => false
- )
- )
- )
- );
+ // set needed prefix path for bootstrap decorators
+ if ($format == self::BOOTSTRAP) {
+ $form->addElementPrefixPath(
+ 'EasyBib_Form_Decorator',
+ 'EasyBib/Form/Decorator',
+ Zend_Form::DECORATOR
+ );
+ }
- /**
- * Hiden Element Decorator
- *
- * @staticvar array
- */
- protected static $_HiddenDecorator = array(
- 'table' => array(
- 'ViewHelper'
- ),
- 'div' => array(
- 'ViewHelper'
- ),
- 'bootstrap' => array(
- 'ViewHelper'
- )
- );
+ // set form element decorators
+ $form->setElementDecorators(self::$_ElementDecorator[$format]);
- /**
- * Form Element Decorator
- *
- * @staticvar array
- */
- protected static $_FormDecorator = array(
- 'table' => array(
- 'FormElements',
- 'Form'
- ),
- 'div' => array(
- 'FormElements',
- 'Form'
- ),
- 'bootstrap' => array(
- 'FormElements',
- 'Form'
- )
- );
+ // set submit button decorators
+ if ($form->getElement($submit_str)) {
+ $form->getElement($submit_str)->setDecorators(self::$_SubmitDecorator[$format]);
+ if ($format == self::BOOTSTRAP) {
+ $form->getElement($submit_str)
+ ->setAttrib('class', array('btn', 'primary'))
+ ->setAttrib('type', 'submit');
+ if ($form->getElement($cancel_str)) {
+ $form->getElement($submit_str)->getDecorator('HtmlTag')
+ ->setOption('openOnly', true);
+ }
+ }
+ }
- /**
- * DisplayGroup Decorator
- *
- * @staticvar array
- */
- protected static $_DisplayGroupDecorator = array(
- 'table' => array(
- 'FormElements',
- array(
- 'HtmlTag',
- array(
- 'tag' => 'table',
- 'summary' => ''
- )
- ),
- 'Fieldset'
- ),
- 'div' => array(
- 'FormElements',
- 'Fieldset'
- ),
- 'bootstrap' => array(
- 'FormElements',
- 'Fieldset'
- )
-
- );
+ // set cancel button decorators
+ if ($form->getElement($cancel_str)) {
+ $form->getElement($cancel_str)->setDecorators(self::$_ResetDecorator[$format]);
+ if ($format == self::BOOTSTRAP) {
+ $form->getElement($cancel_str)
+ ->setAttrib('class', 'btn')
+ ->setAttrib('type', 'reset');
+ if ($form->getElement($submit_str)) {
+ $form->getElement($cancel_str)->getDecorator('HtmlTag')
+ ->setOption('closeOnly', true);
+ }
+ }
+ }
- /**
- * Set the form decorators by the given string format or by the default div style
- *
- * @param object $objForm Zend_Form pointer-reference
- * @param string $constFormat Project_Plugin_FormDecoratorDefinition constants
- * @return NULL
- */
- public static function setFormDecorator(Zend_Form $form, $format = self::BOOTSTRAP, $submit_str = 'submit', $cancel_str = 'cancel') {
- /**
- * - disable default decorators
- * - set form & displaygroup decorators
- */
- $form->setDisableLoadDefaultDecorators(true);
- $form->setDisplayGroupDecorators(self::$_DisplayGroupDecorator[$format]);
- $form->setDecorators(self::$_FormDecorator[$format]);
-
- // set needed prefix path for bootstrap decorators
- if ($format == self::BOOTSTRAP) {
- $form->addElementPrefixPath(
- 'EasyBib_Form_Decorator',
- 'EasyBib/Form/Decorator',
- Zend_Form::DECORATOR
- );
- }
-
- // set form element decorators
- $form->setElementDecorators(self::$_ElementDecorator[$format]);
-
- // set submit button decorators
- if ($form->getElement($submit_str)) {
- $form->getElement($submit_str)->setDecorators(self::$_SubmitDecorator[$format]);
- if ($format == self::BOOTSTRAP) {
- $form->getElement($submit_str)
- ->setAttrib('class', array('btn', 'primary'))
- ->setAttrib('type', 'submit');
- if ($form->getElement($cancel_str)) {
- $form->getElement($submit_str)->getDecorator('HtmlTag')
- ->setOption('openOnly', true);
- }
- }
- }
-
- // set cancel button decorators
- if ($form->getElement($cancel_str)) {
- $form->getElement($cancel_str)->setDecorators(self::$_ResetDecorator[$format]);
- if ($format == self::BOOTSTRAP) {
- $form->getElement($cancel_str)
- ->setAttrib('class', 'btn')
- ->setAttrib('type', 'reset');
- if ($form->getElement($submit_str)) {
- $form->getElement($cancel_str)->getDecorator('HtmlTag')
- ->setOption('closeOnly', true);
- }
- }
- }
-
- // set hidden input decorators
- foreach ($form->getElements() as $e) {
- if ($e->getType() == 'Zend_Form_Element_Hidden') {
- $e->setDecorators(self::$_HiddenDecorator[$format]);
- }
- }
- }
+ // set hidden input decorators
+ foreach ($form->getElements() as $e) {
+ if ($e->getType() == 'Zend_Form_Element_Hidden') {
+ $e->setDecorators(self::$_HiddenDecorator[$format]);
+ }
+ }
+ }
}
View
2 library/EasyBib/Form/Decorator/BootstrapErrors.php
@@ -71,7 +71,7 @@ public function render($content)
->setElementSeparator('<br />')
->setElementSeparator('</span>');
$errors = $formErrorHelper->formErrors($errors, array('class' => 'help-inline'));
-
+
switch ($placement) {
case 'PREPEND':
return $errors . $separator . $content;
View
26 library/EasyBib/View/Helper/MessagesFormatter.php
@@ -45,13 +45,13 @@ class EasyBib_View_Helper_MessagesFormatter extends Zend_View_Helper_Abstract
/**
* Formats given messages in a paragraph with given class
* input format can be string, array, multi dimensional array
- *
+ *
* With array use following notation: array('error', 'message')
- * -> first child is class for paragraph
- * - use success|notice|error for blueprint
- * - use (alert-message) warning|error|success|info for bootstrap
+ * -> first child is class for paragraph
+ * - use success|notice|error for blueprint
+ * - use (alert-message) warning|error|success|info for bootstrap
* -> second child is printed message
- *
+ *
* @param array $messages
* @param string $tag (default=p)
* @param string $format (default=blueprint)
@@ -60,7 +60,7 @@ class EasyBib_View_Helper_MessagesFormatter extends Zend_View_Helper_Abstract
public function messagesFormatter($messages, $tag = 'p', $format = 'bootstrap')
{
$return = '';
-
+
if (is_array($messages) && count($messages) > 0) {
if (is_array($messages[0])) {
foreach ($messages AS $msg) {
@@ -72,11 +72,11 @@ public function messagesFormatter($messages, $tag = 'p', $format = 'bootstrap')
}
$return .= '<'.$tag.' '.$class.'>';
if ($format == 'bootstrap') {
- $return .= '<p>';
+ $return .= '<p>';
}
$return .= $msg[1];
if ($format == 'bootstrap') {
- $return .= '</p>';
+ $return .= '</p>';
}
$return .= '</'.$tag.'>';
}
@@ -89,11 +89,11 @@ public function messagesFormatter($messages, $tag = 'p', $format = 'bootstrap')
}
$return .= '<'.$tag.' '.$class.'>';
if ($format == 'bootstrap') {
- $return .= '<p>';
+ $return .= '<p>';
}
$return .= $messages[1];
if ($format == 'bootstrap') {
- $return .= '</p>';
+ $return .= '</p>';
}
$return .= '</'.$tag.'>';
}
@@ -105,15 +105,15 @@ public function messagesFormatter($messages, $tag = 'p', $format = 'bootstrap')
}
$return .= '<'.$tag.' '.$class.'>';
if ($format == 'bootstrap') {
- $return .= '<p>';
+ $return .= '<p>';
}
$return .= $messages;
if ($format == 'bootstrap') {
- $return .= '</p>';
+ $return .= '</p>';
}
$return .= '</'.$tag.'>';
}
-
+
return $return;
}
}
Something went wrong with that request. Please try again.