示例#1
0
 function __initialize()
 {
     parent::__initialize();
     $ds = model_datasource('system');
     $ds->ExecuteSql("CREATE TABLE IF NOT EXISTS blog(id INTEGER,title VARCHAR(50),body TEXT,PRIMARY KEY(id))");
     $this->content(new Anchor(buildQuery('blog', 'newpost'), 'New post'));
 }
 function __initialize()
 {
     parent::__initialize();
     if ($GLOBALS['CREATE_DATA']) {
         $ds = model_datasource('system');
         $fn = array('John', 'Jane', 'Thomas', 'Marc', 'Jamie', 'Bob', 'Marie');
         $ln = array('Doe', 'Murphy', 'Anderson', 'Smith');
         $country_codes = array('DE', 'US', 'RU', 'FR', 'IT', 'SE');
         $ds->ExecuteSql("CREATE TABLE participants(name VARCHAR(50), country VARCHAR(5),age INTEGER,game_count INTEGER,PRIMARY KEY(name))");
         foreach ($fn as $f) {
             foreach ($ln as $l) {
                 $cc = $country_codes[rand(0, count($country_codes) - 1)];
                 $ds->ExecuteSql("INSERT INTO participants(name,country,age,game_count)VALUES(?,?,?,?)", array("{$f} {$l}", $cc, rand(18, 70), rand(0, 100)));
             }
         }
         $nums = array();
         $ds->ExecuteSql("CREATE TABLE numbers(number INTEGER,hit_count INTEGER,PRIMARY KEY(number))");
         for ($i = 0; $i <= 36; $i++) {
             $nums[$i] = 0;
             $ds->ExecuteSql("INSERT INTO numbers(number,hit_count)VALUES(?,?)", array($i, 0));
         }
         for ($i = 0; $i < 9999; $i++) {
             $rnd = rand(0, 36);
             $nums[$rnd]++;
         }
         foreach ($nums as $i => $c) {
             $ds->ExecuteSql("UPDATE numbers SET hit_count=? WHERE number=?", array($c, $i));
         }
     }
     GoogleVisualization::$DefaultDatasource = model_datasource('system');
 }
示例#3
0
 function __initialize($title = "", $body_class = false)
 {
     global $CONFIG;
     // sometimes state-/UI-less sites (like APIs) trickout the AJAX detection by setting this.
     // as we need UI this must be reset here
     unset($GLOBALS['result_of_system_is_ajax_call']);
     header("Content-Type: text/html; charset=utf-8");
     // overwrite previously set header to ensure we deliver HTML
     unset($CONFIG["use_compiled_js"]);
     unset($CONFIG["use_compiled_css"]);
     if (current_event(true) != 'login' && (!isset($_SESSION['admin_handler_username']) || !isset($_SESSION['admin_handler_password']) || $_SESSION['admin_handler_username'] != $CONFIG['system']['admin']['username'] || $_SESSION['admin_handler_password'] != $CONFIG['system']['admin']['password'])) {
         log_debug(current_event(true));
         log_debug($_SESSION['admin_handler_username']);
         log_debug($_SESSION['admin_handler_password']);
         redirect('sysadmin', 'login');
     }
     parent::__initialize("SysAdmin - {$title}", 'sysadmin');
     $this->_translate = false;
     if (current_event(true) != 'login') {
         $nav = parent::content(new Control('div'));
         $nav->class = "navigation";
         foreach ($CONFIG['system']['admin']['actions'] as $label => $def) {
             if (!class_exists(fq_class_name($def[0]))) {
                 continue;
             }
             $nav->content(new Anchor(buildQuery($def[0], $def[1]), $label));
         }
         $nav->content(new Anchor(buildQuery('sysadmin', 'cache'), 'Cache'));
         $nav->content(new Anchor(buildQuery('sysadmin', 'phpinfo'), 'PHP info'));
         $nav->content(new Anchor(buildQuery('translationadmin', 'newstrings'), 'Translations'));
         $nav->content(new Anchor(buildQuery('sysadmin', 'testing'), 'Testing'));
         $nav->content(new Anchor(buildQuery('', ''), 'Back to app'));
         $nav->content(new Anchor(buildQuery('sysadmin', 'logout'), 'Logout', 'logout'));
         $this->_subnav = parent::content(new Control('div'));
     }
     $this->_contentdiv = parent::content(new Control('div'))->addClass('content');
     $copylink = new Anchor('http://www.scavix.com', '&#169; 2012-' . date('Y') . ' Scavix&#174; Software Ltd. &amp; Co. KG');
     $copylink->target = '_blank';
     $footer = parent::content(new Control('div'))->addClass('footer');
     $footer->content("<br class='clearer'/>");
     $footer->content($copylink);
     if (current_event() == strtolower($CONFIG['system']['default_event']) && !system_method_exists($this, current_event())) {
         redirect('sysadmin', 'index');
     }
 }