Ejemplo n.º 1
0
                           style="width: 125px;"/>
                </p>
            </fieldset>
            <fieldset>
                <legend>
                    <?php 
_ex('Timezone', 'TinyMCE Dialog - Timezone fieldset label', 'timed-content');
?>
 
                </legend>
                <p><?php 
_ex('Select a city whose timezone you wish to use:', 'TinyMCE Dialog - Timezone <select> HTML label', 'timed-content');
?>
                    <select name="server_tz" id="server_tz" style="width: auto;">
                        <?php 
echo customFieldsInterface::__generateTimezoneSelectOptions(get_option('timezone_string'));
?>
                    </select>
                </p>

                <p><?php 
_e('Wordpress Timezone:', 'timed-content');
?>
 <?php 
echo get_option('timezone_string');
?>
</p>
            </fieldset>
            <div class="mceActionPanel">
                <input type="button" id="insert" name="insert"
                       value="<?php 
        /**
         * Display the new Custom Fields meta box
         */
        function displayCustomFields()
        {
            global $post;
            ?>
			<p><?php 
            echo $this->desc;
            ?>
</p>
			<div class="form-wrap">
				<?php 
            wp_nonce_field($this->handle, $this->handle . '_wpnonce', false, true);
            foreach ($this->customFields as $customField) {
                // Check scope
                $scope = $customField['scope'];
                $output = false;
                foreach ($scope as $scopeItem) {
                    switch ($scopeItem) {
                        default:
                            if ($post->post_type == $scopeItem) {
                                $output = true;
                            }
                            break;
                    }
                    if ($output) {
                        break;
                    }
                }
                // Check capability
                if (!current_user_can($customField['capability'], $post->ID)) {
                    $output = false;
                }
                // Output if allowed
                if ($output) {
                    ?>
						<div class="form-field form-required" id="<?php 
                    echo $this->prefix . $customField['name'];
                    ?>
_div" style="display: <?php 
                    echo $customField['display'];
                    ?>
">
							<?php 
                    switch ($customField['type']) {
                        case "radio":
                            // radio
                            $checked_value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            echo "<strong>" . $customField['title'] . "</strong><br />\n";
                            foreach ($customField['values'] as $value => $label) {
                                echo "<input type=\"radio\" name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "_" . $value . "\" value=\"" . $value . "\"";
                                if ($checked_value == $value) {
                                    echo " checked=\"checked\"";
                                }
                                echo " style=\"width: 30px;\" /><label for=\"" . $this->prefix . $customField['name'] . "_" . $value . "\" style=\"display: inline;\">" . $label . "</label><br />\n";
                            }
                            break;
                        case "menu":
                            // menu
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "\" style=\"display:inline;\"><strong>" . $customField['title'] . "</strong></label><br />\n";
                            if (sizeof($customField['values']) == 0) {
                                echo "<em>" . __("This menu is empty.", "timed-content") . "</em>\n";
                            } else {
                                $selected_value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                                echo "<select name=\"" . $this->prefix . $customField['name'] . "[]\" id=\"" . $this->prefix . $customField['name'] . "\" style=\"width: auto; height: auto; padding: 3px;\" size=\"" . $customField['size'] . "\" multiple=\"multiple\">\n";
                                foreach ($customField['values'] as $value => $label) {
                                    echo "\t<option value=\"" . $value . "\"";
                                    if ($selected_value == $value) {
                                        echo " selected=\"selected\"";
                                    }
                                    echo ">" . $label . "</option>\n";
                                }
                                echo "</select>\n";
                            }
                            break;
                        case "list":
                            // list
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "\" style=\"display:inline;\"><strong>" . $customField['title'] . "</strong></label>&nbsp;&nbsp;\n";
                            if (sizeof($customField['values']) == 0) {
                                echo "<em>" . __("This menu is empty.", "timed-content") . "</em>\n";
                            } else {
                                $selected_value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                                echo "<select name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "\" style=\"width: auto;\">\n";
                                foreach ($customField['values'] as $value => $label) {
                                    echo "\t<option value=\"" . $value . "\"";
                                    if ($selected_value == $value) {
                                        echo " selected=\"selected\"";
                                    }
                                    echo ">" . $label . "</option>\n";
                                }
                                echo "</select>\n";
                            }
                            break;
                        case "timezone-list":
                            // timezone list
                            $selected_value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "\" style=\"display:inline;\"><strong>" . $customField['title'] . "</strong></label>&nbsp;&nbsp;\n";
                            echo "<select name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "\" style=\"width: auto;\">\n";
                            echo customFieldsInterface::__generateTimezoneSelectOptions($selected_value);
                            echo "</select>\n";
                            break;
                        case "checkbox":
                            // Checkbox
                            $checked_value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "\" style=\"display:inline;\"><strong>" . $customField['title'] . "</strong></label>&nbsp;&nbsp;\n";
                            echo "<input type=\"checkbox\" name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "\" value=\"yes\"";
                            if ($checked_value == "yes") {
                                echo " checked=\"checked\"";
                            }
                            echo " style=\"width: 30px;\" />\n";
                            break;
                        case "checkbox-list":
                            // Checkbox list
                            $checked_value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            echo "<strong>" . $customField['title'] . "</strong><br />\n";
                            if (sizeof($customField['values']) == 0) {
                                echo "<em>" . __("This menu is empty.", "timed-content") . "</em>\n";
                            } else {
                                foreach ($customField['values'] as $value => $label) {
                                    echo "<input type=\"checkbox\" name=\"" . $this->prefix . $customField['name'] . "[]\" id=\"" . $this->prefix . $customField['name'] . "_" . $value . "\" value=\"" . $value . "\"";
                                    if (is_array($checked_value) && in_array($value, $checked_value)) {
                                        echo " checked=\"checked\"";
                                    }
                                    echo " style=\"width: 30px;\" /><label for=\"" . $this->prefix . $customField['name'] . "_" . $value . "\" style=\"display: inline;\" >" . $label . "</label><br />\n";
                                }
                            }
                            break;
                        case "textarea":
                        case "wysiwyg":
                            // Text area
                            $value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "\"><strong>" . $customField['title'] . "</strong></label>\n";
                            echo "<textarea name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "\" columns=\"30\" rows=\"3\">" . htmlspecialchars($value) . "</textarea>\n";
                            // WYSIWYG
                            if ($customField['type'] == "wysiwyg") {
                                ?>
<script type="text/javascript">
//<![CDATA[
	jQuery( document ).ready( function() {
		jQuery( "<?php 
                                echo $this->prefix . $customField['name'];
                                ?>
" ).addClass( "mceEditor" );
		if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
			tinyMCE.execCommand( "mceAddControl", false, "<?php 
                                echo $this->prefix . $customField['name'];
                                ?>
" );
		}
	});
//]]>
</script>
									<?php 
                            }
                            break;
                        case "color-picker":
                            $value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            // Color picker using WP's built-in Iris jQuery plugin
                            ?>
<script type="text/javascript">
//<![CDATA[
	jQuery(document).ready(function() {
		var <?php 
                            echo $this->prefix . $customField['name'];
                            ?>
Options = {
			defaultColor: false,
			hide: true,
			palettes: true
		};
		 
		jQuery("#<?php 
                            echo $this->prefix . $customField['name'];
                            ?>
").wpColorPicker(<?php 
                            echo $this->prefix . $customField['name'];
                            ?>
Options);
	});
//]]>
</script>
									<?php 
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "\"><strong>" . $customField['title'] . "</strong></label>&nbsp;&nbsp;\n";
                            echo "<input type=\"text\" name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "\" value=\"" . $value . "\" size=\"7\" maxlength=\"7\" style=\"width: 100px;\" />\n";
                            break;
                        case "date":
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "\" style=\"display:inline;\"><strong>" . $customField['title'] . "</strong></label>&nbsp;&nbsp;\n";
                            //									echo "<span style=\"display:inline;\"><strong>" . $customField[ 'title' ] . "</strong></span>&nbsp;&nbsp;\n";
                            $value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            // Date picker using WP's built-in Datepicker jQuery plugin
                            ?>
<script type="text/javascript">
//<![CDATA[
	jQuery(document).ready(function() {
		jQuery( "#<?php 
                            echo $this->prefix . $customField['name'];
                            ?>
" ).datepicker(
			{
				<?php 
                            if (isset($customField['custom_functions'])) {
                                echo $customField['custom_functions'];
                            }
                            ?>
				changeMonth: true,
				changeYear: true
			}
		);
	});
//]]>
</script>
									<?php 
                            echo "<input type=\"text\" name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "\" value=\"" . htmlspecialchars($value) . "\" style=\"width: 175px;\" />\n";
                            break;
                        case "datetime":
                            echo "<span style=\"display:inline;\"><strong>" . $customField['title'] . "</strong></span><br />\n";
                            $value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            foreach ($value as $k => $v) {
                                $value[$k] = htmlspecialchars($v);
                            }
                            // Date picker using WP's built-in Datepicker jQuery plugin
                            // Time picker using jQuery UI Timepicker: http://fgelinas.com/code/timepicker
                            ?>
<script type="text/javascript">
//<![CDATA[
	jQuery(document).ready(function() {
		jQuery( "#<?php 
                            echo $this->prefix . $customField['name'];
                            ?>
_date" ).datepicker(
			{
				changeMonth: true,
				changeYear: true
			}
		);
		jQuery( "#<?php 
                            echo $this->prefix . $customField['name'];
                            ?>
_time" ).timepicker(
			{
                defaultTime: 'now'
			}
		);
	});
//]]>
</script>
									<?php 
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "_date\" style=\"display:inline;\"><em>" . _x('Date', 'Date field label', 'timed-content') . ":</em></label>&nbsp;&nbsp;\n";
                            echo "<input type=\"text\" name=\"" . $this->prefix . $customField['name'] . "[date]\" id=\"" . $this->prefix . $customField['name'] . "_date\" value=\"" . $value['date'] . "\" style=\"width: 175px;\" />\n";
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "_time\" style=\"display:inline;\"><em>" . _x('Time', 'Time field label', 'timed-content') . ":</em></label>&nbsp;&nbsp;\n";
                            echo "<input type=\"text\" name=\"" . $this->prefix . $customField['name'] . "[time]\" id=\"" . $this->prefix . $customField['name'] . "_time\" value=\"" . $value['time'] . "\" style=\"width: 125px;\" />\n";
                            break;
                        case "number":
                            (int) ($value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true));
                            // Number picker using WP's built-in Spinner jQuery plugin
                            ?>
<script type="text/javascript">
//<![CDATA[
	jQuery(document).ready(function() {
		jQuery( "#<?php 
                            echo $this->prefix . $customField['name'];
                            ?>
" ).spinner(
			{
				stop: function( event, ui ) { jQuery( this ).trigger("change"); },
				<?php 
                            if (isset($customField['min'])) {
                                ?>
min: <?php 
                                echo $customField['min'];
                                ?>
, <?php 
                            }
                            ?>
				<?php 
                            if (isset($customField['max'])) {
                                ?>
max: <?php 
                                echo $customField['max'];
                                ?>
 <?php 
                            }
                            ?>
			}
		);
	});
//]]>
</script>
									<?php 
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "\" style=\"display:inline;\"><strong>" . $customField['title'] . "</strong></label>&nbsp;&nbsp;\n";
                            echo "<input type=\"text\" name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "\" value=\"" . $value . "\" size=\"2\" />\n";
                            break;
                        case "hidden":
                            $value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            // Hidden field
                            echo "<input type=\"hidden\" name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "\" value=\"" . $value . "\" />\n";
                            break;
                        default:
                            $value = "" === get_post_meta($post->ID, $this->prefix . $customField['name'], true) ? $customField['default'] : get_post_meta($post->ID, $this->prefix . $customField['name'], true);
                            // Plain text field
                            echo "<label for=\"" . $this->prefix . $customField['name'] . "\"><strong>" . $customField['title'] . "</strong></label>\n";
                            echo "<input type=\"text\" name=\"" . $this->prefix . $customField['name'] . "\" id=\"" . $this->prefix . $customField['name'] . "\" value=\"" . $value . "\" />\n";
                            break;
                    }
                    ?>
							<?php 
                    if (isset($customField['description'])) {
                        echo "<p>" . $customField['description'] . "</p>\n";
                    }
                    ?>
						</div>
					<?php 
                }
            }
            ?>
			</div>
			<?php 
        }