private static function addPlanJsFunction(array $parameters) { // Adds script to add plan to scene $jsOutput = DataCenterJs::callFunction('scene.setModule', array(DataCenterJs::buildInstance('DataCenterScenePlan', array(DataCenterJs::toScalar($parameters['plan']->getId()), self::buildPhysicalJsObject($parameters), self::buildStateJsObject($parameters))))); // Adds script to render scene $jsOutput .= DataCenterJs::callFunction('scene.render'); // Returns JavaScript return DataCenterJs::buildFunction(array('scene'), $jsOutput); }
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); }