Пример #1
0
 public function render()
 {
     if ($this->icon) {
         $label = Html::icon($this->icon) . ' ' . Html::escape($this->label);
     } else {
         $label = Html::escape($this->label);
     }
     echo Html::element($this->tag, $this->attributes, $label);
 }
Пример #2
0
 /**
  * Render the element(s).
  */
 public function render()
 {
     if (method_exists($this, 'renderContents')) {
         echo Html::element($this->tag, $this->attributes, true);
         $this->renderContents();
         echo '</', $this->tag, '>';
     } else {
         echo Html::element($this->tag, $this->attributes);
     }
 }
Пример #3
0
 public function renderContents()
 {
     foreach ($this->items as $label => $values) {
         echo "\t";
         echo Html::element('dt', array(), $label);
         if (is_array($values)) {
             foreach ($values as $value) {
                 echo Html::element('dd', array(), $value);
             }
         } else {
             echo Html::element('dd', array(), $values);
         }
     }
 }
Пример #4
0
 /**
  * Render the items.
  */
 public function renderContents()
 {
     foreach ($this->items as $url => $action) {
         if (is_int($url) && is_string($action)) {
             echo "\t<li class=\"nav-header\">" . Html::escape($action) . "</li>\n";
         } else {
             echo "\t<li><a href=\"" . $url . '">';
             if (is_array($action)) {
                 //  has an icon?
                 echo Html::icon($action['icon']), ' ', Html::escape($action['label']);
             } else {
                 echo Html::escape($action);
             }
             echo "</a></li>\n";
         }
     }
 }
Пример #5
0
 protected function runSeed($class)
 {
     // Boot Laravel Framework
     $app = (require_once \Sledgehammer\PATH . 'bootstrap/app.php');
     $request = \Illuminate\Http\Request::capture();
     $app['request'] = $request;
     $app->bootstrapWith(['Illuminate\\Foundation\\Bootstrap\\DetectEnvironment', 'Illuminate\\Foundation\\Bootstrap\\LoadConfiguration', 'Illuminate\\Foundation\\Bootstrap\\ConfigureLogging', 'Illuminate\\Foundation\\Bootstrap\\RegisterFacades', 'Illuminate\\Foundation\\Bootstrap\\RegisterProviders', 'Illuminate\\Foundation\\Bootstrap\\BootProviders']);
     // Run the seeder
     $command = new DevutilsCommand();
     // @todo implement formatter
     $command->setOutput(new BufferedOutput());
     $seeder = new Seeder();
     $seeder->setCommand($command);
     $seeder->setContainer($app);
     $seeder->call($class);
     // Return the result
     return new Alert(nl2br(Html::escape($command->getOutput()->fetch())), ['class' => 'alert alert-info']);
 }
Пример #6
0
 public function render()
 {
     echo '<div style="white-space: pre">';
     $lines = explode("\n", $this->diff);
     array_shift($lines);
     // skip @@ @@
     foreach ($lines as $line) {
         $firstCharacter = substr($line, 0, 1);
         if ($firstCharacter == '+') {
             echo '<span style="background: lightgreen">';
         } elseif ($firstCharacter == '-') {
             echo '<span style="background: pink">';
         } else {
             echo '<span>';
         }
         echo Html::escape($line);
         echo "</span>\n";
     }
     echo '</div>';
 }
Пример #7
0
 public function renderContents()
 {
     echo "\n";
     foreach ($this->crumbs as $crumb) {
         if ($crumb['url'] == false || \Sledgehammer\value($crumb['active'])) {
             echo "\t<li class=\"active\">";
         } else {
             echo "\t<li>";
         }
         if (isset($crumb['icon'])) {
             $label = Html::icon($crumb['icon']) . ' ' . Html::escape($crumb['label']);
         } else {
             $label = Html::escape($crumb['label']);
         }
         if ($crumb['url']) {
             echo Html::element('a', array('href' => $crumb['url']), $label);
         } else {
             echo $label;
         }
         echo "</li>\n";
     }
 }
Пример #8
0
 public function render()
 {
     if ($this->count == 0) {
         // No pages, no pagination
         return;
     }
     $start = 1;
     $end = $this->count;
     $pages = array();
     $class = 'pagination';
     if ($this->align != 'left') {
         $class .= ' pagination-' . $this->align;
     }
     echo '<div class="' . $class . "\"><ul>\n";
     // previous
     if ($this->current != 1) {
         echo "\t<li>", Html::element('a', array('href' => $this->href . ($this->current - 1)), '&laquo;'), "</li>\n";
     }
     if ($this->count > $this->max) {
         $offset = floor($this->max / 2);
         if ($this->current < $offset + 2) {
             $end = $this->max - 1;
         } else {
             if ($this->current + $offset > $this->count) {
                 $start = $this->count - $this->max;
             } else {
                 $start = $this->current - $offset;
             }
             $end = $this->current + $offset;
             if ($end > $this->count) {
                 $end = $this->count;
             }
         }
     }
     // numbers
     for ($i = $start; $i <= $end; ++$i) {
         $attributes = $i == $this->current ? array('class' => 'active') : array();
         echo "\t", Html::element('li', $attributes, Html::element('a', array('href' => $this->href . $i), $i)), "\n";
     }
     // total pages indication
     if ($end != $this->count) {
         if ($end != $this->count - 1) {
             $nextDecimal = floor($this->current / 10) * 10 + 10;
             if ($nextDecimal > $this->count) {
                 $nextDecimal = $this->count;
             }
             echo "\t<li>", Html::element('a', array('href' => $this->href . $nextDecimal), '...'), "</li>\n";
             // @todo jump to page
         }
         echo "\t<li>", Html::element('a', array('href' => $this->href . $this->count), $this->count), "</li>\n";
     }
     // next
     if ($this->current != $this->count) {
         echo "\t<li>", Html::element('a', array('href' => $this->href . ($this->current + 1)), '&raquo;'), "</li>\n";
     }
     echo '</ul></div>';
 }
Пример #9
0
    }
    ?>
        </tbody>
    </table>
<?php 
}
if ($removed) {
    ?>
    <table class="table" style="width: auto;">
        <thead>
        <tr>
            <th>Option removed</th>
        </tr>
        </thead>
        <tbody>
        <?php 
    foreach ($removed as $key => $value) {
        ?>
            <tr>
                <td><?php 
        echo Html::escape($key);
        ?>
</td>
            </tr>
        <?php 
    }
    ?>
        </tbody>
    </table>
<?php 
}
Пример #10
0
 /**
  * Renders all logged entries in a <table>.
  */
 public function render()
 {
     echo '<table class="log-container">';
     echo '<thead class="log-header"><tr><th class="log-header-column logentry-number">Nr.</th>';
     if ($this->columns === null) {
         echo '<th class="log-header-column">', ucfirst($this->singular), '</th>';
         if ($this->totalDuration !== 0.0) {
             echo '<th class="log-header-column">Duration</th>';
         }
     } else {
         foreach ($this->columns as $column) {
             echo '<th class="log-header-column">', $column, '</th>';
         }
     }
     if ($this->backtrace !== 0) {
         echo '<th class="log-header-column">Backtrace</th>';
     }
     echo '</tr></thead>';
     echo '<tbody class="log-entries">';
     $nr = $this->start;
     foreach ($this->entries as $entry) {
         echo '<tr class="logentry">';
         echo '<td class="logentry-number">', $nr, '</td>';
         ++$nr;
         call_user_func($this->renderer, $entry[0], $entry[1]);
         if ($this->backtrace !== 0) {
             if (isset($entry[1]['backtrace'])) {
                 $backtrace = $entry[1]['backtrace'];
                 $call = array_shift($backtrace);
                 $trace = ' in ' . $call['file'] . ' on line <b">' . $call['line'] . '</b>';
                 $tooltip = '';
                 foreach ($backtrace as $call) {
                     $tooltip .= ' ' . $call['file'] . ' on line ' . $call['line'] . "\n";
                 }
                 echo ' <td class="log-backtrace" title="' . Html::escape($tooltip) . '">' . $trace . '</td>';
             } else {
                 echo '<td></td>';
             }
         }
         echo "</tr>\n";
     }
     echo '</tbody>';
     echo '</table>';
     if ($this->count > count($this->entries)) {
         echo '<br /><spann class="logentry-alert">The other ' . ($this->count - count($this->entries)) . ' ' . $this->plural . ' are suppressed.</span>';
     }
 }
Пример #11
0
 static function renderLog($entry, $meta)
 {
     $duration = $meta['duration'];
     if ($duration > 3) {
         $color = 'logentry-alert';
     } elseif ($duration > 1.5) {
         $color = 'logentry-warning';
     } else {
         $color = 'logentry-debug';
     }
     echo '<td title="', Html::escape($entry), '">', Html::escape($meta['relativeUrl']), '</td>';
     echo '<td class="logentry-number ', $color, '"><b>', format_parsetime($duration), '</b>&nbsp;sec</td>';
 }
Пример #12
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";
Пример #13
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;
     }
 }
Пример #14
0
        <?php 
foreach ($stories as $story) {
    $total += $story['points'];
    ?>
 
            <tr>
                <td><?php 
    echo Html::escape($story['epic']);
    ?>
</td>
                <td><?php 
    echo Html::escape($story['summary']);
    ?>
</td>
                <td><?php 
    echo Html::escape($story['points']);
    ?>
</td>
            </tr>
        <?php 
}
?>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="3">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="2"><b>Total</b></td>
            <td><b><?php 
echo $total;
Пример #15
0
 public function renderContents()
 {
     echo "\n";
     if ($this->fieldset) {
         echo "<fieldset>\n";
         if ($this->legend !== null) {
             echo "\t<legend>", Html::escape($this->legend), "</legend>\n";
         }
     }
     // Render form fields
     foreach ($this->fields as $label => $field) {
         echo "\t";
         render($field);
         echo "\n";
     }
     if ($this->fieldset) {
         echo "</fieldset>\n";
     }
     // Render form actions
     if (count($this->actions) !== 0) {
         foreach ($this->actions as $key => $component) {
             render($component);
         }
     }
 }