/** * create dirs and place default documents */ private function initDotReposeSubdirectories() { static::$manager->createDir('default://.repose.d' . DS . 'schema'); static::$manager->createDir('default://.repose.d' . DS . 'policy'); static::$manager->createDir('default://.repose.d' . DS . 'forms'); static::$manager->put('default://.repose.d' . DS . 'schema' . DS . 'default.json', SchemaService::defaultSchema()); static::$manager->put('default://.repose.d' . DS . 'policy' . DS . 'default.json', PolicyService::defaultPolicy()); // TODO similar for forms dir }
/** * @param array<CuePoint> $cuePoints * @return string xml */ public static function generateXml(array $cuePoints) { $schemaType = CuePointPlugin::getApiValue(CuePointSchemaType::SERVE_API); $xsdUrl = "http://" . kConf::get('cdn_host') . "/api_v3/service/schema/action/serve/type/{$schemaType}"; $scenes = new SimpleXMLElement('<scenes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="' . $xsdUrl . '" />'); $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaCuePointXmlParser'); foreach ($cuePoints as $cuePoint) { $scene = null; foreach ($pluginInstances as $pluginInstance) { $scene = $pluginInstance->generateXml($cuePoint, $scenes, $scene); } } $xmlContent = $scenes->asXML(); $xml = new KDOMDocument(); libxml_use_internal_errors(true); libxml_clear_errors(); if (!$xml->loadXML($xmlContent)) { $errorMessage = kXml::getLibXmlErrorDescription($xmlContent); throw new kCuePointException("XML is invalid:\n{$errorMessage}", kCuePointException::XML_INVALID); } $xsdPath = SchemaService::getSchemaPath($schemaType); libxml_clear_errors(); if (!$xml->schemaValidate($xsdPath)) { $errorMessage = kXml::getLibXmlErrorDescription($xmlContent); throw new kCuePointException("XML is invalid:\n{$errorMessage}", kCuePointException::XML_INVALID); } return $xmlContent; }
public function schema($argv) { $ss = new SchemaService(); if (count($argv) === 2) { $schema = $ss->schema('default'); } else { $schema = $ss->schema($argv[2]); } print $schema->toJson() . "\n"; }
<?php $downloadUrl = 'http://' . kConf::get('www_host') . "/api_v3/index.php/service/schema/action/serve/type/{$schemaType}/name/{$schemaType}.xsd"; echo "Download URL: <a href=\"{$downloadUrl};\" target=\"_blank\">{$downloadUrl}</a><br/>\n"; $schemaPath = SchemaService::getSchemaPath($schemaType); $xslPath = dirname(__FILE__) . '/xsl/type.xsl'; // Load the XML source $xml = new KDOMDocument(); $xml->load($schemaPath); if ($xml->firstChild->hasAttribute('version')) { echo "Version: " . $xml->firstChild->getAttribute('version') . "<br/>\n"; } $xsl = new KDOMDocument(); $xsl->load($xslPath); // Configure the transformer $proc = new XSLTProcessor(); $proc->importStyleSheet($xsl); // attach the xsl rules echo "<br/>\n"; echo $proc->transformToXML($xml);