/**
  * Redirect to controls if vlc is running
  * @param Zend_Controller_Action $controller
  */
 public function gen_beforePageBuild(Zend_Controller_Action $controller)
 {
     /*
     $vlc = X_Vlc::getLastInstance();
     
     if ( $vlc === null ) {
     	X_Debug::i("No vlc instance");
     	return;
     }
     */
     $controllerName = $controller->getRequest()->getControllerName();
     $actionName = $controller->getRequest()->getActionName();
     $query = "{$controllerName}/{$actionName}";
     X_Debug::i("Plugin triggered for: {$query}");
     //$isRunning = $vlc->isRunning();
     $isRunning = X_Streamer::i()->isStreaming();
     if (array_search($query, $this->redirectCond_To) !== false && $isRunning) {
         $controller->getRequest()->setControllerName('controls')->setActionName('control')->setDispatched(false);
         X_Debug::i("Redirect to controls/control");
     } elseif (array_search($query, $this->redirectCond_Away) !== false && !$isRunning) {
         X_Debug::i("Redirect to index/collections");
         $controller->getRequest()->setControllerName('index')->setActionName('collections')->setDispatched(false);
     } else {
         X_Debug::i("No redirection: vlc is running? " . ($isRunning ? 'Yes' : 'No'));
     }
 }
Пример #2
0
 public function doAction(Zend_Controller_Action $action)
 {
     $entryId = $action->getRequest()->getParam('entry-id');
     $xslt = $action->getRequest()->getParam('xslt');
     $this->client = Infra_ClientHelper::getClient();
     $xml = $this->client->media->getMrss($entryId);
     $xslParams = array();
     $xslParams['entryDistributionId'] = '';
     $xslParams['distributionProfileId'] = '';
     ob_start();
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($xml);
     $xsltDoc = new DOMDocument();
     $xsltDoc->loadXML($xslt);
     $xslt = new XSLTProcessor();
     $xslt->registerPHPFunctions();
     // it is safe to register all php fuctions here
     $xslt->setParameter('', $xslParams);
     $xslt->importStyleSheet($xsltDoc);
     $ob = ob_get_clean();
     ob_end_clean();
     if ($ob) {
         $action->getHelper('json')->direct(array('error' => $ob));
     }
     $obj = array('result' => $xslt->transformToXml($xmlDoc));
     $action->getHelper('json')->direct($obj);
 }
 /**
  * Redirect to controls if vlc is running
  * @param Zend_Controller_Action $controller
  */
 public function gen_beforePageBuild(Zend_Controller_Action $controller)
 {
     X_Debug::i("Plugin triggered: redirect to installer");
     $controllerName = $controller->getRequest()->getControllerName();
     if ($controllerName != 'installer' && $controllerName != 'error') {
         //die($controllerName);
         $controller->getRequest()->setControllerName('installer')->setActionName('index')->setDispatched(false);
     }
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $request = $action->getRequest();
     $page = $this->_getParam('page', 1);
     $pageSize = $this->_getParam('pageSize', 10);
     $form = new Form_PartnerIdFilter();
     $form->populate($request->getParams());
     $newForm = new Form_NewEventNotificationTemplate();
     $actionUrl = $action->view->url(array('controller' => 'plugin', 'action' => 'EventNotificationTemplatesListAction'), null, true);
     $form->setAction($actionUrl);
     // init filter
     $partnerFilter = $this->getPartnerFilterFromRequest($request);
     $client = Infra_ClientHelper::getClient();
     $eventNotificationPlugin = Kaltura_Client_EventNotification_Plugin::get($client);
     // get results and paginate
     $paginatorAdapter = new Infra_FilterPaginator($eventNotificationPlugin->eventNotificationTemplate, "listByPartner", null, $partnerFilter);
     $paginator = new Infra_Paginator($paginatorAdapter, $request);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($pageSize);
     if ($partnerFilter) {
         $newForm->getElement('newPartnerId')->setValue($partnerFilter->idIn);
     }
     // set view
     $action->view->form = $form;
     $action->view->newForm = $newForm;
     $action->view->paginator = $paginator;
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $request = $action->getRequest();
     $field = $request->getParam('field', null);
     $id = $request->getParam('id', null);
     $type = $request->getParam('type', null);
     $reqponse = $this->query($type, array("{$field}Id" => array($id)), array("@timestamp" => "desc"), 100, array("sessionId"));
     $json = array();
     if (isset($reqponse->hits) && isset($reqponse->hits->hits)) {
         $sessions = array();
         foreach ($reqponse->hits->hits as $hit) {
             if (isset($hit->fields) && isset($hit->fields->sessionId)) {
                 foreach ($hit->fields->sessionId as $sessionId) {
                     if (!in_array("{$sessionId}", $sessions)) {
                         $sessions[] = "{$sessionId}";
                     }
                 }
             }
         }
         $reqponse = $this->query($type, array("sessionId" => $sessions), array("@timestamp" => "asc", "sessionIndex" => "asc"), 100000);
         if (isset($reqponse->hits) && isset($reqponse->hits->hits)) {
             $json = $reqponse->hits->hits;
         }
     }
     echo $action->getHelper('json')->sendJson($json, false);
 }
Пример #6
0
 public function doAction(Zend_Controller_Action $action)
 {
     $client = Infra_ClientHelper::getClient();
     $virusScanPlugin = Kaltura_Client_VirusScan_Plugin::get($client);
     //create new form
     $newForm = new Form_NewVirusScanProfile();
     $page = $this->_getParam('page', 1);
     $pageSize = $this->_getParam('pageSize', 10);
     //get PartnerId
     $partnerId = $this->_getParam('partnerId');
     //filter form
     $request = $action->getRequest();
     $virusScanFilterForm = new Form_VirusScanFilter();
     $virusScanFilterFormAction = $action->view->url(array('controller' => $request->getParam('controller'), 'action' => $request->getParam('action')), null, true);
     $virusScanFilterForm->setAction($virusScanFilterFormAction);
     $virusScanFilterForm->populate($request->getParams());
     $virusScanFilter = $this->getVirusScanFilterFromRequest($request);
     $newForm->getElement("newPartnerId")->setValue($virusScanFilter->partnerIdEqual);
     //filter also by partnerId
     if (!is_null($partnerId)) {
         $virusScanFilter->partnerIdEqual = $partnerId;
     }
     $paginatorAdapter = new Infra_FilterPaginator($virusScanPlugin->virusScanProfile, "listAction", null, $virusScanFilter);
     $paginator = new Infra_Paginator($paginatorAdapter);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($pageSize);
     $action->view->virusScanFilterForm = $virusScanFilterForm;
     $action->view->newForm = $newForm;
     $action->view->paginator = $paginator;
 }
Пример #7
0
 public function doAction(Zend_Controller_Action $action)
 {
     $request = $action->getRequest();
     $page = $this->_getParam('page', 1);
     $pageSize = $this->_getParam('pageSize', 10);
     $partnerId = $this->_getParam('partnerId');
     // init filter
     $drmProfileFilter = $this->getDrmProfileFilterFromRequest($request);
     $drmProfileFilter->orderBy = "-createdAt";
     $client = Infra_ClientHelper::getClient();
     $drmPluginClient = Kaltura_Client_Drm_Plugin::get($client);
     // get results and paginate
     $paginatorAdapter = new Infra_FilterPaginator($drmPluginClient->drmProfile, "listAction", null, $drmProfileFilter);
     $paginator = new Infra_Paginator($paginatorAdapter, $request);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($pageSize);
     // set view
     $drmProfileFilterForm = new Form_DrmProfileFilter();
     $drmProfileFilterForm->populate($request->getParams());
     $drmProfileFilterFormAction = $action->view->url(array('controller' => $request->getParam('controller'), 'action' => $request->getParam('action')), null, true);
     $drmProfileFilterForm->setAction($drmProfileFilterFormAction);
     $action->view->filterForm = $drmProfileFilterForm;
     $action->view->paginator = $paginator;
     $createProfileForm = new Form_CreateDrmProfile();
     $actionUrl = $action->view->url(array('controller' => 'plugin', 'action' => 'DrmProfileConfigure'), null, true);
     $createProfileForm->setAction($actionUrl);
     if ($drmProfileFilter && isset($drmProfileFilter->partnerIdEqual)) {
         $createProfileForm->getElement("newPartnerId")->setValue($drmProfileFilter->partnerIdEqual);
     }
     $action->view->newProfileForm = $createProfileForm;
 }
Пример #8
0
 /**
  * Hook into action controller preDispatch() workflow
  *
  * @return void
  */
 public function preDispatch()
 {
     $role = 'guest';
     //        die($role);
     if ($this->_auth->hasIdentity()) {
         $user = $this->_auth->getIdentity();
         if (is_object($user)) {
             $role = $this->_auth->getIdentity()->role;
         }
     }
     $request = $this->_action->getRequest();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $module = $request->getModuleName();
     //        $this->view->getLayout()->setLayout($module);
     $this->_controllerName = $controller;
     $resource = $controller;
     $privilege = $action;
     if (!$this->_acl->has($resource)) {
         $resource = null;
     }
     if (!$this->_acl->isAllowed($role, $resource, $privilege)) {
         if (!$this->_auth->hasIdentity()) {
             $noPermsAction = $this->_acl->getNoAuthAction();
         } else {
             $noPermsAction = $this->_acl->getNoAclAction();
         }
         $request->setModuleName($noPermsAction['module']);
         $request->setControllerName($noPermsAction['controller']);
         $request->setActionName($noPermsAction['action']);
         $request->setDispatched(false);
     }
 }
Пример #9
0
 /**
  * getRequest() - 
  * 
  * @return Zend_Controller_Request_Abstract $request 
  */
 public function getRequest()
 {
     if (null === $this->_request) {
         $this->_request = $this->_actionController->getRequest();
     }
     return $this->_request;
 }
Пример #10
0
 /**
  * Hook into action controller preDispatch() workflow
  *
  * @return void
  */
 public function preDispatch()
 {
     $role = 'public';
     if ($this->_auth->hasIdentity()) {
         $user = $this->_auth->getIdentity();
         if (is_object($user)) {
             $role = $this->_auth->getIdentity()->role;
         }
     }
     $request = $this->_action->getRequest();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $module = $request->getModuleName();
     $this->_controllerName = $controller;
     $resource = $controller;
     $privilege = $action;
     if (!$this->_acl->has($resource)) {
         $resource = null;
     }
     if (!$this->_acl->isAllowed($role, $resource, $privilege)) {
         $request->setModuleName('default');
         $request->setControllerName('error');
         $request->setActionName('error');
         $request->setDispatched(false);
     }
     /**	
     		 if (!$this->_acl->isAllowed($role, $resource, $privilege)){
     		throw new Pas_Exception_NotAuthorised('Not authorised');
     		
     		}
     
     		***/
 }
Пример #11
0
 public function doAction(Zend_Controller_Action $action)
 {
     $entryId = $action->getRequest()->getParam('entry-id');
     $this->client = Infra_ClientHelper::getClient();
     $action->getHelper('layout')->setLayout('layout_empty');
     $action->view->entryId = $entryId;
     $action->view->xml = $this->client->media->getMrss($entryId);
 }
Пример #12
0
 public function doAction(Zend_Controller_Action $action)
 {
     $request = $action->getRequest();
     $page = $request->getParam('page', 1);
     $pageSize = $request->getParam('pageSize', 10);
     $action->view->form = new Form_PartnerFilter();
     // init filter
     $partnerFilter = $this->getPartnerFilterFromRequest($request);
     /*
     		// get results and paginate
     		$paginatorAdapter = new Kaltura_FilterPaginator("metadataProfile", "listAction", null, $partnerFilter);
     		$paginator = new Kaltura_Paginator($paginatorAdapter, $request);
     		$paginator->setCurrentPageNumber($page);
     		$paginator->setItemCountPerPage($pageSize);
     		
     		// popule the form
     		$form->populate($request->getParams());
     		
     		// set view
     		$action->view->form = $form;
     		$action->view->paginator = $paginator;
     */
     return;
     $request = $action->getRequest();
     $action->view->metadataProfilesForm = new Form_metadataProfiles();
     $action->view->metadataProfilesForm->populate($request->getParams());
     $partnerId = $request->getParam('partnerId', false);
     $entryId = $request->getParam('entryId', false);
     $freeText = $request->getParam('freeText', false);
     $form = new Form_PartnerFilter();
     $form->populate($request->getParams());
     $action->view->form = $form;
     if ($partnerId || $entryId || $freeText) {
         try {
             $client = Kaltura_ClientHelper::getClient();
             $metadataProfileFilter = new KalturaMetadataProfileFilter();
             $metadataProfileFilter->partnerIdEqual = $partnerId;
             $this->view->inQueuePaginator = null;
             //$client->user->add($systemUser);
         } catch (Exception $ex) {
             //to do
         }
     }
 }
Пример #13
0
 public function init()
 {
     parent::getRequest();
     $this->view = new Smarty();
     $this->view->template_dir = ROOT_DIR . '/application/views/';
     $this->view->compile_dir = ROOT_DIR . '/application/views_c/';
     $this->view->assign('BASE_URL', BASE_URL);
     $this->view->assign('ROOT_DIR', ROOT_DIR);
     $this->view->assign('ADMIN_DIR', ADMIN_DIR);
     $this->view->assign('isAjax', $this->getIsAjaxRequest());
     $this->view->caching = false;
     $this->viewIncludes = array();
     $this->dbAdapter = Zend_Registry::get('dbAdapter');
     $this->auth = Zend_Auth::getInstance();
     //---------- from predispatch
     $request = $this->getRequest();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     if (!$this->auth->hasIdentity() && $controller != 'auth') {
         $this->_redirect('/auth/');
     } else {
         if ($this->auth->hasIdentity() && $controller == 'auth' && $action != 'logout') {
             $this->_redirect('/');
         }
     }
     // ---------------
     if ($this->auth->hasIdentity()) {
         $this->user = new User($this->auth->getStorage()->read()->u_id);
     } else {
         return;
     }
     $this->controllers = new ControllersHandler();
     if (!$this->user->checkReadPerm($this->controllers->getControllerIdByName($this->getRequest()->getControllerName()))) {
         $this->_redirect('/pages/');
     }
     /*    if(!($this->siteId = $this->getCookie('cur_site_id')))
     		{
                 $this->siteId = 2;
             }
     */
     $sitesList = $this->getSitesList();
     $this->tplVars['header'] = array('username' => $this->user->getLogin(), 'sites' => $sitesList, 'curSite' => $sitesList['names'][$this->siteId], 'curHost' => $this->getNCSiteHostname(), 'controllers' => $this->getControllersList(), 'actions' => array('selected' => $this->getRequest()->getActionName()), 'curController' => $this->getRequest()->getControllerName(), 'adminHost' => $this->getXadmin());
     $this->tplVars['page_css'] = array();
     $this->tplVars['page_js'] = array();
     $config = new Zend_Config_Ini(ROOT_DIR . '/application/config.ini', 'general');
     $filter = $config->log->toArray();
     foreach ($filter as $k => $f) {
         $filter[$k] = explode(",", $f);
     }
     if (isset($filter[$controller]) && in_array($action, $filter[$controller])) {
         $this->to_log();
     }
 }
Пример #14
0
 function gen_beforePageBuild(Zend_Controller_Action $controller)
 {
     $moduleName = $controller->getRequest()->getModuleName();
     $controllerName = $controller->getRequest()->getControllerName();
     $actionName = $controller->getRequest()->getActionName();
     $providerName = $controller->getRequest()->getParam('p', false);
     // check permission class
     if ($controllerName == 'browse' && $actionName == 'share') {
         // check provider too only if controller == browse
         $resourceKey = "{$moduleName}/{$controllerName}/{$actionName}" . ($providerName !== false ? "/{$providerName}" : '');
     } else {
         $resourceKey = "{$moduleName}/{$controllerName}/{$actionName}";
     }
     // TODO:
     // replace this with an ACL call:
     //  if ( !$acl->canUse($resource, $currentStatus) )
     if (array_search("{$moduleName}/{$controllerName}/{$actionName}", $this->_whiteList) === false) {
         if (!$this->isLoggedIn()) {
             X_Debug::i("Login required and user not logged in");
             if ($this->helpers()->devices()->isVlc()) {
                 X_Debug::i("Look like it's this vlc: {$_SERVER['REMOTE_ADDR']}");
                 if (gethostbyname($_SERVER['REMOTE_ADDR']) == '::1' || gethostbyname($_SERVER['REMOTE_ADDR']) == '127.0.0.1') {
                     X_Debug::i("Skipping auth, it should be the local vlc");
                     return;
                 }
             } elseif ($this->helpers()->devices()->isWiimc() && $this->helpers()->devices()->isWiimcBeforeVersion('1.1.6')) {
                 // wiimc <= 1.1.5 send 2 different user-agent string
                 // for browsing mode and video mode
                 // so i have care about this
                 // TODO remove this when 1.1.5 an older will be deprecated
                 // anyway i take care only of vanilla wiimc based on ios58. custom version
                 // not supported
                 $useragent = "{$_SERVER['HTTP_USER_AGENT']} (IOS58)";
                 // try to add " (ISO58)" to the useragent and check again
                 if (Application_Model_AuthSessionsMapper::i()->fetchByIpUserAgent($_SERVER['REMOTE_ADDR'], $useragent)) {
                     X_Debug::i("Workaround for WIIMC user-agent-incongruence");
                     return;
                 }
             } elseif ($this->helpers()->acl()->canUseAnonymously($resourceKey)) {
                 X_Debug::i("Resource can be used anonymously");
                 return;
             }
             X_Debug::w("Auth required, redirecting to login");
             $controller->getRequest()->setControllerName("auth")->setActionName('index')->setDispatched(false);
         } elseif ($this->config('acl.enabled', false)) {
             X_Debug::i("ACL enabled, checking resource {{$resourceKey}}");
             $username = $this->getCurrentUser(true);
             if (!$this->helpers()->acl()->canUse($username, $resourceKey)) {
                 X_Debug::w("Forbidden, can't access resource");
                 $controller->getRequest()->setControllerName("auth")->setActionName('forbidden')->setDispatched(false);
             } else {
                 X_Debug::i("Access granted");
             }
         } else {
             X_Debug::i("ACL disabled");
         }
     } else {
         X_Debug::i("Whitelisted resource");
     }
 }
Пример #15
0
 public function doAction(Zend_Controller_Action $action)
 {
     $action->getHelper('layout')->disableLayout();
     $request = $action->getRequest();
     $drmProfileId = $this->_getParam('drm_profile_id');
     $partnerId = $this->_getParam('new_partner_id');
     $drmProfileProvider = $this->_getParam('new_drm_profile_provider');
     $drmProfileForm = null;
     $action->view->formValid = false;
     try {
         if ($request->isPost()) {
             $partnerId = $this->_getParam('partnerId');
             $drmProfileProvider = $this->_getParam('provider');
             $drmProfileForm = new Form_DrmProfileConfigure($partnerId, $drmProfileProvider);
             $action->view->formValid = $this->processForm($drmProfileForm, $request->getPost(), $partnerId, $drmProfileId);
             if (!is_null($drmProfileId)) {
                 $drmProfile = $drmProfileForm->getObject("Kaltura_Client_Drm_Type_DrmProfile", $request->getPost(), false, true);
             }
         } else {
             if (!is_null($drmProfileId)) {
                 $client = Infra_ClientHelper::getClient();
                 $drmPluginClient = Kaltura_Client_Drm_Plugin::get($client);
                 $drmProfile = $drmPluginClient->drmProfile->get($drmProfileId);
                 $partnerId = $drmProfile->partnerId;
                 $drmProfileProvider = $drmProfile->provider;
                 $drmProfileForm = new Form_DrmProfileConfigure($partnerId, $drmProfileProvider);
                 $drmProfileForm->populateFromObject($drmProfile, false);
             } else {
                 $drmProfileForm = new Form_DrmProfileConfigure($partnerId, $drmProfileProvider);
                 $drmProfileForm->getElement('partnerId')->setValue($partnerId);
             }
         }
     } catch (Exception $e) {
         $action->view->formValid = false;
         KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString());
         $action->view->errMessage = $e->getMessage();
     }
     $action->view->form = $drmProfileForm;
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaApplicationPartialView');
     KalturaLog::debug("plugin instances [" . count($pluginInstances) . "]");
     foreach ($pluginInstances as $pluginInstance) {
         $drmProfilePlugins = $pluginInstance->getApplicationPartialViews('plugin', get_class($this));
         if (!$drmProfilePlugins) {
             continue;
         }
         foreach ($drmProfilePlugins as $plugin) {
             /* @var $plugin Kaltura_View_Helper_PartialViewPlugin */
             $plugin->plug($action->view);
         }
     }
 }
Пример #16
0
 /**
  * Get category/video list
  * @param unknown_type $provider
  * @param unknown_type $location
  * @param Zend_Controller_Action $controller
  */
 public function getShareItems($provider, $location, Zend_Controller_Action $controller)
 {
     if ($provider != $this->getId()) {
         return;
     }
     X_Debug::i('Plugin triggered');
     X_VlcShares_Plugins::broker()->unregisterPluginClass('X_VlcShares_Plugins_SortItems');
     //$baseUrl = $this->config('base.url', 'http://www.gogocinema.net/mediacenter/index.php?page=ajax_show_folder&id=');
     $items = new X_Page_ItemList_PItem();
     X_Debug::i("Requested location: {$location}");
     // location format:
     // sortType/subType/page/thread/linkType:linkId
     $split = $location != '' ? @explode('/', $location, 5) : array();
     @(list($sortType, $subType, $page, $thread, $linkTypeId) = $split);
     X_Debug::i("Exploded location: " . var_export($split, true));
     // special case: if sortType = search the subType param can be in
     // gogocinema:search
     if ($sortType == self::SORT_SEARCH && is_null($subType)) {
         $this->disableCache();
         $searchValue = $controller->getRequest()->getParam("{$this->getId()}:search", null);
         if ($searchValue == null) {
             // go back in index
             $split = array();
         } else {
             $subType = $searchValue;
             $split[1] = $searchValue;
             // in this way sort search doesn't go in classification
         }
     }
     switch (count($split)) {
         case 5:
             // we shouldn't be here!
         // we shouldn't be here!
         case 4:
             $this->_fetchVideos($items, $sortType, $subType, $page, $thread);
             break;
         case 2:
             $page = 1;
         case 3:
             $this->_fetchThreads($items, $sortType, $subType, $page);
             break;
         case 1:
             $this->_fetchClassification($items, $sortType);
             break;
         case 0:
         default:
             $this->disableCache();
             $this->_fetchSortType($items);
     }
     return $items;
 }
Пример #17
0
 /**
  * Add the button BackToStream in controls page
  *
  * @param X_Streamer_Engine $engine
  * @param Zend_Controller_Action $controller the controller who handle the request
  * @return array
  */
 public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller)
 {
     $urlHelper = $controller->getHelper('url');
     $return = new X_Page_ItemList_PItem();
     if ($this->config('show.title', true)) {
         $onAirName = X_Env::_("p_streaminfo_unknown_source");
         if ($engine instanceof X_Streamer_Engine_Vlc) {
             $vlc = $engine->getVlcWrapper();
             $onAirName = $vlc->getCurrentName();
         } else {
             // try to find the name from the location (if any)
             $providerId = $controller->getRequest()->getParam('p', false);
             $location = $controller->getRequest()->getParam('l', false);
             if ($providerId && $location) {
                 $providerObj = X_VlcShares_Plugins::broker()->getPlugins($providerId);
                 $location = X_Env::decode($location);
                 if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) {
                     $onAirName = $providerObj->resolveLocation($location);
                 }
             }
         }
         // show the title of the file
         $item = new X_Page_Item_PItem('streaminfo-onair', X_Env::_('p_streaminfo_onair') . ": {$onAirName}");
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($urlHelper->url()));
         $return->append($item);
     }
     if ($engine instanceof X_Streamer_Engine_Vlc) {
         $vlc = $engine->getVlcWrapper();
         if ($this->config('show.time', false)) {
             $currentTime = X_Env::formatTime($vlc->getCurrentTime());
             $totalTime = X_Env::formatTime($vlc->getTotalTime());
             $item = new X_Page_Item_PItem('streaminfo-time', "{$currentTime}/{$totalTime}");
             $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($urlHelper->url()));
             $return->append($item);
         }
     }
     return $return;
 }
Пример #18
0
 /**
  * Manipula uma chamada para relatório, mostrando o formulário correto,
  * executando a classe e operação de domínio que levanta os dados e renderizando
  * a view/partial correta
  * <br/>
  * $renderViews são um array onde o índice é o nome de um parâmetro que pode ser
  * recebido no request e o valor é a view a ser renderizada.<br/>
  * O índice 'report' deve ser usado com a view de relatório padrão. 'form'
  * deve ser utilizado para a view de interface para renderizar o formulário.
  * <br/>
  *  ['report'] => 'view-padrao'<br/>
  *  ['form'] => 'view-form'<br/>
  *  ['summarized'] => 'view-summarized'<br/>
  * 
  * @param String $domainClass
  * @param String $domainAction
  * @param String $formClass name of the form class
  * @param ArrayObject $renderViews
  * @param String $viewFolder é o nome do diretório onde estão as views, para ser renderizada com retorno, em geral para o pdf
  * @param Zend_View $view o objeto view
  * @param Zend_Request $request o objeto request
  * @return String
  */
 public function handleRequest($domainClass, $domainAction, $formClass, array $renderViews, $viewFolder, Agana_Print_Meta $metaReport, Zend_Controller_Action $controller)
 {
     //        die(Zend_Debug::dump($controller->view));
     $controller->view->records = null;
     if ($controller->getRequest()->getParam('format')) {
         $layout = Zend_Layout::getMvcInstance();
         $layout->setLayout('report.layout');
         $domain = new $domainClass();
         $controller->view->records = $domain->{$domainAction}(Zend_Auth::getInstance()->getIdentity()->appaccount_id, $controller->getRequest()->getParams());
         $viewToRender = $this->viewToRender($controller->getRequest()->getParams(), $renderViews);
         $controller->view->format = $controller->getParam('format');
         $personDomain = new Persons_Domain_Person();
         $person = $personDomain->getById(Zend_Auth::getInstance()->getIdentity()->person_id);
         $appAccount = $person->getAppaccount();
         $metaReport->setAccountName($appAccount->getName());
         if ($controller->getParam('format') == 'pdf') {
             $report = new Agana_Print_Pdf_Report($metaReport, $controller->view->theme_path);
             $controller->view->assign('report', $report);
             $layout->disableLayout();
             $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
             $viewRenderer->setNoRender(true);
             $content = $controller->view->render($viewFolder . '/' . $viewToRender . '.phtml');
             $report->addPage($content);
             $report->download();
         } else {
             $report = new Agana_Print_Html_Report($metaReport, '');
             $controller->view->assign('report', $report);
             return $controller->render($viewToRender);
         }
     } else {
         $form = new $formClass();
         $controller->view->assign('form', $form);
         $viewToRender = $renderViews['form'];
         return $controller->render($viewToRender);
     }
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
 {
     /*
     if ( !$this->_forceRendering ) { 
     	// even if forced.enabled, don't build the page if the device is wiimc
     	if ( $this->helpers()->devices()->isWiimc() || ( !((bool) $this->config('forced.enabled', false)) && !$this->helpers()->devices()->isAndroid() )) return;
     }
     */
     if (!$this->isDefaultRenderer()) {
         return;
     }
     X_Debug::i("Plugin triggered");
     $request = $controller->getRequest();
     $urlHelper = $controller->getHelper('url');
     /* @var $view Zend_Controller_Action_Helper_ViewRenderer */
     $view = $controller->getHelper('viewRenderer');
     /* @var $layout Zend_Layout_Controller_Action_Helper_Layout */
     $layout = $controller->getHelper('layout');
     $view->setViewSuffix('mobile.phtml');
     $layout->getLayoutInstance()->setLayout('mobile', true);
     if ($request instanceof Zend_Controller_Request_Http) {
         if ($request->isXmlHttpRequest()) {
             $layout->getLayoutInstance()->disableLayout();
         }
     }
     try {
         $providerObj = X_VlcShares_Plugins::broker()->getPlugins($request->getParam('p', ''));
         $view->view->providerName = strtolower($providerObj->getId());
         if ($providerObj instanceof X_VlcShares_Plugins_ResolverDisplayableInterface) {
             // location in request obj are X_Env::encoded
             $view->view->location = $providerObj->resolveLocation(X_Env::decode($request->getParam('l', '')));
         }
         if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) {
             // location in request obj are X_Env::encoded
             $view->view->locationRaw = $providerObj->resolveLocation(X_Env::decode($request->getParam('l', '')));
             $view->view->parentLocation = $providerObj->getParentLocation(X_Env::decode($request->getParam('l', '')));
         }
     } catch (Exception $e) {
         //die('No provider');
         X_Debug::i('No provider O_o');
     }
     // set some vars for view
     $view->view->provider = $request->getParam('p', '');
     $view->view->items = $items;
     $view->view->actionName = $request->getActionName();
     $view->view->controllerName = $request->getControllerName();
     $view->view->coverflowEnabled = $this->config('coverflow.enabled', true);
 }
Пример #20
0
 public function doAction(Zend_Controller_Action $action)
 {
     $action->getHelper('layout')->disableLayout();
     $request = $action->getRequest();
     $dropFolderId = $this->_getParam('drop_folder_id');
     $partnerId = $this->_getParam('new_partner_id');
     $dropFolderType = $this->_getParam('new_drop_folder_type');
     $dropFolderForm = null;
     $action->view->formValid = false;
     try {
         if ($request->isPost()) {
             $partnerId = $this->_getParam('partnerId');
             $dropFolderType = $this->_getParam('type');
             $dropFolderForm = new Form_DropFolderConfigure($partnerId, $dropFolderType);
             $action->view->formValid = $this->processForm($dropFolderForm, $request->getPost(), $dropFolderId);
             if (!is_null($dropFolderId)) {
                 $dropFolder = $dropFolderForm->getObject("Kaltura_Client_DropFolder_Type_DropFolder", $request->getPost(), false, true);
                 $this->disableFileHandlerType($dropFolderForm, $dropFolder->fileHandlerType);
             }
         } else {
             if (!is_null($dropFolderId)) {
                 $client = Infra_ClientHelper::getClient();
                 $dropFolderPluginClient = Kaltura_Client_DropFolder_Plugin::get($client);
                 $dropFolder = $dropFolderPluginClient->dropFolder->get($dropFolderId);
                 $partnerId = $dropFolder->partnerId;
                 $dropFolderType = $dropFolder->type;
                 $dropFolderForm = new Form_DropFolderConfigure($partnerId, $dropFolderType);
                 $dropFolderForm->populateFromObject($dropFolder, false);
                 $this->disableFileHandlerType($dropFolderForm, $dropFolder->fileHandlerType);
             } else {
                 $dropFolderForm = new Form_DropFolderConfigure($partnerId, $dropFolderType);
                 $dropFolderForm->getElement('partnerId')->setValue($partnerId);
                 $settings = Zend_Registry::get('config')->dropFolder;
                 if ($dropFolderType === Kaltura_Client_DropFolder_Enum_DropFolderType::LOCAL) {
                     $dropFolderForm->getElement('fileSizeCheckInterval')->setValue($settings->fileSizeCheckIntervalLocal);
                 } else {
                     $dropFolderForm->getElement('fileSizeCheckInterval')->setValue($settings->fileSizeCheckIntervalRemote);
                 }
             }
         }
     } catch (Exception $e) {
         $action->view->formValid = false;
         KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString());
         $action->view->errMessage = $e->getMessage();
     }
     $action->view->form = $dropFolderForm;
 }
Пример #21
0
 public function doAction(Zend_Controller_Action $action)
 {
     $request = $action->getRequest();
     $action->view->errors = array();
     $formAction = $action->view->url(array('controller' => 'plugin', 'action' => 'AdminConsoleGalleryAction'), null, true);
     $action->view->searchEntriesForm = new Form_Batch_SearchEntries();
     $action->view->searchEntriesForm->setAction($formAction);
     $filter = $action->view->searchEntriesForm->getFilter($request->getParams());
     $action->view->searchEntriesForm->populate($request->getParams());
     $client = Infra_ClientHelper::getClient();
     if (!$client) {
         $action->view->errors[] = 'init client failed';
         return;
     }
     $partnerId = $request->getParam('partnerId');
     if ($partnerId > 0) {
         $paginatorAdapter = new Infra_FilterPaginator($client->media, "listAction", $partnerId, $filter);
         $paginator = new Infra_Paginator($paginatorAdapter, $request, null, 30);
         $paginator->setAvailablePageSizes(array(15, 30, 60, 100));
         $paginator->setAction($formAction);
         $action->view->paginator = $paginator;
         $action->view->playerPartnerId = $partnerId;
         $action->view->uiConf = null;
         $action->view->swfUrl = null;
         $adminConsolePlugin = Kaltura_Client_AdminConsole_Plugin::get($client);
         $uiConfId = Zend_Registry::get('config')->settings->defaultUiConfId;
         if ($uiConfId) {
             $action->view->uiConf = $adminConsolePlugin->uiConfAdmin->get($uiConfId);
         } else {
             $uiConfFilter = new Kaltura_Client_Type_UiConfFilter();
             $uiConfFilter->partnerIdIn = 0;
             $uiConfFilter->objTypeEqual = Kaltura_Client_Enum_UiConfObjType::PLAYER_V3;
             $uiConfFilter->orderBy = Kaltura_Client_Enum_UiConfOrderBy::CREATED_AT_DESC;
             $uiConfPager = new Kaltura_Client_Type_FilterPager();
             $uiConfPager->pageSize = 1;
             $uiConfList = $adminConsolePlugin->uiConfAdmin->listAction($uiConfFilter, $uiConfPager);
             /* @var $uiConfList Kaltura_Client_AdminConsole_Type_UiConfAdminListResponse */
             if (count($uiConfList->objects)) {
                 $action->view->uiConf = reset($uiConfList->objects);
             }
         }
         if ($action->view->uiConf) {
             $action->view->swfUrl = "/index.php/kwidget/wid/_{$partnerId}/cache_st/" . time() . "/uiconf_id/" . $action->view->uiConf->id;
         }
     }
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $request = $action->getRequest();
     $page = $this->_getParam('page', 1);
     $pageSize = $this->_getParam('pageSize', 10);
     $newForm = new Form_NewGenericProvider();
     // init filter
     $genericProviderFilter = new KalturaGenericDistributionProviderFilter();
     // get results and paginate
     $paginatorAdapter = new Kaltura_FilterPaginator("genericDistributionProvider", "listAction", null, $genericProviderFilter);
     $paginator = new Kaltura_Paginator($paginatorAdapter, $request);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($pageSize);
     // set view
     $action->view->newForm = $newForm;
     $action->view->paginator = $paginator;
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $request = $action->getRequest();
     $page = $this->_getParam('page', 1);
     $pageSize = $this->_getParam('pageSize', 10);
     $form = new Form_PartnerIdFilter();
     $form->populate($request->getParams());
     $newForm = new Form_NewDistributionProfile();
     $actionUrl = $action->view->url(array('controller' => 'plugin', 'action' => 'DistributionProfileListAction'), null, true);
     $form->setAction($actionUrl);
     // init filter
     $partnerFilter = $this->getPartnerFilterFromRequest($request);
     $client = Infra_ClientHelper::getClient();
     $contentDistributionPlugin = Kaltura_Client_ContentDistribution_Plugin::get($client);
     // get results and paginate
     $paginatorAdapter = new Infra_FilterPaginator($contentDistributionPlugin->distributionProfile, "listByPartner", null, $partnerFilter);
     $paginator = new Infra_Paginator($paginatorAdapter, $request);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($pageSize);
     $providers = array(Kaltura_Client_ContentDistribution_Enum_DistributionProviderType::GENERIC => 'Generic', Kaltura_Client_ContentDistribution_Enum_DistributionProviderType::SYNDICATION => 'Syndication');
     $genericProviders = array();
     $client = Infra_ClientHelper::getClient();
     $contentDistributionClientPlugin = Kaltura_Client_ContentDistribution_Plugin::get($client);
     $providersList = $contentDistributionClientPlugin->distributionProvider->listAction();
     if ($providersList) {
         foreach ($providersList->objects as $provider) {
             if ($provider->type == Kaltura_Client_ContentDistribution_Enum_DistributionProviderType::GENERIC) {
                 $genericProviders[$provider->id] = $provider->name;
             } else {
                 $providers[$provider->type] = $provider->name;
             }
         }
     }
     $newForm->setProviders($providers);
     $newPartnerElement = $newForm->getElement('newPartnerId');
     if ($newPartnerElement) {
         $newPartnerElement->setValue($partnerFilter->idIn);
     }
     // set view
     $action->view->form = $form;
     $action->view->newForm = $newForm;
     $action->view->paginator = $paginator;
     $action->view->providers = $providers;
     $action->view->genericProviders = $genericProviders;
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
 {
     if (!$this->isDefaultRenderer()) {
         // to be used, this
         return;
     }
     X_Debug::i("Plugin triggered");
     $request = $controller->getRequest();
     $urlHelper = $controller->getHelper('url');
     if ($request instanceof Zend_Controller_Request_Http) {
         if ($request->isXmlHttpRequest() || $request->getParam('webkit:json', false)) {
             $this->dispatchRequest($request, $items, $controller);
         } else {
             $this->showMainPage($request, $controller);
         }
     } else {
         X_Debug::f("Request isn't HTTP");
     }
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $form = new Form_NewFlavorParam();
     $action->view->form = $form;
     $request = $action->getRequest();
     if ($request->isPost()) {
         $params = $request->getParams();
         $client = Infra_ClientHelper::getClient();
         $fp = new Kaltura_Client_Type_FlavorParams();
         if ($form->isValid($params)) {
             $fp->name = $params['name'];
             $fp->systemName = $params['name'];
             $fp->isSystemDefault = Kaltura_Client_Enum_NullableBoolean::TRUE_VALUE;
             $fp->description = $params['description'];
             $fp->tags = $params['tags'];
             $fp->partnerId = $params['partner_id'];
             $fp->videoCodec = $params['video_codec'];
             $fp->audioCodec = $params['audio_codec'];
             $fp->format = $params['container_format'];
             $fp->videoBitrate = $params['video_bitrate'];
             $fp->audioBitrate = $params['audio_bitrate'];
             $fp->height = $params['video_height'];
             $fp->width = $params['video_width'];
             $fp->twoPass = $params['two_pass'];
             $fp->conversionEngines = '2,99,3';
             $fp->conversionEnginesExtraParams = strlen($params['extra_params']) > 0 ? $params['extra_params'] : '-flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq \'blurCplx^(1-qComp)\' -level 30 -async 2 -vsync 1 -threads 4 | -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 -keyint_min 20 -sc_threshold 40 -i_qfactor 0.71 -bt 100k -maxrate 400k -bufsize 1200k -rc_eq \'blurCplx^(1-qComp)\' -level 30 -async 2 -vsync 1 | -x264encopts qcomp=0.6:qpmin=10:qpmax=50:qpstep=4:frameref=1:bframes=0:threads=auto:level_idc=30:global_header:partitions=i4x4+p8x8+b8x8:trellis=1:me_range=16:keyint_min=20:scenecut=40:ipratio=0.71:ratetol=20:vbv-maxrate=400:vbv-bufsize=1200';
             try {
                 $systemPartnerPlugin = Kaltura_Client_SystemPartner_Plugin::get($client);
                 $filter = new Kaltura_Client_SystemPartner_Type_SystemPartnerFilter();
                 $partner = $systemPartnerPlugin->systemPartner->get($fp->partnerId);
                 $oldKs = $client->getKs();
                 $newKs = $client->generateSession($partner->adminSecret, "", Kaltura_Client_Enum_SessionType::ADMIN, $fp->partnerId, 86400, "");
                 $client->setKs($newKs);
                 $result = $client->flavorParams->add($fp);
                 $client->setKs($oldKs);
                 $action->view->resultString = 'Flavor named \'' . $result->name . '\' successfully created ID is: ' . $result->id;
             } catch (Exception $e) {
                 var_dump($e);
             }
         }
     }
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $action->getHelper('layout')->disableLayout();
     $request = $action->getRequest();
     $dropFolderId = $this->_getParam('drop_folder_id');
     $partnerId = $this->_getParam('new_partner_id');
     $dropFolderType = $this->_getParam('new_drop_folder_type');
     $dropFolderForm = null;
     $action->view->formValid = false;
     try {
         if ($request->isPost()) {
             $partnerId = $this->_getParam('partnerId');
             $dropFolderType = $this->_getParam('type');
             $dropFolderForm = new Form_DropFolderConfigure($partnerId, $dropFolderType);
             $action->view->formValid = $this->processForm($dropFolderForm, $request->getPost(), $dropFolderId);
         } else {
             if (!is_null($dropFolderId)) {
                 $client = Infra_ClientHelper::getClient();
                 $dropFolderPluginClient = Kaltura_Client_DropFolder_Plugin::get($client);
                 $dropFolder = $dropFolderPluginClient->dropFolder->get($dropFolderId);
                 $partnerId = $dropFolder->partnerId;
                 $dropFolderType = $dropFolder->type;
                 $dropFolderForm = new Form_DropFolderConfigure($partnerId, $dropFolderType);
                 $dropFolderForm->populateFromObject($dropFolder, false);
             } else {
                 $dropFolderForm = new Form_DropFolderConfigure($partnerId, $dropFolderType);
                 $dropFolderForm->getElement('partnerId')->setValue($partnerId);
             }
         }
     } catch (Exception $e) {
         $action->view->formValid = false;
         KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString());
         $action->view->errMessage = $e->getMessage();
     }
     $action->view->form = $dropFolderForm;
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $action->getHelper('layout')->disableLayout();
     $profileId = $this->_getParam('profileId');
     $editMode = false;
     if ($profileId != null) {
         $editMode = true;
     }
     $client = Infra_ClientHelper::getClient();
     $virusScanPlugin = Kaltura_Client_VirusScan_Plugin::get($client);
     $form = new Form_Partner_VirusScanConfiguration();
     $action->view->formValid = false;
     $request = $action->getRequest();
     if ($request->isPost()) {
         $formData = $request->getPost();
         if ($form->isValid($formData)) {
             $profile = $form->getObject("Kaltura_Client_VirusScan_Type_VirusScanProfile", $request->getPost(), false, true);
             $entryFilter = new Kaltura_Client_Type_BaseEntryFilter();
             $entryTypeArray = $request->getPost('entryTypeToFilter');
             if (is_array($entryTypeArray)) {
                 $entryFilter->typeIn = implode(',', $entryTypeArray);
             }
             $profile->entryFilter = $entryFilter;
             unset($profile->entryTypeToFilter);
             //update profile
             try {
                 if ($editMode) {
                     $virusScanPlugin->virusScanProfile->update($profileId, $profile);
                 } else {
                     Infra_ClientHelper::impersonate($profile->partnerId);
                     unset($profile->partnerId);
                     $virusScanPlugin->virusScanProfile->add($profile);
                     Infra_ClientHelper::unimpersonate();
                 }
                 $action->view->formValid = true;
             } catch (Exception $ex) {
                 $action->view->formValid = false;
                 $action->view->errMessage = $ex->getMessage();
             }
         } else {
             $form->populate($formData);
             $form->getElement('partnerId')->setValue($this->_getParam('new_partner_id'));
         }
     } else {
         $partnerId = $request->getParam('new_partner_id');
         if ($editMode || $partnerId) {
             //disable field if $editMode, so partnerId won't change
             $form->getElement('partnerId')->setAttrib('readonly', true);
             $form->getElement('partnerId')->setAttrib('class', 'readonly');
             $form->getElement('partnerId')->setValue($request->getParam('new_partner_id'));
             if ($profileId != null) {
                 $profile = $virusScanPlugin->virusScanProfile->get($profileId);
                 $form->populateFromObject($profile, false);
                 //setting multicheck drop down list values
                 $typesArr = array();
                 if (!empty($profile->entryFilter->typeEqual)) {
                     $typesArr[] = $profile->entryFilter->typeEqual;
                 } else {
                     if (!empty($profile->entryFilter->typeIn)) {
                         $typesArr = array_map('trim', explode(',', $profile->entryFilter->typeIn));
                     }
                 }
                 $form->getElement('entryTypeToFilter')->setValue($typesArr);
             }
         }
     }
     $action->view->form = $form;
 }
 public function doAction(Zend_Controller_Action $action)
 {
     $action->getHelper('layout')->disableLayout();
     $this->client = Infra_ClientHelper::getClient();
     $eventNotificationPlugin = Kaltura_Client_EventNotification_Plugin::get($this->client);
     $request = $action->getRequest();
     $partnerId = $this->_getParam('partner_id');
     if (!$partnerId) {
         $partnerId = 0;
     }
     $templateId = $this->_getParam('template_id');
     $cloneTemplateId = $this->_getParam('clone_template_id');
     $type = null;
     $eventNotificationTemplate = null;
     $action->view->errMessage = null;
     $action->view->form = '';
     $action->view->plugins = array();
     $form = null;
     try {
         Infra_ClientHelper::impersonate($partnerId);
         if ($cloneTemplateId) {
             if ($partnerId) {
                 $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->cloneAction($cloneTemplateId);
                 $templateId = $eventNotificationTemplate->id;
                 $type = $eventNotificationTemplate->type;
             } else {
                 $action->view->errMessage = "Partner ID must be defined.";
                 $templateId = null;
                 Infra_ClientHelper::unimpersonate();
                 return;
             }
         } elseif ($templateId) {
             $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->get($templateId);
             $type = $eventNotificationTemplate->type;
         } else {
             $type = $this->_getParam('type');
         }
         $form = KalturaPluginManager::loadObject('Form_EventNotificationTemplateConfiguration', $type, array($partnerId, $type));
         /* @var $form Form_EventNotificationTemplateConfiguration */
         $templateClass = KalturaPluginManager::getObjectClass('Kaltura_Client_EventNotification_Type_EventNotificationTemplate', $type);
         KalturaLog::debug("template class [{$templateClass}]");
         if (!$form || !$form instanceof Form_EventNotificationTemplateConfiguration) {
             $action->view->errMessage = "Template form not found for type [{$type}]";
             return;
         }
         $urlParams = array('controller' => 'plugin', 'action' => 'EventNotificationTemplateConfigureAction', 'clone_template_id' => null);
         if ($templateId) {
             $urlParams['template_id'] = $templateId;
         }
         $form->setAction($action->view->url($urlParams));
         if ($templateId) {
             if ($request->isPost()) {
                 if ($form->isValid($request->getPost())) {
                     $form->populate($request->getPost());
                     $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
                     $form->resetUnUpdatebleAttributes($eventNotificationTemplate);
                     $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->update($templateId, $eventNotificationTemplate);
                     $form->setAttrib('class', 'valid');
                     $action->view->formValid = true;
                 } else {
                     $form->populate($request->getPost());
                     $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
                 }
                 $form->finit($eventNotificationTemplate);
             } else {
                 $form->populateFromObject($eventNotificationTemplate);
             }
         } else {
             if ($request->isPost() && $form->isValid($request->getPost())) {
                 $form->populate($request->getPost());
                 $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
                 $eventNotificationTemplate->partnerId = null;
                 $eventNotificationTemplate = $eventNotificationPlugin->eventNotificationTemplate->add($eventNotificationTemplate);
                 $form->setAttrib('class', 'valid');
                 $action->view->formValid = true;
             } else {
                 $form->populate($request->getPost());
                 $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
             }
             $form->finit($eventNotificationTemplate);
         }
     } catch (Exception $e) {
         KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString());
         $action->view->errMessage = $e->getMessage();
         if ($form) {
             $form->populate($request->getPost());
             $eventNotificationTemplate = $form->getObject($templateClass, $request->getPost());
         }
     }
     Infra_ClientHelper::unimpersonate();
     $action->view->form = $form;
     $action->view->templateId = $templateId;
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaApplicationPartialView');
     KalturaLog::debug("plugin instances [" . count($pluginInstances) . "]");
     foreach ($pluginInstances as $pluginInstance) {
         $entryInvestigatePlugins = $pluginInstance->getApplicationPartialViews('plugin', get_class($this));
         if (!$entryInvestigatePlugins) {
             continue;
         }
         foreach ($entryInvestigatePlugins as $plugin) {
             /* @var $plugin Kaltura_View_Helper_PartialViewPlugin */
             $plugin->plug($action->view);
         }
     }
 }
Пример #29
0
 /**
  * Add the button BackToStream in controls page
  * 
  * @param X_Streamer_Engine $engine 
  * @param Zend_Controller_Action $controller the controller who handle the request
  * @return array
  */
 public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller)
 {
     // ignore if the streamer is not vlc
     if (!$engine instanceof X_Streamer_Engine_Vlc) {
         return;
     }
     X_Debug::i('Plugin triggered');
     $profileId = $controller->getRequest()->getParam($this->getId(), false);
     $urlHelper = $controller->getHelper('url');
     $outputLink = false;
     // i store the default link, so if i don't find the proper output
     // i will have a valid link for -go-to-stream- button
     //$output->setLink($this->config('default.link', "http://{$_SERVER['SERVER_ADDR']}:8081"));
     if ($profileId !== false) {
         $profile = new Application_Model_Profile();
         Application_Model_ProfilesMapper::i()->find($profileId, $profile);
         $outputLink = $profile->getLink();
     } else {
         // if store session is enabled, i try to get last output
         // method from store
         // else i fallback to best selection
         try {
             if ($this->config('store.session', true)) {
                 /* @var $cache X_VlcShares_Plugins_Helper_Cache */
                 $cache = $this->helpers()->helper('cache');
                 $outputLink = $cache->retrieveItem('profile::lastvlclink');
             }
         } catch (Exception $e) {
             // cache expired or cache disabled;
             X_Debug::i("Stored session not used");
         }
         if (!$outputLink) {
             X_Debug::i("Outputlink not found. Using best for this device");
             $profile = $this->getBest();
             $outputLink = $profile->getLink();
         }
     }
     $outputLink = self::prepareOutputLink($outputLink);
     $outputLink = str_replace(array('{%SERVER_IP%}', '{%SERVER_NAME%}'), array($_SERVER['SERVER_ADDR'], $_SERVER['HTTP_HOST']), $outputLink);
     $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_profiles_backstream'));
     $item->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setIcon('/images/icons/play.png')->setLink($outputLink);
     return new X_Page_ItemList_PItem(array($item));
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $list, Zend_Controller_Action $controller)
 {
     if (!$this->isDefaultRenderer()) {
         return;
     }
     X_Debug::i("Plugin triggered");
     $request = $controller->getRequest();
     $responseType = 'u:BrowseResponse';
     $num = count($list->getItems());
     if ($this->request['browseflag'] == 'BrowseMetadata') {
         $parentID = $this->_getParent($controller->getRequest());
         $item = new X_Page_Item_PItem('fake-item', "Container");
         $item->setLink(array_merge(array('controller' => $controller->getRequest()->getControllerName(), 'action' => $controller->getRequest()->getActionName()), $controller->getRequest()->getParams()));
         $item->setDescription("Fake description");
         $didl = X_Upnp::createMetaDIDL($item, $parentID, $num, $controller->getRequest()->getControllerName(), $controller->getRequest()->getActionName(), $controller->getRequest()->getParam('p', 'null'));
     } elseif ($this->request['browseflag'] == 'BrowseDirectChildren') {
         $parentID = $this->request['objectid'];
         $didl = X_Upnp::createDIDL($list->getItems(), $parentID, $num, $controller->getRequest()->getControllerName(), $controller->getRequest()->getActionName(), $controller->getRequest()->getParam('p', 'null'));
     }
     $xmlDIDL = $didl->saveXML();
     X_Debug::i("DIDL response: {$xmlDIDL}");
     // Build SOAP-XML reply from DIDL-XML and send it to upnp device
     $domSOAP = X_Upnp::createSOAPEnvelope($xmlDIDL, $num, $num, $responseType, $parentID);
     $soapXML = $domSOAP->saveXML();
     // turn off viewRenderer and Layout, add Content-Type and set response body
     $this->_render($soapXML, $controller);
 }