本文整理汇总了PHP中ClusterTool::setCurrentCluster方法的典型用法代码示例。如果您正苦于以下问题:PHP ClusterTool::setCurrentCluster方法的具体用法?PHP ClusterTool::setCurrentCluster怎么用?PHP ClusterTool::setCurrentCluster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClusterTool
的用法示例。
在下文中一共展示了ClusterTool::setCurrentCluster方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStaticPath
/**
* @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;
}
示例2: generateAndSaveImage
/**
* @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;
}
示例3: setClusterIdentifier
/**
* 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);
}
示例4: getData
/**
* @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;
}
示例5: domain
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' );
}
示例6: time
$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();
示例7: __construct
/**
* @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");
}
}
示例8: foreach
<?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;
示例9: initVars
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;
}
}
示例10: foreach
<?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'] ) );
}
}
示例11: isset
$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, ',', '"') )
示例12: updateRanking
//.........这里部分代码省略.........
$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;
}
示例13: array
$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' ) );
示例14: array
$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';
示例15: generateSpriteForCluster
/**
* @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;
//.........这里部分代码省略.........