/** * Create a duplicate. * * @param integer $customWriteModuleId * @param string $duplicate_name the name of the duplicate, if false, * the name "[MODULE NAME] copy [x] will be given to the duplicate. */ function Create($customWriteModuleId, $duplicate_name = false) { global $wpdb; // Get module name $customModule = RCCWP_CustomWriteModule::Get($customWriteModuleId); if (!$duplicate_name) { // go ahead and rename, then duplicate $duplicate_name = $customModule->name; if ($other_blocks = $wpdb->get_results("SELECT duplicate_name FROM " . FLUTTER_TABLE_MODULES_DUPLICATES . " WHERE duplicate_name LIKE '" . preg_replace('/\\scopy\\s[0-9]*/', '', $duplicate_name) . " %' ORDER BY duplicate_id DESC")) { $duplicate_name = $other_blocks[0]->duplicate_name; $testcase = substr($duplicate_name, -1, 1); $duplicate_name[strlen($duplicate_name) - 1] = intval($testcase) + 1; } else { $duplicate_name .= ' copy 2'; } } $wpdb->query("INSERT INTO " . FLUTTER_TABLE_MODULES_DUPLICATES . " (module_id, duplicate_name) VALUES ({$customWriteModuleId}, '{$duplicate_name}')"); FlutterLayoutBlock::UpdateAllModulesSettings(); return $wpdb->insert_id; }
$moduleTmpPath = "{$tmpPath}{$module->name}"; chmod_R($moduleTmpPath, 0777); // Export write panels //check if arrary the write modules is empty if ($_POST["write_panels"] != NULL) { $write_panels = split(",", $_POST["write_panels"]); foreach ($write_panels as $panelID) { $writePanel = RCCWP_CustomWritePanel::Get($panelID); $exportedFilename = $moduleTmpPath . DIRECTORY_SEPARATOR . '_' . $writePanel->name . '.pnl'; RCCWP_CustomWritePanel::Export($panelID, $exportedFilename); } } // Export duplicates and description $moduleInfoFilename = $moduleTmpPath . DIRECTORY_SEPARATOR . 'module_info.exp'; $moduleInfo_exported_data['duplicates'] = RCCWP_ModuleDuplicate::GetCustomModulesDuplicates($moduleID); $moduleInfo_exported_data['moduleinfo'] = RCCWP_CustomWriteModule::Get($moduleID); $handle = fopen($moduleInfoFilename, "w"); $result = @fwrite($handle, serialize($moduleInfo_exported_data)); @fclose($handle); // -- Create zip file $zipFile = "{$tmpPath}{$module->name}.zip"; chdir($moduleTmpPath . DIRECTORY_SEPARATOR); if (RCCWP_Application::CheckCompressionProgramZip()) { $command = "zip -r {$zipFile} ./*"; } else { _e('Cannot find zip program', $flutter_domain); return; } exec($command, $out, $err); // send file in header header('Content-type: binary');
/** * Deletes a module and all its child fields as well as the module folder. * * @param integer $customWriteModuleId module id. */ function Delete($customWriteModuleId = null) { include_once 'RCCWP_CustomGroup.php'; if (isset($customWriteModuleId)) { global $wpdb; $customWriteModule = RCCWP_CustomWriteModule::Get($customWriteModuleId); $customWriteModuleName = $customWriteModule->name; $sql = sprintf("DELETE FROM " . RC_CWP_TABLE_MODULES . " WHERE id = %d", $customWriteModuleId); $wpdb->query($sql); // Remove template folder if (!empty($customWriteModuleName)) { $moduleTemplateFolder = FLUTTER_MODULES_DIR . $customWriteModuleName; RCCWP_CustomWriteModule::remove_dir($moduleTemplateFolder); } // Remove Layout data FlutterLayoutBlock::DeleteModule($customWriteModuleId); } }
function View($param = 23) { global $flutter_domain; if (isset($_GET['custom-write-module-id']) && !empty($_GET['custom-write-module-id'])) { $customWriteModuleId = (int) $_GET['custom-write-module-id']; } if (isset($_POST['custom-write-module-id']) && !empty($_POST['custom-write-module-id'])) { $customWriteModuleId = (int) $_POST['custom-write-module-id']; } $customWriteModule = RCCWP_CustomWriteModule::Get($customWriteModuleId); ?> <div class="wrap"> <h2><?php _e('Custom Write Module Info', $flutter_domain); ?> </h2> <h4><a href="?page=FlutterManageModules&view-modules=1"> « <?php _e('Back to Custom Modules List', $flutter_domain); ?> </a></h4> <form action="" method="post" id="view-write-module-form"> <input type="hidden" name="custom-write-module-id" value="<?php echo $customWriteModuleId; ?> " /> <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> <tbody> <tr> <th scope="row" align="right"><?php _e('Name', $flutter_domain); ?> :</th> <td><?php echo $customWriteModule->name; ?> </td> </tr> <tr> <th scope="row" align="right"><?php _e('Description', $flutter_domain); ?> :</th> <td><?php echo $customWriteModule->description; ?> </td> </tr> </tbody> </table> <script type="text/javascript" language="javascript"> function confirmBeforeDelete() { return confirm("<?php _e('Are you sure you want to delete this module? Please notice that all the template files of this module will be deleted too.', $flutter_domain); ?> "); } </script> <p class="submit" > <input name="edit-custom-write-module" type="submit" id="edit-custom-write-module" value="<?php _e('Edit Module', $flutter_domain); ?> " /> <input onclick="return confirmBeforeDelete();" name="delete-custom-write-module" type="submit" id="delete-custom-write-module" value="<?php _e('Delete Module', $flutter_domain); ?> " /> </p> </form> <form action="" method="post" id="view-module-duplicates"> <br /><br /> <h3><?php _e('Module Duplicates for Layout', $flutter_domain); ?> </h3> <div class="tablenav"><div class="alignright"> <input name="create-module-duplicate" type="submit" id="create-module-duplicate" value="<?php _e('Create Duplicate', $flutter_domain); ?> " class="button-secondary" /> </div></div> <br class="clear"/> <table cellpadding="3" cellspacing="3" width="100%" class="widefat"> <thead> <tr> <th scope="col"><?php _e('Name', $flutter_domain); ?> </th> <th scope="col" colspan="2"><?php _e('Action', $flutter_domain); ?> </th> </tr> </thead> <tbody> <?php $customWriteModuleDuplicates = RCCWP_ModuleDuplicate::GetCustomModulesDuplicates($customWriteModuleId); foreach ($customWriteModuleDuplicates as $customWriteModuleDuplicate) { $class = $class == '' ? 'alternate' : ''; ?> <tr class="<?php echo $class; ?> "> <td><?php echo $customWriteModuleDuplicate->duplicate_name; ?> </td> <td><a href="<?php echo RCCWP_ManagementPage::GetModuleDuplicateEditUrl($customWriteModuleId, $customWriteModuleDuplicate->duplicate_id); ?> " class="edit"><?php _e('Rename', $flutter_domain); ?> </a></td> <td><a href="<?php echo RCCWP_ManagementPage::GetModuleDuplicateDeleteUrl($customWriteModuleId, $customWriteModuleDuplicate->duplicate_id); ?> " class="delete"><?php _e('Delete', $flutter_domain); ?> </a></td> </tr> <?php } ?> </tbody> </table> </form> </div> <?php }
} else { $templatesNamesStr = $templatesNamesStr . "<option value='" . $file . "'>" . $file . "</option>"; } } } closedir($handle); } ?> <div class="lbContent"> <?php global $wpdb, $canvas; $variables = $wpdb->get_results("SELECT * FROM " . $canvas->variables . " WHERE parent = '{$block_id}' ORDER BY variable_id"); $title = $wpdb->get_results("SELECT * FROM " . $canvas->main . " WHERE block_id = '{$block_id}'"); // Get module name include_once 'RCCWP_CustomWriteModule.php'; $customWriteModule = RCCWP_CustomWriteModule::Get($title[0]->module_id); if ($title[0]->duplicate_id == 0) { $title[0]->module_title = $customWriteModule->name; } else { $title[0]->module_title = $wpdb->get_var("SELECT duplicate_name FROM " . $canvas->duplicates . " WHERE duplicate_id = " . $title[0]->duplicate_id); } $content = '<h3>' . $title[0]->module_title . ''; if ($title[0]->author != '' && $title[0]->uri != '') { $content .= '<span>by <a target="new" href="' . $title[0]->uri . '">' . $title[0]->author . '</a></span>'; } if ($title[0]->description != '') { $content .= '<p>' . $title[0]->description . '</p>'; } $F = "\$F"; $module_template_name_id = 'canvas_' . $zone . '_' . $position . '_' . $block_id . '_module_template_name'; $ListboxAJAX = FLUTTER_URI . "ajax/canvas-populate-listbox.php?mod_name=" . $module_name . "&template_name=";