/** * 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; }
function SaveModuleSettings($blockID) { $moduleSettings = FlutterLayoutBlock::GetModuleSettingsByBlock($blockID); foreach ($moduleSettings->variables as $varKey => $variable) { $moduleSettings->variables[$varKey]->value = $_POST[$variable->variable_name]; } $moduleSettings->SaveValues(); }
/** * 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); } }
/** * Import default modules/panels in the theme if it is the first time to * activate the theme and add the theme settings to the database. * */ function ImportNewTheme($themeName) { // -- Add/update theme settings to the database FlutterLayoutBlock::UpdateModuleSettings(get_template_directory() . '/configure.xml', -1, '-', get_option('template')); FlutterLayoutBlock::UpdateAllModulesSettings(); // -- Import modules and panels if (RCCWP_Application::IsWordpressMu()) { if (get_site_option('Flutter_theme_ft_' . $themeName) == '1') { return; } update_site_option('Flutter_theme_ft_' . $themeName, '1'); } else { if (get_option('Flutter_theme_ft_' . $themeName) == '1') { return; } update_option('Flutter_theme_ft_' . $themeName, '1'); } $modulesFolder = get_template_directory() . '/Flutter_modules/'; $panelsFolder = get_template_directory() . '/Flutter_panels/'; // Import modules if ($handle = @opendir($modulesFolder)) { while (false !== ($file = readdir($handle))) { $filePath = $modulesFolder . $file; RCCWP_CustomWriteModule::Import($filePath); } } // Import panels if ($handle = @opendir($panelsFolder)) { while (false !== ($file = readdir($handle))) { $filePath = $panelsFolder . $file; RCCWP_CustomWritePanel::Import($filePath); } } }
/** * This function is for add new element at the Flutter i * layout settings * * @author David Valdez <*****@*****.**> */ function show_layout_settings() { global $flutter_domain, $wpdb; $template = get_option('template'); $registered_layout = $wpdb->get_var("SELECT COUNT(*) FROM " . FLUTTER_TABLE_LAYOUT_MODULES . " WHERE theme = '{$template}'"); if ($registered_layout == 0) { $wpdb->query("INSERT INTO " . FLUTTER_TABLE_LAYOUT_MODULES . " (module_id,theme,page,duplicate_id) VALUES (-1,'{$template}','-',0)"); } else { $template_module_id = $wpdb->get_var("SELECT module_id FROM " . FLUTTER_TABLE_LAYOUT_MODULES . " WHERE theme = '{$template}'"); } if (!empty($_GET['flutter_action']) && $_GET['flutter_action'] == "create-layout-setting") { RCCWP_ThemeSettingsPage::create_layout_element(); exit; } ?> <script type="text/javascript"> jQuery('document').ready(function(){ jQuery('.del_element').click(function(){ if(!confirm("<?php echo _e("are you sure?", $flutter_domain); ?> ")){ return false; } }); }); </script> <?php $modules = FlutterLayoutBlock::GetModuleSettings($template_module_id); $table_header = "<table cellpadding='3' cellspacing='3' width='100%' class='widefat'>"; $table_header .= "<thead><tr><th scope='col' width='70%'>" . __('Name', $flutter_domain) . "</th><th scope='col' colspan='2'>" . __('Actions', $flutter_domain) . "</th></tr></thead><tbody>"; $table_body = ""; $table_footer = "</tbody></table>"; if (empty($modules->variables)) { echo "<h2>" . __("You don't have any setting created, start creating one", $flutter_domain) . "</h2>"; echo "<br /><a href='?page=RCCWP_ThemeSettingsPage&flutter_action=create-layout-setting'>Add new layout setting</a>"; exit; } foreach ($modules->variables as $varkey => $variable) { if (empty($class)) { $class = ""; } $class = $class == '' ? 'alternate' : ''; $table_body .= "<tr class='{$class}'>"; $table_body .= "<td>{$variable->variable_name}</td>"; $table_body .= "<td></td>"; $table_body .= "<td><a class='del_element' id='del_{$variable->variable_id}' href='?page=RCCWP_ThemeSettingsPage&element_id={$variable->variable_id}&flutter_action=delete-theme-settings'>" . __("Delete", $flutter_domain) . "</a></td>"; $table_body .= "</tr>"; } echo $table_header . $table_body . $table_footer; echo "<br /><br /><a href='?page=RCCWP_ThemeSettingsPage&flutter_action=create-layout-setting'>" . __('add new template option', $flutter_domain) . "</a>"; echo "<br /><br />"; echo '<a href="http://flutter.freshout.us"><img src="' . FLUTTER_URI . '/images/flutter_logo.jpg" /></a>'; }
/** Adding Submenu Fluttler Layout settings**/ function AttachLayoutSettingsPage() { global $wpdb; global $flutter_domain; $template = get_option('template'); $template_module_id = $wpdb->get_var("SELECT module_id FROM " . FLUTTER_TABLE_LAYOUT_MODULES . " WHERE theme = '{$template}'"); $template_block_id = $wpdb->get_var("SELECT block_id FROM " . FLUTTER_TABLE_LAYOUT_MODULES . " WHERE theme = '{$template}'"); $count_settings = $wpdb->get_var("SELECT COUNT(*) FROM " . FLUTTER_TABLE_LAYOUT_VARIABLES . " WHERE parent = '{$template_block_id}'"); if ($count_settings != 0) { $themeSettingsID = FlutterLayoutBlock::GetModuleSettingsID($template_module_id, '-'); if (!empty($themeSettingsID)) { add_submenu_page("themes.php", __('Template Options', $flutter_domain), FLUTTER_CAPABILITY_LAYOUT, 8, 'Flutter_ThemeSettings', array('RCCWP_ThemeSettingsPage', 'Main')); } } }
function GetModules($pageName, $position = '', $templateName = false) { global $wpdb; if (!$templateName) { $templateName = get_option('template'); } $blocksID = $wpdb->get_col(" SELECT block_id " . " FROM " . FLUTTER_TABLE_LAYOUT_MODULES . " WHERE theme = '{$templateName}' AND position = '{$position}' AND page='{$pageName}'"); $resutls = array(); foreach ($blocksID as $blockID) { $resutls[] = FlutterLayoutBlock::GetModuleSettingsByBlock($blockID, $templateName); } return $resutls; }