function template_preprocess_angular_media_app in CKEditor Widgets 7
Implements hook_theme_preprocess().
File
- ./
angular_media.module, line 571 - Implementation of angular_media.module.
Code
function template_preprocess_angular_media_app(&$variables) {
$settings = $variables['settings'];
$settings['apiUrl'] = url('api/angular-media') . '/';
$settings['token'] = drupal_get_token(ANGULAR_MEDIA_TOKEN_KEY);
// Add settings from variables
foreach (array(
'flickrKey',
'flickrSearch',
) as $key) {
$settings[$key] = !empty($settings[$key]) ? $settings[$key] : variable_get('angular_media_' . $key, NULL);
}
// Determine which tabs can be shown
if (!count($settings['tabs']) || empty($settings['tabs'][0])) {
$settings['tabs'] = angular_media_tabs();
}
// Add additional values;
if (empty($settings['flickrKey'])) {
unset($settings['tabs']['flickr']);
}
// Some variables are not needed in $settings
foreach (array(
'style',
'hidden',
) as $key) {
if (!empty($settings[$key])) {
$variables[$key] = $settings[$key];
unset($settings[$key]);
}
}
// Cleanup Drupal select output
foreach (array(
'tabs',
'allowedTypes',
'allowedSchemes',
) as $key) {
if (!empty($settings[$key])) {
$settings[$key] = array_filter($settings[$key]);
$settings[$key] = !empty($settings[$key]) ? array_keys($settings[$key]) : array();
}
}
$variables['fieldName'] = $settings['fieldName'];
$variables['settings'] = json_encode($settings, JSON_HEX_QUOT);
}