public function publishersFilter() { if( is_null( $this->_publisherFilters ) ) { $facetApplication = null; foreach( $this->contentList->facets as $facet ) { if( $facet instanceof FacetApplication ) { $facetApplication = $facet; break; } } $filters = array(); foreach( $facetApplication->defaultValues as $applicationId ) { $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId ); if( !$applicationLocalized ) continue; $filter = $applicationLocalized->getPublishersFilter(); if( !empty($filter) ) $filters[] = '('.$applicationLocalized->getPublishersFilter().')'; } $this->_publisherFilters = '( '.implode( ' OR ', $filters ).' )'; } return $this->_publisherFilters; }
/** * @param int $applicationId * @return array[] */ public static function fetchAllowedUsersByApplication($applicationId) { $appLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($applicationId); $conditions = array( 'application_localized_id' => $appLocalized->id, ); $result = parent::fetchObjectList(self::definition(), null, $conditions, null, null, false ); $usersList = array(); foreach( $result as $row ) { if ( !empty($row) ) { $usersList[] = $row['user_uuid']; } } return $usersList; }
/** * @param string $remote_id * @param string $cluster_identifier * @param string $description * @param string $url * @param string $application * @param string $elearningStatus * @return int */ public static function addToMySelection( $remote_id, $cluster_identifier, $description, $url, $application, $elearningStatus = null ) { $currentMMUser = MMUsers::getCurrentUserObject(); if ( !($currentMMUser instanceof MMUsers) ) return 0; $uuid = $currentMMUser->attribute( 'uuid' ); $country = $currentMMUser->attribute( 'country' ); if( !self::isAlreadyInUserSelection( $remote_id, $cluster_identifier ) ) { if ( !$currentMMUser ) return self::countTotalFromUserSelection(); $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($application); $application = $applicationLocalized->applicationObject()->attribute('identifier'); $selection = new MMSelections(); $selection->setAttribute( 'uuid', $uuid ); $selection->setAttribute( 'country', $country ); $selection->setAttribute( 'url', $url ); $selection->setAttribute( 'remote_id', $remote_id ); $selection->setAttribute( 'cluster_identifier', $cluster_identifier ); $selection->setAttribute( 'description', $description ); $selection->setAttribute( 'add_date', time() ); $selection->setAttribute( 'application', $application ); $selection->store(); } elseif( $application == 'e-learning' ) { self::updateSelectionDescription( $remote_id, $cluster_identifier, $description, $elearningStatus ); } self::setCookie(); return self::countTotalFromUserSelection($uuid, $country); }
/** * @return array */ public function getResponseSolr() { $applicationDictionaryRows = $this->prepareConfig(); $forbiddenWords = NodeVisibilityCheck::getForbiddenWordsArray( $this->_cluster_identifier ); $queryTerm = count($forbiddenWords) ? implode(' ', $forbiddenWords) : '*:*'; foreach ( $applicationDictionaryRows as $applicationDictionaryRow ) { // Get application node_id $applicationId = $applicationDictionaryRow['application_id']; /** @var ApplicationLocalized[] $_localApplication */ $this->_localApplications[$applicationId] = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId ); $appLocalizedIsProper = ( $this->_localApplications[$applicationId] instanceof ApplicationLocalized ); if ( !$appLocalizedIsProper ) { eZDebug::writeError( sprintf( 'Cannot fetch localized application %s for cluster %s', $applicationId, $this->_cluster_identifier ), __FILE__ . '::' . __LINE__ ); continue; } /* @type $validLanguages array */ $newsletterStyle = $applicationDictionaryRow['newsletter_style']; $clusterSiteIni = eZINI::fetchFromFile( "extension/{$this->_cluster_identifier}/settings/site.ini.append.php" ); $validLanguages = $clusterSiteIni->variable( 'RegionalSettings', 'SiteLanguageList' ); // Common $fq = array( 'meta_class_identifier_ms:"article"', '(attr_archive_date_dt:"1970-01-01T01:00:00Z" OR attr_archive_date_dt:[NOW TO *])', 'meta_installation_id_ms:'.eZSolr::installationID(), 'attr_is_invisible_' . $this->_cluster_identifier . '_b:false', 'meta_language_code_ms:(' . implode( ' OR ', $validLanguages ) . ')', ); $taxonomyList = json_decode( $applicationDictionaryRow['taxonomy_filter'], true ); if(count($taxonomyList) > 0){ foreach ($taxonomyList as $row) { foreach($row as $taxonomyCategory => $taxonomies){ $taxonomies = array_map(function($value) { return '"' . $value . '"'; }, $taxonomies); $fq[] = "subattr_{$taxonomyCategory}___source_id____s: (" . implode(',', $taxonomies) . ')'; } } } // NO SDK $publisherNodeIds = $this->_localApplications[$applicationId]->publisherNodeIds(); if(count($publisherNodeIds) == 1 ) { $newsletterStyle = $applicationDictionaryRow['newsletter_style']; $fq = array_merge($fq, array( 'meta_path_si:' . $publisherNodeIds[0], )); } elseif (count($publisherNodeIds) > 1 ) { $publisherFilter = implode(' OR ', $publisherNodeIds); $newsletterStyle = $applicationDictionaryRow['newsletter_style']; $fq = array_merge($fq, array( "meta_path_si:($publisherFilter)", )); } /** * SDK Specific treatment; dead code for now * if ( $this->_localApplications[$applicationId] instanceof SDKApplication ) { // SDK application $fq = array_merge($fq, array( 'subattr_local_application___source_id____s:' . $applicationId, 'is_sdk_b:true AND is_newsletter_b:true' )); } * */ // Solr query parameters $rows = 100000; $queryParams = array( 'indent' => 'on', 'q' => $queryTerm, 'start' => 0, 'rows' => $rows, 'fq' => $fq, 'fl' => array( 'attr_has_image_' . $this->_cluster_identifier . '_bst', 'meta_remote_id_ms', 'meta_node_id_si', 'meta_main_node_id_si', 'attr_featured_content_b', 'attr_date_dt', 'meta_path_string_ms', 'meta_language_code_ms', 'attr_view_counter_' . $this->_cluster_identifier . '_i', 'subattr_speciality___source_id____s', 'subattr_customer_type___source_id____s', 'meta_current_version_si', 'attr_promo_description_t', 'attr_author_t', 'attr_source_t', 'attr_online_date_dt', 'attr_headline_s', 'subattr_publisher_folder___source_id____s', 'attr_promo_headline_s', 'attr_'.$this->_cluster_identifier.'_remote_s', 'attr_'.$this->_cluster_identifier.'_node_remote_s', //'attr_media_content_image_'.$this->_cluster_identifier.'____ms', //'attr_promo_image_'.$this->_cluster_identifier.'_s', 'is_sdk_b', 'meta_url_alias_ms', 'attr_promo_headline_t', 'subattr_publisher_folder___source_id____s', 'meta_id_si', 'attr_media_content_types_' . ClusterTool::clusterIdentifier() . '_bst', 'attr_' . ClusterTool::clusterIdentifier() . '_url_s', 'attr_core_content_t', 'subattr_download_ressource___expiration_date____dt', 'attr_node_remote_s', 'attr_media_content_quiz_replies_' . $this->_cluster_identifier . '____ms', 'attr_media_content_quiz_points_' . $this->_cluster_identifier . '_i', 'attr_media_content_quiz_question_' . $this->_cluster_identifier . '_ms', ), 'qt' => '', 'explainOther' => '', 'hl.fl' => '', 'sort' => $this->_configuration['sort'] ); $publisherFilters = $this->_localApplications[$applicationId]->getPublishersFilter(); if ( $publisherFilters ) { $queryParams['fq'][] = $publisherFilters; } if ( !empty($this->_customerType) ) { $customerTypeCondition = implode(',', $this->stringArrayToFilterQueryParam($this->_customerType)); $queryParams['fq'][] = sprintf( 'subattr_customer_type___source_id____s:(%s)', $customerTypeCondition ); } if ( !empty($this->_specialty) ) { $specialtyCondition = implode(',', $this->stringArrayToFilterQueryParam($this->_specialty)); $queryParams['fq'][] = sprintf( 'subattr_speciality___source_id____s:(%s)', $specialtyCondition ); } if ( $applicationDictionaryRow["publisher"] ) { $queryParams['fq'][] = sprintf( 'subattr_publisher_folder___source_id____s:(%s)', $applicationDictionaryRow["publisher"] ); } if ( $newsletterStyle == 'PICL' ) { $queryParams['fq'][] = 'subattr_media_type___source_id____s:107.2'; } //taxonomies $taxonomies = $this->getApplicationTaxonomies($applicationDictionaryRow['feed_id']); $firstCategory = reset(array_keys($taxonomies)); $queryTaxonomies = ''; foreach($taxonomies as $categorie=>$taxonomie) { if($categorie != $firstCategory) { $queryTaxonomies .= ' AND '; } $queryTaxonomies .= 'subattr_' . $categorie . '___source_id____s:(' . $taxonomie . ')'; } if($queryTaxonomies != '') { $queryParams['fq'][] = $queryTaxonomies; } $queryParamsFqFallback = $queryParams['fq']; $rowValueKey = ''; // different sort and filters by mechanism switch ($applicationDictionaryRow["mechanism"]) { case 1: $rowValueKey = 'number_article_list'; $queryParams['sort'] = implode( ', ', $queryParams['sort'] ); //if begin/end date is set if(!empty($this->_beginDate) && !empty($this->_endDate)) { $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']'; } else { $queryParams['fq'][] = sprintf( 'attr_online_date_dt:[NOW-%sDAY TO *]', $this->_configuration['days'] ); } break; case 2: $rowValueKey = 'number_article_random'; $oneHourRandom = floor(time() / 3600); $queryParams['sort'] = 'attr_' . $oneHourRandom . '_random asc'; break; case 4: $rowValueKey = 'number_article_last_x'; $queryParams['sort'] = "attr_online_date_dt desc"; $queryParams['fq'][] = 'attr_online_date_dt:[NOW-7DAY TO *]'; //if begin/end date is set if(!empty($this->_beginDate) && !empty($this->_endDate)) { $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']'; } else { $queryParams['fq'][] = sprintf( 'attr_online_date_dt:[NOW-%sDAY TO *]', $this->_configuration['days'] ); } break; case 5: $rowValueKey = 'number_article_list'; if(!empty($this->_beginDate) && !empty($this->_endDate)) { $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']'; } $queryParams['sort'] = implode( ', ', $queryParams['sort'] ); if( $applicationDictionaryRow['number_article_ns'] ) { $queryParams['rows'] = (int)$applicationDictionaryRow['number_article_ns']; } else { $queryParams['rows'] = 100; } break; } if ( (int) $applicationDictionaryRow[$rowValueKey] >= 0 ) { $queryParams['rows'] = (int) $applicationDictionaryRow[$rowValueKey]; } $queryParams['fl'] = implode( ',', $queryParams['fl'] ); $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] ); // main fetch solr $result = SolrTool::rawSearch( $queryParams, 'php', false ); if ( !isset( $result['response']['docs'] ) ) { eZDebug::writeError( 'Error from Solr for query : ' . $result['params']['fq'], __FILE__ . '::' . __LINE__ ); if( php_sapi_name() != 'cli' ) { header( 'HTTP/1.x 500 Internal Server Error' ); eZExecution::cleanExit(); } } if ( count($result['response']['docs']) == 0 && $applicationDictionaryRow['mechanism'] == 5) { $queryParams['fq'] = $queryParamsFqFallback; $queryParams['sort'] = array( 'attr_featured_content_b desc', 'attr_online_date_dt desc', ); $queryParams['sort'] = implode( ', ', $queryParams['sort'] ); //if begin/end date is set if(!empty($this->_beginDate) && !empty($this->_endDate)) { $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']'; } $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] ); $result = SolrTool::rawSearch( $queryParams, 'php', false ); } // if no result fallback for mechanism 3 if ( count( $result['response']['docs'] ) == 0 && $applicationDictionaryRow["mechanism"] == 3 ) { $queryParams['fq'] = $queryParamsFqFallback; $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] ); if ( (int) $applicationDictionaryRow['number_article_random'] >= 0 ) { $queryParams['rows'] = (int) $applicationDictionaryRow['number_article_random']; } else { $queryParams['rows'] = $rows; } $oneHourRandom = floor(time() / 3600); $queryParams['sort'] = 'attr_' . $oneHourRandom . '_random asc'; $result = SolrTool::rawSearch( $queryParams, 'php', false ); if ( !isset( $result['response']['docs'] ) ) { eZDebug::writeError( 'Error from Solr for query : ' . $result['params']['fq'], __FILE__ . '::' . __LINE__ ); if( php_sapi_name() != 'cli' ) { header( 'HTTP/1.x 500 Internal Server Error' ); eZExecution::cleanExit(); } } } $articles = $result['response']['docs']; // if mechanism 4, we need to have articles also from previous week if($applicationDictionaryRow["mechanism"] == 4) { $queryParams['fq'] = $queryParamsFqFallback; $queryParams['fq'][] = 'attr_online_date_dt:[NOW-14DAY TO NOW-7DAY]'; $oneHourRandom = floor(time()); $queryParams['sort'] = 'attr_' . $oneHourRandom . '_random asc'; $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] ); $queryParams['rows'] = (int) $applicationDictionaryRow['number_article_random_y']; $resultRandom = SolrTool::rawSearch( $queryParams, 'php', false ); if ( !isset( $resultRandom['response']['docs'] ) ) { eZDebug::writeError( 'Error from Solr for query : ' . $result['params']['fq'], __FILE__ . '::' . __LINE__ ); if( php_sapi_name() != 'cli' ) { header( 'HTTP/1.x 500 Internal Server Error' ); eZExecution::cleanExit(); } } if(count($resultRandom['response']['docs'])) { $articles = array_merge($articles, $resultRandom['response']['docs']); } } $this->_applicationsData[$applicationId][] = array( 'articles' => $articles, 'applicationDictionaryRow' => $applicationDictionaryRow ); } return $this->_applicationsData; }
<?php //header( 'Cache-Control: no-cache, must-revalidate' ); header('Content-Type', 'application/json'); $tpl = eZTemplate::factory(); $nodeID = $Params['NodeID']; $applicationIdentifier = $Params['ApplicationIdentifier']; $node = null; if ($nodeID != null && $node != 'undefined') { $node = eZContentObjectTreeNode::fetch($nodeID); } $application = CacheApplicationTool::buildLocalizedApplicationByApplication($applicationIdentifier); if ($application instanceof ApplicationLocalized == false) { echo json_encode(array( 'publisher_logo' => false, )); return; } $publisherLogo = false; $showRelatedPublishers = $application->applicationObject()->getCustomParameter('ShowPublisherLogos'); if ($showRelatedPublishers && $node != null && $node instanceof eZContentObjectTreeNode) {
/** * @return array */ public static function getApplicationLists() { $userAppList = AppBarControl::instance()->applicationIds(); $orderedAppList = $userAppList; $apps = array(); sort($orderedAppList); $rawApps = ApplicationLocalized::fetchApplicationList(array('id' => array($orderedAppList))); foreach ( $rawApps as $k => $app ) { $force = false; if(SolrSafeOperatorHelper::featureIsActive('LearningNeedsAssessment') && $app->identifier == 'learning-needs-assessment') { $force = true; } if ( $app->attribute('application_library') || $force ) { /* @var $app ApplicationLocalized */ $apps['#' . $app->attribute('id')] = $app; } else { unset($userAppList[array_search($app->attribute('id'), $userAppList)]); $userAppList = array_values($userAppList); unset($orderedAppList[array_search($app->attribute('id'), $orderedAppList)]); $orderedAppList = array_values($orderedAppList); } } // we check if some apps were deleted in the meantime if ( self::user() ) { $applistToUpdate = false; foreach ( $userAppList as $k => $id ) { if ( !isset($apps['#' . $id]) ) { // we remove the application from the app bar only if it is not available for the anonymous // display rights are handled at application level if ( !in_array($id, CountryApplicationLibrary::fetchAuthorizedApplicationIds(true)) ) { unset($userAppList[$k]); $applistToUpdate = true; } else { $apps['#' . $id] = CacheApplicationTool::buildLocalizedApplicationByApplication($id); } } } if ( $applistToUpdate ) { $userAppList = array_values($userAppList); $user = MMUsers::getCurrentUserObject(); $orderedAppList = $userAppList; sort($orderedAppList); $user->setApplicationList($userAppList); } } return array( 'app_list' => self::user() ? $orderedAppList : $userAppList, 'apps' => $apps ); }
/** * @param array $conditions * @return ApplicationObject[] */ public static function fetchApplicationList ( $conditions = array() ) { if( is_null(self::$_applicationList ) ) { $appIds = parent::fetchObjectList(ApplicationObject::definition(), null, $conditions, null, null, false ); $apps = array(); foreach( $appIds as $appId ) { $appLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($appId['id']); if ( $appLocalized instanceof ApplicationLocalized && $appLocalized->applicationObject instanceof ApplicationObject ) $apps[] = $appLocalized->applicationObject; } self::$_applicationList = $apps; } return self::$_applicationList; }
/** * @param array $solrResult * @param FacetBase[] $facets * @return array */ public function articleResult(&$solrResult, $facets) { $returnArray = array(); $articleNodeIDs = array(); $articleSolrData = array(); $articleData = array(); $fields = $this->getFields(); foreach ( $solrResult['response']['docs'] as $doc ) { $nodeId = $doc['meta_guid_ms']; $article = array( 'headline' => isset ( $doc[$fields['headline']] ) ? $doc[$fields['headline']] : array(), 'url' => isset ( $doc[$fields['url']] ) ? $doc[$fields['url']] : array(), 'status' => isset ( $doc[$fields['status']] ) ? $doc[$fields['status']] : array(), 'condition' => isset ( $doc[$fields['condition']] ) ? $doc[$fields['condition']] : array(), 'gender' => isset ( $doc[$fields['gender']] ) ? $doc[$fields['gender']] : array(), 'min_age' => isset ( $doc[$fields['min_age']] ) ? $doc[$fields['min_age']] : array(), 'max_age' => isset ( $doc[$fields['max_age']] ) ? $doc[$fields['max_age']] : array(), 'country' => isset ( $doc[$fields['country']] ) ? $doc[$fields['country']] : array(), ); switch (reset($article['status'])) { case '231.2': // case ClinicalTrialsImportManager::STATUS_RECRUITING: $article['status'] = 'RECRUITING'; break; case '231.1': // case ClinicalTrialsImportManager::STATUS_NOT_RECRUITING: $article['status'] = 'NOT RECRUITING'; break; default: $article['status'] = 'NOT AVAILABLE'; break; } switch (count($article['gender'])) { case 0: $article['gender'] = 'NOT AVAILABLE'; break; case 1: if ($article['gender'][0] == '') { $article['gender'] = 'NOT AVAILABLE'; } else { $article['gender'] = 'GENDER_' . $article['gender'][0]; } break; case 2: $article['gender'] = 'GENDER_BOTH'; break; } if ($article['min_age'] == 0) { $article['min_age'] = 'NOT AVAILABLE'; } if ($article['max_age'] == 0) { $article['max_age'] = 'NOT AVAILABLE'; } $articleData[] = $article; $solrApplicationIndexes = isset ( $doc[$fields['apps']] ) ? $doc[$fields['apps']] : array(); $solrApplicationNames = array(); $solrApplicationIdentifiers = array(); foreach( $solrApplicationIndexes as $applicationIndex ) { list ( $cluster, $void, $applicationId ) = explode( '##', $applicationIndex ); if ( $cluster == ClusterTool::clusterIdentifier() ) { $app = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId ); if ( !($app instanceof ApplicationLocalized) ) continue; $solrApplicationNames[] = $app->attribute('name'); $solrApplicationIdentifiers[] = $app->applicationObject()->attribute('identifier'); } } $url = isset( $doc[$fields['url']] ) ? $doc[$fields['url']] : null; if ( empty( $solrApplicationIdentifiers ) ) { eZDebug::writeError( "Could not get application id for cluster for node $nodeId - Falling back to current application" ); $solrApplicationIdentifiers = array( $this->contentList->applicationObject()->attribute('identifier') ); } $masterApps = $this->contentList->iniMerck()->hasSection('MasterAppSettings') && $this->contentList->iniMerck()->hasVariable( 'MasterAppSettings', 'MasterAppList' ) ? $this->contentList->iniMerck()->variable( 'MasterAppSettings', 'MasterAppList' ) : array(); $applicationIdentifier = $solrApplicationIdentifiers[0]; if (!empty($masterApps)) { foreach ($solrApplicationIdentifiers as $solrApplicationIdentifierKey => $solrApplicationIdentifier) { if (in_array($solrApplicationIdentifier, $masterApps)) { $applicationIdentifier = $solrApplicationIdentifier; unset( $solrApplicationIdentifiers[$solrApplicationIdentifierKey] ); $solrApplicationIdentifiers = array_merge( array( $applicationIdentifier ), $solrApplicationIdentifiers ); break; } } } $application = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier ); $applicationObject = $application->applicationObject(); $applicationType = $applicationObject->applicationType()->attribute('type_identifier'); $url = ($applicationType == 'first-child') ? '/' . $application->attribute('url') : '/'.$application->attribute('url').'/'.$url; $articleSolrData[$nodeId] = array( 'url' => $url, 'headline' => isset( $doc[$fields['headline']] ) ? $doc[$fields['headline']] : null, 'promo_description' => isset( $doc[$fields['promo_description']] ) ? $doc[$fields['promo_description']] : null, 'apps' => $solrApplicationNames, 'app_identifiers' => $solrApplicationIdentifiers, 'trip_speciality' => isset( $doc[$fields['trip_speciality']] ) ? $doc[$fields['trip_speciality']] : null, 'trip_url' => isset( $doc[$fields['trip_url']] ) ? $doc[$fields['trip_url']] : null, 'trip_publication' => isset( $doc[$fields['trip_publication']] ) ? $doc[$fields['trip_publication']] : null ); } if( $this->withArticles ) { $articleInformations = array( 'articles' => $articleData, 'articles_solrdata' => $articleSolrData, 'features' => $this->features, 'with_feed' => $this->withFeed, 'content_service_configuration' => ( isset($app) ? $app->applicationObject->configurationContentService : array() ), ); $returnArray['article_informations'] = $articleInformations; $returnArray['articles_nb'] = count($articleNodeIDs); if( trim($this->searchQuery) != '' ) { if( isset( $solrResult['spellcheck']['suggestions']) ) $returnArray['kw_suggestion'] = $solrResult['spellcheck']['suggestions']['collation']; } if( isset( $solrResult['highlighting'] ) ) { $highlights = $this->parseSolrHighlights( $solrResult ); if( $highlights ) $returnArray['highlights'] = $highlights; } } if ( $this->withAllSpecialities ) { $facet = null; foreach($this->contentList->facets as $f) { if( $f instanceof FacetFieldTagSpeciality ) { $facet = $facets[$f->key]['list']; break; } } $main_speciality = ''; $specialities = array(); $first = true; foreach( $facet as $lbl => $arr ) { if( $first ) { $main_speciality = $lbl; $first = false; } else $specialities[$lbl] = $arr; } $allSpecialitiesInformations = array( 'main_speciality' => $main_speciality, 'specialities' => $specialities, 'all_specialities' => $this->allSpecialitiesFacet() ); $returnArray['all_specialities_informations'] = $allSpecialitiesInformations; } if( $this->withMostPopularKeywords ) $returnArray['most_popular_kw'] = $this->keywordsAutocomplete(''); if ( $this->withT3Facets ) { $t3FacetInformations = array(); foreach($this->contentList->facets as $index => $f) { if( $f instanceof FacetFieldTagType3 ) { $t3FacetInformations['t3_facets'] = $facets[$f->key]['list']; $t3FacetInformations['t3_name'] = $f->key; $t3FacetInformations['t3_key'] = 'f'.$index; break; } } $returnArray['t3_facet_informations'] = $t3FacetInformations; } return $returnArray; }
/** * @param int $applicationId */ public function __construct( $applicationId ) { $this->_applicationId = $applicationId; $this->_application = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId )->applicationObject; }
static function updateRanking() { $qpru = QuizPendingRankingUpdate::fetchAll(); if( $qpru ) { $benchMessage = $benchSQLStart = $benchSQLEnd = $benchCalculusStart = $benchCalculusEnd = $benchTotalStart = $benchTotalEnd = null; // We only update one quiz application's leaderboard on each // cronjob pass even if multiple leaderboards are awaiting update // to limit SQL queries $lowestRanking = (int)$qpru[0]['lowest_global_ranking']; $clusterIdentifier = $qpru[0]['cluster_identifier']; $applicationId = (int)$qpru[0]['application_id']; $application = CacheApplicationTool::buildLocalizedApplicationByApplication($applicationId); if( is_numeric( $lowestRanking ) && $lowestRanking != null && is_numeric( $applicationId ) && $applicationId != null ) { $benchTotalStart = getrusage(); $db = eZDB::instance(); $db->begin(); $results = $db->arrayQuery( sprintf(" SELECT uuid, user_specialty, score, global_ranking, specialty_ranking FROM %s WHERE global_ranking <= %d AND cluster_identifier = '%s' AND application_id = %d AND ( nb_correct > 0 OR nb_wrong > 0 ) ORDER BY score DESC", self::SQL_TABLENAME, $lowestRanking, $db->escapeString( $clusterIdentifier ), $applicationId ) ); $updateCount = 0; if( $results && count( $results ) > 1 ) { $benchCalculusStart = getrusage(); $updateResult = null; $spe = $changed = $res = array(); $r = $_r = 1; foreach( $results as $rank => $row ) { if( (int)$row['global_ranking'] != $r ) { $changed[] = $row['uuid']; $results[$rank]['global_ranking'] = $r; } if( isset( $results[$rank + 1] ) && ( (int)$results[$rank + 1]['score'] != (int)$row['score'] ) ) $r++; $spe[$row['user_specialty']][] = $results[$rank]; $res[$row['uuid']] = $rank; } foreach( $spe as $row ) { $_r = 1; if( count( $row ) > 1 ) { foreach( $row as $_rank => $_row ) { if( (int)$_row['specialty_ranking'] != $_r ) { if( !in_array( $_row['uuid'], $changed ) ) $changed[] = $_row['uuid']; $results[$res[$_row['uuid']]]['specialty_ranking'] = $_r; } if( isset( $row[$_rank + 1] ) ) { if( (int)$row[$_rank + 1]['score'] != (int)$_row['score'] ) $_r++; } } } else { if( (int)$row[0]['specialty_ranking'] != $_r ) { if( !in_array( $row[0]['uuid'], $changed ) ) $changed[] = $row[0]['uuid']; $results[$res[$row[0]['uuid']]]['specialty_ranking'] = $_r; } } } $benchCalculusEnd = getrusage(); if( count( $changed ) > 0 ) { $benchSQLStart = getrusage(); foreach( $changed as $uuid ) { $updateResult = $db->query( sprintf(" UPDATE %s SET global_ranking = %d, specialty_ranking = %d WHERE uuid = '%s' AND cluster_identifier = '%s' AND application_id = %d", self::SQL_TABLENAME, $results[$res[$uuid]]['global_ranking'], $results[$res[$uuid]]['specialty_ranking'], $uuid, $db->escapeString( $clusterIdentifier ), $applicationId ) ); } $benchSQLEnd = getrusage(); } $updateCount = count( $changed ); $benchTotalEnd = getrusage(); if( $updateCount > 0 ) $benchMessage = 'Total: ' . self::benchmarckTime( $benchTotalEnd, $benchTotalStart ) . 'ms (Calculus: ' . self::benchmarckTime( $benchCalculusEnd, $benchCalculusStart ) . 'ms, SQL: ' . self::benchmarckTime( $benchSQLEnd, $benchSQLStart ) . 'ms)'; } else { if( $results && count( $results ) == 1 ) { $updateResult = $db->query( sprintf(" UPDATE %s SET global_ranking = 1, specialty_ranking = 1 WHERE uuid = '%s' AND cluster_identifier = '%s' AND application_id = %d", self::SQL_TABLENAME, $results[0]['uuid'], $db->escapeString( $clusterIdentifier ), $applicationId ) ); $updateCount = 1; } } $db->commit(); } // Once leaderboard update is done, we delete the corresponding PendingRankingUpdate row in DB QuizPendingRankingUpdate::removeById( (int)$qpru[0]['id'] ); // If we updated a user with a lower global ranking than the one used for the recalculation above, that means we // had users sharing the same global ranking. We need to schedule yet another recalculation with the lowest ranking available if( $r != $lowestRanking ) { ClusterTool::setCurrentCluster( $clusterIdentifier ); $lowestGlobalRanking = QuizPlayerScoring::fetchBy( array( 'cluster_identifier' => $clusterIdentifier, 'application_id' => $applicationId ), array( 'global_ranking' => 'desc' ), array( 'length' => 1 ) ); QuizPendingRankingUpdate::add( $lowestGlobalRanking[0]->attribute('global_ranking'), $applicationId ); } return array( 'updateCount' => $updateCount, 'updateResult' => $updateResult, 'clusterIdentifier' => $clusterIdentifier, 'applicationId' => $applicationId, 'benchmark' => $benchMessage ); } return null; }
/** * @param null $command * @return string */ protected function getWSHandler( $command = null ) { // Specific cases for ESHCP 1.8 validation if ( in_array( $command, array( 'validate/us' ) ) ) { $this->_wsHandler = "EshcpWSHelper"; return $this->_wsHandler; } // Specific cases as some webservices used for UUMP countries will be available only through 8088 port if ( in_array( $command, array( 'doccheck' ) ) ) { $this->_wsHandler = "WSHelper"; return $this->_wsHandler; } // Do we override classic WSHandler (ESB) for a specific one, for special registration purposes ? if ( SolrSafeOperatorHelper::featureIsActive( 'OverrideWSHandler' ) && ( $command == 'create' ) ) { $this->_wsHandler = SolrSafeOperatorHelper::feature( 'OverrideWSHandler', 'ClassName' ); // Are we on the "validation" registration page and is the hash correct ? if ( self::verifyHash() ) { // We go back on classic ESB instead of overriden WSHandler $register_app = CacheApplicationTool::buildLocalizedApplicationByApplication( $_POST['app_id'] ); $this->_wsHandler = $register_app->getCustomParameter( 'WSHandler' ); } } // Are we on a UUMP cluster ? elseif ( SolrSafeOperatorHelper::featureIsActive( 'UUMP' ) ) { $this->_wsHandler = SolrSafeOperatorHelper::feature( 'UUMP', 'WSHandlerClassName' ); } // Else we use the classic ESB else { $this->_wsHandler = "WSHelper"; } return $this->_wsHandler; }
private function buildResultList() { $applications = array(); $applicationIds = array(); $applicationsByName = array(); foreach( CountryApplicationLibrary::fetchAuthorizedApplicationIds() as $appId ) { if( $appId == 0 ) continue; $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication( $appId ); if( !($applicationLocalized instanceof ApplicationLocalized) ) continue; // Hack : Temporary patch to override in localized application the mm_application.parent_id if ( $applicationLocalized->getCustomParameter('DirectAccessDisable') === true ) continue; if( (bool)$applicationLocalized->applicationObject->attribute('application_library') ) { if($applicationLocalized->restrictionLevel() == ApplicationObject::RESTRICTION_LEVEL_LIMITED) { if(MMLimitedApplicationsAllowedUsers::hasCurrentUserAccessToApp($applicationLocalized->application_id)) { $applications[] = $applicationLocalized->applicationObject; $applicationIds[] = $appId; } } else { $applications[] = $applicationLocalized->applicationObject; $applicationIds[] = $appId; } } } /* @var $app ApplicationObject */ foreach( $applications as $k => $app ) $applicationsByName[$app->applicationLocalized()->attribute('headline')] = $app; uksort( $applicationsByName, function($a, $b){ return strnatcasecmp($a, $b); }); // display all applications $this->pushResult('application_ids' , $applicationIds); $this->pushResult('applications_by_name', $applicationsByName); // for anonymous users $ids = CountryAppsBar::fetchAppsBarApplicationIds(); $applications_anonymous = array(); foreach($ids as $id) $applications_anonymous[] = (string)$id; $this->pushResult('applications_anonymous', $applications_anonymous); // banners $banners = array(); $base = $this->applicationLocalized()->applicationUrl().'/'; /* @var $application ApplicationObject */ /* @var $homepageApplication MMHomePage */ $homepageApplication = ApplicationFactory::fetchByUri('/'); foreach( $homepageApplication->getAppsToAdd() as $application ) { $bannerFiles = $application->applicationLocalized()->getBanners(); if (is_array($bannerFiles) && !is_null($bannerFiles['big']) && !is_null($bannerFiles['small'])) { $banners[] = array( 'id' => $this->applicationLocalized()->attribute('id'), 'img' => SolrSafeOperatorHelper::bannerDecHash('/esibuild/banner/'.$application->attribute( 'identifier' ).'/big/'.ClusterTool::clusterIdentifier().'.png'), 'img_small' => SolrSafeOperatorHelper::bannerDecHash('/esibuild/banner/'.$application->attribute( 'identifier' ).'/small/'.ClusterTool::clusterIdentifier().'.png'), 'label' => $application->applicationLocalized()->attribute('headline'), 'url' => $base . $application->applicationLocalized()->attribute('url'), ); } if( count($banners) >= self::BANNER_ITEMS_LIMIT ) break; } $this->pushResult('banners', $banners); }
/** * @return ApplicationLocalized */ public function applicationLocalized() { return CacheApplicationTool::buildLocalizedApplicationByApplication($this->attribute('id')); }
/** * @return ApplicationObject */ public function application() { $localized = CacheApplicationTool::buildLocalizedApplicationByApplication($this->attribute("channel_application_id")); if ($localized == null) { return null; } return $localized->applicationObject(); }
if( is_null($cluster) ) $script->shutdown(3, 'No cluster provided - Aborting'); if( is_null($filename) ) $script->shutdown(1, 'No File provided - Aborting'); if( !($f = fopen($filename, 'r')) ) $script->shutdown(2, 'Could not open source file - Aborting'); $db = eZDB::instance(); ClusterTool::setCurrentCluster($cluster); $appsById = array(); foreach( $db->arrayQuery( sprintf( "SELECT application_id FROM mm_application_localized WHERE cluster_identifier = '%s'", $cluster ) ) as $row ) $appsById[$row['application_id']] = CacheApplicationTool::buildLocalizedApplicationByApplication($row['application_id'] ); uasort( $appsById, function($a, $b){ return strnatcasecmp( $a->applicationObject->attribute('identifier'), $b->applicationObject->attribute('identifier') ); }); ClusterTool::resetCurrentCluster(); $dumpCmd = 'mysqldump -h'.$db->Server.' -u'.$db->User.' -p'.$db->Password.' '.$db->DB.' mm_application mm_application_localized > "'.eZINI::instance()->variable('FileSettings', 'VarDir').'/mm_application_import_dump.'.date('YmdHis').'.sql"'; $dump = exec($dumpCmd); $headers = fgetcsv($f, null, ',', '"'); while ( $r= fgetcsv($f, null, ',', '"') ) { $row = array_combine($headers, $r);
public static function getPublisherArticleUrl($publisher, $articleId) { $fields = array( 'apps' => 'subattr_local_application___source_mixed____s', 'url' => 'attr_'.ClusterTool::clusterIdentifier().'_url_s', 'publisher_path' => 'subattr_publisher_folder___source_id____s', ); $fq = array( "subattr_publisher_folder___source_id____s: \"{$publisher}\"", "attr_publisher_internal_id_s: \"{$articleId}\"", ); $params = array( 'indent' => 'on', 'q' => '', 'start' => 0, 'rows' => 1, 'fq' => implode(' AND ', $fq), 'fl' => implode(',', array_values($fields)), 'qt' => 'ezpublish', 'explainOther' => '', 'hl.fl' => '', ); $raw = SolrTool::rawSearch($params); if ($raw['response']['numFound'] == 0) { return null; } $row = $raw['response']['docs'][0]; $solrApplicationIndexes = $row[$fields['apps']]; $solrApplicationIdentifiers = array(); $solrApplicationNames = array(); foreach( $solrApplicationIndexes as $applicationIndex ) { list ( $cluster, /* unused */, $applicationId ) = explode( '##', $applicationIndex ); if ( $cluster == ClusterTool::clusterIdentifier() ) { $app = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId ); if ( !($app instanceof ApplicationLocalized) ) continue; $solrApplicationNames[] = $app->attribute('name'); $solrApplicationIdentifiers[] = $app->applicationObject()->attribute('identifier'); } } if (empty($solrApplicationIdentifiers)) { return; } $applicationIdentifier = $solrApplicationIdentifiers[0]; $application = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier ); $applicationObject = $application->applicationObject(); $applicationType = $applicationObject->applicationType()->attribute('type_identifier'); $publisherPath = $row[$fields['publisher_path']][0]; $publisherInfo = PublisherFolderTool::getPathToIDMapping($publisherPath); $publisherFolderId = $publisherInfo['pfid']; $url = isset( $row[$fields['url']] ) ? $row[$fields['url']] : null; $url = ($applicationType == 'first-child') ? $application->attribute('url_alias') : $application->attribute('url_alias') . '/' . $publisherFolderId . '/' . $url; return $url; }
/** * @return array */ public static function version_json() { $cacheManifest = CacheTool::dailyValue(self::MOBILE_MANIFEST_NAME); if(is_null($cacheManifest)) $cacheManifest = array(); $allAppIds = CountryApplicationLibrary::fetchAuthorizedApplicationIds(); $applicationIds = array('my-selection', 'application-library', 'register', 'global-search', 'contactus-fr', 'sendtocolleague', 'mobile-app-settings'); foreach ( $allAppIds as $appId ) { if ( $appId == 0 ) continue; $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($appId); if ( !($applicationLocalized instanceof ApplicationLocalized) ) continue; if ( (bool) $applicationLocalized->applicationObject->attribute('application_library') ) { $applicationIds[] = $applicationLocalized->applicationObject->attribute('identifier'); } } $newApps = array_diff($applicationIds, array_keys($cacheManifest)); if(count($newApps)) { // fill the cacheManifest with new entry foreach($newApps as $newApp) { $cacheManifest[$newApp] = array("js" => array_flip(self::getJavascript($newApp, 'all')), "css" => array_flip(self::getCSS($newApp)) ); } // save new applications in cache CacheTool::dailyValue(self::MOBILE_MANIFEST_NAME, $cacheManifest); } $js = array(); $css = array(); foreach($applicationIds as $id) { $js = array_merge($js, $cacheManifest[$id]["js"]); $css = array_merge($css, $cacheManifest[$id]["css"]); } return array_unique(array_merge($js, $css)); }
/** * i18n operator works like : source|context([argument1, argument2 ...]) * Arguments are optional and are comma separated * * @return Callable[] * * Examples : * * Simple without argument: * {{# i18n }} * MORE|merck() * {{/ i18n }} * * Or with argument: * {{# i18n }} * %nb RESULTS|merck(3) * {{/ i18n }} */ private static function getHelpers($application = null) { return array( 'i18n' => function($text) { preg_match("#(?<source>[^\|]+)\|(?<context>[^(]+)\((?<params>[^\)]+)?\)#", $text, $m); if($m && $m["source"] && $m["context"]) { $arguments = array(); if($m["params"]) { $params = explode(",", $m["params"]); preg_match_all("#(?<arguments>%\w+)#", $m["source"], $mParams); if($mParams && $mParams["arguments"]) { for($i = 0; $i < count($mParams["arguments"]); $i++) { $arguments[$mParams["arguments"][$i]] = $params[$i]; } } } return ezpI18n::tr($m["context"], $m["source"], null, $arguments); } return $text; }, 'taxonomies_filter' => function($text) use ($application) { $filterTaxonomies = $application->getCustomParameter('TaxonomiesFilter'); $html = ''; foreach($filterTaxonomies as $category) { $taxonomies = FacetFilteringTool::getTaxonomyTranslationsByCategory($category); $tpl = eZTemplate::factory(); $tpl->setVariable('taxonomies', $taxonomies); $tpl->setVariable('category', $category); $html .= $tpl->fetch( 'design:esibuild/app_content/channel/filter.tpl' ); } return $html; }, 'editors_choice_content' => function($text) use ($application) { $taxonomyCategory = $application->getCustomParameter('EditorsChoiceFilter'); $taxonomyValue = $application->getCustomParameter('EditorsChoiceValue'); $limit = $application->getCustomParameter('EditorsChoiceLimit'); $html = ''; $language = eZINI::instance('site.ini')->variable('RegionalSettings', 'ContentObjectLocale'); $fields = array( 'node_id' => 'meta_node_id_si', 'object_id' => 'meta_id_si', 'language' => 'meta_language_code_ms', 'url' => 'attr_'.ClusterTool::clusterIdentifier().'_url_s', 'headline' => 'attr_headline_s', 'promo_description' => 'attr_promo_description_t', 'rating' => 'attr_content_rating_'.ClusterTool::clusterIdentifier().'_f', 'views' => 'attr_view_counter_'.ClusterTool::clusterIdentifier().'_i', 'app_identifiers' => 'subattr_parent_application___identifier____s', 'apps' => 'subattr_local_application___source_mixed____s', 'app_id' => 'subattr_local_application___source_id____s', 'online_date' => 'attr_online_date_dt', 'score' => 'score', 'publisher_path' => 'subattr_publisher_folder___source_id____s', 'has_image' => 'attr_has_image_'.ClusterTool::clusterIdentifier().'_bst', 'media_types' => 'attr_media_content_types_'.ClusterTool::clusterIdentifier().'_bst', 'internal_id' => 'attr_publisher_internal_id_s', 'link_url' => 'attr_media_content_link_'.ClusterTool::clusterIdentifier().'____ms' ); $filters = array( "subattr_{$taxonomyCategory[0]}___source_id____s: \"{$taxonomyValue[0]}\"", "meta_language_code_ms: \"{$language}\"" ); $params = array( 'indent' => 'on', 'q' => '*:*', 'fq' => implode(' AND ' , $filters), 'start' => '0', 'rows' => $limit, 'fl' => implode(',',$fields), 'qt' => 'ezpublish', 'explainOther' => '', 'hl.fl' => '', 'sort' => "attr_online_date_dt desc", ); $result = SolrTool::rawSearch($params); foreach ($result[response][docs] as $key => $value) { $result[response][docs][$key]['headline'] = $value['attr_headline_s']; $result[response][docs][$key]['node_id'] = $value['meta_node_id_si']; $result[response][docs][$key]['object_id'] = $value['meta_id_si']; $result[response][docs][$key]['language'] = $value['meta_language_code_ms']; $result[response][docs][$key]['promo_description'] = $value['attr_promo_description_t']; $app = CacheApplicationTool::buildLocalizedApplicationByApplication( $value['subattr_local_application___source_id____s'][0] ); $applicationObject = $app->applicationObject(); $applicationType = $applicationObject->applicationType()->attribute('type_identifier'); $result[response][docs][$key]['application_name'] = $app->attribute('url_alias'); $publisherPath = $value['subattr_publisher_folder___source_id____s'][0]; $publisher = PublisherFolder::getPublisherFromPath($publisherPath); $publisherFolderId = $publisher->getTranslation()->attribute('publisher_folder_id'); $publisherName = $publisher->getTranslation()->attribute('name'); $result[response][docs][$key]['publisher_name'] = $publisherName; $url = $value['attr_'.ClusterTool::clusterIdentifier().'_url_s']; $url = ($applicationType == 'first-child') ? $app->attribute('url_alias') : $app->attribute('url_alias') . '/' . $publisherFolderId . '/' . $url; $result[response][docs][$key]['url'] = $url; $result[response][docs][$key]['online_date'] = solrTool::getDateFromSolr($value['attr_online_date_dt']); $result[response][docs][$key]['publisher_name'] = $publisherName; $result[response][docs][$key]['has_image'] = json_decode( base64_decode($value['attr_has_image_'.ClusterTool::clusterIdentifier().'_bst']), true ); $mediaCase = ImageArticleTool::NEWS_APPLICATION_CASE; $hasImage = $result[response][docs][$key]['has_image'][$mediaCase]; if ($hasImage) { $result[response][docs][$key]["dt_url"] = SolrSafeOperatorHelper::getImageArticleUrl($mediaCase, $result[response][docs][$key]['object_id'], $result[response][docs][$key]['language'], 'dt_full'); $result[response][docs][$key]["mb_url"] = SolrSafeOperatorHelper::getImageArticleUrl($mediaCase, $result[response][docs][$key]['object_id'], $result[response][docs][$key]['language'], 'm_full'); } } $tpl = eZTemplate::factory(); $tpl->setVariable('editorsChoice', $result); $html .= $tpl->fetch( 'design:esibuild/app_content/channel/editors_choice.tpl' ); return $html; } ); }
/** * @param string $taxonomyCategory * @param float $taxonomyValue * @param int $limit * @param boolean $includeAllValues * @return array */ public function getRelatedContent($taxonomyCategory, $taxonomyValue, $limit, $includeAllValues, $nodeId) { $fields = $this->mappingFieldsSolr; $filters = array(); if ($includeAllValues) { foreach ($taxonomyValue as $tv) { $filters[] = "subattr_{$taxonomyCategory}___source_id____s: \"{$tv}\""; } } else { $filter = "subattr_{$taxonomyCategory}___source_id____s: (%s)"; $taxonomyValue = array_map( function($v) { return "\"{$v}\""; }, $taxonomyValue); $filter = sprintf($filter, implode(' OR ', $taxonomyValue)); $filters[] = $filter; } $filters[] = '-meta_node_id_si: ' . $nodeId; $locale = LocaleTool::languageFromLocale(); $filters[] = "meta_language_code_ms:".$locale.'*'; $params = array( 'indent' => 'on', 'q' => '*:*', 'fq' => implode(' AND ' , $filters), 'start' => $this->offset, 'rows' => $limit, 'fl' => implode(',',$fields), 'qt' => 'ezpublish', 'explainOther' => '', 'hl.fl' => '', 'sort' => "attr_online_date_dt desc", ); $solrResult = SolrTool::rawSearch( $params, 'php', true, false ); foreach ( $solrResult['response']['docs'] as $doc ) { $nodeId = $doc['meta_node_id_si'][0]; $articleNodeIDs[] = $nodeId; $solrApplicationIndexes = isset ( $doc[$fields['apps']] ) ? $doc[$fields['apps']] : array(); $solrApplicationNames = array(); $solrApplicationIdentifiers = array(); $app = null; foreach( $solrApplicationIndexes as $applicationIndex ) { list ( $cluster, /* unused */, $applicationId ) = explode( '##', $applicationIndex ); if ( $cluster == ClusterTool::clusterIdentifier() ) { $app = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId ); if ( !($app instanceof ApplicationLocalized) ) continue; $solrApplicationNames[] = $app->attribute('name'); $solrApplicationIdentifiers[] = $app->applicationObject()->attribute('identifier'); } } $url = isset( $doc[$fields['url']] ) ? $doc[$fields['url']] : null; if ( empty( $solrApplicationIdentifiers ) ) { eZDebug::writeError( "Could not get application id for cluster for node $nodeId - Falling back to current application" ); $solrApplicationIdentifiers = array( $this->contentList->applicationObject()->attribute('identifier') ); } $masterApps = $this->contentList->iniMerck()->hasSection('MasterAppSettings') && $this->contentList->iniMerck()->hasVariable( 'MasterAppSettings', 'MasterAppList' ) ? $this->contentList->iniMerck()->variable( 'MasterAppSettings', 'MasterAppList' ) : array(); $applicationIdentifier = $solrApplicationIdentifiers[0]; if (!empty($masterApps)) { foreach ($solrApplicationIdentifiers as $solrApplicationIdentifierKey => $solrApplicationIdentifier) { if (in_array($solrApplicationIdentifier, $masterApps)) { $applicationIdentifier = $solrApplicationIdentifier; unset( $solrApplicationIdentifiers[$solrApplicationIdentifierKey] ); $solrApplicationIdentifiers = array_merge( array( $applicationIdentifier ), $solrApplicationIdentifiers ); break; } } } $application = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier ); $applicationObject = $application->applicationObject(); $applicationType = $applicationObject->applicationType()->attribute('type_identifier'); $publisherPath = $doc[$fields['publisher_path']][0]; $publisherInfo = PublisherFolderTool::getPathToIDMapping($publisherPath); $publisherFolderId = $publisherInfo['pfid']; $onlineDateStamp = strtotime($doc[$fields['online_date']]) > 3600*24*2 ? SolrTool::getTimestampFromSolr($doc[$fields['online_date']]) : 0; $mediaTypes = isset( $doc[$fields['media_types']] ) ? json_decode( base64_decode($doc[$fields['media_types']]), true ) : array(); $mediaCount = 0; $hasImage = isset( $doc[$fields['has_image']] ) ? json_decode( base64_decode($doc[$fields['has_image']]), true ) : array(); $url = ($applicationType == 'first-child') ? $application->attribute('url_alias') : $application->attribute('url_alias') . '/' . $publisherFolderId . '/' . $url; $result[$nodeId] = array( 'object_id' => isset( $doc[$fields['object_id']] ) ? $doc[$fields['object_id']] : null, 'language' => isset( $doc[$fields['language']] ) ? $doc[$fields['language']] : null, 'headline' => isset( $doc[$fields['headline']] ) ? $doc[$fields['headline']] : null, 'promo_description' => isset( $doc[$fields['promo_description']] ) ? $doc[$fields['promo_description']] : null, 'online_date' => strtotime($doc[$fields['online_date']]) > 3600*24*2 ? SolrTool::getDateFromSolr($doc[$fields['online_date']]) : 0, 'has_image' => $hasImage, 'url' => $url, 'node_id' => $nodeId, 'internal_id' => isset( $doc[$fields['internal_id']] ) ? $doc[$fields['internal_id']] : null, 'application' => $application, ); } return $result; }