Get() публичный статический Метод

Get the properties of a write panel
public static Get ( unknown_type $customWritePanelId ) : an
$customWritePanelId unknown_type
Результат an object containing the properties of the write panel which are id, name, description, display_order, capability_name, type
Пример #1
0
function add_input_search_manage($where)
{
    if (isset($_GET['custom-write-panel-id'])) {
        $write_panel = RCCWP_CustomWritePanel::Get($_GET['custom-write-panel-id']);
        printf("\n      <script type=\"text/javascript\">\n      //<![CDATA[\n        jQuery().ready(function() {\n          add_input_search_manage('%s');\n        });\n      //]]>\n      </script>", $_GET['custom-write-panel-id']);
    }
    return $where;
}
Пример #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);
                     }
                 }
             }
     }
 }
Пример #3
0
 /**
  * Get a custom write panel by reading $_REQUEST['custom-write-panel-id'] or the
  * To see whether $_GET['post'] has a custom write panel associated to it.
  *
  * @return Custom Write Panel as an object, returns null if there is no write panels.
  */
 function GetCustomWritePanel()
 {
     global $wpdb;
     if (isset($_GET['post'])) {
         $customWritePanelId = get_post_meta((int) $_GET['post'], RC_CWP_POST_WRITE_PANEL_ID_META_KEY, true);
         if (empty($customWritePanelId)) {
             $customWritePanelId = (int) isset($_REQUEST['custom-write-panel-id']);
         }
     } else {
         if (function_exists('icl_t') && isset($_GET['trid'])) {
             $element_id = $wpdb->get_col("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE element_type='post' AND trid = " . intval($_GET['trid']));
             $customWritePanelId = get_post_meta((int) $element_id, RC_CWP_POST_WRITE_PANEL_ID_META_KEY, true);
             if (empty($customWritePanelId)) {
                 $customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
             }
         } else {
             if (isset($_REQUEST['custom-write-panel-id'])) {
                 $customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
             }
         }
     }
     $customWritePanel = FALSE;
     if (isset($customWritePanelId)) {
         include_once 'RCCWP_Application.php';
         $customWritePanel = RCCWP_CustomWritePanel::Get($customWritePanelId);
     }
     return $customWritePanel;
 }
Пример #4
0
$moduleID = (int) $_REQUEST['custom-write-module-id'];
$module = RCCWP_CustomWriteModule::Get($moduleID);
if (isset($_POST["write_panels"])) {
    //$write_panels = json_decode(stripslashes($_POST["write_panels"]));
    $modulePath = FLUTTER_MODULES_DIR . $module->name . DIRECTORY_SEPARATOR;
    $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR;
    // Copy dir to tmp folder
    dircopy($modulePath, $tmpPath . $module->name);
    $moduleTmpPath = "{$tmpPath}{$module->name}";
    chmod_R($moduleTmpPath, 0777);
    // Export write panels
    //check if arrary the write modules is empty
    if ($_POST["write_panels"] != NULL) {
        $write_panels = split(",", $_POST["write_panels"]);
        foreach ($write_panels as $panelID) {
            $writePanel = RCCWP_CustomWritePanel::Get($panelID);
            $exportedFilename = $moduleTmpPath . DIRECTORY_SEPARATOR . '_' . $writePanel->name . '.pnl';
            RCCWP_CustomWritePanel::Export($panelID, $exportedFilename);
        }
    }
    // Export duplicates and description
    $moduleInfoFilename = $moduleTmpPath . DIRECTORY_SEPARATOR . 'module_info.exp';
    $moduleInfo_exported_data['duplicates'] = RCCWP_ModuleDuplicate::GetCustomModulesDuplicates($moduleID);
    $moduleInfo_exported_data['moduleinfo'] = RCCWP_CustomWriteModule::Get($moduleID);
    $handle = fopen($moduleInfoFilename, "w");
    $result = @fwrite($handle, serialize($moduleInfo_exported_data));
    @fclose($handle);
    // -- Create zip file
    $zipFile = "{$tmpPath}{$module->name}.zip";
    chdir($moduleTmpPath . DIRECTORY_SEPARATOR);
    if (RCCWP_Application::CheckCompressionProgramZip()) {
Пример #5
0
 function SetCurrentCustomWritePanelMenuItem()
 {
     global $submenu_file;
     global $menu;
     require_once 'RCCWP_Options.php';
     $options = RCCWP_Options::Get();
     if (!empty($options['default-custom-write-panel'])) {
         require_once 'RCCWP_CustomWritePanel.php';
         $customWritePanel = RCCWP_CustomWritePanel::Get((int) $options['default-custom-write-panel']);
         if ($customWritePanel->type == "post") {
             $menu[5][2] = 'post-new.php?custom-write-panel-id=' . (int) $options['default-custom-write-panel'];
         } else {
             $menu[5][2] = 'page-new.php?custom-write-panel-id=' . (int) $options['default-custom-write-panel'];
         }
     }
     if (empty($_REQUEST['custom-write-panel-id'])) {
         $_REQUEST['custom-write-panel-id'] = "";
     }
     if ($_REQUEST['custom-write-panel-id']) {
         $customWritePanel = RCCWP_CustomWritePanel::Get((int) $_REQUEST['custom-write-panel-id']);
         if (isset($_REQUEST['filter-posts'])) {
             if ($customWritePanel->type == "post") {
                 $submenu_file = 'edit.php?filter-posts=1&custom-write-panel-id=' . (int) $_REQUEST['custom-write-panel-id'];
             } else {
                 $submenu_file = 'edit-pages.php?filter-posts=1&custom-write-panel-id=' . (int) $_REQUEST['custom-write-panel-id'];
             }
         } else {
             if ($customWritePanel->type == "post") {
                 $submenu_file = 'post-new.php?custom-write-panel-id=' . (int) $_REQUEST['custom-write-panel-id'];
             } else {
                 $submenu_file = 'page-new.php?custom-write-panel-id=' . (int) $_REQUEST['custom-write-panel-id'];
             }
         }
     }
 }
    /**
     * View groups/fields of a write panel
     *
     */
    function View()
    {
        global $mf_domain;
        $customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
        $customWritePanel = RCCWP_CustomWritePanel::Get($customWritePanelId);
        $custom_groups = RCCWP_CustomWritePanel::GetCustomGroups($customWritePanelId);
        // get default group id
        foreach ($custom_groups as $group) {
            if ($group->name == '__default') {
                $customDefaultGroupId = $group->id;
                break;
            }
        }
        ?>

		<script type="text/javascript" language="javascript">
			function confirmBeforeDelete()
			{
				return confirm("<?php 
        _e('Are you sure you want to delete this custom Field?', $mf_domain);
        ?>
");
			}
		</script>
		<div class="wrap">

		<form action="<?php 
        echo RCCWP_ManagementPage::GetPanelPage() . "&mf_action=view-custom-write-panel";
        ?>
" method="post"  id="posts-filter" name="SelectWritePanel">
			<h2>
				<?php 
        echo $customWritePanel->name;
        ?>
				<span style="font-size:small">
					&nbsp; &nbsp;
					<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-write-panel', $panel->id);
        ?>
" ><?php 
        _e('Edit', $mf_domain);
        ?>
</a>|
					<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('delete-custom-write-panel', $panel->id);
        ?>
" onclick="return confirmBeforeDelete();"><?php 
        _e('Delete', $mf_domain);
        ?>
</a>|
					<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('export-custom-write-panel', $panel->id);
        ?>
" ><?php 
        _e('Export', $mf_domain);
        ?>
</a>
				</span>
			</h2>
			<p id="post-search" style="margin-top:6px">
				<strong>
					<?php 
        _e('Choose a Write Panel', $mf_domain);
        ?>
					<select name="custom-write-panel-id" style="margin-top:-2px" onchange="document.SelectWritePanel.submit()">
						<?php 
        foreach ($customWritePanels as $panel) {
            ?>
							<option <?php 
            echo $customWritePanelId == $panel->id ? ' selected ' : '';
            ?>
 value="<?php 
            echo $panel->id;
            ?>
"><?php 
            echo $panel->name;
            ?>
</option>
						<?php 
        }
        ?>
					</select>
				</strong>
				<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-group');
        ?>
" class="button-secondary">+ <?php 
        _e('Create a Group', $mf_domain);
        ?>
</a>
				<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . "&custom-group-id={$customDefaultGroupId}";
        ?>
" class="button-secondary">+ <?php 
        _e('Create a Field', $mf_domain);
        ?>
</a>
			</p>
		</form>
		
		<br class="clear"/>

  		<table cellpadding="3" cellspacing="3" width="100%" class="widefat">
  		<thead>
	  		<tr>
	  			<th width="60%" scope="col"><?php 
        _e('Name', $mf_domain);
        ?>
</th>
	  			<th width="20%" scope="col"><?php 
        _e('Type', $mf_domain);
        ?>
</th>
				<th width="20%" scope="col"><?php 
        _e('Actions', $mf_domain);
        ?>
</th>
			</tr>
  		</thead>
  		<tbody>
	  		<?php 
        foreach ($custom_groups as $group) {
            if ($customDefaultGroupId != $group->id) {
                ?>
		  			<tr>
		  				<td><strong><a style="color:#D54E21" href="<?php 
                echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-group') . "&custom-group-id={$group->id}";
                ?>
"><?php 
                echo $group->name;
                ?>
</a></strong>&nbsp;&nbsp;(<a style="font-size:very-small" href="<?php 
                echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . "&custom-group-id={$group->id}";
                ?>
"><?php 
                _e('create field', $mf_domain);
                ?>
</a>) </td>
		  				<td><?php 
                _e('Group', $mf_domain);
                ?>
</td>
		  				<td><a onclick="return confirmBeforeDelete();" href="<?php 
                echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('delete-custom-group') . "&custom-group-id={$group->id}";
                ?>
">X <?php 
                _e('Delete', $mf_domain);
                ?>
</a></td>
		  				
		  			</tr>
	  		<?php 
                RCCWP_CustomWritePanelPage::DisplayGroupFields($group->id, true);
            }
        }
        RCCWP_CustomWritePanelPage::DisplayGroupFields($customDefaultGroupId);
        ?>
  		</tbody>
  		</table>
		</div>
		<br />
		<?php 
    }
Пример #7
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'));
                }
        }
    }
Пример #8
0
 /**
  * Return the name of the write panel giving the post_id
  *
  * @param integer $post_id
  * @return string
  */
 function GetWritePanelName($post_id)
 {
     global $wpdb;
     if ($the_post = wp_is_post_revision($post_id)) {
         $post_id = $the_post;
     }
     //getting the panel id
     $sql = $wpdb->prepare("SELECT meta_value FROM {$wpdb->postmeta} WHERE post_id = %s AND meta_key = %s", array($post_id, '_mf_write_panel_id'));
     $panel_id = $wpdb->get_var($sql);
     if (empty($panel_id)) {
         return false;
     }
     //Getting the write panel name using the id
     $properties = RCCWP_CustomWritePanel::Get($panel_id);
     return $properties->name;
 }
Пример #9
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');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
     }
 }
Пример #10
0
    function ApplyCustomWritePanelHeader()
    {
        global $CUSTOM_WRITE_PANEL;
        global $mf_domain;
        // Validate	 capability
        require_once 'RCCWP_Options.php';
        $assignToRole = RCCWP_Options::Get('assign-to-role');
        $requiredPostsCap = 'edit_posts';
        $requiredPagesCap = 'edit_pages';
        if ($assignToRole == 1) {
            $requiredPostsCap = $CUSTOM_WRITE_PANEL->capability_name;
            $requiredPagesCap = $CUSTOM_WRITE_PANEL->capability_name;
        }
        if ($CUSTOM_WRITE_PANEL->type == "post") {
            $requiredCap = $requiredPostsCap;
        } else {
            $requiredCap = $requiredPagesCap;
        }
        if (!current_user_can($requiredCap)) {
            wp_die(__('You do not have sufficient permissions to access this custom write panel.', $mf_domain));
        }
        ?>
		
		<script type="text/javascript">
			var mf_path = "<?php 
        echo MF_URI;
        ?>
" ;
			var JS_MF_FILES_PATH = '<?php 
        echo MF_FILES_URI;
        ?>
';
			var swf_authentication = "<?php 
        if (function_exists('is_ssl') && is_ssl()) {
            echo $_COOKIE[SECURE_AUTH_COOKIE];
        } else {
            echo $_COOKIE[AUTH_COOKIE];
        }
        ?>
" ;
			var swf_nonce = "<?php 
        echo wp_create_nonce('media-form');
        ?>
" ;
		</script>
 		<script type="text/javascript" src="<?php 
        echo MF_URI;
        ?>
js/groups.js"></script>
		
		<script type="text/javascript">
				function isset(  ) {
					var a=arguments; var l=a.length; var i=0;
					
					while ( i!=l ) {
						if (typeof(a[i])=='undefined') { 
						return false; 
						} else { 
						i++; 
						}
					}
					
					return true;
				}
			
			// -------------
			// Edit Photo functions
			function prepareUpdatePhoto(inputName){	
				jQuery('#'+inputName+'_dorename').val(1);
				return true;
			}
		</script>
		
		<script type="text/javascript">
			var JS_MF_FILES_PATH   = '<?php 
        echo MF_FILES_URI;
        ?>
';
			var wp_root            = "<?php 
        echo get_bloginfo('wpurl');
        ?>
";
			var mf_path            = "<?php 
        echo MF_URI;
        ?>
";
			var mf_relative        = "<?php 
        echo MF_URI_RELATIVE;
        ?>
";
			var phpthumb           = "<?php 
        echo PHPTHUMB;
        ?>
";
			var swf_authentication = "<?php 
        if (function_exists('is_ssl') && is_ssl()) {
            echo $_COOKIE[SECURE_AUTH_COOKIE];
        } else {
            echo $_COOKIE[AUTH_COOKIE];
        }
        ?>
" ;
			var swf_nonce          = "<?php 
        echo wp_create_nonce('media-form');
        ?>
" ;
		</script>

		<script type="text/javascript">
				function isset(  ) {
					var a=arguments; var l=a.length; var i=0;
					
					while ( i!=l ) {
						if (typeof(a[i])=='undefined') { 
						return false; 
						} else { 
						i++; 
						}
					}
					
					return true;
				}
		</script>

		<?php 
        //change title
        global $post, $title;
        if ($post->ID == 0) {
            $blu = RCCWP_CustomWritePanel::Get($CUSTOM_WRITE_PANEL->id);
            if ($post->post_type == "post") {
                $name_title = "Post";
            } else {
                $name_title = "Page";
            }
            $title = "Write " . $name_title . " >> " . $blu->name;
        } else {
            $blu = RCCWP_CustomWritePanel::Get($CUSTOM_WRITE_PANEL->id);
            if ($post->post_type == "post") {
                $name_title = "Post";
            } else {
                $name_title = "Page";
            }
            $title = "Edit " . $name_title . " >> " . $blu->name;
        }
        // Show/Hide Panel fields
        global $STANDARD_FIELDS;
        $standardFields = RCCWP_CustomWritePanel::GetStandardFields($CUSTOM_WRITE_PANEL->id);
        $hideCssIds = array();
        foreach ($STANDARD_FIELDS as $standardField) {
            if (!in_array($standardField->id, $standardFields)) {
                foreach ($standardField->cssId as $cssID) {
                    array_push($hideCssIds, $cssID);
                }
            }
        }
        if (empty($hideCssIds)) {
            return;
        }
        array_walk($hideCssIds, create_function('&$item1, $key', '$item1 = "#" . $item1;'));
        $hideCssIdString = implode(', ', $hideCssIds);
        ?>
		
		<style type="text/css">
			<?php 
        echo $hideCssIdString;
        ?>
 {display: none !important;}
		</style>
		
		<?php 
    }
Пример #11
0
 /**
  * Export a write panel to file
  *
  * @param integer $panelID
  * @param string $exportedFilename the full path of the file to which the panel will be exported
  */
 function Export($panelID, $exportedFilename)
 {
     include_once 'RCCWP_CustomWriteModule.php';
     include_once 'RCCWP_CustomGroup.php';
     include_once 'RCCWP_CustomField.php';
     $exported_data = array();
     $writePanel = RCCWP_CustomWritePanel::Get($panelID);
     $writePanel->standardFieldsIDs = RCCWP_CustomWritePanel::GetStandardFields($panelID);
     $writePanel->assignedCategories = array();
     $writePanel->theme = RCCWP_CustomWritePanel::GetThemePage($writePanel->name);
     $assignedCategories = RCCWP_CustomWritePanel::GetAssignedCategories($panelID);
     foreach ($assignedCategories as $assignedCategory) {
         $writePanel->assignedCategories[] = $assignedCategory->cat_name;
     }
     $moduleGroups = RCCWP_CustomWritePanel::GetCustomGroups($panelID);
     foreach ($moduleGroups as $moduleGroup) {
         $groupFields[$moduleGroup->name]->fields = RCCWP_CustomGroup::GetCustomFields($moduleGroup->id);
         $groupFields[$moduleGroup->name]->duplicate = $moduleGroup->duplicate;
         $groupFields[$moduleGroup->name]->at_right = $moduleGroup->at_right;
     }
     $exported_data['panel'] = $writePanel;
     $exported_data['fields'] = $groupFields;
     $handle = fopen($exportedFilename, "w");
     $result = fwrite($handle, serialize($exported_data));
     @fclose($handle);
 }
Пример #12
0
    public static function attributesBoxContentPost($post)
    {
        global $wpdb;
        global $mf_domain;
        $single_panel = FALSE;
        $panel_id = get_post_meta($post->ID, "_mf_write_panel_id", TRUE);
        if ($panel_id) {
            $panel = RCCWP_CustomWritePanel::Get($panel_id);
        }
        ?>
    <p><strong><?php 
        _e('Write Panel');
        ?>
</strong></p>
    <label class="screen-reader-text" for="parent_id"><?php 
        _e('Write Panel');
        ?>
</label>
    <?php 
        // get a list of the write panels
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
        ?>
    		<select name="rc-cwp-change-custom-write-panel-id" id="rc-cwp-change-custom-write-panel-id">
          <option value="-1"><?php 
        _e('(None)', $mf_domain);
        ?>
</option>
    		<?php 
        $items = array();
        foreach ($customWritePanels as $panel) {
            $selected = $panel->id == $panel_id ? 'selected="selected"' : '';
            $allow = $panel->type == "post";
            if ($panel->single && $panel->id != $panel_id) {
                // check to see if there are any posts with this panel already. If so, we can't allow it to be used.
                $sql = $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE {$wpdb->postmeta}.meta_value = %d AND {$wpdb->postmeta}.meta_key = %s", array($panel->id, "_mf_write_panel_id"));
                $count = $wpdb->get_var($sql);
                $allow = $count == 0;
            }
            if ($allow) {
                // cannot change to "single" panels
                ?>
    			<option value="<?php 
                echo $panel->id;
                ?>
" <?php 
                echo $selected;
                ?>
><?php 
                echo $panel->name;
                ?>
</option>
    		  <?php 
            }
        }
        ?>
    		</select>
    <?php 
    }
Пример #13
0
    function ApplyCustomWritePanelHeader()
    {
        global $CUSTOM_WRITE_PANEL;
        global $flutter_domain;
        // Validate capability
        require_once 'RCCWP_Options.php';
        $assignToRole = RCCWP_Options::Get('assign-to-role');
        $requiredPostsCap = 'edit_posts';
        $requiredPagesCap = 'edit_pages';
        if ($assignToRole == 1) {
            $requiredPostsCap = $CUSTOM_WRITE_PANEL->capability_name;
            $requiredPagesCap = $CUSTOM_WRITE_PANEL->capability_name;
        }
        if ($CUSTOM_WRITE_PANEL->type == "post") {
            $requiredCap = $requiredPostsCap;
        } else {
            $requiredCap = $requiredPagesCap;
        }
        if (!current_user_can($requiredCap)) {
            wp_die(__('You do not have sufficient permissions to access this custom write panel.', $flutter_domain));
        }
        // --- Apply Flutter CSS and javascript
        ?>

		<link rel='stylesheet' href='<?php 
        echo FLUTTER_URI;
        ?>
css/epoch_styles.css' type='text/css' />
		<link href="<?php 
        echo FLUTTER_URI;
        ?>
js/greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" />
		<style type="text/css">
			
			.tr_inside{
				background-color:transparent !important;
			}
			
			.freshout{
				display: block;
    			margin-left: auto;
    			margin-right: auto ;
			}
				
			.photo_edit_link{
				clear:both;
				margin: 0px 0px 0px 0px;
				width:150px;
				text-align:center;
			}
			
			.error_msg_txt{
				font-weight: bold;
				overflow: auto;
			}
			
			.duplicate_button{
				text-decoration:none; 
				font-weight:bold;
				float:right
			}
			
			.duplicate_image{
				vertical-align:middle;
				padding-right:3px;
			}
					
		</style>
		<script language="JavaScript" type="text/javascript" src="<?php 
        echo FLUTTER_URI;
        ?>
js/prototype.js"></script>

		
		<script type="text/javascript">
            var wp_root         = "<?php 
        echo get_bloginfo('wpurl');
        ?>
";
			var GB_ROOT_DIR     = "<?php 
        echo FLUTTER_URI;
        ?>
js/greybox/";
			var flutter_path    = "<?php 
        echo FLUTTER_URI;
        ?>
";
            var flutter_relative = "<?php 
        echo FLUTTER_URI_RELATIVE;
        ?>
";
            var phpthumb        = "<?php 
        echo PHPTHUMB;
        ?>
";
			var swf_authentication = "<?php 
        if (function_exists('is_ssl') && is_ssl()) {
            echo $_COOKIE[SECURE_AUTH_COOKIE];
        } else {
            echo $_COOKIE[AUTH_COOKIE];
        }
        ?>
" ;
			var swf_nonce = "<?php 
        echo wp_create_nonce('media-form');
        ?>
" ;
		</script>
		<script type="text/javascript" src="<?php 
        echo FLUTTER_URI;
        ?>
js/greybox/AJS.js"></script>
		<script type="text/javascript" src="<?php 
        echo FLUTTER_URI;
        ?>
js/greybox/AJS_fx.js"></script>
		<script type="text/javascript" src="<?php 
        echo FLUTTER_URI;
        ?>
js/greybox/gb_scripts.js"></script>
		<script type="text/javascript" src="<?php 
        echo FLUTTER_URI;
        ?>
js/swfcallbacks.js" ></script>
		<script type="text/javascript" src="<?php 
        echo get_bloginfo('wpurl');
        ?>
/wp-includes/js/swfupload/swfupload.js"></script>

		<script type="text/javascript">
				function isset(  ) {
					// http://kevin.vanzonneveld.net
					// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
					// +   improved by: FremyCompany
					// *     example 1: isset( undefined, true);
					// *     returns 1: false
					// *     example 2: isset( 'Kevin van Zonneveld' );
					// *     returns 2: true
					
					var a=arguments; var l=a.length; var i=0;
					
					while ( i!=l ) {
						if (typeof(a[i])=='undefined') { 
						return false; 
						} else { 
						i++; 
						}
					}
					
					return true;
				}
				
			function checkForm(event){
				var stopPublish = false;
				$$('input.field_required','textarea.field_required').each(
						function(inputField){
                            <?php 
        $hide_visual_editor = RCCWP_Options::Get('hide-visual-editor');
        if ($hide_visual_editor == '' || $hide_visual_editor == 0) {
            ?>
                                re = new RegExp(".*_multiline");
                                if(re.match(inputField.id)){
                                    inputField.value = tinyMCE.get(inputField.id).getContent();
                                }

                            <?php 
        }
        ?>

							if ($F(inputField) == "" &&
								!(Object.isElement($(inputField.id+"_last")) && $F(inputField.id+"_last") != "")	){
								stopPublish = true;

								// Update row color
								if (isset($("row_"+inputField.id).style))
									$("row_"+inputField.id).style.backgroundColor = "#FFEBE8";

								// Update iframe color if it exists
								if (Object.isElement($("upload_internal_iframe_"+inputField.id))){
								  	if ($("upload_internal_iframe_"+inputField.id).contentDocument) {
								    	// For FF
								    	$("upload_internal_iframe_"+inputField.id).contentDocument.body.style.backgroundColor = "#FFEBE8"; 
								  	} else if ($("upload_internal_iframe_"+inputField.id).contentWindow) {
									    // For IE5.5 and IE6
									    $("upload_internal_iframe_"+inputField.id).contentWindow.document.body.style.backgroundColor = "#FFEBE8";
								    }
								}
									
								$("fieldcellerror_"+inputField.id).style.display = "";
								$("fieldcellerror_"+inputField.id).innerHTML = "ERROR: Field can not be empty";
							}
							else{
								$("fieldcellerror_"+inputField.id).style.display = "none";
								if (isset($("row_"+inputField.id).style))
									$("row_"+inputField.id).style.backgroundColor = "";
									
								// Update iframe color if it exists
								if (Object.isElement($("upload_internal_iframe_"+inputField.id))){
								  	if ($("upload_internal_iframe_"+inputField.id).contentDocument) {
								    	// For FF
								    	$("upload_internal_iframe_"+inputField.id).contentDocument.body.style.backgroundColor = "#EAF3FA"; 
								  	} else if ($("upload_internal_iframe_"+inputField.id).contentWindow) {
									    // For IE5.5 and IE6
									    $("upload_internal_iframe_"+inputField.id).contentWindow.document.body.style.backgroundColor = "#EAF3FA";
								    }
								}
									
							}
						}
					);
				if (stopPublish){
					$("flutter-publish-error-message").style.display = "";
					Event.stop(event);
					return false;
				}
				
				return true;
			}

			Event.observe(window, 'load', function() {
				Event.observe('post', 'submit', checkForm);
			});
			
			// -------------
			// Edit Photo functions
			
			function setCookie(c_name,value,expiredays)
			{
				var exdate=new Date();
				exdate.setDate(exdate.getDate()+expiredays);
				document.cookie=c_name+ "=" +escape(value)+
				((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
			}
			function prepareUpdatePhoto(inputName){	
				document.getElementById(inputName+'_dorename').value = '1';
				return true;
			}	
			function exchangeValues(e, id)
			{
				//document.getElementById(document.getElementById('parent_text_'+id.substring(10)).value).value = e;
				//document.getElementById(document.getElementById('hidImgValue'+id.substring(10)).value).value = e;
			}
			
			// -------------
			// Date RCCPW_WritePostPage::Functions

			var dp_cal = new Array(); // declare the calendars as global variables
			
			function pickDate(inputName){
				if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]) document.getElementById('date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat('Y-m-d');
			}
			
			function InitializeDateObject(inputName, dateFormat, currentValue){
				if (!Object.isElement($('display_date_field_' + inputName))) return;
				
				dp_cal[inputName]  = new Epoch('dp_cal_'+inputName,'popup',document.getElementById('display_date_field_'+inputName), false, 'pickDate', inputName, dateFormat);
				
				var d = new Date();
				
				if (currentValue.length > 0){
					d.setYear(parseInt(currentValue.substr(0,4),10));
					d.setMonth(parseInt(currentValue.substr(5,2),10)-1);
					d.setDate(parseInt(currentValue.substr(8,2),10));
				}
				d.selected = true;
				d.canSelect = true;
				var tmpDatesArray = new Array(d);
				dp_cal[inputName].selectDates(tmpDatesArray, true, true, true);
				if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]) 
					document.getElementById('display_date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat(dateFormat);
			}	

			function today_date(inputName, dateFormat){
				var d = new Date();
				var tmpDatesArray = new Array(d);
				dp_cal[inputName].selectDates(tmpDatesArray, true, true, true);
				if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]){ 
					document.getElementById('display_date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat(dateFormat);
					document.getElementById('date_field_' + inputName).value = dp_cal[inputName].selectedDates[0].dateFormat('Y-m-d');
				}
			}
			

		</script>

		<?php 
        //change title
        global $post, $title;
        if ($post->ID == 0) {
            $blu = RCCWP_CustomWritePanel::Get($CUSTOM_WRITE_PANEL->id);
            if ($post->post_type == "post") {
                $name_title = "Post";
            } else {
                $name_title = "Page";
            }
            $title = "Write " . $name_title . " >> " . $blu->name;
        } else {
            $blu = RCCWP_CustomWritePanel::Get($CUSTOM_WRITE_PANEL->id);
            if ($post->post_type == "post") {
                $name_title = "Post";
            } else {
                $name_title = "Page";
            }
            $title = "Edit " . $name_title . " >> " . $blu->name;
        }
        // Show/Hide Panel fields
        global $STANDARD_FIELDS;
        $standardFields = RCCWP_CustomWritePanel::GetStandardFields($CUSTOM_WRITE_PANEL->id);
        $hideCssIds = array();
        foreach ($STANDARD_FIELDS as $standardField) {
            if (!in_array($standardField->id, $standardFields)) {
                foreach ($standardField->cssId as $cssID) {
                    array_push($hideCssIds, $cssID);
                }
            }
        }
        if (empty($hideCssIds)) {
            return;
        }
        array_walk($hideCssIds, create_function('&$item1, $key', '$item1 = "#" . $item1;'));
        $hideCssIdString = implode(', ', $hideCssIds);
        ?>
		
		<style type="text/css">
			<?php 
        echo $hideCssIdString;
        ?>
 {display: none !important;}
		</style>
		
		<?php 
    }
    /**
     * View groups/fields of a write panel
     *
     */
    function View()
    {
        global $mf_domain;
        $customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
        $customWritePanel = RCCWP_CustomWritePanel::Get($customWritePanelId);
        $custom_groups = RCCWP_CustomWritePanel::GetCustomGroups($customWritePanelId);
        // get default group id
        foreach ($custom_groups as $group) {
            if ($group->name == '__default' && $group->panel_id == $customWritePanelId) {
                // traversal added extra condition to handle globals
                $customDefaultGroupId = $group->id;
                break;
            }
        }
        ?>

		<script type="text/javascript" language="javascript">
			function confirmBeforeDelete()
			{
				return confirm("<?php 
        _e('Are you sure you want to delete this custom Field?', $mf_domain);
        ?>
");
			}
			
			function confirmBeforeDeleteGroup()
			{
				return confirm("<?php 
        _e('Are you sure you want to delete this field group?\\n\\nNote: All fields that are part of this group will also be deleted!', $mf_domain);
        ?>
");
			}
		</script>
		<div class="wrap">

		<form action="<?php 
        echo RCCWP_ManagementPage::GetPanelPage() . "&mf_action=view-custom-write-panel";
        ?>
" method="post"  id="posts-filter" name="SelectWritePanel">
			<h2>
				<?php 
        echo $customWritePanel->name;
        ?>
				<span style="font-size:small">
					&nbsp; &nbsp;
					<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-write-panel', $customWritePanel->id);
        ?>
" ><?php 
        _e('Edit', $mf_domain);
        ?>
</a>|
					<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('delete-custom-write-panel', $customWritePanel->id);
        ?>
" onclick="return confirmBeforeDelete();"><?php 
        _e('Delete', $mf_domain);
        ?>
</a>|
					<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('export-custom-write-panel', $customWritePanel->id);
        ?>
" ><?php 
        _e('Export', $mf_domain);
        ?>
</a>
				</span>
			</h2>
			<p id="post-search" style="margin-top:6px">
				<strong>
					<?php 
        _e('Choose a Write Panel', $mf_domain);
        ?>
					<select name="custom-write-panel-id" style="margin-top:-2px" onchange="document.SelectWritePanel.submit()">
						<?php 
        foreach ($customWritePanels as $panel) {
            ?>
							<option <?php 
            echo $customWritePanelId == $panel->id ? ' selected ' : '';
            ?>
 value="<?php 
            echo $panel->id;
            ?>
"><?php 
            echo $panel->name;
            ?>
</option>
						<?php 
        }
        ?>
					</select>
				</strong>
				<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-group');
        ?>
" class="button-secondary">+ <?php 
        _e('Create a Group', $mf_domain);
        ?>
</a>
				<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . "&custom-group-id={$customDefaultGroupId}";
        ?>
" class="button-secondary">+ <?php 
        _e('Create a Field', $mf_domain);
        ?>
</a>
			</p>
		</form>
    <br class="clear"/>
    <?php 
        if (isset($_GET['save_order']) && $_GET['saved_order'] == "true") {
            ?>
      <div id="message" class="updated">
        Saved Order.
      </div>
    <?php 
        }
        ?>

 		<?php 
        foreach ($custom_groups as $group) {
            ?>
 
      <?php 
            if ($group->name == "__default") {
                ?>
        <h2>Magic Fields</h2>
      <?php 
            } else {
                ?>
 
       <h2 class="mf-no-default-group"><a href="<?php 
                echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-group') . "&custom-group-id={$group->id}";
                ?>
"><?php 
                echo $group->name;
                ?>
</a></strong>
          <span class="mf_add_group_field">(<a href="<?php 
                echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . "&custom-group-id={$group->id}";
                ?>
"><?php 
                _e('create field', $mf_domain);
                ?>
</a>)</span>
          <span class="mf_delete_group_field">(<a onclick="return confirmBeforeDeleteGroup();" href="<?php 
                echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('delete-custom-group') . "&custom-group-id={$group->id}";
                ?>
"><?php 
                _e('delete', $mf_domain);
                ?>
</a>)</span>

       </h2>
      <?php 
            }
            ?>
		<form action="<?php 
            echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('save-fields-order');
            ?>
" method="post"  id="posts-filter" name="ImportWritePanelForm" enctype="multipart/form-data">
  	<table cellpadding="3" cellspacing="3" width="100%" class="widefat">
  		<thead>
	  		<tr>
          <th width="5%"></th>
	  			<th width="20%" scope="col"><?php 
            _e('Label', $mf_domain);
            ?>
</th>
	  			<th width="35%" scope="col"><?php 
            _e('Name (Order)', $mf_domain);
            ?>
</th>
	  			<th width="20%" scope="col"><?php 
            _e('Type', $mf_domain);
            ?>
</th>
					<th width="20%" scope="col"><?php 
            _e('Actions', $mf_domain);
            ?>
</th>
				</tr>
  		</thead>
  		<tbody class="sortable">
      <?php 
            RCCWP_CustomWritePanelPage::DisplayGroupFields($group->id);
            ?>
  		</tbody>
  		</table>
	    <?php 
        }
        ?>
		</div>
		<br />
    <input type="submit" name="save_submit" value="<?php 
        _e('Save Order', $mf_domain);
        ?>
" id="save_order" />
    </form>
		<?php 
    }
Пример #15
0
 /**
  * Get a custom write panel by reading $_REQUEST['custom-write-panel-id'] or the
  * To see whether $_GET['post'] has a custom write panel associated to it.
  *
  * @return Custom Write Panel as an object, returns null if there is no write panels.
  */
 public static function GetCustomWritePanel()
 {
     global $wpdb;
     if (isset($_GET['post'])) {
         $customWritePanelId = get_post_meta((int) $_GET['post'], RC_CWP_POST_WRITE_PANEL_ID_META_KEY, true);
         if (empty($customWritePanelId)) {
             if (array_key_exists('custom-write-panel-id', $_REQUEST)) {
                 $customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
             } else {
                 $customWritePanelId = 0;
             }
         }
     } else {
         if (function_exists('icl_t') && isset($_GET['trid'])) {
             $t_name = $wpdb->prefix . "icl_translations";
             $sql = $wpdb->prepare("SELECT element_id FROM {$t_name} WHERE element_type='post' AND trid = %d", array($_GET['trid']));
             $element_id = $wpdb->get_col($sql);
             $customWritePanelId = get_post_meta((int) $element_id, RC_CWP_POST_WRITE_PANEL_ID_META_KEY, true);
             if (empty($customWritePanelId)) {
                 if (array_key_exists('custom-write-panel-id', $_REQUEST)) {
                     $customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
                 } else {
                     $customWritePanelId = 0;
                 }
             }
         } else {
             if (isset($_REQUEST['custom-write-panel-id'])) {
                 $customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
             }
         }
     }
     $customWritePanel = FALSE;
     if (isset($customWritePanelId)) {
         include_once 'RCCWP_Application.php';
         $customWritePanel = RCCWP_CustomWritePanel::Get($customWritePanelId);
     }
     return $customWritePanel;
 }
Пример #16
0
 /**
  * Get a custom write panel by reading $_REQUEST['custom-write-panel-id'] or the
  * To see whether $_GET['post'] has a custom write panel associated to it.
  *
  * @return Custom Write Panel as an object, returns null if there is no write panels.
  */
 function GetCustomWritePanel()
 {
     if (isset($_GET['post'])) {
         $customWritePanelId = get_post_meta((int) $_GET['post'], RC_CWP_POST_WRITE_PANEL_ID_META_KEY, true);
         if (empty($customWritePanelId)) {
             $customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
         }
     } else {
         if (isset($_REQUEST['custom-write-panel-id'])) {
             $customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
         }
     }
     if (isset($customWritePanelId)) {
         include_once 'RCCWP_Application.php';
         $customWritePanel = RCCWP_CustomWritePanel::Get($customWritePanelId);
     }
     return $customWritePanel;
 }