Esempio n. 1
0
 public function finalize()
 {
     if (count($this->cells)) {
         if ($str = \util\Misc::array2str(array_column($this->cells, 'value'))) {
             return " ({$str})";
         }
     }
     return "";
 }
Esempio n. 2
0
 public function finalize()
 {
     if ($header = $this->header->finalize()) {
         $entries = array();
         foreach ($this->entries as $entry) {
             if ($str = $entry->finalize()) {
                 $entries[] = $str;
             }
         }
         if (!empty($entries)) {
             return array('drop' => "DROP TABLE IF EXISTS {$this->name};", 'creation' => "CREATE TABLE {$this->name} ({$header->creation});", 'insertion' => "INSERT INTO {$this->name} ({$header->insertion}) VALUES " . \util\Misc::array2str($entries) . ';');
         }
     }
     return false;
 }
 public function finalize()
 {
     $insertion = array();
     $creation = array();
     foreach ($this->fields as $fld) {
         if ($fld = $fld->finalize()) {
             $insertion[] = $fld->name;
             $creation[] = "{$fld->name} {$fld->type}";
         }
     }
     if (empty($insertion)) {
         return false;
     }
     $ret = new \stdClass();
     $ret->insertion = \util\Misc::array2str($insertion);
     $ret->creation = \util\Misc::array2str($creation);
     return $ret;
 }
Esempio n. 4
0
 public function script($div_id)
 {
     $header = "<script src='https://www.google.com/jsapi'></script>\n            <script type='text/javascript'>\n                google.load('visualization','1.0',{'packages':['corechart','table','timeline']});\n                google.setOnLoadCallback(drawChart);\n                function drawChart(){";
     if (strcmp($this->chart->type, "Table") === 0 and false) {
         $this->chart->options->set('cssClassNames', 'cssClassNames');
         $header .= "var cssClassNames = {\n\t\t\t\t'headerRow': 'table-header',\n\t\t\t\t'tableRow': 'table-row',\n\t\t\t\t'oddTableRow': 'table-row-odd',\n\t\t\t\t'selectedTableRow': 'table-row-selected',\n\t\t\t\t'hoverTableRow': 'table-row-hover',\n\t\t\t\t'headerCell': 'table-header-cell',\n\t\t\t\t'tableCell': 'table-cell',\n\t\t\t\t'rowNumberCell': ''};";
     }
     $header .= "var data = new google.visualization.DataTable();";
     foreach ($this->chart->data->columns() as $fld) {
         $header .= "data.addColumn('" . $fld['type'] . "', '" . $fld['name'] . "');\n";
     }
     $recs = array();
     foreach ($this->chart->data->rows() as $rec) {
         $recs[] = '[' . \util\Misc::array2str($rec) . ']';
     }
     $header .= "data.addRows([\n" . \util\Misc::array2str($recs) . "\n]);\n";
     $header .= "var options = {";
     $optArray = $this->chart->options->getAll();
     $strArray = array();
     foreach ($optArray as $opt => $val) {
         $strArray[] = "{$opt} : {$val}";
     }
     $header .= \util\Misc::array2str($strArray) . "};\n";
     $header .= "var chart = new google.visualization." . $this->chart->type . "(document.getElementById('{$div_id}'));\n";
     $header .= "chart.draw(data,options);\n";
     $header .= "} </script>";
     return $header;
 }