View source
<?php
define('SALVATTORE_VERSION_REGEX', '/(1\\.\\d\\.\\d)/');
function salvattore_permission() {
return array(
'manage Salvattore settings' => array(
'title' => t('Manage Salvattore settings'),
),
);
}
function salvattore_menu() {
$items = array();
$items['admin/config/user-interface/salvattore'] = array(
'title' => 'Salvattore Settings',
'description' => 'Configure Salvattore',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'salvattore_admin_settings_form',
),
'access arguments' => array(
'manage Salvattore settings',
),
'file' => 'salvattore.admin.inc',
);
return $items;
}
function salvattore_views_api() {
return array(
'api' => 3,
);
}
function template_preprocess_views_view_salvattore(&$vars) {
template_preprocess_views_view_unformatted($vars);
$view = $vars['view'];
$options = $vars['options'];
}
function salvattore_preprocess_views_view_salvattore(&$vars) {
drupal_add_js(salvattore_get_path(), array(
'scope' => 'footer',
));
if (variable_get('salvattore_load_default_css')) {
drupal_add_css(drupal_get_path('module', 'salvattore') . '/css/salvattore_default.css', array(
'type' => 'file',
'preprocess' => FALSE,
));
}
}
function salvattore_get_path() {
$salvattore_path = libraries_get_path('salvattore');
if (variable_get('salvattore_use_min_js')) {
$salvattore_path .= '/dist/salvattore.min.js';
}
else {
$salvattore_path .= '/dist/salvattore.js';
}
return $salvattore_path;
}
function salvattore_get_version($reset = FALSE) {
$version =& drupal_static(__FUNCTION__);
if ($version === NULL || $reset == TRUE) {
if ($cached = cache_get('salvattore_version') && isset($cached->data) && $reset != TRUE) {
$version = $cached->data;
}
else {
$version = FALSE;
$salvattore_path = salvattore_get_path();
if (file_exists($salvattore_path)) {
$salvattore = file_get_contents($salvattore_path);
$matches = array();
preg_match(SALVATTORE_VERSION_REGEX, $salvattore, $matches);
if (isset($matches[0])) {
$version = $matches[0];
if ($version) {
cache_set('salvattore_version', $version);
}
}
unset($salvattore);
}
}
}
return $version;
}