root/afridex/plugins/fresh-page/RCCWP_CustomWritePanelPage.php

Revision 21, 11.4 kB (checked in by admin, 18 years ago)
Line 
1<?php
2include_once('RCCWP_CustomWritePanel.php');
3
4class RCCWP_CustomWritePanelPage
5{
6        function Content($customWritePanel = null)
7        {
8                $customWritePanelName = "";
9                $customWritePanelDescription = "";
10                $write_panel_category_ids = array();
11               
12                if ($customWritePanel != null)
13                {
14                        $customWritePanelName = $customWritePanel->name;
15                        $customWritePanelDescription = $customWritePanel->description;
16                        $customWritePanelDisplayOrder = $customWritePanel->display_order;
17                        $customWritePanelType = $customWritePanel->type;
18                        $customWritePanelCategoryIds = RCCWP_CustomWritePanel::GetAssignedCategoryIds($customWritePanel->id);
19                        $customWritePanelStandardFieldIds = RCCWP_CustomWritePanel::GetStandardFieldIds($customWritePanel->id);
20                        $customWritePanelHiddenExtFieldCssIds = RCCWP_CustomWritePanel::GetHiddenExternalFieldCssIds($customWritePanel->id);
21                ?>
22                <input type="hidden" name="custom-write-panel-id" value="<?=$_POST['custom-write-panel-id']?>" />
23                <?php
24                }
25               
26                ?>
27                <table class="optiontable" border="0">
28                <tbody>
29
30                <tr valign="top">
31                        <th scope="row"> </th>
32                        <td align="left">
33                                <input type="radio" name="radPostPage" id="radPostPage" value="post" <?php if($customWritePanelType == 'post'){?> checked="checked" <?php } ?> onclick='showHide("Post");' /> <strong>Post </strong> &nbsp; &nbsp; &nbsp;
34                                <input type="radio" name="radPostPage" id="radPostPage" value="page" <?php if($customWritePanelType == 'page'){?> checked="checked" <?php } ?> onclick='showHide("Page");' /> <strong>Page</strong>
35                        </td>
36                </tr>
37                <tr valign="top">
38                        <th scope="row"  align="right">Name:</th>
39                        <td><input name="custom-write-panel-name" id="custom-write-panel-name" size="40" type="text" value="<?=$customWritePanelName?>" /></td>
40                </tr>
41<!--
42                <tr valign="top">
43                        <th scope="row">Description:</th>
44                        <td><textarea name="custom-write-panel-description" id="custom-write-panel-description" rows="2" cols="38"><?=$customWritePanelDescription?></textarea></td>
45                </tr>
46-->
47                <tr valign="top">
48<!--
49                        <th scope="row">Assigned Categories:</th>
50                        <td>
51                                <select multiple size="10" name="custom-write-panel-categories[]" style="width:305px">
52                                        <?php
53                                        $cats = RCCWP_Application::GetWpCategories();
54                                       
55                                        foreach ($cats as $cat) :
56                                                $selected = "";
57                                                if (in_array($cat->cat_ID, $customWritePanelCategoryIds))
58                                                {
59                                                        $selected = "selected=\"selected\"";
60                                                }
61                                        ?>
62                                                <option value="<?=$cat->cat_ID?>" <?=$selected?>><?=$cat->cat_name ?></option>
63                                        <?php
64                                        endforeach;
65                                        ?>
66                                </select>
67                        </td>
68                </tr>
69-->
70                                <!-- START :: Javascript for Image/Photo' Css Class -->
71                                <script type="text/javascript" language="javascript">
72                                        function showHide(name)
73                                        {
74                                                if(name == "Page")
75                                                {
76                                                        document.getElementById('catLabel').style.display = 'none';
77                                                        document.getElementById('catText').style.display = 'none';
78                                                }
79                                                else
80                                                {
81                                                        document.getElementById('catLabel').style.display = 'inline';
82                                                        document.getElementById('catText').style.display = 'inline';
83                                                }
84
85                                        }
86                                </script>
87                                <!-- END :: Javascript for Image/Photo' Css Class -->
88                       
89                        <th scope="row"  align="right"><div id="catLabel" style="display:inline;">Assigned Categories:</div></th>
90                        <td>
91                                <div id="catText" style="display:inline;">
92                                        <?php
93                                        $cats = RCCWP_Application::GetWpCategories();
94               
95                                        foreach ($cats as $cat) : 
96                                                $checked = "";
97                                                if(isset($_GET['custom-write-panel-id']) && !empty($_GET['custom-write-panel-id']))
98                                                {
99                                                        if (in_array($cat->cat_ID, $customWritePanelCategoryIds))
100                                                        {
101                                                                $checked = "checked=\"checked\"";
102                                                        }
103                                                }
104                                        ?>
105                                                <input type="checkbox" name="custom-write-panel-categories[]" value="<?=$cat->cat_ID?>" <?=$checked?> /> <?=$cat->cat_name ?> <br/>
106                                        <?php
107                                        endforeach;
108                                        ?>
109                                </div>
110                        </td>
111                </tr>
112<!--
113                <tr valign="top">
114                        <th scope="row">Standard Fields:</th>
115                        <td>
116                                <select multiple size="10" name="custom-write-panel-standard-fields[]" style="width:305px">
117                                        <?php
118                                        $standard_fields = RCCWP_Application::GetWpStandardFields();
119                                        foreach ($standard_fields as $field) :
120                                                $selected = "";
121                                                if ($customWritePanel != null)
122                                                {
123                                                        if (in_array($field->id, $customWritePanelStandardFieldIds))
124                                                        {
125                                                                $selected = "selected=\"selected\"";
126                                                        }
127                                                }
128                                                else
129                                                {
130                                                        if ($field->default_inclusion == 'true')
131                                                        {
132                                                                $selected = "selected=\"selected\""; 
133                                                        }
134                                                }
135                                        ?>
136                                                <option value="<?=$field->id?>" <?=$selected?>><?=$field->name?></option>
137                                        <?php
138                                        endforeach;
139                                        ?>
140                                </select>
141                        </td>
142                </tr>
143        -->
144
145                <tr valign="top">
146                        <th scope="row" align="right">Standard Fields:</th>
147                        <td>
148                                        <?php
149                                        $standard_fields = RCCWP_Application::GetWpStandardFields();
150                                        foreach ($standard_fields as $field) :
151                                                $checked = "";
152                                                if ($customWritePanel != null)
153                                                {
154                                                        if (in_array($field->id, $customWritePanelStandardFieldIds))
155                                                        {
156                                                                $checked = "checked=\"checked\"";
157                                                        }
158                                                }
159                                                else
160                                                {
161                                                        if ($field->default_inclusion == 'true')
162                                                        {
163                                                                $checked = "checked=\"checked\""; 
164                                                        }
165                                                }
166                                        ?>
167                                                <input type="checkbox" name="custom-write-panel-standard-fields[]" value="<?=$field->id?>" <?=$checked?> /> <?=$field->name?> <br />
168                                        <?php
169                                        endforeach;
170                                        ?>
171                                </select>
172                        </td>
173                </tr>
174<!--
175                <tr valign="top">
176                        <th scope="row">Hidden External Fields:</th>
177                        <td>
178                        <?php
179                        $extFields = implode("\n", (array)$customWritePanelHiddenExtFieldCssIds);
180                        ?>
181                        <textarea name="custom-write-panel-ext-fields" id="custom-write-panel-ext-fields" rows="2" cols="38"><?=$extFields?></textarea><br />
182                        <em>Other plugins may add input fields in write panel. Enter the input fields' css ID here to hide them. Separate each value with a newline.</em>
183                        </td>
184                </tr>
185-->
186                <tr valign="top">
187                        <th scope="row" align="right">Hidden External Fields:</th>
188                        <td>
189                        <?php
190//                      $extFields = implode("\n", (array)$customWritePanelHiddenExtFieldCssIds);
191                        ?>
192                                <input type="checkbox" name="custom-write-panel-ext-fields[]" id="custom-write-panel-ext-fields[]" value="tagdiv" <?php if (isset($customWritePanelHiddenExtFieldCssIds)) { foreach($customWritePanelHiddenExtFieldCssIds as $item){ if($item == 'tagdiv'){ ?> checked="checked" <?php } } }?> /> Tags
193                                <br/>
194                                <input type="checkbox" name="custom-write-panel-ext-fields[]" id="custom-write-panel-ext-fields[]" value="wp-bookmarklet" <?php if (isset($customWritePanelHiddenExtFieldCssIds)) { foreach($customWritePanelHiddenExtFieldCssIds as $item) { if($item == 'wp-bookmarklet'){ ?> checked="checked" <?php } } }?> /> WordPress Bookmarklet
195                        </td>
196                </tr>
197
198                <tr valign="top">
199                        <th scope="row" align="right">Order:</th>
200                        <td><input name="custom-write-panel-order" id="custom-write-panel-order" size="2" type="text" value="<?=$customWritePanelDisplayOrder?>" /></td>
201                </tr>
202                <?php
203                if (!isset($customWritePanel)) :
204                ?>
205                <tr>
206                        <th scope="row" align="right">Custom Fields:</th>
207                        <td>Add custom fields later by editing this custom write panel.</td>
208                </tr>
209                <?php
210                endif;
211                ?>
212                </tbody>
213                </table>
214               
215                <?php
216        }
217       
218        function Edit()
219        {
220                $customWritePanel = RCCWP_Application::GetCustomWritePanels((int)$_REQUEST['custom-write-panel-id']);
221                ?>
222                <div class="wrap">
223               
224                <h2>Edit Custom Write Panel</h2>
225               
226                <form action="" method="post" id="edit-custom-write-panel-form">
227               
228                <?php
229                RCCWP_CustomWritePanelPage::Content($customWritePanel);
230                ?>
231               
232                <p class="submit" >
233                        <input name="cancel-edit-custom-write-panel" type="submit" id="cancel-edit-custom-write-panel" value="<?php _e('Cancel'); ?>" />
234                        <input name="submit-edit-custom-write-panel" type="submit" id="submit-edit-custom-write-panel" value="<?php _e('Update'); ?>" />
235                </p>
236                </form>
237               
238                </div>
239               
240                <?php
241        }
242       
243        function GetAssignedCategoriesString($customWritePanel)
244        {
245                $results = RCCWP_CustomWritePanel::GetAssignedCategories($customWritePanel);
246                $str = '';
247                foreach ($results as $r)
248                {
249                        $str .= $r->cat_name . ', ';   
250                }
251                $str = substr($str, 0, strlen($str) - 2); // deletes last comma and whitespace
252                return $str;
253        }
254       
255        function GetStandardFieldsString($customWritePanel)
256        {
257                $results = RCCWP_CustomWritePanel::GetStandardFields($customWritePanel);
258                foreach ($results as $r)
259                {
260                        $str .= $r->name . ', ';       
261                }
262                $str = substr($str, 0, strlen($str) - 2); // deletes last comma and whitespace
263                return $str;
264        }
265       
266        function View($param = 23)
267        {
268                if(isset($_GET['custom-write-panel-id']) && !empty($_GET['custom-write-panel-id']) )
269                        $customWritePanelId = (int)$_GET['custom-write-panel-id'];
270                if(isset($_POST['custom-write-panel-id']) && !empty($_POST['custom-write-panel-id']) )
271                        $customWritePanelId = (int)$_POST['custom-write-panel-id'];
272
273                $customWritePanel = RCCWP_Application::GetCustomWritePanels($customWritePanelId);
274                ?>
275
276                <div class="wrap">
277
278                <h2>Custom Write Panel Info</h2>
279
280                <form action="" method="post" id="view-write-panel-form">
281               
282                <input type="hidden" name="custom-write-panel-id" value="<?=$customWritePanelId?>" />
283                       
284                <fieldset class="options">
285                       
286                <table class="optiontable">
287                <tbody>
288                <tr>
289                        <th scope="row" align="right">Name:</th>
290                        <td><?=$customWritePanel->name?></td>
291                </tr>
292<!--
293                <tr>
294                        <th scope="row">Description:</th>
295                        <td><?=$customWritePanel->description?></td>
296                </tr>
297-->
298                <tr>
299                        <th scope="row" align="right">Assigned Categories:</th>
300                        <td><?=RCCWP_CustomWritePanelPage::GetAssignedCategoriesString($customWritePanelId)?></td>
301                </tr>
302                <tr>
303                        <th scope="row" align="right">Standard Fields:</th>
304                        <td><?=RCCWP_CustomWritePanelPage::GetStandardFieldsString($customWritePanelId)?></td>
305                </tr>
306                <tr>
307                        <th scope="row" align="right">Type:</th>
308                        <td><?=$customWritePanel->type;?></td>
309                </tr>
310                </tbody>
311                </table>
312                 
313                </fieldset>
314               
315                <p class="submit" ><input name="edit-custom-write-panel" type="submit" id="edit-custom-write-panel" value="Edit Write Panel" /></p>
316               
317                <fieldset class="options">
318                <legend>Custom Fields</legend>
319               
320                <table cellpadding="3" cellspacing="3" width="100%" class="widefat">
321                <thead>
322                <tr>
323                        <th scope="col">Order</th>
324                        <th scope="col">Name</th>
325                        <th scope="col">Type</th>
326<!--                    <th scope="col">Description</th> -->
327                        <th scope="col" colspan="2">Action</th>
328                </tr>
329                </thead>
330                <tbody>
331                <?php
332                $custom_fields = RCCWP_CustomWritePanel::GetCustomFields($customWritePanelId);
333                foreach ($custom_fields as $field) :
334                        $class = $class == '' ? 'alternate' : '';
335                ?>
336                        <tr class="<?=$class?>">
337                                <td align="right" width="3"><?=$field->display_order?></td>
338                                <td align="center"><?=$field->name?></td>
339                                <td><?=$field->type?></td>
340<!--                            <td><?=$field->description?></td> -->
341                                <td><a href="<?=RCCWP_ManagementPage::GetCustomFieldEditUrl($customWritePanelId, $field->id)?>" class="edit">Edit</a></td>
342                                <td><a href="<?=RCCWP_ManagementPage::GetCustomFieldDeleteUrl($customWritePanelId, $field->id)?>" class="delete">Delete</a></td>
343                        </tr>
344                <?php
345                endforeach;
346                ?>
347                </tbody>
348                </table>
349                 
350                </fieldset>
351               
352                <p class="submit" ><input name="create-custom-field" type="submit" id="create-custom-field" value="Create Custom Field" /></p>
353               
354                </form>
355
356                </div>
357               
358                <?php
359        }
360}
361?>
Note: See TracBrowser for help on using the browser.