コード例 #1
0
ファイル: field.php プロジェクト: ZerGabriel/cms-1
 private function _add($ds)
 {
     $data = $this->request->post();
     try {
         $type = $data['type'];
         unset($data['type']);
         $field = DataSource_Hybrid_Field::factory($type, $data);
         $field_id = DataSource_Hybrid_Field_Factory::create_field($ds->record(), $field);
     } catch (Validation_Exception $e) {
         Session::instance()->set('post_data', $this->request->post());
         Messages::errors($e->errors('validation'));
         $this->go_back();
     } catch (Kohana_Exception $e) {
         Messages::errors($e->getMessage());
         $this->go_back();
     }
     if (!$field_id) {
         $this->go_back();
     }
     Session::instance()->delete('post_data');
     if ($this->request->post('save_and_create') !== NULL) {
         $this->go(Route::get('datasources')->uri(array('controller' => 'field', 'directory' => 'hybrid', 'action' => 'add', 'id' => $ds->id())));
     } else {
         $this->go(Route::get('datasources')->uri(array('directory' => 'hybrid', 'controller' => 'field', 'action' => 'edit', 'id' => $field_id)));
     }
 }
コード例 #2
0
ファイル: field.php プロジェクト: ZerGabriel/cms-1
 public function post_repair()
 {
     $field = $this->_get_field();
     if (!DataSource_Hybrid_Field_Factory::is_column_exists($field)) {
         $ds = Datasource_Data_Manager::load($field->ds_id);
         if (!$ds->loaded()) {
             throw HTTP_API_Exception::factory(API::ERROR_UNKNOWN, 'Datasource section :id not found', array(':id' => $field->ds_id));
         }
         DataSource_Hybrid_Field_Factory::create_field($ds->record(), $field);
         $this->message('Field ":field" repaired', array(':field' => $field->header));
         $this->response(TRUE);
     }
 }