Пример #1
0
    function page()
    {
        ?>
		<div class="wrap">
			<div id="icon-options-general" class="icon32"></div>
			<h2><?php 
        echo __('Podcast Settings');
        ?>
</h2>

			<form method="post" action="options.php">
				<?php 
        settings_fields(Podcast::$pagehook);
        ?>

				<?php 
        $podcast = \Podlove\Model\Podcast::get_instance();
        $form_attributes = array('context' => 'podlove_podcast', 'form' => false);
        \Podlove\Form\build_for($podcast, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $podcast = $form->object;
            $wrapper->string('title', array('label' => __('Title', 'podlove'), 'description' => __('', 'podlove'), 'html' => array('class' => 'regular-text required')));
            $wrapper->string('subtitle', array('label' => __('Subtitle', 'podlove'), 'description' => __('The subtitle is used by iTunes.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->text('summary', array('label' => __('Summary', 'podlove'), 'description' => __('A couple of sentences describing the podcast.', 'podlove'), 'html' => array('rows' => 5, 'cols' => 40)));
            $wrapper->string('slug', array('label' => __('Mnemonic', 'podlove'), 'description' => __('The abbreviation for your podcast. Commonly the initials of the title.', 'podlove'), 'html' => array('class' => 'regular-text required')));
            $wrapper->image('cover_image', array('label' => __('Cover Art URL', 'podlove'), 'description' => __('JPEG or PNG. At least 1400 x 1400 pixels.', 'podlove'), 'html' => array('class' => 'regular-text'), 'image_width' => 300, 'image_height' => 300));
            $wrapper->string('author_name', array('label' => __('Author Name', 'podlove'), 'description' => __('Publicly displayed in Podcast directories.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->string('owner_name', array('label' => __('Owner Name', 'podlove'), 'description' => __('Used by iTunes and other Podcast directories to contact you.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->string('owner_email', array('label' => __('Owner Email', 'podlove'), 'description' => __('Used by iTunes and other Podcast directories to contact you.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->string('keywords', array('label' => __('Keywords', 'podlove'), 'description' => __('List of keywords. Separate with commas.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->select('category_1', array('label' => __('iTunes Categories', 'podlove'), 'description' => '', 'type' => 'select', 'options' => \Podlove\Itunes\categories()));
            $wrapper->select('category_2', array('label' => '', 'description' => '', 'type' => 'select', 'options' => \Podlove\Itunes\categories()));
            $wrapper->select('category_3', array('label' => '', 'description' => '<br>' . __('For placement within the older, text-based browse system, podcast feeds may list up to 3 category/subcategory pairs. (For example, "Music" counts as 1, as does "Business > Careers.") For placement within the newer browse system based on Category links, however, and for placement within the Top Podcasts and Top Episodes lists that appear in the right column of most podcast pages, only the first category listed in the feed is used.') . ' (<a href="http://www.apple.com/itunes/podcasts/specs.html#category" target="_blank">http://www.apple.com/itunes/podcasts/specs.html#category</a>)', 'options' => \Podlove\Itunes\categories()));
            $wrapper->select('language', array('label' => __('Language', 'podlove'), 'description' => __('', 'podlove'), 'default' => get_bloginfo('language'), 'options' => \Podlove\Locale\locales()));
            $wrapper->select('explicit', array('label' => __('Explicit Content?', 'podlove'), 'description' => __('', 'podlove'), 'type' => 'checkbox', 'options' => array(0 => 'no', 1 => 'yes', 2 => 'clean')));
            $wrapper->string('media_file_base_uri', array('label' => __('Media File Base URL', 'podlove'), 'description' => __('Example: http://cdn.example.com/pod/', 'podlove'), 'html' => array('class' => 'regular-text required')));
            $artwork_options = array('0' => __('None', 'podlove'), 'manual' => __('Manual Entry', 'podlove'));
            $episode_assets = Model\EpisodeAsset::all();
            foreach ($episode_assets as $episode_asset) {
                $file_type = $episode_asset->file_type();
                if ($file_type && $file_type->type === 'image') {
                    $artwork_options[$episode_asset->id] = sprintf(__('Media File: %s', 'podlove'), $episode_asset->title);
                }
            }
            $wrapper->select('supports_cover_art', array('label' => __('Episode Artwork Media File', 'podlove'), 'options' => $artwork_options));
        });
        ?>
				
			</form>
		</div>	
		<?php 
    }
Пример #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 
    }
    public function register_page()
    {
        $podcast = \Podlove\Model\Podcast::get();
        $form_attributes = array('context' => 'podlove_podcast', 'action' => $this->get_url());
        ?>
		<p>
			<?php 
        echo __('These are the three most important fields describing your podcast.
					<strong>Title</strong> is the title of the podcast that is the primary field to be used to represent the podcast in directories, lists and other uses.
					The <strong>subtitle</strong> is an extension to the title. The subtitle is meant to clarify what the podcast is about. While a title can be anything, a subtitle should be more descriptive in what the content actually wants to convey and what the most important information is, you want everybody want to know about the offering.
					A <strong>summary</strong> is a much more precise and elaborate description of the podcast\'s content. While title and subtitle are rather concise, a summary is meant to consist of one or more sentences that form a paragraph or more.', 'podlove');
        ?>
		</p>
		<?php 
        \Podlove\Form\build_for($podcast, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $podcast = $form->object;
            $wrapper->string('title', array('label' => __('Title', 'podlove'), 'html' => array('class' => 'regular-text required podlove-check-input')));
            $wrapper->string('subtitle', array('label' => __('Subtitle', 'podlove'), 'description' => __('Extension to the title. Clarify what the podcast is about.', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input')));
            $wrapper->text('summary', array('label' => __('Summary', 'podlove'), 'description' => __('Elaborate description of the podcast\'s content.', 'podlove'), 'html' => array('rows' => 3, 'cols' => 40, 'class' => 'autogrow podlove-check-input')));
            $wrapper->upload('cover_image', array('label' => __('Cover Art URL', 'podlove'), 'description' => __('JPEG or PNG. At least 1400 x 1400 pixels.', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input', 'data-podlove-input-type' => 'url'), 'media_button_text' => __("Use for Podcast Cover Art", 'podlove')));
            $wrapper->select('language', array('label' => __('Language', 'podlove'), 'description' => __('', 'podlove'), 'default' => get_bloginfo('language'), 'options' => \Podlove\Locale\locales()));
        });
    }
 private function form_template($season, $action, $button_text = NULL)
 {
     wp_enqueue_script('jquery');
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-datepicker');
     $form_args = array('context' => 'podlove_season', 'hidden' => array('season' => $season->id, 'action' => $action), 'submit_button' => false, 'form_end' => function () {
         echo "<p>";
         submit_button(__('Save Changes'), 'primary', 'submit', false);
         echo " ";
         submit_button(__('Save Changes and Continue Editing', 'podlove'), 'secondary', 'submit_and_stay', false);
         echo "</p>";
     });
     \Podlove\Form\build_for($season, $form_args, function ($form) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $season = $form->object;
         $wrapper->string('title', ['label' => __('Title', 'podlove') . \Podlove\get_help_link('podlove_help_seasons_title'), 'html' => ['class' => 'regular-text podlove-check-input']]);
         $wrapper->string('subtitle', ['label' => __('Subtitle', 'podlove'), 'html' => ['class' => 'regular-text podlove-check-input']]);
         $wrapper->text('summary', ['label' => __('Summary', 'podlove'), 'html' => array('rows' => 3, 'cols' => 40, 'class' => 'autogrow podlove-check-input')]);
         $wrapper->string('start_date', ['label' => __('Start Date', 'podlove') . \Podlove\get_help_link('podlove_help_seasons_date'), 'html' => ['class' => 'regular-text podlove-check-input', 'readonly' => 'readonly']]);
         $wrapper->upload('image', ['label' => __('Image', 'podlove'), 'html' => ['class' => 'regular-text podlove-check-input', 'data-podlove-input-type' => 'url'], 'media_button_text' => __("Use Image for Season", 'podlove')]);
     });
 }
    private function form_template($list, $action, $button_text = NULL)
    {
        $form_args = array('context' => 'podlove_list', 'hidden' => array('list' => $list->id, 'action' => $action));
        \Podlove\Form\build_for($list, $form_args, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $list = $form->object;
            $wrapper->string('slug', array('label' => __('ID', 'podlove'), 'html' => array('class' => 'regular-text required'), 'description' => sprintf(__('For referencing in templates: %s', 'podlove'), '<code>{{ network.lists({id: "example"}).title }}</code>')));
            $wrapper->string('title', array('label' => __('Title', 'podlove'), 'html' => array('class' => 'regular-text required')));
            $wrapper->string('subtitle', array('label' => __('Subtitle', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->text('description', array('label' => __('Summary', 'podlove'), 'description' => __('', 'podlove'), 'html' => array('rows' => 3, 'cols' => 40, 'class' => 'autogrow')));
            $wrapper->image('logo', array('label' => __('Logo', 'podlove'), 'description' => __('JPEG or PNG.', 'podlove'), 'html' => array('class' => 'regular-text'), 'image_width' => 300, 'image_height' => 300));
            $wrapper->string('url', array('label' => __('List URL', 'podlove'), 'description' => __('', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->callback('podcasts', array('label' => __('Podcasts', 'podlove'), 'callback' => function () use($list) {
                $form_base_name = "podlove_list";
                ?>
					<div id="podcast_lists">
						<table class="podlove_alternating" border="0" cellspacing="0">
							<thead>
								<tr>
									<th><?php 
                echo __('Source', 'podlove');
                ?>
</th>
									<th><?php 
                echo __('Podcast/URL', 'podlove');
                ?>
</th>
									<th style="width: 60px"><?php 
                echo __('Remove', 'podlove');
                ?>
</th>
									<th style="width: 30px"></th>
								</tr>
							</thead>
							<tbody class="podcasts_table_body" style="min-height: 50px;">
								<tr class="podcasts_table_body_placeholder" style="display: none;">
									<td><em><?php 
                echo __('No Podcasts were added yet.', 'podlove');
                ?>
</em></td>
								</tr>
							</tbody>
						</table>

						<div id="add_new_podcasts_wrapper">
							<input class="button" id="add_new_podcast" value="+" type="button" />
						</div>

						<script type="text/template" id="podcast-row-template">
						<tr class="media_file_row podlove-podcast-table" data-id="{{id}}">
							<td class="podlove-podcast-column">
								<select name="<?php 
                echo $form_base_name;
                ?>
[podcasts][{{id}}][type]" class="podlove-podcast-dropdown">
									<option value="wplist" selected><?php 
                echo __('WordPress Network', 'podlove');
                ?>
</option>
								</select>
							</td>
							<td class="podlove-podcast-value"></td>
							<td>
								<span class="podcast_remove">
									<i class="clickable podlove-icon-remove"></i>
								</span>
							</td>
							<td class="move column-move"><i class="reorder-handle podlove-icon-reorder"></i></td>
						</tr>
						</script>
						<script type="text/template" id="podcast-select-type-wplist">
						<select name="<?php 
                echo $form_base_name;
                ?>
[podcasts][{{id}}][podcast]" class="podlove-podcast chosen-image">
							<option>— <?php 
                echo __('Select Podcast', 'podlove');
                ?>
 —</option>
							<?php 
                foreach (Network::podcasts() as $blog_id => $podcast) {
                    if ($podcast->title) {
                        printf("<option value='%s' data-img-src='%s'>%s</option>\n", $blog_id, $podcast->cover_art()->setWidth(45)->url(), $podcast->title);
                    }
                }
                ?>
						</select>
						</script>
					</div>

					<script type="text/javascript">

						var PODLOVE = PODLOVE || {};

						(function($) {
							var i = 0;
							var existing_podcasts = <?php 
                echo is_null($list->podcasts) ? "[]" : $list->podcasts;
                ?>
;
							var podcasts = [];

							function update_chosen() {
								$(".chosen").chosen();
								$(".chosen-image").chosenImage();
							}

							function podcast_dropdown_handler() {
								$('select.podlove-podcast-dropdown').change(function() {
									row = $(this).closest("tr");
									podcast_source = $(this).val();

									// Check for empty podcast / for new field
									if (podcast_source === '') {
										row.find(".podlove-podcast-value").html(""); // Empty podcast column and hide edit button
										row.find(".podlove-podcast-edit").hide();
										return;
									}

									if (!row.find(".podlove-podcast").length) {
										template_id = "#podcast-select-type-" + podcast_source;
										template = $( template_id ).html();
										template = template.replace(/\{\{id\}\}/g, row.data('id') );

										row.find(".podlove-podcast-value").html( template );
										update_chosen();

										i++; // continue using "i" which was already used to add the existing contributions
									}

								});
							}

							$(document).ready(function() {
								$("#podcast_lists table").podloveDataTable({
									rowTemplate: "#podcast-row-template",
									deleteHandle: ".podcast_remove",
									sortableHandle: ".reorder-handle",
									addRowHandle: "#add_new_podcast",
									data: existing_podcasts,
									dataPresets: podcasts,
									onRowLoad: function(o) {
										template_id = "#podcast-select-type-" + o.entry.type;
										template = $( template_id ).html();
										row_as_object = $(o.row)
										
										row_as_object.find(".podlove-podcast-value").html( template );
										row_as_object.find('select.podlove-podcast-dropdown option[value="' + o.entry.type + '"]').attr('selected', 'selected');

										switch ( o.entry.type ) {
											default: case 'wplist':
												row_as_object.find('select.podlove-podcast option[value="' + o.entry.podcast + '"]').attr('selected', true);
											break;
										}

										o.row = row_as_object[0].outerHTML.replace(/\{\{id\}\}/g, i);

										i++;
									},
									onRowAdd: function(o) {
										o.row = o.row.replace(/\{\{id\}\}/g, i);

										
										row = $(".podcasts_table_body tr:last .podlove-podcast-dropdown").focus();

										podcast_dropdown_handler();
										update_chosen();
										row.change();
									},
									onRowDelete: function(tr) {
										
									}
								});
							});

						}(jQuery));

					</script>
					<?php 
            }));
        });
    }