/** * Called by AJAX * @return */ public function RegionPreview() { $db =& $this->db; $user =& $this->user; include_once "lib/data/region.data.class.php"; //ajax request handler $response = new ResponseManager(); //Expect $layoutid = Kit::GetParam('layoutid', _POST, _INT, 0); $regionid = Kit::GetParam('regionid', _POST, _STRING); $seqGiven = Kit::GetParam('seq', _POST, _INT, 0); $seq = Kit::GetParam('seq', _POST, _INT, 0); $width = Kit::GetParam('width', _POST, _INT, 0); $height = Kit::GetParam('height', _POST, _INT, 0); // The sequence will not be zero based, so adjust it $seq--; // Get some region imformation $return = ""; $xml = new DOMDocument("1.0"); $region = new region($db); if (!($xmlString = $region->GetLayoutXml($layoutid))) { trigger_error($region->GetErrorMessage(), E_USER_ERROR); } $xml->loadXML($xmlString); // This will be all the media nodes in the region provided $xpath = new DOMXPath($xml); $nodeList = $xpath->query("//region[@id='{$regionid}']/media"); $return = ''; if ($nodeList->length == 0) { // No media to preview $response->extra['text'] = __('Empty Region'); $response->html = ''; $response->Respond(); } $node = $nodeList->item($seq); // We have our node. $type = (string) $node->getAttribute("type"); $mediaDurationText = (string) $node->getAttribute("duration"); $mediaid = (string) $node->getAttribute("id"); // Create a module to deal with this if (!file_exists('modules/' . $type . '.module.php')) { $return .= 'Unknow module type'; } require_once "modules/{$type}.module.php"; if (!($moduleObject = new $type($db, $user, $mediaid, $layoutid, $regionid))) { trigger_error($moduleObject->GetErrorMessage(), E_USER_ERROR); } $return .= '<div class="regionPreviewOverlay"></div>'; $return .= $moduleObject->Preview($width, $height); $response->html = $return; $response->extra['type'] = $type; $response->extra['duration'] = $mediaDurationText; $response->extra['number_items'] = $nodeList->length; $response->extra['text'] = $seqGiven . ' / ' . $nodeList->length . ' ' . $moduleObject->displayType . ' lasting ' . $mediaDurationText . ' seconds'; $response->extra['current_item'] = $seqGiven; $response->Respond(); }