Exemplo n.º 1
0
 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))))));
 }
Exemplo n.º 2
0
 public function edit($path)
 {
     // Detects mode
     if (!$path['id']) {
         // Creates a new facility location
         $location = DataCenterDBLocation::newFromValues(array('tense' => 'present', 'name' => DataCenterUI::message('default', 'new-type', DataCenterUI::message('type', 'location'))));
         // Sets 'do' specific parameters
         $formParameters = array('label' => 'add', 'success' => array('page' => 'facilities', 'type' => 'location'), 'type' => 'add');
         $headingParameters = array('message' => 'adding-type', 'subject' => DataCenterUI::message('type', $path['type']));
     } else {
         // Gets facility location from database
         $location = DataCenterDB::getLocation($path['id']);
         // Sets 'do' specific parameters
         $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'facilities', 'type' => 'location', 'action' => 'view', 'id' => $path['id']), 'type' => 'edit');
         $headingParameters = array('message' => 'editing-type', 'subject' => DataCenterUI::message('type', $path['type']));
     }
     // Builds JavaScript that hooks the button into the geocoder
     $jsForm = 'document.form_save';
     $jsOut = DataCenterJs::callFunction('addHandler', array("{$jsForm}.field_button_0", DataCenterJs::toScalar('click'), DataCenterJs::buildFunction(null, DataCenterJs::chain(array('dataCenter.renderer.getTarget' => DataCenterJs::toScalar('map'), 'showAddress' => array('document.form_save.field_region.value', DataCenterJs::toObject(array('latField' => "'{$jsForm}.field_latitude'", 'lngField' => "'{$jsForm}.field_longitude'"))))))));
     // Complete form parameters
     $formParameters = array_merge($formParameters, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'facilities', 'type' => 'location'), 'row' => $location, 'fields' => array('tense' => array('type' => 'tense', 'disable' => !$path['id'] ? array('past') : array()), 'name' => array('type' => 'string'), 'region' => array('type' => 'string'), array('type' => 'button', 'label' => 'lookup'), 'latitude' => array('type' => 'string'), 'longitude' => array('type' => 'string'))));
     // Returns 2 columm layout with a form and a map widget
     return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', $headingParameters), DataCenterUI::renderWidget('form', $formParameters))), DataCenterUI::renderWidget('map', !$path['id'] ? array() : array('location' => $location)))) . DataCenterXml::script($jsOut);
 }
 public function getLocation()
 {
     return DataCenterDB::getLocation($this->get('location'));
 }