/** * @param string $clusterIdentifier * @param string $applicationIdentifier * @param string $bannerType * @return string */ public static function getStaticPath( $clusterIdentifier, $applicationIdentifier, $bannerType ) { if ( $clusterIdentifier !== ClusterTool::clusterIdentifier() ) { ClusterTool::setCurrentCluster($clusterIdentifier); } $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier ); if ( !($applicationLocalized instanceof ApplicationLocalized) ) { return null; } $bannerArray = $applicationLocalized->getBanners(); if( isset( $bannerArray[$bannerType] ) && !empty( $bannerArray[$bannerType] ) ) { return preg_replace( '#/extension#', 'extension/', $bannerArray[$bannerType] ); } return null; }
/** * @param string $text * @return string */ public function generateAndSaveImage( $text = null ) { if ( is_null( $text ) ) { ClusterTool::setCurrentCluster( $this->clusterIdentifier ); $text = ezpI18n::tr( $this->context, $this->source ); } $temp_file = sys_get_temp_dir() . "/misc" . uniqid() . '.png'; $convertExecutablePath = eZINI::instance( 'image.ini' )->variable( 'ImageMagick', 'ExecutablePath' ); $convertExecutable = eZINI::instance( 'image.ini' )->variable( 'ImageMagick', 'Executable' ); $cmd = "-background transparent -fill lightgray -font './extension/ezoscar/design/oscar/font/arial.ttf' -pointsize 11 label:{$text}"; exec( "$convertExecutablePath/$convertExecutable $cmd $temp_file" ); $imageFile = file_get_contents( $temp_file ); $this->fileUtils->storeContents( $imageFile ); unlink( $temp_file ); return $imageFile; }
/** * Changes clusterIdentifier state internally ! * * @param string $clusterIdentifier */ public static function setClusterIdentifier ($clusterIdentifier) { if ($clusterIdentifier == "") ClusterTool::resetCurrentCluster(); elseif ( in_array($clusterIdentifier, ClusterTool::globCluster()) || $clusterIdentifier == 'cluster_master' ) ClusterTool::setCurrentCluster($clusterIdentifier); }
/** * @see ezfSolrDocumentFieldBase::getData() * @return array */ public function getData() { $data = parent::getData(); $content = $this->ContentObjectAttribute->content(); /* @var $content array */ foreach ( array_merge( self::taxonomyAttribute(), array_keys($content) ) as $taxonomyIdentifier ) { $taxonomyValues = isset( $content[$taxonomyIdentifier] ) ? $content[$taxonomyIdentifier] : array(); $subattrSourceIdValues = array(); $subattrSourceIdFieldName = self::getCustomSubattributeFieldName( $taxonomyIdentifier, 'source_id'); foreach ( $taxonomyValues as $taxonomyValue ) { if( preg_match( '#^symptom_.*$#', $taxonomyValue ) ) { $sourceKey = $taxonomyValue; $subattrSourceIdValues[] = $sourceKey; // we need a few more things for the symptoms /* @type $node eZContentObjectTreeNode */ $contentObject = $this->ContentObjectAttribute->object(); $node = $contentObject->mainNode(); $clusters = NodeTool::getArticleClusters($node); foreach( $clusters as $cluster ) { ClusterTool::setCurrentCluster($cluster); $ini = eZINI::fetchFromFile('extension/'.$cluster.'/settings/site.ini'); $node->setCurrentLanguage( $ini->variable('RegionalSettings', 'ContentObjectLocale') ); $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( MerckManualShowcase::mainApplicationIdentifier() ); if ( !$applicationLocalized ) continue; $customSymptomAttributeKey = 'attr_custom_symptom_'.$cluster.'_s'; $labelTranslations = FacetFilteringTool::getTaxonomyTranslation( 'symptom' ); $label = $labelTranslations[$sourceKey]; $url = preg_replace( '#^[^/]+#', '', MerckManualFunctionCollection::getMerckManualNodeUrl( 'meck-manual-showcase', $node, $ini->variable('RegionalSettings', 'ContentObjectLocale') ) ); ClusterTool::resetCurrentCluster(); $customSymptomAttributeValueParts = array( mb_strtolower(mb_substr(StringTool::removeAccents( StringTool::CJK2Pinyin($label) ), 0, 1)), $label, $url ); $data[$customSymptomAttributeKey] = implode( '##', $customSymptomAttributeValueParts ); } } else if ( preg_match('#^222\.[0-9]+$#', $taxonomyValue ) ) { $sourceKey = $taxonomyValue; $subattrSourceIdValues[] = $sourceKey; /* @type $node eZContentObjectTreeNode */ /* @type $dataMap eZContentObjectAttribute[] */ $contentObject = $this->ContentObjectAttribute->object(); $node = $contentObject->mainNode(); $clusters = NodeTool::getArticleClusters($node); $customSymptomAttributeValueParts = array( $content['layer_natom'][0], $content['sub_layer_natom'][0], ); foreach( $clusters as $cluster ) { ClusterTool::setCurrentCluster($cluster); $customSymptomAttributeKey = 'attr_custom_layer_sublayer_natom_'.$cluster.'_s'; $data[$customSymptomAttributeKey] = implode( '##', $customSymptomAttributeValueParts ); ClusterTool::resetCurrentCluster(); } } else $subattrSourceIdValues[] = trim( $taxonomyValue ); } $data[$subattrSourceIdFieldName] = empty($subattrSourceIdValues) ? '' : $subattrSourceIdValues; } return $data; }
public function domain( $in = null ) { if ( is_null( $in ) ) return $this->_domain; if ( !isset($this->domains[$in]) ) throw new \InvalidArgumentException( "No existing cluster give: ".$in ); $this->_domain = $in; $this->_cluster = $this->domains[$in]; \ClusterTool::setCurrentCluster( $this->_cluster ); $this->_clusterMerckIni = \eZINI::fetchFromFile( 'extension/'.$this->_cluster.'/settings/merck.ini.append.php' ); $this->_clusterSiteIni = \eZINI::fetchFromFile( 'extension/'.$this->_cluster.'/settings/site.ini.append.php' ); }
$importMonitor->setAttribute( 'date_insert', time() ); $importMonitor->setAttribute( 'new_relic_report', 0 ); $importMonitor->store(); } catch( \Exception $e ) { $this->script->shutdown( 0, 'An error occured while uploading the XML to the FTP' ); return; } } } ftp_pasv( $resource, true ); ftp_close( $resource ); } } /** * @param string $metricName * @param int $value */ protected function reportToNewRelic( $metricName, $value ) { $this->newRelicApi->setCustomMetric( $metricName, $value * 1000 ); } } $cli = eZCLI::instance(); ClusterTool::setCurrentCluster( 'cluster_master' ); $importMonitor = new newRelicImportMonitoringCronjob( $script, $cli ); $importMonitor->run();
/** * @param array $params * @param string $cluster_identifier */ function __construct( $params, $cluster_identifier ) { $this->_params = $params; $this->_type = isset( $params['type'] ) ? $params['type'] : false; $this->_frequency = isset( $params['frequency'] ) ? $params['frequency'] : false; $this->_customerType = ( isset( $params['customer_type'] ) && $params['customer_type'] != false ) ? explode(self::PARAM_SEPARATOR, $params['customer_type']) : false; $this->_specialty = ( isset( $params['specialty'] ) && $params['specialty'] != false ) ? explode(self::PARAM_SEPARATOR, $params['specialty']) : false; $this->_publisher = isset( $params['publisher'] ) ? $params['publisher'] : false; $this->_allowCache = !( $this->_customerType || $this->_specialty ); $this->_beginDate = isset( $params['begin'] ) ? $params['begin'] : false; $this->_endDate = isset( $params['end'] ) ? $params['end'] : false; $this->_outputMode = isset( $params['outputMode'] ) && in_array( $params['outputMode'], self::$outputModeWhiteList ) ? $params['outputMode'] : false; $this->_params = array( 'type' => $this->_type, 'frequency' => $this->_frequency, 'customer_type' => $this->_customerType, 'specialty' => $this->_specialty, 'publisher_folder' => $this->_publisher ); $this->_cluster_identifier = $cluster_identifier; $this->_configurations = self::createConfigurationsForCluster( $cluster_identifier, $this->_type ); ClusterTool::setCurrentCluster( $cluster_identifier ); $varDir = eZINI::instance( 'site.ini' )->variable( 'FileSettings', 'VarDir' ); if(isset( $params['path'] )) { $this->_path = $varDir . $params['path']; } else { $this->_path = $varDir . $this->_path; } $this->_applicationsData = array(); //time parameters if($this->_beginDate) { $beginDatetime = new DateTime(); $beginDatetime = $beginDatetime->setTimestamp($this->_beginDate); $this->_beginDate = $beginDatetime->format("Y-m-d\TH:i:s\Z"); } if(isset($params['end']) && $params['end']) { $endDatetime = new DateTime(); $endDatetime = $endDatetime->setTimestamp($this->_endDate); $this->_endDate = $endDatetime->format("Y-m-d\TH:i:s\Z"); } }
<?php $cli = eZCLI::instance(); $db = eZDB::instance(); $quizPlayerScoringTable = QuizPlayerScoring::SQL_TABLENAME; $quizAppsToCheckQuery = "SELECT DISTINCT application_id, cluster_identifier FROM $quizPlayerScoringTable"; $quizAppsToCheck = $db->arrayQuery( $quizAppsToCheckQuery ); if( $quizAppsToCheck ) { foreach ($quizAppsToCheck as $quizApp) { ClusterTool::setCurrentCluster($quizApp['cluster_identifier']); $shouldRecalculate = false; $clusterIdentifier = $quizApp['cluster_identifier']; $applicationId = $quizApp['application_id']; $checkForErrorsInLeaderboardQuery = "SELECT score, GROUP_CONCAT(global_ranking) as global_rankings FROM $quizPlayerScoringTable WHERE cluster_identifier = '$clusterIdentifier' AND application_id = $applicationId AND ( nb_correct > 0 OR nb_wrong > 0 ) GROUP BY score DESC"; $checkForErrorsInLeaderboard = $db->arrayQuery($checkForErrorsInLeaderboardQuery); if ($checkForErrorsInLeaderboard) { $lastGlobalRanking = null;
public static function initVars($year, $cluster, $auto) { if($auto) { self::$autoMode = true; self::$year = date('Y', strtotime('now')); self::$month = date('m', strtotime('now')); self::$batch = self::getBatchNumberFromToday(); } else { self::$year = $year; } ClusterTool::setCurrentCluster($cluster); self::$tripApplication = CacheApplicationTool::buildLocalizedApplicationByIdentifier('trip'); self::$tripIds = self::getAllTripLocalizedIds(); $tab = FacetFilteringTool::getTaxonomyTranslation('customer_type'); foreach($tab as $key => $val) { self::$customerTypeIds[] = $key; } }
<?php $actionName = MMRssGenerator::$actionName; $db = eZDB::instance(); $query = "SELECT * FROM ezpending_actions WHERE action = '{$actionName}'"; $newslattersToGenerate = $db->arrayQuery( $query ); foreach ( $newslattersToGenerate as $newsletter ) { $parameters = unserialize( $newsletter['param'] ); ClusterTool::setCurrentCluster( $parameters['cluster_identifier'] ); $rssGenerator = new MMRssGenerator( $parameters['params'], $parameters['cluster_identifier'] ); if ( $rssGenerator->getXML( true ) ) { // delete this pending action $db->query( sprintf( "DELETE FROM ezpending_actions WHERE id = %d", $newsletter['id'] ) ); } }
$filename = isset($options['arguments'][2]) ? $options['arguments'][2] : null; $cluster = isset($options['arguments'][1]) ? $options['arguments'][1] : null; 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, ',', '"') )
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; }
$options = $script->getOptions( "[clusterIdentifier:][countryCode:]", "", array( 'clusterIdentifier' => 'Cluster identifier', 'countryCode' => 'Country code' ) ); $script->startup(); $script->initialize(); if( $options['clusterIdentifier'] && $options['countryCode'] ) { $updated = 0; $lowestRankingsPerQuizApp = array(); $playerScoringRows = QuizPlayerScoring::fetchBy( array( 'cluster_identifier' => array( array( $options['clusterIdentifier'] ) ) ) ); if( $playerScoringRows ) { ClusterTool::setCurrentCluster( $options['clusterIdentifier'] ); $us = FacetFilteringTool::getTaxoTranslationWithIDs( 'user_specialty' ); foreach( $playerScoringRows as $playerScoring ) { $user = MMUsers::fetchByIdAndCountry( $playerScoring->attribute( 'uuid' ), $options['countryCode'] ); if( $user ) { if( isset( $us[$user->attribute( 'user_speciality' )] ) && $us[$user->attribute( 'user_speciality' )]['id'] != $playerScoring->attribute( 'user_specialty' ) ) { if( !isset( $lowestRankingsPerQuizApp[$playerScoring->attribute( 'application_id' )] ) || ( isset( $lowestRankingsPerQuizApp[$playerScoring->attribute( 'application_id' )] ) && $lowestRankingsPerQuizApp[$playerScoring->attribute( 'application_id' )] < (int)$playerScoring->attribute( 'global_ranking' ) ) ) $lowestRankingsPerQuizApp[$playerScoring->attribute( 'application_id' )] = (int)$playerScoring->attribute( 'global_ranking' ); $oldUS = $playerScoring->attribute( 'user_specialty' ); $playerScoring->setAttribute( 'user_specialty', $us[$user->attribute( 'user_speciality' )]['id'] ); $playerScoring->store(); $updated++; $cli->output( "Updated user speciality (" . $oldUS . " -> " . $us[$user->attribute( 'user_speciality' )]['id'] . ") in scoring data for user " . $playerScoring->attribute( 'uuid' ) );
$script = eZScript::instance( array( 'description' => ( 'Import Trip XML into merck database' ), 'use-modules' => true, 'use-extensions' => true, 'debug-output' => false, ) ); $script->startup(); $script->initialize(); $options = $script->getOptions( '', "", array( ) ); ClusterTool::setCurrentCluster('cluster_uk'); $importManager = new BBCImportManager(); try { $importedArticles = $importManager->fetchFeedContents()->parseFeed()->processImport(); $cli->output("Added {$importedArticles} to indexation queue"); } catch (Exception $e) { $cli->error($e->getMessage()); $script->shutdown(1); } $script->shutdown(0); class BBCImportManager { const FEED_URL = 'http://feeds.bbci.co.uk/news/health/rss.xml';
/** * @param string$clusterIdentifier * @param bool $backupExisting * @param bool $includeTimestamp * @return array * @throws Exception */ public function generateSpriteForCluster($clusterIdentifier, $backupExisting = true, $includeTimestamp = true) { $outputFile = $this->buildFilePath($this->outputPath, array($clusterIdentifier)); $timestampOutputFile = $this->generateFileName($outputFile, $includeTimestamp); $generatedSpriteName = substr($timestampOutputFile, strrpos($timestampOutputFile, '/') + 1); ClusterTool::setCurrentCluster( $clusterIdentifier ); $lessPath = "extension/{$clusterIdentifier}/design/oscar/stylesheets/"; $icoSprite = "/ico_sprite.png"; $offsetStep = 95; $crop = $offsetStep * 2; $mobileStep = 83; $spriteConvertOptions = " -crop x{$crop}+0+0 "; $globalConvertOptions = " -append -quality 80%"; $applicationList = CacheApplicationTool::clusterApplications(); $cssList = array(); $icoList = array(); foreach( $applicationList as $application ) { $icoCss = 'ico_'.SolrSafeOperatorHelper::getAppIdentifierForIcon( $application->applicationObject->identifier ); $icoFile = StaticData::clusterFilePath( $clusterIdentifier, 'apps/'.$application->applicationObject->identifier.$icoSprite, true, true ); if ( ! file_exists( $icoFile ) ) { $icoFile = StaticData::clusterFilePath( 'default', 'apps/'.$application->applicationObject->identifier.$icoSprite, true, true ); } if ( file_exists( $icoFile ) && ! in_array( $icoCss, $cssList ) ) { $cssList[] = $icoCss; $icoList[] = $icoFile; } } if (empty($icoList)) { throw new \Exception("No icons found for cluster {$clusterIdentifier}", 0); } if ($backupExisting && file_exists($outputFile)) { rename($outputFile, $outputFile . '.bak'); } $convertBinPath = $this->convertBinPath; $cmd = 'export PATH=$PATH:' . $convertBinPath . '; convert ' . implode( $spriteConvertOptions, $icoList ) . "{$spriteConvertOptions} {$globalConvertOptions} {$outputFile}"; $cmdStatus = 0; $cmdOutput = array(); exec($cmd, $cmdOutput, $cmdStatus); if ($cmdStatus != 0) { return array( 'errorCode' => $cmdStatus, 'generateSpriteCommand' => $cmd, 'error' => implode('\n', $cmdOutput), ); } $css = " #app-catalog a.app-bar-access-app-library .poster{ background-image: none !important; } #app-catalog a .poster, #hide-app a .poster, .item-apps .batch .wrap > a .poster, .item-related-app .batch .wrap > a .poster{ background-image:url(/esibuild/static/{$clusterIdentifier}/{$generatedSpriteName}); background-repeat: no-repeat; } "; $cssMobile = " #app-catalog a.app-bar-access-app-library .poster{ background-image: none !important; } #app-catalog a .poster, #hide-app a .poster, .item-apps .batch .wrap > a .poster, .item-related-app .batch .wrap > a .poster{ background-image:url(/esibuild/static/{$clusterIdentifier}/{$generatedSpriteName}); background-repeat: no-repeat; background-size: {$mobileStep}px auto !important; } "; $offset = 0; $offsetMobile = 0; foreach( $cssList as $key => $cssStyle ) { $css .= " #app-catalog a .poster.$cssStyle, #hide-app a .poster.$cssStyle, .item-apps .batch .wrap > a .poster.$cssStyle, .item-related-app .batch .wrap > a .poster.$cssStyle{ background-position: 0 -{$offset}px !important; } "; $cssMobile .= " #app-catalog a .poster.$cssStyle, #hide-app a .poster.$cssStyle, .item-apps .batch .wrap > a .poster.$cssStyle{ background-position: 0 -{$offsetMobile}px !important; } "; $offset += $offsetStep; $offsetMobile += $mobileStep; $css .= " #app-catalog a:hover .poster.$cssStyle, #app-catalog a:active .poster.$cssStyle, #app-catalog a.active .poster.$cssStyle, #hide-app a:active .poster.$cssStyle, #hide-app a.active .poster.$cssStyle, .item-apps .batch:hover .wrap > a .poster.$cssStyle, .item-related-app .batch:hover .wrap > a .poster.$cssStyle{ background-position: 0 -{$offset}px !important; } "; $cssMobile .= " #app-catalog a:hover .poster.$cssStyle, #app-catalog a:active .poster.$cssStyle, #app-catalog a.active .poster.$cssStyle, #hide-app a:active .poster.$cssStyle, #hide-app a.active .poster.$cssStyle, .item-apps .batch:hover .wrap > a .poster.$cssStyle, .item-related-app .batch:hover .wrap > a .poster.$cssStyle{ background-position: 0 -{$offsetMobile}px !important; } "; $offset += $offsetStep; $offsetMobile += $mobileStep; } if ( ! file_exists( $lessPath ) ) { mkdir( $lessPath, 0755 ); } if ( is_dir( $lessPath ) ) { $lessFile = $lessPath."mod.icosprite.less"; file_put_contents( $lessFile, $css ); $lessFileMobile = $lessPath."mod.icosprite.mobile.less"; file_put_contents( $lessFileMobile, $cssMobile ); eZCache::clearByID( array('ezjscore-packer'), 'template-block' ); } return array( 'errorCode' => 0, 'generateSpriteCommand' => $cmd ); }
'applicationIds' => 'Application ids comma seperated' ) ); $script->startup(); $script->initialize(); $clusters = array(); if( $options['clusterIdentifier'] ) { $clusters = array( $options['clusterIdentifier'] ); } else { foreach( glob( 'extension/cluster_*') as $f ) $clusters[] = basename( $f ); } $applicationIds = array(); if ( !empty( $options['applicationIds'] ) ) { $applicationIds = explode( ',' , $options['applicationIds'] ); } foreach( $clusters as $clusterIdentifier ) { ClusterTool::setCurrentCluster($clusterIdentifier); ApplicationSearch::reindex( $clusterIdentifier, $applicationIds ); } $script->shutdown();
public static function exportConfig($clusterIdentifier) { $db = MMDB::instance(); $cli = eZCLI::instance(); $config = array(); $cli->output($clusterIdentifier); // GENERAL ABOUT CLUSTER $localized["view"] = ezpI18n::tr("merck", "NO VIEW"); $localized["views"] = ezpI18n::tr("merck", "VIEWS"); $localized["rating"] = ezpI18n::tr("merck", "NO RATING"); $localized["ratings"] = ezpI18n::tr("merck", "RATING"); $localized["dateForm"] = str_replace('%', '', eZINI::instance("date.ini")->variable($clusterIdentifier, 'DateFormat')); $localized["altDescription"] = ezpI18n::tr("seo", "ACTUALITIES"); $config["localized"] = $localized; ClusterTool::setCurrentCluster($clusterIdentifier); // About application foreach($db->arrayQuery(sprintf("SELECT DISTINCT(application_identifier) FROM mm_seo WHERE cluster_identifier = '%s'", $clusterIdentifier)) as $row) { $applicationIdentifier = $row["application_identifier"]; $filters = array(); $config[$applicationIdentifier] = array(); $appLocalized = ApplicationLocalized::getLocalizedApplicationByIdentifier($applicationIdentifier, $clusterIdentifier); $appUrl = $appLocalized->attribute('url'); /** @var ContentListBase $app */ $app = ApplicationFactory::fetchByUri( '/'.$appUrl ); $isContentApplication = ( $app instanceof ContentListBase); if ( !$isContentApplication ) { continue; } // CREATE FILTER $solrFilter = $app->getResultHandler()->solrFilter(); $solrFacetsFiler = $app->getResultHandler()->solrFacetsFilter(); if( $solrFilter ) $filters[] = $solrFilter; if( $solrFacetsFiler ) $filters[] = $solrFacetsFiler; $filters = implode(' AND ', $filters); $config[$applicationIdentifier]["filters"] = $filters; // CREATE MAPPING PUBLISHERS $publishers = array(); foreach($app->applicationLocalized()->publisherFolders as $publisherFolder) { $publishers[$publisherFolder->attribute("path")] = $publisherFolder->getTranslation()->attribute("name"); } $config[$applicationIdentifier]["publishers"] = $publishers; // CREATE CONFIGURATION TAGLINE $features = $app->resultHandler->features; $config[$applicationIdentifier]["tagline"] = $features["line"]; } return $config; }
/** * 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]); } } } }