/** * Validate the login */ function onLogin() { try { TTransaction::open('library'); $data = $this->form->getData('StdClass'); // validate form data $this->form->validate(); $language = $data->language ? $data->language : 'en'; TAdiantiCoreTranslator::setLanguage($language); TApplicationTranslator::setLanguage($language); $auth = User::autenticate($data->{'user'}, $data->{'password'}); if ($auth) { TSession::setValue('logged', TRUE); TSession::setValue('login', $data->{'user'}); TSession::setValue('language', $data->language); // reload page TApplication::executeMethod('SetupPage', 'onSetup'); } TTransaction::close(); // finaliza a transação } catch (Exception $e) { TSession::setValue('logged', FALSE); // exibe a mensagem gerada pela exceção new TMessage('error', '<b>Erro</b> ' . $e->getMessage()); // desfaz todas alterações no banco de dados TTransaction::rollback(); } }
/** * Constructor Method */ function __construct() { parent::__construct(); parent::set_size_request(840, 640); parent::set_position(GTK::WIN_POS_CENTER); parent::connect_simple('delete-event', array($this, 'onClose')); parent::connect_simple('destroy', array('Gtk', 'main_quit')); parent::set_title(self::APP_TITLE); parent::set_icon(GdkPixbuf::new_from_file('favicon.png')); $gtk = GtkSettings::get_default(); $gtk->set_long_property("gtk-button-images", TRUE, 0); $gtk->set_long_property("gtk-menu-images", TRUE, 0); self::$inst = $this; $ini = parse_ini_file('application.ini'); $lang = $ini['language']; TAdiantiCoreTranslator::setLanguage($lang); TApplicationTranslator::setLanguage($lang); date_default_timezone_set($ini['timezone']); $this->content = new GtkFixed(); $vbox = new GtkVBox(); parent::add($vbox); $vbox->pack_start(GtkImage::new_from_file('app/images/pageheader-gtk.png'), false, false); $MenuBar = TMenuBar::newFromXML('menu.xml'); $vbox->pack_start($MenuBar, false, false); $vbox->pack_start($this->content, true, true); parent::show_all(); }
public static function run($debug = FALSE) { new TSession(); $lang = TSession::getValue('language') ? TSession::getValue('language') : 'en'; TAdiantiCoreTranslator::setLanguage($lang); TApplicationTranslator::setLanguage($lang); if ($_REQUEST) { $class = isset($_REQUEST['class']) ? $_REQUEST['class'] : ''; if (!TSession::getValue('logged') and $class !== 'LoginForm') { echo TPage::getLoadedCSS(); echo TPage::getLoadedJS(); new TMessage('error', 'Not logged'); return; } parent::run($debug); } }
<?php // define the autoloader include_once 'lib/adianti/util/TAdiantiLoader.class.php'; spl_autoload_register(array('TAdiantiLoader', 'autoload_web')); // read configurations $ini = parse_ini_file('application.ini'); date_default_timezone_set($ini['timezone']); TAdiantiCoreTranslator::setLanguage($ini['language']); TApplicationTranslator::setLanguage($ini['language']); // define constants define('APPLICATION_NAME', $ini['application']); define('OS', strtoupper(substr(PHP_OS, 0, 3))); define('PATH', dirname(__FILE__)); class TApplication extends TCoreApplication { public static function run($debug = FALSE) { new TSession(); if ($_REQUEST) { parent::run($debug); } } } TApplication::run(TRUE);
<?php require_once 'init.php'; $uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; new TSession(); $template = 'theme1'; $lang = TSession::getValue('language') ? TSession::getValue('language') : 'en'; TAdiantiCoreTranslator::setLanguage($lang); TApplicationTranslator::setLanguage($lang); if (TSession::getValue('logged')) { TTransaction::open('library'); $member = User::newFromLogin(TSession::getValue('login')); if ($member->role->mnemonic == 'LIBRARIAN') { $content = file_get_contents("app/templates/{$template}/librarian.html"); } else { if ($member->role->mnemonic == 'OPERATOR') { $content = file_get_contents("app/templates/{$template}/operator.html"); } else { if ($member->role->mnemonic == 'ADMINISTRATOR') { $content = file_get_contents("app/templates/{$template}/admin.html"); } } } TTransaction::close(); } else { $content = file_get_contents("app/templates/{$template}/login.html"); } $content = TApplicationTranslator::translateTemplate($content); $content = str_replace('{LIBRARIES}', file_get_contents("app/templates/{$template}/libraries.html"), $content); $content = str_replace('{URI}', $uri, $content); $content = str_replace('{class}', isset($_REQUEST['class']) ? $_REQUEST['class'] : '', $content);