コード例 #1
0
 public function execute()
 {
     // keywords & page
     // keywords
     //		$keywords = $this->request->getRequestParameter ( "keywords" , "" );
     // page
     //		$page = $this->request->getRequestParameter ( "page" , "1" );
     $partner_id = $this->getP("partner_id", null);
     if (false && $partner_id) {
         $criteria_filter = entryPeer::getCriteriaFilter();
         $criteria = $criteria_filter->getFilter();
         $criteria->addAnd(entryPeer::PARTNER_ID, "(" . entryPeer::PARTNER_ID . "<100 OR " . entryPeer::PARTNER_ID . "={$partner_id} )", Criteria::CUSTOM);
         entryPeer::enable();
     }
     $page_size = 20;
     $entry_filter = new entryFilter();
     $entry_pager = new mySmartPager($this, "entry", $page_size);
     $act = new AJAX_getEntriesAction();
     $act->setIdList(NULL);
     $act->setSortAlias("ids");
     $act->setPublicOnly(true);
     $act->skip_count = false;
     $this->entry_results = $act->fetchPage($this, $entry_filter, $entry_pager);
     $this->getResponse()->setHttpHeader("Content-Type", "text/xml; charset=utf-8");
     $this->number_of_results = $entry_pager->getNumberOfResults();
     $this->number_of_pages = $entry_pager->getNumberOfPages();
 }
コード例 #2
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $entry_id = $this->getP("entry_id");
     $kshow_id = $this->getP("kshow_id");
     $show_entry_id = $this->getP("show_entry_id");
     // Make sure the request is for a ready roughcut
     $c = entryPeer::getCriteriaFilter()->getFilter();
     $c->addAnd(entryPeer::STATUS, entryStatus::READY, Criteria::EQUAL);
     list($kshow, $show_entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $show_entry_id);
     if ($error_obj) {
         $this->addError($error_obj);
         return;
     }
     $entry = entryPeer::retrieveByPK($entry_id);
     if (!$entry) {
         $this->addError(APIErrors::INVALID_ENTRY_ID, "entry", $entry_id);
         return;
     }
     $metadata = $kshow->getMetadata();
     $relevant_kshow_version = 1 + $kshow->getVersion();
     // the next metadata will be the first relevant version for this new entry
     $version_info = array();
     $version_info["KuserId"] = $puser_kuser->getKuserId();
     $version_info["PuserId"] = $puser_id;
     $version_info["ScreenName"] = $puser_kuser->getPuserName();
     $new_metadata = myMetadataUtils::addEntryToMetadata($metadata, $entry, $relevant_kshow_version, $version_info);
     $entry_modified = true;
     if ($new_metadata) {
         // TODO - add thumbnail only for entries that are worthy - check they are not moderated !
         $thumb_modified = myKshowUtils::updateThumbnail($kshow, $entry, false);
         if ($thumb_modified) {
             $new_metadata = myMetadataUtils::updateThumbUrlFromMetadata($new_metadata, $entry->getThumbnailUrl());
         }
         // it is very important to increment the version count because even if the entry is deferred
         // it will be added on the next version
         if (!$kshow->getHasRoughcut()) {
             // make sure the kshow now does have a roughcut
             $kshow->setHasRoughcut(true);
             $kshow->save();
         }
         $kshow->setMetadata($new_metadata, true);
     }
     $this->addMsg("entry", objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     $this->addMsg("kshow", objectWrapperBase::getWrapperClass($kshow, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     $this->addMsg("metadata", $new_metadata);
 }
コード例 #3
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $entry_id = $this->getP("entry_id");
     $kshow_id = $this->getP("kshow_id");
     // Make sure the request is for a ready roughcut
     $c = entryPeer::getCriteriaFilter()->getFilter();
     $c->addAnd(entryPeer::STATUS, entryStatus::READY, Criteria::EQUAL);
     list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id);
     if ($error_obj) {
         $this->addError($error_obj);
         return;
     }
     $version = $this->getP("version");
     // it's a path on the disk
     if (kString::beginsWith($version, ".")) {
         // someone is trying to hack in the system
         return sfView::ERROR;
     } elseif ($version == "-1") {
         $version = null;
     }
     // in case we're making a roughcut out of a regular invite, we start from scratch
     $entry_data_path = kFileSyncUtils::getLocalFilePathForKey($entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version));
     //replaced__getDataPath
     if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW || $entry_data_path === null) {
         $this->xml_content = "<xml></xml>";
         return;
     }
     $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
     $file_name = kFileSyncUtils::getReadyLocalFilePathForKey($sync_key, false);
     // fetch content of file from disk - it should hold the XML
     if (kString::endsWith($file_name, "xml")) {
         $xml_content = kFileSyncUtils::file_get_contents($sync_key, false, false);
         if (!$xml_content) {
             $xml_content = "<xml></xml>";
         }
         myMetadataUtils::updateEntryForPending($entry, $version, $xml_content);
         $this->addMsg("metadata", $xml_content);
     } else {
         $this->addError(APIErrors::INVALID_FILE_NAME, $file_name);
     }
 }
 public function getEntryMrssDoc(EntryDistribution $entryDistribution)
 {
     $entry = entryPeer::retrieveByPK($entryDistribution->getEntryId());
     // set the default criteria to use the current entry distribution partner id (it is restored later)
     // this is needed for related entries under kMetadataMrssManager which is using retrieveByPK without the correct partner id filter
     $oldEntryCriteria = entryPeer::getCriteriaFilter()->getFilter();
     entryPeer::setDefaultCriteriaFilter();
     entryPeer::addPartnerToCriteria($this->getPartnerId(), true);
     try {
         $mrss = null;
         $mrssParams = new kMrssParameters();
         if ($this->getItemXpathsToExtend()) {
             $mrssParams->setItemXpathsToExtend($this->getItemXpathsToExtend());
         }
         $mrss = kMrssManager::getEntryMrssXml($entry, $mrss, $mrssParams);
         $mrssStr = $mrss->asXML();
     } catch (Exception $e) {
         // restore the original criteria so it will not get stuck due to the exception
         entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
         throw $e;
     }
     // restore the original criteria
     entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
     $mrssObj = new DOMDocument();
     if (!$mrssObj->loadXML($mrssStr)) {
         throw new Exception('Entry mrss xml is not valid');
     }
     return $mrssObj;
 }
コード例 #5
0
ファイル: entryIndex.php プロジェクト: DBezemer/server
 public static function getDefaultCriteriaFilter()
 {
     return entryPeer::getCriteriaFilter();
 }
 /**
 	return array('status' => $status, 'message' => $message, 'objects' => $objects);
 		objects - array of
 				'thumb' 
 				'title'  
 				'description' 
 				'id' - unique id to be passed to getMediaInfo 
 
 	this service will first return the relevant kshows, then find the relevant roughcuts and finally fetch the entries
 */
 public function searchMedia($media_type, $searchText, $page, $pageSize, $authData = null, $extraData = null)
 {
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
     // this bellow will bypass the partner filter - at the end of the code the filter will return to be as was before
     $kshow_criteria = kshowPeer::getCriteriaFilter()->getFilter();
     $original_kshow_partner_to_filter = $kshow_criteria->get(kshowPeer::PARTNER_ID);
     $kshow_criteria->remove(kshowPeer::PARTNER_ID);
     $entry_criteria = entryPeer::getCriteriaFilter()->getFilter();
     $original_entry_partner_to_filter = $entry_criteria->get(entryPeer::PARTNER_ID);
     $entry_criteria->remove(entryPeer::PARTNER_ID);
     $page_size = $pageSize > self::MAX_PAGE_SIZE ? self::MAX_PAGE_SIZE : $pageSize;
     $status = "ok";
     $message = '';
     $kshow_filter = $this->getKshowFilter($extraData);
     $limit = $pageSize;
     $offset = $pageSize * ($page - 1);
     // $page starts from 1
     //		$keywords_array = mySearchUtils::getKeywordsFromStr ( $searchText );
     // TODO_ change mechanism !
     //$search_mechanism = self::KALTURA_SERVICE_CRITERIA_FROM_KSHOW;
     $search_mechanism = self::KALTURA_SERVICE_CRITERIA_FROM_ROUGHCUT;
     // TODO - optimize the first part of the entry_id search
     // cache once we know the kshow_ids / roughcuts - this will make paginating much faster
     $kshow_crit = new Criteria();
     $kshow_crit->clearSelectColumns()->clearOrderByColumns();
     $kshow_crit->addSelectColumn(kshowPeer::ID);
     $kshow_crit->addSelectColumn(kshowPeer::SHOW_ENTRY_ID);
     $kshow_crit->setLimit(self::$s_default_count_limit);
     $kshow_filter->addSearchMatchToCriteria($kshow_crit, $searchText, kshow::getSearchableColumnName());
     if ($search_mechanism == self::KALTURA_SERVICE_CRITERIA_FROM_KSHOW) {
         $kshow_crit->add(kshowPeer::ENTRIES, 1, criteria::GREATER_EQUAL);
     }
     $rs = kshowPeer::doSelectStmt($kshow_crit);
     $kshow_arr = array();
     $roughcut_arr = array();
     $res = $rs->fetchAll();
     foreach ($res as $record) {
         $kshow_arr[] = $record[0];
         $roughcut_arr[] = $record[1];
     }
     //		// old code from doSelectRs
     //		while($rs->next())
     //		{
     //			$kshow_arr[] = $rs->getString(1);
     //			$roughcut_arr[] = $rs->getString(2);
     //		}
     $crit = new Criteria();
     $crit->setOffset($offset);
     $crit->setLimit($limit);
     $crit->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
     $crit->add(entryPeer::MEDIA_TYPE, $media_type);
     if ($search_mechanism == self::KALTURA_SERVICE_CRITERIA_FROM_KSHOW) {
         $crit->add(entryPeer::KSHOW_ID, $kshow_arr, Criteria::IN);
         $entry_results = entryPeer::doSelect($crit);
     } elseif ($search_mechanism == self::KALTURA_SERVICE_CRITERIA_FROM_ROUGHCUT) {
         //			$entry_results  = roughcutEntryPeer::retrievByRoughcutIds ( $crit , $roughcut_arr , true );
         $entry_results = roughcutEntryPeer::retrievEntriesByRoughcutIds($crit, $roughcut_arr);
     }
     // after the query - return the filter to what it was before
     $entry_criteria->addAnd(entryPeer::PARTNER_ID, $original_entry_partner_to_filter);
     $kshow_criteria->addAnd(kshowPeer::PARTNER_ID, $original_kshow_partner_to_filter);
     $objects = array();
     // add thumbs when not image or video
     $should_add_thumbs = $media_type != entry::ENTRY_MEDIA_TYPE_AUDIO;
     foreach ($entry_results as $obj) {
         if ($search_mechanism == self::KALTURA_SERVICE_CRITERIA_FROM_KSHOW) {
             $entry = $obj;
         } else {
             //$entry = $obj->getEntry();
             $entry = $obj;
         }
         /* @var $entry entry */
         // use the id as the url - it will help using this entry id in addentry
         $object = array("id" => $entry->getId(), "url" => $entry->getDataUrl(), "tags" => $entry->getTags(), "title" => $entry->getName(), "description" => $entry->getTags(), "flash_playback_type" => $entry->getMediaTypeName());
         if ($should_add_thumbs) {
             $object["thumb"] = $entry->getThumbnailUrl();
         }
         $objects[] = $object;
     }
     return array('status' => $status, 'message' => $message, 'objects' => $objects, "needMediaInfo" => self::$NEED_MEDIA_INFO);
 }
コード例 #7
0
 public static function copyData($source_entry_id, entry $target)
 {
     // the source_entry can be from any partner - not only of the current context
     entryPeer::getCriteriaFilter()->disable();
     // TODO - should not be switched of - it sohuld work ok with the new ks/kn mechanism and only public entries should be copied
     $source_entry = entryPeer::retrieveByPK($source_entry_id);
     if (!$source_entry) {
         return false;
     }
     $exclude_fields = array("id", "comments", "total_rank", "views", "votes", "favorites", "conversion_profile_id", "access_control_id", "categories", "categories_ids", "start_date", "end_date");
     baseObjectUtils::fillObjectFromObject(entryPeer::getFieldNames(BasePeer::TYPE_FIELDNAME), $source_entry, $target, baseObjectUtils::CLONE_POLICY_PREFER_EXISTING, $exclude_fields);
     $wrapper = objectWrapperBase::getWrapperClass($target, objectWrapperBase::DETAIL_LEVEL_REGULAR);
     $target->setDimensions($source_entry->getWidth(), $source_entry->getHeight());
     $target->getCustomDataObj();
     //		$target->setLengthInMsecs( $source_entry->getLengthInMsecs() );
     //		$target->setMediaType( $source_entry->getMediaType() );
     //		$target->setTags ( $source_entry->getTags () );
     $sourceThumbKey = $source_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
     //replaced__getThumbnailPat
     $sourceDataKey = $source_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
     //replaced__getDataPath
     $sourceDataEditKey = $source_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA_EDIT);
     //replaced__getDataPathEdit
     //		$target->setThumbnail ( $source_thumbnail_path );
     //		$target->setData ( $source_data_path );
     $targetThumbKey = $target->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
     //replaced__getThumbnailPath
     $targetDataKey = $target->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
     //replaced__getDataPath
     $targetDataEditKey = $target->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA_EDIT);
     //replaced__getDataPathEdit
     $content = myContentStorage::getFSContentRootPath();
     //		echo "[$content] [$source_thumbnail_path]->[$target_thumbnail_path] [$source_data_path]->[$target_data_path]";
     if (kFileSyncUtils::file_exists($sourceDataKey, true)) {
         kFileSyncUtils::softCopy($sourceDataKey, $targetDataKey);
     }
     if (kFileSyncUtils::file_exists($sourceThumbKey, true)) {
         kFileSyncUtils::softCopy($sourceThumbKey, $targetThumbKey);
     }
     if (kFileSyncUtils::file_exists($sourceDataEditKey, true)) {
         kFileSyncUtils::softCopy($sourceDataEditKey, $targetDataEditKey);
     }
     // added by Tan-Tan 12/01/2010 to support falvors copy
     $sourceFlavorAssets = flavorAssetPeer::retrieveByEntryId($source_entry_id);
     foreach ($sourceFlavorAssets as $sourceFlavorAsset) {
         $sourceFlavorAsset->copyToEntry($target->getId(), $target->getPartnerId());
     }
     return true;
 }
コード例 #8
0
ファイル: kXslPathManager.php プロジェクト: DBezemer/server
 /**
  * @return string path value
  * @param entry $entry
  * @param string $xslStr
  */
 protected function getPathValue(entry $entry, $xslStr)
 {
     // set the default criteria to use the current entry distribution partner id (it is restored later)
     // this is needed for related entries under kMetadataMrssManager which is using retrieveByPK without the correct partner id filter
     $oldEntryCriteria = entryPeer::getCriteriaFilter()->getFilter();
     myPartnerUtils::resetPartnerFilter('entry');
     myPartnerUtils::addPartnerToCriteria('entry', $entry->getPartnerId(), true);
     $mrss = null;
     $mrssParams = new kMrssParameters();
     $mrssParams->setStatuses(array(flavorAsset::ASSET_STATUS_READY, flavorAsset::ASSET_STATUS_EXPORTING));
     $mrss = kMrssManager::getEntryMrssXml($entry, $mrss, $mrssParams);
     $mrssStr = $mrss->asXML();
     // restore the original criteria
     entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
     if (!$mrssStr) {
         KalturaLog::err('No MRSS returned for entry [' . $entry->getId() . ']');
         return null;
     }
     $mrssObj = new DOMDocument();
     if (!$mrssObj->loadXML($mrssStr)) {
         KalturaLog::err('Error loading MRSS XML object for entry [' . $entry->getId() . ']');
         return null;
     }
     $xslObj = new DOMDocument();
     $xslStr = trim($xslStr);
     if (!$xslObj->loadXML($xslStr)) {
         KalturaLog::err('Error loading XSL');
         return null;
     }
     $proc = new XSLTProcessor();
     $proc->registerPHPFunctions(kXml::getXslEnabledPhpFunctions());
     $proc->importStyleSheet($xslObj);
     $resultXmlObj = $proc->transformToDoc($mrssObj);
     if (!$resultXmlObj) {
         KalturaLog::err('Error transforming XML for entry id [' . $entry->getId() . ']');
         return null;
     }
     /* DEBUG logs
     		KalturaLog::log('entry mrss = '.$mrssStr);
     		KalturaLog::log('profile xslt = '.$xslStr);
     		*/
     KalturaLog::debug('Result XML: ' . $resultXmlObj->saveXML());
     $xpath = new DOMXPath($resultXmlObj);
     $fieldElement = $xpath->query("//path_value")->item(0);
     if (!$fieldElement) {
         KalturaLog::err('Cannot find element <path_value> in XML');
         return null;
     }
     $fieldValue = $fieldElement->nodeValue;
     return $fieldValue;
 }
コード例 #9
0
ファイル: SphinxEntryCriteria.php プロジェクト: AdiTal/server
 protected function applyFilterFields(baseObjectFilter $filter)
 {
     /* @var $filter entryFilter */
     if ($filter->is_set('_eq_redirect_from_entry_id')) {
         $partnerGroup = array(kCurrentContext::getCurrentPartnerId(), PartnerPeer::GLOBAL_PARTNER);
         $criteriaFilter = entryPeer::getCriteriaFilter();
         $defaultCriteria = $criteriaFilter->getFilter();
         $defaultCriteria->remove(entryPeer::PARTNER_ID);
         $defaultCriteria->add(entryPeer::PARTNER_ID, $partnerGroup, Criteria::IN);
         $origEntryId = $filter->get('_eq_redirect_from_entry_id');
         $origEntry = entryPeer::retrieveByPK($origEntryId);
         if (!empty($origEntry)) {
             if ($origEntry->getType() == entryType::LIVE_STREAM) {
                 // Set a relatively short expiry value in order to reduce the wait-time
                 // until the cache is refreshed and a redirection kicks-in.
                 kApiCache::setExpiry(kApiCache::REDIRECT_ENTRY_CACHE_EXPIRY);
             }
             // Get the id of the entry id that is being redirected from the original entry
             $redirectEntryId = $origEntry->getRedirectEntryId();
             if (is_null($redirectEntryId)) {
                 $filter->set('_eq_id', $origEntryId);
                 // Continue with original entry id
             } else {
                 // Get the redirected entry and check if it exists and is ready
                 $redirectedEntry = entryPeer::retrieveByPK($redirectEntryId);
                 if (!empty($redirectedEntry) && $redirectedEntry->getStatus() == entryStatus::READY) {
                     // Redirected entry is ready.
                     // Set it as the replacement of the original one
                     $filter->set('_eq_id', $redirectEntryId);
                 } else {
                     // Can't redirect? --> Fallback to the original entry
                     $filter->set('_eq_id', $origEntryId);
                 }
             }
         } else {
             throw new kCoreException("Invalid entry id [\"{$origEntryId}\"]", kCoreException::INVALID_ENTRY_ID, $origEntryId);
         }
         $filter->unsetByName('_eq_redirect_from_entry_id');
     }
     $categoriesAncestorParsed = null;
     $categories = $filter->get("_in_category_ancestor_id");
     if ($categories !== null) {
         //if the category exist or the category name is an empty string
         $categoriesAncestorParsed = $filter->categoryIdsToAllSubCategoriesIdsParsed($categories);
         if (!($categoriesAncestorParsed !== '' || $categories == '')) {
             $categoriesAncestorParsed = category::CATEGORY_ID_THAT_DOES_NOT_EXIST;
         }
     }
     $filter->unsetByName('_in_category_ancestor_id');
     $categories = $filter->get("_matchor_categories_ids");
     if ($categories !== null) {
         //if the category exist or the category name is an empty string
         if (is_null($categoriesAncestorParsed)) {
             $categoriesParsed = $filter->categoryIdsToIdsParsed($categories);
         } else {
             $categoriesParsed = $categoriesAncestorParsed;
         }
         if ($categoriesParsed !== '' || $categories == '') {
             $filter->set("_matchor_categories_ids", $categoriesParsed);
         } else {
             $filter->set("_matchor_categories_ids", category::CATEGORY_ID_THAT_DOES_NOT_EXIST);
         }
     } else {
         $filter->set("_matchor_categories_ids", $categoriesAncestorParsed);
     }
     $categories = $filter->get("_matchand_categories_ids");
     if ($categories !== null) {
         //if the category exist or the category name is an empty string
         $categoriesParsed = $filter->categoryIdsToIdsParsed($categories);
         if ($categoriesParsed !== '' || $categories == '') {
             $filter->set("_matchand_categories_ids", $categoriesParsed);
         } else {
             $filter->set("_matchand_categories_ids", category::CATEGORY_ID_THAT_DOES_NOT_EXIST);
         }
     }
     $categoriesIds = $filter->get("_notcontains_categories_ids");
     if ($categoriesIds !== null) {
         $categoriesParsed = $filter->categoryIdsToAllSubCategoriesIdsParsed($categoriesIds, CategoryEntryStatus::ACTIVE . ',' . CategoryEntryStatus::PENDING . ',' . CategoryEntryStatus::REJECTED);
         if ($categoriesParsed !== '' || $categoriesIds == '') {
             $filter->set("_notcontains_categories_ids", $categoriesParsed);
         } else {
             $filter->set("_notcontains_categories_ids", category::CATEGORY_ID_THAT_DOES_NOT_EXIST);
         }
     }
     $matchAndCats = $filter->get("_matchand_categories");
     if ($matchAndCats !== null) {
         //if the category exist or the category name is an empty string
         $categoriesParsed = $filter->categoryFullNamesToIdsParsed($matchAndCats, CategoryEntryStatus::ACTIVE);
         if ($categoriesParsed !== '' || $matchAndCats == '') {
             $filter->set("_matchand_categories_ids", $categoriesParsed);
         } else {
             $filter->set("_matchand_categories_ids", category::CATEGORY_ID_THAT_DOES_NOT_EXIST);
         }
         $filter->unsetByName('_matchand_categories');
     }
     $matchOrCats = $filter->get("_matchor_categories");
     if ($matchOrCats !== null) {
         //if the category exist or the category name is an empty string
         $categoriesParsed = $filter->categoryFullNamesToIdsParsed($matchOrCats, CategoryEntryStatus::ACTIVE);
         if ($categoriesParsed !== '' || $matchOrCats == '') {
             $filter->set("_matchor_categories_ids", $categoriesParsed);
         } else {
             $filter->set("_matchor_categories_ids", category::CATEGORY_ID_THAT_DOES_NOT_EXIST);
         }
         $filter->unsetByName('_matchor_categories');
     }
     $notContainsCats = $filter->get("_notcontains_categories");
     if ($notContainsCats !== null) {
         //if the category exist or the category name is an empty string
         $categoriesParsed = $filter->categoryFullNamesToIdsParsed($notContainsCats, CategoryEntryStatus::ACTIVE . ',' . CategoryEntryStatus::PENDING . ',' . CategoryEntryStatus::REJECTED);
         if ($categoriesParsed !== '' || $notContainsCats == '') {
             $filter->set("_notcontains_categories_ids", $categoriesParsed);
         } else {
             $filter->set("_notcontains_categories_ids", category::CATEGORY_ID_THAT_DOES_NOT_EXIST);
         }
         $filter->unsetByName('_notcontains_categories');
     }
     // match categories by full name
     $CatFullNameIn = $filter->get("_in_categories_full_name");
     if ($CatFullNameIn !== null) {
         //if the category exist or the category name is an empty string
         $categoriesParsed = $filter->categoryFullNamesToIdsParsed($CatFullNameIn, CategoryEntryStatus::ACTIVE);
         if ($categoriesParsed !== '' || $CatFullNameIn == '') {
             $filter->set("_matchor_categories_ids", $categoriesParsed);
         } else {
             $filter->set("_matchor_categories_ids", category::CATEGORY_ID_THAT_DOES_NOT_EXIST);
         }
         $filter->unsetByName('_in_categories_full_name');
     }
     if ($filter->is_set('_is_live')) {
         $this->addCondition(entryIndex::DYNAMIC_ATTRIBUTES . '.' . LiveEntry::IS_LIVE . ' = ' . ($filter->get('_is_live') == '1' ? '1' : '0'));
         $filter->unsetByName('_is_live');
     }
     if ($filter->is_set('_is_recorded_entry_id_empty')) {
         $fieldName = entryIndex::DYNAMIC_ATTRIBUTES . '.' . LiveEntry::RECORDED_ENTRY_ID;
         $this->addWhere("{$fieldName} " . ($filter->get('_is_recorded_entry_id_empty') ? "IS" : "IS NOT") . " NULL");
         $filter->unsetByName('_is_recorded_entry_id_empty');
     }
     $matchOrRoots = array();
     if ($filter->is_set('_eq_root_entry_id')) {
         $matchOrRoots[] = entry::ROOTS_FIELD_ENTRY_PREFIX . ' ' . $filter->get('_eq_root_entry_id');
         $filter->unsetByName('_eq_root_entry_id');
     }
     if ($filter->is_set('_in_root_entry_id')) {
         $roots = explode(baseObjectFilter::IN_SEPARATOR, $filter->get('_in_root_entry_id'));
         foreach ($roots as $root) {
             $matchOrRoots[] = entry::ROOTS_FIELD_ENTRY_PREFIX . " {$root}";
         }
         $filter->unsetByName('_in_root_entry_id');
     }
     //When setting parent entry ID we also set the root entry id so the entry should be indexed with the root entry prefix
     if ($filter->is_set('_eq_parent_entry_id')) {
         $matchOrRoots[] = entry::ROOTS_FIELD_PARENT_ENTRY_PREFIX . '_' . $filter->get('_eq_parent_entry_id');
         $filter->unsetByName('_eq_parent_entry_id');
     }
     if ($filter->is_set('_is_root')) {
         if ($filter->get('_is_root')) {
             $filter->set('_notin_roots', entry::ROOTS_FIELD_ENTRY_PREFIX);
         } else {
             $matchOrRoots[] = entry::ROOTS_FIELD_ENTRY_PREFIX;
         }
         $filter->unsetByName('_is_root');
     }
     if (count($matchOrRoots)) {
         $filter->set('_matchand_roots', $matchOrRoots);
     }
     //		if ($filter->get("_matchor_duration_type") !== null)
     //			$filter->set("_matchor_duration_type", $filter->durationTypesToIndexedStrings($filter->get("_matchor_duration_type")));
     if ($filter->get(baseObjectFilter::ORDER) === "recent" || $filter->get(baseObjectFilter::ORDER) === "-recent") {
         $filter->set("_lte_available_from", time());
         //$filter->set("_gteornull_end_date", time()); // schedule not finished
         $filter->set(baseObjectFilter::ORDER, "-available_from");
     }
     if ($filter->get(baseObjectFilter::ORDER) === "+recent") {
         $filter->set(baseObjectFilter::ORDER, "+available_from");
     }
     if ($filter->get(baseObjectFilter::ORDER) === "-first_broadcast") {
         $this->addOrderBy(entryIndex::DYNAMIC_ATTRIBUTES . '.' . LiveEntry::FIRST_BROADCAST, Criteria::DESC);
         $filter->set(baseObjectFilter::ORDER, null);
     }
     if ($filter->get(baseObjectFilter::ORDER) === "+first_broadcast") {
         $this->addOrderBy(entryIndex::DYNAMIC_ATTRIBUTES . '.' . LiveEntry::FIRST_BROADCAST, Criteria::ASC);
         $filter->set(baseObjectFilter::ORDER, null);
     }
     if ($filter->get('_free_text')) {
         $freeTexts = $filter->get('_free_text');
         KalturaLog::debug("Attach free text [{$freeTexts}]");
         $additionalConditions = array();
         $advancedSearch = $filter->getAdvancedSearch();
         if ($advancedSearch) {
             $additionalConditions = $advancedSearch->getFreeTextConditions($filter->getPartnerSearchScope(), $freeTexts);
         }
         $this->addFreeTextToMatchClauseByMatchFields($freeTexts, entryFilter::FREE_TEXT_FIELDS, $additionalConditions);
     }
     $filter->unsetByName('_free_text');
     return parent::applyFilterFields($filter);
 }
コード例 #10
0
ファイル: BaseentryPeer.php プロジェクト: DBezemer/server
 /**
  * the filterCriteria will filter out all the doSelect methods - ONLY if the filter is turned on.
  * IMPORTANT - the filter is turend on by default and when switched off - should be turned on again manually .
  * 
  * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  */
 protected static function attachCriteriaFilter(Criteria $criteria)
 {
     entryPeer::getCriteriaFilter()->applyFilter($criteria);
 }
コード例 #11
0
ファイル: entryPeer.php プロジェクト: richhl/kalturaCE
 public static function blockDeletedInCriteriaFilter()
 {
     $ecf = entryPeer::getCriteriaFilter();
     $ecf->getFilter()->addAnd(entryPeer::STATUS, entryStatus::DELETED, Criteria::NOT_EQUAL);
 }
コード例 #12
0
 protected function getFieldValuesXml(EntryDistribution $entryDistribution, $fieldName = null)
 {
     $entry = entryPeer::retrieveByPKNoFilter($entryDistribution->getEntryId());
     if (!$entry) {
         KalturaLog::err('Entry not found with ID [' . $entryDistribution->getEntryId() . ']');
         return null;
     }
     // set the default criteria to use the current entry distribution partner id (it is restored later)
     // this is needed for related entries under kMetadataMrssManager which is using retrieveByPK without the correct partner id filter
     $oldEntryCriteria = entryPeer::getCriteriaFilter()->getFilter();
     myPartnerUtils::resetPartnerFilter('entry');
     myPartnerUtils::addPartnerToCriteria('entry', $entryDistribution->getPartnerId(), true);
     try {
         $mrss = null;
         $mrssParams = new kMrssParameters();
         if ($this->getItemXpathsToExtend()) {
             $mrssParams->setItemXpathsToExtend($this->getItemXpathsToExtend());
         }
         $mrss = kMrssManager::getEntryMrssXml($entry, $mrss, $mrssParams);
         $mrssStr = $mrss->asXML();
     } catch (Exception $e) {
         // restore the original criteria so it will not get stuck due to the exception
         entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
         throw $e;
     }
     // restore the original criteria
     entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
     if (!$mrssStr) {
         KalturaLog::err('No MRSS returned for entry [' . $entry->getId() . ']');
         return null;
     }
     $mrssObj = new DOMDocument();
     if (!$mrssObj->loadXML($mrssStr)) {
         KalturaLog::err('Error loading MRSS XML object for entry [' . $entry->getId() . ']');
         return null;
     }
     $xslObj = new DOMDocument();
     $xslStr = $this->getFieldValuesXslt($entryDistribution, $fieldName);
     $xslStr = trim($xslStr);
     if (!$xslObj->loadXML($xslStr)) {
         KalturaLog::err('Error loading distribution profile XSLT for profile ID [' . $this->getId() . ']');
         return null;
     }
     $proc = new XSLTProcessor();
     $proc->registerPHPFunctions(kXml::getXslEnabledPhpFunctions());
     $proc->importStyleSheet($xslObj);
     $resultXml = $proc->transformToXml($mrssObj);
     //in order to keep the UTF-8 encoding we transformToXml http://www.php.net/manual/en/xsltprocessor.transformtodoc.php#69305
     $resultXmlObj = new DOMDocument();
     $resultXmlObj->loadXML($resultXml);
     if (!$resultXmlObj) {
         KalturaLog::err('Error transforming XML for distribution profile [' . $this->getId() . '] and entry id [' . $entry->getId() . ']');
         return null;
     }
     /* DEBUG logs
     		KalturaLog::log('entry mrss = '.$mrssStr);
     		KalturaLog::log('profile xslt = '.$xslStr);
     		*/
     KalturaLog::debug('Result XML: ' . $resultXmlObj->saveXML());
     return $resultXmlObj;
 }
 /**
  * @return criteriaFilter
  */
 protected function getDefaultCriteriaFilter()
 {
     return entryPeer::getCriteriaFilter();
 }
 /**
 	return array('status' => $status, 'message' => $message, 'objects' => $objects);
 		objects - array of
 				'thumb' 
 				'title'  
 				'description' 
 				'id' - unique id to be passed to getMediaInfo 
 */
 public function searchMedia($media_type, $searchText, $page, $pageSize, $authData = null, $extraData = null)
 {
     $page_size = $pageSize > self::MAX_PAGE_SIZE ? self::MAX_PAGE_SIZE : $pageSize;
     $status = "ok";
     $message = '';
     // this is a silly hack until we change the interface to work with an input container rather than the request
     // TODO - replace !
     $_REQUEST["keywords"] = $searchText;
     // TODO  - remove  -see the comment above the __construct() funciton
     $clzz = self::$s_clazz;
     //get_class ();
     $service = new $clzz();
     $entry_filter = $service->getEntryFilter($extraData);
     $map = array("page" => $page, "keywords" => $searchText);
     // this container will
     $generic_container = new myGenericContainer($map);
     $entry_pager = new mySmartPager($generic_container, "entry", $page_size);
     // this bellow will bypass the partner filter - at the end of the code the filter will return to be as was before
     // don't filter by partner
     $criteria = entryPeer::getCriteriaFilter()->getFilter();
     $original_partner_to_filter = $criteria->get(entryPeer::PARTNER_ID);
     $criteria->remove(entryPeer::PARTNER_ID);
     // filter: allow only entries of status READY !
     $criteria->addAnd(entryPeer::STATUS, entryStatus::READY);
     $act = new AJAX_getEntriesAction();
     $act->setIdList(NULL);
     $act->setSortAlias("ids");
     $act->skip_count = true;
     //		$kaltura_media_type = self::getKalturaMediaType ( $media_type );
     $act->setMediaType($media_type);
     $fetch = true;
     if ($authData != null) {
         list($kuser_id, $hash) = explode("I", $authData);
         $fetch = false;
         $hash_res = kString::verifyExpiryHash($kuser_id, self::AUTH_SALT, $hash, self::AUTH_INTERVAL);
         if (0 < $hash_res) {
             $fetch = true;
             $act->setOnlyForKuser($kuser_id);
         }
         if (!$fetch) {
             $status = "error";
             $message = "invalid authentication data";
         }
     } else {
         $act->setPublicOnly(true);
     }
     if ($fetch) {
         $entry_results = $act->fetchPage($generic_container, $entry_filter, $entry_pager);
     } else {
         $entry_results = array();
     }
     // after the query - return the filter to what it was before
     $criteria->addAnd(entryPeer::PARTNER_ID, $original_partner_to_filter);
     $number_of_results = $entry_pager->getNumberOfResults();
     $number_of_pages = $entry_pager->getNumberOfPages();
     $objects = array();
     // add thumbs when not image or video
     $should_add_thumbs = $media_type != entry::ENTRY_MEDIA_TYPE_AUDIO;
     foreach ($entry_results as $entry) {
         /* @var $entry entry */
         // use the id as the url - it will help using this entry id in addentry
         $object = array("id" => $entry->getId(), "url" => $entry->getDataUrl(), "tags" => $entry->getTags(), "title" => $entry->getName(), "description" => $entry->getDescription(), "flash_playback_type" => $entry->getMediaTypeName());
         if ($should_add_thumbs) {
             $object["thumb"] = $entry->getThumbnailUrl();
         }
         $objects[] = $object;
     }
     return array('status' => $status, 'message' => $message, 'objects' => $objects, "needMediaInfo" => self::$NEED_MEDIA_INFO);
 }
コード例 #15
0
 public function applyFilters()
 {
     $this->criteriasLeft = 0;
     KalturaLog::debug("Applies " . count($this->filters) . " filters");
     foreach ($this->filters as $index => $filter) {
         KalturaLog::debug("Applies filter {$index}");
         $this->applyFilter($filter);
     }
     // attach all default criteria from peer
     entryPeer::getCriteriaFilter()->applyFilter($this);
     // go over all criterions and try to move them to the solr
     foreach ($this->getMap() as $field => $criterion) {
         if (!$criterion instanceof SolrEntryCriterion) {
             KalturaLog::debug("Criterion [" . $criterion->getColumn() . "] is not solr criteria");
             $this->criteriasLeft++;
             continue;
         }
         if ($criterion->apply($this->whereClause)) {
             KalturaLog::debug("Criterion [" . $criterion->getColumn() . "] attached");
             $this->keyToRemove[] = $field;
         } else {
             KalturaLog::debug("Criterion [" . $criterion->getColumn() . "] failed");
             $this->criteriasLeft++;
         }
     }
     KalturaLog::debug("Applied " . count($this->whereClause) . " matches, " . count($this->whereClause) . " clauses, " . count($this->keyToRemove) . " keys removed, {$this->criteriasLeft} keys left");
     $wheres = '';
     if (count($this->whereClause)) {
         $wheres = "";
         foreach ($this->whereClause as $where) {
             $c = @$where[0];
             $wheres .= ($c == "-" || $c == "+" ? " " : " +") . $where;
         }
     }
     $orderBy = '';
     $orderByColumns = $this->getOrderByColumns();
     $orderByColumns = array_unique($orderByColumns);
     $setLimit = true;
     if (count($orderByColumns)) {
         $replace = self::$solrOrderFields;
         $search = array_keys($replace);
         $orders = array();
         foreach ($orderByColumns as $orderByColumn) {
             $arr = explode(' ', $orderByColumn);
             $orderField = $arr[0];
             if (isset($replace[$orderField])) {
                 KalturaLog::debug("Add sort field[{$orderField}] copy from [{$orderByColumn}]");
                 $orders[] = str_replace($search, $replace, $orderByColumn);
             } else {
                 KalturaLog::debug("Skip sort field[{$orderField}] from [{$orderByColumn}] limit won't be used in solr query");
                 $setLimit = false;
             }
         }
         if (count($orders)) {
             $orderBy = 'sort=' . implode(',', $orders);
         }
     }
     $limit = self::SOLR_MAX_RECORDS;
     if ($this->criteriasLeft) {
         $setLimit = false;
     }
     $offset = 0;
     if ($setLimit && $this->getLimit()) {
         $limit = $this->getLimit();
         if ($this->getOffset()) {
             $offset = $this->getOffset();
         }
     }
     $query = "{$wheres} {$orderBy}";
     echo $query . "\n";
     die;
     $solr = kSolrSearchManager::createSolrService();
     $response = $solr->search($query, $offset, $limit);
     if (!$response) {
         KalturaLog::err("Invalid solr query [{$sql}]");
         return;
     }
     $response = json_decode($response);
     $response = $response['response'];
     $docs = $response['docs'];
     $ids = $array();
     foreach ($docs as $doc) {
         $ids[] = $doc["id"];
     }
     KalturaLog::debug("Found " . count($ids) . " ids");
     foreach ($this->keyToRemove as $key) {
         KalturaLog::debug("Removing key [{$key}] from criteria");
         $this->remove($key);
     }
     $this->addAnd(entryPeer::ID, $ids, Criteria::IN);
     $this->recordsCount = 0;
     if ($setLimit) {
         $this->recordsCount = $response['numFound'];
     } else {
         $c = clone $this;
         $c->setLimit(null);
         $c->setOffset(null);
         $this->recordsCount = entryPeer::doCount($c);
     }
 }