/
index.php
99 lines (77 loc) · 3.32 KB
/
index.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
<?php
// Initial setup
require_once( '../kernel/setup_inc.php' );
require_once( CASCADER_PKG_PATH.'Cascader.php' );
// Only admin can use this - for now
$gBitSystem->verifyPermission( 'p_admin' );
// make sure the package is active
$gBitSystem->verifyPackage( 'cascader' );
// This is appended to the css file link ensuring an up to date view on ever page load
$gBitSmarty->assign( 'refresh', '?refresh='.time() );
// array used to feedback information to the user
$feedback = array();
// We need to use the cascader style for this package
if( !empty( $_REQUEST['cascader_style'] ) ) {
$gBitSystem->storeConfig( 'style', 'cascader', THEMES_PKG_NAME );
$gPreviewStyle = 'cascader';
}
// apply the style layout
$styleLayouts = $gBitThemes->getStyleLayouts();
$gBitSmarty->assign_by_ref( "styleLayouts", $styleLayouts );
if( !empty( $_REQUEST["site_style_layout"] ) ) {
$gBitSystem->storeConfig( 'site_style_layout', ( ( $_REQUEST["site_style_layout"] != 'remove' ) ? $_REQUEST["site_style_layout"] : NULL ), THEMES_PKG_NAME );
}
// load cascader
$gCascader = new Cascader( $_REQUEST );
if( !$gCascader->load() ) {
$feedback['error'] = $gCascader->mErrors;
}
// Make sure gCascader is avalable in the templates
$gBitSmarty->assign_by_ref( 'gCascader', $gCascader );
// Process form requests
// Remove all scheme files
if( !empty( $_REQUEST['clear_all_styles'] ) ) {
unlink_r( LibertyAttachable::getStoragePath() );
$gBitSystem->storeConfig( 'cascader_style', NULL );
}
// create a css file based on the user specifications
if( !empty( $_REQUEST['create_style'] ) ) {
$cascaderCss = $gCascader->createHeader();
$cascaderCss .= $gCascader->createCss( $_REQUEST['cascader'] );
if( $cssUrl = $gCascader->writeCss( $cascaderCss ) ) {
$feedback['success'] = tra( "The css file was stored to" ).": ".$cssUrl;
} else {
$feedback['error'] = tra( "There was a problem storing your custom css file." );
}
$gBitSystem->storeConfig( 'cascader_style', $cssUrl );
}
// apply an existing style
if( !empty( $_REQUEST['apply_style'] ) ) {
$gBitSystem->storeConfig( 'cascader_style', LibertyAttachable::getStorageUrl().$_REQUEST['apply_style'] );
}
// unset the custom style color settings
if( !empty( $_REQUEST['clear_style'] ) ) {
$gBitSystem->storeConfig( 'cascader_style', NULL );
}
// remove a style file
if( !empty( $_REQUEST['remove_style'] ) ) {
if( $gCascader->expunge( $_REQUEST['remove_style'] ) ) {
// remove the config entry if we're removing the css file we're currently using
if( preg_match( "/".$_REQUEST['remove_style']."$/", $gBitSystem->getConfig( 'cascader_style' ) ) ) {
$gBitSystem->storeConfig( 'cascader_style', NULL );
}
$feedback['success'] = tra( "The css file was successfully removed from your system" );
}
}
// create the calendar
$date = getdate( time() );
$calendar = new CascaderCalendar();
$gBitSmarty->assign( 'calendar', $calendar->getMonthView( ( !empty( $_REQUEST['month'] ) ? $_REQUEST['month'] : $date['mon'] ), ( !empty( $_REQUEST['year'] ) ? $_REQUEST['year'] : $date['year'] ) ) );
// get a list of stored css files
$cssList = $gCascader->getList();
$gBitSmarty->assign( 'cssList', $cssList );
// load css file
$gBitThemes->loadCss( THEMES_PKG_PATH.'themes.css' );
$gBitSmarty->assign( "feedback", $feedback );
$gBitSystem->display( 'bitpackage:cascader/cascader.tpl', 'Cascader' , array( 'display_mode' => 'display' ));
?>