| [21] | 1 | <?php |
|---|
| 2 | include_once('RCCWP_CustomGroup.php'); |
|---|
| 3 | |
|---|
| 4 | class RCCWP_CustomGroupPage |
|---|
| 5 | { |
|---|
| 6 | function Content($customGroup = null) |
|---|
| 7 | { |
|---|
| 8 | $customGroupName = ""; |
|---|
| 9 | if (isset($_GET['custom-write-panel-id']) ) |
|---|
| 10 | $customWritePanelId = $_GET['custom-write-panel-id']; |
|---|
| 11 | if (isset($_POST['custom-write-panel-id']) ) |
|---|
| 12 | $customWritePanelId = $_POST['custom-write-panel-id']; |
|---|
| 13 | |
|---|
| 14 | if ($customGroup != null) |
|---|
| 15 | { |
|---|
| 16 | $customGroupName = $customGroup->name; |
|---|
| 17 | $customGroupDuplicate = $customGroup->duplicate; |
|---|
| 18 | $customGroupAtRight = $customGroup->at_right; |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | ?> |
|---|
| 22 | <?php if($customWritePanelId) { ?> |
|---|
| 23 | <input type="hidden" name="custom-write-panel-id" value="<?php echo $customWritePanelId?>"> |
|---|
| 24 | <?php } ?> |
|---|
| 25 | |
|---|
| 26 | <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> |
|---|
| 27 | <tbody> |
|---|
| 28 | |
|---|
| 29 | <tr valign="top"> |
|---|
| 30 | <th scope="row" align="right">Name:</th> |
|---|
| 31 | <td><input name="custom-group-name" id="custom-group-name" size="40" type="text" value="<?php echo $customGroupName?>" /></td> |
|---|
| 32 | </tr> |
|---|
| 33 | |
|---|
| 34 | <tr> |
|---|
| 35 | <th scope="row" align="right">Duplication:</th> |
|---|
| 36 | <td><input name="custom-group-duplicate" id="custom-group-duplicate" type="checkbox" value="1" <?php echo $customGroupDuplicate == 0 ? "":"checked" ?> /> The group can be duplicated</td> |
|---|
| 37 | </tr> |
|---|
| 38 | |
|---|
| 39 | <tr> |
|---|
| 40 | <th scope="row" align="right">Position:</th> |
|---|
| 41 | <td><input name="custom-group-at_right" id="custom-group-at_right" type="checkbox" value="1" <?php echo $customGroupAtRight == 0 ? "":"checked" ?> /> Add the group on the right.</td> |
|---|
| 42 | </tr> |
|---|
| 43 | |
|---|
| 44 | <?php |
|---|
| 45 | if (!isset($customGroup)) : |
|---|
| 46 | ?> |
|---|
| 47 | <tr> |
|---|
| 48 | <th scope="row" align="right">Custom Fields:</th> |
|---|
| 49 | <td>Add custom fields later by editing this custom group.</td> |
|---|
| 50 | </tr> |
|---|
| 51 | <?php |
|---|
| 52 | endif; |
|---|
| 53 | ?> |
|---|
| 54 | </tbody> |
|---|
| 55 | </table> |
|---|
| 56 | |
|---|
| 57 | <?php |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | function Edit() |
|---|
| 61 | { |
|---|
| 62 | $customGroup = RCCWP_CustomGroup::Get((int)$_REQUEST['custom-group-id']); |
|---|
| 63 | ?> |
|---|
| 64 | <div class="wrap"> |
|---|
| 65 | |
|---|
| 66 | <h2>Edit Group - <?php echo $customGroup->name?></h2> |
|---|
| 67 | |
|---|
| 68 | <form action="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('submit-edit-custom-group')."&custom-group-id={$customGroup->id}"?>" method="post" id="edit-custom-group-form"> |
|---|
| 69 | |
|---|
| 70 | <?php |
|---|
| 71 | RCCWP_CustomGroupPage::Content($customGroup); |
|---|
| 72 | ?> |
|---|
| 73 | |
|---|
| 74 | <p class="submit" > |
|---|
| 75 | <a style="color:black" href="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-edit-custom-group')?>" class="button"><?php _e('Cancel'); ?></a> |
|---|
| 76 | <input type="submit" id="submit-edit-custom-group" value="<?php _e('Update'); ?>" /> |
|---|
| 77 | </p> |
|---|
| 78 | </form> |
|---|
| 79 | |
|---|
| 80 | </div> |
|---|
| 81 | |
|---|
| 82 | <?php |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | function GetCustomFields($customGroupId) |
|---|
| 86 | { |
|---|
| 87 | global $wpdb; |
|---|
| 88 | $sql = "SELECT cf.id, cf.name, tt.name AS type, cf.description, cf.display_order, co.options, co.default_option AS default_value, tt.has_options, cp.properties, tt.has_properties, tt.allow_multiple_values FROM " . RC_CWP_TABLE_GROUP_FIELDS . |
|---|
| 89 | " cf LEFT JOIN " . RC_CWP_TABLE_CUSTOM_FIELD_OPTIONS . " co ON cf.id = co.custom_field_id" . |
|---|
| 90 | " LEFT JOIN " . RC_CWP_TABLE_CUSTOM_FIELD_PROPERTIES . " cp ON cf.id = cp.custom_field_id" . |
|---|
| 91 | " JOIN " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " tt ON cf.type = tt.id" . |
|---|
| 92 | " WHERE group_id = " . $customGroupId . |
|---|
| 93 | " ORDER BY cf.display_order"; |
|---|
| 94 | $results =$wpdb->get_results($sql); |
|---|
| 95 | if (!isset($results)) |
|---|
| 96 | $results = array(); |
|---|
| 97 | |
|---|
| 98 | for ($i = 0; $i < $wpdb->num_rows; ++$i) |
|---|
| 99 | { |
|---|
| 100 | $results[$i]->options = unserialize($results[$i]->options); |
|---|
| 101 | $results[$i]->properties = unserialize($results[$i]->properties); |
|---|
| 102 | $results[$i]->default_value = unserialize($results[$i]->default_value); |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | return $results; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | /*function View($param = 23) |
|---|
| 109 | { |
|---|
| 110 | |
|---|
| 111 | if(isset($_GET['custom-write-panel-id']) && !empty($_GET['custom-write-panel-id']) ) |
|---|
| 112 | $customWritePanelId = (int)$_GET['custom-write-panel-id']; |
|---|
| 113 | if(isset($_POST['custom-write-panel-id']) && !empty($_POST['custom-write-panel-id']) ) |
|---|
| 114 | $customWritePanelId = (int)$_POST['custom-write-panel-id']; |
|---|
| 115 | |
|---|
| 116 | if(isset($_GET['custom-group-id']) && !empty($_GET['custom-group-id']) ) |
|---|
| 117 | $customGroupId = (int)$_GET['custom-group-id']; |
|---|
| 118 | if(isset($_POST['custom-group-id']) && !empty($_POST['custom-group-id']) ) |
|---|
| 119 | $customGroupId = (int)$_POST['custom-group-id']; |
|---|
| 120 | |
|---|
| 121 | $customGroup = RCCWP_CustomGroup::Get($customGroupId); |
|---|
| 122 | |
|---|
| 123 | ?> |
|---|
| 124 | |
|---|
| 125 | <div class="wrap"> |
|---|
| 126 | |
|---|
| 127 | <h2>Custom Group Info</h2> |
|---|
| 128 | <h4><a href="<?php echo RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($customWritePanelId); ?>"> « Back to Module</a></h4> |
|---|
| 129 | <form action="" method="post" id="view-group-form"> |
|---|
| 130 | |
|---|
| 131 | <input type="hidden" name="custom-group-id" value="<?php echo $customGroupId?>" /> |
|---|
| 132 | |
|---|
| 133 | <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> |
|---|
| 134 | <tbody> |
|---|
| 135 | <tr> |
|---|
| 136 | <th scope="row" align="right">Name:</th> |
|---|
| 137 | <td><?php echo $customGroup->name ?></td> |
|---|
| 138 | </tr> |
|---|
| 139 | </tbody> |
|---|
| 140 | </table> |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | <a href="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-group')."&custom-group-id=$customGroupId"?>" class="button-secondary"><?php _e('Edit Group'); ?></a> |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | <h3>Custom Fields</h3> |
|---|
| 147 | |
|---|
| 148 | <div class="tablenav"><div class="alignright"> |
|---|
| 149 | <input name="flutter_action" type="hidden" value="create-custom-field" /> |
|---|
| 150 | <input name="create-custom-field" type="submit" id="create-custom-field" value="Create Custom Field" class="button-secondary" /> |
|---|
| 151 | </div></div> |
|---|
| 152 | <br class="clear"/> |
|---|
| 153 | |
|---|
| 154 | <table cellpadding="3" cellspacing="3" width="100%" class="widefat"> |
|---|
| 155 | <thead> |
|---|
| 156 | <tr> |
|---|
| 157 | <th scope="col">Order</th> |
|---|
| 158 | <th scope="col">Name</th> |
|---|
| 159 | <th scope="col">Type</th> |
|---|
| 160 | <!-- <th scope="col">Description</th> --> |
|---|
| 161 | <th scope="col" colspan="2">Action</th> |
|---|
| 162 | </tr> |
|---|
| 163 | </thead> |
|---|
| 164 | <tbody> |
|---|
| 165 | <?php |
|---|
| 166 | $custom_fields = RCCWP_CustomGroup::GetCustomFields($customGroupId); |
|---|
| 167 | foreach ($custom_fields as $field) : |
|---|
| 168 | $class = $class == '' ? 'alternate' : ''; |
|---|
| 169 | ?> |
|---|
| 170 | <tr class="<?php echo $class?>"> |
|---|
| 171 | <td align="right" width="3"><?php echo $field->display_order?></td> |
|---|
| 172 | <td align="center"><?php echo $field->name?></td> |
|---|
| 173 | <td><?php echo $field->type?></td> |
|---|
| 174 | <!-- <td><?php echo $field->description?></td> --> |
|---|
| 175 | <td><a href="<?php echo RCCWP_ManagementPage::GetCustomFieldEditUrl($customWritePanelId, $customGroupId, $field->id)?>" class="edit">Edit</a></td> |
|---|
| 176 | <td><a href="<?php echo RCCWP_ManagementPage::GetCustomFieldDeleteUrl($customGroupId, $field->id)?>" class="delete">Delete</a></td> |
|---|
| 177 | </tr> |
|---|
| 178 | <?php |
|---|
| 179 | endforeach; |
|---|
| 180 | ?> |
|---|
| 181 | </tbody> |
|---|
| 182 | </table> |
|---|
| 183 | |
|---|
| 184 | </form> |
|---|
| 185 | |
|---|
| 186 | </div> |
|---|
| 187 | |
|---|
| 188 | <?php |
|---|
| 189 | }*/ |
|---|
| 190 | } |
|---|
| 191 | ?> |
|---|