Ejemplo n.º 1
0
 /**
  *  Fill the new column Panel name
  *	This is executed if the "condense menu" option is active
  */
 function ColumnWritePanelData($column_name)
 {
     global $post;
     if ($column_name == "WritePanel") {
         $name = RCCWP_CustomWritePanel::GetWritePanelName($post->ID);
         if (!$name) {
             echo " - ";
         } else {
             echo $name;
         }
     }
 }
function install()
{
    require_once dirname(__FILE__) . '/../magic-fields/RCCWP_CustomWritePanel.php';
    // Create default write pages
    $existing_write_panels = array();
    foreach (RCCWP_CustomWritePanel::GetCustomWritePanels() as $panel) {
        array_push($existing_write_panels, $panel->name);
    }
    $panels_dir_name = dirname(__FILE__) . '/panels/';
    $panels_dir = opendir($panels_dir_name);
    $panels = array();
    while (false !== ($panel_file = readdir($panels_dir))) {
        $panel_name = basename($panel_file, ".pnl");
        if (!is_dir($panel_file) && $panel_name && $panel_name != $panel_file && !in_array($panel_name, $existing_write_panels)) {
            // If this file isn't a directory, ends with .pnl, and isn't already an existing panel, create and store it for import.
            // $panel_id = RCCWP_CustomWritePanel::Create($panel_name, '', array(), array(), 1, "post", false);
            RCCWP_CustomWritePanel::Import($panels_dir_name . $panel_file);
            $panels[$panel_name] = $panel_file;
        }
    }
    foreach ($panels as $panel_name => $panel_file) {
        RCCWP_CustomWritePanel::Import($panels_dir_name . $panel_file, $panel_name, true);
    }
}
Ejemplo n.º 3
0
    function Edit()
    {
        global $FIELD_TYPES;
        global $mf_domain;
        $custom_field = RCCWP_CustomField::Get((int) $_GET['custom-field-id']);
        $customGroupID = $custom_field->group_id;
        if (in_array($custom_field->type, array('Image'))) {
            $cssVlaue = $custom_field->CSS;
        }
        ?>
	  	
  		<div class="wrap">
  		<h2><?php 
        _e('Edit Custom Field', $mf_domain);
        ?>
 - <?php 
        echo $custom_field->description;
        ?>
</h2>
  		
  		<br class="clear" />
  		<?php 
        if (isset($_GET['err_msg'])) {
            switch ($_GET['err_msg']) {
                case -1:
                    ?>
				<div class="error"><p> <?php 
                    _e('A field with the same name already exists in this write panel. Please choose a different name.', $mf_domain);
                    ?>
</p></div>
				<?php 
            }
        }
        ?>
  		
	  	
  		<form action="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('submit-edit-custom-field') . "&custom-group-id={$customGroupID}";
        ?>
" method="post" id="edit-custom-field-form"  onsubmit="return checkEmpty();">
  		<input type="hidden" name="custom-field-id" value="<?php 
        echo $custom_field->id;
        ?>
">
		
		
		<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
		<tbody>
		<tr valign="top">
			<th scope="row"><?php 
        _e('Name', $mf_domain);
        ?>
:</th>
			<td><input name="custom-field-name" id="custom-field-name" size="40" type="text" value="<?php 
        echo htmlspecialchars($custom_field->name);
        ?>
" /></td>
		</tr>
		<tr valign="top">
			<th scope="row"><?php 
        _e('Label', $mf_domain);
        ?>
:</th>
			<td><input name="custom-field-description" id="custom-field-description" size="40" type="text" value="<?php 
        echo htmlspecialchars($custom_field->description);
        ?>
" /></td>
		</tr>
		<tr valign="top">
			<th scope="row"><?php 
        _e('Help text', $mf_domain);
        ?>
:</th>
			<td><input name="custom-field-helptext" id="custom-field-helptext" size="40" type="text" value="<?php 
        echo htmlspecialchars($custom_field->help_text);
        ?>
" /><br/><small><?php 
        _e('If set, this will be displayed in a tooltip next to the field label', $mf_domain);
        ?>
</small></td>
		</tr>
		<tr valign="top">
			<th scope="row"><?php 
        _e('Can be duplicated', $mf_domain);
        ?>
:</th>
			<td><input name="custom-field-duplicate" id="custom-field-duplicate" type="checkbox" value="1" <?php 
        echo $custom_field->duplicate == 0 ? "" : "checked";
        ?>
/></td>
		</tr>
		<tr valign="top">
			<th scope="row"><?php 
        _e('Order', $mf_domain);
        ?>
:</th>
			<td>
				<input name="custom-field-order" id="custom-field-order" size="2" type="text" value="<?php 
        echo $custom_field->display_order;
        ?>
" />
			</td>	
		</tr>
		
		<?php 
        if (in_array($custom_field->type_id, array($FIELD_TYPES['textbox'], $FIELD_TYPES['multiline_textbox'], $FIELD_TYPES['checkbox'], $FIELD_TYPES['checkbox_list'], $FIELD_TYPES['radiobutton_list'], $FIELD_TYPES['dropdown_list'], $FIELD_TYPES['listbox'], $FIELD_TYPES['file'], $FIELD_TYPES['image'], $FIELD_TYPES['audio'], $FIELD_TYPES['related_type']))) {
            ?>
		<tr valign="top">
			<th scope="row"><?php 
            _e('Required', $mf_domain);
            ?>
:</th>
			<td>
				<select name="custom-field-required" id="custom-field-required">
					<option value="0" <?php 
            echo $custom_field->required_field == 0 ? 'selected="selected"' : '';
            ?>
 ><?php 
            _e('Not Required - can be empty', $mf_domain);
            ?>
</option>
					<option value="1" <?php 
            echo $custom_field->required_field == 1 ? 'selected="selected"' : '';
            ?>
 ><?php 
            _e('Required - can not be empty', $mf_domain);
            ?>
</option>
				</select>
			</td>	
		</tr>
		
		<?php 
        }
        ?>
		<?php 
        if (in_array($custom_field->type, array('Textbox', 'Listbox'))) {
            ?>
		<tr valign="top">
			<th scope="row"><?php 
            _e('Size', $mf_domain);
            ?>
:</th>
			<td><input type="text" name="custom-field-size" id="custom-field-size" size="2" value="<?php 
            echo $custom_field->properties['size'];
            ?>
" /></td>
		</tr>	
		<?php 
        }
        ?>

		<?php 
        if (in_array($custom_field->type, array('Multiline Textbox'))) {
            ?>
		<tr valign="top">
			<th scope="row"><?php 
            _e('Height', $mf_domain);
            ?>
:</th>
			<td><input type="text" name="custom-field-height" id="custom-field-height" size="2" value="<?php 
            echo $custom_field->properties['height'];
            ?>
" /></td>
		</tr>	
		<tr valign="top">
			<th scope="row"><?php 
            _e('Width', $mf_domain);
            ?>
:</th>
			<td><input type="text" name="custom-field-width" id="custom-field-width" size="2" value="<?php 
            echo $custom_field->properties['width'];
            ?>
" /></td>
		</tr>	
		<?php 
        }
        ?>

		<?php 
        if (in_array($custom_field->type, array('Date'))) {
            ?>
		<tr valign="top">
			<th scope="row"><?php 
            _e('Format', $mf_domain);
            ?>
:</th>
			<td>
				<select name="custom-field-date-format" id="custom-field-date-format">
					<option value="m/d/Y" <?php 
            if ($custom_field->properties['format'] == "m/d/Y") {
                echo " selected ";
            }
            ?>
>4/20/2008</option>
					<option value="l, F d, Y" <?php 
            if ($custom_field->properties['format'] == "l, F d, Y") {
                echo " selected ";
            }
            ?>
>Sunday, April 20, 2008</option>
					<option value="F d, Y" <?php 
            if ($custom_field->properties['format'] == "F d, Y") {
                echo " selected ";
            }
            ?>
>April 20, 2008</option>
					<option value="m/d/y" <?php 
            if ($custom_field->properties['format'] == "m/d/y") {
                echo " selected ";
            }
            ?>
>4/20/08</option>
					<option value="Y-d-m" <?php 
            if ($custom_field->properties['format'] == "Y-m-d") {
                echo " selected ";
            }
            ?>
>2008-04-20</option>
					<option value="d-M-y" <?php 
            if ($custom_field->properties['format'] == "d-M-y") {
                echo " selected ";
            }
            ?>
>20-Apr-08</option>
					<option value="m.d.Y" <?php 
            if ($custom_field->properties['format'] == "m.d.Y") {
                echo " selected ";
            }
            ?>
>4.20.2008</option>
					<option value="m.d.y" <?php 
            if ($custom_field->properties['format'] == "m.d.y") {
                echo " selected ";
            }
            ?>
>4.20.08</option>
				</select>
			</td>
		</tr>	
		<?php 
        }
        ?>
		
		<?php 
        if (in_array($custom_field->type, array('Slider'))) {
            ?>
	
		<tr valign="top">
			<th scope="row"><?php 
            echo _e('Value min', $mf_domain);
            ?>
:</th>
			<td><input type="text" name="custom-field-slider-min" id="custom-field-slider-min" size="2" value="<?php 
            echo $custom_field->properties['min'];
            ?>
" /></td>
		</tr>
		<tr valign="top">
			<th scope="row"><?php 
            echo _e('Value max', $mf_domain);
            ?>
:</th>
			<td><input type="text" name="custom-field-slider-max" id="custom-field-slider-max" size="2" value="<?php 
            echo $custom_field->properties['max'];
            ?>
" /></td>
		</tr>		
		<tr valign="top">
			<th scope="row"><?php 
            echo _e('Stepping', $mf_domain);
            ?>
:</th>
			<td><input type="text" name="custom-field-slider-step" id="custom-field-slider-step" size="2" value="<?php 
            echo $custom_field->properties['step'];
            ?>
" /></td>
		</tr>
		<?php 
        }
        ?>

		<?php 
        //eeble
        if (in_array($custom_field->type, array('Related Type'))) {
            $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
            ?>
		<tr valign="top">
			<th scope="row"><?php 
            _e('Related Type Panel', $mf_domain);
            ?>
:</th>
			<td><select name="custom-field-related-type-panel-id" id="custom-field-related-type-panel-id">
				<option value="-4" <?php 
            if ($custom_field->properties['panel_id'] == -4) {
                echo 'selected';
            }
            ?>
 >All Post</option>
				<option value="-3" <?php 
            if ($custom_field->properties['panel_id'] == -3) {
                echo 'selected';
            }
            ?>
 >All Page</option>
				<option value="-2" <?php 
            if ($custom_field->properties['panel_id'] == -2) {
                echo 'selected';
            }
            ?>
 >All Post with Write Panel</option>
				<option value="-1" <?php 
            if ($custom_field->properties['panel_id'] == -1) {
                echo 'selected';
            }
            ?>
 >All Page with Write Panel</option>
				<?php 
            foreach ($customWritePanels as $panel) {
                ?>
					<option value="<?php 
                echo $panel->id;
                ?>
" <?php 
                if ($custom_field->properties['panel_id'] == $panel->id) {
                    echo 'selected';
                }
                ?>
><?php 
                echo $panel->name;
                ?>
</option>
				<?php 
            }
            ?>
			</select></td>
		</tr>
		<?php 
        }
        ?>

		<?php 
        if ($custom_field->has_options == "true") {
            $options = implode("\n", (array) $custom_field->options);
            ?>
		<tr valign="top">
			<th scope="row"><?php 
            _e('Options', $mf_domain);
            ?>
:</th>
			<td>
				<textarea name="custom-field-options" id="custom-field-options" rows="2" cols="38"><?php 
            echo htmlspecialchars($options);
            ?>
</textarea><br />
				<em><?php 
            _e('Separate each option with a newline.', $mf_domain);
            ?>
</em>
			</td>
		</tr>
		<tr valign="top">
			<th scope="row"><?php 
            _e('Default Value', $mf_domain);
            ?>
:</th>
			<td>
				<?php 
            $default_value = implode("\n", (array) $custom_field->default_value);
            if ($custom_field->allow_multiple_values == "true") {
                ?>
				<textarea name="custom-field-default-value" id="custom-field-default-value" rows="2" cols="38"><?php 
                echo htmlspecialchars($default_value);
                ?>
</textarea><br />
				<em><?php 
                _e('Separate each value with a newline.', $mf_domain);
                ?>
</em>
				<?php 
            } else {
                ?>
				<input type="text" name="custom-field-default-value" id="custom-field-default-value" size="25" value="<?php 
                echo htmlspecialchars($default_value);
                ?>
" />
				<?php 
            }
            ?>
			</td>
		</tr>
		<?php 
        }
        ?>
		<tr valign="top">
			<th scope="row"><?php 
        _e('Type', $mf_domain);
        ?>
:</th>
			<td>

				<!-- START :: Javascript for Image/Photo' Css Class -->
				<script type="text/javascript" language="javascript">
					submitForm = false;
					function fun(name)
					{
						if(name == "Image")
						{
							document.getElementById('divCSS').style.display = 'inline';
							document.getElementById('divLbl').style.display = 'inline';
							document.getElementById('lblHeight').style.display = 'inline';
							document.getElementById('txtHeight').style.display = 'inline';
							document.getElementById('lblWidth').style.display = 'inline';
							document.getElementById('txtWidth').style.display = 'inline';
						}
						else
						{
							document.getElementById('divCSS').style.display = 'none';
							document.getElementById('divLbl').style.display = 'none';
							document.getElementById('lblHeight').style.display = 'none';
							document.getElementById('txtHeight').style.display = 'none';
							document.getElementById('lblWidth').style.display = 'none';
							document.getElementById('txtWidth').style.display = 'none';
						}
					}
					function checkEmpty()
					{
						if (submitForm && (document.getElementById('custom-field-name').value == "" || document.getElementById('custom-field-description').value == "")){
							alert("<?php 
        _e('Please fill in the name and the label of the field', $mf_domain);
        ?>
");	
							return false;
						}
						return true;
						
					}
				</script>
				<!-- END :: Javascript for Image/Photo' Css Class -->

				<?php 
        $field_types = RCCWP_CustomField::GetCustomFieldTypes();
        foreach ($field_types as $field) {
            $checked = $field->name == $custom_field->type ? 'checked="checked"' : '';
            ?>
					<label><input name="custom-field-type" value="<?php 
            echo $field->id;
            ?>
" type="radio" <?php 
            echo $checked;
            ?>
 onclick='fun("<?php 
            echo $field->name;
            ?>
");'/>
					<?php 
            echo $field->name;
            ?>
</label><br />
				<?php 
        }
        ?>
			</td>
		</tr>
		<!-- START :: For Image/Photo' Css -->
		<?php 
        $isDisplay = $custom_field->type == "Image" ? 'display:inline;' : 'display:none;';
        $size = explode("&", $custom_field->properties['params']);
        if (isset($size[3])) {
            $c = $size[3];
        }
        if (substr($size[1], 0, 1) == "h") {
            $h = substr($size[1], 2);
        } elseif (substr($size[1], 0, 1) == "w") {
            $w = substr($size[1], 2);
        }
        if (substr($size[2], 0, 1) == "h") {
            $h = substr($size[2], 2);
        } elseif (substr($size[2], 0, 1) == "w") {
            $w = substr($size[2], 2);
        }
        $cssVlaue = $custom_field->CSS;
        ?>
		<tr valign="top">
			<th scope="row"><span id="lblHeight" style="<?php 
        echo $isDisplay;
        ?>
"><?php 
        _e('Max Height', $mf_domain);
        ?>
:</span></th>
			<td><span id="txtHeight" style="<?php 
        echo $isDisplay;
        ?>
"><input type="text" name="custom-field-photo-height" id="custom-field-photo-height" size="3" value="<?php 
        echo $h;
        ?>
" /></span></td>
		</tr>	
		<tr valign="top">
			<th scope="row"><span id="lblWidth" style="<?php 
        echo $isDisplay;
        ?>
"><?php 
        _e('Max Width', $mf_domain);
        ?>
:</span></th>
			<td><span id="txtWidth" style="<?php 
        echo $isDisplay;
        ?>
"><input type="text" name="custom-field-photo-width" id="custom-field-photo-width" size="3" value="<?php 
        echo $w;
        ?>
" /></span></td>
		</tr>
		<tr valign="top">
			<th scope="row"><span id="lblWidth" style="<?php 
        echo $isDisplay;
        ?>
"><?php 
        _e('Custom', $mf_domain);
        ?>
:</span></th>
			<td><span id="txtWidth" style="<?php 
        echo $isDisplay;
        ?>
"><input type="text" name="custom-field-custom-params" id="custom-field-custom-params" value="<?php 
        echo $c;
        ?>
" /></span>
		
		</td>
		</tr>
		
		<tr valign="top">
			<th scope="row"><div id="divLbl" style="<?php 
        echo $isDisplay;
        ?>
"><?php 
        _e('Css Class', $mf_domain);
        ?>
:</div></th>
			<td>
				<div id="divCSS" style="<?php 
        echo $isDisplay;
        ?>
">
				<input name="custom-field-css" id="custom-field-css" size="40" type="text" value="<?php 
        echo $cssVlaue;
        ?>
" />
				</div>
			</td>
		</tr>

		<!-- END :: For Image/Photo' Css -->		
		</tbody>
		</table>
		
		<input name="mf_action" type="hidden" value="submit-edit-custom-field" />
  		<p class="submit" >
  			<a style="color:black" href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-create-custom-field') . "&custom-group-id={$customGroupID}";
        ?>
" class="button"><?php 
        _e('Cancel', $mf_domain);
        ?>
</a> 
  			<input type="submit" id="submit-edit-custom-field" value="<?php 
        _e('Update', $mf_domain);
        ?>
" onclick="submitForm=true;" />
  		</p>
	  	
  		</form>
	  	
  		</div>
	  	
  		<?php 
    }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
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'];
             }
         }
     }
 }
    function SetOptions()
    {
        global $mf_domain;
        $current_field = RCCWP_CustomField::GetCustomFieldTypes($_POST['custom-field-type']);
        $customGroupID = $_REQUEST['custom-group-id'];
        ?>
		
		<div class="wrap">
		
		<h2><?php 
        _e("Create Custom Field", $mf_domain);
        ?>
</h2>
		
		<form action="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('finish-create-custom-field');
        ?>
" method="post" id="continue-create-new-field-form">
		
		<input type="hidden" name="custom-group-id" 	value="<?php 
        echo $_POST['custom-group-id'];
        ?>
" />
		<input type="hidden" name="custom-field-name" 		value="<?php 
        echo htmlspecialchars($_POST['custom-field-name']);
        ?>
" />
		<input type="hidden" name="custom-field-description" 	value="<?php 
        echo htmlspecialchars($_POST['custom-field-description']);
        ?>
" />
		<input type="hidden" name="custom-field-duplicate" value="<?php 
        echo htmlspecialchars($_POST['custom-field-duplicate']);
        ?>
" />
		<input type="hidden" name="custom-field-order" 		value="<?php 
        echo $_POST['custom-field-order'];
        ?>
" />
		<input type="hidden" name="custom-field-required" 		value="<?php 
        echo $_POST['custom-field-required'];
        ?>
" />
		<input type="hidden" name="custom-field-type" 		value="<?php 
        echo $_POST['custom-field-type'];
        ?>
" />
		<input type="hidden" name="custom-field-helptext" 		value="<?php 
        echo $_POST['custom-field-helptext'];
        ?>
" />

		<!-- Hidden value for Image/Photo' Css Class-->
		<input type="hidden" name="custom-field-css" value="<?php 
        echo $_POST['custom-field-css'];
        ?>
" />

		<h3><?php 
        echo $current_field->name;
        ?>
</h3>
		
		<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
		<tbody>
		
		<?php 
        if ($current_field->has_properties == "true") {
            ?>
		
		<?php 
            if (in_array($current_field->name, array('Textbox', 'Listbox'))) {
                if ($current_field->name == 'Textbox') {
                    $size = 25;
                } else {
                    if ($current_field->name == 'Listbox') {
                        $size = 3;
                    }
                }
                ?>
		<tr valign="top">
			<th scope="row"><?php 
                _e('Size', $mf_domain);
                ?>
:</th>
			<td><input type="text" name="custom-field-size" id="custom-field-size" size="2" value="<?php 
                echo $size;
                ?>
" /></td>
		</tr>	
		<?php 
            }
            ?>
		
		<?php 
            if (in_array($current_field->name, array('Multiline Textbox'))) {
                $height = 3;
                $width = 23;
                ?>
		<tr valign="top">
			<th scope="row"><?php 
                _e('Height', $mf_domain);
                ?>
:</th>
			<td><input type="text" name="custom-field-height" id="custom-field-height" size="2" value="<?php 
                echo $height;
                ?>
" /></td>
		</tr>	
		<tr valign="top">
			<th scope="row"><?php 
                _e('Width', $mf_domain);
                ?>
:</th>
			<td><input type="text" name="custom-field-width" id="custom-field-width" size="2" value="<?php 
                echo $width;
                ?>
" /></td>
		</tr>	
		<?php 
            }
            ?>
		
		<?php 
            if (in_array($current_field->name, array('Slider'))) {
                $min_val = 0;
                $max_val = 10;
                $step = 1;
                ?>
		<tr valign="top">
			<th scope="row"><?php 
                _e('Value min', $mf_domain);
                ?>
:</th>
			<td><input type="text" name="custom-field-slider-min" id="custom-field-slider-min" size="2" value="<?php 
                echo $min_val;
                ?>
" /></td>
		</tr>
		<tr valign="top">
			<th scope="row"><?php 
                _e('Value max', $mf_domain);
                ?>
:</th>
			<td><input type="text" name="custom-field-slider-max" id="custom-field-slider-max" size="2" value="<?php 
                echo $max_val;
                ?>
" /></td>
		</tr>		
		<tr valign="top">
			<th scope="row"><?php 
                _e('Stepping', $mf_domain);
                ?>
:</th>
			<td><input type="text" name="custom-field-slider-step" id="custom-field-slider-step" size="2" value="<?php 
                echo $step;
                ?>
" /></td>
		</tr>
		<?php 
            }
            ?>
		
		<?php 
            //eeble
            if (in_array($current_field->name, array('Related Type'))) {
                $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
                ?>
		<tr valign="top">
			<th scope="row"><?php 
                _e('Related Type Panel', $mf_domain);
                ?>
:</th>
			<td><select name="custom-field-related-type-panel-id" id="custom-field-related-type-panel-id">
				<option value="-4">All Post</option>
				<option value="-3">All Page</option>
				<option value="-2">All Post with Write Panel</option>
				<option value="-1">All Page with Write Panel</option>
				<?php 
                foreach ($customWritePanels as $panel) {
                    ?>
					<option value="<?php 
                    echo $panel->id;
                    ?>
"><?php 
                    echo $panel->name;
                    ?>
</option>
				<?php 
                }
                ?>
			</select></td>
		</tr>
		<?php 
            }
            ?>

				
		<?php 
        }
        // has_properties
        ?>
		
		<?php 
        if ($current_field->has_options == "true") {
            ?>
		
		<tr valign="top">
			<th scope="row"><?php 
            _e('Options', $mf_domain);
            ?>
:</th>
			<td>
				<textarea name="custom-field-options" id="custom-field-options" rows="2" cols="38"></textarea><br />
				<em><?php 
            _e('Separate each option with a newline.', $mf_domain);
            ?>
</em>
			</td>
		</tr>	
		<tr valign="top">
			<th scope="row"><?php 
            _e('Default Value', $mf_domain);
            ?>
:</th>
			<td>
				<?php 
            if ($current_field->allow_multiple_values == "true") {
                ?>
				<textarea name="custom-field-default-value" id="custom-field-default-value" rows="2" cols="38"></textarea><br />
				<em><?php 
                _e('Separate each value with a newline.', $mf_domain);
                ?>
</em>
				<?php 
            } else {
                ?>
				
				<input type="text" name="custom-field-default-value" id="custom-field-default-value" size="25" />
				<?php 
            }
            ?>
			</td>
		</tr>
		<?php 
        }
        ?>


		<?php 
        if ($current_field->has_properties && $current_field->name == 'Image') {
            ?>
		<tr valign="top">
			<th scope="row"><?php 
            _e('Options', $mf_domain);
            ?>
:</th>
			<td>
				<?php 
            _e('Max Height', $mf_domain);
            ?>
: <input type="text" name="custom-field-photo-height" id="custom-field-photo-height"/>
				<?php 
            _e('Max Width', $mf_domain);
            ?>
: <input type="text" name="custom-field-photo-width" id="custom-field-photo-width" />
				<?php 
            _e('Custom', $mf_domain);
            ?>
: <input type="text" name="custom-field-custom-params" id="custom-field-custom-params" />
				<div style="color:blue;text-decoration:underline;"
					onclick="div=document.getElementById('params');div.style.display='';"
					>
					<?php 
            _e('Custom Options List', $mf_domain);
            ?>
				</div>
				<div id="params"
					style="display:none;"
					onclick="this.style.display='none';">
					<pre><?php 
            echo param_list();
            ?>
</pre>
				</div>
			</td>
		</tr>
		<?php 
        }
        ?>

		<!-- Date Custom Field -->
		<?php 
        if ($current_field->has_properties && $current_field->name == 'Date') {
            ?>
		<tr valign="top">
			<th scope="row"><?php 
            _e('Options', $mf_domain);
            ?>
:</th>
			<td>
			<?php 
            _e('Format', $mf_domain);
            ?>
:	<select name="custom-field-date-format" id="custom-field-date-format">
					<option value="m/d/Y">4/20/2008</option>
					<option value="l, F d, Y">Sunday, April 20, 2008</option>
					<option value="F d, Y">April 20, 2008</option>
					<option value="m/d/y">4/20/08</option>
					<option value="Y-m-d">2008-04-20</option>
					<option value="d-M-y">20-Apr-08</option>
					<option value="m.d.Y">4.20.2008</option>
					<option value="m.d.y">4.20.08</option>
				</select>
			</td>
		</tr>
		<?php 
        }
        ?>
		<!-- Date Custom Field -->

		</tbody>
		</table>
		
		<p class="submit" >
			<a style="color:black" href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-create-custom-field') . "&custom-group-id={$customGroupID}";
        ?>
" class="button"><?php 
        _e('Cancel', $mf_domain);
        ?>
</a> 
			<input type="submit" id="finish-create-custom-field" value="<?php 
        _e('Finish', $mf_domain);
        ?>
" />
		</p>
			
		</form>
		
		</div>
		
		<?php 
    }
Ejemplo n.º 8
0
    /**
     *  This function is executed every time to something related with the Magic Fields happen
     *  this function update,delete,create a customfield,writepanel,group.
     */
    function Main()
    {
        require_once 'RC_Format.php';
        global $CUSTOM_WRITE_PANEL, $wp_version;
        if (isset($_POST['edit-with-no-custom-write-panel'])) {
            $type = RCCWP_Post::GetCustomWritePanel();
            if (is_object($type)) {
                $ptype = $type->type;
            } else {
                $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post';
            }
            wp_redirect($ptype . '.php?action=edit&post=' . $_POST['post-id'] . '&no-custom-write-panel');
        } else {
            if (isset($_POST['edit-with-custom-write-panel']) && isset($_POST['custom-write-panel-id']) && (int) $_POST['custom-write-panel-id'] > 0) {
                if (substr($wp_version, 0, 3) >= 3.0) {
                    $ptype = 'post';
                } else {
                    $type = RCCWP_Post::GetCustomWritePanel();
                    if (is_object($type)) {
                        $ptype = $type->type;
                    } else {
                        $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post';
                    }
                }
                wp_redirect($ptype . '.php?action=edit&post=' . $_POST['post-id'] . '&custom-write-panel-id=' . $_POST['custom-write-panel-id']);
            }
        }
        if (empty($_REQUEST['mf_action'])) {
            $currentAction = "";
        } else {
            $currentAction = $_REQUEST['mf_action'];
        }
        switch ($currentAction) {
            // ------------ Write Panels
            case 'finish-create-custom-write-panel':
                include_once 'RCCWP_CustomWritePanel.php';
                $default_theme_page = NULL;
                if ($_POST['radPostPage'] == 'page') {
                    $default_theme_page = $_POST['page_template'];
                    $default_parent_page = $_POST['parent_id'];
                }
                $customWritePanelId = RCCWP_CustomWritePanel::Create($_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page, $default_parent_page, $_POST['custom-write-panel-expanded']);
                wp_redirect(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('view-custom-write-panel', $customWritePanelId));
                break;
            case 'submit-edit-custom-write-panel':
                include_once 'RCCWP_CustomWritePanel.php';
                $default_theme_page = $default_parent_page = NULL;
                if ($_POST['radPostPage'] == 'page') {
                    $default_theme_page = $_POST['page_template'];
                    $default_parent_page = $_POST['parent_id'];
                }
                $default = array('custom-write-panel-id' => '', 'custom-write-panel-name' => '', 'custom-write-panel-standard-fields' => '', 'custom-write-panel-categories' => '', 'custom-write-panel-order' => '', 'single' => '', 'theme_page' => '', 'parent_page' => '', 'expanded' => '');
                $_POST['theme_page'] = $default_theme_page;
                $_POST['parent_page'] = $default_parent_page;
                $save = array_merge($default, $_POST);
                RCCWP_CustomWritePanel::Update($save['custom-write-panel-id'], $save['custom-write-panel-name'], NULL, $save['custom-write-panel-standard-fields'], $save['custom-write-panel-categories'], $save['custom-write-panel-order'], FALSE, true, $save['single'], $save['theme_page'], $save['parent_page'], $save['custom-write-panel-expanded']);
                RCCWP_CustomWritePanel::AssignToRole($_POST['custom-write-panel-id'], 'administrator');
                break;
            case 'export-custom-write-panel':
                require_once 'RCCWP_CustomWritePanel.php';
                $panelID = $_REQUEST['custom-write-panel-id'];
                $writePanel = RCCWP_CustomWritePanel::Get($panelID);
                // send file in header
                header('Content-type: binary');
                header('Content-Disposition: attachment; filename="' . $writePanel->name . '.pnl"');
                print RCCWP_CustomWritePanel::Export($panelID);
                exit;
                break;
            case 'delete-custom-write-panel':
                include_once 'RCCWP_CustomWritePanel.php';
                RCCWP_CustomWritePanel::Delete($_GET['custom-write-panel-id']);
                break;
                // ------------ Groups
            // ------------ Groups
            case 'finish-create-custom-group':
                include_once 'RCCWP_CustomGroup.php';
                $default = array('custom-write-panel-id' => '', 'custom-group-name' => '', 'custom-group-duplicate' => '', 'custom-group-expanded' => '');
                $values = array_merge($default, $_POST);
                $customGroupId = RCCWP_CustomGroup::Create($values['custom-write-panel-id'], $values['custom-group-name'], $values['custom-group-duplicate'], $values['custom-group-expanded'], NULL);
                break;
            case 'delete-custom-group':
                include_once 'RCCWP_CustomGroup.php';
                $customGroup = RCCWP_CustomGroup::Get((int) $_REQUEST['custom-group-id']);
                RCCWP_CustomGroup::Delete($_GET['custom-group-id']);
                break;
            case 'unlink-write-panel':
                global $wpdb;
                $postId = (int) preg_replace('/post-/', '', $_REQUEST['post-id']);
                $dashboard = $_REQUEST['dashboard'];
                if ($postId) {
                    //only delete images and postmeta fields with write panels
                    if (count(get_post_meta($postId, RC_CWP_POST_WRITE_PANEL_ID_META_KEY))) {
                        $query = sprintf('SELECT wp_pm.meta_value 
						FROM %s mf_pm, %s mf_cf, %s wp_pm
						WHERE mf_pm.field_name = mf_cf.name AND mf_cf.type = 9 AND mf_pm.post_id = %d AND wp_pm.meta_id = mf_pm.id', MF_TABLE_POST_META, MF_TABLE_GROUP_FIELDS, $wpdb->postmeta, $postId);
                        $images = $wpdb->get_results($query);
                        foreach ($images as $image) {
                            if ($image->meta_value != '') {
                                $tmp = sprintf('%s%s', MF_FILES_PATH, $image->meta_value);
                                @unlink($tmp);
                            }
                        }
                        //delete all data of postmeta (WP and MF)
                        $query = sprintf('DELETE a,b from %s a INNER JOIN %s b WHERE a.meta_id = b.id AND a.post_id = %d', $wpdb->postmeta, MF_TABLE_POST_META, $postId);
                        $wpdb->query($query);
                    }
                    delete_post_meta($postId, RC_CWP_POST_WRITE_PANEL_ID_META_KEY);
                    wp_redirect($dashboard);
                    exit;
                }
                break;
            case 'submit-edit-custom-group':
                include_once 'RCCWP_CustomGroup.php';
                $default = array('custom-write-panel-id' => '', 'custom-group-name' => '', 'custom-group-duplicate' => '', 'custom-group-expanded' => '');
                $all = $_POST;
                $all['custom-group-id'] = $_REQUEST['custom-group-id'];
                $values = array_merge($default, $all);
                RCCWP_CustomGroup::Update($values['custom-group-id'], $values['custom-group-name'], $values['custom-group-duplicate'], $values['custom-group-expanded'], NULL);
                break;
                // ------------ Fields
            // ------------ Fields
            case 'copy-custom-field':
                include_once 'RCCWP_CustomField.php';
                $fieldToCopy = RCCWP_CustomField::Get($_REQUEST['custom-field-id']);
                if (RCCWP_Processor::CheckFieldName($fieldToCopy->name, $_REQUEST['custom-write-panel-id'])) {
                    $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                    wp_redirect($newURL);
                    exit;
                }
                RCCWP_CustomField::Create($_REQUEST['custom-group-id'], $fieldToCopy->name, $fieldToCopy->description, $fieldToCopy->display_order, $fieldToCopy->required_field, $fieldToCopy->type_id, $fieldToCopy->options, $fieldToCopy->default_value, $fieldToCopy->properties, $fieldToCopy->duplicate, $fieldToCopy->helptext);
            case 'continue-create-custom-field':
                if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                    $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                    wp_redirect($newURL);
                    exit;
                }
                break;
            case 'finish-create-custom-field':
                include_once 'RCCWP_CustomField.php';
                if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                    $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1';
                    wp_redirect($newURL);
                    exit;
                }
                $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_REQUEST['custom-field-type']);
                if ($current_field->has_properties) {
                    $custom_field_properties = array();
                    if (in_array($current_field->name, array('Textbox', 'Listbox'))) {
                        $custom_field_properties['size'] = $_POST['custom-field-size'];
                        if (isset($_POST['strict-max-length'])) {
                            $custom_field_properties['strict-max-length'] = $_POST['strict-max-length'];
                            if (empty($custom_field_properties['size'])) {
                                $custom_field_properties['size'] = 10;
                            }
                        }
                    } else {
                        if (in_array($current_field->name, array('Multiline Textbox'))) {
                            $custom_field_properties['height'] = $_POST['custom-field-height'];
                            $custom_field_properties['width'] = $_POST['custom-field-width'];
                            if (isset($_POST['hide-visual-editor'])) {
                                $custom_field_properties['hide-visual-editor'] = 1;
                            }
                            if (isset($_POST['strict-max-length'])) {
                                $custom_field_properties['hide-visual-editor'] = 1;
                                $custom_field_properties['strict-max-length'] = $_POST['strict-max-length'];
                                if (empty($custom_field_properties['height'])) {
                                    $custom_field_properties['height'] = 4;
                                }
                                if (empty($custom_field_properties['width'])) {
                                    $custom_field_properties['width'] = 64;
                                }
                            }
                        } else {
                            if (in_array($current_field->name, array('Date'))) {
                                $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                            } else {
                                if (in_array($current_field->name, array('Image', 'Image (Upload Media)'))) {
                                    $params = '';
                                    if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) {
                                        $params .= '&h=' . $_POST['custom-field-photo-height'];
                                    }
                                    if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) {
                                        $params .= '&w=' . $_POST['custom-field-photo-width'];
                                    }
                                    if ($_POST['custom-field-custom-params'] != '') {
                                        $params .= '&' . $_POST['custom-field-custom-params'];
                                    }
                                    if ($params) {
                                        $custom_field_properties['params'] = $params;
                                    }
                                } else {
                                    if (in_array($current_field->name, array('Date'))) {
                                        $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                                    } else {
                                        if (in_array($current_field->name, array('Slider'))) {
                                            $custom_field_properties['max'] = $_POST['custom-field-slider-max'];
                                            $custom_field_properties['min'] = $_POST['custom-field-slider-min'];
                                            $custom_field_properties['step'] = $_POST['custom-field-slider-step'];
                                        } else {
                                            if (in_array($current_field->name, array('Related Type'))) {
                                                $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id'];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $default = array('custom-group-id' => '', 'custom-field-name' => '', 'custom-field-description' => '', 'custom-field-order' => '', 'custom-field-required' => '', 'custom-field-type' => '', 'custom-field-options' => '', 'custom-field-default-value' => '', 'prop' => '', 'custom-field-duplicate' => '', 'custom-field-helptext' => '');
                $_POST['prop'] = $custom_field_properties;
                $save = array_merge($default, $_POST);
                RCCWP_CustomField::Create($save['custom-group-id'], $save['custom-field-name'], $save['custom-field-description'], $save['custom-field-order'], $save['custom-field-required'], $save['custom-field-type'], $save['custom-field-options'], $save['custom-field-default-value'], $save['prop'], $save['custom-field-duplicate'], $save['custom-field-helptext']);
                break;
            case 'submit-edit-custom-field':
                include_once 'RCCWP_CustomField.php';
                $current_field_obj = RCCWP_CustomField::Get($_POST['custom-field-id']);
                if ($_POST['custom-field-name'] != $current_field_obj->name && RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) {
                    $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-field') . '&custom-field-id=' . $_POST['custom-field-id'] . '&err_msg=-1';
                    wp_redirect($newURL);
                    exit;
                }
                $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_POST['custom-field-type']);
                if ($current_field->has_properties) {
                    $custom_field_properties = array();
                    if (in_array($current_field->name, array('Textbox', 'Listbox'))) {
                        $custom_field_properties['size'] = $_POST['custom-field-size'];
                        if (isset($_POST['strict-max-length'])) {
                            $custom_field_properties['strict-max-length'] = $_POST['strict-max-length'];
                            if (empty($custom_field_properties['size'])) {
                                $custom_field_properties['size'] = 10;
                            }
                        }
                    } else {
                        if (in_array($current_field->name, array('Multiline Textbox'))) {
                            $custom_field_properties['height'] = $_POST['custom-field-height'];
                            $custom_field_properties['width'] = $_POST['custom-field-width'];
                            if (isset($_POST['hide-visual-editor'])) {
                                $custom_field_properties['hide-visual-editor'] = 1;
                            }
                            if (isset($_POST['strict-max-length'])) {
                                $custom_field_properties['hide-visual-editor'] = 1;
                                $custom_field_properties['strict-max-length'] = $_POST['strict-max-length'];
                                if (empty($custom_field_properties['height'])) {
                                    $custom_field_properties['height'] = 4;
                                }
                                if (empty($custom_field_properties['width'])) {
                                    $custom_field_properties['width'] = 64;
                                }
                            }
                        } else {
                            if (in_array($current_field->name, array('Image', 'Image (Upload Media)'))) {
                                $params = '';
                                if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) {
                                    $params = '&h=' . $_POST['custom-field-photo-height'];
                                }
                                if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) {
                                    $params .= '&w=' . $_POST['custom-field-photo-width'];
                                }
                                if ($_POST['custom-field-custom-params'] != '') {
                                    $params .= '&' . $_POST['custom-field-custom-params'];
                                }
                                if ($params) {
                                    $custom_field_properties['params'] = $params;
                                }
                            } else {
                                if (in_array($current_field->name, array('Date'))) {
                                    $custom_field_properties['format'] = $_POST['custom-field-date-format'];
                                } else {
                                    if (in_array($current_field->name, array('Slider'))) {
                                        $custom_field_properties['max'] = $_POST['custom-field-slider-max'];
                                        $custom_field_properties['min'] = $_POST['custom-field-slider-min'];
                                        $custom_field_properties['step'] = $_POST['custom-field-slider-step'];
                                    } else {
                                        if (in_array($current_field->name, array('Related Type'))) {
                                            $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id'];
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $default = array('custom-group-id' => '', 'custom-field-name' => '', 'custom-field-description' => '', 'custom-field-order' => '', 'custom-field-required' => '', 'custom-field-type' => '', 'custom-field-options' => '', 'custom-field-default-value' => '', 'prop' => '', 'custom-field-duplicate' => '', 'custom-field-helptext' => '');
                $_POST['prop'] = $custom_field_properties;
                $save = array_merge($default, $_POST);
                RCCWP_CustomField::Update($save['custom-field-id'], $save['custom-field-name'], $save['custom-field-description'], $save['custom-field-order'], $save['custom-field-required'], $save['custom-field-type'], $save['custom-field-options'], $save['custom-field-default-value'], $save['prop'], $save['custom-field-duplicate'], $save['custom-field-helptext']);
                break;
            case 'delete-custom-field':
                include_once 'RCCWP_CustomField.php';
                if (isset($_REQUEST['custom-field-id']) && !empty($_REQUEST['custom-field-id'])) {
                    RCCWP_CustomField::Delete($_REQUEST['custom-field-id']);
                }
                break;
            case 'save-fields-order':
                RCCWP_CustomWritePanelPage::save_order_fields();
            default:
                if (RCCWP_Application::InWritePostPanel()) {
                    include_once 'RCCWP_Menu.php';
                    include_once 'RCCWP_WritePostPage.php';
                    $CUSTOM_WRITE_PANEL = RCCWP_Post::GetCustomWritePanel();
                    if (isset($CUSTOM_WRITE_PANEL) && !empty($CUSTOM_WRITE_PANEL)) {
                        add_action('admin_head', array('RCCWP_WritePostPage', 'CustomFieldsCSS'));
                        //adding javascripts files for the custom fields
                        add_action('admin_print_scripts', array('RCCWP_WritePostPage', 'CustomFieldsJavascript'));
                        add_action('admin_print_scripts', array('RCCWP_WritePostPage', 'ApplyWritePanelAssignedCategoriesOrTemplate'));
                        add_action('admin_head', array('RCCWP_WritePostPage', 'ApplyCustomWritePanelHeader'));
                        add_action('admin_menu', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface'));
                    } else {
                        if (!isset($_REQUEST['no-custom-write-panel']) && isset($_REQUEST['post'])) {
                            include_once 'RCCWP_Options.php';
                            $promptEditingPost = RCCWP_Options::Get('prompt-editing-post');
                            if ($promptEditingPost == 1) {
                                wp_redirect('?page=' . urlencode(MF_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&assign-custom-write-panel=' . (int) $_GET['post']);
                            }
                        }
                    }
                } else {
                    if (isset($_POST['update-custom-write-panel-options'])) {
                        if ($_POST['uninstall-custom-write-panel'] == 'uninstall') {
                            RCCWP_Application::Uninstall();
                            wp_redirect('options-general.php');
                        } else {
                            if (isset($_POST['clear-cache-image-mf'])) {
                                $dir = MF_CACHE_DIR;
                                if (is_dir($dir)) {
                                    if ($dh = opendir($dir)) {
                                        while (($file = readdir($dh)) !== false) {
                                            if (!is_dir($file)) {
                                                @unlink(MF_CACHE_DIR . $file);
                                            }
                                        }
                                        closedir($dh);
                                    }
                                }
                            }
                            include_once 'RCCWP_Options.php';
                            $default = array('condense-menu' => 0, 'hide-non-standart-content' => 0, 'hide-write-post' => 0, 'hide-write-page' => 0, 'hide-visual-editor' => 0, 'dont-remove-tmce' => 0, 'prompt-editing-post' => 0, 'assign-to-role' => 0, 'default-custom-write-panel' => 0);
                            $save_options = $_POST;
                            unset($save_options['uninstall-custom-write-panel']);
                            unset($save_options['update-custom-write-panel-options']);
                            $save = array_merge($default, $save_options);
                            RCCWP_Options::Update($save);
                        }
                    }
                }
                if (isset($_REQUEST['post'])) {
                    // traversal addition to change write panel
                    add_action('admin_menu', array('RCCWP_WritePostPage', 'CreateAttributesBox'));
                }
        }
    }
Ejemplo n.º 9
0
 function ShowPanel($panel)
 {
     return true;
     require_once 'RCCWP_CustomWritePanel.php';
     global $wpdb, $canvas;
     if ($panel->always_show) {
         return true;
     }
     $custom_panel_modules = RCCWP_CustomWritePanel::GetPanelCustomModules($panel->id);
     foreach ($custom_panel_modules as $panel_module) {
         //echo "SELECT * FROM ".$canvas->main." WHERE module_id = $panel_module->mod_id AND zone <> 'shelf'";
         if ($wpdb->get_results("SELECT * FROM " . $canvas->main . " WHERE module_id = {$panel_module->mod_id} AND zone <> 'shelf'")) {
             return true;
         }
     }
     if (0 < $wpdb->get_var("SELECT count({$wpdb->postmeta}.meta_value)\n\t\t\tFROM {$wpdb->postmeta}\n\t\t\tWHERE {$wpdb->postmeta}.meta_key = '_rc_cwp_write_panel_id' and {$wpdb->postmeta}.meta_value = '{$panel->id}'")) {
         return true;
     }
     return false;
 }
Ejemplo n.º 10
0
function change_number_not_write_panel_manage($where)
{
    global $parent_file;
    if (isset($_SESSION['change_number_not_write_panel_manage'])) {
        return $where;
    }
    $types = array('edit.php', 'edit-pages.php', 'edit.php?post_type=page');
    if (!in_array($parent_file, $types)) {
        return $where;
    }
    if (isset($_GET['custom-write-panel-id'])) {
        return $where;
    }
    if (!RCCWP_Options::Get('hide-non-standart-content')) {
        return $where;
    }
    $type = 'post';
    if (is_wp30()) {
        if ($parent_file == 'edit.php?post_type=page') {
            $type = 'page';
        }
    } else {
        if ($parent_file == 'edit-pages.php') {
            $type = 'page';
        }
    }
    $num_posts_mf = RCCWP_CustomWritePanel::GetCountPostNotWritePanel($type);
    printf("\n    <script type=\"text/javascript\">\n    //<![CDATA[\n      jQuery().ready(function() {\n        change_number_manage_not_write_panel('(%s)','(%s)','(%s)','(%s)','(%s)','(%s)','(%s)');\n      });\n    //]]>\n    </script>", array_sum((array) $num_posts_mf) - $num_posts_mf->trash, $num_posts_mf->publish, $num_posts_mf->pending, $num_posts_mf->draft, $num_posts_mf->private, $num_posts_mf->trash, $num_posts_mf->future);
    $_SESSION['change_number_not_write_panel_manage'] = "1";
    return $where;
}
Ejemplo n.º 11
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 
    }
Ejemplo n.º 12
0
    function CustomFieldCollectionInterface($rightOnly = false)
    {
        global $flutter_domain;
        global $CUSTOM_WRITE_PANEL;
        global $wpdb;
        global $post;
        //if no exists the write panel returni
        if (!isset($CUSTOM_WRITE_PANEL)) {
            return;
        }
        $customGroups = RCCWP_CustomWritePanel::GetCustomGroups($CUSTOM_WRITE_PANEL->id);
        foreach ($customGroups as $customGroup) {
            //render the elements
            $customFields = RCCWP_CustomGroup::GetCustomFields($customGroup->id);
            //when will be edit the  Post
            if (isset($_REQUEST['post']) && count($customFields) > 0) {
                //using the first field name we can know
                //the order  of the groups
                $firstFieldName = $customFields[0]->name;
                $order = RCCWP_CustomField::GetOrderDuplicates($_REQUEST['post'], $firstFieldName);
                ?>
 
                <div class="write_panel_wrapper"  id="write_panel_wrap_<?php 
                echo $customGroup->id;
                ?>
"><?php 
                //build the group duplicates
                foreach ($order as $key => $element) {
                    ?>
                    <?php 
                    RCCWP_WritePostPage::GroupDuplicate2($customGroup, $element, $key, false);
                    ?>
                   <?php 
                }
                ?>
                <?php 
                //knowing what is the biggest duplicate group
                if (!empty($order)) {
                    $tmp = $order;
                    sort($tmp);
                    $top = $tmp[count($tmp) - 1];
                } else {
                    $top = 0;
                }
                ?>
                <input type='hidden' name='g<?php 
                echo $customGroup->id;
                ?>
counter' id='g<?php 
                echo $customGroup->id;
                ?>
counter' value='<?php 
                echo $top;
                ?>
' />
                <input type="hidden" name="rc-custom-write-panel-verify-key" id="rc-custom-write-panel-verify-key" value="<?php 
                echo wp_create_nonce('rc-custom-write-panel');
                ?>
" />
		        <input type="hidden" name="rc-cwp-custom-write-panel-id" value="<?php 
                echo $CUSTOM_WRITE_PANEL->id;
                ?>
" />
                </div>
            <?php 
            } else {
                if (count($customFields) > 0) {
                    ?>
                <div class="write_panel_wrapper" id="write_panel_wrap_<?php 
                    echo $customGroup->id;
                    ?>
">
                <?php 
                    RCCWP_WritePostPage::GroupDuplicate2($customGroup, 1, 1, false);
                    $gc = 1;
                    ?>
                <input type='hidden' name='g<?php 
                    echo $customGroup->id;
                    ?>
counter' id='g<?php 
                    echo $customGroup->id;
                    ?>
counter' value='<?php 
                    echo $gc;
                    ?>
' />
           		<input type='hidden' name="rc-custom-write-panel-verify-key" id="rc-custom-write-panel-verify-key" value="<?php 
                    echo wp_create_nonce('rc-custom-write-panel');
                    ?>
" />
		        <input type='hidden' name="rc-cwp-custom-write-panel-id" value="<?php 
                    echo $CUSTOM_WRITE_PANEL->id;
                    ?>
" />
                </div>
            <?php 
                }
            }
        }
    }
    function ViewWritePanels()
    {
        global $mf_domain;
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels(TRUE);
        ?>

		<div class="wrap">

		<form action="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('import-write-panel');
        ?>
" method="post"  id="posts-filter" name="ImportWritePanelForm" enctype="multipart/form-data">
			<h2><?php 
        _e('Custom Write Panel', $mf_domain);
        ?>
</h2>
			<p id="post-search">					
				<input id="import-write-panel-file" name="import-write-panel-file" type="file" />
				<input id="overwrite-existing" name="overwrite-existing" type="checkbox"/> Overwrite existing panel
				<a href="#none" class="button-secondary" style="display:inline" onclick="document.ImportWritePanelForm.submit();"><?php 
        _e('Import a Write Panel', $mf_domain);
        ?>
</a>
				<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-write-panel');
        ?>
" class="button-secondary" style="display:inline">+ <?php 
        _e('Create a Write Panel', $mf_domain);
        ?>
</a>
			</p>	
		</form>
				
		<br class="clear"/>
		
		<table cellpadding="3" cellspacing="3" width="100%" class="widefat">
			<thead>
				<tr>
					<th scope="col" width="40%"><?php 
        _e('Name (Order)', $mf_domain);
        ?>
</th>
					<th width="10%"><?php 
        _e('Id', $mf_domain);
        ?>
</th>
					<th width="10%"><?php 
        _e('Type', $mf_domain);
        ?>
</th>
					<th width="40%" colspan="4" style="text-align:center"><?php 
        _e('Actions', $mf_domain);
        ?>
</th>
				</tr>
			</thead>
			<tbody>
				<?php 
        foreach ($customWritePanels as $panel) {
            ?>
					<tr>
						<td><?php 
            echo $panel->name;
            if ($panel->name != '_Global') {
                echo ' <span style="color: #999;">(' . $panel->display_order . ')</span>';
            }
            ?>
</td>
						<td><?php 
            echo $panel->id;
            ?>
</td>
						<td><?php 
            echo ucwords($panel->type);
            if ($panel->single != 1) {
                echo ' <sup class="multiple" title="Multiple Posts/Pages">[+]</sup>';
            }
            ?>
</td>
						<td><a href="<?php 
            echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('view-custom-write-panel', $panel->id);
            ?>
" ><?php 
            _e('Edit Fields/Groups', $mf_domain);
            ?>
</a></td>
						<td><?php 
            if ($panel->name != '_Global') {
                ?>
<a href="<?php 
                echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-write-panel', $panel->id);
                ?>
" ><?php 
                _e('Edit Write Panel', $mf_domain);
                ?>
</a>&nbsp;<?php 
            }
            ?>
</td>
						<td><?php 
            if ($panel->name != '_Global') {
                ?>
<a href="<?php 
                echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-write-panel', $panel->id);
                ?>
" ><a href="<?php 
                echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('export-custom-write-panel', $panel->id);
                ?>
" ><?php 
                _e('Export', $mf_domain);
                ?>
</a><?php 
            }
            ?>
</td>		
					</tr>
				<?php 
        }
        ?>
			</tbody>
		</table>
		<br />
		</div>
		<?php 
    }
    function Main()
    {
        global $mf_domain;
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
        $customWritePanelOptions = RCCWP_Options::Get();
        if (function_exists('is_site_admin') && !is_site_admin()) {
            update_option("Magic_Fields_notTopAdmin", true);
        } else {
            update_option("Magic_Fields_notTopAdmin", false);
        }
        ?>
	<div class="wrap">

	<h2><?php 
        _e('Magic Fields Options', $mf_domain);
        ?>
</h2>
	
	<form action="#" method="post" id="custom-write-panel-options-form">	
	
	<h3><?php 
        _e('Write Panel Options', $mf_domain);
        ?>
</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> 
	
	<tr valign="top">
		<th scope="row"><?php 
        _e('Condense Menu', $mf_domain);
        ?>
</th>
		<td>
			<label for="condense-menu">
				<input name="condense-menu" id="condense-menu" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['condense-menu']);
        ?>
 type="checkbox"> &nbsp; <?php 
        _e('This option removes the write panel from the main navigation and places them inside of the post and menu pages.');
        ?>
</label>
			</td>
	</tr>
	
	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide non-standart content in Post Panel', $mf_domain);
        ?>
</th>
		<td>
			<label for="hide-non-standart-content" >
			<input name="hide-non-standart-content" id="hide-non-standart-content" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-non-standart-content']);
        ?>
 type="checkbox"> &nbsp; <?php 
        _e('Hide posts made with Write panels in the edit section in the Post panel');
        ?>
</label>
		</td>
	</tr>
	
	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide Post Panel', $mf_domain);
        ?>
</th>
			<td>
			<label for="hide-write-post"> 
			<input name="hide-write-post" id="hide-write-post" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-write-post']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Hide Wordpress Post panel', $mf_domain);
        ?>
</label> 
		</td>
		</tr>
 
	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide Page Panel', $mf_domain);
        ?>
</th>
		<td>
			<label for="hide-write-page"> 
			<input name="hide-write-page" id="hide-write-page" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-write-page']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Hide Wordpress Page panel', $mf_domain);
        ?>
</label> 
 		</td>
	</tr>
	
	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide Visual Editor (multiline)', $mf_domain);
        ?>
</th>
		<td>
			<label for="hide-visual-editor"> 
			<input name="hide-visual-editor" id="hide-visual-editor" value="1"  <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-visual-editor']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Hide Visual Editor (multiline)', $mf_domain);
        ?>
</label> 
 		</td>
	</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Editing Prompt', $mf_domain);
        ?>
</th>
		<td>
			<label for="prompt-editing-post"> 
			<input name="prompt-editing-post" id="prompt-editing-post" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['prompt-editing-post']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('Prompt when editing a Post not created with Custom Write Panel.', $mf_domain);
        ?>
</label> 
		</td>
	</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Assign to Role', $mf_domain);
        ?>
</th>
			<td>
			<label for="assign-to-role"> 
			<input name="assign-to-role" id="assign-to-role" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['assign-to-role']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('This option will create a capability for each write panel such that the write panel is accessible by the Administrator only by default.
			 You can assign the write panel to other roles using ', $mf_domain);
        ?>
</label><a target="_blank" href="http://sourceforge.net/projects/role-manager">Role Manager Plugin</a>. 
		</td>
	</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Default Panel', $mf_domain);
        ?>
</th>
		<td>
			<label for="default-custom-write-panel">
			<select name="default-custom-write-panel" id="default-custom-write-panel">
				<option value=""><?php 
        _e('(None)', $mf_domain);
        ?>
</option>
			<?php 
        $defaultCustomWritePanel = $customWritePanelOptions['default-custom-write-panel'];
        foreach ($customWritePanels as $panel) {
            $selected = $panel->id == $defaultCustomWritePanel ? 'selected="selected"' : '';
            ?>
				<option value="<?php 
            echo $panel->id;
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo $panel->name;
            ?>
</option>
			<?php 
        }
        ?>
			</select>
			</label>
		</td>
	</tr>

	</table>

	
	<h3><?php 
        _e('Other Options', $mf_domain);
        ?>
</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
	<tr valign="top">
		<th scope="row"><?php 
        _e('Edit-n-place', $mf_domain);
        ?>
</th>
		<td>
			<label for="enable-editnplace"> 
			<input name="enable-editnplace" id="enable-editnplace" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['enable-editnplace']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('Edit posts instantly from the post page.', $mf_domain);
        ?>
</label> 
		</td>
		</tr>
	<script type='text/javascript' src='<?php 
        echo MF_URI;
        ?>
js/sevencolorpicker.js'></script>
	<script type="text/javascript">
		jQuery('document').ready(function(){
			jQuery('#eip-highlight-color').SevenColorPicker();
		});
	</script>
	<tr>
		<th scope="row"><?php 
        _e('EIP highlight color', $mf_domain);
        ?>
 </th>
		<td>
			<label for="eip-highlight-color">
			<input name="eip-highlight-color" id="eip-highlight-color" value="<?php 
        echo $customWritePanelOptions['eip-highlight-color'];
        ?>
"  >
			&nbsp; <?php 
        _e('Use color to highlight areas EIP', $mf_domain);
        ?>
</label>
		</td>
	</tr>
	
	</table>

	<br />	
	<h3><?php 
        _e('Uninstall Magic Fields', $mf_domain);
        ?>
</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> 
		<tr valign="top">
			<th scope="row"><?php 
        _e('Uninstall Magic Fields', $mf_domain);
        ?>
</th>
			<td>
				<input type="text" id="uninstall-custom-write-panel" name="uninstall-custom-write-panel" size="25" /><br />
				<label for="uninstall-custom-write-panel">
				&nbsp; <?php 
        _e('Type <strong>uninstall</strong> into the textbox, click <strong>Update Options</strong>, and all the tables created by this plugin will be deleted', $mf_domain);
        ?>
</label>
			</td>
		</tr>
	</table>

	<p class="submit" ><input name="update-custom-write-panel-options" type="submit" value="<?php 
        _e('Update Options', $mf_domain);
        ?>
" /></p>
	
	</form>

	</div>
	
	<?php 
    }
Ejemplo n.º 15
0
 /**
  * Import default modules/panels in the theme if it is the first time to 
  * activate the theme and add the theme settings to the database.
  *
  */
 function ImportNewTheme($themeName)
 {
     // -- Add/update theme settings to the database
     FlutterLayoutBlock::UpdateModuleSettings(get_template_directory() . '/configure.xml', -1, '-', get_option('template'));
     FlutterLayoutBlock::UpdateAllModulesSettings();
     // -- Import modules and panels
     if (RCCWP_Application::IsWordpressMu()) {
         if (get_site_option('Flutter_theme_ft_' . $themeName) == '1') {
             return;
         }
         update_site_option('Flutter_theme_ft_' . $themeName, '1');
     } else {
         if (get_option('Flutter_theme_ft_' . $themeName) == '1') {
             return;
         }
         update_option('Flutter_theme_ft_' . $themeName, '1');
     }
     $modulesFolder = get_template_directory() . '/Flutter_modules/';
     $panelsFolder = get_template_directory() . '/Flutter_panels/';
     // Import modules
     if ($handle = @opendir($modulesFolder)) {
         while (false !== ($file = readdir($handle))) {
             $filePath = $modulesFolder . $file;
             RCCWP_CustomWriteModule::Import($filePath);
         }
     }
     // Import panels
     if ($handle = @opendir($panelsFolder)) {
         while (false !== ($file = readdir($handle))) {
             $filePath = $panelsFolder . $file;
             RCCWP_CustomWritePanel::Import($filePath);
         }
     }
 }
Ejemplo n.º 16
0
    public static function Main()
    {
        global $mf_domain;
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
        $customWritePanelOptions = RCCWP_Options::Get();
        //check dont-remove p and br
        if (!isset($customWritePanelOptions['dont-remove-tmce'])) {
            $customWritePanelOptions['dont-remove-tmce'] = 0;
        }
        if (!isset($customWritePanelOptions['use-standard-uploader'])) {
            $customWritePanelOptions['use-standard-uploader'] = 0;
        }
        if (function_exists('is_site_admin') && !is_site_admin()) {
            update_option("Magic_Fields_notTopAdmin", true);
        } else {
            update_option("Magic_Fields_notTopAdmin", false);
        }
        ?>
	<div class="wrap">

	<h2><?php 
        _e('Magic Fields Options', $mf_domain);
        ?>
</h2>

	<form action="#" method="post" id="custom-write-panel-options-form">
	<?php 
        wp_nonce_field('update-custom-write-panel-options');
        ?>
 
	<h3><?php 
        _e('Write Panel Options', $mf_domain);
        ?>
</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">

	<tr valign="top">
		<th scope="row"><?php 
        _e('Condense Menu', $mf_domain);
        ?>
</th>
		<td>
			<label for="condense-menu">
				<input name="condense-menu" id="condense-menu" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['condense-menu']);
        ?>
 type="checkbox"> &nbsp; <?php 
        _e('This option removes the write panel from the main navigation and places them inside of the post and menu pages.');
        ?>
</label>
			</td>
	</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide non-standart content in Post Panel', $mf_domain);
        ?>
</th>
		<td>
			<label for="hide-non-standart-content" >
			<input name="hide-non-standart-content" id="hide-non-standart-content" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-non-standart-content']);
        ?>
 type="checkbox"> &nbsp; <?php 
        _e('Hide posts made with Write panels in the edit section in the Post panel');
        ?>
</label>
		</td>
	</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide Post Panel', $mf_domain);
        ?>
</th>
			<td>
			<label for="hide-write-post">
			<input name="hide-write-post" id="hide-write-post" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-write-post']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Hide Wordpress Post panel', $mf_domain);
        ?>
</label>
		</td>
		</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide Page Panel', $mf_domain);
        ?>
</th>
		<td>
			<label for="hide-write-page">
			<input name="hide-write-page" id="hide-write-page" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-write-page']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Hide Wordpress Page panel', $mf_domain);
        ?>
</label>
 		</td>
	</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide Visual Editor (multiline)', $mf_domain);
        ?>
</th>
		<td>
			<label for="hide-visual-editor">
			<input name="hide-visual-editor" id="hide-visual-editor" value="1"  <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-visual-editor']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Hide Visual Editor (multiline)', $mf_domain);
        ?>
</label>
 		</td>
	</tr>

        <tr valign="top">
          <th scope="row"><?php 
        _e('Do not remove tags tmce. (multiline)', $mf_domain);
        ?>
</th>
          <td>
            <label for="dont-remove-tmce">
            <input name="dont-remove-tmce" id="dont-remove-tmce" value="1"  <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['dont-remove-tmce']);
        ?>
 type="checkbox">
            &nbsp; <?php 
        _e("Stop removing the &lt;p&gt; and &lt;br /&gt; tags when saving and show them in the HTML editor", $mf_domain);
        ?>
</label>
        </td>
</tr>


  <tr valign="top">
		<th scope="row"><?php 
        _e('Use Standard File Uploader (non-ajax)', $mf_domain);
        ?>
</th>
		<td>
			<label for="use-standard-uploader">
			<input name="use-standard-uploader" id="use-standard-uploader" value="1"  <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['use-standard-uploader']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Try using the standard file uploader if the AJAX loader fails to upload to your server', $mf_domain);
        ?>
</label>
 		</td>
	</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Editing Prompt', $mf_domain);
        ?>
</th>
		<td>
			<label for="prompt-editing-post">
			<input name="prompt-editing-post" id="prompt-editing-post" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['prompt-editing-post']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Prompt when editing a Post not created with Custom Write Panel.', $mf_domain);
        ?>
</label>
		</td>
	</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Assign to Role', $mf_domain);
        ?>
</th>
			<td>
			<label for="assign-to-role">
			<input name="assign-to-role" id="assign-to-role" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['assign-to-role']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('This option will create a capability for each write panel such that the write panel is accessible by the Administrator only by default.
			 You can assign the write panel to other roles using ', $mf_domain);
        ?>
</label><a target="_blank" href="http://sourceforge.net/projects/role-manager">Role Manager Plugin</a>.
		</td>
	</tr>

	<tr valign="top">
		<th scope="row"><?php 
        _e('Default Panel', $mf_domain);
        ?>
</th>
		<td>
			<label for="default-custom-write-panel">
			<select name="default-custom-write-panel" id="default-custom-write-panel">
				<option value=""><?php 
        _e('(None)', $mf_domain);
        ?>
</option>
			<?php 
        $defaultCustomWritePanel = $customWritePanelOptions['default-custom-write-panel'];
        foreach ($customWritePanels as $panel) {
            $selected = $panel->id == $defaultCustomWritePanel ? 'selected="selected"' : '';
            ?>
				<option value="<?php 
            echo $panel->id;
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo $panel->name;
            ?>
</option>
			<?php 
        }
        ?>
			</select>
			</label>
		</td>
	</tr>

	</table>

	<h3><?php 
        _e('Extra', $mf_domain);
        ?>
</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
		<tr valign="top">
			<th scope="row"><?php 
        _e('Clear cache', $mf_domain);
        ?>
</th>
			<td>
				<label for="clear-cache-image-mf">
				<input name="clear-cache-image-mf" id="clear-cache-image-mf" value="1" type="checkbox">
			&nbsp; <?php 
        _e('delete all image thumbs', $mf_domain);
        ?>
</label>
			</td>
		</tr>
	</table>


	<h3><?php 
        _e('Uninstall Magic Fields', $mf_domain);
        ?>
</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
		<tr valign="top">
			<th scope="row"><?php 
        _e('Uninstall Magic Fields', $mf_domain);
        ?>
</th>
			<td>
				<input type="text" id="uninstall-custom-write-panel" name="uninstall-custom-write-panel" size="25" /><br />
				<label for="uninstall-custom-write-panel">
				&nbsp; <?php 
        _e('Type <strong>uninstall</strong> into the textbox, click <strong>Update Options</strong>, and all the tables created by this plugin will be deleted', $mf_domain);
        ?>
</label>
			</td>
		</tr>
	</table>

	<p class="submit" ><input name="update-custom-write-panel-options" type="submit" value="<?php 
        _e('Update Options', $mf_domain);
        ?>
" /></p>

	</form>

	</div>

	<?php 
    }
Ejemplo n.º 17
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);
 }
    function ViewWritePanels()
    {
        global $mf_domain;
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
        ?>

		<div class="wrap">

		<form action="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('import-write-panel');
        ?>
" method="post"  id="posts-filter" name="ImportWritePanelForm" enctype="multipart/form-data">
			<h2><?php 
        _e('Custom Write Panel', $mf_domain);
        ?>
</h2>
			<p id="post-search">					
				<input id="import-write-panel-file" name="import-write-panel-file" type="file" /> 
				<a href="#none" class="button-secondary" style="display:inline" onclick="document.ImportWritePanelForm.submit();"><?php 
        _e('Import a Write Panel', $mf_domain);
        ?>
</a>
				<a href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-write-panel');
        ?>
" class="button-secondary" style="display:inline">+ <?php 
        _e('Create a Write Panel', $mf_domain);
        ?>
</a>
			</p>	
		</form>
				
		<br class="clear"/>
		
		<table cellpadding="3" cellspacing="3" width="100%" class="widefat">
			<thead>
				<tr>
					<th scope="col" width="60%"><?php 
        _e('Name', $mf_domain);
        ?>
</th>
					<th colspan="4" style="text-align:center"><?php 
        _e('Actions', $mf_domain);
        ?>
</th>
				</tr>
			</thead>
			<tbody>
				<?php 
        foreach ($customWritePanels as $panel) {
            ?>
					<tr>
						<td><?php 
            echo $panel->name;
            ?>
</td>			
						<td><a href="<?php 
            echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('view-custom-write-panel', $panel->id);
            ?>
" ><?php 
            _e('Edit Fields/Groups', $mf_domain);
            ?>
</a></td>
						<td><a href="<?php 
            echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-write-panel', $panel->id);
            ?>
" ><?php 
            _e('Edit Write Panel', $mf_domain);
            ?>
</a></td>
						<td><a href="<?php 
            echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('export-custom-write-panel', $panel->id);
            ?>
" ><?php 
            _e('Export', $mf_domain);
            ?>
</a></td>		
					</tr>
				<?php 
        }
        ?>
			</tbody>
		</table>
		<br />
		</div>
		<?php 
    }
Ejemplo n.º 19
0
 /**
  * Drawing our  custom fields
  */
 function CustomFieldCollectionInterface()
 {
     global $CUSTOM_WRITE_PANEL, $wpdb, $mf_domain, $post;
     if (empty($CUSTOM_WRITE_PANEL)) {
         return false;
     }
     //getting information of the CustomWrite Panel
     $groups = RCCWP_CustomWritePanel::GetCustomGroups($CUSTOM_WRITE_PANEL->id);
     foreach ($groups as $group) {
         //Only is drawed the group if has at least one field
         $hasfields = RCCWP_CustomGroup::HasCustomfields($group->id);
         if (!$hasfields) {
             continue;
         }
         if ($group->name == "__default") {
             $name = "Magic Fields Custom Fields";
         } else {
             $name = $group->name;
         }
         add_meta_box('panel_' . $group->id, $name, array('RCCWP_WritePostPage', 'metaboxContent'), $CUSTOM_WRITE_PANEL->type, 'normal', 'high', $group);
     }
 }
Ejemplo n.º 20
0
    function AssignCustomWritePanel()
    {
        global $mf_domain;
        $postId = (int) $_GET['assign-custom-write-panel'];
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
        $customWritePanelOptions = RCCWP_Options::Get();
        $message = 'The Post that you\'re about to edit is not associated with any Custom Write Panel.';
        ?>
		
		<div id="message" class="updated"><p><?php 
        _e($message);
        ?>
</p></div>
		
		<div class="wrap">
		<h2><?php 
        _e('Assign Custom Write Panel');
        ?>
</h2>
		
		<form action="" method="post" id="assign-custom-write-panel-form">
		
		<table class="optiontable">
		<tbody>
		<tr valign="top">
			<th scope="row"><?php 
        _e('Custom Write Panel', $mf_domain);
        ?>
:</th>
			<td>
				<select name="custom-write-panel-id" id="custom-write-panel-id">
					<option value=""><?php 
        _e('(None)', $mf_domain);
        ?>
</option>
				<?php 
        $defaultCustomWritePanel = $customWritePanelOptions['default-custom-write-panel'];
        foreach ($customWritePanels as $panel) {
            $selected = $panel->id == $defaultCustomWritePanel ? 'selected="selected"' : '';
            ?>
					<option value="<?php 
            echo $panel->id;
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo $panel->name;
            ?>
</option>
				<?php 
        }
        ?>
				</select>
			</td>
		</tr>
		</tbody>
		</table>
		
		<input type="hidden" name="post-id" value="<?php 
        echo $postId;
        ?>
" />
		<p class="submit" >
			<input name="edit-with-no-custom-write-panel" type="submit" value="<?php 
        _e("Don't Assign Custom Write Panel", $mf_domain);
        ?>
" />
			<input name="edit-with-custom-write-panel" type="submit" value="<?php 
        _e('Edit with Custom Write Panel', $mf_domain);
        ?>
" />
		</p>
		
		</form>
		
		</div>
		
		<?php 
    }
Ejemplo n.º 21
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');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
     }
 }
Ejemplo n.º 22
0
 /**
  * Import a module given the zip file path. Importing a module means inserting it in
  * the database and copying its folder to modules folder. If a module with the same
  * name already exists, the function will append a number to the module name. You must 
  * have either php ZipArchive extension or unzip program installed.
  *
  * @param string $zipFilePath the full path of the zip file
  * @param string $moduleName the module name, if this value if false, the function will
  * 							use the zip filename as the module name. The default value is false
  * @return the module id, or false in case of error.
  */
 function Import($zipFilePath, $moduleName = false)
 {
     include_once 'RCCWP_CustomGroup.php';
     include_once 'RCCWP_CustomField.php';
     include_once 'RCCWP_CustomWritePanel.php';
     include_once 'RCCWP_Application.php';
     include_once 'RCCWP_CustomWritePanel.php';
     global $flutter_domain;
     if (!strpos($zipFilePath, ".zip")) {
         return false;
     }
     if (!$moduleName) {
         //use zip filename
         $moduleName = basename($zipFilePath, ".zip");
     }
     if ($moduleName == '') {
         return false;
     }
     // Append a number if the module already exists,
     $i = 1;
     $newModuleName = $moduleName;
     while (file_exists(FLUTTER_MODULES_DIR . $newModuleName)) {
         $newModuleName = $moduleName . "_" . $i++;
     }
     $moduleName = $newModuleName;
     mkdir(FLUTTER_MODULES_DIR . $moduleName);
     chmod(FLUTTER_MODULES_DIR . $moduleName, 0777);
     $destPath = FLUTTER_MODULES_DIR . $moduleName . DIRECTORY_SEPARATOR;
     if (class_exists('ZipArchive')) {
         $zip = new ZipArchive();
         // open archive
         if ($zip->open($zipFilePath) !== TRUE) {
             die(__('Could not open archive', $flutter_domain));
         }
         // extract contents to destination directory
         $zip->extractTo($destPath);
         // close archive
         $zip->close();
     } else {
         if (RCCWP_Application::CheckDecompressionProgramUnzip()) {
             $command = "unzip {$zipFilePath} -d " . $destPath;
         } else {
             die(__('Cannot find unzip program!', $flutter_domain));
         }
         exec($command, $out, $err);
     }
     $moduleInfo_imported_data = unserialize(file_get_contents($destPath . 'module_info.exp'));
     //Import module
     $moduleID = RCCWP_CustomWriteModule::Create($moduleName, $moduleInfo_imported_data['moduleinfo']->description, false);
     //Import any panels
     if ($handle = @opendir($destPath)) {
         while (false !== ($file = readdir($handle))) {
             if (substr($file, 0, 1) == "_") {
                 $panelName = basename(substr($file, 1), ".pnl");
                 RCCWP_CustomWritePanel::Import($destPath . $file, $panelName);
             }
         }
     }
     //Create Duplicates
     foreach ($moduleInfo_imported_data['duplicates'] as $moduleDuplicate) {
         RCCWP_ModuleDuplicate::Create($moduleID, $moduleDuplicate->duplicate_name);
     }
     return $moduleID;
 }
Ejemplo n.º 23
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;
 }
Ejemplo n.º 24
0
        $command = "zip -r {$zipFile}  ./*";
    } else {
        _e('Cannot find zip program', $flutter_domain);
        return;
    }
    exec($command, $out, $err);
    // send file in header
    header('Content-type: binary');
    header('Content-Disposition: attachment; filename="' . $module->name . '.zip"');
    readfile($zipFile);
    // Remove file and directory
    unlink($zipFile);
    advancedRmdir($moduleTmpPath);
    exit;
}
$customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-basic11.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" <?php 
language_attributes();
?>
>
<head>
	<title><?php 
_e('Export Module', $flutter_domain);
?>
</title>
	<link rel='stylesheet' href='<?php 
echo get_bloginfo('wpurl');
?>
Ejemplo n.º 25
0
    function Main()
    {
        global $flutter_domain;
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
        $customWritePanelOptions = RCCWP_Options::Get();
        if (function_exists('is_site_admin') && !is_site_admin()) {
            update_option("Flutter_notTopAdmin", true);
        } else {
            update_option("Flutter_notTopAdmin", false);
        }
        ?>
	
	<div class="wrap">

	<h2><?php 
        _e('Flutter Options', $flutter_domain);
        ?>
</h2>
	
	<form action="" method="post" id="custom-write-panel-options-form">	
	

	<h3><?php 
        _e('Write Panel Options', $flutter_domain);
        ?>
</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> 

	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide Post Panel', $flutter_domain);
        ?>
</th>
        	<td>
			<label for="hide-write-post"> 
			<input name="hide-write-post" id="hide-write-post" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-write-post']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Hide Wordpress Post panel', $flutter_domain);
        ?>
</label> 
		</td>
        </tr>
 
    	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide Page Panel', $flutter_domain);
        ?>
</th>
		<td>
			<label for="hide-write-page"> 
			<input name="hide-write-page" id="hide-write-page" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-write-page']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Hide Wordpress Page panel', $flutter_domain);
        ?>
</label> 
 		</td>
        </tr>
	
	<tr valign="top">
		<th scope="row"><?php 
        _e('Hide Visual Editor (multiline)', $flutter_domain);
        ?>
</th>
		<td>
			<label for="hide-visual-editor"> 
			<input name="hide-visual-editor" id="hide-visual-editor" value="1"  <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['hide-visual-editor']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Hide Visual Editor (multiline)', $flutter_domain);
        ?>
</label> 
 		</td>
        </tr>

    	<tr valign="top">
		<th scope="row"><?php 
        _e('Editing Prompt', $flutter_domain);
        ?>
</th>
		<td>
			<label for="prompt-editing-post"> 
			<input name="prompt-editing-post" id="prompt-editing-post" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['prompt-editing-post']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('Prompt when editing a Post not created with Custom Write Panel.', $flutter_domain);
        ?>
</label> 
		</td>
        </tr>

    	<tr valign="top">
		<th scope="row"><?php 
        _e('Assign to Role', $flutter_domain);
        ?>
</th>
        	<td>
			<label for="assign-to-role"> 
			<input name="assign-to-role" id="assign-to-role" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['assign-to-role']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('This option will create a capability for each write panel such that the write panel is accessible by the Administrator only by default.
			 You can assign the write panel to other roles using ', $flutter_domain);
        ?>
</label><a target="_blank" href="http://sourceforge.net/projects/role-manager">&nbsp; Role Manager Plugin</a>. 
		</td>
        </tr>

    	<tr valign="top">
		<th scope="row"><?php 
        _e('Default Panel', $flutter_domain);
        ?>
</th>
		<td>
		
			<label for="default-custom-write-panel">
			<select name="default-custom-write-panel" id="default-custom-write-panel">
				<option value=""><?php 
        _e('(None)', $flutter_domain);
        ?>
</option>
			<?php 
        $defaultCustomWritePanel = $customWritePanelOptions['default-custom-write-panel'];
        foreach ($customWritePanels as $panel) {
            $selected = $panel->id == $defaultCustomWritePanel ? 'selected="selected"' : '';
            ?>
				<option value="<?php 
            echo $panel->id;
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo $panel->name;
            ?>
</option>
			<?php 
        }
        ?>
			</select>
			</label>
		
		</td>
        </tr>

	</table>


	<br />
	<h3><?php 
        _e('Layout Options', $flutter_domain);
        ?>
</h3>
	<p><?php 
        _e('Allows you to add modules to the blog.', $flutter_domain);
        ?>
</p>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> 

	<tr valign="top">
		<th scope="row"><?php 
        _e('Layout Tab', $flutter_domain);
        ?>
</th>
		<td>
			<label for="canvas_show"> 
			<input name="canvas_show" id="canvas_show" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['canvas_show']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('Show Layout tab.', $flutter_domain);
        ?>
</label> 
		</td>
        </tr>


	<tr valign="top">
		<th scope="row"><?php 
        _e('Style Tab', $flutter_domain);
        ?>
</th>
		<td>
			<label for="ink_show"> 
			<input name="ink_show" id="ink_show" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['ink_show']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('Show Style tab.', $flutter_domain);
        ?>
</label> 
		</td>
        </tr>


	<tr valign="top">
		<th scope="row"><?php 
        _e('Layout Instructions', $flutter_domain);
        ?>
</th>
		<td>
			<label for="canvas_show_instructions"> 
			<input name="canvas_show_instructions" id="canvas_show_instructions" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['canvas_show_instructions']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('Display the instructions on the Layout page.', $flutter_domain);
        ?>
</label> 
		</td>
        </tr>


	<tr valign="top">
		<th scope="row"><?php 
        _e('Zones Names', $flutter_domain);
        ?>
</th>
		<td>
			<label for="canvas_show_zone_name"> 
			<input name="canvas_show_zone_name" id="canvas_show_zone_name" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['canvas_show_zone_name']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('Show zones names on droppable zones.', $flutter_domain);
        ?>
	</label> 
		</td>
        </tr>

	</table>

	
	<h3><?php 
        _e('Other Options', $flutter_domain);
        ?>
</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">

    	<!-- <tr valign="top">
		<th scope="row"><?php 
        _e('Snipshot', $flutter_domain);
        ?>
</th>
		<td>
			<label for="use-snipshot"> 
			<input name="use-snipshot" id="use-snipshot" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['use-snipshot']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('Use Snipshot services instead of cropper to edit photos.', $flutter_domain);
        ?>
</label> 
		</td>
        </tr> -->

	<tr valign="top">
		<th scope="row"><?php 
        _e('Edit-n-place', $flutter_domain);
        ?>
</th>
		<td>
			<label for="enable-editnplace"> 
			<input name="enable-editnplace" id="enable-editnplace" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['enable-editnplace']);
        ?>
 type="checkbox"> 
			&nbsp; <?php 
        _e('Edit posts instantly from the post page.', $flutter_domain);
        ?>
</label> 
		</td>
        </tr>
	<script type='text/javascript' src='<?php 
        echo FLUTTER_URI;
        ?>
js/sevencolorpicker.js'></script>
	<script type="text/javascript">
		jQuery('document').ready(function(){
			jQuery('#eip-highlight-color').SevenColorPicker();
		});
	</script>
	<tr>
		<th scope="row"><?php 
        _e('EIP highlight color', $flutter_domain);
        ?>
 </th>
		<td>
			<label for="eip-highlight-color">
			<input name="eip-highlight-color" id="eip-highlight-color" value="<?php 
        echo $customWritePanelOptions['eip-highlight-color'];
        ?>
"  >
			&nbsp; <?php 
        _e('Use color to highlight areas EIP', $flutter_domain);
        ?>
</label>
		</td>
	</tr>

	<tr>
		<th scope="row"><?php 
        _e('Browser uploader', $flutter_domain);
        ?>
 </th>
		<td>
			<label for="enable-browserupload">
			<input name="enable-browserupload" id="enable-browserupload" value="1" <?php 
        echo RCCWP_OptionsPage::GetCheckboxState($customWritePanelOptions['enable-browserupload']);
        ?>
 type="checkbox">
			&nbsp; <?php 
        _e('Use Browser uploader instead Flash Uploader', $flutter_domain);
        ?>
</label>
		</td>
	</tr>

	</table>

	<br />	
	<h3><?php 
        _e('Uninstall Flutter', $flutter_domain);
        ?>
</h3>
	<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> 

    	<tr valign="top">
		<th scope="row"><?php 
        _e('Uninstall Flutter', $flutter_domain);
        ?>
</th>
		<td>
			<input type="text" id="uninstall-custom-write-panel" name="uninstall-custom-write-panel" size="25" /><br />
			<label for="uninstall-custom-write-panel">
			&nbsp; <?php 
        _e('Type <strong>uninstall</strong> into the textbox, click <strong>Update Options</strong>, and all the tables created by this plugin will be deleted', $flutter_domain);
        ?>
</label>
		
		</td>
        </tr>

	</table>

	<p class="submit" ><input name="update-custom-write-panel-options" type="submit" value="<?php 
        _e('Update Options', $flutter_domain);
        ?>
" /></p>
	
	</form>

	</div>
	
	<?php 
    }
Ejemplo n.º 26
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);
                     }
                 }
             }
     }
 }
Ejemplo n.º 27
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;
 }