Exemplo n.º 1
0
 /**
  *
  * Populate the uiconf from the config
  * @param Zend_Config_Ini $widget
  * @param string $baseSwfUrl
  * @param string $swfName
  * @param int $objType
  * @param bool $disableUrlHashing
  */
 public static function populateUiconfFromConfig($widget, $baseSwfUrl, $swfName, $objType, $disableUrlHashing)
 {
     $uiconf = new uiConf();
     if ($widget->conf_file) {
         $confFileContents = uiConfDeployment::readConfFileFromPath($widget->conf_file);
         if (!$confFileContents) {
             KalturaLog::debug("Unable to read xml file from: {$widget->conf_file}");
         }
         if ($disableUrlHashing) {
             $confFileContents = str_replace('<Plugin id="kalturaMix"', '<Plugin id="kalturaMix" disableUrlHashing="true" ', $confFileContents);
         }
         $uiconf->setConfFile($confFileContents);
     }
     if ($widget->config) {
         $uiconf->setConfig(@$widget->config);
     } else {
         if ($widget->config_file) {
             $configFileContents = uiConfDeployment::readConfFileFromPath($widget->config_file);
             if (!$configFileContents) {
                 KalturaLog::debug("Unable to read json file from: {$widget->config_file}");
             }
             $uiconf->setConfig($configFileContents);
         }
     }
     if ($uiconf->getConfFile() === FALSE && $uiconf->getConfig() === FALSE) {
         return FALSE;
         // conf file or config is a must, features is not.
     }
     if (isset($widget->features)) {
         $uiconf->setConfFileFeatures(uiConfDeployment::readConfFileFromPath($widget->features));
     }
     if ($uiconf->getConfFileFeatures() === FALSE) {
         KalturaLog::debug("missing features conf file for uiconf {$widget->name}");
         // conf file is a must, features is not.
     }
     //Set values to the ui conf
     $uiconf->setPartnerId(uiConfDeployment::$partnerId);
     $uiconf->setSubpId(uiConfDeployment::$subPartnerId);
     $uiconf->setCreationMode(uiConfDeployment::$creationMode);
     $uiconf->setUseCdn(uiConfDeployment::$useCdn);
     $uiconf->setObjType($objType);
     $uiconf->setName($widget->name);
     $uiconf->setSwfUrl($baseSwfUrl . $widget->version . '/' . $swfName);
     if ($widget->html5_version) {
         $uiconf->setHtml5Url("/html5/html5lib/" . $widget->html5_version . "/mwEmbedLoader.php");
     }
     $uiconf->setTags(uiConfDeployment::$defaultTags . ', ' . uiConfDeployment::$baseTag . '_' . $widget->usage);
     $uiconf->setWidth(@$widget->width);
     $uiconf->setHeight(@$widget->height);
     $uiconf->setConfVars(@$widget->conf_vars);
     $uiconf->setDisplayInSearch(mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK);
     return $uiconf;
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     //myDbHelper::DB_HELPER_CONN_PROPEL2
     $this->saved = false;
     $uiConfId = $this->getRequestParameter("id");
     if ($uiConfId) {
         $uiConf = uiConfPeer::retrieveByPK($uiConfId);
     } else {
         $uiConf = new uiConf();
     }
     if ($this->getRequest()->getMethodName() == "POST") {
         $uiConf->setPartnerId($this->getRequestParameter("partnerId"));
         $uiConf->setSubpId($uiConf->getPartnerId() * 100);
         $uiConf->setObjType($this->getRequestParameter("type"));
         $uiConf->setName($this->getRequestParameter("name"));
         $uiConf->setWidth($this->getRequestParameter("width"));
         $uiConf->setHeight($this->getRequestParameter("height"));
         $uiConf->setCreationMode($this->getRequestParameter("creationMode"));
         $uiConf->setSwfUrl($this->getRequestParameter("swfUrl"));
         $uiConf->setConfVars($this->getRequestParameter("confVars"));
         $useCdn = $this->getRequestParameter("useCdn");
         $uiConf->setUseCdn($useCdn === "1" ? true : false);
         $uiConf->setDisplayInSearch($this->getRequestParameter("displayInSearch"));
         $uiConf->setConfVars($this->getRequestParameter("confVars"));
         $uiConf->setTags($this->getRequestParameter("tags"));
         /* files: */
         if ($uiConf->getCreationMode() != uiConf::UI_CONF_CREATION_MODE_MANUAL) {
             $confFile = $this->getRequestParameter("uiconf_confFile");
             $confFileFeatures = $this->getRequestParameter("uiconf_confFileFeatures");
             if ($uiConf->getConfFile() != $confFile || $uiConf->getConfFileFeatures() != $confFileFeatures) {
                 $uiConf->setConfFile($confFile);
                 $uiConf->setConfFileFeatures($confFileFeatures);
             }
         }
         $uiConf->save();
         $this->saved = true;
     }
     // so script won't die when uiconf is missing
     if (!$uiConf) {
         $uiConf = new uiConf();
     }
     $partner = PartnerPeer::retrieveByPK($uiConf->getPartnerId());
     $types = $uiConf->getUiConfTypeMap();
     $c = new Criteria();
     $c->add(widgetPeer::UI_CONF_ID, $uiConf->getId());
     $c->setLimit(1000);
     $widgets = widgetPeer::doSelect($c);
     $widgetsPerPartner = array();
     $this->tooMuchWidgets = false;
     if (count($widgets) == 1000) {
         $this->tooMuchWidgets = true;
     } else {
         if ($widgets) {
             foreach ($widgets as $widget) {
                 if (!array_key_exists($widget->getPartnerId(), $widgetsPerPartner)) {
                     $widgetsPerPartner[$widget->getPartnerId()] = 0;
                 }
                 $widgetsPerPartner[$widget->getPartnerId()]++;
             }
         }
     }
     // find the FileSync
     $fileSyncs = array();
     $fileSyncs[] = array("key" => $uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA));
     $fileSyncs[] = array("key" => $uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES));
     foreach ($fileSyncs as &$fileSync) {
         $fileSync["fileSyncs"] = FileSyncPeer::retrieveAllByFileSyncKey($fileSync["key"]);
     }
     $this->fileSyncs = $fileSyncs;
     $this->widgetsPerPartner = $widgetsPerPartner;
     $this->directoryMap = $uiConf->getDirectoryMap();
     $this->swfNames = $uiConf->getSwfNames();
     $this->types = $types;
     $this->uiConf = $uiConf;
     $this->partner = $partner;
 }
Exemplo n.º 3
0
 public static function populateUiconfFromConfig($confConfigObj, $baseSwfUrl, $swfName, $objType, $disableUrlHashing)
 {
     global $defaultTags, $baseTag, $confObj, $kcw_for_editors, $kdp_for_studio;
     $uiconf = new uiConf();
     $confFileContents = uiConfDeployment::readConfFileFromPath($confConfigObj->conf_file);
     if ($disableUrlHashing) {
         $confFileContents = str_replace('<Plugin id="kalturaMix"', '<Plugin id="kalturaMix" disableUrlHashing="true" ', $confFileContents);
     }
     $uiconf->setConfFile($confFileContents);
     if ($uiconf->getConfFile() === FALSE) {
         return FALSE;
         // conf file is a must, features is not.
     }
     $replace_tag = '';
     if ($objType == uiConf::UI_CONF_TYPE_ADVANCED_EDITOR) {
         $replace_tag = 'uIConfigId';
     }
     if ($objType == uiConf::UI_CONF_TYPE_EDITOR) {
         $replace_tag = 'UIConfigId';
     }
     if ($replace_tag) {
         if (isset($confConfigObj->kcw_identifier) && isset($kcw_for_editors[$confConfigObj->kcw_identifier])) {
             $pattern = '/<' . $replace_tag . '>(.*)<\\/' . $replace_tag . '>/';
             $replacement = "<{$replace_tag}>{$kcw_for_editors[$confConfigObj->kcw_identifier]}</{$replace_tag}>";
             $uiconf->setConfFile(preg_replace($pattern, $replacement, $uiconf->getConfFile()));
         }
     }
     if (isset($confConfigObj->usage) && $confConfigObj->usage == 'templates') {
         foreach ($kdp_for_studio as $identifier => $confId) {
             $uiconf->setConfFile(str_replace('@@' . $identifier . '@@', $confId, $uiconf->getConfFile()));
         }
     }
     $uiconf->setConfFileFeatures(uiConfDeployment::readConfFileFromPath($confConfigObj->conf_file, true));
     if ($uiconf->getConfFileFeatures() === FALSE) {
         echo "missing features conf file for uiconf {$confConfigObj->name}" . PHP_EOL;
     }
     // conf file is a must, features is not.
     $uiconf->setPartnerId(0);
     $uiconf->setSubpId(0);
     $uiconf->setCreationMode(3);
     $uiconf->setUseCdn(1);
     $uiconf->setObjType($objType);
     $uiconf->setName($confConfigObj->name);
     $uiconf->setSwfUrl($baseSwfUrl . $confConfigObj->version . '/' . $swfName);
     $uiconf->setTags($defaultTags . ', ' . $baseTag . '_' . $confConfigObj->usage);
     $uiconf->setWidth(@$confConfigObj->width);
     $uiconf->setHeight(@$confConfigObj->height);
     $uiconf->setConfVars(@$confConfigObj->conf_vars);
     $uiconf->setDisplayInSearch(mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK);
     return $uiconf;
 }