Beispiel #1
0
 public static function templateEdit()
 {
     extract(\Supernova\View::$values);
     $name = \Supernova\Core::$elements['controller'];
     $title = inject(__("Edit %name%: %item%"), array("name" => $name, "item" => ${$name}));
     $form = \Supernova\Form::create(array("model" => $name, "values" => ${$name}));
     $link = \Supernova\Helper::link(array("href" => \Supernova\Route::generateUrl(array("prefix" => \Supernova\Core::$elements['prefix'], "controller" => $name, "action" => "index")), "text" => __("<< Back")));
     return "\n        <h3>{$title}</h3>\n        {$form}\n        {$link}\n        ";
 }
Beispiel #2
0
echo __("OOPS, Something went wrong");
?>
</h3>
                        <p><?php 
echo __("The page you are trying to access seems to no longer exists.");
?>
</p>
                        <p><?php 
echo __("Check you address bar, meaby you got a mistaken address");
?>
</p>
                    </div>
                    <div style="clear:both;"></div>
                    <br/><br/>
<?php 
if (!empty($encodedError)) {
    echo "<p>" . __("If the problem persist, please send this text to the administrator email:") . \Supernova\Helper::link(["href" => "mailto:" . CONTACT_EMAIL, "text" => CONTACT_EMAIL, "class" => ["adminemail"]]) . "</p>";
    echo "<pre class='encodedError'>";
    echo $encodedError;
    echo "</pre>";
}
?>
				</div><!-- #content-->
			</div><!-- #container-->
		</section><!-- #middle-->
	</div><!-- #wrapper -->
	<footer id="footer">
	</footer><!-- #footer -->
</body>
</html>
Beispiel #3
0
    public static function table($args)
    {
        $objects = $args['values'];
        if (!$objects) {
            return "<table class='table table-striped' ><tr><td>" . __("No results") . "</td></tr></table>";
        } else {
            if (!is_object(current($objects))) {
                trigger_error(__("Objects not found in value called for Helper::table. Array or string found"), E_USER_WARNING);
            }
            $modelName = explode("\\", get_class(current($objects)));
            $modelName = end($modelName);
            $model = "\\App\\Model\\" . $modelName;
            $modelForm = $model . "Form";
            $form = new $modelForm();
            // get header
            $fields = current($objects)->toArray();
            $labels = array_keys($fields);
            $labelTH = "";
            foreach ($labels as $label) {
                $labelTH .= "<th>";
                $labelTH .= isset($form->settings[$label]["widget"]["label"]) ? $form->settings[$label]["widget"]["label"] : $label;
                $labelTH .= "</th>";
            }
            $labelTH .= "<th>Acciones</th>";
            $eachData = "";
            foreach ($objects as $object) {
                $results = $object->toArray();
                $eachData .= "<tr>";
                foreach ($results as $fields => $values) {
                    $eachData .= "<td>";
                    if (isset($args['use']) && isset($args['use'][$fields])) {
                        if (is_array($args['use'][$fields])) {
                            $eachData .= $args['use'][$fields][$values];
                        }
                        if (is_string($args['use'][$fields])) {
                            $fn = explode("::", $args['use'][$fields]);
                            if (method_exists($fn[0], $fn[1])) {
                                if ($fn[1] != "getList") {
                                    $eachData .= $fn[0]::$fn[1]($values);
                                } else {
                                    $list = $fn[0]::$fn[1]();
                                    $eachData .= isset($list[$values]) ? $list[$values] : "";
                                }
                            }
                        }
                    } else {
                        $eachData .= $values;
                    }
                    $eachData .= "</td>";
                }
                $actions = isset($args['actions']) ? $args['actions'] : array('edit' => __('Edit'), 'delete' => __('Delete'));
                if ($actions) {
                    $eachData .= "<td>";
                    $eachLink = "";
                    foreach ($actions as $action => $label) {
                        $eachLink .= \Supernova\Helper::link(array("href" => \Supernova\Route::generateUrl(array("prefix" => \Supernova\Inflector::camelToUnder(\Supernova\Core::$elements['prefix']), "controller" => \Supernova\Inflector::camelToUnder(\Supernova\Core::$elements['controller']), "action" => $action, "id" => $results['id'])), "text" => $label));
                    }
                    $eachData .= $eachLink;
                    $eachData .= "</td>";
                }
                $eachData .= "</tr>";
            }
        }
        $output = <<<EOL
        <table class="table table-striped" >
            <thead>
                <tr>
                    {$labelTH}
                </tr>
            </thead>
            <tbody>
                {$eachData}
            </tbody>
            <tfoot>
            </tfoot>
        </table>
EOL;
        return $output;
    }