protected function setExtraFilters(entryFilter &$fields_set) { $fields_set->set("_in_type", entryType::MEDIA_CLIP); //. "," . entryType::MIX ); if (!$fields_set->get("_order_by")) { $fields_set->set("_order_by", "-created_at"); } }
protected function setExtraFilters(entryFilter &$fields_set) { if (intval($fields_set->get("_in_moderation_status")) == moderation::MODERATION_STATUS_APPROVED) { $fields_set->set("_in_moderation_status", array(moderation::MODERATION_STATUS_APPROVED, moderation::MODERATION_STATUS_AUTO_APPROVED)); } $fields_set->set("_eq_type", entryType::PLAYLIST); $fields_set->set("_eq_status", entryStatus::READY); // make sure will display only $this->setP("use_filter_puser_id", "false"); // don't mind filtering according to the puser/kuser }
private static function addSchedulingToCriteria(Criteria $c, entryFilter $filter = null) { $min = 0; $max = kApiCache::getTime(); $allowNull = true; if ($filter) { if ($filter->is_set('_lteornull_start_date')) { $max = min($max, $filter->get('_lteornull_start_date')); $filter->unsetByName('_lteornull_start_date'); } if ($filter->is_set('_gteornull_start_date')) { $min = max($min, $filter->get('_gteornull_start_date')); $filter->unsetByName('_gteornull_start_date'); } if ($filter->is_set('_lte_start_date')) { $max = min($max, $filter->get('_lte_start_date')); $allowNull = false; $filter->unsetByName('_lte_start_date'); } if ($filter->is_set('_gte_start_date')) { $min = max($min, $filter->get('_gte_start_date')); $allowNull = false; $filter->unsetByName('_gte_start_date'); } } self::addSchedulingCriterion($c, entryPeer::START_DATE, $min, $max, $allowNull); $min = kApiCache::getTime(); $max = 0; $allowNull = true; if ($filter) { if ($filter->is_set('_lteornull_end_date')) { $max = min($max, $filter->get('_lteornull_end_date')); $filter->unsetByName('_lteornull_end_date'); } if ($filter->is_set('_gteornull_end_date')) { $min = max($min, $filter->get('_gteornull_end_date')); $filter->unsetByName('_gteornull_end_date'); } if ($filter->is_set('_lte_end_date')) { $max = min($max, $filter->get('_lte_end_date')); $allowNull = false; $filter->unsetByName('_lte_end_date'); } if ($filter->is_set('_gte_end_date')) { $min = max($min, $filter->get('_gte_end_date')); $allowNull = false; $filter->unsetByName('_gte_end_date'); } } self::addSchedulingCriterion($c, entryPeer::END_DATE, $min, $max, $allowNull); }
/** * Applies all filter fields and unset the handled fields * * @param baseObjectFilter $filter */ protected function applyFilterFields(entryFilter $filter) { if ($filter->get("_matchand_categories") !== null) { $filter->set("_matchand_categories_ids", $filter->categoryNamesToIds($filter->get("_matchand_categories"))); $filter->unsetByName('_matchand_categories'); } if ($filter->get("_matchor_categories") !== null) { $filter->set("_matchor_categories_ids", $filter->categoryNamesToIds($filter->get("_matchor_categories"))); $filter->unsetByName('_matchor_categories'); } 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->set("_lte_available_from", time()); $filter->set("_gteornull_end_date", time()); // schedule not finished $filter->set(baseObjectFilter::ORDER, "-available_from"); } if ($filter->get('_free_text')) { KalturaLog::debug('No advanced filter defined'); $freeTexts = $filter->get('_free_text'); $additionalConditions = array(); if (preg_match('/^"[^"]+"$/', $freeTexts)) { $additionalConditions[] = $freeText; // fixme - only name,tags,description ? } else { if (strpos($freeTexts, baseObjectFilter::IN_SEPARATOR) > 0) { str_replace(baseObjectFilter::AND_SEPARATOR, baseObjectFilter::IN_SEPARATOR, $freeTexts); $freeTextsArr = explode(baseObjectFilter::IN_SEPARATOR, $freeTexts); foreach ($freeTextsArr as $valIndex => $valValue) { if (!is_numeric($valValue) && strlen($valValue) <= 1) { unset($freeTextsArr[$valIndex]); } } foreach ($freeTextsArr as $freeText) { $additionalConditions[] = $freeText; // fixme - only name,tags,description ? } } else { $freeTextsArr = explode(baseObjectFilter::AND_SEPARATOR, $freeTexts); foreach ($freeTextsArr as $valIndex => $valValue) { if (!is_numeric($valValue) && strlen($valValue) <= 1) { unset($freeTextsArr[$valIndex]); } } $freeTextExpr = implode(" +", $freeTextsArr); $additionalConditions[] = $freeTextExpr; // fixme - only name,tags,description ? } } if (count($additionalConditions)) { $this->whereClause[] = '(' . implode(' ', $additionalConditions) . ')'; } } $filter->unsetByName('_free_text'); foreach ($filter->fields as $field => $val) { if (is_null($val) || !strlen($val)) { // KalturaLog::debug("Skip field[$field] value is null"); continue; } $fieldParts = explode(baseObjectFilter::FILTER_PREFIX, $field, 3); if (count($fieldParts) != 3) { KalturaLog::debug("Skip field[{$field}] has [" . count($fieldParts) . "] parts"); continue; } list($prefix, $operator, $fieldName) = $fieldParts; $fieldNamesArr = explode(baseObjectFilter::OR_SEPARATOR, $fieldName); if (count($fieldNamesArr) > 1) { $solrFieldNames = array(); foreach ($fieldNamesArr as $fieldName) { $solrField = self::getSolrFieldName($fieldName); $type = self::getSolrFieldType($solrField); $solrFieldNames[] = $solrField; } $solrField = '(' . implode(',', $solrFieldNames) . ')'; $vals = array_unique(explode(baseObjectFilter::OR_SEPARATOR, $val)); $val = implode(' ', $vals); } elseif (!$this->hasMatchableField($fieldName)) { KalturaLog::debug("Skip field[{$field}] has no matchable for name[{$fieldName}]"); continue; } else { $solrField = self::getSolrFieldName($fieldName); $type = self::getSolrFieldType($solrField); } $valStr = print_r($val, true); KalturaLog::debug("Attach field[{$fieldName}] as solr field[{$solrField}] of type [{$type}] and comparison[{$operator}] for value[{$valStr}]"); switch ($operator) { case baseObjectFilter::MULTI_LIKE_OR: case baseObjectFilter::MATCH_OR: $vals = explode(',', $val); foreach ($vals as $valIndex => $valValue) { if (!is_numeric($valValue) && strlen($valValue) <= 1) { unset($vals[$valIndex]); } } if (count($vals)) { $this->whereClause[] = "{$solrField}:(" . implode(" ", $vals) . ")"; $filter->unsetByName($field); } break; case baseObjectFilter::NOT_IN: $vals = array(); if (is_string($val)) { $vals = explode(',', $val); } elseif (is_array($val)) { $vals = $val; } foreach ($vals as $valIndex => $valValue) { if (!is_numeric($valValue) && strlen($valValue) <= 1) { unset($vals[$valIndex]); } } if (count($vals)) { $vals = array_slice($vals, 0, self::MAX_IN_VALUES); $this->whereClause[] = "-{$solrField}:(" . implode(" ", $vals) . ")"; $filter->unsetByName($field); } break; case baseObjectFilter::IN: $vals = array(); if (is_string($val)) { $vals = explode(',', $val); } elseif (is_array($val)) { $vals = $val; } foreach ($vals as $valIndex => $valValue) { if (!is_numeric($valValue) && strlen($valValue) <= 1) { unset($vals[$valIndex]); } } if (count($vals)) { $vals = array_slice($vals, 0, self::MAX_IN_VALUES); $this->whereClause[] = "{$solrField}:(" . implode(" ", $vals) . ")"; $filter->unsetByName($field); } break; case baseObjectFilter::EQ: if (is_numeric($val) || strlen($val) > 1) { $this->whereClause[] = "{$solrField}:{$val}"; // fixme - find exact match $filter->unsetByName($field); } break; case baseObjectFilter::MULTI_LIKE_AND: case baseObjectFilter::MATCH_AND: case baseObjectFilter::LIKE: $vals = explode(',', $val); foreach ($vals as $valIndex => $valValue) { if (!is_numeric($valValue) && strlen($valValue) <= 1) { unset($vals[$valIndex]); } } if (count($vals)) { $this->whereClause[] = "{$solrField}:(+" . implode(" +", $vals) . ")"; $filter->unsetByName($field); } break; default: KalturaLog::debug("Skip field[{$field}] has no opertaor[{$operator}]"); } } }