private static function get_form_data($episode)
 {
     $form_data = array(array('type' => 'string', 'key' => 'title', 'options' => array('label' => __('Title', 'podlove'), 'description' => '', 'html' => array('readonly' => 'readonly', 'class' => 'podlove-check-input')), 'position' => 1100), array('type' => 'text', 'key' => 'subtitle', 'options' => array('label' => __('Subtitle', 'podlove'), 'description' => '', 'html' => array('class' => 'large-text autogrow podlove-check-input', 'rows' => 1)), 'position' => 1000), array('type' => 'text', 'key' => 'summary', 'options' => array('label' => __('Summary', 'podlove'), 'description' => '', 'html' => array('class' => 'large-text autogrow podlove-check-input', 'rows' => 3)), 'position' => 900), array('type' => 'string', 'key' => 'slug', 'options' => array('label' => __('Episode Media File Slug', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text podlove-check-input')), 'position' => 510), array('type' => 'string', 'key' => 'duration', 'options' => array('label' => __('Duration', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text podlove-check-input')), 'position' => 400), array('type' => 'multiselect', 'key' => 'episode_assets', 'options' => Podcast_Post_Meta_Box::episode_assets_form($episode), 'position' => 300));
     // allow modules to add / change the form
     $form_data = apply_filters('podlove_episode_form_data', $form_data, $episode);
     // sort entities by position
     // TODO first sanitize position attribute, then I don't have to check on each comparison
     usort($form_data, array(__CLASS__, 'compare_by_position'));
     return $form_data;
 }
Ejemplo n.º 2
0
    /**
     * Meta Box Template
     */
    public static function post_type_meta_box_callback($post)
    {
        $post_id = $post->ID;
        $podcast = Model\Podcast::get_instance();
        $episode = Model\Episode::find_or_create_by_post_id($post_id);
        wp_nonce_field(\Podlove\PLUGIN_FILE, 'podlove_noncename');
        ?>
		<input type="hidden" name="show-media-file-base-uri" value="<?php 
        echo $podcast->media_file_base_uri;
        ?>
" />
		<table class="form-table">
			<?php 
        $form_args = array('context' => '_podlove_meta', 'submit_button' => false, 'form' => false);
        \Podlove\Form\build_for($episode, $form_args, function ($form) use($podcast) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $episode = $form->object;
            $wrapper->checkbox('active', array('label' => __('Post Episode to Show', 'podlove'), 'description' => '', 'default' => true));
            $wrapper->string('slug', array('label' => __('Episode Media File Slug', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text')));
            // TODO: validate and parse
            $wrapper->string('duration', array('label' => __('Duration', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text')));
            $wrapper->string('subtitle', array('label' => __('Subtitle', 'podlove'), 'description' => '', 'html' => array('class' => 'large-text')));
            $wrapper->text('summary', array('label' => __('Summary', 'podlove'), 'description' => '', 'html' => array('class' => 'large-text', 'rows' => max(2, count(explode("\n", $episode->summary))))));
            if ($podcast->supports_cover_art === 'manual') {
                $wrapper->string('cover_art', array('label' => __('Episode Cover Art URL', 'podlove'), 'description' => __('JPEG or PNG. At least 1400 x 1400 pixels.', 'podlove'), 'html' => array('class' => 'regular-text')));
            }
            $wrapper->text('chapters', array('label' => __('Chapter Marks', 'podlove'), 'description' => __('One timepoint (hh:mm:ss[.mmm]) and the chapter title per line.', 'podlove'), 'html' => array('class' => 'large-text code', 'placeholder' => '00:00:00.000 Intro', 'rows' => max(2, count(explode("\n", $episode->chapters))))));
            $wrapper->checkbox('enable', array('label' => __('Enable?', 'podlove'), 'description' => __('Allow this episode to appear in podcast directories.', 'podlove'), 'default' => true));
            // TODO: button to update
            // TODO: pretty display
            // TODO: don't display link
            // TODO: display last modified from header
            $wrapper->multiselect('episode_assets', Podcast_Post_Meta_Box::episode_assets_form($episode));
        });
        ?>
		</table>
		<?php 
    }