Esempio n. 1
0
 /**
  * Een array printen met syntax highlighting.
  *
  * @param array $array
  */
 private function renderArray($array)
 {
     foreach ($array as $key => $value) {
         if (is_array($value) && count($value) != 0) {
             echo '<b>' . $key . ':</b> array(' . "<br />\n";
             if (\Sledgehammer\is_indexed($value)) {
                 foreach ($value as $value2) {
                     echo '&nbsp;&nbsp;', \Sledgehammer\syntax_highlight($value2), "<br />\n";
                 }
             } else {
                 foreach ($value as $key2 => $value2) {
                     echo '&nbsp;&nbsp;' . \Sledgehammer\syntax_highlight($key2) . ' => ', \Sledgehammer\syntax_highlight($value2, null, 2048), "<br />\n";
                 }
             }
             echo ")<br />\n";
         } else {
             echo '<b>' . $key . ':</b> ', \Sledgehammer\syntax_highlight($value, null, 2048), "<br />\n";
         }
     }
 }
Esempio n. 2
0
 protected function renderElement()
 {
     $type = strtolower($this->getAttribute('type'));
     if (in_array($type, ['select', 'textarea'])) {
         $this->tag = $type;
         unset($this->attributes['type']);
     }
     $attributes = $this->attributes;
     switch ($this->tag) {
         case 'select':
             $options = $attributes['options'];
             unset($attributes['options'], $attributes['value']);
             echo Html::element($this->tag, $attributes, true);
             $selected = $this->getAttribute('value');
             $isIndexed = \Sledgehammer\is_indexed($options);
             foreach ($options as $value => $label) {
                 $option = array();
                 if ($isIndexed) {
                     $value = $label;
                 } else {
                     $option['value'] = $value;
                 }
                 if (\Sledgehammer\equals($value, $selected)) {
                     $option['selected'] = 'selected';
                 }
                 echo Html::element('option', $option, Html::escape($label));
             }
             echo '</select>';
             break;
         case 'textarea':
             unset($attributes['value']);
             echo Html::element($this->tag, $attributes, Html::escape($this->getAttribute('value')));
             break;
         default:
             echo Html::element($this->tag, $attributes);
             break;
     }
 }
Esempio n. 3
0
<?php

use Sledgehammer\Mvc\Component\Button;
use Sledgehammer\Core\Html;
use Sledgehammer\Core\Url;
echo "<div class=\"modal-dialog\">\n";
echo "\t<div class=\"modal-content\">\n";
echo "\t\t<div class=\"modal-header\">";
echo '<h4 class="modal-title">';
echo Html::escape($title), "</h4></div>\n";
echo "\t\t<div class=\"modal-body\">\n\t\t\t", $body, "\n\t\t</div>\n";
if (count($choices) !== 0) {
    echo "\t\t<form class=\"modal-footer\" action=\"" . Url::getCurrentURL() . '" method="' . $method . "\">\n";
    $indexed = \Sledgehammer\is_indexed($choices);
    foreach (array_reverse($choices) as $answer => $choice) {
        if (is_array($choice) === false) {
            $choice = array('label' => $choice);
        }
        $choice['type'] = 'submit';
        $choice['name'] = $identifier;
        if ($indexed) {
            $choice['value'] = $choice['label'];
        } else {
            $choice['value'] = $answer;
        }
        $button = new Button($choice);
        echo "\t\t\t", $button, "\n";
    }
    echo "\t\t</form>\n";
}
echo "\t</div>\n";
Esempio n. 4
0
 /**
  * Return a new collection in the reverse order.
  *
  * @return Collection
  */
 public function reverse()
 {
     $this->dataToArray();
     $preserveKeys = \Sledgehammer\is_indexed($this->data) === false;
     return new self(array_reverse($this->data, $preserveKeys));
 }