public static function getRootPath() { $rootFolder = eZIni::instance('sqliimport.ini')->variable('XMLImportSettings', 'RootImport'); if (substr($rootFolder, -1) == '/') $rootFolder = substr($rootFolder, 0, -1); return $rootFolder; }
public static function binaryToFile($binary, $keep=true) { if (!$binary) return false; $ini = eZIni::instance('site.ini'); $fileDirectory = $ini->variable('FileSettings', 'VarDir') . '/' . $ini->variable('FileSettings', 'CacheDir') . '/synch'; if (!is_dir($fileDirectory)) mkdir($fileDirectory); $ext = 'bin'; $fileName = 'binaryToFile'; if ($keep) $fileName = uniqid($fileName); $filePath = $fileDirectory . '/' . $fileName . '.' . $ext; if (file_put_contents($filePath, $binary)) { $finfo = new finfo(); $mime_type = $finfo->file($filePath, FILEINFO_MIME_TYPE); if (isset(self::$mimeTypesExtension[$mime_type])) { $ext = self::$mimeTypesExtension[$mime_type]; if (rename($filePath, $fileDirectory . '/' . $fileName . '.' . $ext)) { finfo_close($finfo); return $fileDirectory . '/' . $fileName . '.' . $ext; } else { throw new MMSynchException(__METHOD__ . ' Error to rename binary file'); } } else { throw new MMSynchException(__METHOD__ . ' Unknow file extension of mime type ' . $mime_type); } finfo_close($finfo); } throw new MMSynchException(__METHOD__ . ' Error to create file with binary data'); }
/** * * @return eZDBInterface */ public static function db() { if (!self::$db) { $ini = eZIni::instance('sqliimport.ini'); $databaseImplementation = $ini->variable( 'DatabaseSettings', 'DatabaseImplementation' ); list( $server, $port, $user, $pwd, $db, $usePersistentConnection) = $ini->variableMulti( 'DatabaseSettings', array( 'Server', 'Port', 'User', 'Password', 'Database', 'UsePersistentConnection', ) ); $databaseParameters = array( 'server' => $server, 'port' => $port, 'user' => $user, 'password' => $pwd, 'database' => $db, 'use_persistent_connection' => $usePersistentConnection ); self::$db = eZDB::instance($databaseImplementation, $databaseParameters, true); } return self::$db; }
/** * @param bool|string $localeString * @return array */ protected static function isoCodes( $localeString = false ) { $locale = eZLocale::instance( $localeString ); $localeString = $locale->localeCode(); $HTTPLocaleCode = $locale->HTTPLocaleCode; if ( $HTTPLocaleCode == '' ) { $localeString = eZINI::instance()->variable( 'RegionalSettings', 'Locale' ); } $ini = eZIni::instance( 'merck.ini' ); $HTTPLocaleCodes = $ini->variable( 'LocaleOverride', 'HTTPLocaleCode' ); if ( isset( $HTTPLocaleCodes[$localeString] ) ) { $HTTPLocaleCode = $HTTPLocaleCodes[$localeString]; } return explode( '-', $HTTPLocaleCode ); }
<?php $module = $Params['Module']; $namedParameters = $module->getNamedParameters(); $statusId = $namedParameters['id']; $ini = eZIni::instance('merck.ini'); $db = MMImportMonitorHelper::db(); $sql = ' SELECT st.date as st_date, st.xml_file as st_xml_file, c.publisher_folder_id as c_publisher_folder_id FROM import_status as st LEFT JOIN article as a ON a.id = st.article_id LEFT JOIN content as c ON a.content_id = c.id LEFT JOIN publisher_folder as p ON c.publisher_folder_id = p.id WHERE st.id = "%s"; '; $row = reset($db->arrayQuery(sprintf($sql, $db->escapeString($statusId)))); if ( !empty( $row ) ) { $sql = "SELECT p.path as p_path FROM mm_publisher_folder WHERE p.id={$row['c_publisher_folder_id']}"; $publisherRow = reset( MMDB::instance()->arrayQuery( $sql ) ); $row['p_path'] = ( empty( $publisherRow ) ? null : $publisherRow['p_path'] ); $pathPrefix = $ini->variable('ImportMonitor', 'XmlFilePath'); $path = sprintf('%s/%s/archived/%s_%s', $pathPrefix, $row['p_path'], date('Ymd', $row['st_date']), $row['st_xml_file']); if (!empty($row['p_path']) && file_exists($path)) { header ("Content-Type:text/xml"); echo file_get_contents($path); } }
protected function synchronize() { parent::synchronize(); $ini = eZIni::instance('sqliimport.ini'); $publishersOptions = array( 'publish' => true, 'data_map' => array('default' => array('name' => $this->source['p_path'])), 'language' => $this->source['pf_default_language'] ); // Master content folder $options = array( 'publish' => false, 'remote_id' => $this->remoteId(), 'class_identifier' => self::$class_identifier, 'parent_node_id' => $ini->variable('MMSynchPublisherFolder', 'ContentRootNodeId') ); $this->content = self::create(array_merge($publishersOptions, $options)); $this->populate(); //MMSynchLog::debug($this->content, 'Synchronize content folder #' . $this->content->defaultLocation->getNodeId()); $this->publish(); // Media content folder $options = array( 'remote_id' => $this->remoteIdMedia(), 'class_identifier' => 'folder', 'parent_node_id' => $ini->variable('MMSynchPublisherFolder', 'MediaRootNodeId') ); $this->contentMedia = self::create(array_merge($publishersOptions, $options)); MMSynchLog::debug($this->contentMedia, 'Synchronize media folder #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaImage = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaImage(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Image')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaImage, 'Synchronize image media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaFile = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaFile(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'File')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaFile, 'Synchronize file media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaDownFile = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaDownFile(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Download File')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaDownFile, 'Synchronize download file media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaVideo = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaVideo(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Video')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaVideo, 'Synchronize video media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaAudio = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaAudio(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Audio')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaAudio, 'Synchronize audio media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaLink = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaLink(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Link')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaLink, 'Synchronize link media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaHtml = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaHtml(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Html')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaHtml, 'Synchronize html media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaHtmlTable = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaHtmlTable(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Html Table')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaHtml, 'Synchronize html table media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaQuiz = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaQuiz(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Quiz')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaQuiz, 'Synchronize quiz media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaHtmlMedia = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaHtmlMedia(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Html Media')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaHtmlMedia, 'Synchronize html_media media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); // User content folder $options = array( 'remote_id' => $this->remoteIdUser(), 'class_identifier' => 'user_group', 'parent_node_id' => $ini->variable('MMSynchPublisherFolder', 'UserRootNodeId') ); $this->contentUser = self::create(array_merge($publishersOptions, $options)); MMSynchLog::debug($this->contentUser, 'Synchronize user folder #' . $this->contentUser->defaultLocation->getNodeId()); // Création de la taxonomy $this->createTaxonomy(); }
protected static function getFirstSeasonDate() { if (!static::$QUIZ_SEASON_EPOCH_TIME) { $ini = eZIni::instance('merck.ini'); $startDate = $ini->variable('QuizSettings', 'SeasonsStartDate'); static::$QUIZ_SEASON_EPOCH_TIME = DateTime::createFromFormat('Y-m-d H:i:s', $startDate); } return static::$QUIZ_SEASON_EPOCH_TIME; }
/** * Log user on backend and relay cookie * * @param bool $params Login result of ESB login * @return boolean Success * @throws Exception */ protected static function backendLog($params) { $ini = eZIni::instance('merck.ini'); // Create backend request $backendUrl = $ini->variable('WSMobile', 'BackEndUrl'); $parameters = array( 'params' => MMUserLogin::encryptText(json_encode($params)), 'action' => 'update' ); $url = rtrim($backendUrl, '/') . '/loginActions.php?' . http_build_query($parameters); // Send Backend request $c = curl_init(); curl_setopt($c, CURLOPT_URL, $url); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_NOBODY, true); curl_setopt($c, CURLOPT_HEADER, true); if ( $ini->hasVariable('WSMobile', 'BackEndHeader') ) { /* @type $headers array */ $headersList = array(); $headers = $ini->variable('WSMobile', 'BackEndHeader'); foreach ( $headers as $header => $value ) { $headersList[] = sprintf('%s: %s', $header, $value); } curl_setopt($c, CURLOPT_HTTPHEADER, $headersList); } $basicAuthEnv = ( $ini->hasSection('WSMobile') && $ini->hasVariable('WSMobile', 'BasicAuthEnv') ) ? $ini->variable( 'WSMobile', 'BasicAuthEnv' ) : null; $env = ( eZINI::instance()->hasSection( 'Environment' ) && eZINI::instance()->hasVariable( 'Environment', 'Type' ) ) ? eZINI::instance()->variable( 'Environment', 'Type' ) : null; if ( is_array( $basicAuthEnv ) && in_array( $env, $basicAuthEnv ) ) { $username = $ini->variable( 'WSMobile', "BasicAuthUsername" ); $username = $username[$env]; $password = $ini->variable( 'WSMobile', "BasicAuthPassword" ); $password = $password[$env]; curl_setopt($c, CURLOPT_USERPWD, $username . ':' . $password); } $result = curl_exec($c); $errno = curl_errno($c); $error = curl_error($c); curl_close($c); if ( $result === false ) { throw new Exception(sprintf('%s (%s)', $error, $errno), 25); } // Relayed backend cookies $setCookies = array(); if ( preg_match_all('/Set-Cookie: (.*)\b/', $result, $setCookies) !== false ) { $cookies = self::cookieHeaderParse($setCookies[0]); foreach ( $cookies as $cookie ) { $expire = $cookie['expires'] ? $cookie['expires'] : 0; $path = $cookie['path'] ? $cookie['path'] : '/'; // Quick Fix : #38428 $domain = $cookie['domain'] ? str_replace('backendphp', 'www', $cookie['domain']) : ContextTool::domain(); // $domain = $cookie['domain'] ? $cookie['domain'] : ContextTool::domain(); setcookie($cookie['value']['key'], $cookie['value']['value'], $expire, $path, $domain); } } return true; }
/** * @return string */ public static function directory() { $ini = eZIni::instance('merck.ini'); return eZDir::path(array(eZSys::storageDirectory(), $ini->variable('FileSettings', 'StaticDir'))); }
public function __destruct() { $ini = eZIni::instance('site.ini'); $fileDirectory = $ini->variable('FileSettings', 'VarDir') . '/' . $ini->variable('FileSettings', 'CacheDir') . '/synch'; $files = glob( $fileDirectory . '/*.bin' ); foreach($files as $file) @unlink($file); }
function buildGlossaryRegExp() { // initialisation $ini = eZIni::instance('glossary.ini'); $glossaryNodeId = $ini->variable('GeneralSettings', 'GlossaryNodeID'); $definitionClassIdentifier = $ini->variable('GeneralSettings', 'DefinitionClassIdentifier'); $titleAttributeIdentifier = $ini->variable('GeneralSettings', 'TitleAttributeIdentifier'); $definitionAttributeIdentifier = $ini->variable('GeneralSettings', 'DefinitionAttributeIdentifier'); $exceptionTags = $ini->variable('GeneralSettings', 'ExceptionTags'); $exceptionTagsString = implode('|', $exceptionTags); // Fetch glossary definitions $params = array('Depth' => 0, 'ClassFilterType' => 'include', 'ClassFilterArray' => array($definitionClassIdentifier)); $definitions = eZContentObjectTreeNode::subTreeByNodeID($params, $glossaryNodeId); if (count($definitions) == 0) { throw new Exception(); } // Fetch glossary informations $glossaryNode = eZContentObjectTreeNode::fetch($glossaryNodeId); if (!is_object($glossaryNode)) { throw new Exception(); } $glossaryUrl = $glossaryNode->attribute('url_alias'); // foreach definition : save search pattern and fetch template for replacement $matchArray = array(); $replaceArray = array(); foreach ($definitions as $definition) { $object = $definition->object(); if (!is_object($object)) { throw new Exception(); } $dataMap = $object->dataMap(); $title = $dataMap[$titleAttributeIdentifier]->content(); $definition = $dataMap[$definitionAttributeIdentifier]->content(); $matchArray[] = preg_quote($title, '/'); $tpl = eZTemplate::factory(); $tpl->setVariable('title', $title); $tpl->setVariable('glossaryUrl', $glossaryUrl); $tpl->setVariable('definition', $definition); $replaceArray[strtolower($title)] = $tpl->fetch('design:ca_glossary.tpl'); } // match the current definition between a word beginning and a word end (\b) // and not followed by closing exception tags : (?!.*<\/(".$exceptionTagsString.")>+) // and not in between < and > that is to say in a tag, for example title of a img : (?![^(>|<)]*>+) $regExp = "/\\b(" . implode('|', $matchArray) . ")\\b(?!.*<\\/(" . $exceptionTagsString . ")>+)(?![^(>|<)]*>+)/i"; $this->glossaryArray = $replaceArray; return $regExp; }
/** * @param array $uncrytedTicket * @return MMUsers */ public static function createOrUpdateMMUser( $uncrytedTicket ) { $userId = $uncrytedTicket['uuid']; $customerType = $uncrytedTicket['customerType']; if ( isset($uncrytedTicket['userSpeciality']) ) { $userSpeciality = $uncrytedTicket['userSpeciality']; } else { $userSpeciality = $uncrytedTicket['mainSpeciality']; } $state = $uncrytedTicket['state']; $country = eZIni::instance('site.ini')->variable('RegionalSettings','CountryOfRegistration'); $language = $uncrytedTicket['language']; /** * @todo: check $language entry format and parse it if needed to get an iso code on 2 chars */ $iniMapping = eZINI::instance('mercktaxonomymapping.ini'); $taxonomyType = $iniMapping->variable( 'Taxonomy', 'SpecialtiesTaxonomyType'); $specialtiesMappingINI = $iniMapping->variable( 'Taxonomy', 'Specialties' ); $customerTypesMappingINI = $iniMapping->variable( 'Taxonomy', 'CustomerTypes' ); if($taxonomyType != "transitive") { if ( isset( $customerTypesMappingINI[$customerType] ) ) { $customerType = $customerTypesMappingINI[$customerType]; } else { $customerType = $customerTypesMappingINI['Default']; self::updateDBWithEmptyValue( 'empty-CT', $userId, $country ); } if ( isset( $specialtiesMappingINI[$userSpeciality] ) ) { $userSpeciality = $specialtiesMappingINI[$userSpeciality]; } else { $userSpeciality = $specialtiesMappingINI['Default']; self::updateDBWithEmptyValue( 'empty-SPE', $userId, $country ); } } else { $customerTypesMapping = SolrSafeOperatorHelper::getCustomerTypes(); if ( !isset( $customerTypesMapping["$customerType"] ) ) { // fill with default value $customerType = $customerTypesMappingINI['Default']; self::updateDBWithEmptyValue( 'empty-CT', $userId, $country ); } $specialtiesMapping = SolrSafeOperatorHelper::getUserSpecialities(); if ( !isset( $specialtiesMapping[(string)$userSpeciality] ) ) { // fill with default value $userSpeciality = $specialtiesMappingINI['Default']; self::updateDBWithEmptyValue( 'empty-SPE', $userId, $country ); } } /** @var MMUsers $user */ $user = MMUsers::fetchByIdAndCountry( $userId, $country ); $isModifiedUser = false; if ( $user ) { if ( $customerType != $user->attribute('customer_type') ) { $user->setAttribute('customer_type', $customerType); $isModifiedUser = true; } if ( $userSpeciality !== $user->attribute('user_speciality') ) { $mainSpeciality = UserSpecialityContentSpeciality::getContentSpeciality ( $userSpeciality ); $defaultAdditionalSpecialities = MMUserLogin::getAddSpecialties($mainSpeciality); $user->setAttribute('user_speciality', $userSpeciality); // mapping main_spe additional spe $preferences = $user->getPreferences(); $userAditionalSpecialities = $preferences['specialities']; array_shift($userAditionalSpecialities); $tmp = array_diff( $userAditionalSpecialities, $defaultAdditionalSpecialities ); if( empty( $tmp ) ) // we don't modify the user spes if he has changed his selection { $preferences["specialities"] = MMUserLogin::getAddSpecialties($mainSpeciality); $user->setPreferences($preferences); } $user->setPreferences($preferences); // The user specialty has been modified, we need to update it for Quiz-type applications of the current cluster if( CacheApplicationTool::buildLocalizedApplicationByIdentifier('train-the-brain') instanceof ApplicationLocalized) { $playerScoring = QuizPlayerScoring::fetchOneBy( array( 'application_id' => (int)$app->applicationObject->id, 'uuid' => $user->attribute( 'uuid' ) ) ); // Checking if the current user has scored at least once for the application if( $playerScoring ) { foreach( FacetFilteringTool::getTaxoTranslationWithIDs( 'user_specialty' ) as $k => $t ) { if( ($k . "") === ($userSpeciality . "") ) { // Updating the user specialty id in the player scoring table $playerScoring->setAttribute( 'user_specialty', $t['id'] ); $playerScoring->store(); } } // Scheduling a ranking update QuizPendingRankingUpdate::add( $playerScoring->attribute( 'global_ranking' ), $app->applicationObject->id ); } } $isModifiedUser = true; } if ( $country != $user->attribute('country') ) { $user->setAttribute('country', $country); $isModifiedUser = true; } if( $language != $user->attribute( 'language' ) ) { $user->setAttribute('language', $language ); $isModifiedUser = true; } if ( $state != $user->attribute('state') ) { $user->setAttribute('state', $state); $isModifiedUser = true; } if ( $isModifiedUser ) { $user->setAttribute('date_update', time()); $user->store(); } // set gpnotebook hand shake data in preferences if($user->getGPNotebookHS()) { SolrSafeOperatorHelper::getAndStoreGPNotebookHS(); } } else { $mainSpeciality = UserSpecialityContentSpeciality::getContentSpeciality ( $userSpeciality ); $insertedArray = array ( 'uuid' => $userId, 'customer_type' => $customerType, 'user_speciality' => $userSpeciality, 'country' => $country, 'language' => $language, 'date_update' => time(), 'state' => $state, ); $user = new MMUsers ($insertedArray); $user->store(); // mapping main_spe additional spe $preferences = $user->getPreferences(); $preferences["specialities"] = MMUserLogin::getAddSpecialties($mainSpeciality); $user->setPreferences($preferences); $isModifiedUser = true; } if ( $isModifiedUser ) { // Tag Lyris user to be reimported : $user->tagLyrisToProcess(); } return $user; }
/** * The modify method gets the current content object AND the list of * Solr Docs (for each available language version). * * @param eZContentObject $contentObject * @param eZSolrDoc[] $docList */ public function modify( eZContentObject $contentObject, &$docList ) { /* @var eZContentObjectTreeNode $contentMainNode */ $contentMainNode = $contentObject->mainNode(); $contentObjectLanguages = $contentObject->allLanguages(); $articleLanguageArray = array_keys($contentObjectLanguages); $publisherFolderNodeId = PublisherFolderTool::getPublisherNodeIdFromArticleNode($contentMainNode); $isMerckManualShowcase = false; // Depth : 0 => father article, 1+ => child article $articleRelativeDepth = $contentMainNode->attribute('depth') - 4; if ( is_null($publisherFolderNodeId) ) return; $publisherFolderInfos = PublisherFolderTool::getPublisherFolderInfosFromNodeId($publisherFolderNodeId); if ( !$publisherFolderInfos ) return; $publisherFolderRelations = PublisherFolderTool::getPublisherFolderRelations($publisherFolderInfos['path']); if ( !$publisherFolderRelations || count($publisherFolderRelations['clusters']) === 0 ) return; // node remote $remote = $contentMainNode->attribute("remote_id"); $this->addValueToDoc( $docList, 'attr_node_remote_s', $remote); $this->addValueToDoc( $docList, 'attr_relative_depth_i', $articleRelativeDepth); foreach ( $publisherFolderRelations['clusters'] as $cluster => $applications ) { ClusterTool::setCurrentCluster( $cluster ); $applicationIdentifier = $applications[0]; /* @var $applicationLocalized ApplicationLocalized */ $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier ); if ( !($applicationLocalized instanceof ApplicationLocalized) ) { if (count($applications) == 1) { unset($publisherFolderRelations['clusters'][$cluster]); continue; } $applicationIdentifier = $applications[1]; $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier ); if ( !($applicationLocalized instanceof ApplicationLocalized) ) { unset($publisherFolderRelations['clusters'][$cluster]); continue; } $publisherFolderRelations['clusters'][$cluster] = array ($applicationIdentifier); } // visibility per cluster $isVisible = ObjectVisibilityManager::isVisible($contentMainNode->attribute('contentobject_id'), $cluster); $this->addValueToDoc( $docList, 'attr_is_invisible_' . $cluster . '_b', !$isVisible ); if (!isset(self::$_applicationIdentifierToId[$applicationIdentifier])) self::$_applicationIdentifierToId[$applicationIdentifier] = $applicationLocalized->applicationObject()->attribute ('id'); $publisherFolder = $applicationLocalized->getPublisherFolderFromPath($publisherFolderInfos['path']); $publisherLanguages = $publisherFolder->getLanguages(); $publisherAndArticleLanguages = array_intersect($publisherLanguages, $articleLanguageArray); if ( count($publisherAndArticleLanguages) == 0 ) continue; $primaryLanguage = reset($publisherAndArticleLanguages); $contentMainNode->setCurrentLanguage($primaryLanguage); // publisher folder languages $languageKey = 'subattr_language_' . $cluster . '____s'; $formatedLanguages = array_map( array('kezfSolrArticleIndex', 'languageCode') , $publisherAndArticleLanguages ); $indexLanguages = array_unique( $formatedLanguages ); $this->addValueToDoc( $docList, $languageKey, $indexLanguages, true, false ); // Meck manual sections if( $applicationIdentifier == MerckManualShowcase::mainApplicationIdentifier() ) $isMerckManualShowcase = true; // url computation /* @var eZContentObjectAttribute[] $dataMap */ $dataMap = $contentMainNode->dataMap(); ClusterTool::setCurrentCluster( $cluster ); if( $applicationIdentifier == MerckManualShowcase::mainApplicationIdentifier() ) { $urlContent = preg_replace( '#^([^/]+/){2}#', '', MerckManualFunctionCollection::getMerckManualNodeUrl( $applicationIdentifier, $contentMainNode, $primaryLanguage ) ); } else $urlContent = preg_replace( '#^([^/]+/){2}#', '', $contentMainNode->urlAlias() ); $this->addValueToDoc( $docList, 'attr_' . $cluster . '_url_s', $urlContent); $hasImage = array(); for ( $mediaCase = 0; $mediaCase<=2; $mediaCase++ ) { $hasImage[$mediaCase] = NodeOperatorHelper::hasImageArticle($contentMainNode, $mediaCase); } self::addValueToDoc( $docList, 'attr_has_image_' . $cluster . '_bst', base64_encode(json_encode($hasImage)) ); $db = MMDB::instance(); // index rating $row = $db->arrayQuery(sprintf("SELECT * FROM mm_rating_remote WHERE cluster_identifier = '%s' AND remote_id = '%s'", $cluster, $contentObject->remoteID())); if(count($row) && $row[0]["counter"] > 5 ) { self::addValueToDoc( $docList, 'attr_content_rating_'.$cluster.'_f', $row[0]["total"]/$row[0]["counter"] ); //update to_reindex $db->query(sprintf("UPDATE mm_rating_remote SET to_reindex=0 WHERE cluster_identifier = '%s' AND remote_id = '%s'", $cluster, $contentObject->remoteID())); } // index views $row = $db->arrayQuery(sprintf("SELECT * FROM mm_readcount_remote WHERE cluster_identifier = '%s' AND remote_id = '%s'", $cluster, $contentObject->remoteID())); if(count($row) && $row[0]["count"] > 0 ) { self::addValueToDoc( $docList, 'attr_view_counter_'.$cluster.'_i', $row[0]["count"] ); //update to_reindex $db->query(sprintf("UPDATE mm_readcount_remote SET to_reindex=0 WHERE cluster_identifier = '%s' AND remote_id = '%s'", $cluster, $contentObject->remoteID())); } if( $dataMap && $dataMap['media_content']->hasContent() ) { $mediaContent = $dataMap['media_content']->content(); $mediaRelationList = $mediaContent['relation_list']; $entries = array(); $firstLink = true; $totalQuizzes = 0; foreach ( $mediaRelationList as $mediaRelation ) { $mediaObjectId = $mediaRelation['contentobject_id']; $mediaClass = $mediaRelation['contentclass_identifier']; /******************************************************************************* * TODO : Adapt after PF Refactor *******************************************************************************/ if ( !in_array($mediaClass, array('image', 'quiz', 'link')) ) continue; if ( $mediaClass === 'image' ) { if ( count( $entries ) >= 3 ) continue; // Language is DEPRECATED, Fake Language instead $entries[] = $mediaObjectId . ";dep-DP"; /******************************************************************************* * TODO : End : Adapt after PF Refactor *******************************************************************************/ } elseif ( ( $mediaClass === 'link' && $firstLink ) || $mediaClass === 'quiz' ) { $mediaObject = eZContentObject::fetch( $mediaObjectId ); if ( !$mediaObject ) continue; /* @var eZContentObjectAttribute[] $mediaDatamap */ $mediaDatamap = $mediaObject->dataMap(); if ( !is_array($mediaDatamap) ) continue; if ( $mediaClass === 'link' ) { if (!$mediaDatamap['url']->hasContent()) continue; $firstLink = false; self::addValueToDoc( $docList, 'attr_media_content_link_' . $cluster . '____ms', $mediaDatamap['url']->content(), false ); } elseif ( $mediaClass === 'quiz' ) { if ( $mediaDatamap['replies']->hasContent() ) { $quizReplies = $mediaDatamap['replies']->content(); $quizReplies = $quizReplies->attribute('columns'); $quizReplies = $quizReplies['sequential'][1]['rows']; if ( count($quizReplies) > 0 ) self::addValueToDoc( $docList, 'attr_media_content_quiz_replies_' . $cluster . '____ms', $quizReplies, true); } if ( !empty($mediaDatamap['question']->DataText) ) { self::addValueToDoc( $docList, 'attr_media_content_quiz_question_' . $cluster . '_ms', trim(strip_tags($mediaDatamap['question']->DataText)), false ); } if ( !$mediaDatamap['points']->hasContent() ) continue; $totalQuizzes+= $mediaDatamap['points']->content(); } } } $withMediaDuration = true; $typeMedias = NodeOperatorHelper::getPictosMedia( $contentMainNode, $withMediaDuration ); $typeMediasSerialized = base64_encode( json_encode($typeMedias) ); // getPictosMedia as solr field self::addValueToDoc( $docList, 'attr_media_content_types_' . $cluster . '_bst', $typeMediasSerialized, false ); // getMediaCount as solr field $mediaCount = NodeOperatorHelper::getMediaCount($contentMainNode); self::addValueToDoc( $docList, 'attr_media_content_count_' . $cluster . '_i', $mediaCount, false ); // Used only for Quizz if ( $totalQuizzes > 0 ) self::addValueToDoc( $docList, 'attr_media_content_quiz_points_' . $cluster . '_i', $totalQuizzes, false ); } unset($isHidden); } ClusterTool::resetCurrentCluster(); $concernedNode = $contentMainNode; $concernedNode->setCurrentLanguage($articleLanguageArray[0]); if ( $contentMainNode->attribute('depth') > 4 ) { $concernedNode = $contentMainNode->fetchParent(); $concernedNode->setCurrentLanguage($articleLanguageArray[0]); } /* @type $concernedDM eZContentObjectAttribute[] */ $concernedDM = $concernedNode->dataMap(); $tags = $concernedDM['tags']; $MerckManualAboutSectionId = eZIni::instance('merck.ini')->variable('MerckManualAboutSettings', 'SectionSourceId'); $taxonomiesAttribute = $concernedDM['serialized_taxonomies']; if( $taxonomiesAttribute instanceof eZContentObjectAttribute && $taxonomiesAttribute->hasContent() ) { $taxonomies = $taxonomiesAttribute->content(); foreach( array_keys($publisherFolderRelations['clusters']) as $cluster ) { self::addValueToDoc( $docList, "attr_exclude_from_search_{$cluster}_b", $MerckManualAboutSectionId && in_array($MerckManualAboutSectionId, $taxonomies['section']), false ); } } if( $tags instanceof eZContentObjectAttribute && $tags->hasContent() ) self::addValueToDoc( $docList, 'subattr_tags____ms', explode("|", $tags->content()) ); if ( $isMerckManualShowcase ) $this->processSpecificMerckManual($docList, $concernedNode, $concernedDM, $publisherFolderRelations); foreach ( $publisherFolderRelations['clusters'] as $cluster => $applications ) { ClusterTool::setCurrentCluster( $cluster ); foreach( $applications as $key => $applicationIdentifier ) { if ( !isset(self::$_applicationIdentifierToId[$applicationIdentifier]) ) { $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier ); if( !($applicationLocalized instanceof ApplicationLocalized) ) { eZDebug::writeError( sprintf('Cluster: %s; Identifier: %s; ObjectId: %s', $cluster, $applicationIdentifier, $contentObject->attribute('id') ), 'Error getting application localized' ); unset( $publisherFolderRelations['clusters'][$cluster][$key] ); } else self::$_applicationIdentifierToId[$applicationIdentifier] = $applicationLocalized->applicationObject()->attribute('id'); } } } ClusterTool::resetCurrentCluster(); $applicationIds = array(); foreach ( $publisherFolderRelations['clusters'] as $cluster => $applications ) foreach( $applications as $applicationIdentifier ) $applicationIds[] = self::$_applicationIdentifierToId[$applicationIdentifier]; $uniqueApplicationIds = array_unique($applicationIds); foreach( $docList as $languageCode => $doc ) { $dataMap = $contentObject->fetchDataMap(false, $languageCode); $headline = $dataMap['headline']->content(); $headlineLowerCase = mb_strtolower( StringTool::removeAccents($headline, 'utf-8', false), 'utf-8' ); $unaccentedFirstLetter = mb_substr($headlineLowerCase, 0, 1, 'utf-8'); $doc->addField( 'attr_headline_first_letter_lc_s', $unaccentedFirstLetter ); $doc->addField( 'attr_headline_lc_s', $headlineLowerCase ); foreach( $uniqueApplicationIds as $id ) { $doc->addField( 'subattr_local_application___source_id____s', $id ); } foreach( $publisherFolderRelations['clusters'] as $cluster => $applications ) { foreach( $applications as $applicationIdentifier ) { $doc->addField('subattr_local_application___source_mixed____s', $cluster . '##unused##' . self::$_applicationIdentifierToId[$applicationIdentifier]); } } } }