Пример #1
0
 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');
 }
Пример #2
0
 /**
  * Sets an option.
  * 
  * Overrides parent to capture 'title' option as tables does not handle that.
  * We will instead create a &ltdiv class='caption'/&gt; element with the title once the table has been rendered.
  * @override
  */
 function opt($name, $value = null)
 {
     if ($name == 'title' && $value) {
         $script = "\$('#{self}').prepend( \$('<div/>').addClass('caption').html(" . json_encode($value) . ") );";
         $script = "if( \$('#{self}').data('ready') ){ {$script} }else setTimeout(readyCb{self},100);";
         $script = "var readyCb{self} = function(){ {$script} }; readyCb{self}();";
         $this->script($script);
     }
     return parent::opt($name, $value);
 }