/** * @return string[] The keys of all found sources. */ public function findAllSources() { $configuration = $this->parent->getModule('Configuration'); $allSources = $configuration->get('aggregator.sources'); $validSources = []; foreach ($allSources as $key => $source) { if (!class_exists($source)) { continue; } $validSources[$key] = $source; } return $validSources; }
/** * Prepare our list items for display * * @todo pagination */ public function prepare_items() { // Make sure we have an array for $this->items. if (!is_array($this->items)) { $this->items = array(); } // Get all the blogs. $blogs = Aggregator::get_sites(); // Our array of portals. $portals = array(); // Check if we have sync jobs for those sites. foreach ($blogs as $blog) { if ($sync_blogs = get_site_option("aggregator_{$blog->blog_id}_source_blogs")) { $portals[$blog->blog_id] = $sync_blogs; } unset($sync_blogs); } if (!empty($portals)) { $this->items = $portals; } else { $this->items = array(); } }
function renderTestSummary(Aggregator $agg, $testpath) { $output = new \XMLWriter(); if (!$output->openUri($this->savePath . '/index-test.html')) { throw new Exception('Cannot render tests summary, opening XML failed'); } $output->setIndentString(' '); $output->setIndent(true); $output->startElement('html'); $output->startElement('head'); $output->writeElement('title', 'Test Summary'); $output->startElement('link'); $output->writeAttribute('href', 'cover.css'); $output->writeAttribute('rel', 'stylesheet'); $output->writeAttribute('type', 'text/css'); $output->endElement(); $output->endElement(); $output->startElement('body'); $output->writeElement('h2', 'Tests Executed, click for code coverage summary'); $output->startElement('p'); $output->startElement('a'); $output->writeAttribute('href', 'index.html'); $output->text('Aggregate Code Coverage for all tests'); $output->endElement(); $output->endElement(); $output->startElement('ul'); foreach ($agg->retrieveTestPaths() as $test) { $output->startElement('li'); $output->startElement('a'); $output->writeAttribute('href', $this->mangleTestFile($test)); $output->text(str_replace($testpath . '/', '', $test)); $output->endElement(); $output->endElement(); } $output->endElement(); $output->endElement(); $output->endDocument(); }
echo "No changes to coverage needed. Bye!\n"; exit; } $dir = getcwd(); chdir($testpath); error_reporting(0); $test->doRunTests('run-tests', array('coverage' => true), $modified); error_reporting($e); chdir($dir); if (file_exists($testpath . '/run-tests.log')) { // tests failed echo "Tests failed - not regenerating coverage data\n"; exit; } dorender: $a = new Aggregator($testpath, $codepath, $testpath . '/pear2coverage.db'); if ($norender) { exit; } if (file_exists(__DIR__ . '/test')) { foreach (new \DirectoryIterator(__DIR__ . '/test') as $file) { if ($file->isDot()) { continue; } unlink($file->getPathName()); } } else { mkdir(__DIR__ . '/test'); } echo "Rendering\n"; $a->render(__DIR__ . '/test');
function handleRequest() { $type = param('q', 'tag'); $outputType = param('f', 'html'); switch ($type) { case 'item': //refresh: always from cache $zf_aggregator = new Aggregator(); $item = $zf_aggregator->getItem(param('itemid')); $view = zf_createView($outputType); $view->renderArticle($item); break; case 'download-item': //refresh: always from cache $zf_aggregator = new Aggregator(); $item = $zf_aggregator->downloadItem(param('itemid')); $view = zf_createView($outputType); $view->renderArticle($item); break; case 'save-item': //refresh: always from cache $zf_aggregator = new Aggregator(); $item = $zf_aggregator->saveItem(param('itemid'), param('save', 1)); $view = zf_createView($outputType); $view->renderArticle($item); break; case 'summary': //refresh: always from cache $zf_aggregator = new Aggregator(); $item = $zf_aggregator->getItem(param('itemid')); $view = zf_createView($outputType); $view->renderSummary($item); break; case 'channel': //refresh: user defined $zf_aggregator = new Aggregator(); $feed = $zf_aggregator->getPublisherFeed(param('id'), param('mode', ZF_REFRESHMODE == 'automatic' ? 'auto' : 'none'), param('trim', 'auto'), int_param('onlynew', ZF_ONLYNEW == 'no' ? 0 : 1)); $view = zf_createView($outputType); $view->renderFeed($feed, array('groupbyday' => false, 'decoration' => int_param('decoration'), 'summary' => param('sum', 1) == 1)); break; case 'tag': //refresh: always auto refresh for tag view // if html output & sorted by feed, trim every single item // according to subcription's settings $sort = param('sort', ZF_SORT); if ($sort == 'feed' && strstr($outputType, 'html')) { $groupbyday = false; $aggregate = false; } else { // otherwise just aggregate in a single feed $groupbyday = true; $aggregate = true; } $zf_aggregator = new Aggregator(); $tag = param('tag', ZF_HOMETAG); $feeds = $zf_aggregator->getFeedsForTag($tag, $aggregate, $trim = param('trim', 'auto'), int_param('onlynew', ZF_ONLYNEW == 'no' ? 0 : 1)); zf_debugRuntime("before rendering"); $view = zf_createView($outputType); $view->renderFeedList($feeds, array('groupbyday' => $groupbyday, 'summary' => int_param('sum', 1) == 1, 'tag' => $tag)); break; case 'subs': //only JSON $subs = SubscriptionStorage::getInstance()->getSortedActiveSubscriptions(param('tag', '')); if (!headers_sent()) { header('Content-Type: application/json; charset=' . ZF_ENCODING); } echo json_encode($subs, JSON_FORCE_OBJECT); break; case 'tags': $tags = SubscriptionStorage::getInstance()->getTags(); if (!headers_sent()) { header('Content-Type: application/json; charset=' . ZF_ENCODING); } echo json_encode($tags, JSON_FORCE_OBJECT); break; case 'force-refresh': // only internal use // TODO: check API key $sub = SubscriptionStorage::getInstance()->getSubscription(param('id')); FeedCache::getInstance()->updateSingle($sub->source); echo $sub->source->title . ' DONE. '; break; case 'refresh-all': $subs = SubscriptionStorage::getInstance()->getActiveSubscriptions(param('tag', '')); FeedCache::getInstance()->update($subs); echo ' DONE. '; break; } }
function execute($par = null) { $bits = explode('/', $par, 2); if (count($bits) < 2) { // editor form not yet implemented } else { list($type, $target) = $bits; global $wgFeedClasses, $wgOut; $wgOut->disable(); $aggro = new Aggregator($target); $aggro->outputFeed($type, 10); } }
* Templating for the network admin screen * * @package Aggregator */ // Get the blog ID from the URL, if set. $portal_id = isset($_GET['portal']) ? intval($_GET['portal']) : 0; // Input var okay. $source_id = isset($_GET['source']) ? intval($_GET['source']) : 0; // Input var okay. // Determine/set the action to perform. $action = isset($_GET['action']) ? sanitize_text_field(wp_unslash($_GET['action'])) : 'list'; // Input var okay. switch ($action) { case 'add': // Just print a dropdown which we can redirect to the edit page. $blogs = Aggregator::get_sites(); ?> <div class="wrap"> <h2><?php esc_html_e('Add New Sync Job'); ?> </h2> <form class="new_aggregator" action="" method="get"> <p> <label for="portal"><?php esc_html_e('Choose the site that will act as the "portal" site:'); ?> </label> <select name="portal" id="portal"> <option selected="selected">-- Select a blog --</option> <?php
public function load() { parent::load(); $dirty_type = @$_REQUEST["bdiitree_type"]; switch ($dirty_type) { default: case "total_jobs": $sub_title = "Number of Jobs"; $key = "TotalJobs"; break; case "free_cpus": $sub_title = "Number of Free CPUs"; $key = "FreeCPUs"; break; case "estimated_response_time": $sub_title = "Estimated Response Time"; $key = "EstimatedResponseTime"; break; case "waiting_jobs": $sub_title = "Number of Waiting Jobs"; $key = "WaitingJobs"; break; case "running_jobs": $sub_title = "Number of Running Jobs"; $key = "RunningJobs"; break; case "free_job_slots": $sub_title = "Number of Free Job Slots"; $key = "FreeJobSlots"; break; } $model = new BDII(); $rgs = $model->get(); $model = new ResourceGroup(); $oim_rgs = $model->getindex(); $this->view->total_area = 0; $this->view->key = $key; $this->view->sub_title = $sub_title; $this->view->rgs = array(); foreach ($this->rgs as $rgid => $rg) { //filter ones that passed mysql query for resource group if (isset($rgs[$rgid])) { $bdii_rg = $rgs[$rgid]; $rg_view = array(); //has resources information? if (isset($bdii_rg->resources)) { //for each resource.. foreach ($bdii_rg->resources as $rid => $resource) { //filter ones that passed mysql query for resource if (isset($rg[$rid])) { //aggregate data for each services $agg = new Aggregator(); $num = 0; $services = $resource["bdii"]->Services; foreach ($services as $service) { $service = $service->Service; $servicename = $service->ServiceName; //$serviceuri = $service->ServiceUri; //for each queue if ($service->Queues === null) { continue; } foreach ($service->Queues as $queue) { $queue = $queue->Queue; $state = $queue->State; $agg->sum("TotalJobs", $state->GlueCEStateTotalJobs); $agg->sum("FreeCPUs", $state->GlueCEStateFreeCPUs); $agg->sum("EstimatedResponseTime", $state->GlueCEStateEstimatedResponseTime); $agg->sum("WaitingJobs", $state->GlueCEStateWaitingJobs); $agg->sum("RunningJobs", $state->GlueCEStateRunningJobs); $agg->sum("FreeJobSlots", $state->GlueCEStateFreeJobSlots); ++$num; } } if ($num > 0) { $rg_view[$rid] = array("info" => $rg[$rid], "agg" => $agg); $this->view->total_area += $agg->get($key); } } } } $this->view->rgs[$rgid] = array("info" => $oim_rgs[$rgid][0], "resources" => $rg_view); /* $bdii = $rg->bdii; $this->view->rgs[$rgid] = $bdii; foreach($bdii->aggregates as $aggregate) { } */ } else { elog("Can't find information for resource group {$rgid}"); } } $this->setpagetitle($this->default_title() . " - " . $sub_title); }
if (!count($modified) && $force) { goto norunnie; } chdir($testpath); $e = error_reporting(); error_reporting(0); $test->doRunTests('run-tests', array('coverage' => true), $modified); error_reporting($e); chdir($olddir); if (!$force && file_exists($testpath . '/run-tests.log')) { // tests failed echo "Tests failed - not regenerating coverage data\n"; exit; } norunnie: $a = new Aggregator($testpath, $codepath, $testpath . '/pear2coverage.db'); if ($norender) { exit; } if (file_exists(__DIR__ . '/coverage')) { echo "Removing old coverage HTML..."; foreach (new \DirectoryIterator(__DIR__ . '/coverage') as $file) { if ($file->isDot()) { continue; } unlink($file->getPathName()); } echo "done\n"; } else { mkdir(__DIR__ . '/coverage'); }
{ //fclose($this->socket); } public function run() { while (true) { if ($this->pause) { continue; } //Always 0 here! //echo "Count: " . count($this->queue) . "\n"; foreach ($this->queue as $k => $v) { echo $v['created_at'] . "\n"; if (self::TIMEOUT + $v['created_at'] < time()) { $response = array(); $response['correlation_id'] = $k; $response['response'] = $v['response']; var_dump($response); $response = json_encode($response); //fwrite($this->sockett, $response); //unset($this->queue[$k]); } } } } } $aggregator = new Aggregator(); $aggregator->subscribe(); ?>
/** * Provide a list of sync jobs. * * @return array|bool An array of Aggregator_Job objects, false on error */ public function get_jobs() { // Get a list of sites. $blogs = Aggregator::get_sites(); // Should never be empty, but hey, let's play safe. if (empty($blogs)) { return false; } // Holder for the jobs. $jobs = array(); // Loop through each blog, getting any sync jobs. foreach ($blogs as $portal) { // Find any portal jobs. // @todo There's probably a better way to do this... foreach ($blogs as $source) { // Don't try and find any blogs syncing to themselves. if ($portal->blog_id === $source->blog_id) { continue; } // Get any jobs. $job = new Aggregator_Job($portal->blog_id, $source->blog_id); if (is_null($job->post_id)) { continue; } else { $jobs[] = $job; } } } return $jobs; }