コード例 #1
0
ファイル: App.php プロジェクト: alekseynemiro/WebForms.PHP
 /**
  * Initializes the app.
  */
 public static function Init()
 {
     if (!class_exists('\\Nemiro\\Server')) {
         \Nemiro\App::IncludeFile('Server.php');
         new \Nemiro\Server();
     }
     if (!class_exists('\\Nemiro\\Text')) {
         \Nemiro\App::IncludeFile('Text.php');
     }
     if (!class_exists('\\Nemiro\\Console')) {
         \Nemiro\App::IncludeFile('Console.php');
     }
     if (!class_exists('\\Nemiro\\UI\\Page')) {
         \Nemiro\App::IncludeFile('~/Nemiro/UI');
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: alekseynemiro/WebForms.PHP
<?php

require_once 'global.php';
/**
 * The main page.
 */
class Index extends \Nemiro\UI\Page
{
}
\Nemiro\App::Magic();
コード例 #3
0
ファイル: global.php プロジェクト: alekseynemiro/WebForms.PHP
<?php

# config.php from the root path
require_once 'config.php';
# app.php from the WebForms.PHP
require_once $_SERVER['DOCUMENT_ROOT'] . '/Nemiro/App.php';
# import and init application class
use Nemiro\App;
App::Init();
# set event handlers
App::AddHandler('Application_BeginRequest');
App::AddHandler('Application_PageCreated');
# you are not required to use all the handlers
# App::AddHandler('Application_EndRequest');
# App::AddHandler('Application_IncludedFile');
# App::AddHandler('Application_Error');
# you can use custom handler names
# App::AddHandler('Session_Start', 'MyHandler');
# include database clients
# get from https://github.com/alekseynemiro/Nemiro.Data.PHP
# App::IncludeFile('~/Nemiro/Data');
$CurrentLang = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : PAGE_DEFAULT_CULTURE;
# application event handlers
function Application_BeginRequest()
{
    global $CurrentLang;
    if (isset($_GET['lang']) && $CurrentLang != $_GET['lang'] || isset($_GET['lang']) && $_GET['lang'] == 'en') {
        setcookie('lang', $_GET['lang'], time() + 2592000);
        if ($_GET['lang'] == 'en') {
            unset($_GET['lang']);
        }
コード例 #4
0
require_once 'config.php';
# app.php from the WebForms.PHP
require_once $_SERVER['DOCUMENT_ROOT'] . '\\Nemiro\\App.php';
# import and init application class
use Nemiro\App;
App::Init();
# set event handlers
App::AddHandler('Application_BeginRequest');
# you are not required to use all the handlers
# App::AddHandler('Application_EndRequest');
# App::AddHandler('Application_IncludedFile');
App::AddHandler('Application_Error');
# you can use custom handler names
App::AddHandler('Session_Start', 'MyHandler');
# include files from folder using Import.php
App::IncludeFile('~/Nemiro/Collections');
# include database clients
# get from https://github.com/alekseynemiro/Nemiro.Data.PHP
# App::IncludeFile('~/Nemiro/Data');
# include your modules
# App::IncludeFile('~/user.php');
# App::IncludeFile('~/your/path/here.php');
# application event handlers
function Application_BeginRequest()
{
    # echo 'Processing...';
}
# function Application_IncludedFile($path)
# {
#		echo sprintf('Included: %s', $path);
# }
コード例 #5
0
ファイル: Page.php プロジェクト: alekseynemiro/WebForms.PHP
 /**
  * Loads text resources for the current culture.
  */
 private function LoadResources()
 {
     \Nemiro\Console::Info('Resources loading.');
     # global resources
     $this->MergeResources('~/global.json');
     # global resources for current culture
     if ($this->Culture != NULL && $this->Culture != '') {
         if (!$this->MergeResources('~/global.' . $this->Culture . '.json') && strpos($this->Culture, '-') !== FALSE) {
             $this->MergeResources('~/global.' . explode('-', $this->Culture)[0] . '.json');
         }
     }
     $sciptName = App::GetScriptPath() . App::GetScriptName();
     # load default resourses for current page
     $this->MergeResources($sciptName . '.json');
     # load resourses for current culture
     if ($this->Culture != NULL && $this->Culture != '') {
         if (!$this->MergeResources($sciptName . '.' . $this->Culture . '.json') && strpos($this->Culture, '-') !== FALSE) {
             $this->MergeResources($sciptName . '.' . explode('-', $this->Culture)[0] . '.json');
         }
     }
     \Nemiro\Console::Info('Resources loaded.');
 }