/** * @param $clusters * @param $options * @return void */ function generateCache($clusters, $options) { $cli = eZCLI::instance(); foreach ( $clusters as $clusterPath ) { $clusterIdentifier = basename( $clusterPath ); $configurations = MMRssGenerator::createConfigurationsForCluster( $clusterIdentifier ); foreach ( $configurations as $type => $configType ) { foreach ( $configType as $frequency => $config ) { $cli->output( "$clusterIdentifier - $type - $frequency" ); $params = array( 'type' => $type, 'frequency' => $frequency, ); //set date to daily, weekly and monthly if(isset($options['begin' . ucfirst($frequency)]) && !empty($options['begin' . ucfirst($frequency)])) { //test if end frequence is set if(!isset($options['end' . ucfirst($frequency)])) { $options['end' . ucfirst($frequency)] = '*'; } if(empty($options['end' . ucfirst($frequency)])) { $options['end' . ucfirst($frequency)] = '*'; } //add frequence date parameters $params['beginDate'] = $options['begin' . ucfirst($frequency)]; $params['endDate'] = $options['end' . ucfirst($frequency)]; //if date params set, use different path $params['path'] = "/rssManualCache/"; } $rssGenerator = new MMRssGenerator( $params, $clusterIdentifier ); $rssGenerator->getXML( true ); } } } }
<?php /* @type $Params string[] */ $cluster_identifier = ClusterTool::clusterIdentifier(); $rssGenerator = new MMRssGenerator( $Params, $cluster_identifier ); $outputMode = isset( $Params['outputMode' ]) ? $Params['outputMode'] : NewsletterPresenter::DEFAULT_MODE; $presenter = NewsletterPresenter::getPresenterForMode($outputMode); $contentTypeHeader = $presenter->getContentTypeHeader(); $rssGenerator->setConfiguration(); $rssGenerator->getResponseSolr(); $options = $presenter->getOptionsForMode($outputMode); $presenter->setRssType($rssGenerator->rssType()); $result = $presenter->render($rssGenerator->getLocalApplications(), $rssGenerator->getApplicationData(), $cluster_identifier, $options); if ($outputMode == 'xml') { $rssGenerator->saveForCreatorMail($result); } header($contentTypeHeader); echo $result; eZExecution::cleanExit();
<?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'] ) ); } }
<?php /* @type $Params string[] */ $cluster_identifier = ClusterTool::clusterIdentifier(); //set cache path $Params['path'] = '/rssManualCache/'; $rssGenerator = new MMRssGenerator( $Params, $cluster_identifier ); $result = $rssGenerator->getXML(); if ( $result ) { header( 'Content-type: text/xml' ); echo $result; } else { header( 'Content-type: text/xml' ); echo '<?xml version="1.0" encoding="utf-8"?>'; echo '<rss version="2.0">'; echo '<channel><item><title>'; echo '<![CDATA[Currently there is no content for your query. Please try again in 15 minutes.]]>'; echo '</title></item></channel>'; echo '</rss>'; } eZExecution::cleanExit();