1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Toolbar plugin.
|
6 |
|
|
*/
|
7 |
|
|
class sweaver_plugin_toolbar extends sweaver_plugin {
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Menu registry.
|
11 |
|
|
*/
|
12 |
|
|
public function sweaver_menu(&$weight, $page_arguments, $base) {
|
13 |
|
|
|
14 |
|
|
$items = array();
|
15 |
|
|
|
16 |
|
|
// Theme classes groups administration.
|
17 |
|
|
$base['access arguments'] = array(array('sweaver_plugin_toolbar', 'sweaver_menu_access_callback', 'use editor'));
|
18 |
|
|
$items['admin/sweaver'] = $base + array(
|
19 |
|
|
'title' => 'Sweaver',
|
20 |
|
|
'page arguments' => array($page_arguments),
|
21 |
|
|
'access callback' => 'sweaver_menu_access_callback',
|
22 |
|
|
'weight' => -6,
|
23 |
|
|
);
|
24 |
|
|
|
25 |
|
|
return $items;
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
/**
|
29 |
|
|
* Frontend css and js.
|
30 |
|
|
*/
|
31 |
|
|
public function sweaver_form_css_js(&$inline_settings) {
|
32 |
|
|
if (module_exists('overlay')) {
|
33 |
|
|
drupal_add_js(drupal_get_path('module', 'sweaver') .'/plugins/sweaver_plugin_toolbar/sweaver_plugin_toolbar.js');
|
34 |
|
|
}
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
/**
|
38 |
|
|
* The plugin does not really have a page of its own
|
39 |
|
|
*/
|
40 |
|
|
public function sweaver_menu_callback() {
|
41 |
|
|
$session = isset($_SESSION['sweaver_plugin_toolbar_session_on'])
|
42 |
|
|
? $_SESSION['sweaver_plugin_toolbar_session_on']
|
43 |
|
|
: variable_get('sweaver_plugin_toolbar_session_default_on', TRUE);
|
44 |
|
|
$_SESSION['sweaver_plugin_toolbar_session_on'] = !$session;
|
45 |
|
|
|
46 |
|
|
// Go back to previous page.
|
47 |
|
|
drupal_goto($_SERVER['HTTP_REFERER']);
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
/**
|
51 |
|
|
* Sweaver dependencies.
|
52 |
|
|
*/
|
53 |
|
|
public function sweaver_dependencies() {
|
54 |
|
|
return array('toolbar');
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
/**
|
58 |
|
|
* Show editor
|
59 |
|
|
*/
|
60 |
|
|
public function show_editor() {
|
61 |
|
|
return isset($_SESSION['sweaver_plugin_toolbar_session_on'])
|
62 |
|
|
? $_SESSION['sweaver_plugin_toolbar_session_on']
|
63 |
|
|
: variable_get('sweaver_plugin_toolbar_session_default_on', TRUE);
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
/**
|
67 |
|
|
* Menu access callback.
|
68 |
|
|
*/
|
69 |
|
|
public function sweaver_menu_access_callback($args) {
|
70 |
|
|
return user_access($args[0]) && (sweaver_show_editor(FALSE, FALSE) || request_path() == 'admin/sweaver');
|
71 |
|
|
}
|
72 |
|
|
} |