Пример #1
0
 public function before()
 {
     parent::before();
     $this->metadata = Model::factory('Metadata');
     $this->set('_metadata', $this->metadata);
     Auth::instance()->auto_login();
     $this->set('_language', i18n::lang());
     $this->metadata->title('Вход в панель управления', false);
 }
Пример #2
0
 /**
  * gets the fragment name, unique using i18n theme and skin and cat and loc
  * @param  string $name 
  * @return string       
  */
 public static function fragment_name($name)
 {
     $cat_seoname = '';
     if (Model_Category::current()->loaded()) {
         $cat_seoname = '_category_' . Model_Category::current()->seoname;
     }
     return 'fragment_' . $name . '_' . i18n::lang() . '_' . Theme::$theme . $cat_seoname;
     //.Theme::$skin
 }
Пример #3
0
 /**
  * gets the fragment name, unique using i18n theme and skin and cat and loc
  * @param  string $name 
  * @return string       
  */
 public static function fragment_name($name)
 {
     $cat_seoname = '';
     if (Controller::$category !== NULL) {
         if (Controller::$category->loaded()) {
             $cat_seoname = '_category_' . Controller::$category->seoname;
         }
     }
     $loc_seoname = '';
     if (Controller::$location !== NULL) {
         if (Controller::$location->loaded()) {
             $loc_seoname = '_location_' . Controller::$location->seoname;
         }
     }
     return 'fragment_' . $name . '_' . i18n::lang() . '_' . Theme::$theme . $cat_seoname . $loc_seoname;
     //.Theme::$skin
 }
Пример #4
0
Файл: view.php Проект: azuya/Wi3
 public function set_filepath($filepath)
 {
     // Get path for possible translations
     if (strrpos($filepath, "/") !== FALSE) {
         $split = strrpos($filepath, "/");
         $firstpart = substr($filepath, 0, $split + 1);
         // The +1 to catch the /
         $lastpart = substr($filepath, $split + 1);
     } else {
         $firstpart = "";
         $lastpart = $filepath;
     }
     // Check whether translation exists, and load it if so
     if (file_exists($firstpart . "i18n/" . i18n::lang() . "/" . $lastpart)) {
         $this->_file = $firstpart . "i18n/" . i18n::lang() . "/" . $lastpart;
     } elseif (file_exists($firstpart . "i18n/" . substr(i18n::lang(), 0, 2) . "/" . $lastpart)) {
         $this->_file = $firstpart . "i18n/" . substr(i18n::lang(), 0, 2) . "/" . $lastpart;
     } else {
         $this->_file = $filepath;
     }
     return $this;
 }
Пример #5
0
/**
 * Enable the Kohana auto-loader for unserialization.
 *
 * @see  http://php.net/spl_autoload_call
 * @see  http://php.net/manual/var.configuration.php#unserialize-callback-func
 */
ini_set('unserialize_callback_func', 'spl_autoload_call');
//-- Configuration and initialization -----------------------------------------
/**
 * Set the development status
 */
define('IN_DEVELOPMENT', $_SERVER['SERVER_NAME'] === 'localhost');
/**
 * Sets the sites’ language
 */
i18n::$lang = 'sv-se';
/**
 * Initialize Kohana, setting the default options.
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
 * - string   index_file  name of your index file, usually "index.php"       index.php
 * - string   charset     internal character set used for input and output   utf-8
 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 */
Kohana::init(array('base_url' => '/', 'index_file' => '', 'profiling' => IN_DEVELOPMENT, 'caching' => !IN_DEVELOPMENT));
/**
Пример #6
0
Файл: wi3.php Проект: azuya/Wi3
 public function init()
 {
     // Load session handler
     $this->session = Session::instance();
     // Set cache handler
     $this->cache = Wi3TikoCache::instance();
     // Define APPRELATIVEPATH, which is the path to the application relative to the web root
     // We can retrieve this by using the SCRIPT_NAME from the front-controller ({pathfromroot}/app/index.php), and extracting the path-from-root
     define("APPRELATIVEPATH", substr($_SERVER["SCRIPT_NAME"], 0, strpos($_SERVER["SCRIPT_NAME"], "/app/index.php")) . "/app/latest/");
     // Define document root
     // TODO: Add support for ISS (see http://www.helicron.net/php/)
     define("DOCUMENTROOT", $_SERVER["DOCUMENT_ROOT"] . "/");
     // Determine language
     $lang = Cookie::get('lang');
     if ($lang !== NULL) {
         if (!in_array($lang, array('nl-nl', 'en-us'))) {
             // Check the allowed languages, and force the default
             $lang = 'nl-nl';
         }
     } else {
         // Language not set in cookie. Get default language from i18n file.
         $i18nfiles = Kohana::find_file("config", "i18n");
         if (!empty($i18nfiles)) {
             $i18nsettings = Kohana::load($i18nfiles[0]);
             $lang = $i18nsettings["lang"];
         } else {
             $lang = 'nl-nl';
             // Fall back to default
         }
         // Save loaded language in cookie
         Cookie::set('lang', $lang);
     }
     // Set the target language
     i18n::lang($lang);
     // Set the source language to some non-existing language to prevent Kohana skipping translation lookup if source and target language are identical
     i18n::$source = "bb-bb";
     // See http://unicode.org/cldr/utility/languageid.jsp?a=bb&l=en for valid tags
     // Load wi3-kohana-specific functions
     $this->kohana = new Wi3_Kohana();
     // XSS Clean all user input!
     // TODO: only do this if the user is not an admin...
     $this->originalpost = $_POST;
     // Save original $_POST
     foreach ($_POST as $key => $val) {
         $_POST[$key] = Security::xss_clean($val);
     }
     $this->originalget = $_GET;
     // Save original $_GET
     foreach ($_GET as $key => $val) {
         $_GET[$key] = Security::xss_clean($val);
     }
     // Load some Wi3 classes
     // Load a global database configuration
     $this->database = new Wi3_Database();
     // Helper functions to create databases etc
     $this->globaldatabase = Wi3_Database::instance("global");
     Event::instance("wi3.init.globaldatabase.loaded")->execute();
     // Get routing, url and path information
     // These classes in turn add a callback to the wi3.init.site.loaded Event, after which they will update with path and urls to the site
     $this->routing = Wi3_Routing::instance();
     Event::instance("wi3.init.routing.loaded")->execute();
     $this->pathof = Wi3_Pathof::instance();
     Event::instance("wi3.init.pathof.loaded")->execute();
     $this->urlof = Wi3_Urlof::instance();
     Event::instance("wi3.init.urlof.loaded")->execute();
     // Load CSS and Javascript 'injectors'
     $this->css = Wi3_Css::instance();
     $this->javascript = Wi3_Javascript::instance();
     // Instantiate the Model class, that is an interface to the 'factory' method for any underlying model-systems
     $this->model = Wi3_Model::inst();
     Event::instance("wi3.init.model.loaded")->execute();
     // Instantiate the form-builder
     $this->formbuilder = Wi3_Formbuilder::inst();
     Event::instance("wi3.init.formbuilder.loaded")->execute();
     // Now find out what is the scope of this request
     // It most often is a site-scope (i.e. the admin or view of a site), but might also be a global scope (i.e. superadmin)
     // This depends on the controller.
     // Pagefiller-specific controllers are always for the the sitearea
     $this->scope = (substr(Request::instance()->controller, 0, 9) == "adminarea" or substr(Request::instance()->controller, 0, 10) == "pagefiller" or Request::instance()->controller == "sitearea") ? "site" : "global";
     if ($this->scope == "site") {
         $this->sitearea = Wi3_Sitearea::inst();
         // Find out what site we are working with
         // Both the admin controller and the site controller need to know this in order to work properly
         // Find the site by apache 'sitename' variable
         if (isset($_SERVER['REDIRECT_SITENAME'])) {
             $sitename = $_SERVER['REDIRECT_SITENAME'];
             // With correct loading, $_SERVER['REDIRECT_SITENAME'] should always be present, as it is set in the vhosts .htaccess that redirect here
             // Global site is the site in the global space, i.e. the Site model in the 'list of sites' that is always accesible
             // ( In the per-site database, there can only exist one Site model )
             $this->sitearea->globalsite = $this->model->factory("site")->set('name', $sitename)->load();
             Event::instance("wi3.init.sitearea.globalsite.loaded")->execute();
             $this->sitearea->site = $this->sitearea->globalsite;
             // This site instance will be replaced by the local user site. The ->name will be added to that local site, since it does not store that in the local db
         }
         // If the sitename not present, the page request came here via some illegal method.
         // If the site was not loaded correctly or is not active, we cannot show the site either
         if (!isset($_SERVER['REDIRECT_SITENAME']) or empty($sitename) or !$this->sitearea->globalsite->loaded() or $this->sitearea->globalsite->active == FALSE) {
             // Site does not exist. Quit.
             throw new Kohana_Exception("site does not exist");
         }
         // Global site has been loaded and it was found to be active
         // Now we load the local site and requested page from within the user Database
         // This requires the inclusion of the site as a module and an init on its database-config
         //
         // First, Include the whole site-tree in the find_file() function
         Kohana::modules(Kohana::modules() + array("site" => APPPATH . "../../sites/" . $sitename . "/"));
         // Because Kohana uses include_once() this will only init the new module, without double-including the others
         // Load the sitedatabase config. It will be fetched from the sites/sitename/config folder since the sites/sitename is now in the Kohana find_file paths
         $siteconfig = Kohana::config('sitedatabase')->site;
         // Set up a site database connection, to be used by the site-based-models like Site_Page, Site_User, File etc
         $this->sitearea->database = Wi3_Database::instance("site", $siteconfig);
         Event::instance("wi3.init.sitearea.database.loaded")->execute();
         // Load the user-site
         $this->sitearea->site = $this->model->factory("site_site")->set('id', 1)->load();
         $this->sitearea->site->name = $sitename;
         // Add name, since this is not stored in the local site tables, but only in the global ones
         Event::instance("wi3.init.sitearea.site.loaded")->execute();
         // Load the pageposition, page and file manager, all within the sitearea
         $this->sitearea->pagepositions = Wi3_Sitearea_Pagepositions::inst();
         $this->sitearea->pages = Wi3_Sitearea_Pages::inst();
         $this->sitearea->files = Wi3_Sitearea_Files::inst();
         $this->sitearea->users = Wi3_Sitearea_Users::inst();
     }
     // Load baseviews that are passed as $this into views in order to enable some in-view functions
     // Different setups are possible with the different parameters supplied
     // An instance is created, so that they can also be referenced simply from again loading e.g. Wi3_Baseview::instance('superadminarea');
     // These instances are used as 'object scope' for the $this variables in views. See i.e. the superadminarea-controller's ->view function and the Baseview->capture() for more details
     $this->baseview_superadminarea = Wi3_Baseview::instance('superadminarea', array('javascript_url' => $this->urlof->appfiles . 'static/javascript/', 'javascript_path' => $this->pathof->app . 'static/javascript/', 'css_url' => $this->urlof->appfiles . 'static/css/', 'css_path' => $this->pathof->app . 'static/css/'));
     //Maybe just define the asset-path(s), from which the URLs are deduced, based on the Wi3::inst()->urlof ?
     $this->baseview_adminarea = Wi3_Baseview::instance('adminarea', array('javascript_url' => $this->urlof->appfiles . 'static/javascript/', 'javascript_path' => $this->pathof->app . 'static/javascript/', 'css_url' => $this->urlof->appfiles . 'static/css/', 'css_path' => $this->pathof->app . 'static/css/'));
     $this->baseview_sitearea = Wi3_Baseview::instance('sitearea', array('javascript_url' => $this->urlof->site . 'static/javascript/', 'javascript_path' => $this->pathof->site . 'static/javascript/', 'css_url' => $this->urlof->site . 'static/css/', 'css_path' => $this->pathof->site . 'static/css/'));
     Event::instance("wi3.init.baseviews.loaded")->execute();
     // Set up an config loader
     $this->configof = Wi3_Configof::instance();
     // Set up auth. This will try to login the current user from either the site db or the global db, based on the scope
     if ($this->scope == "site") {
         $this->sitearea->auth = Wi3_Auth_Site::instance();
     } else {
         // If user is in setup, then don't yet load Auth and Database instances, since they most probably don't yet exist
         if (Request::instance()->controller != "setup") {
             $this->globalauth = Wi3_Auth_Global::instance();
         }
     }
     $this->acl = Wi3_ACL::instance();
     // Load the plugin-manager. The manager will also include the paths to the plugins in the modules-system
     $this->plugins = new Wi3_Plugins();
     if ($this->scope == "site") {
         // Make all the pageversion-plugins to load
         // The versionplugins should respond to this event call, and add them to the $this->versionplugins array
         Event::instance('wi3.sitearea.pages.versionplugins.load')->execute();
     }
 }
Пример #7
0
/**
 * Enable the Kohana auto-loader for unserialization.
 *
 * @see  http://php.net/spl_autoload_call
 * @see  http://php.net/manual/var.configuration.php#unserialize-callback-func
 */
ini_set('unserialize_callback_func', 'spl_autoload_call');
//-- Configuration and initialization -----------------------------------------
/**
 * Set the development status
 */
define('IN_DEVELOPMENT', $_SERVER['SERVER_NAME'] === 'localhost');
/**
 * Sets the sites’ language
 */
i18n::$lang = 'en-us';
/**
 * Initialize Kohana, setting the default options.
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
 * - string   index_file  name of your index file, usually "index.php"       index.php
 * - string   charset     internal character set used for input and output   utf-8
 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 */
Kohana::init(array('base_url' => '/', 'index_file' => '', 'profiling' => IN_DEVELOPMENT, 'caching' => !IN_DEVELOPMENT));
/**
Пример #8
0
<h1>Unicode Translating</h1>

<table>
	<tr>
		<th>Code</th>
		<th>Language</th>
		<th>Phrase</th>
	</tr>
	<?php 
foreach ($cases as $lang => $name) {
    i18n::$lang = $lang;
    ?>
	<tr>
		<td><?php 
    echo $lang;
    ?>
</td>
		<td><?php 
    echo __($name);
    ?>
</td>
		<td><?php 
    echo __('Hello, world');
    ?>
</td>
	</tr>
	<?php 
}
?>
</table>
Пример #9
0
 /**
  * gets the fragment name, unique using i18n theme and URL
  * @param  string $name 
  * @return string       
  */
 public static function fragment_name($name)
 {
     return 'fragment_' . $name . '_' . i18n::lang() . '_' . Theme::$theme . '_' . URL::title(URL::current());
 }
Пример #10
0
 /**
  * Initiate the i18n classes.
  * 
  * Reads in and parses chosen language information set in $_SESSION['lang'].
  * 
  * @param boolean $useCompressedLanguageFile Whether to use a single compressed language file to avoid searching for truckloads of files and boost performance.
  */
 public static function init()
 {
     if (isset($_SESSION['lang'])) {
         $tmp = self::parseLang($_SESSION['lang']);
         self::$lang = $tmp[0];
         self::$country = $tmp[1];
     } else {
         self::$lang = '';
         self::$country = '';
     }
     if (isset($_SESSION['lang2'])) {
         $tmp = self::parseLang($_SESSION['lang2']);
         self::$lang2 = $tmp[0];
         self::$country2 = $tmp[1];
     } else {
         self::$lang2 = '';
         self::$country2 = '';
     }
     if (isset($_SESSION['lang3'])) {
         $tmp = self::parseLang($_SESSION['lang3']);
         self::$lang3 = $tmp[0];
         self::$country3 = $tmp[1];
     } else {
         self::$lang3 = '';
         self::$country3 = '';
     }
 }
Пример #11
0
 /**
  * Initialize internationalization
  * for current request
  */
 public static function setup()
 {
     // Get language config variables
     $lang_settings = self::get_language();
     $lang_supported = array_keys($lang_settings['supported']);
     // Get language
     $lang_current = self::get_user_lang($lang_supported);
     // if user language is not set
     if (is_null($lang_current)) {
         $lang_current = self::get_browser_preferred_language($lang_supported);
     }
     // if get browser language failed
     if (is_null($lang_current)) {
         $lang_current = $lang_settings['default'];
     }
     // Set user language
     self::set_user_lang($lang_current);
     // Set request language and locale
     $lang_config = $lang_settings['supported'][$lang_current];
     if (i18n::lang() !== $lang_config['code']) {
         i18n::lang($lang_config['code']);
         setlocale(LC_ALL, $lang_config['locale']);
     }
 }
Пример #12
0
<?php

defined('SYSPATH') or die('No direct script access.');
/**
 * Initialize Kohana
 */
Kohana::init(array('charset' => 'utf-8', 'base_url' => '/ko3/'));
/**
 * Enable modules.
 */
Kohana::modules(array('todoist' => MODPATH . 'todoist'));
/**
 * Log all messages to files
 */
Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs'));
/**
 * Set the language to use for translating.
 */
i18n::$lang = 'en_US';
/**
 * Set the routes.
 */
Route::set('test', 'test/(<controller>(/<action>))')->defaults(array('directory' => 'test', 'controller' => 'list', 'action' => 'index'));
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'welcome', 'action' => 'index', 'id' => NULL));
// Execute the main request
Request::instance($_SERVER['PATH_INFO'])->execute(FALSE);
Пример #13
0
 public function rules()
 {
     return array('title_' . i18n::lang() => array(array('not_empty')), 'storage_id' => array(array('not_empty')));
 }
Пример #14
0
 public function action_reject()
 {
     $id = $this->request->param('id');
     $material = ORM::factory('Material', $id);
     if (!$material->loaded() or $material->status != 2 or $material->is_moderator == 0) {
         $this->redirect('manage/materials');
     }
     $user_id = $material->user_id;
     $lang = $material->lang_notice;
     $user_email = ORM::factory('User', $user_id)->email;
     $this->set('material', $material);
     $token = Arr::get($_POST, 'token', false);
     $return = Arr::get($_POST, 'r', 'manage/materials');
     $this->set('return', Url::site($return));
     if ($this->request->method() == Request::POST && Security::token() === $token) {
         $message = Arr::get($_POST, 'message', '');
         if ($message != '') {
             $material->status = 0;
             $material->mod_message = $message;
             $material->moderator_id = $this->user->id;
             $material->save();
             $prelang = i18n::lang();
             I18n::lang($lang);
             Email::connect();
             Email::View('review_accept_' . $lang);
             Email::set(array('message' => I18n::get('Редакционной коллегией портала "История Казахстана" было отказано в публикации оставленного вами материала.')));
             Email::send($user_email, array('*****@*****.**', 'e-history.kz'), I18n::get('Рассмотрение материала на портале "История Казахстана" e-history.kz'), '', true);
             I18n::lang($prelang);
             $this->redirect('manage/materials');
         } else {
             $this->set('message', $message)->set('token', Security::token(true))->set('errors', true);
         }
     } else {
         $this->set('token', Security::token(true));
     }
 }
Пример #15
0
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
 * - string   index_file  name of your index file, usually "index.php"       index.php
 * - string   charset     internal character set used for input and output   utf-8
 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 */
Kohana::init(array('base_url' => '/', 'index_file' => ''));
/**
 * Sets the language to russian
 */
i18n::lang('ru');
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Kohana_Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('a1' => MODPATH . 'a1', 'acl' => MODPATH . 'acl', 'a2' => MODPATH . 'a2', 'a2acldemo' => MODPATH . 'a2acldemo', 'codebench' => MODPATH . 'codebench', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'orm' => MODPATH . 'orm', 'pagination' => MODPATH . 'pagination', 'userguide' => MODPATH . 'userguide'));
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
Пример #16
0
 /**
  * Tests Validation::errors()
  *
  * @test
  * @covers Validation::errors
  */
 public function test_parameter_labels()
 {
     $validation = Validation::factory(array('foo' => 'bar'))->rule('foo', 'equals', array(':value', 'something'))->label('something', 'Spanish');
     $current = i18n::lang();
     i18n::lang('es');
     $validation->check();
     $translated_expected = array('foo' => 'foo must equal Español');
     $untranslated_expected = array('foo' => 'foo must equal Spanish');
     $result_1 = $validation->errors('Validation', TRUE);
     $result_2 = $validation->errors('Validation', 'en');
     $result_3 = $validation->errors('Validation', FALSE);
     // Restore the current language
     i18n::lang($current);
     $this->assertSame($translated_expected, $result_1);
     $this->assertSame($translated_expected, $result_2);
     $this->assertSame($untranslated_expected, $result_3);
 }
Пример #17
0
 public function actionTestLang()
 {
     i18n::$lang = 'vi-vn';
     echo i18n::get('平台管理') . "<br>";
 }