Exemplo n.º 1
0
 function FormError()
 {
     global $mf_domain;
     if (RCCWP_Application::InWritePostPanel()) {
         echo "<div id='mf-publish-error-message' class='error' style='display:none;'><p><strong>" . __("Post was not published - ", $mf_domain) . "</strong> " . __("You have errors in some fields, please check the fields below.", $mf_domain) . "</p></div>";
     }
 }
Exemplo n.º 2
0
 function Main()
 {
     require_once 'RC_Format.php';
     global $CUSTOM_WRITE_PANEL;
     wp_enqueue_script('jquery-ui-sortable');
     if (isset($_POST['edit-with-no-custom-write-panel'])) {
         $type = RCCWP_Post::GetCustomWritePanel();
         if (is_object($type)) {
             $ptype = $type->type;
         } else {
             $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post';
         }
         wp_redirect($ptype . '.php?action=edit&post=' . $_POST['post-id'] . '&no-custom-write-panel');
     } else {
         if (isset($_POST['edit-with-custom-write-panel']) && isset($_POST['custom-write-panel-id']) && (int) $_POST['custom-write-panel-id'] > 0) {
             $type = RCCWP_Post::GetCustomWritePanel();
             if (is_object($type)) {
                 $ptype = $type->type;
             } else {
                 $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post';
             }
             wp_redirect($type->type . '.php?action=edit&post=' . $_POST['post-id'] . '&custom-write-panel-id=' . $_POST['custom-write-panel-id']);
         }
     }
     if (empty($_REQUEST['mf_action'])) {
         $currentAction = "";
     } else {
         $currentAction = $_REQUEST['mf_action'];
     }
     switch ($currentAction) {
         // ------------ Write Panels
         case 'finish-create-custom-write-panel':
             include_once 'RCCWP_CustomWritePanel.php';
             $default_theme_page = NULL;
             if ($_POST['radPostPage'] == 'page') {
                 $default_theme_page = $_POST['page_template'];
             }
             $customWritePanelId = RCCWP_CustomWritePanel::Create($_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page);
             wp_redirect(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('view-custom-write-panel', $customWritePanelId));
             break;
         case 'submit-edit-custom-write-panel':
             include_once 'RCCWP_CustomWritePanel.php';
             $default_theme_page = NULL;
             if ($_POST['radPostPage'] == 'page') {
                 $default_theme_page = $_POST['page_template'];
             }
             RCCWP_CustomWritePanel::Update($_POST['custom-write-panel-id'], $_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page);
             RCCWP_CustomWritePanel::AssignToRole($_POST['custom-write-panel-id'], 'administrator');
             break;
         case 'export-custom-write-panel':
             require_once 'RCCWP_CustomWritePanel.php';
             $panelID = $_REQUEST['custom-write-panel-id'];
             $writePanel = RCCWP_CustomWritePanel::Get($panelID);
             $exportedFilename = $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $writePanel->name . '.pnl';
             RCCWP_CustomWritePanel::Export($panelID, $exportedFilename);
             // send file in header
             header('Content-type: binary');
             header('Content-Disposition: attachment; filename="' . $writePanel->name . '.pnl"');
             readfile($exportedFilename);
             unlink($exportedFilename);
             exit;
             break;
         case 'delete-custom-write-panel':
             include_once 'RCCWP_CustomWritePanel.php';
             RCCWP_CustomWritePanel::Delete($_GET['custom-write-panel-id']);
             break;
             // ------------ Groups
         // ------------ Groups
         case 'finish-create-custom-group':
             include_once 'RCCWP_CustomGroup.php';
             $customGroupId = RCCWP_CustomGroup::Create($_POST['custom-write-panel-id'], $_POST['custom-group-name'], $_POST['custom-group-duplicate'], $_POST['custom-group-at_right']);
             break;
         case 'delete-custom-group':
             include_once 'RCCWP_CustomGroup.php';
             $customGroup = RCCWP_CustomGroup::Get((int) $_REQUEST['custom-group-id']);
             RCCWP_CustomGroup::Delete($_GET['custom-group-id']);
             break;
         case 'submit-edit-custom-group':
             include_once 'RCCWP_CustomGroup.php';
             RCCWP_CustomGroup::Update($_REQUEST['custom-group-id'], $_POST['custom-group-name'], $_POST['custom-group-duplicate'], $_POST['custom-group-at_right']);
             break;
             // ------------ Fields
         // ------------ Fields
         case 'copy-custom-field':
             include_once 'RCCWP_CustomField.php';
             $fieldToCopy = RCCWP_CustomField::Get($_REQUEST['custom-field-id']);
             if (RCCWP_Processor::CheckFieldName($fieldToCopy->name, $_REQUEST['custom-write-panel-id'])) {
                 $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                 wp_redirect($newURL);
                 exit;
             }
             RCCWP_CustomField::Create($_REQUEST['custom-group-id'], $fieldToCopy->name, $fieldToCopy->description, $fieldToCopy->display_order, $fieldToCopy->required_field, $fieldToCopy->type_id, $fieldToCopy->options, $fieldToCopy->default_value, $fieldToCopy->properties, $fieldToCopy->duplicate, $fieldToCopy->helptext);
         case 'continue-create-custom-field':
             if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                 $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                 wp_redirect($newURL);
                 exit;
             }
             break;
         case 'finish-create-custom-field':
             include_once 'RCCWP_CustomField.php';
             if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                 $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                 wp_redirect($newURL);
                 exit;
             }
             $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_REQUEST['custom-field-type']);
             if ($current_field->has_properties) {
                 $custom_field_properties = array();
                 if (in_array($current_field->name, array('Textbox', 'Listbox'))) {
                     $custom_field_properties['size'] = $_POST['custom-field-size'];
                 } else {
                     if (in_array($current_field->name, array('Multiline Textbox'))) {
                         $custom_field_properties['height'] = $_POST['custom-field-height'];
                         $custom_field_properties['width'] = $_POST['custom-field-width'];
                     } else {
                         if (in_array($current_field->name, array('Date'))) {
                             $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                         } else {
                             if (in_array($current_field->name, array('Image'))) {
                                 $params = '';
                                 if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) {
                                     $params .= '&h=' . $_POST['custom-field-photo-height'];
                                 }
                                 if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) {
                                     $params .= '&w=' . $_POST['custom-field-photo-width'];
                                 }
                                 if ($_POST['custom-field-custom-params'] != '') {
                                     $params .= '&' . $_POST['custom-field-custom-params'];
                                 }
                                 if ($params) {
                                     $custom_field_properties['params'] = $params;
                                 }
                             } else {
                                 if (in_array($current_field->name, array('Date'))) {
                                     $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                                 } else {
                                     if (in_array($current_field->name, array('Slider'))) {
                                         $custom_field_properties['max'] = $_POST['custom-field-slider-max'];
                                         $custom_field_properties['min'] = $_POST['custom-field-slider-min'];
                                         $custom_field_properties['step'] = $_POST['custom-field-slider-step'];
                                     } else {
                                         if (in_array($current_field->name, array('Related Type'))) {
                                             $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id'];
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             RCCWP_CustomField::Create($_POST['custom-group-id'], $_POST['custom-field-name'], $_POST['custom-field-description'], $_POST['custom-field-order'], $_POST['custom-field-required'], $_POST['custom-field-type'], $_POST['custom-field-options'], $_POST['custom-field-default-value'], $custom_field_properties, $_POST['custom-field-duplicate'], $_POST['custom-field-helptext']);
             break;
         case 'submit-edit-custom-field':
             include_once 'RCCWP_CustomField.php';
             $current_field_obj = RCCWP_CustomField::Get($_POST['custom-field-id']);
             if ($_POST['custom-field-name'] != $current_field_obj->name && RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                 $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-field') . '&custom-field-id=' . $_POST['custom-field-id'] . '&err_msg=-1';
                 wp_redirect($newURL);
                 exit;
             }
             $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_POST['custom-field-type']);
             if ($current_field->has_properties) {
                 $custom_field_properties = array();
                 if (in_array($current_field->name, array('Textbox', 'Listbox'))) {
                     $custom_field_properties['size'] = $_POST['custom-field-size'];
                 } else {
                     if (in_array($current_field->name, array('Multiline Textbox'))) {
                         $custom_field_properties['height'] = $_POST['custom-field-height'];
                         $custom_field_properties['width'] = $_POST['custom-field-width'];
                     } else {
                         if (in_array($current_field->name, array('Image'))) {
                             $params = '';
                             if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) {
                                 $params = '&h=' . $_POST['custom-field-photo-height'];
                             }
                             if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) {
                                 $params .= '&w=' . $_POST['custom-field-photo-width'];
                             }
                             if ($_POST['custom-field-custom-params'] != '') {
                                 $params .= '&' . $_POST['custom-field-custom-params'];
                             }
                             if ($params) {
                                 $custom_field_properties['params'] = $params;
                             }
                         } else {
                             if (in_array($current_field->name, array('Date'))) {
                                 $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                             } else {
                                 if (in_array($current_field->name, array('Slider'))) {
                                     $custom_field_properties['max'] = $_POST['custom-field-slider-max'];
                                     $custom_field_properties['min'] = $_POST['custom-field-slider-min'];
                                     $custom_field_properties['step'] = $_POST['custom-field-slider-step'];
                                 } else {
                                     if (in_array($current_field->name, array('Related Type'))) {
                                         $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id'];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             RCCWP_CustomField::Update($_POST['custom-field-id'], $_POST['custom-field-name'], $_POST['custom-field-description'], $_POST['custom-field-order'], $_POST['custom-field-required'], $_POST['custom-field-type'], $_POST['custom-field-options'], $_POST['custom-field-default-value'], $custom_field_properties, $_POST['custom-field-duplicate'], $_POST['custom-field-helptext']);
             break;
         case 'delete-custom-field':
             include_once 'RCCWP_CustomField.php';
             if (isset($_REQUEST['custom-group-id']) && !empty($_REQUEST['custom-group-id'])) {
                 $customGroupId = (int) $_REQUEST['custom-group-id'];
             }
             $customGroup = RCCWP_CustomGroup::Get($customGroupId);
             RCCWP_CustomField::Delete($_REQUEST['custom-field-id']);
             break;
         default:
             if (RCCWP_Application::InWritePostPanel()) {
                 include_once 'RCCWP_Menu.php';
                 include_once 'RCCWP_WritePostPage.php';
                 $CUSTOM_WRITE_PANEL = RCCWP_Post::GetCustomWritePanel();
                 if (isset($CUSTOM_WRITE_PANEL) && $CUSTOM_WRITE_PANEL > 0) {
                     ob_start(array('RCCWP_WritePostPage', 'ApplyCustomWritePanelAssignedCategories'));
                     add_action('admin_head', array('RCCWP_WritePostPage', 'CustomFieldsCSS'));
                     //adding javascripts files for the custom fields
                     add_action('admin_print_scripts', array('RCCWP_WritePostPage', 'CustomFieldsJavascript'));
                     add_action('admin_head', array('RCCWP_WritePostPage', 'ApplyCustomWritePanelHeader'));
                     add_action('admin_menu', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface'));
                 } else {
                     if (!isset($_REQUEST['no-custom-write-panel']) && isset($_REQUEST['post'])) {
                         include_once 'RCCWP_Options.php';
                         $promptEditingPost = RCCWP_Options::Get('prompt-editing-post');
                         if ($promptEditingPost == 1) {
                             wp_redirect('?page=' . urlencode(MF_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&assign-custom-write-panel=' . (int) $_GET['post']);
                         }
                     }
                 }
             } else {
                 if (isset($_POST['update-custom-write-panel-options'])) {
                     if ($_POST['uninstall-custom-write-panel'] == 'uninstall') {
                         RCCWP_Application::Uninstall();
                         wp_redirect('options-general.php');
                     } else {
                         include_once 'RCCWP_Options.php';
                         $options['hide-write-post'] = $_POST['hide-write-post'];
                         $options['hide-write-page'] = $_POST['hide-write-page'];
                         $options['hide-visual-editor'] = $_POST['hide-visual-editor'];
                         $options['prompt-editing-post'] = $_POST['prompt-editing-post'];
                         $options['assign-to-role'] = $_POST['assign-to-role'];
                         $options['use-snipshot'] = $_POST['use-snipshot'];
                         $options['enable-editnplace'] = $_POST['enable-editnplace'];
                         $options['eip-highlight-color'] = $_POST['eip-highlight-color'];
                         $options['enable-swfupload'] = $_POST['enable-swfupload'];
                         $options['enable-browserupload'] = $_POST['enable-browserupload'];
                         $options['default-custom-write-panel'] = $_POST['default-custom-write-panel'];
                         $options['enable-HTMLPurifier'] = $_POST['enable-HTMLPurifier'];
                         $options['tidy-level'] = $_POST['tidy-level'];
                         $options['canvas_show_instructions'] = $_POST['canvas_show_instructions'];
                         $options['canvas_show_zone_name'] = $_POST['canvas_show_zone_name'];
                         $options['canvas_show'] = $_POST['canvas_show'];
                         $options['ink_show'] = $_POST['ink_show'];
                         $options['hide-non-standart-content'] = $_POST['hide-non-standart-content'];
                         $options['condense-menu'] = $_POST['condense-menu'];
                         RCCWP_Options::Update($options);
                         $EnP = RCCWP_Application::create_EditnPlace_css(TRUE);
                     }
                 }
             }
     }
 }
Exemplo n.º 3
0
 /**
  *  Create The Edit In Place  CSS file
  * 
  *  @return  bool  true if the css file was successful created
  */
 function create_EditnPlace_css($create = FALSE)
 {
     include_once 'RCCWP_Options.php';
     $eip_highlight_color = RCCWP_Options::Get('eip-highlight-color');
     if (!$eip_highlight_color) {
         $eip_highlight_color = '#FFFFFF';
     }
     $MF_URI = MF_URI;
     $arrow_image_path = MF_URI . "images/arrow.gif";
     $editnplace_css = "\n#savingDiv{\n\tfont-size: medium;\n\tfont-weight: bold;\n}\n\n.EIP_title:hover, .EIP_content:hover,\n.EIP_textbox:hover, .EIP_mulittextbox:hover {\n\tbackground-color: {$eip_highlight_color}\n}\n\n.EIPSaveCancel{\n\tpadding: 5px;\n\tmargin-top: -1px;\n\tz-index: 1000;\n\tborder-color:#CCC;\n\tborder-width:1px;\n\tborder-style:solid;\n\tbackground-color:white;\n\tposition:fixed;\n\ttop:0px !important;\n\twidth:100% !important;\n\tleft: 0px  !important;\n\t/*position:absolute;\n\tpadding-top:2px;\n\tpadding-bottom:2px;\n\tz-index: 1000;*/\n}\n\n.EIPSaveStatus{\n\tposition:absolute;\n\tfont-size: 14px;\n\tz-index: 1000;\n}\n\n.EIPnicPanelDiv{\n\tposition: absolute;\n\tbackground-image: url({$arrow_image_path});\n\twidth:154px;\n\theight:38px;\n\tz-index: 1000;\n\tmargin-top: -23px;\n}\n\ndiv.nicEdit-panel{\n\tbackground-color: white !important;\n\twidth:140px  !important;\n}\n\ndiv.nicEdit-panelContain{\n\tbackground-color: white !important;\n\tborder-bottom: 0px\t!important;\n\tborder-left: 0px\t!important;\n\tborder-right: 0px\t!important;\n\twidth: 92%\t!important;\n\tmargin-left: 2px\t!important;\n\tmargin-top: 1px\t!important;\n}\n\n.nicEdit-selected{\n\t/*background-color: #FFFFCC  !important;*/\n\tborder: thin inset   !important;\n\tpadding: 10px;\n}\n.nicEdit-button {\n\tbackground-color: white !important;\n\tborder: 0px !important;\n}\n\n.FEIP_textbox {\n        background-color: #CCC;\n        height: 32px;\n        width: 100%;       \n}\n";
     $editnplace_css_file = MF_UPLOAD_FILES_DIR . 'editnplace.css';
     $css = explode("\n", $editnplace_css);
     if (!file_exists($editnplace_css_file)) {
         $css_file_created = RCCWP_Application::save_editnplace_file($editnplace_css_file, 'EditnPlace css', $css, TRUE);
     } else {
         $css_file_created = RCCWP_Application::save_editnplace_file($editnplace_css_file, 'EditnPlace css', $css, $create);
     }
     return $css_file_created;
 }
/**
 *  Here actions/hooks only required in the Admin area
 */
if (is_admin()) {
    require_once 'RCCWP_Application.php';
    require_once 'RCCWP_WritePostPage.php';
    register_activation_hook(dirname(__FILE__) . '/Main.php', array('RCCWP_Application', 'Install'));
    //Attaching the Magic Fields Menus
    add_action('admin_menu', array('RCCWP_Menu', 'AttachMagicFieldsMenus'));
    if ($is_wordpress_mu) {
        //checking if the method Install was executed before
        //if exists the option called "mf_custom_write_panel"
        //is because Magic Fields was already installed
        $option = get_option('mf_custom_write_panel');
        if (!$option) {
            RCCWP_Application::Install();
            add_action('admin_menu', array('RCCWP_Application', 'ContinueInstallation'));
        }
    }
    if (get_option(RC_CWP_OPTION_KEY) !== false) {
        require_once 'RCCWP_Processor.php';
        add_action('init', array('RCCWP_Processor', 'Main'));
        add_action('admin_menu', array('RCCWP_Menu', 'AttachCustomWritePanelMenuItems'));
        add_action('admin_menu', array('RCCWP_Menu', 'DetachWpWritePanelMenuItems'));
        add_action('admin_menu', array('RCCWP_Menu', 'AttachOptionsMenuItem'));
        add_filter('posts_where', array('RCCWP_Menu', 'FilterPostsPagesList'));
        add_action('admin_head', array('RCCWP_Menu', 'HighlightCustomPanel'));
        add_action('admin_head', 'mf_admin_style');
        // -- Hook all functions related to saving posts in order to save custom fields values
        require_once 'RCCWP_Post.php';
        add_action('save_post', array('RCCWP_Post', 'SaveCustomFields'));
Exemplo n.º 5
0
            $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');
    header('Content-Disposition: attachment; filename="' . $module->name . '.zip"');
    readfile($zipFile);
    // Remove file and directory
    unlink($zipFile);
    advancedRmdir($moduleTmpPath);
    exit;
}
Exemplo n.º 6
0
 /**
  *  Upgrade Blog
  *  
  *  If the Plugin was upgrade from a older version
  *  this function is executed for check any possible change in the database
  *  
  *  @return void
  */
 function UpgradeBlog()
 {
     global $wpdb;
     if (RC_CWP_DB_VERSION <= 2) {
         $wpdb->query('ALTER TABLE ' . MF_TABLE_GROUP_FIELDS . ' MODIFY display_order INTEGER');
         $wpdb->query('ALTER TABLE ' . MF_TABLE_GROUP_FIELDS . ' ADD COLUMN help_text text after duplicate');
         $wpdb->query('ALTER TABLE ' . MF_TABLE_PANELS . ' MODIFY display_order INTEGER');
     }
     if (RC_CWP_DB_VERSION >= 6) {
         if ($wpdb->get_var("SHOW TABLES LIKE '" . $wpdb->prefix . "mf_custom_field_types'") == $wpdb->prefix . "mf_custom_field_types") {
             $wpdb->query("DROP TABLE " . $wpdb->prefix . "mf_custom_field_types");
         }
     }
     if (RC_CWP_DB_VERSION >= 7) {
         RCCWP_Application::AddColumnIfNotExist(MF_TABLE_PANEL_GROUPS, "expanded", $column_attr = "tinyint after duplicate");
         RCCWP_Application::AddColumnIfNotExist(MF_TABLE_PANELS, "expanded", $column_attr = "tinyint NOT NULL DEFAULT 1 after type");
     }
     if (RC_CWP_DB_VERSION >= 8) {
         $wpdb->query('ALTER TABLE ' . MF_TABLE_PANEL_CATEGORY . ' MODIFY cat_id VARCHAR(100)');
     }
 }
Exemplo n.º 7
0
 /**
  * Import a module given the zip file path. Importing a module means inserting it in
  * the database and copying its folder to modules folder. If a module with the same
  * name already exists, the function will append a number to the module name. You must 
  * have either php ZipArchive extension or unzip program installed.
  *
  * @param string $zipFilePath the full path of the zip file
  * @param string $moduleName the module name, if this value if false, the function will
  * 							use the zip filename as the module name. The default value is false
  * @return the module id, or false in case of error.
  */
 function Import($zipFilePath, $moduleName = false)
 {
     include_once 'RCCWP_CustomGroup.php';
     include_once 'RCCWP_CustomField.php';
     include_once 'RCCWP_CustomWritePanel.php';
     include_once 'RCCWP_Application.php';
     include_once 'RCCWP_CustomWritePanel.php';
     global $flutter_domain;
     if (!strpos($zipFilePath, ".zip")) {
         return false;
     }
     if (!$moduleName) {
         //use zip filename
         $moduleName = basename($zipFilePath, ".zip");
     }
     if ($moduleName == '') {
         return false;
     }
     // Append a number if the module already exists,
     $i = 1;
     $newModuleName = $moduleName;
     while (file_exists(FLUTTER_MODULES_DIR . $newModuleName)) {
         $newModuleName = $moduleName . "_" . $i++;
     }
     $moduleName = $newModuleName;
     mkdir(FLUTTER_MODULES_DIR . $moduleName);
     chmod(FLUTTER_MODULES_DIR . $moduleName, 0777);
     $destPath = FLUTTER_MODULES_DIR . $moduleName . DIRECTORY_SEPARATOR;
     if (class_exists('ZipArchive')) {
         $zip = new ZipArchive();
         // open archive
         if ($zip->open($zipFilePath) !== TRUE) {
             die(__('Could not open archive', $flutter_domain));
         }
         // extract contents to destination directory
         $zip->extractTo($destPath);
         // close archive
         $zip->close();
     } else {
         if (RCCWP_Application::CheckDecompressionProgramUnzip()) {
             $command = "unzip {$zipFilePath} -d " . $destPath;
         } else {
             die(__('Cannot find unzip program!', $flutter_domain));
         }
         exec($command, $out, $err);
     }
     $moduleInfo_imported_data = unserialize(file_get_contents($destPath . 'module_info.exp'));
     //Import module
     $moduleID = RCCWP_CustomWriteModule::Create($moduleName, $moduleInfo_imported_data['moduleinfo']->description, false);
     //Import any panels
     if ($handle = @opendir($destPath)) {
         while (false !== ($file = readdir($handle))) {
             if (substr($file, 0, 1) == "_") {
                 $panelName = basename(substr($file, 1), ".pnl");
                 RCCWP_CustomWritePanel::Import($destPath . $file, $panelName);
             }
         }
     }
     //Create Duplicates
     foreach ($moduleInfo_imported_data['duplicates'] as $moduleDuplicate) {
         RCCWP_ModuleDuplicate::Create($moduleID, $moduleDuplicate->duplicate_name);
     }
     return $moduleID;
 }
Exemplo n.º 8
0
    /**
     *  This function is executed every time to something related with the Magic Fields happen
     *  this function update,delete,create a customfield,writepanel,group.
     */
    function Main()
    {
        require_once 'RC_Format.php';
        global $CUSTOM_WRITE_PANEL, $wp_version;
        if (isset($_POST['edit-with-no-custom-write-panel'])) {
            $type = RCCWP_Post::GetCustomWritePanel();
            if (is_object($type)) {
                $ptype = $type->type;
            } else {
                $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post';
            }
            wp_redirect($ptype . '.php?action=edit&post=' . $_POST['post-id'] . '&no-custom-write-panel');
        } else {
            if (isset($_POST['edit-with-custom-write-panel']) && isset($_POST['custom-write-panel-id']) && (int) $_POST['custom-write-panel-id'] > 0) {
                if (substr($wp_version, 0, 3) >= 3.0) {
                    $ptype = 'post';
                } else {
                    $type = RCCWP_Post::GetCustomWritePanel();
                    if (is_object($type)) {
                        $ptype = $type->type;
                    } else {
                        $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post';
                    }
                }
                wp_redirect($ptype . '.php?action=edit&post=' . $_POST['post-id'] . '&custom-write-panel-id=' . $_POST['custom-write-panel-id']);
            }
        }
        if (empty($_REQUEST['mf_action'])) {
            $currentAction = "";
        } else {
            $currentAction = $_REQUEST['mf_action'];
        }
        switch ($currentAction) {
            // ------------ Write Panels
            case 'finish-create-custom-write-panel':
                include_once 'RCCWP_CustomWritePanel.php';
                $default_theme_page = NULL;
                if ($_POST['radPostPage'] == 'page') {
                    $default_theme_page = $_POST['page_template'];
                    $default_parent_page = $_POST['parent_id'];
                }
                $customWritePanelId = RCCWP_CustomWritePanel::Create($_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page, $default_parent_page, $_POST['custom-write-panel-expanded']);
                wp_redirect(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('view-custom-write-panel', $customWritePanelId));
                break;
            case 'submit-edit-custom-write-panel':
                include_once 'RCCWP_CustomWritePanel.php';
                $default_theme_page = $default_parent_page = NULL;
                if ($_POST['radPostPage'] == 'page') {
                    $default_theme_page = $_POST['page_template'];
                    $default_parent_page = $_POST['parent_id'];
                }
                $default = array('custom-write-panel-id' => '', 'custom-write-panel-name' => '', 'custom-write-panel-standard-fields' => '', 'custom-write-panel-categories' => '', 'custom-write-panel-order' => '', 'single' => '', 'theme_page' => '', 'parent_page' => '', 'expanded' => '');
                $_POST['theme_page'] = $default_theme_page;
                $_POST['parent_page'] = $default_parent_page;
                $save = array_merge($default, $_POST);
                RCCWP_CustomWritePanel::Update($save['custom-write-panel-id'], $save['custom-write-panel-name'], NULL, $save['custom-write-panel-standard-fields'], $save['custom-write-panel-categories'], $save['custom-write-panel-order'], FALSE, true, $save['single'], $save['theme_page'], $save['parent_page'], $save['custom-write-panel-expanded']);
                RCCWP_CustomWritePanel::AssignToRole($_POST['custom-write-panel-id'], 'administrator');
                break;
            case 'export-custom-write-panel':
                require_once 'RCCWP_CustomWritePanel.php';
                $panelID = $_REQUEST['custom-write-panel-id'];
                $writePanel = RCCWP_CustomWritePanel::Get($panelID);
                // send file in header
                header('Content-type: binary');
                header('Content-Disposition: attachment; filename="' . $writePanel->name . '.pnl"');
                print RCCWP_CustomWritePanel::Export($panelID);
                exit;
                break;
            case 'delete-custom-write-panel':
                include_once 'RCCWP_CustomWritePanel.php';
                RCCWP_CustomWritePanel::Delete($_GET['custom-write-panel-id']);
                break;
                // ------------ Groups
            // ------------ Groups
            case 'finish-create-custom-group':
                include_once 'RCCWP_CustomGroup.php';
                $default = array('custom-write-panel-id' => '', 'custom-group-name' => '', 'custom-group-duplicate' => '', 'custom-group-expanded' => '');
                $values = array_merge($default, $_POST);
                $customGroupId = RCCWP_CustomGroup::Create($values['custom-write-panel-id'], $values['custom-group-name'], $values['custom-group-duplicate'], $values['custom-group-expanded'], NULL);
                break;
            case 'delete-custom-group':
                include_once 'RCCWP_CustomGroup.php';
                $customGroup = RCCWP_CustomGroup::Get((int) $_REQUEST['custom-group-id']);
                RCCWP_CustomGroup::Delete($_GET['custom-group-id']);
                break;
            case 'unlink-write-panel':
                global $wpdb;
                $postId = (int) preg_replace('/post-/', '', $_REQUEST['post-id']);
                $dashboard = $_REQUEST['dashboard'];
                if ($postId) {
                    //only delete images and postmeta fields with write panels
                    if (count(get_post_meta($postId, RC_CWP_POST_WRITE_PANEL_ID_META_KEY))) {
                        $query = sprintf('SELECT wp_pm.meta_value 
						FROM %s mf_pm, %s mf_cf, %s wp_pm
						WHERE mf_pm.field_name = mf_cf.name AND mf_cf.type = 9 AND mf_pm.post_id = %d AND wp_pm.meta_id = mf_pm.id', MF_TABLE_POST_META, MF_TABLE_GROUP_FIELDS, $wpdb->postmeta, $postId);
                        $images = $wpdb->get_results($query);
                        foreach ($images as $image) {
                            if ($image->meta_value != '') {
                                $tmp = sprintf('%s%s', MF_FILES_PATH, $image->meta_value);
                                @unlink($tmp);
                            }
                        }
                        //delete all data of postmeta (WP and MF)
                        $query = sprintf('DELETE a,b from %s a INNER JOIN %s b WHERE a.meta_id = b.id AND a.post_id = %d', $wpdb->postmeta, MF_TABLE_POST_META, $postId);
                        $wpdb->query($query);
                    }
                    delete_post_meta($postId, RC_CWP_POST_WRITE_PANEL_ID_META_KEY);
                    wp_redirect($dashboard);
                    exit;
                }
                break;
            case 'submit-edit-custom-group':
                include_once 'RCCWP_CustomGroup.php';
                $default = array('custom-write-panel-id' => '', 'custom-group-name' => '', 'custom-group-duplicate' => '', 'custom-group-expanded' => '');
                $all = $_POST;
                $all['custom-group-id'] = $_REQUEST['custom-group-id'];
                $values = array_merge($default, $all);
                RCCWP_CustomGroup::Update($values['custom-group-id'], $values['custom-group-name'], $values['custom-group-duplicate'], $values['custom-group-expanded'], NULL);
                break;
                // ------------ Fields
            // ------------ Fields
            case 'copy-custom-field':
                include_once 'RCCWP_CustomField.php';
                $fieldToCopy = RCCWP_CustomField::Get($_REQUEST['custom-field-id']);
                if (RCCWP_Processor::CheckFieldName($fieldToCopy->name, $_REQUEST['custom-write-panel-id'])) {
                    $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                    wp_redirect($newURL);
                    exit;
                }
                RCCWP_CustomField::Create($_REQUEST['custom-group-id'], $fieldToCopy->name, $fieldToCopy->description, $fieldToCopy->display_order, $fieldToCopy->required_field, $fieldToCopy->type_id, $fieldToCopy->options, $fieldToCopy->default_value, $fieldToCopy->properties, $fieldToCopy->duplicate, $fieldToCopy->helptext);
            case 'continue-create-custom-field':
                if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                    $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                    wp_redirect($newURL);
                    exit;
                }
                break;
            case 'finish-create-custom-field':
                include_once 'RCCWP_CustomField.php';
                if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                    $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                    wp_redirect($newURL);
                    exit;
                }
                $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_REQUEST['custom-field-type']);
                if ($current_field->has_properties) {
                    $custom_field_properties = array();
                    if (in_array($current_field->name, array('Textbox', 'Listbox'))) {
                        $custom_field_properties['size'] = $_POST['custom-field-size'];
                        if (isset($_POST['strict-max-length'])) {
                            $custom_field_properties['strict-max-length'] = $_POST['strict-max-length'];
                            if (empty($custom_field_properties['size'])) {
                                $custom_field_properties['size'] = 10;
                            }
                        }
                    } else {
                        if (in_array($current_field->name, array('Multiline Textbox'))) {
                            $custom_field_properties['height'] = $_POST['custom-field-height'];
                            $custom_field_properties['width'] = $_POST['custom-field-width'];
                            if (isset($_POST['hide-visual-editor'])) {
                                $custom_field_properties['hide-visual-editor'] = 1;
                            }
                            if (isset($_POST['strict-max-length'])) {
                                $custom_field_properties['hide-visual-editor'] = 1;
                                $custom_field_properties['strict-max-length'] = $_POST['strict-max-length'];
                                if (empty($custom_field_properties['height'])) {
                                    $custom_field_properties['height'] = 4;
                                }
                                if (empty($custom_field_properties['width'])) {
                                    $custom_field_properties['width'] = 64;
                                }
                            }
                        } else {
                            if (in_array($current_field->name, array('Date'))) {
                                $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                            } else {
                                if (in_array($current_field->name, array('Image', 'Image (Upload Media)'))) {
                                    $params = '';
                                    if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) {
                                        $params .= '&h=' . $_POST['custom-field-photo-height'];
                                    }
                                    if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) {
                                        $params .= '&w=' . $_POST['custom-field-photo-width'];
                                    }
                                    if ($_POST['custom-field-custom-params'] != '') {
                                        $params .= '&' . $_POST['custom-field-custom-params'];
                                    }
                                    if ($params) {
                                        $custom_field_properties['params'] = $params;
                                    }
                                } else {
                                    if (in_array($current_field->name, array('Date'))) {
                                        $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                                    } else {
                                        if (in_array($current_field->name, array('Slider'))) {
                                            $custom_field_properties['max'] = $_POST['custom-field-slider-max'];
                                            $custom_field_properties['min'] = $_POST['custom-field-slider-min'];
                                            $custom_field_properties['step'] = $_POST['custom-field-slider-step'];
                                        } else {
                                            if (in_array($current_field->name, array('Related Type'))) {
                                                $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id'];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $default = array('custom-group-id' => '', 'custom-field-name' => '', 'custom-field-description' => '', 'custom-field-order' => '', 'custom-field-required' => '', 'custom-field-type' => '', 'custom-field-options' => '', 'custom-field-default-value' => '', 'prop' => '', 'custom-field-duplicate' => '', 'custom-field-helptext' => '');
                $_POST['prop'] = $custom_field_properties;
                $save = array_merge($default, $_POST);
                RCCWP_CustomField::Create($save['custom-group-id'], $save['custom-field-name'], $save['custom-field-description'], $save['custom-field-order'], $save['custom-field-required'], $save['custom-field-type'], $save['custom-field-options'], $save['custom-field-default-value'], $save['prop'], $save['custom-field-duplicate'], $save['custom-field-helptext']);
                break;
            case 'submit-edit-custom-field':
                include_once 'RCCWP_CustomField.php';
                $current_field_obj = RCCWP_CustomField::Get($_POST['custom-field-id']);
                if ($_POST['custom-field-name'] != $current_field_obj->name && RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                    $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-field') . '&custom-field-id=' . $_POST['custom-field-id'] . '&err_msg=-1';
                    wp_redirect($newURL);
                    exit;
                }
                $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_POST['custom-field-type']);
                if ($current_field->has_properties) {
                    $custom_field_properties = array();
                    if (in_array($current_field->name, array('Textbox', 'Listbox'))) {
                        $custom_field_properties['size'] = $_POST['custom-field-size'];
                        if (isset($_POST['strict-max-length'])) {
                            $custom_field_properties['strict-max-length'] = $_POST['strict-max-length'];
                            if (empty($custom_field_properties['size'])) {
                                $custom_field_properties['size'] = 10;
                            }
                        }
                    } else {
                        if (in_array($current_field->name, array('Multiline Textbox'))) {
                            $custom_field_properties['height'] = $_POST['custom-field-height'];
                            $custom_field_properties['width'] = $_POST['custom-field-width'];
                            if (isset($_POST['hide-visual-editor'])) {
                                $custom_field_properties['hide-visual-editor'] = 1;
                            }
                            if (isset($_POST['strict-max-length'])) {
                                $custom_field_properties['hide-visual-editor'] = 1;
                                $custom_field_properties['strict-max-length'] = $_POST['strict-max-length'];
                                if (empty($custom_field_properties['height'])) {
                                    $custom_field_properties['height'] = 4;
                                }
                                if (empty($custom_field_properties['width'])) {
                                    $custom_field_properties['width'] = 64;
                                }
                            }
                        } else {
                            if (in_array($current_field->name, array('Image', 'Image (Upload Media)'))) {
                                $params = '';
                                if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) {
                                    $params = '&h=' . $_POST['custom-field-photo-height'];
                                }
                                if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) {
                                    $params .= '&w=' . $_POST['custom-field-photo-width'];
                                }
                                if ($_POST['custom-field-custom-params'] != '') {
                                    $params .= '&' . $_POST['custom-field-custom-params'];
                                }
                                if ($params) {
                                    $custom_field_properties['params'] = $params;
                                }
                            } else {
                                if (in_array($current_field->name, array('Date'))) {
                                    $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                                } else {
                                    if (in_array($current_field->name, array('Slider'))) {
                                        $custom_field_properties['max'] = $_POST['custom-field-slider-max'];
                                        $custom_field_properties['min'] = $_POST['custom-field-slider-min'];
                                        $custom_field_properties['step'] = $_POST['custom-field-slider-step'];
                                    } else {
                                        if (in_array($current_field->name, array('Related Type'))) {
                                            $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id'];
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $default = array('custom-group-id' => '', 'custom-field-name' => '', 'custom-field-description' => '', 'custom-field-order' => '', 'custom-field-required' => '', 'custom-field-type' => '', 'custom-field-options' => '', 'custom-field-default-value' => '', 'prop' => '', 'custom-field-duplicate' => '', 'custom-field-helptext' => '');
                $_POST['prop'] = $custom_field_properties;
                $save = array_merge($default, $_POST);
                RCCWP_CustomField::Update($save['custom-field-id'], $save['custom-field-name'], $save['custom-field-description'], $save['custom-field-order'], $save['custom-field-required'], $save['custom-field-type'], $save['custom-field-options'], $save['custom-field-default-value'], $save['prop'], $save['custom-field-duplicate'], $save['custom-field-helptext']);
                break;
            case 'delete-custom-field':
                include_once 'RCCWP_CustomField.php';
                if (isset($_REQUEST['custom-field-id']) && !empty($_REQUEST['custom-field-id'])) {
                    RCCWP_CustomField::Delete($_REQUEST['custom-field-id']);
                }
                break;
            case 'save-fields-order':
                RCCWP_CustomWritePanelPage::save_order_fields();
            default:
                if (RCCWP_Application::InWritePostPanel()) {
                    include_once 'RCCWP_Menu.php';
                    include_once 'RCCWP_WritePostPage.php';
                    $CUSTOM_WRITE_PANEL = RCCWP_Post::GetCustomWritePanel();
                    if (isset($CUSTOM_WRITE_PANEL) && !empty($CUSTOM_WRITE_PANEL)) {
                        add_action('admin_head', array('RCCWP_WritePostPage', 'CustomFieldsCSS'));
                        //adding javascripts files for the custom fields
                        add_action('admin_print_scripts', array('RCCWP_WritePostPage', 'CustomFieldsJavascript'));
                        add_action('admin_print_scripts', array('RCCWP_WritePostPage', 'ApplyWritePanelAssignedCategoriesOrTemplate'));
                        add_action('admin_head', array('RCCWP_WritePostPage', 'ApplyCustomWritePanelHeader'));
                        add_action('admin_menu', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface'));
                    } else {
                        if (!isset($_REQUEST['no-custom-write-panel']) && isset($_REQUEST['post'])) {
                            include_once 'RCCWP_Options.php';
                            $promptEditingPost = RCCWP_Options::Get('prompt-editing-post');
                            if ($promptEditingPost == 1) {
                                wp_redirect('?page=' . urlencode(MF_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&assign-custom-write-panel=' . (int) $_GET['post']);
                            }
                        }
                    }
                } else {
                    if (isset($_POST['update-custom-write-panel-options'])) {
                        if ($_POST['uninstall-custom-write-panel'] == 'uninstall') {
                            RCCWP_Application::Uninstall();
                            wp_redirect('options-general.php');
                        } else {
                            if (isset($_POST['clear-cache-image-mf'])) {
                                $dir = MF_CACHE_DIR;
                                if (is_dir($dir)) {
                                    if ($dh = opendir($dir)) {
                                        while (($file = readdir($dh)) !== false) {
                                            if (!is_dir($file)) {
                                                @unlink(MF_CACHE_DIR . $file);
                                            }
                                        }
                                        closedir($dh);
                                    }
                                }
                            }
                            include_once 'RCCWP_Options.php';
                            $default = array('condense-menu' => 0, 'hide-non-standart-content' => 0, 'hide-write-post' => 0, 'hide-write-page' => 0, 'hide-visual-editor' => 0, 'dont-remove-tmce' => 0, 'prompt-editing-post' => 0, 'assign-to-role' => 0, 'default-custom-write-panel' => 0);
                            $save_options = $_POST;
                            unset($save_options['uninstall-custom-write-panel']);
                            unset($save_options['update-custom-write-panel-options']);
                            $save = array_merge($default, $save_options);
                            RCCWP_Options::Update($save);
                        }
                    }
                }
                if (isset($_REQUEST['post'])) {
                    // traversal addition to change write panel
                    add_action('admin_menu', array('RCCWP_WritePostPage', 'CreateAttributesBox'));
                }
        }
    }
Exemplo n.º 9
0
 /**
  * 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);
         }
     }
 }
    function Content($customWritePanel = null)
    {
        global $flutter_domain, $wpdb;
        $customWritePanelName = "";
        $customWritePanelDescription = "";
        $write_panel_category_ids = array();
        $defaultTagChecked = 'checked="checked"';
        $customWritePanelAllFieldIds = NULL;
        $customThemePage = NULL;
        $showPost = true;
        if ($customWritePanel != null) {
            $customWritePanelName = $customWritePanel->name;
            $customWritePanelDescription = $customWritePanel->description;
            $customWritePanelDisplayOrder = $customWritePanel->display_order;
            $customWritePanelType = $customWritePanel->type;
            if ($customWritePanelType == 'page') {
                $showPost = false;
            }
            $customWritePanelCategoryIds = RCCWP_CustomWritePanel::GetAssignedCategoryIds($customWritePanel->id);
            $customWritePanelStandardFieldIds = RCCWP_CustomWritePanel::GetStandardFields($customWritePanel->id);
            $customWritePanelAllFieldIds = RCCWP_CustomWritePanel::Get($customWritePanel->id);
            if ($customWritePanelType == 'page') {
                $customThemePage = RCCWP_CustomWritePanel::GetThemePage($customWritePanel->name);
            }
            $defaultTagChecked = '';
            ?>
			<input type="hidden" name="custom-write-panel-id" value="<?php 
            echo $customWritePanel->id;
            ?>
" />
			<?php 
        }
        ?>


		<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
		<tbody>
		<tr valign="top">
			<th scope="row"><?php 
        _e('Placement', $flutter_domain);
        ?>
</th>
        		<td>
				<!-- START :: Javascript for Image/Photo' Css Class -->
				<script type="text/javascript" language="javascript">
					jQuery(document).ready( function() {
							<?php 
        if ($showPost) {
            ?>
								showHide("flutter_forpost", "flutter_forpage");
							<?php 
        } else {
            ?>
								showHide("flutter_forpage", "flutter_forpost");
							<?php 
        }
        ?>
						});
						
					function showHide(showClassID, hideClassID)
					{
						jQuery( function($) {
							$("."+showClassID).css("display","");
							$("."+hideClassID).css("display","none");
							});
					}
				</script>
				<!-- END :: Javascript for Image/Photo' Css Class -->
				<input type="radio" name="radPostPage" id="radPostPage" value="post" <?php 
        if (empty($custoWritePanelType) || $customWritePanelType == 'post') {
            ?>
 checked="checked" <?php 
        }
        ?>
 onclick='showHide("flutter_forpost", "flutter_forpage");' /> <strong><?php 
        _e('Post', $flutter_domain);
        ?>
 </strong> &nbsp; &nbsp; &nbsp; 
				<input type="radio" name="radPostPage" id="radPostPage" value="page" <?php 
        if (!empty($customWritePanelType) && $customWritePanelType == 'page') {
            ?>
 checked="checked" <?php 
        }
        ?>
 onclick='showHide("flutter_forpage", "flutter_forpost");' /> <strong><?php 
        _e('Page', $flutter_domain);
        ?>
</strong>
			</td>
		</tr>


		<tr valign="top">
			<th scope="row"  align="right"><?php 
        _e('Name', $flutter_domain);
        ?>
:</th>
			<td>
				<input name="custom-write-panel-name" id="custom-write-panel-name" size="40" type="text" value="<?php 
        echo $customWritePanelName;
        ?>
" />
			</td>
		</tr>

	
		<tr valign="top"  id="catText" class="flutter_forpost">
			<th scope="row"  align="right"><div id="catLabel" style="display:inline;"><?php 
        _e('Assigned Categories', $flutter_domain);
        ?>
:</div></th>
			<td>
				
				<?php 
        $cats = RCCWP_Application::GetWpCategories();
        foreach ($cats as $cat) {
            $checked = "";
            if (isset($customWritePanel->id) && !empty($customWritePanel->id)) {
                if (in_array($cat->cat_ID, $customWritePanelCategoryIds)) {
                    $checked = "checked=\"checked\"";
                }
            }
            ?>
					<input type="checkbox" name="custom-write-panel-categories[]" value="<?php 
            echo $cat->cat_ID;
            ?>
" <?php 
            echo $checked;
            ?>
 /> <?php 
            echo $cat->cat_name;
            ?>
 <br/>
				<?php 
        }
        ?>
				
			</td>
		</tr>
		
		<tr valign="top"  id="catText" class="flutter_forpage">
			<th scope="row"  align="right"><div id="catLabel" style="display:inline;"><?php 
        _e('Assigned Theme', $flutter_domain);
        ?>
:</div></th>
			<td>
				
				<select name="page_template" id="page_template">
					<option value='default'><?php 
        _e('Default Template');
        ?>
</option>
					<?php 
        $themes_defaults = get_page_templates();
        foreach ($themes_defaults as $v => $k) {
            if ($customWritePanelType == 'page') {
                $theme_select = NULL;
                if ($customThemePage == $k) {
                    $theme_select = 'SELECTED';
                }
            }
            ?>
					<option value='<?php 
            echo $k;
            ?>
' <?php 
            echo $theme_select;
            ?>
 ><?php 
            echo $v;
            ?>
</option>
					<?php 
        }
        ?>
					<?php 
        ?>
				</select>
		
			</td>
		</tr>
		
        <tr>
            <th><?php 
        _e('Quantity', $flutter_domain);
        ?>
</th>
            <td>
				<?php 
        if (isset($customWritePanel->id) && !empty($customWritePanel->id)) {
            if ($customWritePanelAllFieldIds->single == 0) {
                $multiple_checked = 'checked="checked"';
            } else {
                $single_checked = 'checked="checked"';
            }
        } else {
            $multiple_checked = 'checked="checked"';
        }
        ?>
				<input type="radio" name="single" id="radPostPage" value="1" <?php 
        echo $single_checked;
        ?>
  /> <strong><?php 
        _e('Single', $flutter_domain);
        ?>
 </strong> &nbsp; &nbsp; &nbsp; 
				<input type="radio" name="single" id="radPostPage" value="0" <?php 
        echo $multiple_checked;
        ?>
  /> <strong><?php 
        _e('Multiple', $flutter_domain);
        ?>
</strong>
             </td>
        </tr>

		<tr valign="top">
			<th scope="row" align="right"><?php 
        _e('Standard Fields', $flutter_domain);
        ?>
:</th>
			<td>
				<?php 
        global $STANDARD_FIELDS, $wp_version;
        foreach ($STANDARD_FIELDS as $field) {
            if ($field->excludeVersion <= substr($wp_version, 0, 3)) {
                continue;
            }
            if ($field->isAdvancedField) {
                continue;
            }
            $checked = "";
            $classes = "";
            if ($customWritePanel != null) {
                if (in_array($field->id, $customWritePanelStandardFieldIds)) {
                    $checked = "checked=\"checked\"";
                }
            } else {
                if ($field->defaultChecked) {
                    $checked = "checked=\"checked\"";
                }
            }
            if ($field->forPost && !$field->forPage) {
                $classes = $classes . " flutter_forpost";
            }
            if ($field->forPage && !$field->forPost) {
                $classes = $classes . " flutter_forpage";
            }
            ?>
					<div class="<?php 
            echo $classes;
            ?>
"> 
						<input type="checkbox" name="custom-write-panel-standard-fields[]" value="<?php 
            echo $field->id;
            ?>
" <?php 
            echo $checked;
            ?>
 /> 
						<?php 
            echo $field->displayName;
            ?>
 
						<br />
					</div>
				<?php 
        }
        ?>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row" align="right"><?php 
        _e('Advanced Fields', $flutter_domain);
        ?>
:</th>
			<td>
				<?php 
        global $STANDARD_FIELDS, $wp_version;
        foreach ($STANDARD_FIELDS as $field) {
            if ($field->excludeVersion <= substr($wp_version, 0, 3)) {
                continue;
            }
            if (!$field->isAdvancedField) {
                continue;
            }
            $checked = "";
            $classes = "";
            if ($customWritePanel != null) {
                if (in_array($field->id, $customWritePanelStandardFieldIds)) {
                    $checked = "checked=\"checked\"";
                }
            } else {
                if ($field->defaultChecked) {
                    $checked = "checked=\"checked\"";
                }
            }
            if ($field->forPost && !$field->forPage) {
                $classes = $classes . " flutter_forpost";
            }
            if ($field->forPage && !$field->forPost) {
                $classes = $classes . " flutter_forpage";
            }
            ?>
					<div class="<?php 
            echo $classes;
            ?>
"> 
						<input type="checkbox" name="custom-write-panel-standard-fields[]" value="<?php 
            echo $field->id;
            ?>
" <?php 
            echo $checked;
            ?>
 /> 
						<?php 
            echo $field->displayName;
            ?>
 
						<br />
					</div>
				<?php 
        }
        ?>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row" align="right"><?php 
        _e('Order', $flutter_domain);
        ?>
:</th>
            <?php 
        if (empty($customWritePanelDisplayOrder)) {
            $customWritePanelDisplayOrder = "";
        }
        ?>
			<td><input name="custom-write-panel-order" id="custom-write-panel-order" size="2" type="text" value="<?php 
        echo $customWritePanelDisplayOrder;
        ?>
" /></td>
		</tr>

		<?php 
        if (!isset($customWritePanel)) {
            ?>
		<tr>
			<th scope="row" align="right"><?php 
            _e('Custom Fields', $flutter_domain);
            ?>
:</th>
			<td><?php 
            _e('Add custom fields later by editing this custom write panel.', $flutter_domain);
            ?>
</td>
		</tr>
		<?php 
        }
        ?>
		</tbody>
		</table>
		
		<?php 
    }
Exemplo n.º 11
0
    public static function Content($customGroup = null)
    {
        // add the new expanded column, if it's not there already (Traversal)
        RCCWP_Application::AddColumnIfNotExist(MF_TABLE_PANEL_GROUPS, "expanded", $column_attr = "tinyint after duplicate");
        global $mf_domain;
        $customGroupName = $customGroupDuplicate = $customGroupExpanded = "";
        if (isset($_GET['custom-write-panel-id'])) {
            $customWritePanelId = $_GET['custom-write-panel-id'];
        }
        if (isset($_POST['custom-write-panel-id'])) {
            $customWritePanelId = $_POST['custom-write-panel-id'];
        }
        if ($customGroup != null) {
            $customGroupName = $customGroup->name;
            $customGroupDuplicate = $customGroup->duplicate;
            $customGroupExpanded = $customGroup->expanded;
        }
        ?>
		<?php 
        if ($customWritePanelId) {
            ?>
  			<input type="hidden" name="custom-write-panel-id" value="<?php 
            echo $customWritePanelId;
            ?>
">
		<?php 
        }
        ?>

		<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
		<tbody>

		<tr valign="top">
			<th scope="row"  align="right"><?php 
        _e('Name', $mf_domain);
        ?>
:</th>
			<td><input name="custom-group-name" id="custom-group-name" size="40" type="text" value="<?php 
        echo $customGroupName;
        ?>
" /></td>
		</tr>

		<tr>
			<th scope="row" align="right"><?php 
        _e('Duplication', $mf_domain);
        ?>
:</th>
			<td><input name="custom-group-duplicate" id="custom-group-duplicate" type="checkbox" value="1" <?php 
        echo $customGroupDuplicate == 0 ? "" : "checked";
        ?>
 />&nbsp;<?php 
        _e('The group can be duplicated', $mf_domain);
        ?>
</td>
		</tr>

		<tr>
			<th scope="row" align="right"><?php 
        _e('Show as Expanded', $mf_domain);
        ?>
:</th>
			<td><input name="custom-group-expanded" id="custom-group-expanded" type="checkbox" value="1" <?php 
        echo $customGroupExpanded == 0 ? '' : ' checked="checked" ';
        ?>
 />&nbsp;<?php 
        _e('Display the full expanded group editing interface instead of the group summary', $mf_domain);
        ?>
			  <br /><small><?php 
        _e('Note: the group can still be collapsed by the user, this just determines the default state on load');
        ?>
</td>
		</tr>

		</tbody>
		</table>
		<br />

		<?php 
    }
Exemplo n.º 12
0
 function Main()
 {
     require_once 'RC_Format.php';
     global $CUSTOM_WRITE_PANEL;
     wp_enqueue_script('jquery-ui-sortable');
     if (isset($_POST['edit-with-no-custom-write-panel'])) {
         wp_redirect('post.php?action=edit&post=' . $_POST['post-id'] . '&no-custom-write-panel=' . $_POST['custom-write-panel-id']);
     } else {
         if (isset($_POST['edit-with-custom-write-panel'])) {
             wp_redirect('post.php?action=edit&post=' . $_POST['post-id'] . '&custom-write-panel-id=' . $_POST['custom-write-panel-id']);
         }
     }
     if (empty($_REQUEST['flutter_action'])) {
         $currentAction = "";
     } else {
         $currentAction = $_REQUEST['flutter_action'];
     }
     switch ($currentAction) {
         // ------------ Write Panels
         case 'finish-create-custom-write-panel':
             include_once 'RCCWP_CustomWritePanel.php';
             $default_theme_page = NULL;
             if ($_POST['radPostPage'] == 'page') {
                 $default_theme_page = $_POST['page_template'];
             }
             $customWritePanelId = RCCWP_CustomWritePanel::Create($_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page);
             wp_redirect(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('view-custom-write-panel', $customWritePanelId));
             break;
         case 'submit-edit-custom-write-panel':
             include_once 'RCCWP_CustomWritePanel.php';
             $default_theme_page = NULL;
             if ($_POST['radPostPage'] == 'page') {
                 $default_theme_page = $_POST['page_template'];
             }
             RCCWP_CustomWritePanel::Update($_POST['custom-write-panel-id'], $_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page);
             RCCWP_CustomWritePanel::AssignToRole($_POST['custom-write-panel-id'], 'administrator');
             break;
         case 'export-custom-write-panel':
             require_once 'RCCWP_CustomWritePanel.php';
             $panelID = $_REQUEST['custom-write-panel-id'];
             $writePanel = RCCWP_CustomWritePanel::Get($panelID);
             $exportedFilename = $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $writePanel->name . '.pnl';
             RCCWP_CustomWritePanel::Export($panelID, $exportedFilename);
             // send file in header
             header('Content-type: binary');
             header('Content-Disposition: attachment; filename="' . $writePanel->name . '.pnl"');
             readfile($exportedFilename);
             unlink($exportedFilename);
             exit;
             break;
         case 'delete-custom-write-panel':
             include_once 'RCCWP_CustomWritePanel.php';
             RCCWP_CustomWritePanel::Delete($_GET['custom-write-panel-id']);
             //wp_redirect('?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php'));
             break;
             // ------------ Modules
             // ------------ Groups
         // ------------ Modules
         // ------------ Groups
         case 'finish-create-custom-group':
             include_once 'RCCWP_CustomGroup.php';
             $customGroupId = RCCWP_CustomGroup::Create($_POST['custom-write-panel-id'], $_POST['custom-group-name'], $_POST['custom-group-duplicate'], $_POST['custom-group-at_right']);
             break;
         case 'delete-custom-group':
             include_once 'RCCWP_CustomGroup.php';
             $customGroup = RCCWP_CustomGroup::Get((int) $_REQUEST['custom-group-id']);
             RCCWP_CustomGroup::Delete($_GET['custom-group-id']);
             break;
         case 'submit-edit-custom-group':
             include_once 'RCCWP_CustomGroup.php';
             RCCWP_CustomGroup::Update($_REQUEST['custom-group-id'], $_POST['custom-group-name'], $_POST['custom-group-duplicate'], $_POST['custom-group-at_right']);
             break;
             // ------------ Fields
         // ------------ Fields
         case 'copy-custom-field':
             include_once 'RCCWP_CustomField.php';
             $fieldToCopy = RCCWP_CustomField::Get($_REQUEST['custom-field-id']);
             if (RCCWP_Processor::CheckFieldName($fieldToCopy->name, $_REQUEST['custom-write-panel-id'])) {
                 $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                 wp_redirect($newURL);
                 exit;
             }
             RCCWP_CustomField::Create($_REQUEST['custom-group-id'], $fieldToCopy->name, $fieldToCopy->description, $fieldToCopy->display_order, $fieldToCopy->required_field, $fieldToCopy->type_id, $fieldToCopy->options, $fieldToCopy->default_value, $fieldToCopy->properties, $fieldToCopy->duplicate);
         case 'continue-create-custom-field':
             if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                 $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                 wp_redirect($newURL);
                 exit;
             }
             break;
         case 'finish-create-custom-field':
             include_once 'RCCWP_CustomField.php';
             if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                 $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                 wp_redirect($newURL);
                 exit;
             }
             $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_REQUEST['custom-field-type']);
             if ($current_field->has_properties) {
                 $custom_field_properties = array();
                 if (in_array($current_field->name, array('Textbox', 'Listbox'))) {
                     $custom_field_properties['size'] = $_POST['custom-field-size'];
                 } else {
                     if (in_array($current_field->name, array('Multiline Textbox'))) {
                         $custom_field_properties['height'] = $_POST['custom-field-height'];
                         $custom_field_properties['width'] = $_POST['custom-field-width'];
                     } else {
                         if (in_array($current_field->name, array('Date'))) {
                             $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                         } else {
                             if (in_array($current_field->name, array('Image'))) {
                                 $params = '';
                                 if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) {
                                     $params .= '&h=' . $_POST['custom-field-photo-height'];
                                 }
                                 if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) {
                                     $params .= '&w=' . $_POST['custom-field-photo-width'];
                                 }
                                 if ($_POST['custom-field-custom-params'] != '') {
                                     $params .= '&' . $_POST['custom-field-custom-params'];
                                 }
                                 if ($params) {
                                     $custom_field_properties['params'] = $params;
                                 }
                             } else {
                                 if (in_array($current_field->name, array('Date'))) {
                                     $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                                 } else {
                                     if (in_array($current_field->name, array('Slider'))) {
                                         $custom_field_properties['max'] = $_POST['custom-field-slider-max'];
                                         $custom_field_properties['min'] = $_POST['custom-field-slider-min'];
                                         $custom_field_properties['step'] = $_POST['custom-field-slider-step'];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             RCCWP_CustomField::Create($_POST['custom-group-id'], $_POST['custom-field-name'], $_POST['custom-field-description'], $_POST['custom-field-order'], $_POST['custom-field-required'], $_POST['custom-field-type'], $_POST['custom-field-options'], $_POST['custom-field-default-value'], $custom_field_properties, $_POST['custom-field-duplicate']);
             break;
         case 'submit-edit-custom-field':
             include_once 'RCCWP_CustomField.php';
             $current_field_obj = RCCWP_CustomField::Get($_POST['custom-field-id']);
             if ($_POST['custom-field-name'] != $current_field_obj->name && RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                 $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-field') . '&custom-field-id=' . $_POST['custom-field-id'] . '&err_msg=-1';
                 wp_redirect($newURL);
                 exit;
             }
             $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_POST['custom-field-type']);
             if ($current_field->has_properties) {
                 $custom_field_properties = array();
                 if (in_array($current_field->name, array('Textbox', 'Listbox'))) {
                     $custom_field_properties['size'] = $_POST['custom-field-size'];
                 } else {
                     if (in_array($current_field->name, array('Multiline Textbox'))) {
                         $custom_field_properties['height'] = $_POST['custom-field-height'];
                         $custom_field_properties['width'] = $_POST['custom-field-width'];
                     } else {
                         if (in_array($current_field->name, array('Image'))) {
                             $params = '';
                             if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) {
                                 $params = '&h=' . $_POST['custom-field-photo-height'];
                             }
                             if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) {
                                 $params .= '&w=' . $_POST['custom-field-photo-width'];
                             }
                             if ($_POST['custom-field-custom-params'] != '') {
                                 $params .= '&' . $_POST['custom-field-custom-params'];
                             }
                             if ($params) {
                                 $custom_field_properties['params'] = $params;
                             }
                         } else {
                             if (in_array($current_field->name, array('Date'))) {
                                 $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                             } else {
                                 if (in_array($current_field->name, array('Slider'))) {
                                     $custom_field_properties['max'] = $_POST['custom-field-slider-max'];
                                     $custom_field_properties['min'] = $_POST['custom-field-slider-min'];
                                     $custom_field_properties['step'] = $_POST['custom-field-slider-step'];
                                 }
                             }
                         }
                     }
                 }
             }
             RCCWP_CustomField::Update($_POST['custom-field-id'], $_POST['custom-field-name'], $_POST['custom-field-description'], $_POST['custom-field-order'], $_POST['custom-field-required'], $_POST['custom-field-type'], $_POST['custom-field-options'], $_POST['custom-field-default-value'], $custom_field_properties, $_POST['custom-field-duplicate']);
             break;
         case 'delete-custom-field':
             include_once 'RCCWP_CustomField.php';
             if (isset($_REQUEST['custom-group-id']) && !empty($_REQUEST['custom-group-id'])) {
                 $customGroupId = (int) $_REQUEST['custom-group-id'];
             }
             $customGroup = RCCWP_CustomGroup::Get($customGroupId);
             RCCWP_CustomField::Delete($_REQUEST['custom-field-id']);
             break;
         case 'delete-theme-settings':
             include_once 'RCCWP_ThemeSettingsPage.php';
             $settings = new RCCWP_ThemeSettingsPage();
             $settings->remove_layout_setting();
             break;
         case 'create-layout-setting':
             include_once 'RCCWP_ThemeSettingsPage.php';
             if (!empty($_POST['variable_name'])) {
                 RCCWP_ThemeSettingsPage::finish_create_layout_element();
                 break;
             }
         default:
             if (RCCWP_Application::InWritePostPanel()) {
                 include_once 'RCCWP_Menu.php';
                 include_once 'RCCWP_WritePostPage.php';
                 $CUSTOM_WRITE_PANEL = RCCWP_Post::GetCustomWritePanel();
                 if (isset($CUSTOM_WRITE_PANEL) && $CUSTOM_WRITE_PANEL > 0) {
                     ob_start(array('RCCWP_WritePostPage', 'ApplyCustomWritePanelAssignedCategories'));
                     add_action('admin_head', array('RCCWP_WritePostPage', 'ApplyCustomWritePanelHeader'));
                     // Allows fields to be added to right
                     //	commented to test		add_action('submitpost_box', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterfaceRight'), 5);
                     //						add_action('submitpage_box', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterfaceRight'), 5);
                     // commented to test
                     add_action('add_meta_box', 'post', 'side', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterfaceRight'));
                     // Allows fields to be added to the post edit body
                     add_action('simple_edit_form', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface'), 5);
                     add_action('edit_form_advanced', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface'), 5);
                     add_action('edit_page_form', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface'), 5);
                 } else {
                     if (!isset($_REQUEST['no-custom-write-panel']) && isset($_REQUEST['post'])) {
                         include_once 'RCCWP_Options.php';
                         $promptEditingPost = RCCWP_Options::Get('prompt-editing-post');
                         if ($promptEditingPost == 1) {
                             wp_redirect('?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&assign-custom-write-panel=' . (int) $_GET['post']);
                         }
                     }
                 }
             } else {
                 if (isset($_POST['finish-create-custom-write-module'])) {
                     include_once 'RCCWP_CustomWriteModule.php';
                     $customWriteModuleId = RCCWP_CustomWriteModule::Create($_POST['custom-write-module-name'], $_POST['custom-write-module-description']);
                     //RCCWP_CustomWritePanel::AssignToRole($customWritePanelId, 'administrator');
                     if ($customWriteModuleId == -1) {
                         //$_POST['create-custom-write-module'] = 1;
                         $modulesURL = '?page=' . 'FlutterManageModules' . '&view-modules=1&create-custom-write-module=1&err_msg=-1';
                         wp_redirect($modulesURL);
                     } else {
                         wp_redirect(RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($customWriteModuleId));
                     }
                 } else {
                     if (isset($_POST['submit-edit-custom-write-module'])) {
                         include_once 'RCCWP_CustomWriteModule.php';
                         $customWriteModuleId = RCCWP_CustomWriteModule::Update($_REQUEST['custom-write-module-id'], $_REQUEST['custom-write-module-name'], $_REQUEST['custom-write-module-description']);
                         if ($customWriteModuleId == -1) {
                             $customWriteModuleId = $_REQUEST['custom-write-module-id'];
                             $modulesURL = '?page=' . 'FlutterManageModules' . "&edit-custom-write-module=1&view-custom-write-module={$customWriteModuleId}&custom-write-module-id={$customWriteModuleId}&err_msg=-1";
                             wp_redirect($modulesURL);
                         }
                         //RCCWP_CustomWritePanel::AssignToRole($_POST['custom-write-panel-id'], 'administrator');
                     } else {
                         if (isset($_POST['update-custom-write-panel-options'])) {
                             if ($_POST['uninstall-custom-write-panel'] == 'uninstall') {
                                 RCCWP_Application::Uninstall();
                                 wp_redirect('options-general.php');
                             } else {
                                 include_once 'RCCWP_Options.php';
                                 $options['hide-write-post'] = $_POST['hide-write-post'];
                                 $options['hide-write-page'] = $_POST['hide-write-page'];
                                 $options['hide-visual-editor'] = $_POST['hide-visual-editor'];
                                 $options['prompt-editing-post'] = $_POST['prompt-editing-post'];
                                 $options['assign-to-role'] = $_POST['assign-to-role'];
                                 $options['use-snipshot'] = $_POST['use-snipshot'];
                                 $options['enable-editnplace'] = $_POST['enable-editnplace'];
                                 $options['eip-highlight-color'] = $_POST['eip-highlight-color'];
                                 $options['enable-swfupload'] = $_POST['enable-swfupload'];
                                 $options['enable-browserupload'] = $_POST['enable-browserupload'];
                                 $options['default-custom-write-panel'] = $_POST['default-custom-write-panel'];
                                 $options['enable-HTMLPurifier'] = $_POST['enable-HTMLPurifier'];
                                 $options['tidy-level'] = $_POST['tidy-level'];
                                 $options['canvas_show_instructions'] = $_POST['canvas_show_instructions'];
                                 $options['canvas_show_zone_name'] = $_POST['canvas_show_zone_name'];
                                 $options['canvas_show'] = $_POST['canvas_show'];
                                 $options['ink_show'] = $_POST['ink_show'];
                                 RCCWP_Options::Update($options);
                             }
                         } else {
                             if (isset($_REQUEST['create-module-duplicate'])) {
                                 include_once 'RCCWP_ModuleDuplicate.php';
                                 $moduleID = $_REQUEST['custom-write-module-id'];
                                 RCCWP_ModuleDuplicate::Create($moduleID);
                                 wp_redirect(RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($moduleID));
                             } else {
                                 if (isset($_POST['submit-edit-module-duplicate'])) {
                                     include_once 'RCCWP_ModuleDuplicate.php';
                                     $moduleID = $_REQUEST['custom-write-module-id'];
                                     RCCWP_ModuleDuplicate::Update($_REQUEST['module-duplicate-id'], $_REQUEST['module-duplicate-name']);
                                     wp_redirect('?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&view-custom-write-module=' . $moduleID . '&custom-write-module-id=' . $moduleID);
                                 } else {
                                     if (isset($_REQUEST['delete-module-duplicate'])) {
                                         include_once 'RCCWP_ModuleDuplicate.php';
                                         $moduleID = $_REQUEST['custom-write-module-id'];
                                         RCCWP_ModuleDuplicate::Delete($_REQUEST['module-duplicate-id']);
                                         wp_redirect(RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($moduleID));
                                     } else {
                                         if (isset($_POST['delete-custom-write-module'])) {
                                             include_once 'RCCWP_CustomWriteModule.php';
                                             $moduleID = $_REQUEST['custom-write-module-id'];
                                             RCCWP_CustomWriteModule::Delete($moduleID);
                                             wp_redirect('?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&view-modules=1');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
     }
 }
    function Content($customWritePanel = null)
    {
        // add the new expanded column, if it's not there already (Traversal)
        RCCWP_Application::AddColumnIfNotExist(MF_TABLE_PANELS, "expanded", $column_attr = "tinyint NOT NULL DEFAULT 1 after type");
        global $mf_domain, $wpdb;
        $customWritePanelName = "";
        $customWritePanelDescription = "";
        $customWritePanelExpanded = 1;
        $write_panel_category_ids = array();
        $defaultTagChecked = 'checked="checked"';
        $customWritePanelAllFieldIds = NULL;
        $customThemePage = NULL;
        $showPost = true;
        $customParentPage = NULL;
        $customWritePanelCategoryIds = NULL;
        if ($customWritePanel != null) {
            $customWritePanelName = $customWritePanel->name;
            $customWritePanelDescription = $customWritePanel->description;
            $customWritePanelExpanded = $customWritePanel->expanded;
            $customWritePanelDisplayOrder = $customWritePanel->display_order;
            $customWritePanelType = $customWritePanel->type;
            if ($customWritePanelType == 'page') {
                $showPost = false;
            }
            $customWritePanelCategoryIds = RCCWP_CustomWritePanel::GetAssignedCategoryIds($customWritePanel->id);
            foreach ($customWritePanelCategoryIds as $key => $c) {
                if ((int) $c != 0) {
                    $tc = get_category($c);
                    $customWritePanelCategoryIds[$key] = $tc->slug;
                }
            }
            $customWritePanelStandardFieldIds = RCCWP_CustomWritePanel::GetStandardFields($customWritePanel->id);
            $customWritePanelAllFieldIds = RCCWP_CustomWritePanel::Get($customWritePanel->id);
            if ($customWritePanelType == 'page') {
                $customThemePage = RCCWP_CustomWritePanel::GetThemePage($customWritePanel->name);
                $customParentPage = RCCWP_CustomWritePanel::GetParentPage($customWritePanel->name);
            }
            $defaultTagChecked = '';
            ?>
			<input type="hidden" name="custom-write-panel-id" value="<?php 
            echo $customWritePanel->id;
            ?>
" />
			<?php 
        }
        ?>


		<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
		<tbody>
		<tr valign="top">
			<th scope="row"><?php 
        _e('Placement', $mf_domain);
        ?>
</th>
				<td>
				<!-- START :: Javascript for Image/Photo' Css Class -->
				<script type="text/javascript" language="javascript">
					jQuery(document).ready( function() {
							<?php 
        if ($showPost) {
            ?>
								showHide("mf_forpost", "mf_forpage");
							<?php 
        } else {
            ?>
								showHide("mf_forpage", "mf_forpost");
							<?php 
        }
        ?>
						});
						
					function showHide(showClassID, hideClassID)
					{
						jQuery( function($) {
							$("."+showClassID).css("display","");
							$("."+hideClassID).css("display","none");
							});
					}
				</script>
				<!-- END :: Javascript for Image/Photo' Css Class -->
				<input type="radio" name="radPostPage" id="radPostPage" value="post" <?php 
        if (empty($custoWritePanelType) || $customWritePanelType == 'post') {
            ?>
 checked="checked" <?php 
        }
        ?>
 onclick='showHide("mf_forpost", "mf_forpage");' /> <strong><?php 
        _e('Post', $mf_domain);
        ?>
 </strong> &nbsp; &nbsp; &nbsp; 
				<input type="radio" name="radPostPage" id="radPostPage" value="page" <?php 
        if (!empty($customWritePanelType) && $customWritePanelType == 'page') {
            ?>
 checked="checked" <?php 
        }
        ?>
 onclick='showHide("mf_forpage", "mf_forpost");' /> <strong><?php 
        _e('Page', $mf_domain);
        ?>
</strong>
			</td>
		</tr>


		<tr valign="top">
			<th scope="row"  align="right"><?php 
        _e('Name', $mf_domain);
        ?>
:</th>
			<td>
				<input name="custom-write-panel-name" id="custom-write-panel-name" size="40" type="text" value="<?php 
        echo $customWritePanelName;
        ?>
" />
			</td>
		</tr>

	
		<tr valign="top"  id="catText" class="mf_forpost">
			<th scope="row"  align="right"><div id="catLabel" style="display:inline;"><?php 
        _e('Assigned Categories', $mf_domain);
        ?>
:</div></th>
			<td>
				
				<?php 
        $cats = get_categories("get=all");
        RCCWP_CustomWritePanelPage::PrintNestedCats($cats, 0, 0, $customWritePanelCategoryIds);
        ?>
				
			</td>
		</tr>
		
		<tr valign="top"  id="catText" class="mf_forpage">
			<th scope="row"  align="right"><div id="catLabel" style="display:inline;"><?php 
        _e('Assigned Theme', $mf_domain);
        ?>
:</div></th>
			<td>
				
				<select name="page_template" id="page_template">
					<option value='default'><?php 
        _e('Default Template');
        ?>
</option>
					<?php 
        $themes_defaults = get_page_templates();
        $theme_select = NULL;
        foreach ($themes_defaults as $v => $k) {
            $theme_select = NULL;
            if ($customWritePanelType == 'page') {
                if ($customThemePage == $k) {
                    $theme_select = 'SELECTED';
                }
            }
            ?>
					<option value='<?php 
            echo $k;
            ?>
' <?php 
            echo $theme_select;
            ?>
 ><?php 
            echo $v;
            ?>
</option>
					<?php 
        }
        ?>
					<?php 
        ?>
				</select>
		
			</td>
		</tr>
		
		<tr valign="top"  id="catText" class="mf_forpage">
			<th scope="row"  align="right"><div id="catLabel" style="display:inline;"><?php 
        _e('Page Parent', $mf_domain);
        ?>
:</div></th>
			<td>
			<?php 
        wp_dropdown_pages(array('selected' => $customParentPage, 'name' => 'parent_id', 'show_option_none' => __('Main Page (no parent)'), 'sort_column' => 'menu_order, post_title', 'option_none_value' => -1));
        ?>
			</td>
		</tr>
		
		<tr>
			<th><?php 
        _e('Quantity', $mf_domain);
        ?>
</th>
			<td>
				<?php 
        if (isset($customWritePanel->id) && !empty($customWritePanel->id)) {
            if ($customWritePanelAllFieldIds->single == 0) {
                $multiple_checked = 'checked="checked"';
                $single_checked = '';
            } else {
                $single_checked = 'checked="checked"';
                $multiple_checked = '';
            }
        } else {
            $multiple_checked = 'checked="checked"';
            $single_checked = '';
        }
        ?>
				<input type="radio" name="single" id="radPostPage" value="1" <?php 
        echo $single_checked;
        ?>
  /> <strong><?php 
        _e('Single', $mf_domain);
        ?>
 </strong> &nbsp; &nbsp; &nbsp; 
				<input type="radio" name="single" id="radPostPage" value="0" <?php 
        echo $multiple_checked;
        ?>
  /> <strong><?php 
        _e('Multiple', $mf_domain);
        ?>
</strong>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row" align="right"><?php 
        _e('Standard Fields', $mf_domain);
        ?>
:</th>
			<td>
				<?php 
        global $STANDARD_FIELDS, $wp_version;
        foreach ($STANDARD_FIELDS as $field) {
            if ($field->excludeVersion <= substr($wp_version, 0, 3)) {
                continue;
            }
            if ($field->isAdvancedField) {
                continue;
            }
            $checked = "";
            $classes = "";
            if ($customWritePanel != null) {
                if (in_array($field->id, $customWritePanelStandardFieldIds)) {
                    $checked = "checked=\"checked\"";
                }
            } else {
                if ($field->defaultChecked) {
                    $checked = "checked=\"checked\"";
                }
            }
            if ($field->forPost && !$field->forPage) {
                $classes = $classes . " mf_forpost";
            }
            if ($field->forPage && !$field->forPost) {
                $classes = $classes . " mf_forpage";
            }
            ?>
					<div class="<?php 
            echo $classes;
            ?>
"> 
						<input type="checkbox" name="custom-write-panel-standard-fields[]" value="<?php 
            echo $field->id;
            ?>
" <?php 
            echo $checked;
            ?>
 /> 
						<?php 
            echo $field->displayName;
            ?>
 
						<br />
					</div>
				<?php 
        }
        ?>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row" align="right"><?php 
        _e('Advanced Fields', $mf_domain);
        ?>
:</th>
			<td>
				<?php 
        global $STANDARD_FIELDS, $wp_version;
        foreach ($STANDARD_FIELDS as $field) {
            if ($field->excludeVersion <= substr($wp_version, 0, 3)) {
                continue;
            }
            if (!$field->isAdvancedField) {
                continue;
            }
            $checked = "";
            $classes = "";
            if ($customWritePanel != null) {
                if (in_array($field->id, $customWritePanelStandardFieldIds)) {
                    $checked = "checked=\"checked\"";
                }
            } else {
                if ($field->defaultChecked) {
                    $checked = "checked=\"checked\"";
                }
            }
            if ($field->forPost && !$field->forPage) {
                $classes = $classes . " mf_forpost";
            }
            if ($field->forPage && !$field->forPost) {
                $classes = $classes . " mf_forpage";
            }
            ?>
					<div class="<?php 
            echo $classes;
            ?>
"> 
						<input type="checkbox" name="custom-write-panel-standard-fields[]" value="<?php 
            echo $field->id;
            ?>
" <?php 
            echo $checked;
            ?>
 /> 
						<?php 
            echo $field->displayName;
            ?>
 
						<br />
					</div>
				<?php 
        }
        ?>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row" align="right"><?php 
        _e('Order', $mf_domain);
        ?>
:</th>
			<?php 
        if (empty($customWritePanelDisplayOrder)) {
            $customWritePanelDisplayOrder = "";
        }
        ?>
			<td><input name="custom-write-panel-order" id="custom-write-panel-order" size="2" type="text" value="<?php 
        echo $customWritePanelDisplayOrder;
        ?>
" /></td>
		</tr>
		
		<tr>
			<th scope="row" align="right"><?php 
        _e('Top Level Fields Expanded', $mf_domain);
        ?>
:</th>
			<td><input name="custom-write-panel-expanded" id="custom-write-panel-expanded" type="checkbox" value="1" <?php 
        echo $customWritePanelExpanded == 0 ? '' : ' checked="checked" ';
        ?>
 />&nbsp;<?php 
        _e('Display the full expanded group editing interface instead of the summary for fields created at the top level (fields not inside a group)', $mf_domain);
        ?>
			  <br /><small><?php 
        _e('Note: the group can still be collapsed by the user, this just determines the default state on load');
        ?>
</td>
		</tr>


		</tbody>
		</table>
		
		<?php 
    }
Exemplo n.º 14
0
            //<![CDATA[                                                                                     
            jQuery('body').bind('afterPreWpautop', function(e, o){
                o.data = o.unfiltered
                  .replace(/caption\]\[caption/g, 'caption] [caption')
                  .replace(/<object[\s\S]+?<\/object>/g, function(a) {
                              return a.replace(/[\r\n]+/g, ' ');
              });
              }).bind('afterWpautop', function(e, o){
                o.data = o.unfiltered;
              });
          //]]>                                                                                           
          </script>
          <?php 
        }
    }
    if (RCCWP_Application::InWritePostPanel()) {
        require_once 'RCCWP_Options.php';
        $dont_remove = RCCWP_Options::Get('dont-remove-tmce');
        if ($dont_remove) {
            add_action('admin_print_footer_scripts', 'tmce_not_remove_p_and_br', 50);
        }
    }
}
add_action('pre_get_posts', array('RCCWP_Query', 'FilterPrepare'));
add_filter('posts_where', array('RCCWP_Query', 'FilterCustomPostsWhere'));
add_filter('posts_where', array('RCCWP_Query', 'ExcludeWritepanelsPosts'));
add_filter('posts_orderby', array('RCCWP_Query', 'FilterCustomPostsOrderby'));
add_filter('posts_fields', array('RCCWP_Query', 'FilterCustomPostsFields'));
add_filter('posts_join_paged', array('RCCWP_Query', 'FilterCustomPostsJoin'));
//in search add conditions for look in postmeta
add_filter('posts_where_request', array('RCCWP_Query', 'AddConditionForSearchInPostmeta'));