public static function render(array $parameters) { // Adds script to UI DataCenterUI::addScript('/extensions/DataCenter/Resources/Widgets/Plan/Plan.js'); // Sets defaults $parameters = array_merge(self::$defaultParameters, $parameters); // Checks if width was given as an integer if (is_int($parameters['width'])) { // Converts width to CSS pixel definition $parameters['width'] .= 'px'; } // Checks if height was given as an integer if (is_int($parameters['height'])) { // Converts height to CSS pixel definition $parameters['height'] .= 'px'; } // Begins widget $xmlOutput = parent::begin($parameters['class']); // Adds XML element $xmlOutput .= DataCenterXML::div(array('id' => $parameters['id'], 'style' => DataCenterCss::toAttributes(array('width' => $parameters['width'], 'height' => $parameters['height']))), ' '); // Builds script for adding setup job to renderer $jsOutput = DataCenterJs::callFunction('dataCenter.renderer.addJob', array(DataCenterJs::toScalar('scene'), DataCenterJs::toScalar($parameters['id']), self::addPlanJsFunction($parameters))); // Adds script $xmlOutput .= DataCenterXml::script($jsOutput); // Begins widget $xmlOutput .= parent::end(); // Returns XML return $xmlOutput; }
public static function render(array $parameters) { global $egDataCenterGoogleMapsAPIKey; DataCenterUI::addScript('http://maps.google.com/maps?file=api&v=2&key=' . $egDataCenterGoogleMapsAPIKey); // Sets defaults $parameters = array_merge(self::$defaultParameters, $parameters); // Begins widget $xmlOutput = parent::begin($parameters['class']); // Checks if width was given as an integer if (is_int($parameters['width'])) { // Converts width to CSS pixel definition $parameters['width'] .= 'px'; } // Checks if height was given as an integer if (is_int($parameters['height'])) { // Converts height to CSS pixel definition $parameters['height'] .= 'px'; } // Build CSS style for XML element $style = "width:{$parameters['width']};height:{$parameters['height']};"; // Adds XML element $xmlOutput .= DataCenterXML::div(array('id' => $parameters['id'], 'style' => $style), ' '); // Checks if multiple locations were given if ($parameters['locations']) { // Builds script to add setup job to renderer $jsOutput = sprintf("dataCenter.renderer.addJob( 'map', %s, %s );", DataCenterJs::toScalar($parameters['id']), self::addMarkersJsFunction($parameters)); // Alternatively checks if a single location was given } elseif ($parameters['location']) { // Builds script to add setup job to renderer $jsOutput = sprintf("dataCenter.renderer.addJob( 'map', %s, %s );", DataCenterJS::toScalar($parameters['id']), self::showPositionJsFunction($parameters)); } else { // Adds an empty job to the render queue so the map gets rendered $jsOutput = sprintf("dataCenter.renderer.addJob( 'map', %s, %s );", DataCenterJS::toScalar($parameters['id']), 'function( map ) { return true; }'); } $xmlOutput .= DataCenterXml::script($jsOutput); // Ends widget $xmlOutput .= parent::end(); // Returns XML return $xmlOutput; }