Exemplo n.º 1
0
 /**
  * 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();
     }
 }
Exemplo n.º 2
0
 /**
  * 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();
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
<?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);
Exemplo n.º 5
0
define('OS', strtoupper(substr(PHP_OS, 0, 3)));
define('PATH', dirname(__FILE__));
$uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
new TSession();
ob_start();
$menu = TMenuBar::newFromXML('menu.xml');
$menu->show();
$menu_string = ob_get_contents();
ob_end_clean();
// verifica se o usuario esta logado para redirecionar
// para o layout e login
if (TSession::getValue('logado')) {
    $template = 'theme1';
} else {
    $template = 'loja';
}
$content = file_get_contents("app/templates/{$template}/layout.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);
$content = str_replace('{template}', $template, $content);
$content = str_replace('{MENU}', $menu_string, $content);
$css = TPage::getLoadedCSS();
$js = TPage::getLoadedJS();
$content = str_replace('{HEAD}', $css . $js, $content);
if (isset($_REQUEST['class'])) {
    $url = http_build_query($_REQUEST);
    $content = str_replace('//#javascript_placeholder#', "__adianti_load_page('engine.php?{$url}');", $content);
}
echo $content;
 /**
  * Returns the singleton instance
  * @return  Instance of TApplicationTranslator
  */
 public static function getInstance()
 {
     // if there's no instance
     if (empty(self::$instance)) {
         // creates a new object
         self::$instance = new TApplicationTranslator();
     }
     // returns the created instance
     return self::$instance;
 }
Exemplo n.º 7
0
 /**
  * Show the HTML and the enabled sections
  */
 public function show()
 {
     $sections_stack = array('main');
     $array_content = array();
     $buffer = array();
     if (file_exists($this->path)) {
         $array_content = file($this->path);
         // iterate line by line
         foreach ($array_content as $line) {
             $line_ = trim($line);
             $line_ = str_replace("\n", '', $line_);
             $line_ = str_replace("\r", '', $line_);
             $line = TApplicationTranslator::translateTemplate($line_);
             // detect section start
             if (substr($line_, 0, 5) == '<!--[' and substr($line_, -4) == ']-->' and substr($line_, 0, 6) !== '<!--[/') {
                 $sectionName = substr($line_, 5, strpos($line_, ']-->') - 5);
                 $sections_stack[] = $sectionName;
                 $buffer[$sectionName] = '';
             }
             // detect section end
             if (substr($line_, 0, 6) == '<!--[/') {
                 $sectionName = substr($line_, 6, strpos($line_, ']-->') - 6);
                 if (isset($this->repeatSection[$sectionName]) and $this->repeatSection[$sectionName]) {
                     // if the section is repeatable, repeat the content according to its replacements
                     if (isset($this->replacements[$sectionName])) {
                         foreach ($this->replacements[$sectionName] as $iteration_replacement) {
                             $row = $buffer[$sectionName];
                             $row = $this->replace($iteration_replacement, $row);
                             print $row;
                         }
                     }
                 }
                 $buffer[$sectionName] = '';
                 array_pop($sections_stack);
             }
             $sectionName = end($sections_stack);
             if (in_array($sectionName, $this->enabledSections)) {
                 // if the section is repeatable, then put the line inside the buffer
                 if (isset($this->repeatSection[$sectionName]) and $this->repeatSection[$sectionName]) {
                     $buffer[$sectionName] .= $line;
                 } else {
                     // print the line with the replacements
                     if (isset($this->replacements[$sectionName])) {
                         print $this->replace($this->replacements[$sectionName], $line);
                     } else {
                         print $line;
                     }
                 }
             }
         }
     }
 }