public function finalize()
 {
     if (count($this->cells)) {
         if ($str = \util\Misc::array2str(array_column($this->cells, 'value'))) {
             return " ({$str})";
         }
     }
     return "";
 }
 private function genName($filename, $worksheet_name)
 {
     $filename = \util\Misc::regexExtractFilename($filename);
     $tbl_name = "{$filename[0]}_{$worksheet_name}";
     # ' ' => '_'
     $tbl_name = preg_replace("#[^\\w]+#", '_', $tbl_name);
     # '__' => '_'
     $tbl_name = preg_replace("#[_]{2}[_]*#", '_', $tbl_name);
     return $tbl_name;
 }
 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;
 }
echo $html_header->html();
?>
<body><?php 
if (isset($_POST['submit'])) {
    $params = array();
    $idlist = "";
    if (isset($_POST['idlist_textarea'])) {
        $idlist = \util\Misc::cleanCSV($_POST['idlist_textarea']);
        $parms['idlist_textarea'] = $_POST['idlist_textarea'];
    }
    $file = new \util\FileUpload('idlist_file');
    if (($txt = $file->read()) !== FALSE) {
        if ($idlist) {
            $idlist .= ", " . \util\Misc::cleanCSV($txt);
        } else {
            $idlist = \util\Misc::cleanCSV($txt);
        }
    }
    $idtype = $_POST['idtype'];
    $outputFormat = $_POST['outputFormat'];
    $params['idtype'] = $idtype;
    $params['outputFormat'] = $outputFormat;
    $params['hideunique'] = isset($_POST['hide_unique']) ? 1 : 0;
    if (trim($idlist) == "") {
        $params['errormsg'] = "Cannot submit without IDs!";
        echo \html\FormPanel::makeHiddenForm("CSVForm", "index.php", $params);
    } else {
        $params = array('idlist' => $idlist, 'idtype' => $idtype, 'outputFormat' => $outputFormat, 'hideunique' => isset($_POST['hideunique']) ? 1 : 0);
        echo \html\FormPanel::makeHiddenForm("CSVForm", "process.php", $params);
    }
} else {
示例#5
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;
 }