Issue #2039277 by googletorp, dawehner, sandhya.m: Convert aggregator/opml to the new controller style.
parent
cc7e1532c6
commit
c82b285554
|
@ -89,36 +89,6 @@ function template_preprocess_aggregator_item(&$variables) {
|
|||
$variables['attributes']['class'][] = 'feed-item';
|
||||
}
|
||||
|
||||
/**
|
||||
* Page callback: Generates an OPML representation of all feeds.
|
||||
*
|
||||
* @param $cid
|
||||
* (optional) If set, feeds are exported only from a category with this ID.
|
||||
* Otherwise, all feeds are exported. Defaults to NULL.
|
||||
*
|
||||
* @return string
|
||||
* An OPML formatted string.
|
||||
*
|
||||
* @see aggregator_menu()
|
||||
*
|
||||
* @deprecated Use \Drupal\aggregator\Controller\AggregatorController::opmlPage()
|
||||
*/
|
||||
function aggregator_page_opml($cid = NULL) {
|
||||
if ($cid) {
|
||||
$result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = :cid ORDER BY title', array(':cid' => $cid));
|
||||
}
|
||||
else {
|
||||
$result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');
|
||||
}
|
||||
|
||||
$feeds = $result->fetchAll();
|
||||
$aggregator_page_opml = array(
|
||||
'#theme' => 'aggregator_page_opml',
|
||||
'#feeds' => $feeds,
|
||||
);
|
||||
return drupal_render($aggregator_page_opml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the OPML page for the feed.
|
||||
*
|
||||
|
@ -126,13 +96,14 @@ function aggregator_page_opml($cid = NULL) {
|
|||
* An associative array containing:
|
||||
* - feeds: An array of the feeds to theme.
|
||||
*
|
||||
* @return string
|
||||
* An OPML formatted string.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_aggregator_page_opml($variables) {
|
||||
$feeds = $variables['feeds'];
|
||||
|
||||
drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8');
|
||||
|
||||
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
||||
$output .= "<opml version=\"1.1\">\n";
|
||||
$output .= "<head>\n";
|
||||
|
@ -146,7 +117,7 @@ function theme_aggregator_page_opml($variables) {
|
|||
$output .= "</body>\n";
|
||||
$output .= "</opml>\n";
|
||||
|
||||
print $output;
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ use Drupal\aggregator\ItemInterface;
|
|||
use Drupal\Core\Database\Connection;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
/**
|
||||
|
@ -352,11 +353,35 @@ class AggregatorController extends ControllerBase implements ContainerInjectionI
|
|||
}
|
||||
|
||||
/**
|
||||
* @todo Remove aggregator_opml().
|
||||
* Generates an OPML representation of all feeds or feeds by category.
|
||||
*
|
||||
* @param int $cid
|
||||
* (optional) If set, feeds are exported only from a category with this ID.
|
||||
* Otherwise, all feeds are exported. Defaults to NULL.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* The response containing the OPML.
|
||||
*/
|
||||
public function opmlPage($cid = NULL) {
|
||||
module_load_include('pages.inc', 'aggregator');
|
||||
return aggregator_page_opml($cid);
|
||||
if ($cid) {
|
||||
$result = $this->database->query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = :cid ORDER BY title', array(':cid' => $cid));
|
||||
}
|
||||
else {
|
||||
$result = $this->database->query('SELECT * FROM {aggregator_feed} ORDER BY title');
|
||||
}
|
||||
|
||||
$feeds = $result->fetchAll();
|
||||
$aggregator_page_opml = array(
|
||||
'#theme' => 'aggregator_page_opml',
|
||||
'#feeds' => $feeds,
|
||||
);
|
||||
$output = drupal_render($aggregator_page_opml);
|
||||
|
||||
$response = new Response();
|
||||
$response->headers->set('Content-Type', 'text/xml; charset=utf-8');
|
||||
$response->setContent($output);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue