public function save(PropelPDO $con = null) { myPartnerUtils::setPartnerIdForObj($this); mySearchUtils::setDisplayInSearch($this); if (!$this->getIsAdmin()) { $this->setIsAdmin(false); } return parent::save($con); }
public function execute() { // for search - use the alternative connection myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; if (!myResponseUtils::hasPageExpired($this->getContext()->getResponse())) { return sfView::NONE; } $filter = $this->getFiler(); // new kuserFilter (); $mode = @$_REQUEST["mode"]; $page_size = $mode == "ALL" ? self::PAGE_SIZE : 2 * self::PAGE_SIZE; $my_pager = new mySmartPager($this, $this->getPagerName(), $page_size); $featured = ""; $id_list = mySearchUtils::getIdList($mode, $featured); $this->setIdList($id_list); $this->fetchPage($this, $filter, $my_pager); // cache the result // TODO - make this work !! //$this->getResponse()->addCacheControlHttpHeader('max_age=60'); myResponseUtils::setCacheHeaders($this->context->getResponse(), time(), self::EXPIRY_IN_SECONDS); }
public function getSearchText() { $displayInSearch = $this->getDisplayInSearch(); $words = ""; $fields_to_use = $this->getColumnNames(); foreach ($fields_to_use as $field) { $field_str = $this->getByName($field, BasePeer::TYPE_FIELDNAME); $words .= " " . $field_str; } $extra_invisible_data = null; $extra_invisible_data = "_MEDIA_TYPE_" . $this->getMediaType(); $type = $this->getType(); // add the SEARCH_ENTRY_TYPE_RC to the words if ($type == entryType::MIX) { $extra_invisible_data .= " " . mySearchUtils::SEARCH_ENTRY_TYPE_RC; } $prepared_text = mySearchUtils::prepareSearchText($words); $partner_id = $this->getPartnerId(); // if res == 1 - only for partner , if == 2 - also for kaltura network return mySearchUtils::addPartner($partner_id, $prepared_text, $displayInSearch, $extra_invisible_data); }
public function save(PropelPDO $con = null) { $is_new = false; if ($this->isNew()) { $is_new = true; $this->setId(self::calculateId()); if ($this->getName() != self::DUMMY_KSHOW_NAME) { myStatisticsMgr::addKshow($this); } } myPartnerUtils::setPartnerIdForObj($this); mySearchUtils::setDisplayInSearch($this); $res = parent::save($con); if ($is_new) { $obj = kshowPeer::retrieveByPk($this->getId()); $this->setIntId($obj->getIntId()); } return $res; }
/** * Will be used for the KCW's search - this is slightly different * * @param Criteria $criteria * @param array $keys_to_search * @param array $field_names */ public function addSearchMatchToCriteria($criteria, $keys_to_search, $field_names) { $operator = self::MATCH_OR; // accumulate all the $keys_to_search for the specific filed_names $columns = array(); // in case there is only one field_name not in an array - place it in an array only to make it easy for the next step if (!is_array($field_names)) { $field_names = array($field_names); } foreach ($field_names as $field_name) { $columns[] = $this->getRealFieldNameFromPeer($field_name); } $match_str = implode(",", $columns); $against_str = self::formatMySqlAgainst($keys_to_search, $operator, ",", self::MATCH_AND); // depending on the partner_search_scope - alter the against_str if (self::MATCH_KALTURA_NETWORK_AND_PRIVATE == $this->partner_search_scope) { // add nothing the the match } elseif ($this->partner_search_scope == null) { // the kaltura_netrowk keyword is mandatory ! // - find all the NOT partner only //$against_str = "+" . mySearchUtils::getKalturaNetworkKeyword() . " " . $against_str; $against_str = "-" . mySearchUtils::getPartnerOnlyKeyword() . " " . "-" . mySearchUtils::getPartnerNoneKeyword() . " " . $against_str; } else { $against_str = "+" . mySearchUtils::getPartnerKeyword($this->partner_search_scope) . " " . $against_str; } if (trim($against_str)) { // if nothing to add - don't add // the string to search is quoted by double-quotes $match_against_str = "MATCH (" . $match_str . ") AGAINST ('" . $against_str . "' IN BOOLEAN MODE )"; $accumulated_match_criterion = $criteria->getNewCriterion($columns[0], $match_against_str, Criteria::CUSTOM); $criteria->addAsColumn("_score", $match_against_str); $criteria->addAnd($accumulated_match_criterion); } }
public function getSearchText() { return mySearchUtils::removePartner(parent::getSearchText()); }
public function syncCategories() { if (!$this->is_categories_modified) { return; } if ($this->categories != null && $this->categories !== "") { $newCats = explode(self::ENTRY_CATEGORY_SEPARATOR, $this->categories); } else { $newCats = array(); } if ($this->old_categories !== null && $this->old_categories !== "") { $oldCats = explode(self::ENTRY_CATEGORY_SEPARATOR, $this->old_categories); } else { $oldCats = array(); } $allIds = array(); $allIdsWithParents = array(); $addedCats = array(); $removedCats = array(); $remainingCats = array(); foreach ($oldCats as $cat) { if (array_search($cat, $newCats) === false) { $removedCats[] = $cat; } } foreach ($newCats as $cat) { if (array_search($cat, $oldCats) === false) { $addedCats[] = $cat; } else { $remainingCats[] = $cat; } } foreach ($remainingCats as $cat) { $category = categoryPeer::getByFullNameExactMatch($cat); if ($category) { $allIds[] = $category->getId(); $allIdsWithParents[] = $category->getId(); $allIdsWithParents = array_merge($allIdsWithParents, $category->getAllParentsIds()); } } $alreadyAddedCatIds = $allIdsWithParents; foreach ($addedCats as $cat) { $category = categoryPeer::getByFullNameExactMatch($cat); if (!$category) { $category = category::createByPartnerAndFullName($this->getPartnerId(), $cat); } $category->incrementEntriesCount(1, $alreadyAddedCatIds); $allIds[] = $category->getId(); $alreadyAddedCatIds[] = $category->getId(); $alreadyAddedCatIds = array_merge($alreadyAddedCatIds, $category->getAllParentsIds()); } $alreadyRemovedCatIds = $allIdsWithParents; foreach ($removedCats as $cat) { $category = categoryPeer::getByFullNameExactMatch($cat); if ($category) { $category->decrementEntriesCount(1, $alreadyRemovedCatIds); $alreadyRemovedCatIds[] = $category->getId(); $alreadyRemovedCatIds = array_merge($alreadyRemovedCatIds, $category->getAllParentsIds()); } } $this->setCategoriesIds(implode(",", $allIds)); mySearchUtils::setSearchTextDiscreteForEntry($this); parent::save(); $this->is_categories_modified = false; }