当前位置: 首页>>代码示例>>PHP>>正文


PHP entryFilter::categoryNamesToIds方法代码示例

本文整理汇总了PHP中entryFilter::categoryNamesToIds方法的典型用法代码示例。如果您正苦于以下问题:PHP entryFilter::categoryNamesToIds方法的具体用法?PHP entryFilter::categoryNamesToIds怎么用?PHP entryFilter::categoryNamesToIds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在entryFilter的用法示例。


在下文中一共展示了entryFilter::categoryNamesToIds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: applyFilterFields

 /**
  * 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]);
                     }
//.........这里部分代码省略.........
开发者ID:richhl,项目名称:kalturaCE,代码行数:101,代码来源:SolrEntryCriteria.php


注:本文中的entryFilter::categoryNamesToIds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。