/**
     * @name warning This function revise if the current Navigator is Internet Explorer and if is true, show a message to upgrade if is older version
     */
    static function warning()
    {
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
            echo '<!--[if lte IE 9]>
				<div class="warning">' . kw::t('Please, update your Internet Explorer version or change to:', 'kw/InternetExplorer') . ' <a href="http://www.mozilla.org/es-ES/firefox/new/" target="_blank">Mozilla Firefox</a> o <a href="http://www.google.com/intl/es_es/chrome/" target="_blank">Google Chrome</a></div>
			<![endif]-->';
        }
    }
Exemple #2
0
 /**
  * Read a GET value and if exists it return to concatenate with the query
  * @param unknown $key
  * @param unknown $toadd The name of the field in the database
  * @param unknown $comparator !=, <, >, =
  */
 private function getQuery($key, $toadd, $comparator = '=')
 {
     $val = kw::get($key);
     if ($val != '') {
         return ' and ' . $toadd . $comparator . $val . ' ';
     }
     return '';
 }
 function rewriter($module = '', $controller = '', $action = '', $get = '', $lang = '')
 {
     // Base URL
     $r = kw::$config['url_base'];
     // Actions
     $r .= '?lang=' . kw::get('lang');
     $r .= '&m=' . ($module != '' ? $module : kw::get('m'));
     $r .= '&c=' . ($controller != '' ? $controller : kw::get('c'));
     $r .= '&a=' . ($action != '' ? $action : kw::get('a'));
     // Final GET
     if ($get != '') {
         $r .= '&' . $get;
     }
     return $r;
 }
Exemple #4
0
 /**
  * Connection to MySQL
  * @param unknown $host
  * @param unknown $db
  * @param unknown $user
  * @param unknown $pass
  */
 public function __construct()
 {
     // Load DB config
     if (!self::$conn) {
         kw::readConfig('db');
         $config = kw::$config['db'];
         $this->host = $config['host'];
         $this->db = $config['db'];
         $this->user = $config['user'];
         $this->pass = $config['pass'];
         self::$conn = new mysqli($this->host, $this->user, $this->pass, $this->db);
         if (self::$conn->connect_errno) {
             echo "ERROR connecting to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
             die;
         }
     }
 }
Exemple #5
0
<h1><?php 
echo kw::t('Error'), ' ', $this->error;
?>
</h1>
<p>
	<?php 
echo kw::t($this->errorMessage);
?>
</p>
Exemple #6
0
<?php

/**
 * @name KernelWeb & CMS: Index
 * @author ArrayZone
 * @package KernelCMS
 * @version 1.0
 * @copyright ArrayZone 2014
 * @license AZPL or later; see License.txt or http://arrayzone.com/license
 * @category core
 */
// Force show all errors (comment this when you finish the development)
error_reporting(E_ALL);
// Starting Kernel Web, this is the critical point of your app
// If you change this directory is needed to change in "cron.php" and everypage that you create
// If will use this in a lot of pages, you can create a new file like "loadKernel.php" with the include inside
include 'KernelWeb/main.php';
// To test load time
// If PHP version is lower than 5.4 it would start count time now, else it get time since petition was send
// If you like disable this, comment this line and the last line "ServerStatus::calcTime();"
//ServerStatus::calcTime();
// Execute Kernel Loader (with default controller and default action)
// it will load all pages
// You can specify what thing will be loaded if is not specified (for example, the default module)
kw::start('api', 'index', 'index');
// End test time
//ServerStatus::calcTime();
// This is all your index.php file!!! What do you expect?
Exemple #7
0
 /**
  * @name t (translate) This function show a translated text
  *  It selfinclude the language files
  *  All files have to be located in $app/private/modules/$module/lang/$lang-$LOCALE/$category (controller or something)
  * @param string $text Specify type of file (the name)
  * @param string $category
  * @param string $params
  */
 static function t($text, $category = 'generic', $params = array())
 {
     static $texts = array();
     // Loading main language file
     //include (kw::$dir . "system/language/".$lang.".php");
     if (isset($texts[$category][$text])) {
         //if exist the text to translate
         return $texts[$category][$text];
     } elseif (!isset($texts[$category])) {
         // main category is not included
         $file = kw::$app_dir . 'private/modules/' . kw::get('m') . '/lang/' . kw::$lang . '/' . $category . '.php';
         if (is_file($file)) {
             // File exists
             $texts[$category] = (include $file);
             return isset($texts[$category][$text]) ? $texts[$category][$text] : $text;
         } else {
             // File not exists, so it will be empty
             $texts[$category] = array();
         }
     }
     return $text;
 }
Exemple #8
0
<?php

/* CONTENT OF EACH ARRAY
 * 'TextMenu'=>array(
 * 		mod = module,
 *		cont = controller,
 * 		act = action,
 * 		target = type of target in href,
 * 		href = direct HREF (this is ignored if are "cont" or "act"
 * )
 * 
 * EMPTY show index
 */
return array(kw::t('Home', 'generic') => array('href' => array('cont' => 'index', 'act' => 'index')), kw::t('Documentation', 'generic') => array('href' => array('cont' => 'documentation', 'act' => 'index')), kw::t('Downloads', 'generic') => array('href' => array('cont' => 'downloads', 'act' => 'index')), kw::t('Changelog', 'generic') => array('href' => array('cont' => 'changelog', 'act' => 'index')), kw::t('Contact', 'generic') => array('href' => array('cont' => 'contact', 'act' => 'index')));
Exemple #9
0
 * @author ArrayZone
 * @package KernelWeb
 * @version 1.0
 * @copyright ArrayZone 2014
 * @license AZPL or later; see License.txt or http://arrayzone.com/license
 * @category core
 * 
 *
 * Log avaible levels
 * Log 
 * -1 - DISABLED (NOT RECOMMENDED)
 *  0 - FATAL
 *  1 - ERROR
 *  2 - WARNING (production mode)
 *  3 - INFO
 *  4 - DEBUG (Developer mode)
 *  5 - TRACE
 *  
 */
/*
 * user configs
 */
kw::$debug = true;
// Kernel Web debug mode. Disable on production mode
/*
 * Main configurations
 * You can re-configure only some parts of here in $app/private/config/app.conf.php
 */
kw::$app_dir = getcwd() . '/';
kw::$config = array('name' => 'KernelWeb', 'version' => 'A.0.3a', 'rewrite' => true, 'url_base' => ((isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . ((isset($_SERVER['SERVER_PORT']) and !in_array($_SERVER['SERVER_PORT'], array('80', '443'))) ? ':' . $_SERVER['SERVER_PORT'] : '') . ($_SERVER['SCRIPT_NAME'] != '/index.php' ? dirname($_SERVER['SCRIPT_NAME']) : '') . '/', 'languages' => array('es-ES', 'ca-ES', 'en-EN'), 'language_available_on_database' => false, 'log' => array('base' => array('level' => 2, 'file' => kw::$dir . 'system/logging/kernelweb.txt')));
Exemple #10
0
 /**
  * @name loadData
  * This function load a file located in $appdir/private/modules/$module/$file.php
  * The loaded file must RETURN something (like array or string), NOT echo (if you do this, use ob_start and return buffer)
  * @param string $data
  */
 static function loadData($file)
 {
     return require kw::$app_dir . 'private/modules/' . kw::get('m') . '/data/' . $file . '.php';
 }
Exemple #11
0
 * @copyright ArrayZone 2014
 * @license AZPL or later; see License.txt or http://arrayzone.com/license
 * @category Core
 * 
 * Description:
 * This script start all Kernel Web Services to work correctly.
 * Youre script only need have this file included to work
 */
// Starting session (required for language and others)
session_start();
// Loading the directory location
$dir = dirname(__FILE__) . '/';
// Loading the Kernel, configuration is included
require_once $dir . 'kernel/kw.php';
// Main KernelWeb Variables
kw::$dir = $dir;
// Kernel main auto-settings - Kernel Web directory
// Main controllers
require $dir . 'kernel/config.php';
require $dir . 'kernel/kwcontroller.php';
require $dir . 'kernel/kwview.php';
require $dir . 'kernel/rewriter.php';
/* 
 * AutoLoader Creator
 * If we try to use a non loaded class, the framework try to start it.
 * It's possible to add as must as loaders as we want, only one pe
 */
spl_autoload_register("kw::init");
spl_autoload_register("kw::addModel");
// Forcing close session... It delete the session...
//if (session_status() != PHP_SESSION_NONE) session_write_close();
 /**
  * @name log
  * @tutorial Save a log if is enabled logging
  * @param boolean $save If is true, save the log
  * @param string $message Message to log
  */
 private function log($message, $data = array())
 {
     if ($this->logErrors) {
         // Try to get a name (label or name)
         if (class_exists('kw')) {
             if (isset($data['label'])) {
                 $this->errors .= kw::te('Found an error in field', 'FormGenerator') . ': "' . $data['label'] . '": ';
             } elseif (isset($data['name'])) {
                 $this->errors .= kw::te('Found an error in field', 'FormGenerator') . ': "' . $data['name'] . '": ';
             }
         } else {
             if (isset($data['label'])) {
                 $this->errors .= 'Found an error in field' . $data['label'] . '": ';
             } elseif (isset($data['name'])) {
                 $this->errors .= 'Found an error in field' . ': "' . $data['name'] . '": ';
             }
         }
         // preparing message
         $this->errors .= ' ' . $message . '.';
         // Extra message (title attribute)
         if (isset($data['title']) and $data['title'] != '') {
             $this->errors .= ' | ' . kw::te('MESSAGE', 'FormGenerator') . ': ' . $data['title'];
         }
         $this->errors .= '<br />';
     }
 }
Exemple #13
0
<?php

/**
 * @name KernelWeb & CMS: Index
 * @author ArrayZone
 * @package KernelWeb - System
 * @version 1.0
 * @copyright ArrayZone 2014
 * @license AZPL or later; see License.txt or http://arrayzone.com/license
 * @category core
 */
// Force show all errors (comment this when you finish the development)
error_reporting(E_ALL);
//include '../KernelWeb/index.php'; // Starting Kernel Web, this is the critical point of your app
include '../main.php';
// To test load time
// If PHP version is lower than 5.4 it would start count time now, else it get time since petition was send
// If you like disable this, comment this line and the last line "ServerStatus::calcTime();"
ServerStatus::calcTime();
// Execute Kernel Loader (with default controller and default action)
// it will load all pages
// You can specify what thing will be loaded if is not specified (for example, the default module)
kw::start('main', 'index', 'index');
// End test time
ServerStatus::calcTime();
// This is all your index.php file!!! What do you expect?
Exemple #14
0
<?php

/* CONTENT OF EACH ARRAY
 * 'TextMenu'=>array(
 * 		mod = module,
 *		cont = controller,
 * 		act = action,
 * 		target = type of target in href,
 * 		href = direct HREF (this is ignored if are "cont" or "act"
 * )
 * 
 * EMPTY show index
 */
return array(kw::t('Home', 'generic') => array('href' => array('cont' => 'index', 'act' => 'index')), kw::t('Contact', 'generic') => array('href' => array('cont' => 'contact', 'act' => 'index')), 'ArrayZone.com' => array('target' => '_blank', 'href' => 'http://arrayzone.com'), 'KernelWeb Webpage' => array('target' => '_blank', 'href' => 'http://kernel.arrayzone.com'));