| [21] | 1 | <?php |
|---|
| 2 | include_once('RCCWP_CustomWriteModule.php'); |
|---|
| 3 | |
|---|
| 4 | class RCCWP_CustomWriteModulePage |
|---|
| 5 | { |
|---|
| 6 | function Content($customWriteModule = null) |
|---|
| 7 | { |
|---|
| 8 | $customWriteModuleName = ""; |
|---|
| 9 | |
|---|
| 10 | if ($customWriteModule != null) |
|---|
| 11 | { |
|---|
| 12 | $customWriteModuleName = $customWriteModule->name; |
|---|
| 13 | ?> |
|---|
| 14 | <input type="hidden" name="custom-write-module-id" value="<?php echo $_REQUEST['custom-write-module-id']?>" /> |
|---|
| 15 | <?php |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | ?> |
|---|
| 19 | |
|---|
| 20 | <?php |
|---|
| 21 | if (isset($_GET['err_msg'])) : |
|---|
| 22 | switch ($_GET['err_msg']){ |
|---|
| 23 | case -1: |
|---|
| 24 | ?> |
|---|
| 25 | <div class="updated fade"><p> A module with the same name already exists. Please choose a different name.</p></div> |
|---|
| 26 | |
|---|
| 27 | <?php |
|---|
| 28 | } |
|---|
| 29 | endif; |
|---|
| 30 | ?> |
|---|
| 31 | |
|---|
| 32 | <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> |
|---|
| 33 | <tbody> |
|---|
| 34 | |
|---|
| 35 | <tr valign="top"> |
|---|
| 36 | <th scope="row" align="right">Name:</th> |
|---|
| 37 | <td><input name="custom-write-module-name" id="custom-write-module-name" size="40" type="text" value="<?php echo $customWriteModuleName?>" /></td> |
|---|
| 38 | </tr> |
|---|
| 39 | |
|---|
| 40 | <tr valign="top"> |
|---|
| 41 | <th scope="row" align="right">Description:</th> |
|---|
| 42 | <td><textarea name="custom-write-module-description" id="custom-write-module-description" rows="3" cols="40"><?php echo $customWriteModule->description?></textarea></td> |
|---|
| 43 | </tr> |
|---|
| 44 | |
|---|
| 45 | </tbody> |
|---|
| 46 | </table> |
|---|
| 47 | |
|---|
| 48 | <?php |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | function Edit() |
|---|
| 52 | { |
|---|
| 53 | $customWriteModule = RCCWP_CustomWriteModule::Get((int)$_REQUEST['custom-write-module-id']); |
|---|
| 54 | ?> |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | <div class="wrap"> |
|---|
| 59 | |
|---|
| 60 | <h2>Edit Custom Write Module</h2> |
|---|
| 61 | |
|---|
| 62 | <form action="<?php echo RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($_REQUEST['custom-write-module-id']) ?>" method="post" id="edit-custom-write-module-form"> |
|---|
| 63 | |
|---|
| 64 | <?php |
|---|
| 65 | RCCWP_CustomWriteModulePage::Content($customWriteModule); |
|---|
| 66 | ?> |
|---|
| 67 | |
|---|
| 68 | <p class="submit" > |
|---|
| 69 | <input name="cancel-edit-custom-write-module" type="submit" id="cancel-edit-custom-write-module" value="<?php _e('Cancel'); ?>" /> |
|---|
| 70 | <input name="submit-edit-custom-write-module" type="submit" id="submit-edit-custom-write-module" value="<?php _e('Update'); ?>" /> |
|---|
| 71 | </p> |
|---|
| 72 | </form> |
|---|
| 73 | |
|---|
| 74 | </div> |
|---|
| 75 | |
|---|
| 76 | <?php |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | function View($param = 23) |
|---|
| 81 | { |
|---|
| 82 | if(isset($_GET['custom-write-module-id']) && !empty($_GET['custom-write-module-id']) ) |
|---|
| 83 | $customWriteModuleId = (int)$_GET['custom-write-module-id']; |
|---|
| 84 | if(isset($_POST['custom-write-module-id']) && !empty($_POST['custom-write-module-id']) ) |
|---|
| 85 | $customWriteModuleId = (int)$_POST['custom-write-module-id']; |
|---|
| 86 | |
|---|
| 87 | $customWriteModule = RCCWP_CustomWriteModule::Get($customWriteModuleId); |
|---|
| 88 | ?> |
|---|
| 89 | |
|---|
| 90 | <div class="wrap"> |
|---|
| 91 | |
|---|
| 92 | <h2>Custom Write Module Info</h2> |
|---|
| 93 | <h4><a href="?page=FlutterManageModules&view-modules=1"> « Back to Custom Modules List</a></h4> |
|---|
| 94 | <form action="" method="post" id="view-write-module-form"> |
|---|
| 95 | |
|---|
| 96 | <input type="hidden" name="custom-write-module-id" value="<?php echo $customWriteModuleId?>" /> |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> |
|---|
| 100 | <tbody> |
|---|
| 101 | <tr> |
|---|
| 102 | <th scope="row" align="right">Name:</th> |
|---|
| 103 | <td><?php echo $customWriteModule->name?></td> |
|---|
| 104 | </tr> |
|---|
| 105 | <tr> |
|---|
| 106 | <th scope="row" align="right">Description:</th> |
|---|
| 107 | <td><?php echo $customWriteModule->description?></td> |
|---|
| 108 | </tr> |
|---|
| 109 | </tbody> |
|---|
| 110 | </table> |
|---|
| 111 | |
|---|
| 112 | <script type="text/javascript" language="javascript"> |
|---|
| 113 | function confirmBeforeDelete() |
|---|
| 114 | { |
|---|
| 115 | return confirm("Are you sure you want to delete this module? Please notice that all the template files of this module will be deleted too."); |
|---|
| 116 | } |
|---|
| 117 | </script> |
|---|
| 118 | <p class="submit" > |
|---|
| 119 | <input name="edit-custom-write-module" type="submit" id="edit-custom-write-module" value="Edit Module" /> |
|---|
| 120 | <input onclick="return confirmBeforeDelete();" name="delete-custom-write-module" type="submit" id="delete-custom-write-module" value="Delete Module" /> |
|---|
| 121 | </p> |
|---|
| 122 | |
|---|
| 123 | </form> |
|---|
| 124 | |
|---|
| 125 | <form action="" method="post" id="view-module-duplicates"> |
|---|
| 126 | <br /><br /> |
|---|
| 127 | <h3>Module Duplicates for Layout</h3> |
|---|
| 128 | <div class="tablenav"><div class="alignright"> |
|---|
| 129 | <input name="create-module-duplicate" type="submit" id="create-module-duplicate" value="Create Duplicate" class="button-secondary" /> |
|---|
| 130 | </div></div> |
|---|
| 131 | <br class="clear"/> |
|---|
| 132 | |
|---|
| 133 | <table cellpadding="3" cellspacing="3" width="100%" class="widefat"> |
|---|
| 134 | <thead> |
|---|
| 135 | <tr> |
|---|
| 136 | <th scope="col">Name</th> |
|---|
| 137 | <th scope="col" colspan="2">Action</th> |
|---|
| 138 | </tr> |
|---|
| 139 | </thead> |
|---|
| 140 | <tbody> |
|---|
| 141 | <?php |
|---|
| 142 | $customWriteModuleDuplicates = RCCWP_ModuleDuplicate::GetCustomModulesDuplicates($customWriteModuleId); |
|---|
| 143 | foreach ($customWriteModuleDuplicates as $customWriteModuleDuplicate) : |
|---|
| 144 | $class = $class == '' ? 'alternate' : ''; |
|---|
| 145 | ?> |
|---|
| 146 | <tr class="<?php echo $class?>"> |
|---|
| 147 | <td><?php echo $customWriteModuleDuplicate->duplicate_name?></td> |
|---|
| 148 | <td><a href="<?php echo RCCWP_ManagementPage::GetModuleDuplicateEditUrl($customWriteModuleId, $customWriteModuleDuplicate->duplicate_id)?>" class="edit">Rename</a></td> |
|---|
| 149 | <td><a href="<?php echo RCCWP_ManagementPage::GetModuleDuplicateDeleteUrl($customWriteModuleId, $customWriteModuleDuplicate->duplicate_id)?>" class="delete">Delete</a></td> |
|---|
| 150 | </tr> |
|---|
| 151 | <?php |
|---|
| 152 | endforeach; |
|---|
| 153 | ?> |
|---|
| 154 | </tbody> |
|---|
| 155 | </table> |
|---|
| 156 | |
|---|
| 157 | </form> |
|---|
| 158 | |
|---|
| 159 | </div> |
|---|
| 160 | |
|---|
| 161 | <?php |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | function Import() |
|---|
| 165 | { |
|---|
| 166 | include_once('RCCWP_CustomWriteModule.php'); |
|---|
| 167 | |
|---|
| 168 | if(isset($_FILES['import-module-file']) && !empty($_FILES['import-module-file']['tmp_name']) ) { |
|---|
| 169 | $zipFilePath = $_FILES['import-module-file']['tmp_name']; |
|---|
| 170 | } |
|---|
| 171 | else { |
|---|
| 172 | die("Error uploading file!"); |
|---|
| 173 | } |
|---|
| 174 | |
|---|
| 175 | $moduleName = basename($_FILES['import-module-file']['name'], ".zip"); |
|---|
| 176 | $moduleID = RCCWP_CustomWriteModule::Import($zipFilePath, $moduleName); |
|---|
| 177 | unlink($zipFilePath); |
|---|
| 178 | |
|---|
| 179 | echo "<h3>The module was imported successfuly.</h3>"; |
|---|
| 180 | echo '<p><a href="' . RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($moduleID).'"> Click here </a> to edit the module. </p>'; |
|---|
| 181 | |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | } |
|---|
| 185 | ?> |
|---|