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;
 }
示例#2
0
 /**
  * Retrieve a list of all available versions by object type
  * 
  * @action getAvailableTypes
  * @return KalturaUiConfTypeInfoArray
  */
 function getAvailableTypesAction()
 {
     $flashPath = myContentStorage::getFSContentRootPath() . myContentStorage::getFSFlashRootPath();
     $flashPath = realpath($flashPath);
     $uiConf = new uiConf();
     $dirs = $uiConf->getDirectoryMap();
     $swfNames = $uiConf->getSwfNames();
     $typesInfoArray = new KalturaUiConfTypeInfoArray();
     foreach ($dirs as $objType => $dir) {
         $typesInfo = new KalturaUiConfTypeInfo();
         $typesInfo->type = $objType;
         $typesInfo->directory = $dir;
         $typesInfo->filename = isset($swfNames[$objType]) ? $swfNames[$objType] : '';
         $versions = array();
         $path = $flashPath . '/' . $dir . '/';
         $path = realpath($path);
         $files = scandir($path);
         foreach ($files as $file) {
             if (is_dir(realpath($path . '/' . $file)) && strpos($file, 'v') === 0) {
                 $versions[] = $file;
             }
         }
         rsort($versions);
         $versionsObjectArray = new KalturaStringArray();
         foreach ($versions as $version) {
             $versionString = new KalturaString();
             $versionString->value = $version;
             $versionsObjectArray[] = $versionString;
         }
         $typesInfo->versions = $versionsObjectArray;
         $typesInfoArray[] = $typesInfo;
     }
     return $typesInfoArray;
 }