67 lines
1.4 KiB
PHP
67 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* @file
|
|
* SplashBlock.php
|
|
*
|
|
* @author: Frédéric G. MARAND <fgm@osinet.fr>
|
|
*
|
|
* @copyright (c) 2015 Ouest Systèmes Informatiques (OSInet).
|
|
*
|
|
* @license General Public License version 2 or later
|
|
*/
|
|
|
|
namespace OSInet\Splash;
|
|
|
|
|
|
class SplashBlock {
|
|
const MODULE = 'splash';
|
|
const DELTA = 'splash';
|
|
|
|
protected static $defaults = [
|
|
'source' => '#block-system-main',
|
|
'destination' => '#block-splash-splash',
|
|
'timeout' => 3,
|
|
'body' => '',
|
|
];
|
|
|
|
|
|
public static function info() {
|
|
$ret = [
|
|
'info' => t('Splash image'),
|
|
'cache' => DRUPAL_CACHE_GLOBAL,
|
|
];
|
|
|
|
return $ret;
|
|
}
|
|
|
|
public static function variableGet($name) {
|
|
return variable_get(static::MODULE . "-$name", static::$defaults[$name]);
|
|
}
|
|
|
|
public function build() {
|
|
$subject = NULL;
|
|
$content = '<span />';
|
|
$settings = [
|
|
'splash' => [
|
|
'source' => static::variableGet('source'),
|
|
'destination' => static::variableGet('destination'),
|
|
'timeout' => static::variableGet('timeout'),
|
|
'body' => static::variableGet('body'),
|
|
],
|
|
];
|
|
drupal_add_js($settings, 'setting');
|
|
|
|
$file = drupal_get_path('module', 'splash') . '/scripts/splash.js';
|
|
$options = [
|
|
// 'defer' => TRUE,
|
|
// 'every_page' => TRUE,
|
|
];
|
|
drupal_add_js($file, 'file', $options);
|
|
|
|
$ret = [
|
|
'subject' => $subject,
|
|
'content' => $content,
|
|
];
|
|
return $ret;
|
|
}
|
|
}
|