[wp-cvs] wordpress/wp-admin admin-functions.php, 1.46,
1.47 edit-page-form.php, 1.6, 1.7 edit-pages.php, 1.4,
1.5 post.php, 1.89, 1.90
Ryan Boren
rboren at users.sourceforge.net
Wed Oct 6 05:11:13 UTC 2004
Update of /cvsroot/cafelog/wordpress/wp-admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16932/wp-admin
Modified Files:
admin-functions.php edit-page-form.php edit-pages.php post.php
Log Message:
Page templates.
Index: edit-page-form.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/edit-page-form.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** edit-page-form.php 6 Oct 2004 02:18:37 -0000 1.6
--- edit-page-form.php 6 Oct 2004 05:11:09 -0000 1.7
***************
*** 50,56 ****
</fieldset>
<fieldset id="pageparent">
! <legend><?php _e('Page Parent') ?></a></legend>
<div><select name="parent_id">
! <option value='0'>Main Page (no parent)</option>
<?php parent_dropdown($post_parent); ?>
</select>
--- 50,56 ----
</fieldset>
<fieldset id="pageparent">
! <legend><?php _e('Page Parent') ?></legend>
<div><select name="parent_id">
! <option value='0'><?php _e('Main Page (no parent)'); ?></option>
<?php parent_dropdown($post_parent); ?>
</select>
***************
*** 80,83 ****
--- 80,99 ----
<input name="referredby" type="hidden" id="referredby" value="<?php if (isset($_SERVER['HTTP_REFERER'])) echo htmlspecialchars($_SERVER['HTTP_REFERER']); ?>" />
</p>
+
+ <fieldset id="pageoptions">
+ <legend><?php _e('Page Options') ?></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th scope="row"><?php _e('Page Template:') ?></th>
+ <td><div><select name="page_template">
+ <option value='default'><?php _e('Default Template'); ?></option>
+ <?php page_template_dropdown($page_template); ?>
+ </select>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
<?php do_action('edit_page_form', ''); ?>
</form>
Index: admin-functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/admin-functions.php,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** admin-functions.php 6 Oct 2004 02:18:37 -0000 1.46
--- admin-functions.php 6 Oct 2004 05:11:08 -0000 1.47
***************
*** 756,759 ****
--- 756,790 ----
}
+ function get_page_templates() {
+ $themes = get_themes();
+ $theme = get_current_theme();
+ $templates = $themes[$theme]['Template Files'];
+ $page_templates = array();
+
+ foreach ($templates as $template) {
+ $template_data = implode('', file(ABSPATH . $template));
+ preg_match("|Template Name:(.*)|i", $template_data, $name);
+ preg_match("|Description:(.*)|i", $template_data, $description);
+
+ $name = $name[1];
+ $description = $description[1];
+
+ if (! empty($name)) {
+ $page_templates[trim($name)] = basename($template);
+ }
+ }
+
+ return $page_templates;
+ }
+
+ function page_template_dropdown($default = '') {
+ $templates = get_page_templates();
+ foreach (array_keys($templates) as $template) :
+ if ($default == $templates[$template]) $selected = " selected='selected'";
+ else $selected = '';
+ echo "\n\t<option value='" . $templates[$template] . "' $selected>$template</option>";
+ endforeach;
+ }
+
function parent_dropdown($default = 0, $parent = 0, $level = 0) {
global $wpdb;
Index: edit-pages.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/edit-pages.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** edit-pages.php 6 Oct 2004 02:18:37 -0000 1.4
--- edit-pages.php 6 Oct 2004 05:11:09 -0000 1.5
***************
*** 69,72 ****
--- 69,73 ----
$post_pingback = get_settings('default_pingback_flag');
$post_parent = 0;
+ $page_template = 'default';
include('edit-page-form.php');
Index: post.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/post.php,v
retrieving revision 1.89
retrieving revision 1.90
diff -C2 -d -r1.89 -r1.90
*** post.php 6 Oct 2004 02:18:37 -0000 1.89
--- post.php 6 Oct 2004 05:11:09 -0000 1.90
***************
*** 201,204 ****
--- 201,206 ----
if ($post_status = 'static') {
generate_page_rewrite_rules();
+
+ add_post_meta($post_ID, '_wp_page_template', $_POST['page_template'], true);
}
***************
*** 234,237 ****
--- 236,241 ----
if ($post_status == 'static') {
+ $page_template = get_post_meta($post_ID, '_wp_page_template', true);
+
include('edit-page-form.php');
} else {
***************
*** 439,442 ****
--- 443,450 ----
if ($post_status = 'static') {
generate_page_rewrite_rules();
+
+ if ( ! update_post_meta($post_ID, '_wp_page_template', $_POST['page_template'])) {
+ add_post_meta($post_ID, '_wp_page_template', $_POST['page_template'], true);
+ }
}
More information about the cvs
mailing list