1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Custom CSS plugin.
|
6 |
|
|
*/
|
7 |
|
|
class sweaver_plugin_advanced extends sweaver_plugin {
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Frontend form.
|
11 |
|
|
*/
|
12 |
|
|
public function sweaver_form() {
|
13 |
|
|
|
14 |
|
|
$current_style = Sweaver::get_instance()->get_current_style();
|
15 |
|
|
|
16 |
|
|
$form = array();
|
17 |
|
|
$attributes = array();
|
18 |
|
|
|
19 |
|
|
$form['#editor_containers'] = array();
|
20 |
|
|
|
21 |
|
|
$form['#editor_containers']['one']['title'] = 'Watchdog';
|
22 |
|
|
$form['#editor_containers']['one']['content'][] = array('#markup' => '<div id="watchdog">');
|
23 |
|
|
$form['#editor_containers']['one']['content'][] = array(
|
24 |
|
|
'#theme' => 'table',
|
25 |
|
|
'#rows' => array(
|
26 |
|
|
array(
|
27 |
|
|
array('data' => 'List of all changes made in the Style tab'),
|
28 |
|
|
array(
|
29 |
|
|
'data' => '<span class="title delete" onclick="Drupal.Sweaver.deleteAllProperties(); Drupal.Sweaver.writeModifications();">Delete All</span><span class="title hide" onclick="Drupal.Sweaver.cssHider(true);">Hide All</span><span class="title show" onclick="Drupal.Sweaver.cssHider(false);">Show All</span>',
|
30 |
|
|
'class' => array('operations'),
|
31 |
|
|
),
|
32 |
|
|
),
|
33 |
|
|
),
|
34 |
|
|
'#attributes' => array('class' => array('header')),
|
35 |
|
|
);
|
36 |
|
|
$form['#editor_containers']['one']['content'][] = array('#markup' => '<div id="scrollable_area"></div>');
|
37 |
|
|
$form['#editor_containers']['one']['content'][] = array('#markup' => '</div>');
|
38 |
|
|
|
39 |
|
|
$form['#editor_containers']['two']['title'] = 'Custom css';
|
40 |
|
|
$form['#editor_containers']['two']['content']['sweaver_plugin_custom_css'] = 'sweaver_plugin_custom_css';
|
41 |
|
|
$form['sweaver_plugin_custom_css'] = array(
|
42 |
|
|
'#type' => 'textarea',
|
43 |
|
|
'#rows' => 10,
|
44 |
|
|
'#cols' => 80,
|
45 |
|
|
'#resizable' => FALSE,
|
46 |
|
|
'#wysiwyg' => FALSE,
|
47 |
|
|
'#attributes' => array(
|
48 |
|
|
'class' => array('sweaver-400'),
|
49 |
|
|
),
|
50 |
|
|
'#default_value' => (isset($current_style->customcss)) ? $current_style->customcss : '',
|
51 |
|
|
'#prefix' => '<div class="form-floater">',
|
52 |
|
|
);
|
53 |
|
|
$form['#editor_containers']['two']['content']['sweaver_plugin_custom_css_button'] = 'sweaver_plugin_custom_css_button';
|
54 |
|
|
$form['sweaver_plugin_custom_css_button'] = array(
|
55 |
|
|
'#type' => 'button',
|
56 |
|
|
'#value' => t('Apply'),
|
57 |
|
|
'#suffix' => '</div>',
|
58 |
|
|
);
|
59 |
|
|
return $form;
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
/**
|
63 |
|
|
* Frontend form render.
|
64 |
|
|
*/
|
65 |
|
|
public function sweaver_form_render(&$vars, &$form, $plugin) {
|
66 |
|
|
|
67 |
|
|
$name = $plugin['name'];
|
68 |
|
|
$vars['tabs'][$name]['#tab_name'] = $form[$name]['#tab_name'];
|
69 |
|
|
$vars['tabs_data'][$name]['#tab_description'] = $form[$name]['#tab_description'];
|
70 |
|
|
|
71 |
|
|
$output = '';
|
72 |
|
|
|
73 |
|
|
$output .= '<div id="sweaver-advanced" class="clearfix">';
|
74 |
|
|
|
75 |
|
|
// Containers.
|
76 |
|
|
$vertical_tabs = '';
|
77 |
|
|
$containers = '';
|
78 |
|
|
|
79 |
|
|
foreach ($form[$name]['form']['#editor_containers'] as $key => $container_value) {
|
80 |
|
|
// Set the first tab as active by default.
|
81 |
|
|
$tab_class = '';
|
82 |
|
|
if ($key == 'one') {
|
83 |
|
|
$tab_class = 'class="active"';
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
// Combine all vertical tabs.
|
87 |
|
|
$vertical_tabs .= '<div id="tab-'. $key .'" class="vertical-tab"><a href="#" '. $tab_class .'>'. $container_value['title'] .'</a></div>';
|
88 |
|
|
|
89 |
|
|
// Combine all properties in containers.
|
90 |
|
|
$containers .= '<div id="container-'. $key .'" class="container-wrapper">';
|
91 |
|
|
foreach ($container_value['content'] as $sub_key => $field) {
|
92 |
|
|
if (is_int($sub_key))
|
93 |
|
|
$containers .= drupal_render($field);
|
94 |
|
|
else
|
95 |
|
|
$containers .= drupal_render($form[$name]['form'][$field]);
|
96 |
|
|
}
|
97 |
|
|
$containers .= '</div>';
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
$output .= '<div class="vertical-tabs">' . $vertical_tabs . '</div>';
|
101 |
|
|
$output .= '<div class="vertical-content">' . $containers . '</div>';
|
102 |
|
|
|
103 |
|
|
$output .= '</div>';
|
104 |
|
|
|
105 |
|
|
$vars['tabs_data'][$name]['content'] = $output;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
/**
|
110 |
|
|
* Frontend form submit handler.
|
111 |
|
|
*/
|
112 |
|
|
function sweaver_form_submit($form, &$form_state) {
|
113 |
|
|
if (isset($form_state['values']['sweaver_plugin_custom_css'])) {
|
114 |
|
|
$clicked_button = $form_state['clicked_button']['#value'];
|
115 |
|
|
if (($clicked_button == t('Save and continue') || $clicked_button == t('Save and publish') || $clicked_button == t('Publish style')) && isset($form_state['style_id'])) {
|
116 |
|
|
db_query("UPDATE {sweaver_style_draft} set customcss = :customcss WHERE style_id = :style_id", array(':customcss' => $form_state['values']['sweaver_plugin_custom_css'], ':style_id' => $form_state['style_id']));
|
117 |
|
|
if ($form_state['publish']) {
|
118 |
|
|
db_query("UPDATE {sweaver_style} set customcss = :customcss WHERE style_id = :style_id", array(':customcss' => $form_state['values']['sweaver_plugin_custom_css'], ':style_id' => $form_state['style_id']));
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
/**
|
125 |
|
|
* Frontend css and js.
|
126 |
|
|
*/
|
127 |
|
|
public function sweaver_form_css_js(&$inline_settings) {
|
128 |
|
|
drupal_add_js(drupal_get_path('module', 'sweaver') .'/plugins/sweaver_plugin_advanced/sweaver_plugin_customcss.js');
|
129 |
|
|
drupal_add_js(drupal_get_path('module', 'sweaver') .'/plugins/sweaver_plugin_advanced/sweaver_plugin_watchdog.js');
|
130 |
|
|
}
|
131 |
|
|
} |