-
Notifications
You must be signed in to change notification settings - Fork 7
/
RCCWP_ManagementPage.php
executable file
·229 lines (187 loc) · 7.88 KB
/
RCCWP_ManagementPage.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?php
include_once('RCCWP_Application.php');
class RCCWP_ManagementPage
{
function AssignCustomWritePanel()
{
global $flutter_domain;
$postId = (int)$_GET['assign-custom-write-panel'];
$customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
$customWritePanelOptions = RCCWP_Options::Get();
$message = 'The Post that you\'re about to edit is not associated with any Custom Write Panel.';
?>
<div id="message" class="updated"><p><?php _e($message); ?></p></div>
<div class="wrap">
<h2><?php _e('Assign Custom Write Panel'); ?></h2>
<form action="" method="post" id="assign-custom-write-panel-form">
<table class="optiontable">
<tbody>
<tr valign="top">
<th scope="row"><?php _e('Custom Write Panel', $flutter_domain); ?>:</th>
<td>
<select name="custom-write-panel-id" id="custom-write-panel-id">
<option value=""><?php _e('(None)', $flutter_domain); ?></option>
<?php
$defaultCustomWritePanel = $customWritePanelOptions['default-custom-write-panel'];
foreach ($customWritePanels as $panel) :
$selected = $panel->id == $defaultCustomWritePanel ? 'selected="selected"' : '';
?>
<option value="<?php echo $panel->id?>" <?php echo $selected?>><?php echo $panel->name?></option>
<?php
endforeach;
?>
</select>
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="post-id" value="<?php echo $postId?>" />
<p class="submit" >
<input name="edit-with-no-custom-write-panel" type="submit" value="<?php _e("Don't Assign Custom Write Panel", $flutter_domain); ?>" />
<input name="edit-with-custom-write-panel" type="submit" value="<?php _e('Edit with Custom Write Panel', $flutter_domain); ?>" />
</p>
</form>
</div>
<?php
}
function GetCustomFieldEditUrl($customWriteModuleId, $customGroupId, $customFieldId)
{
$url = '?page=' . 'FlutterManageModules' . '&edit-custom-field=' . $customFieldId . '&custom-group-id=' . $customGroupId . '&custom-write-module-id='. $customWriteModuleId ;
return $url;
}
function GetCustomFieldDeleteUrl($customGroupId, $customFieldId)
{
$url = '?page=' . 'FlutterManageModules' . '&delete-custom-field=' . $customFieldId . '&custom-group-id=' . $customGroupId;
return $url;
}
function GetModuleDuplicateEditUrl($customWriteModuleId, $duplicateId)
{
$url = '?page=' . 'FlutterManageModules' . '&edit-module-duplicate=' . $duplicateId . '&module-duplicate-id=' . $duplicateId . '&custom-write-module-id='. $customWriteModuleId ;
return $url;
}
function GetModuleDuplicateDeleteUrl($customWriteModuleId, $duplicateId)
{
$url = '?page=' . 'FlutterManageModules' . '&delete-module-duplicate=' . $duplicateId . '&module-duplicate-id=' . $duplicateId . '&custom-write-module-id='. $customWriteModuleId ;
return $url;
}
function GetCustomWritePanelEditUrl($customWritePanelId)
{
$url = '?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&view-custom-write-panel=' . $customWritePanelId . '&custom-write-panel-id=' . $customWritePanelId;
return $url;
}
function GetCustomWritePanelDeleteUrl($customWritePanelId)
{
$url = '?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&delete-custom-write-panel=' . $customWritePanelId . '&custom-write-panel-id=' . $customWritePanelId;
return $url;
}
function GetCustomWriteModuleEditUrl($moduleId)
{
$url = '?page=' . 'FlutterManageModules' . '&view-custom-write-module=' . $moduleId . '&custom-write-module-id=' . $moduleId;
return $url;
}
function GetCustomWriteModuleDeleteUrl($moduleId)
{
$url = '?page=' . 'FlutterManageModules' . '&delete-custom-write-module=' . $moduleId . '&custom-write-module-id=' . $moduleId;
return $url;
}
function GetCustomGroupEditUrl($groupId, $moduleId)
{
$url = '?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&flutter_action=view-custom-group&custom-group-id=' . $groupId. '&custom-write-module-id=' . $moduleId;
return $url;
}
function GetCustomGroupDeleteUrl($groupId)
{
$url = '?page=' . 'FlutterManageModules' . '&delete-custom-group=' . $groupId . '&custom-group-id=' . $groupId;
return $url;
}
function GetCustomPanelModuleDeleteUrl($customWritePanelId, $panelModuleId)
{
$url = '?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&delete-custom-panel-module=' . $panelModuleId . '&custom-write-panel-id=' . $customWritePanelId;
return $url;
}
function GetCustomWriteModuleGenericUrl($flutterAction, $moduleId = null)
{
if (empty($moduleId) && isset($_REQUEST['custom-write-module-id'])){
$moduleId = $_REQUEST['custom-write-module-id'];
}
if (!empty($moduleId)){
$url = RCCWP_ManagementPage::GetModulePage() . "&custom-write-module-id=$moduleId&flutter_action=$flutterAction";
}
else{
$url = RCCWP_ManagementPage::GetModulePage() . "&flutter_action=$flutterAction";
}
return $url;
}
/**
* Generates a url containing the write panel id and the action
*
* @return unknown
*/
function GetCustomWritePanelGenericUrl($flutterAction, $customWritePanelId = null)
{
if (empty($customWritePanelId) && isset($_REQUEST['custom-write-panel-id'])){
$customWritePanelId = $_REQUEST['custom-write-panel-id'];
}
if (!empty($customWritePanelId)){
$url = RCCWP_ManagementPage::GetPanelPage() . "&custom-write-panel-id=$customWritePanelId&flutter_action=$flutterAction";
}
else{
$url = RCCWP_ManagementPage::GetPanelPage() . "&flutter_action=$flutterAction";
}
return $url;
}
function GetPanelPage(){
return '?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php');
}
function GetModulePage(){
return '?page=FlutterManageModules';
}
// ----------- Modules
function ViewModules()
{
global $flutter_domain;
$customWriteModules = RCCWP_CustomWriteModule::GetCustomModules();
?>
<script type='text/javascript' src='../../wp-includes/js/thickbox/thickbox.js'></script>
<link rel='stylesheet' href='../../wp-includes/js/thickbox/thickbox.css' type='text/css' media='all' />
<div class="wrap">
<form action="<?php echo RCCWP_ManagementPage::GetCustomWriteModuleGenericUrl('import-module')?>" method="post" id="posts-filter" name="ImportModuleForm" enctype="multipart/form-data">
<h2><?php _e('Modules'); ?></h2>
<p id="post-search">
<input id="import-module-file" name="import-module-file" type="file" />
<a href="#none" class="button-secondary" style="display:inline" onclick="document.ImportModuleForm.submit();"><?php _e('Import a Module',$flutter_domain); ?></a>
<a href="<?php echo RCCWP_ManagementPage::GetCustomWriteModuleGenericUrl('create-custom-write-module'); ?>" class="button-secondary" style="display:inline">+ <?php _e('Create a Module',$flutter_domain); ?></a>
</p>
</form>
<br class="clear"/>
<table cellpadding="3" cellspacing="3" width="100%" class="widefat">
<thead>
<tr>
<th scope="col" width="70%"><?php _e('Name'); ?></th>
<th scope="col" colspan="2" ><?php _e('Actions'); ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($customWriteModules as $module) :
$class = $class == '' ? 'alternate' : '';
?>
<tr class="<?php echo $class?>">
<td><?php echo $module->name ?></td>
<td><a href="<?php echo RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($module->id); ?>" class="edit"><?php _e('Edit') ?></a></td>
<td><a href="<?php echo FLUTTER_URI."RCCWP_ExportModule.php?custom-write-module-id={$module->id}";?>&TB_iframe=true&height=500&width=700" class="thickbox" title='Export Module'><?php _e('Export',$flutter_domain); ?></a></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
<form style="display:none" id="do_export" name="do_export" action="<?php echo FLUTTER_URI."RCCWP_ExportModule.php" ?>" method="post" >
<input type="text" name="write_panels"/>
<input type="text" name="custom-write-module-id"/>
</form>
</div>
<?php
}
}
?>