示例#1
0
 /**
  * Build a MenuBar from a XML file
  * @param $xml_file path for the file
  */
 public static function newFromXML($xml_file)
 {
     //TPage::include_js('lib/bootstrap/js/bootstrap-dropdown.js');
     if (file_exists($xml_file)) {
         $menu_string = file_get_contents($xml_file);
         if (utf8_encode(utf8_decode($menu_string)) == $menu_string) {
             $xml = new SimpleXMLElement($menu_string);
         } else {
             $xml = new SimpleXMLElement(utf8_encode($menu_string));
         }
         $menubar = new TMenuBar();
         foreach ($xml as $xmlElement) {
             $atts = $xmlElement->attributes();
             $label = (string) $atts['label'];
             $action = (string) $xmlElement->action;
             $icon = (string) $xmlElement->icon;
             $button_div = new TElement('div');
             $button_div->{'class'} = 'btn-group';
             $button = new TElement('button');
             $button->{'data-toggle'} = 'dropdown';
             $button->{'class'} = 'btn dropdown-toggle';
             $button->add($label);
             $span = new TElement('span');
             $span->{'class'} = 'caret';
             $span->add('');
             $button->add($span);
             $menu = new TMenu($xmlElement->menu->menuitem);
             $button_div->add($button);
             $button_div->add($menu);
             $menubar->add($button_div);
         }
         return $menubar;
     }
 }
示例#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();
 }
示例#3
0
 public static function parse($file, $theme)
 {
     switch ($theme) {
         case 'theme1':
             ob_start();
             $callback = array('SystemPermission', 'checkPermission');
             $menu = TMenuBar::newFromXML('menu.xml', $callback);
             $menu->show();
             $menu_string = ob_get_clean();
             return $menu_string;
             break;
         case 'theme2':
             ob_start();
             $callback = array('SystemPermission', 'checkPermission');
             $xml = new SimpleXMLElement(file_get_contents('menu.xml'));
             $menu = new TMenu($xml, $callback, 1, 'nav collapse', '');
             $menu->class = 'nav';
             $menu->id = 'side-menu';
             $menu->show();
             $menu_string = ob_get_clean();
             return $menu_string;
             break;
         case 'theme3':
             ob_start();
             $callback = array('SystemPermission', 'checkPermission');
             $xml = new SimpleXMLElement(file_get_contents('menu.xml'));
             $menu = new TMenu($xml, $callback, 1, 'treeview-menu', 'treeview', '');
             $menu->class = 'sidebar-menu';
             $menu->id = 'side-menu';
             $menu->show();
             $menu_string = ob_get_clean();
             return $menu_string;
             break;
     }
 }
示例#4
0
 /**
  * Build a MenuBar from a XML file
  * @param $xml_file path for the file
  */
 public static function newFromXML($xml_file)
 {
     if (file_exists($xml_file)) {
         $menu_string = file_get_contents($xml_file);
         if (utf8_encode(utf8_decode($menu_string)) == $menu_string) {
             $xml = new SimpleXMLElement($menu_string);
         } else {
             $xml = new SimpleXMLElement(utf8_encode($menu_string));
         }
         $menubar = new TMenuBar();
         foreach ($xml as $xmlElement) {
             $atts = $xmlElement->attributes();
             $label = (string) $atts['label'];
             $action = (string) $xmlElement->action;
             $icon = (string) $xmlElement->icon;
             $menuItem = new TMenuItem($label, $action, $icon);
             $menubar->append($menuItem, $xmlElement->menu->menuitem);
         }
         return $menubar;
     }
 }
示例#5
0
 function __construct()
 {
     parent::__construct();
     parent::set_title('Adianti Framework :: Samples');
     $this->content = new GtkFixed();
     $vbox = new GtkVBox();
     $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::add($vbox);
     parent::show_all();
 }
 /**
  * Build a MenuBar from a XML file
  * @param $xml_file path for the file
  * @param $permission_callback check permission callback
  */
 public static function newFromXML($xml_file, $permission_callback = NULL)
 {
     if (file_exists($xml_file)) {
         $menu_string = file_get_contents($xml_file);
         if (utf8_encode(utf8_decode($menu_string)) == $menu_string) {
             $xml = new SimpleXMLElement($menu_string);
         } else {
             $xml = new SimpleXMLElement(utf8_encode($menu_string));
         }
         $menubar = new TMenuBar();
         foreach ($xml as $xmlElement) {
             $atts = $xmlElement->attributes();
             $label = (string) $atts['label'];
             $action = (string) $xmlElement->action;
             $icon = (string) $xmlElement->icon;
             $button_div = new TElement('div');
             $button_div->{'class'} = 'btn-group';
             $button = new TElement('button');
             $button->{'data-toggle'} = 'dropdown';
             $button->{'class'} = 'btn dropdown-toggle';
             $button->add($label);
             $span = new TElement('span');
             $span->{'class'} = 'caret';
             $span->add('');
             $button->add($span);
             $menu = new TMenu($xmlElement->menu->menuitem, $permission_callback);
             // check children count (permissions)
             if (count($menu->getMenuItems()) > 0) {
                 $button_div->add($button);
                 $button_div->add($menu);
                 $menubar->add($button_div);
             }
         }
         return $menubar;
     }
 }
示例#7
0
 function __construct()
 {
     parent::__construct();
     parent::set_title('Adianti Framework :: Samples');
     $this->content = new GtkFixed();
     $vbox = new GtkVBox();
     $scroll = new GtkScrolledWindow();
     $scroll->set_policy(GTK::POLICY_AUTOMATIC, GTK::POLICY_ALWAYS);
     $scroll->set_size_request(200, -1);
     $vbox->pack_start(GtkImage::new_from_file('app/images/pageheader.png'), false, false);
     $MenuBar = TMenuBar::newFromXML('menu.xml');
     $vbox->pack_start($MenuBar, false, false);
     $vbox->pack_start($this->content, true, true);
     parent::add($vbox);
     parent::show_all();
 }
示例#8
0
// 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__));
$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);
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__));
$uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$template = 'theme1';
new TSession();
$menu_string = '';
if (TSession::getValue('logged')) {
    $content = file_get_contents("app/templates/{$template}/layout.html");
    ob_start();
    $callback = array('SystemPermission', 'checkPermission');
    $menu = TMenuBar::newFromXML('menu.xml', $callback);
    $menu->show();
    $menu_string = ob_get_contents();
    ob_end_clean();
} 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);
$content = str_replace('{template}', $template, $content);
$content = str_replace('{MENU}', $menu_string, $content);
$content = str_replace('{username}', TSession::getValue('username'), $content);
$content = str_replace('{frontpage}', TSession::getValue('frontpage'), $content);
$css = TPage::getLoadedCSS();