コード例 #1
0
 function writeCsproj()
 {
     $csprojDoc = new KDOMDocument();
     $csprojDoc->formatOutput = true;
     $csprojDoc->load($this->_sourcePath . "/KalturaClient/KalturaClient.csproj");
     $csprojXPath = new DOMXPath($csprojDoc);
     $csprojXPath->registerNamespace("m", "http://schemas.microsoft.com/developer/msbuild/2003");
     $compileNodes = $csprojXPath->query("//m:ItemGroup/m:Compile/..");
     $compileItemGroupElement = $compileNodes->item(0);
     foreach ($this->_csprojIncludes as $include) {
         $compileElement = $csprojDoc->createElement("Compile");
         $compileElement->setAttribute("Include", str_replace("/", "\\", $include));
         $compileItemGroupElement->appendChild($compileElement);
     }
     $this->addFile("KalturaClient/KalturaClient.csproj", $csprojDoc->saveXML(), false);
 }
コード例 #2
0
 public static function modifiedByKeditor($content)
 {
     $xml_doc = new KDOMDocument();
     $xml_doc->loadXML($content);
     $xpath = new DOMXPath($xml_doc);
     $metadata_elem = $xpath->query("//Metadata");
     $modified_by_keditor_list = $metadata_elem->getElementsByTagName("Modified");
     if ($modified_by_keditor_list != null && $modified_by_keditor_list->length > 0) {
         $modified_by_keditor = $modified_by_keditor_list->item(0)->nodeValue;
         return $content;
         //$modified_by_keditor->setValue
     } else {
         $newTextNode = $xml_doc->createTextNode("keditor");
         $modified = $xml_doc->createElement("Modified");
         //, "keditor" );
         $modified->appendChild($newTextNode);
         $metadata_elem->appendChild($modified);
     }
     return $xml_doc->saveXML();
 }
コード例 #3
0
ファイル: QuickPlayFeed.php プロジェクト: DBezemer/server
 /**
  * @param asset $asset
  * @param string $class
  * @param string $encodingProfile
  * @param string $duration
  * @param string $url
  */
 protected function createEnclosureXml(asset $asset, $class, $encodingProfile, $duration)
 {
     /**
      * 
      * In QuickPlay's XML example, the namespace "http://www.quickplaymedia.com" is added to the "enclosure" 
      * element regardless to the fact that it was registerted with the prefix "qpm" on the root element.
      * We cannot set a namespace that was already defined with a prefix because DOMDocument will add the element
      * as "qpm:enclosure" and won't set the namespace explicitly.
      * 
      * The hack is to create a new KDOMDocument with default namespace "http://www.quickplaymedia.com" and then
      * add it to the xml manually (see getXml() method)
      * 
      */
     $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey);
     $contentNode = $this->_enclosureNode->cloneNode(true);
     kXml::setNodeValue($this->_xpath, '@encodingProfile', $encodingProfile, $contentNode);
     $url = $this->getAssetUrl($asset);
     $mimeType = $this->getContentTypeFromUrl($url);
     $enclosureDoc = new KDOMDocument();
     $enclosureElement = $enclosureDoc->createElementNS('http://www.quickplaymedia.com', 'enclosure');
     $xmlElement = $enclosureDoc->createElement('xml');
     $enclosureDoc->appendChild($xmlElement);
     $enclosureNode = $enclosureDoc->importNode($contentNode, true);
     $enclosureNode->setAttribute('class', $class);
     $link = $enclosureNode->getElementsByTagName('link')->item(0);
     $link->setAttribute('type', $mimeType);
     $link->setAttribute('length', $fileSync->getFileSize());
     $link->setAttribute('duration', $duration);
     $link->setAttribute('url', pathinfo($fileSync->getFilePath(), PATHINFO_BASENAME));
     $xmlElement->appendChild($enclosureNode);
     return $enclosureDoc->saveXML($enclosureNode);
 }
コード例 #4
0
 /**
  * @param KalturaDistributionJobData $data
  * @param KalturaExampleDistributionProfile $distributionProfile
  * @param KalturaExampleDistributionJobProviderData $providerData
  */
 protected function handleUpdate(KalturaDistributionJobData $data, KalturaExampleDistributionProfile $distributionProfile, KalturaExampleDistributionJobProviderData $providerData)
 {
     $entryId = $data->entryDistribution->entryId;
     $partnerId = $distributionProfile->partnerId;
     $entry = $this->getEntry($partnerId, $entryId);
     $feed = new KDOMDocument();
     $feed->load($this->updateXmlTemplate);
     $feed->documentElement->setAttribute('mediaId', $data->remoteId);
     $nodes = array('title' => 'name', 'description' => 'description', 'width' => 'width', 'height' => 'height');
     foreach ($nodes as $nodeName => $entryAttribute) {
         $nodeElements = $feed->getElementsByTagName($nodeName);
         foreach ($nodeElements as $nodeElement) {
             $nodeElement->textContent = $entry->{$entryAttribute};
         }
     }
     // get the first asset id
     $thumbAssetIds = explode(',', $data->entryDistribution->thumbAssetIds);
     $thumbAssetId = reset($thumbAssetIds);
     $thumbElements = $feed->getElementsByTagName('thumb');
     $thumbElement = reset($thumbElements);
     $thumbElement->textContent = $this->getThumbAssetUrl($thumbAssetId);
     $videosElements = $feed->getElementsByTagName('videos');
     $videosElement = reset($videosElements);
     $flavorAssets = $this->getFlavorAssets($partnerId, $data->entryDistribution->flavorAssetIds);
     KBatchBase::impersonate($partnerId);
     foreach ($flavorAssets as $flavorAsset) {
         $url = $this->getFlavorAssetUrl($flavorAsset->id);
         $videoElement = $feed->createElement('video');
         $videoElement->textContent = $url;
         $videosElement->appendChild($videoElement);
     }
     KBatchBase::unimpersonate();
     $localFile = tempnam(sys_get_temp_dir(), 'example-update-');
     $feed->save($localFile);
     // loads ftp manager
     $engineOptions = isset(KBatchBase::$taskConfig->engineOptions) ? KBatchBase::$taskConfig->engineOptions->toArray() : array();
     $ftpManager = kFileTransferMgr::getInstance(kFileTransferMgrType::FTP, $engineOptions);
     $ftpManager->login(self::FTP_SERVER_URL, $distributionProfile->username, $distributionProfile->password);
     // put the XML file on the FTP
     $remoteFile = $entryId . '.xml';
     $ftpManager->putFile($remoteFile, $localFile);
     return true;
 }
コード例 #5
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshowId = $this->getP("kshow_id");
     $numberOfVersions = $this->getP("number_of_versions", 5);
     // must be int and not more than 50
     $numberOfVersions = (int) $numberOfVersions;
     $numberOfVersions = min($numberOfVersions, 50);
     $kshow = kshowPeer::retrieveByPK($kshowId);
     if (!$kshow) {
         $this->addError(APIErrors::KSHOW_DOES_NOT_EXISTS);
         return;
     }
     $showEntry = $kshow->getShowEntry();
     if (!$showEntry) {
         $this->addError(APIErrors::ROUGHCUT_NOT_FOUND);
         return;
     }
     $sync_key = $showEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
     $showEntryDataPath = kFileSyncUtils::getLocalFilePathForKey($sync_key);
     $versionsInfoFilePath = $showEntryDataPath . '.info';
     $lastVersionDoc = new KDOMDocument();
     $lastVersionDoc->loadXML(kFileSyncUtils::file_get_contents($sync_key, true, false));
     $lastVersion = myContentStorage::getVersion($showEntryDataPath);
     // check if we need to refresh the data in the info file
     $refreshInfoFile = true;
     if (file_exists($versionsInfoFilePath)) {
         $versionsInfoDoc = new KDOMDocument();
         $versionsInfoDoc->load($versionsInfoFilePath);
         $lastVersionInInfoFile = kXml::getLastElementAsText($versionsInfoDoc, "ShowVersion");
         if ($lastVersionInInfoFile && $lastVersion == $lastVersionInInfoFile) {
             $refreshInfoFile = false;
         } else {
             $refreshInfoFile = true;
         }
     } else {
         $refreshInfoFile = true;
     }
     // refresh or create the data in the info file
     if ($refreshInfoFile) {
         $versionsInfoDoc = new KDOMDocument();
         $xmlElement = $versionsInfoDoc->createElement("xml");
         // start from the first edited version (100001) and don't use 100000
         for ($i = myContentStorage::MIN_OBFUSCATOR_VALUE + 1; $i <= $lastVersion; $i++) {
             $version_sync_key = $showEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $i);
             if (kFileSyncUtils::file_exists($version_sync_key, false)) {
                 $xmlContent = kFileSyncUtils::file_get_contents($version_sync_key);
                 //echo "[" . htmlspecialchars( $xmlContent ) . "]<br>";
                 $xmlDoc = new KDOMDocument();
                 $xmlDoc->loadXML($xmlContent);
                 $elementToCopy = kXml::getFirstElement($xmlDoc, "MetaData");
                 //echo "[$i]";
                 $elementCloned = $elementToCopy->cloneNode(true);
                 $elementImported = $versionsInfoDoc->importNode($elementCloned, true);
                 $xmlElement->appendChild($elementImported);
             }
         }
         $versionsInfoDoc->appendChild($xmlElement);
         kFile::setFileContent($versionsInfoFilePath, $versionsInfoDoc->saveXML());
         // FileSync OK - created a temp file on DC's disk
     }
     $metadataNodes = $versionsInfoDoc->getElementsByTagName("MetaData");
     $count = 0;
     $versionsInfo = array();
     for ($i = $metadataNodes->length - 1; $i >= 0; $i--) {
         $metadataNode = $metadataNodes->item($i);
         $node = kXml::getFirstElement($metadataNode, "ShowVersion");
         $showVersion = $node ? $node->nodeValue : "";
         $node = kXml::getFirstElement($metadataNode, "PuserId");
         $puserId = $node ? $node->nodeValue : "";
         $node = kXml::getFirstElement($metadataNode, "ScreenName");
         $screenName = $node ? $node->nodeValue : "";
         $node = kXml::getFirstElement($metadataNode, "UpdatedAt");
         $updatedAt = $node ? $node->nodeValue : "";
         $versionsInfo[] = array("version" => $showVersion, "puserId" => $puserId, "screenName" => $screenName, "updatedAt" => $updatedAt);
         $count++;
         if ($count >= $numberOfVersions) {
             break;
         }
     }
     $this->addMsg("show_versions", $versionsInfo);
 }