RCCWP_WritePostPage::attributesBoxContentPage PHP Method

attributesBoxContentPage() public static method

public static attributesBoxContentPage ( $post )
    public static function attributesBoxContentPage($post)
    {
        global $wpdb;
        $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 Panel1111');
        ?>
</label>
    	<?php 
        // get a list of the write panels
        $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
        $promptEditingPost = RCCWP_Options::Get('prompt-editing-post');
        $templates_by_filename = array();
        $templates = get_page_templates();
        // get the reverse map
        foreach ($templates as $name => $file) {
            $templates_by_filename[$file] = $name;
        }
        ?>
    	
    	<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"' : '';
            $panel_theme = RCCWP_CustomWritePanel::GetThemePage($panel->name);
            $parent_page = RCCWP_CustomWritePanel::GetParentPage($panel->name);
            if ($parent_page != '') {
                $pp = get_page($parent_page);
                if ($pp) {
                    $parent_page_title = $pp->post_title;
                }
            }
            $allow = $panel->type == "page";
            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 
                $items[$panel->id] = "{ panel_theme: '" . $panel_theme . "', template_name: '" . addslashes($templates_by_filename[$panel_theme]) . "', parent_page: '" . $parent_page . "', parent_page_title: '" . addslashes($parent_page_title) . "' }";
            }
        }
        ?>
    		</select>

        <script type="text/javascript">
        var mf_panel_items = { "-1" : { panel_theme: '', template_name: '', parent_page: '', parent_page_title: '' } };
        
        <?php 
        foreach ($items as $key => $value) {
            ?>
 
        mf_panel_items[<?php 
            echo $key;
            ?>
] = <?php 
            echo $value;
            ?>
; 
        <?php 
        }
        ?>
        
        </script>


    <div id="rc-cwp-set-buttons">
      <p><?php 
        _e('Note: Custom fields and groups associated with the selected write panel will be only be displayed once you have saved this page or post.');
        ?>
</p>
      <p><?php 
        _e('Before saving you may also like to set the <strong>Template</strong> and/or <strong>Parent</strong> in the <strong>Page Attributes</strong> panel to match the defaults for the selected write panel (recommended)');
        ?>
</p>
      <div class="inside">
        <input class="button" type="button" id="rc-cwp-set-page-template" value="<?php 
        _e('Set Page Template');
        ?>
" />
        <input class="button" type="button" id="rc-cwp-set-page-parent" value="<?php 
        _e('Set Page Parent');
        ?>
" />
      </div>
      <div class="mf-panel-info">
      <h5 class="mf-hd-panel-info">Defaults for the selected write panel</h5>
      <p>
        Template: <span id="mf-page-template-display"></span><br />
        Parent: <span id="mf-page-parent-display"></span>
      </p>
    </div>
    
  </div>
    <?php 
    }