Ejemplo n.º 1
0
 private function store_data($section, $record)
 {
     foreach ($section->fields() as $field) {
         if (isset($_POST['f' . $field->id])) {
             $data = new Data();
             $data->record = $record->id;
             $data->field = $field->id;
             $data->{$field->type()->datafield} = $_POST['f' . $field->id];
             $data->save();
         }
     }
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     if (GRAFT_CONFIG['DBHost'] == '' || GRAFT_CONFIG['DBName'] == '' || GRAFT_CONFIG['DBUser'] == '') {
         die('A database connection is required to run clout.');
     }
     // instance everything so the db gets setup
     // probably need a better way to do this
     // in the future #TODO
     \GraftPHP\Clout\Data::build();
     \GraftPHP\Clout\Field::build();
     \GraftPHP\Clout\FieldType::build();
     \GraftPHP\Clout\Record::build();
     \GraftPHP\Clout\Section::build();
     \GraftPHP\Clout\User::build();
     $this->data['sections'] = Section::all();
 }