/** * @return KalturaClientPlugin */ public static function get() { if (!self::$instance) { self::$instance = new KalturaContentDistributionClientPlugin(); } return self::$instance; }
public function doAction(Zend_Controller_Action $action) { $request = $action->getRequest(); $page = $this->_getParam('page', 1); $pageSize = $this->_getParam('pageSize', 10); $form = new Form_PartnerFilter(); $newForm = new Form_NewDistributionProfile(); $actionUrl = $action->view->url(array('controller' => 'plugin', 'action' => 'DistributionProfileListAction'), null, true); $form->setAction($actionUrl); // init filter $partnerFilter = $this->getPartnerFilterFromRequest($request); // get results and paginate $paginatorAdapter = new Kaltura_FilterPaginator("distributionProfile", "listByPartner", null, $partnerFilter); $paginator = new Kaltura_Paginator($paginatorAdapter, $request); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($pageSize); $providers = array(KalturaDistributionProviderType::GENERIC => 'Generic', KalturaDistributionProviderType::SYNDICATION => 'Syndication'); $genericProviders = array(); $client = Kaltura_ClientHelper::getClient(); $contentDistributionClientPlugin = KalturaContentDistributionClientPlugin::get($client); $providersList = $contentDistributionClientPlugin->distributionProvider->listAction(); if ($providersList) { foreach ($providersList->objects as $provider) { if ($provider->type == KalturaDistributionProviderType::GENERIC) { $genericProviders[$provider->id] = $provider->name; } else { $providers[$provider->type] = $provider->name; } } } $newForm->setProviders($providers); // set view $action->view->form = $form; $action->view->newForm = $newForm; $action->view->paginator = $paginator; $action->view->providers = $providers; $action->view->genericProviders = $genericProviders; }
protected function getEntryDistribution($entryId, $distributionProfileId) { $distributionPlugin = KalturaContentDistributionClientPlugin::get($this->getClient()); $entryDistributionFilter = new KalturaEntryDistributionFilter(); $entryDistributionFilter->entryIdEqual = $entryId; $entryDistributionFilter->distributionProfileIdEqual = $distributionProfileId; $result = $distributionPlugin->entryDistribution->listAction($entryDistributionFilter); if (count($result->objects)) { return $result->objects[0]; } else { return null; } }
/** * @param string $flavorAssetId * @return string url */ protected function getFlavorAssetUrl($flavorAssetId) { $contentDistributionPlugin = KalturaContentDistributionClientPlugin::get($this->kalturaClient); return $contentDistributionPlugin->contentDistributionBatch->getAssetUrl($flavorAssetId); // $this->impersonate($this->partnerId); // $url = $this->kalturaClient->flavorAsset->getDownloadUrl($flavorAssetId, true); // $this->unimpersonate(); // return $url; }
/** * @param string $flavorAssetId * @return string url */ protected function getFlavorAssetUrl($flavorAssetId) { $contentDistributionPlugin = KalturaContentDistributionClientPlugin::get($this->kalturaClient); return $contentDistributionPlugin->contentDistributionBatch->getAssetUrl($flavorAssetId); }
public function handleDistribution($entryId, SimpleXMLElement $distribution) { $distributionProfileId = null; if (!empty($distribution->distributionProfileId)) { $distributionProfileId = (int) $distribution->distributionProfileId; } if (!$distributionProfileId && (!empty($distribution->distributionProfile) || !empty($distribution->distributionProvider))) { $distributionProfileId = $this->getDistributionProfileId($distribution->distributionProfile, $distribution->distributionProvider); } if (!$distributionProfileId) { throw new KalturaBatchException("Missing custom data distributionProfile attribute", KalturaBatchJobAppErrors::BULK_MISSING_MANDATORY_PARAMETER); } $distributionPlugin = KalturaContentDistributionClientPlugin::get($this->xmlBulkUploadEngine->getClient()); $entryDistributionFilter = new KalturaEntryDistributionFilter(); $entryDistributionFilter->distributionProfileIdEqual = $distributionProfileId; $entryDistributionFilter->entryIdEqual = $entryId; $pager = new KalturaFilterPager(); $pager->pageSize = 1; $entryDistributionResponse = $distributionPlugin->entryDistribution->listAction($entryDistributionFilter, $pager); $entryDistribution = new KalturaEntryDistribution(); $entryDistributionId = null; if (is_array($entryDistributionResponse->objects) && count($entryDistributionResponse->objects) > 0) { $existingEntryDistribution = reset($entryDistributionResponse->objects); $entryDistributionId = $existingEntryDistribution->id; } else { $entryDistribution->entryId = $entryId; $entryDistribution->distributionProfileId = $distributionProfileId; } if (!empty($distribution->sunrise) && KBulkUploadEngine::isFormatedDate($distribution->sunrise)) { $entryDistribution->sunrise = KBulkUploadEngine::parseFormatedDate($distribution->sunrise); } if (!empty($distribution->sunset) && KBulkUploadEngine::isFormatedDate($distribution->sunset)) { $entryDistribution->sunset = KBulkUploadEngine::parseFormatedDate($distribution->sunset); } if (!empty($distribution->flavorAssetIds)) { $entryDistribution->flavorAssetIds = $distribution->flavorAssetIds; } if (!empty($distribution->thumbAssetIds)) { $entryDistribution->thumbAssetIds = $distribution->thumbAssetIds; } $submitWhenReady = false; if ($distribution['submitWhenReady']) { $submitWhenReady = true; } $this->xmlBulkUploadEngine->impersonate(); if ($entryDistributionId) { $updatedEntryDistribution = $distributionPlugin->entryDistribution->update($entryDistributionId, $entryDistribution); if ($submitWhenReady && $updatedEntryDistribution->dirtyStatus == KalturaEntryDistributionFlag::UPDATE_REQUIRED) { $distributionPlugin->entryDistribution->submitUpdate($entryDistributionId); } } else { $createdEntryDistribution = $distributionPlugin->entryDistribution->add($entryDistribution); $distributionPlugin->entryDistribution->submitAdd($createdEntryDistribution->id, $submitWhenReady); } $this->xmlBulkUploadEngine->unimpersonate(); }