Exemplo n.º 1
0
 /**
  * Visit a form.
  *
  * @param T_Form_Container $node
  */
 function visitFormContainer(T_Form_Container $node)
 {
     foreach ($node->getActions() as $a) {
         if ($a->isPresent()) {
             $this->data[$a->getFieldname()] = 1;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Converts the form to XML with visitor.
  *
  * @param T_Form_Container $form  form to render
  * @param T_Visitor $visitor  optional modified visitor
  * @return string  form XHTML
  */
 protected function getFormXml(T_Form_Container $form, $visitor = null)
 {
     if (is_null($visitor)) {
         $visitor = new T_Form_XhtmlError();
     }
     $form->accept($visitor);
     return $visitor->__toString();
 }
Exemplo n.º 3
0
 /**
  * Validates the form.
  *
  * Note that is it important here to only validate the main form body if
  * there is an action present (one is always created by default). This
  * prevents validation when an alternative form on a page has been
  * submitted.
  *
  * @param T_Cage_Array $source  source data
  * @return T_Form_Group  fluent interface
  */
 function validate(T_Cage_Array $source)
 {
     $is_action = false;
     foreach ($this->action as $button) {
         $button->validate($source);
         if ($button->isPresent()) {
             $is_action = true;
             break;
         }
         /* only 1 action ever present */
     }
     if ($is_action) {
         parent::validate($source);
     }
     return $this;
 }
Exemplo n.º 4
0
 /**
  * Gets all form checking hidden inputs.
  *
  * @param T_Form_Container $form
  * @return array
  */
 function getActionSaltTimeoutAndLockArray(T_Form_Container $form)
 {
     $alias = $form->getAlias();
     $salt = $form->search("{$alias}_salt");
     $timeout = $form->search("{$alias}_timeout");
     $lock = $form->search("{$alias}_thread_lock");
     $data = array($salt->getFieldname() => $salt->getFieldValue(), $salt->getChecksumFieldname() => $salt->getChecksumFieldValue(), $timeout->getFieldname() => $timeout->getFieldValue(), $timeout->getChecksumFieldname() => $timeout->getChecksumFieldValue());
     if ($lock) {
         $data[$lock->getFieldname()] = $lock->getFieldValue();
         $data[$lock->getChecksumFieldname()] = $lock->getChecksumFieldValue();
     }
     $actions = $form->getActions();
     $button = reset($actions);
     $data[$button->getFieldname()] = '';
     return $data;
 }
Exemplo n.º 5
0
 /**
  * Visit a form.
  *
  * @param T_Form_Container $node
  */
 function visitFormContainer(T_Form_Container $node)
 {
     $forward = $node->getForward();
     $mode = strpos(_end($forward->getPath()), '.') === false ? T_Url::AS_DIR : null;
     $action = $this->escape($forward->getUrl(null, $mode));
     $attributes = $node->getAllAttributes();
     $attributes += array('action' => $action, 'id' => $this->getNodeId($node), 'accept-charset' => $node->getCharset(), 'enctype' => $node->getMimeString(), 'method' => $node->getMethod());
     // <form>
     $xhtml = $this->indent . '<form ';
     foreach ($attributes as $key => $value) {
         $xhtml .= $key . '="' . $value . '"' . EOL . $this->indent . '       ';
     }
     $xhtml = rtrim($xhtml) . ' >' . EOL;
     $this->addXhtml($xhtml);
     // <fieldset class="submit">
     $this->changeIndent(1);
     $xhtml = $this->indent . '<fieldset class="submit">' . EOL;
     $actions = $node->getActions();
     $this->changeIndent(1);
     if (count($actions) == 0) {
         $actions[] = new T_Form_Button('submit', $node->getLabel());
     }
     foreach ($actions as $button) {
         $name = explode('_', get_class($button));
         $method = 'render' . array_pop($name);
         $xhtml .= $this->{$method}($button);
     }
     $this->changeIndent(-1);
     // </fieldset></form>
     $xhtml .= $this->indent . '</fieldset>' . EOL;
     $this->changeIndent(-1);
     $xhtml .= $this->indent . '</form>' . EOL;
     $this->addPostXhtml($node, $xhtml);
 }