public function configure($path)
 {
     // Detects mode
     if (!$path['id']) {
         if (is_array($path['parameter']) && count($path['parameter']) >= 2 && $path['parameter'][0] == 'space') {
             // Gets space from database
             $space = DataCenterDB::getSpace($path['parameter'][1]);
             // Creates new component
             $plan = DataCenterDBPlan::newFromValues(array('space' => $path['parameter'][1], 'tense' => 'present', 'name' => $space->get('name')));
             // Sets 'do' specific parameters
             $formParameters = array('label' => 'create', 'hidden' => array('space'), 'success' => array('page' => 'plans'));
             $headingParameters = array('message' => 'adding-type', 'type' => 'plan');
         } else {
             throw new MWException('Invalid parameters. space,# expected.');
         }
     } else {
         // Gets component from database
         $plan = DataCenterDB::getPlan($path['id']);
         // Sets 'do' specific parameters
         $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'plans', 'type' => 'plan', 'action' => 'view', 'id' => $path['id']));
         $headingParameters = array('message' => 'configuring-type', 'type' => 'plan');
     }
     // 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, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'plans', 'type' => 'plan'), 'row' => $plan, 'fields' => array('tense' => array('type' => 'tense', 'disable' => !$path['id'] ? array('past') : array()), 'name' => array('type' => 'string'), 'note' => array('type' => 'text'))))))), DataCenterUI::renderWidget('plan', array('plan' => $plan))));
 }
 public function history($path)
 {
     if ($path['type'] == 'location') {
         $facility = DataCenterDB::getLocation($path['id']);
     } elseif ($path['type'] == 'space') {
         $facility = DataCenterDB::getSpace($path['id']);
     } else {
         return null;
     }
     return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', array('message' => 'history-type', 'subject' => DataCenterUI::message('type', $path['type']))), DataCenterUI::renderWidget('history', array('component' => $facility))))));
 }
 public function edit($path)
 {
     // Checks if...
     if (!$path['id'] && is_array($path['parameter']) && count($path['parameter'] >= 2) && $path['parameter'][0] == 'location') {
         // Creates new facility with default parameters
         $space = DataCenterDBSpace::newFromValues(array('location' => $path['parameter'][1], 'tense' => 'present', 'name' => DataCenterUI::message('default', 'new-type', DataCenterUI::message('type', 'space'))));
         // Sets 'do' specific parameters
         $formParameters = array('label' => 'add', 'hidden' => array($path['parameter'][0]), 'success' => array('page' => 'facilities', 'type' => $path['parameter'][0], 'action' => 'view', 'id' => $path['parameter'][1]), 'type' => 'add');
         $headingParameters = array('message' => 'adding-type', 'subject' => DataCenterUI::message('type', $path['type']));
     } else {
         // Gets facility from database
         $space = DataCenterDB::getSpace($path['id']);
         // Sets 'do' specific parameters
         $formParameters = array('label' => 'save', 'hidden' => array('location', 'id'), 'success' => array('page' => 'facilities', 'type' => 'space', 'action' => 'view', 'id' => $path['id']), 'type' => 'edit');
         $headingParameters = array('message' => 'editing-type', 'subject' => DataCenterUI::message('type', $path['type']));
     }
     // Builds JavaScript to access renderable facility
     $jsTarget = DataCenterJs::chain(array("dataCenter.renderer.getTarget" => DataCenterJs::toScalar('space'), 'getModule'), false);
     // Complete form parameters
     $formParameters = array_merge($formParameters, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'facilities', 'type' => 'space'), 'row' => $space, 'fields' => array('tense' => array('type' => 'tense', 'disable' => array('past')), 'name' => array('type' => 'string'), 'width' => array('type' => 'number', 'effect' => $jsTarget . '.setWidth( {this}.value, true );'), 'height' => array('type' => 'number', 'effect' => $jsTarget . '.setHeight( {this}.value, true );'), 'depth' => array('type' => 'number', 'effect' => $jsTarget . '.setDepth( {this}.value, true );'), 'power' => array('type' => 'number', 'min' => 0, 'max' => 100000, 'step' => 100))));
     // 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', $formParameters))), DataCenterUI::renderWidget('space', array('space' => $space))));
 }