Пример #1
0
 public static function toQueryString(entry $playlist, $should_append_filter_to_url = false)
 {
     $query = "playlist_id={$playlist->getId()}";
     if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) {
         return $query;
     }
     if (!$should_append_filter_to_url) {
         return $query;
     }
     $xml = $playlist->getDataContent();
     list($total_results, $list_of_filters) = self::getPlaylistFilterListStruct($xml);
     $entry_filters = array();
     $partner_id = $playlist->getPartnerId();
     // add ks=_KS_ for the playlist to replace it before hitting the executePlaylist
     $query .= "&fp=f";
     // make sure the filter prefix is short
     if (!$list_of_filters) {
         return $query;
     }
     $i = 1;
     // the extra_filter is 1-based
     foreach ($list_of_filters as $entry_filter_xml) {
         $prefix = "f{$i}_";
         // 	in general this service can fetch entries from kaltura networks.
         // for each filter we should decide if thie assumption is true...
         $allow_partner_only = true;
         // compile all the filters - only then execute them if not yet reached the total_results
         // TODO - optimize - maybe create them only when needed. - For now it's safer to compile all even if not needed.
         $entry_filter = new entryFilter();
         // add the desired prefix "_" because the XML is not expected to have it while the entryFilter class expects it
         $entry_filter->fillObjectFromXml($entry_filter_xml, "_");
         // make sure there is alway a limit for each filter - if not an explicit one - the system limit should be used
         if ($entry_filter->getLimit() == null || $entry_filter->getLimit() < 1) {
             $entry_filter->setLimit(self::TOTAL_RESULTS);
         }
         $entry_filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
         self::updateEntryFilter($entry_filter, $partner_id);
         //$entry_filters[] = $entry_filter;
         $fields = $entry_filter->fields;
         foreach ($fields as $field => $value) {
             if ($value) {
                 $query .= "&" . $prefix . $field . "=" . $value;
             }
         }
         $i++;
     }
     return $query;
 }