<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Core_Page_AJAX {
/**
- * function to call generic ajax forms
+ * Call generic ajax forms
*
* @static
- * @access public
*/
- static function run() {
+ public static function run() {
$className = CRM_Utils_Type::escape($_REQUEST['class_name'], 'String');
$type = '';
if (!empty($_REQUEST['type'])) {
}
/**
- * function to change is_quick_config priceSet to complex
+ * Change is_quick_config priceSet to complex
*
* @static
- * @access public
*/
- static function setIsQuickConfig() {
+ public static function setIsQuickConfig() {
$id = $context = NULL;
if (!empty($_REQUEST['id'])) {
$id = CRM_Utils_Type::escape($_REQUEST['id'], 'Integer');
if (!$result) {
$priceSetId = null;
}
- echo json_encode($priceSetId);
-
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($priceSetId);
}
/**
*
* @return bool
*/
- static function checkAuthz($type, $className, $fnName = null) {
+ public static function checkAuthz($type, $className, $fnName = null) {
switch ($type) {
case 'method':
if (!preg_match('/^CRM_[a-zA-Z0-9]+_Page_AJAX$/', $className)) {
* Outputs the CiviCRM standard json-formatted page/form response
* @param array|string $response
*/
- static function returnJsonResponse($response) {
+ public static function returnJsonResponse($response) {
// Allow lazy callers to not wrap content in an array
if (is_string($response)) {
$response = array('content' => $response);
CRM_Utils_System::civiExit();
}
+ /**
+ * Set headers appropriate for a js file
+ */
+ public static function setJsHeaders() {
+ // Encourage browsers to cache for a long time - 1 year
+ $year = 60*60*24*364;
+ header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $year));
+ header('Content-Type: application/javascript');
+ header("Cache-Control: max-age=$year, public");
+ }
+
/**
* Send autocomplete results to the client. Input can be a simple or nested array.
* @param array $results - If nested array, also provide:
* @param string $key - array key to use as the key
* @deprecated
*/
- static function autocompleteResults($results, $val='label', $key='id') {
+ public static function autocompleteResults($results, $val='label', $key='id') {
$output = array();
if (is_array($results)) {
foreach ($results as $k => $v) {
CRM_Utils_System::civiExit();
}
}
-