/** * Redirige a una url * @param mixed $url Url o arreglo que especifica prefijo, controlador y accion */ public static function redirect($url = null) { ob_start(); header('Location:' . \Supernova\Route::generateUrl($url)); ob_flush(); die; }
public static function create($args) { // Carga un nuevo objeto formulario // Load new form object $modelForm = "\\App\\Model\\" . $args['model'] . "Form"; $form = new $modelForm(); $form->modelName = $args['model']; $form->values = isset($args['values']) && !empty($args['values']) ? $args['values']->toArray() : array(); $form->schema = \Supernova\Cache::load($args['model']); // Genera el formulario // Generate form $action = isset($args['action']) ? \Supernova\Route::generateUrl($args['action']) : ""; $output = "<form class='form-horizontal' role='form' action='{$action}' method='POST' >"; // Genera los inputs // Generate inputs $form->notShow = array("created", "updated", "created_at", "updated_at", "modified", "creado_en", "actualizado_en"); foreach ($form->schema as $field) { if (!in_array($field['Field'], $form->notShow)) { $output .= self::input($field, $form); } } // Agrega boton submit en el formulario // Add submit button in form if (!(isset($args['submit']) && $args['submit'] == false)) { $output .= self::submit(); } self::$counter++; return $output; }
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 "; }
/** * Llama a las paginas de error * @param integer $num Numero de error a mostrar * @param string $encodedError DepuraciĆ³n de error encriptado */ public static function callError($num = 404, $encodedError = "") { include ROOT . DS . \Supernova\Route::getPublicFolder() . DS . "errors" . DS . $num . '.php'; die; }
<div id="wrapper"> <header id="header"> <!-- Header Left : Logo and Site name --> <div class="header-left"> <!-- Header Logo --><img src='<?php echo \Supernova\Route::getPublicUrl(); ?> /errors/img/snf_logo_t.png' /> <!-- Site name --><h1></h1> </div> </header><!-- #header--> <section id="middle"> <div id="container"> <div id="content"> <div style="float:left; width: 110px"><img src='<?php echo \Supernova\Route::getPublicUrl(); ?> /errors/img/error404.jpg' /></div> <div style="float:left; width: 80%"> <h2>Error 404</h2> <h3><?php echo __("OOPS, Nothing found here"); ?> </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"); ?>
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; }