public function init()
 {
     $this->langs = $this->params['langs'];
     $lang = Request::get('lang');
     $lang_cookie = Gbox::getRequest()->getCookies('lang');
     if ($lang && in_array($lang, $this->langs)) {
         $this->setLang($lang);
     } else {
         if (isset($lang_cookie) && in_array($lang_cookie, $this->langs)) {
             $this->setLang($lang);
         } else {
             $this->setLang(self::LANG_DEFAULT);
         }
     }
     $name_file = 'strings-' . $this->lang . '.json';
     $url = Url::to(['@components', 'ConfigLanguages', $name_file]);
     $json = file_get_contents($url);
     $this->strings = Json::decode($json, true);
     if (self::LANG_DEFAULT == $this->lang) {
         $this->strings_default = Json::decode($json, true);
     } else {
         $name_file = 'strings-' . self::LANG_DEFAULT . '.json';
         $url = Url::to(['@components', 'ConfigLanguages', $name_file]);
         $json = file_get_contents($url);
         $this->strings_default = Json::decode($json, true);
     }
 }
 public function init()
 {
     $this->path = Url::to($this->params['path']);
     if (!file_exists($this->path)) {
         mkdir($this->path, 0777, true);
     }
     $this->file = tempnam($this->path, 'debug');
 }
 public static function Navbar($id = null, $navbar_nav = null)
 {
     $html = '<nav class="navbar navbar-default navbar-static-top">';
     $html .= '<div class="container">';
     $html .= '<div class="navbar-header">';
     if ($navbar_nav) {
         $html .= '<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar-collapse-' . $id . '" aria-expanded="false">';
         $html .= '<span class="sr-only">Toggle navigation</span>';
         $html .= '<span class="icon-bar"></span>';
         $html .= '<span class="icon-bar"></span>';
         $html .= '<span class="icon-bar"></span>';
         $html .= '</button>';
     }
     $html .= '<a class="navbar-brand" href="' . Url::goHome() . '">' . Gbox::getConfig()->params['app_name'] . '</a>';
     $html .= '</div>';
     if ($navbar_nav) {
         $html .= $navbar_nav;
     }
     $html .= '</div>';
     $html .= '</nav>';
     return $html;
 }
 public function __construct()
 {
     if (isset($_GET['route'])) {
         $route = filter_input(INPUT_GET, 'route', FILTER_SANITIZE_URL);
         $route = explode('/', $route);
         $route = array_filter($route);
         /* Compruebo si se trata de una petición a un módulo configurado */
         if (count($route) > 0) {
             if (Gbox::getModules($route[0])) {
                 $this->module = array_shift($route);
             }
             $this->controller = array_shift($route);
             $this->action = array_shift($route);
             $this->args = $route;
         }
     }
     if (!$this->controller) {
         $this->controller = 'site';
     }
     if (!$this->action) {
         $this->action = 'index';
     }
     if (!isset($this->args)) {
         $this->args = [];
     }
     $this->controller = implode('', array_map('ucfirst', explode('-', $this->controller)));
     $this->action = implode('', array_map('ucfirst', explode('-', $this->action)));
     if (!$this->module && Gbox::getConfig()->shortUrl) {
         $tmp_controller_url = '@controllers/' . ucfirst($this->controller) . 'Controller' . '.php';
         Url::to($tmp_controller_url);
         if (!file_exists(Url::to($tmp_controller_url)) && strtolower($this->action) == 'index') {
             $this->action = $this->controller;
             $this->controller = 'site';
         }
     }
 }
			    <div class="panel-heading"><h3 class="panel-title"><strong><?php 
echo $this->title;
?>
</strong></h3></div>
			    <div class="panel-body">
					<?php 
echo $form->field($model, 'username')->input('text', ['placeholder' => 'Usuario o correo electrónico'])->label(false);
?>
					<?php 
echo $form->field($model, 'password')->input('password', ['placeholder' => $model->getAttrLabel('password')])->label(false);
?>
				</div>
				<div class="panel-footer text-right">
					<div class="pull-left">
						<?php 
echo $form->field($model, 'rememberMe')->input('checkbox', ['class' => ''])->label(false)->setTemplate('<div class="checkbox"><label>{input} No cerrar sesión</label></div>');
?>
					</div>
					<?php 
echo Html::a('Registrarme', Url::to('@web/account/sign-up'), ['class' => 'btn btn-default']);
?>
					<?php 
echo Html::submitButton('Iniciar sesión', ['class' => 'btn btn-primary']);
?>
				</div>
			</div>
		<?php 
$form->end();
?>
	</div>
</div>
Exemple #6
0
<?php

use Gbox\helpers\Url;
use Gbox\helpers\Html;
?>
<div class="jumbotron">
	<?php 
if (Gbox::$components->user->isGuest) {
    ?>
		<h1>Bienvenido</h1>
	<?php 
} else {
    ?>
		<h1>Bienvenido, <?php 
    echo Gbox::$components->user->firstname;
    ?>
</h1>
	<?php 
}
?>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti saepe dolore voluptas, recusandae quia, quaerat veritatis aperiam? Illum praesentium natus in labore, at harum hic quisquam consequuntur ad, architecto atque.</p>
	<p><a class="btn btn-primary btn-lg" href="<?php 
echo Url::to('@web/features');
?>
" role="button">Características</a></p>
</div>
Exemple #7
0
?>
	            <?php 
foreach (\Gbox\base\Session::get('files-debug', []) as $file) {
    ?>
	            	<?php 
    if ($i < 10) {
        $i++;
    } else {
        break;
    }
    ?>
		            <li class="<?php 
    echo $file == \Gbox\base\Session::get('files-debug-current') ? 'active' : '';
    ?>
"><a href="<?php 
    echo Url::to('@web-module', ['id' => $file]);
    ?>
"><?php 
    echo $file;
    ?>
</a></li>
		        <?php 
}
?>
	          </ul>
	        </li>
	      </ul>
	    </div><!-- /.navbar-collapse -->
	  </div><!-- /.container-fluid -->
	</nav>
	<div class="container">
 protected function goHome()
 {
     return Gbox::getResponse()->redirect(Url::goHome());
 }
Exemple #9
0
<body>
    <h1><?php 
echo $name;
?>
</h1>
    <h2><?php 
echo nl2br($message);
?>
</h2>
    <p>The above error occurred while the Web server was processing your request.</p>
    <p>Please contact us if you think this is a server error. Thank you.</p>
    <div class="version">
        <?php 
echo date('Y-m-d H:i:s', time());
?>
    </div>
    <div class="version">
        <?php 
echo session_id();
?>
    </div>
    <div class="version">
        Servidor o aplicación mal configurado.
        <a href="<?php 
echo \Gbox\helpers\Url::to('@web');
?>
">Volver al inicio</a>
    </div>
</body>
</html>
Exemple #10
0
if (\Gbox::getRequest()->get('type') == 'orm') {
    echo 'active';
}
?>
">Orm</a>
			<a href="<?php 
echo Url::to('@web-module', ['id' => Session::get('files-debug-current'), 'type' => 'model']);
?>
" class="list-group-item <?php 
if (\Gbox::getRequest()->get('type') == 'model') {
    echo 'active';
}
?>
">Model</a>
			<a href="<?php 
echo Url::to('@web-module', ['id' => Session::get('files-debug-current'), 'type' => 'sendmail']);
?>
" class="list-group-item <?php 
if (\Gbox::getRequest()->get('type') == 'sendmail') {
    echo 'active';
}
?>
">Sendmail</a>
		</div>
	</div>
	<div class="col-md-9">
		<div class="panel-group" id="accordion-debug" role="tablist" aria-multiselectable="true">
			<?php 
$i = -1;
?>
			<?php 
Exemple #11
0
 private function head()
 {
     echo Html::title($this->title);
     echo Html::meta('description', $this->description);
     foreach ($this->metaTags as $data) {
         $http = array_key_exists('http', $data) ? $data['http'] : null;
         echo Html::meta($data['name'], $data['content'], $http);
     }
     foreach ($this->css as $data) {
         if (is_string($data)) {
             // var_dump(Url::checkExternalUrl($data));
             if (!Url::checkExternalUrl($data)) {
                 $data = ['@css', $data];
             }
             echo Html::link(Url::to($data));
         } else {
             if (is_array($data)) {
                 if (!Url::checkExternalUrl($data['url'])) {
                     $data['url'] = ['@css', $data['url']];
                 }
                 echo Html::link(Url::to($data['url']), $data['rel'], $data['type']);
             }
         }
     }
     foreach ($this->js as $data) {
         if (is_string($data)) {
             if (!Url::checkExternalUrl($data)) {
                 $data = ['@js', $data];
             }
             echo Html::script(Url::to($data));
         } else {
             if (is_array($data)) {
                 if (!Url::checkExternalUrl($data['url'])) {
                     $data['url'] = ['@js', $data['url']];
                 }
                 echo Html::script(Url::to($data['url']), $data['type'], $data['async']);
             }
         }
     }
 }
 public function redirect($url, $code = 302)
 {
     Gbox::getResponse()->setStatusCode($code);
     Gbox::getResponse()->getHeaders()->set('location', Url::to($url));
 }
Exemple #13
0
 public static function Show()
 {
     return Bootstrap::Navbar('mainmenu', Bootstrap::NavbarNav('mainmenu', [['name' => 'Página principal', 'url' => Url::goHome()], ['name' => 'Características', 'url' => Url::to('@web/features')], ['name' => 'GitHub', 'url' => 'https://github.com/RoxguelDevs/GboxFramework', 'target' => '_blank'], Gbox::$components->user->isGuest ? null : ['name' => 'Mi cuenta', 'url' => Url::to('@web/account')], Gbox::$components->user->isGuest ? ['name' => 'Acceder', 'url' => Url::to('@web/account/login')] : ['name' => 'Cerrar sesión', 'url' => Url::to('@web/account/sign-out')]]));
 }
Exemple #14
0
 private function router()
 {
     /* Compruebo si se trata de una petición a un módulo configurado */
     if (static::$request->getModule()) {
         /*=============================
         		=            DEBUG            =
         		=============================*/
         static::$components->debug->saveReportRouter(['message' => 'Module detected.', 'subtype' => 'module', 'name' => static::$request->getModule()]);
         /*=====  End of DEBUG  ======*/
         $module_file = static::$request->getModule() . '/Module.php';
         $module_string = static::getModules(static::$request->getModule())['class'];
         $invoke = '\\app\\' . static::$request->getModule() . '\\controllers\\';
         require Url::to(['@modules', $module_file]);
         /*=============================
         		=            DEBUG            =
         		=============================*/
         static::$components->debug->saveReportRouter(['message' => 'File module path.', 'subtype' => 'module', 'path' => Url::to(['@modules', $module_file])]);
         /*=====  End of DEBUG  ======*/
         $module = new $module_string();
     } else {
         $invoke = '\\app\\controllers\\';
     }
     $controller = ucfirst(static::$request->getController()) . 'Controller';
     $action = 'action' . ucfirst(static::$request->getAction());
     /*=============================
     		=            DEBUG            =
     		=============================*/
     static::$components->debug->saveReportRouter(['message' => 'Set action.', 'subtype' => 'action', 'name' => $action]);
     /*=====  End of DEBUG  ======*/
     $controller_url = Url::to('@controllers/' . $controller . '.php');
     /*=============================
     		=            DEBUG            =
     		=============================*/
     static::$components->debug->saveReportRouter(['message' => 'Read controller file.', 'subtype' => 'controller', 'url' => $controller_url]);
     /*=====  End of DEBUG  ======*/
     if (!is_readable($controller_url)) {
         throw new NotFoundHttpException("No se puede leer el archivo del controlador.");
     }
     require $controller_url;
     $invoke .= $controller;
     if (!class_exists($invoke)) {
         throw new NotFoundHttpException("No existe la clase en el controlador.");
     }
     if (!is_callable([$invoke, $action])) {
         throw new NotFoundHttpException("No se puede llamar al método (acción) en la clase del controlador.");
     }
     if (static::$request->getArgs() !== NULL) {
         call_user_func_array([new $invoke(), $action], static::$request->getArgs());
     } else {
         call_user_func([new $invoke(), $action]);
     }
 }
Exemple #15
0
					<hr />
					<p><strong>Datos de acceso</strong></p>
					<?php 
echo $form->field($model, 'email')->input('email', ['placeholder' => $model->getAttrLabel('email')])->label(false);
?>
					<?php 
echo $form->field($model, 'username')->input('text', ['placeholder' => $model->getAttrLabel('username')])->label(false);
?>
					<hr />
					<p><strong>Contraseña</strong></p>
					<?php 
echo $form->field($model, 'password')->input('password', ['placeholder' => $model->getAttrLabel('password')])->label(false);
?>
					<?php 
echo $form->field($model, 'password_confirm')->input('password', ['placeholder' => $model->getAttrLabel('password_confirm')])->label(false);
?>
				</div>
				<div class="panel-footer text-right">
					<?php 
echo Html::a('Iniciar sesión', Url::to('@web/account/sign-in'), ['class' => 'btn btn-default']);
?>
					<?php 
echo Html::submitButton('Registrarme', ['class' => 'btn btn-primary']);
?>
				</div>
			</div>
		<?php 
$form->end();
?>
	</div>
</div>