From 492501cb784ec4af7855b39acf815669c60d07b0 Mon Sep 17 00:00:00 2001
From: Pavel A. Karoukin <pavel@yepcorp.com>
Date: Fri, 5 Aug 2011 05:00:10 +0000
Subject: [PATCH] Add JSONP callback option.

---
 contentasjson.module |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/contentasjson.module b/contentasjson.module
index 61e101a..4b336d9 100644
--- a/contentasjson.module
+++ b/contentasjson.module
@@ -94,7 +94,13 @@ function contentasjson_get_data($type, $id) {
   //If false (no data object returned), generate return message
   $data = ($data == FALSE ? _contentasjson_get_error_message_id( $id ) : $data);
   
-  drupal_json_output( $data );
+  if ($_GET['jsonp_callback']) {
+    drupal_add_http_header('Content-Type', 'application/json');
+    echo $_GET['jsonp_callback'] . '(' . drupal_json_encode($data) . ');';
+  }
+  else {
+    drupal_json_output( $data );
+  }
 }
 
 /**
@@ -277,4 +283,4 @@ function _contentasjson_get_error_message_id($id) {
       "@id" => $id 
     ) ) 
   );
-}
\ No newline at end of file
+}
-- 
1.7.0.4

