Пример #1
0
Файл: a.php Проект: Borvik/Munla
 /**
  * Generates the HTML for the anchor element.
  * 
  * @return string
  */
 public function __toString()
 {
     $html = '';
     //if( strlen((string)$this->content) > 0 )
     $html = sprintf('<a%s>%s</a>', get::formattedAttributes($this->getAttributes()), $this->content);
     //else
     //$html = sprintf('<a%s />', get::formattedAttributes($this->getAttributes()));
     return $html;
 }
Пример #2
0
 /**
  * Generates the HTML for the form element.
  * 
  * @return string
  */
 public function __toString()
 {
     $this->attributes['id'] = $this->getId();
     $this->attributes['name'] = $this->getName();
     $this->attributes['type'] = $this->type;
     $html = sprintf('<input%s />', get::formattedAttributes($this->getAttributes()));
     if (is::existset($this->attributes, 'autofocus')) {
         $html .= $this->getAutoFocusScript($this->attributes['id']);
     }
     return $html;
 }
Пример #3
0
 /**
  * Generates the HTML for the form element.
  * 
  * @return string
  */
 public function __toString()
 {
     $this->attributes['id'] = $this->getId();
     $this->attributes['name'] = $this->getName();
     $value = get::array_def($this->attributes, 'value', '');
     $html = sprintf('<textarea%s>%s</textarea>', get::formattedAttributes($this->getAttributes()), get::entities($value));
     if (is::existset($this->attributes, 'autofocus')) {
         $html .= $this->getAutoFocusScript($this->attributes['id']);
     }
     return $html;
 }
Пример #4
0
 /**
  * Generates the HTML for the form element.
  * 
  * @return string
  */
 public function __toString()
 {
     $this->attributes['id'] = $this->getId();
     $this->attributes['name'] = $this->getName();
     $this->attributes['value'] = get::array_def($this->attributes, 'value', '');
     $this->attributes['type'] = $this->type;
     $content = get::array_def($this->attributes, 'content', $this->attributes['value']);
     $html = sprintf('<button%s>%s</button>', get::formattedAttributes($this->getAttributes()), $content);
     if (is::existset($this->attributes, 'autofocus')) {
         $html .= $this->getAutoFocusScript($this->attributes['id']);
     }
     return $html;
 }
Пример #5
0
 /**
  * Generates the HTML for the form element.
  * 
  * @return string
  */
 public function __toString()
 {
     $this->attributes['id'] = $this->getId();
     $this->attributes['name'] = $this->getName();
     $this->attributes['type'] = $this->type;
     $multiple = get::array_def($this->attributes, 'multiple', false) == 'multiple';
     if ($multiple && substr($this->attributes['name'], -2) != '[]') {
         $this->attributes['name'] .= '[]';
     }
     $html = sprintf('<input%s />', get::formattedAttributes($this->getAttributes()));
     if (is::existset($this->attributes, 'autofocus')) {
         $html .= $this->getAutoFocusScript($this->attributes['id']);
     }
     return $html;
 }
Пример #6
0
 /**
  * Generates the HTML for the image element.
  * 
  * @return string
  */
 public function __toString()
 {
     return sprintf('<img%s />', get::formattedAttributes($this->getAttributes()));
 }
Пример #7
0
 /**
  * Creates a label.
  * 
  * Minimum of 2 parameters. $text and $element, or $text and $for.
  * When using $text and $element, the can appear in either order and the order determines
  * where the label is in relation to the input element.  When using
  * $text and $for, they must be in that order.
  * 
  * @param string $text         The text for the label.
  * @param formElement $element The element to provide the label for.
  * @param string $for          The ID of the element it is for.
  * @param bool $insideTag      Whether to place the formElement inside the label tag or outside of it.
  * @param string $class        The class to give the label.
  * @param array $attributes    The other attributes to give the label.
  * 
  * @return string|void
  */
 public function ov_label($text, $for, $insideTag = null, $class = null)
 {
     $args = func_get_args();
     if (count($args) > 5 || count($args) < 2) {
         throw new InvalidArgumentException('Invalid number of arguments passed to label().');
     }
     $e = end($args);
     if (is_array($e)) {
         array_pop($args);
     } else {
         unset($e);
     }
     reset($args);
     $label = '';
     $params = array();
     $outElement = 0;
     if (is_string($text) && is_object($for) && is_subclass_of($for, 'formElement') || is_string($for) && is_object($text) && is_subclass_of($text, 'formElement')) {
         //based off of formElement
         if (is_string($for)) {
             $outElement = -1;
             $t = $for;
             $for = $text;
             $text = $t;
         } else {
             $outElement = 1;
         }
         $label = $text;
         $params['for'] = $for->getId();
     } elseif (is_string($text) && is_string($for)) {
         $label = $text;
         $params['for'] = $for;
     } else {
         throw new InvalidArgumentException('Invalid argument detected - may only submit strings or formElements.');
     }
     if (isset($insideTag) && is_string($insideTag)) {
         $class = $insideTag;
         $insideTag = false;
     }
     if (isset($class) && is_string($class)) {
         $params['class'] = $class;
     }
     // $class = sprintf(' class="%s"', get::entities($class));
     if (isset($e) && is_array($e)) {
         $params = $params + $e;
     }
     if (!array_key_exists('onclick', $params)) {
         $params['onclick'] = ' ';
     }
     $html = '';
     if ($outElement != 0) {
         if ($insideTag) {
             $lbl = $outElement < 0 ? '<label%1$s>%3$s%2$s</label>' : '<label%s>%s%s</label>';
         } else {
             $lbl = $outElement < 0 ? '%3$s<label%1$s>%2$s</label>' : '<label%s>%s</label>%s';
         }
         $html = sprintf($lbl, get::formattedAttributes($params), $label, $for);
     } else {
         $html = sprintf('<label%s>%s</label>', get::formattedAttributes($params), $label);
     }
     if (!$this->echoOff) {
         echo $html;
     }
     return $html;
 }
Пример #8
0
 /**
  * Generates the HTML for the form element.
  * 
  * @return string
  */
 public function __toString()
 {
     $this->attributes['id'] = $this->getId();
     $this->attributes['name'] = $this->getName();
     $keyvalues = get::array_def($this->attributes, 'keyvalues', false, array(true, false));
     $placeholder = get::array_def($this->attributes, 'placeholder', '');
     $separator = get::array_def($this->attributes, 'separator', false);
     $value = get::array_def($this->attributes, 'value', array());
     $multiple = get::array_def($this->attributes, 'multiple', false) == 'multiple';
     if ($multiple && substr($this->attributes['name'], -2) != '[]') {
         $this->attributes['name'] .= '[]';
     }
     if (!is_array($value) && strlen(trim($value)) < 1) {
         $value = array();
     }
     if (!is_array($value)) {
         $value = array($value);
     }
     $html = sprintf('<select%s>', get::formattedAttributes($this->getAttributes()));
     if (!$multiple && isset($placeholder) && strlen(trim($placeholder)) > 0) {
         $html .= sprintf('<option value="%s" disabled%s>%s</option>', get::encodedAttribute($this->emptyValue), count($value) > 0 ? '' : ' selected', get::entities($placeholder));
         if (isset($separator) && $separator !== false) {
             $separator = $separator === true ? '---------------' : $separator;
             $html .= sprintf('<option value="%s" disabled>%s</option>', get::encodedAttribute($this->emptyValue), get::entities($separator));
         }
     }
     if (isset($this->list) && count($this->list) > 0) {
         $stack = $this->build_stack($this->list);
         while ($stack) {
             $current = array_shift($stack);
             if (!is_array($current)) {
                 $html .= $current;
                 continue;
             }
             if (is_array($current['value'])) {
                 if (!is_string($current['key'])) {
                     continue;
                 }
                 $substack = $this->build_stack($current['value']);
                 if ($substack) {
                     $html .= sprintf('<optgroup label="%s">', get::encodedAttribute($current['key']));
                     array_unshift($stack, '</optgroup>');
                     while ($substack) {
                         array_unshift($stack, array_pop($substack));
                     }
                 }
             } else {
                 $v = $keyvalues || is_string($current['key']) ? (string) $current['key'] : $current['value'];
                 $l = $current['value'];
                 $selected = '';
                 if ($l == '-') {
                     $l = !isset($separator) || is_bool($separator) ? '---------------' : $separator;
                     $v = $this->emptyValue;
                 } else {
                     $selected = in_array($v, $value) ? ' selected="selected"' : '';
                 }
                 $html .= sprintf('<option value="%s"%s>%s</option>', get::encodedAttribute($v), $selected, get::entities($l));
             }
         }
     }
     $html .= '</select>';
     if (is::existset($this->attributes, 'autofocus')) {
         $html .= $this->getAutoFocusScript($this->attributes['id']);
     }
     return $html;
 }