cli) { return true; } return parent::getAuth(); } function fetchSchema($type) { $headers = array(); // read header file require_once 'File/Convert.php'; $fc = new File_Convert("Pman/Xtuple/Kingdee/Schema/{$type}_Header.csv", 'text/csv'); $content = $fc->convert('text/csv'); $fh = fopen($content, 'r'); if (!$fh) { $this->jerr("invalid {$type}_Header file"); } $count = 1; while(false !== ($n = fgetcsv($fh,10000, ',', '"'))) { foreach($n as $k) { if(empty($k)){ continue; } $headers['Page' . $count][] = array( 'header' => trim($k), 'dataIndex' => preg_replace(array('/\s/','/\&|\.|\/|\-|\(|\)/'), array('_', ''), strtolower(trim($k))), 'width' => 75 ); } $count++; } fclose($fh); // read schema file $fc = new File_Convert("Pman/Xtuple/Kingdee/Schema/{$type}_Schema.csv", 'text/csv'); $content = $fc->convert('text/csv'); $fh = fopen($content, 'r'); if (!$fh) { $this->jerr("invalid {$type}_Schema file"); } $cols = false; $rows = array(); while(false !== ($n = fgetcsv($fh,10000, ',', '"'))) { if (!strlen(implode('', $n))) { continue; } if (!$cols) { $cols = array(); foreach($n as $k) { $cols[] = trim($k); if($k == 'FPage'){ $headers['t_Schema'][] = array( 'header' => trim($k), 'dataIndex' => trim($k), 'width' => 75 ); continue; } $headers['t_Schema'][] = array( 'header' => trim($k), 'dataIndex' => trim($k), 'dataFormat' => 'string', 'width' => 75 ); } if (empty($cols)) { continue; } continue; } foreach($cols as $i=>$k) { $row[$k] = $n[$i]; } $rows[] = $row; } fclose($fh); $sheets = array(); foreach ($headers as $k => $v){ $sheets[$k] = array( 'workbook' => $k, 'cols' => $v ); } return array('SHEETS' => $sheets, 'SCHEMA' => $rows); } }