forked from Typesetter/Bootstrap-Carousel
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTwitterCarousel_Admin.php
109 lines (87 loc) · 2.96 KB
/
TwitterCarousel_Admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
defined('is_running') or die('Not an entry point...');
class TwitterCarousel_Admin{
public static $config;
public static $components;
public static $debug = true;
public static function Settings(){
global $page, $addonRelativeCode, $langmessage;
if( isset($_POST['save']) ){
msg(self::SaveConfig());
}
self::LoadConfig();
self::GetComponents();
$admin_url = \gp\tool::GetUrl('Admin_TwitterCarousel');
echo '<h2 class="hqmargin">Bootstrap Carousel Gallery » Settings</h2>';
echo '<form id="cketconfig_form" data-values-changed="0" action="' . $admin_url . '" method="post">';
echo '<table class="bordered" style="width:100%;">';
echo '<tr>';
echo '<th style="width:40%;">' . $langmessage['Settings'] . '</th>';
echo '<th style="width:60%;">' . $langmessage['Current_Value'] . '</th>';
echo '</tr>';
$value = self::$config['theme'];
echo '<tr>';
echo '<td>Carousel theme*</td>';
echo '<td>';
echo '<select class="gpselect" name="cketconfig[theme]">';
echo '<option value="Bootstrap default">Bootstrap default</option>';
foreach( self::$components['themes'] as $theme ){
$label = $theme['name'];
$selected = $label == $value ? ' selected="selected" ' : '';
echo '<option value="' . $label . '" ' . $selected . '>' . $label . '</option>';
}
echo '</select>';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '<br/>';
echo '<p>* - All Carousel sections should be re-saved in order to fully apply the new theme</p>';
// SAVE / CANCEL
echo '<br/>';
echo '<input type="submit" id="cketconfig_submit" name="save" value="' . $langmessage['save'] . '" class="gpsubmit" /> ';
echo '<input type="button" onClick="location.href=\'' .$admin_url . '\'" value="' . $langmessage['cancel'] . '" class="gpcancel" />';
echo '</form>';
}
public static function GetComponents(){
global $page, $addonPathCode;
self::$components = array(
'themes' => array(),
);
self::$components['themes'][] = array(
'name' => 'Bootstrap default',
'name' => 'TS style',
);
}
public static function LoadConfig(){
global $addonPathCode, $addonPathData;
$config_file = $addonPathData . '/config.php';
if( file_exists($config_file) ){
include $config_file;
}else{
$config = array (
'theme' => 'Bootstrap default',
);
}
self::$config = $config;
}
public static function SaveConfig(){
global $addonPathData, $langmessage;
$config = array (
'theme' => 'Bootstrap default',
);
foreach ($_POST['cketconfig'] as $key => $value) {
switch($key){
case 'theme':
$config['theme'] = basename(trim($value));
break;
default:
}
}
$config_file = $addonPathData . '/config.php';
if( \gp\tool\Files::SaveData($config_file, 'config', $config) ){
msg($langmessage['SAVED']);
}else{
msg($langmessage['OOPS']);
}
}
}