private static function buildPhysicalJsObject($parameters)
 {
     // Creates shortcut to space
     $space = $parameters['space'];
     // Checks if space was valid
     if ($space) {
         // Creates physical description from space
         $physical = array_merge($space->get(array('width', 'height', 'depth')), array('orientation' => 0, 'racks' => array()));
     } else {
         // Creates empty array
         $physical = array();
     }
     // Returns javascript object
     return DataCenterJs::toObject($physical);
 }
Exemple #2
0
 private static function markerOptions(array $parameters, $location)
 {
     // Begins window
     $xmlOutput = DataCenterXml::open('div', array('class' => 'window'));
     // Adds heading
     $xmlOutput .= DataCenterXml::div(array('class' => 'heading'), DataCenterXml::link($location->get('name'), array('page' => 'facilities', 'type' => 'location', 'action' => 'view', 'id' => $location->getId())));
     // Gets number of spaces in location
     $numSpaces = DataCenterDB::numSpaces(DataCenterDB::buildCondition('facility', 'space', 'location', $location->getId()));
     // Adds body
     $xmlOutput .= DataCenterXml::div(array('class' => 'body'), DataCenterXml::div(array('class' => 'region'), $location->get('region')) . DataCenterXml::div(array('class' => 'spaces'), DataCenterUI::message('label', 'num-spaces', $numSpaces)));
     // Ends window
     $xmlOutput .= DataCenterXml::close('div');
     // Returns JavaScript object of options
     return DataCenterJs::toObject(array('content' => $xmlOutput));
 }
 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);
 }
 private static function buildPhysicalJsObject($parameters)
 {
     // Creates shortcut to plan
     $plan = $parameters['plan'];
     // Gets plan's space from database
     $space = $plan->getSpace();
     // Checks if space was valid
     if ($space) {
         // Creates physical description from space
         $physical = array_merge($space->get(array('width', 'height', 'depth')), array('orientation' => 0, 'racks' => array()));
         // Checks if racks should be rendered
         if ($parameters['lod'] >= 1) {
             $structure = $parameters['plan']->getStructure();
             if ($parameters['include'] instanceof DataCenterDBAssetLink && $parameters['include']->get('asset_type') == 'rack') {
                 $structure[] = $parameters['include'];
             }
             // Loops over each rack link
             foreach ($structure as $rackLink) {
                 $objects = array();
                 // Extracts rack from link
                 $rack = $rackLink->getAsset();
                 if ($rack) {
                     // Gets rack model from database
                     $rackModel = $rack->getModel();
                     if ($parameters['lod'] >= 2) {
                         $rackStructure = $rackLink->getStructure();
                         if ($parameters['include'] instanceof DataCenterDBAssetLink && $parameters['include']->get('asset_type') == 'object' && $parameters['current-rack'] == $rack->getId()) {
                             $rackStructure[] = $parameters['include'];
                         }
                         foreach ($rackStructure as $objectLink) {
                             // Extracts object from object link
                             $object = $objectLink->getAsset();
                             if ($object) {
                                 // Gets object model from database
                                 $objectModel = $object->getModel();
                                 // Adds object to list
                                 $objects[$object->getId()] = array_merge($objectLink->get(array('z', 'orientation')), $objectModel->get(array('units', 'depth')));
                             }
                         }
                     }
                     // Add rack to list
                     $physical['racks'][$rack->getId()] = array_merge($rackLink->get(array('x', 'y', 'orientation')), $rackModel->get(array('units')), array('objects' => $objects));
                 }
             }
         }
     } else {
         // Creates empty array
         $physical = array();
     }
     // Returns JavaScript object
     return DataCenterJs::toObject($physical);
 }