예제 #1
0
 private function determineFields()
 {
     $types = new \Extool\Defines\Types();
     $fields = new \Extool\Representation\Fields();
     for ($i = 0, $column_count = count($this->headers); $i < $column_count; $i++) {
         $column_data = array();
         // going into undefined offsets here, I think my array math is off
         for ($j = 0, $row_count = count($this->raw_data); $j < $row_count; $j++) {
             $column_data[] = $this->raw_data[$j][$i];
         }
         $header = $this->headers[$i];
         $fields->addField($header, $types->determineTypeArray($column_data));
     }
     return $fields;
 }
예제 #2
0
 private function makeModel($view_tables, $view, $prefix = '')
 {
     $tables = $this->getTables();
     $model = new \Extool\Representation\Model($view);
     // An extremely ugly way of creating filtered fields for models
     foreach ($view_tables as $table_name => $table) {
         if ($table[0] = '*') {
             $model->addTable($tables[$table_name]);
         } else {
             $fields = new \Extool\Representation\Fields();
             foreach ($table as $field) {
                 $fields->addField($field, $tables[$table_name]->types[$field]);
             }
             $model_table = new \Extool\Representation\Table($table_name);
             $model->addTable($model_table);
         }
     }
     if ($prefix == 'admin') {
         $this->adminModels[$view] = $model;
     } else {
         $this->models[$view] = $model;
     }
     return $model;
 }