public function save(array $data, $type) { if (!DataCenterPage::userCan('change')) { return false; } $model = DataCenterDBModel::newFromType($type, $data['row']); $model->save(); $model->saveMetaValues($data['meta']); $model->insertChange($data['change']); return true; }
public function modify($path) { // Checks if the type is supported if (!isset(self::$options[$path['type']]['gallery'])) { // Returns error message return wfMsg('datacenter-error-invalid-data'); } // Detects mode if (!$path['id']) { // Creates new component $model = DataCenterDBModel::newFromType($path['type']); // Sets 'do' specific parameters $formParameters = array('label' => 'create', 'success' => array('page' => 'models', 'type' => $path['type']), 'type' => 'create'); $headingParameters = array('message' => 'creating-model-type', 'subject' => DataCenterUI::message('type', $path['type'])); } else { // Gets component from database $model = DataCenterDB::getModel($path['type'], $path['id']); // Sets 'do' specific parameters $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'models', 'type' => $path['type'], 'action' => 'view', 'id' => $path['id']), 'type' => 'modify'); $headingParameters = array('message' => 'modifying-model-type', 'subject' => DataCenterUI::message('type', $path['type'])); } // Returns 2 columm layout with a form and a scene return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', $headingParameters), DataCenterUI::renderWidget('form', array_merge($formParameters, self::$options[$path['type']]['form'], array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'models', 'type' => $path['type']), 'row' => $model))))), '[MODEL VIEWER]')); }