authcache_ajax.module in Authenticated User Page Caching (Authcache) 7.2
Inject personalized fragments into cached pages using Ajax calls.
File
modules/authcache_ajax/authcache_ajax.moduleView source
<?php
/**
* @file
* Inject personalized fragments into cached pages using Ajax calls.
*/
/**
* Implements hook_authcache_enum_key_property_info().
*/
function authcache_ajax_authcache_enum_key_property_info() {
return array(
'ajax' => array(
'name' => t('Browser is capable of issuing Ajax requests'),
'choices' => array(
TRUE,
FALSE,
),
),
);
}
/**
* Implements hook_authcache_key_properties().
*/
function authcache_ajax_authcache_key_properties() {
$client_info = authcache_p13n_client_info();
return array(
'ajax' => !empty($client_info['authcache_ajax']['enabled']),
);
}
/**
* Implements hook_authcache_p13n_client().
*/
function authcache_ajax_authcache_p13n_client() {
return array(
'authcache_ajax' => array(
'title' => t('Ajax'),
'enabled' => !empty($_COOKIE['has_js']),
),
);
}
/**
* Implements hook_theme().
*/
function authcache_ajax_theme() {
return authcache_p13n_find_theme_functions('authcache_ajax');
}
/**
* Theme function for personalization fragment retrieved using an Ajax call.
*/
function theme_authcache_p13n_fragment__authcache_ajax($variables) {
$url = $variables['url'];
$fragment = $variables['fragment'];
$param = $variables['param'];
$attrs = $variables['attributes'];
if ($url && $fragment) {
drupal_add_js(drupal_get_path('module', 'authcache_p13n') . '/authcache_p13n.js');
drupal_add_js(drupal_get_path('module', 'authcache_ajax') . '/authcache_ajax.js');
$attrs['class'][] = 'authcache-ajax-frag';
$attrs['data-p13n-frag'] = $fragment;
if ($param) {
$attrs['data-p13n-param'] = $param;
}
drupal_add_js(array(
'authcacheP13nAjaxFragments' => array(
$fragment => array(
url($url['path'], $url['options']) => $param,
),
),
), 'setting');
return '<span ' . drupal_attributes($attrs) . '></span>';
}
}
/**
* Theme function for personalized Drupal.setting retrieved using an Ajax call.
*/
function theme_authcache_p13n_setting__authcache_ajax($variables) {
$url = $variables['url'];
$setting = $variables['setting'];
if ($url && $setting) {
drupal_add_js(drupal_get_path('module', 'authcache_p13n') . '/authcache_p13n.js');
drupal_add_js(drupal_get_path('module', 'authcache_ajax') . '/authcache_ajax.js');
drupal_add_js(array(
'authcacheP13nAjaxSettings' => array(
$setting => url($url['path'], $url['options']),
),
), 'setting');
return '';
}
}
/**
* Theme function for groups of fragments loaded in only one Ajax call.
*/
function theme_authcache_p13n_assembly__authcache_ajax($variables) {
$url = $variables['url'];
$class = $variables['class'];
if ($url && $class) {
drupal_add_js(drupal_get_path('module', 'authcache_p13n') . '/authcache_p13n.js');
drupal_add_js(drupal_get_path('module', 'authcache_ajax') . '/authcache_ajax.js');
drupal_add_js(array(
'authcacheP13nAjaxAssemblies' => array(
'span.' . $class => url($url['path'], $url['options']),
),
), 'setting');
return '';
}
}
/**
* Theme function for single elements of assemblies.
*/
function theme_authcache_p13n_partial__authcache_ajax($variables) {
$assembly = $variables['assembly'];
$partial = $variables['partial'];
$param = $variables['param'];
$class = $variables['class'];
$attrs = $variables['attributes'];
if ($assembly && $partial && $param && $class) {
drupal_add_js(drupal_get_path('module', 'authcache_p13n') . '/authcache_p13n.js');
drupal_add_js(drupal_get_path('module', 'authcache_ajax') . '/authcache_ajax.js');
$attrs['class'][] = $class;
$attrs['data-p13n-frag'] = $partial;
$attrs['data-p13n-param'] = $param;
return '<span ' . drupal_attributes($attrs) . '></span>';
}
}
Functions
Name | Description |
---|---|
authcache_ajax_authcache_enum_key_property_info | Implements hook_authcache_enum_key_property_info(). |
authcache_ajax_authcache_key_properties | Implements hook_authcache_key_properties(). |
authcache_ajax_authcache_p13n_client | Implements hook_authcache_p13n_client(). |
authcache_ajax_theme | Implements hook_theme(). |
theme_authcache_p13n_assembly__authcache_ajax | Theme function for groups of fragments loaded in only one Ajax call. |
theme_authcache_p13n_fragment__authcache_ajax | Theme function for personalization fragment retrieved using an Ajax call. |
theme_authcache_p13n_partial__authcache_ajax | Theme function for single elements of assemblies. |
theme_authcache_p13n_setting__authcache_ajax | Theme function for personalized Drupal.setting retrieved using an Ajax call. |