private function loadDataGrid()
 {
     // add a fields array key to the record to make sure the datagrid can be crated
     if (!array_key_exists('fields', $this->record)) {
         $this->record['fields'] = array();
     }
     // add the key of each items to the values. This will be used for a link to the delete_field action
     foreach ($this->record['fields'] as $key => $field) {
         $this->record['fields'][$key]['key'] = $key;
     }
     // check if we have a varchar
     foreach ($this->record['fields'] as $field) {
         if ($field['type'] == 'text') {
             $this->allowSave = true;
             break;
         }
     }
     // if the record has fields, create a datagrid with all the fields
     $this->datagrid = new DataGridArray($this->record['fields']);
     $this->datagrid->addColumn('delete', null, Language::lbl('Delete'), Model::createURLForAction('DeleteField') . '&id=[key]', Language::lbl('Delete'));
     $this->datagrid->setColumnsHidden(array('key', 'underscored_label', 'camel_cased_label', 'sql'));
 }
Beispiel #2
0
 /**
  * Load the datagrid with drafts
  *
  * @return	void
  */
 private function loadDrafts()
 {
     // create datagrid
     $this->dgDrafts = new BackendDataGridDB(BackendPagesModel::QRY_DATAGRID_BROWSE_SPECIFIC_DRAFTS, array($this->record['id'], 'draft', BL::getWorkingLanguage()));
     // hide columns
     $this->dgDrafts->setColumnsHidden(array('id', 'revision_id'));
     // disable paging
     $this->dgDrafts->setPaging(false);
     // set headers
     $this->dgDrafts->setHeaderLabels(array('user_id' => ucfirst(BL::lbl('By')), 'edited_on' => ucfirst(BL::lbl('LastEditedOn'))));
     // set colum URLs
     $this->dgDrafts->setColumnURL('title', BackendModel::createURLForAction('edit') . '&id=[id]&draft=[revision_id]');
     // set column-functions
     $this->dgDrafts->setColumnFunction(array('BackendDataGridFunctions', 'getUser'), array('[user_id]'), 'user_id');
     $this->dgDrafts->setColumnFunction(array('BackendDataGridFunctions', 'getTimeAgo'), array('[edited_on]'), 'edited_on');
     // add use column
     $this->dgDrafts->addColumn('use_draft', null, ucfirst(BL::lbl('UseThisDraft')), BackendModel::createURLForAction('edit') . '&id=[id]&draft=[revision_id]', BL::lbl('UseThisDraft'));
     // our JS needs to know an id, so we can highlight it
     $this->dgDrafts->setRowAttributes(array('id' => 'row-[revision_id]'));
 }