private function contributor_form($form_args, $contributor, $action)
 {
     $general_fields = ['realname' => ['field_type' => 'string', 'field_options' => array('label' => __('Real name', 'podlove'), 'html' => array('class' => 'podlove-check-input required podlove-contributor-field'))], 'publicname' => ['field_type' => 'string', 'field_options' => array('label' => __('Public name', 'podlove'), 'description' => 'The Public Name will be used for public mentions. E.g. the Web Player. If left blank, it defaults to the "real name".', 'html' => array('class' => 'podlove-check-input podlove-contributor-field'))], 'nickname' => ['field_type' => 'string', 'field_options' => array('label' => __('Nickname', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field'))], 'gender' => ['field_type' => 'select', 'field_options' => array('label' => __('Gender', 'podlove'), 'options' => array('female' => 'Female', 'male' => 'Male', 'none' => 'Not attributed'))], 'privateemail' => ['field_type' => 'string', 'field_options' => array('label' => __('Contact email', 'podlove'), 'description' => 'The provided email will be used for internal purposes only.', 'html' => array('class' => 'podlove-contributor-field podlove-check-input', 'data-podlove-input-type' => 'email'))], 'avatar' => ['field_type' => 'avatar', 'field_options' => array('label' => __('Avatar', 'podlove'), 'description' => 'Either a Gravatar email adress or a URL.', 'html' => array('class' => 'podlove-contributor-field podlove-check-input', 'data-podlove-input-type' => 'avatar'))], 'slug' => ['field_type' => 'string', 'field_options' => array('label' => __('ID', 'podlove'), 'description' => 'The ID will be used as in internal identifier for e.g. shortcodes.', 'html' => array('class' => 'podlove-check-input required podlove-contributor-field'))], 'guid' => ['field_type' => 'string', 'field_options' => array('label' => __('URI', 'podlove'), 'description' => __('An URI acts as a globally unique ID to identify contributors across podcasts on the internet.', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field'))], 'visibility' => ['field_type' => 'radio', 'field_options' => array('label' => __('Visibility', 'podlove'), 'options' => array('1' => 'Yes, the contributor’s information will be visible for the public (e.g. displayed in the Contributor Table).<br />', '0' => 'No, the contributor’s information will be private and not visible for anybody.'), 'default' => '1')]];
     $general_fields = apply_filters('podlove_contributors_general_fields', $general_fields);
     $affiliation_fields = ['organisation' => ['field_type' => 'string', 'field_options' => ['label' => __('Organisation', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field')]], 'department' => ['field_type' => 'string', 'field_options' => ['label' => __('Department', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field')]], 'jobtitle' => ['field_type' => 'string', 'field_options' => ['label' => __('Job Title', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field')]]];
     $affiliation_fields = apply_filters('podlove_contributors_affiliation_fields', $affiliation_fields);
     $form_sections = ['general' => ['title' => __('General', 'podlove'), 'fields' => $general_fields], 'affiliation' => ['title' => __('Affiliation', 'podlove'), 'fields' => $affiliation_fields]];
     $form_sections = apply_filters('podlove_contributor_settings_sections', $form_sections);
     $contributor = \Podlove\Modules\Contributors\Model\Contributor::find_by_id($_REQUEST['contributor']);
     switch ($_GET["action"]) {
         case 'new':
             $action = 'create';
             break;
         case 'edit':
             $action = 'save';
             break;
         default:
             $action = 'delete';
             break;
     }
     \Podlove\Form\build_for($contributor, $form_args, function ($form) use($form_sections) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $contributor = $form->object;
         foreach ($form_sections as $form_section) {
             $wrapper->subheader($form_section['title']);
             foreach ($form_section['fields'] as $field_name => $field) {
                 call_user_func_array([$wrapper, $field['field_type']], [$field_name, $field['field_options']]);
             }
         }
     });
 }
    public function register_page()
    {
        $podcast = \Podlove\Model\Podcast::get();
        $form_attributes = array('context' => 'podlove_flattr', 'action' => $this->get_url());
        ?>
		<p>
			<?php 
        echo __('This Flattr account will be associated with your Podcast. Flattr donations for e.g. new episodes
							will be linked with this account.', 'podlove');
        ?>
		</p>
		<style type="text/css">
		/* add linebreak after each radio button+label */
		input[type="radio"] + label::after {
		  content: " ";
		  display: block;
		}
		</style>
		<?php 
        \Podlove\Form\build_for((object) Flattr::get_setting(), $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $podcast = $form->object;
            $wrapper->string('account', ['label' => __('Flattr Account', 'podlove'), 'html' => ['class' => 'regular-text required podlove-check-input']]);
            if (\Podlove\Modules\Base::is_active('contributors')) {
                $wrapper->radio('contributor_shortcode_default', ['label' => __('Default Parameter in Contributors Shortcodes', 'podlove'), 'description' => '<br>' . __('You can override this setting individually by passing along the <code>flattr="yes"</code> or <code>flattr="no"</code> parameter to the shortcodes.', 'podlove'), 'options' => ['yes' => 'yes, show Flattr buttons by default', 'no' => 'no, do not show Flattr buttons by default'], 'default' => 'no']);
            }
        });
    }
    public function register_page()
    {
        $podcast = \Podlove\Model\Podcast::get();
        $form_attributes = array('context' => 'podlove_podcast', 'action' => $this->get_url());
        ?>
		<p>
			<?php 
        echo __('You may provide additional information about your podcast that may or may not be used by podcast directories like iTunes.', 'podlove');
        ?>
		</p>
		<?php 
        \Podlove\Form\build_for($podcast, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $podcast = $form->object;
            $wrapper->string('author_name', array('label' => __('Author Name', 'podlove'), 'description' => __('Publicly displayed in Podcast directories.', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input')));
            $wrapper->string('publisher_name', array('label' => __('Publisher Name', 'podlove'), 'description' => __('', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input')));
            $wrapper->string('publisher_url', array('label' => __('Publisher URL', 'podlove'), 'description' => __('', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input', 'data-podlove-input-type' => 'url')));
            $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 podlove-check-input')));
            $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 podlove-check-input', 'data-podlove-input-type' => 'email')));
            $wrapper->string('keywords', array('label' => __('Keywords', 'podlove'), 'description' => __('List of keywords. Separate with commas.', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input')));
            $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('explicit', array('label' => __('Explicit Content?', 'podlove'), 'description' => __('', 'podlove'), 'type' => 'checkbox', 'options' => array(0 => 'no', 1 => 'yes', 2 => 'clean')));
            $wrapper->checkbox('complete', array('label' => __('Podcast complete?', 'podlove'), 'description' => __('Shows that this Podcast is finished and no further episodes will be added.', 'podlove'), 'default' => false));
        });
    }
Example #4
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 
    }
    public function register_page()
    {
        $podcast = \Podlove\Model\Podcast::get();
        $form_attributes = array('context' => 'podlove_podcast', 'action' => $this->get_url(), 'is_table' => false);
        ?>
		<p>
			<?php 
        echo sprintf(__('These are the current social media acccount of your podcast. Display this list using the shortcode %s', 'podlove'), '<code>[podlove-podcast-social-media-list]</code>');
        ?>
		</p>
		<?php 
        \Podlove\Form\build_for($podcast, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\DivWrapper($form);
            $podcast = $form->object;
            $wrapper->callback('services', array('callback' => array(__CLASS__, 'podcast_form_extension_form')));
        });
    }
    public function register_page()
    {
        $podcast = \Podlove\Model\Podcast::get();
        $form_attributes = array('context' => 'podlove_podcast', 'action' => $this->get_url());
        ?>
		<p>
			<?php 
        echo __('The Podlove Publisher expects all your media files to be in the same <strong>Upload Location</strong>.
					It should be a publicly readable directory containing all media files.
					You should not create a separate directory for each episode.', 'podlove');
        ?>
		</p>
		<?php 
        \Podlove\Form\build_for($podcast, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $podcast = $form->object;
            $wrapper->string('media_file_base_uri', array('label' => __('Upload Location', 'podlove'), 'description' => __('Example: http://cdn.example.com/pod/', 'podlove'), 'html' => array('class' => 'regular-text required podlove-check-input', 'data-podlove-input-type' => 'url')));
        });
    }
 public function createObject()
 {
     $this->page = new \Podlove\Modules\Contributors\Settings\GenericEntitySettings('role', '\\Podlove\\Modules\\Contributors\\Model\\ContributorRole');
     $this->page->set_form(function ($form_args, $role, $action) {
         \Podlove\Form\build_for($role, $form_args, function ($form) {
             $wrapper = new \Podlove\Form\Input\TableWrapper($form);
             $wrapper->string('title', array('label' => __('Role Title', 'podlove'), 'html' => array('class' => 'required')));
             $wrapper->string('slug', array('label' => __('Role Slug', 'podlove'), 'html' => array('class' => 'required')));
         });
     });
     $this->page->enable_tabs('roles');
     $this->page->set_labels(array('delete_confirm' => __('You selected to delete the role "%s". Please confirm this action.', 'podlove'), 'add_new' => __('Add new role', 'podlove'), 'edit' => __('Edit role', 'podlove')));
     add_action('podlove_settings_role_view', function () {
         echo __('Use roles to assign a certain type of activity to a single contributor independent of any assigned group. A role might be helpful to mark somebody as being the main presenter of a show or a guest. Use roles sparingly as most of the times, groups might the more valuable way to structure contributors.', 'podlove');
         $table = new \Podlove\Modules\Contributors\Contributor_Role_List_Table();
         $table->prepare_items();
         $table->display();
     });
 }
 public function createObject()
 {
     $this->page = new \Podlove\Modules\Contributors\Settings\GenericEntitySettings('group', '\\Podlove\\Modules\\Contributors\\Model\\ContributorGroup');
     $this->page->set_form(function ($form_args, $group, $action) {
         \Podlove\Form\build_for($group, $form_args, function ($form) {
             $wrapper = new \Podlove\Form\Input\TableWrapper($form);
             $wrapper->string('title', array('label' => __('Group Title', 'podlove'), 'html' => array('class' => 'required')));
             $wrapper->string('slug', array('label' => __('Group Slug', 'podlove'), 'html' => array('class' => 'required')));
         });
     });
     $this->page->enable_tabs('groups');
     $this->page->set_labels(array('delete_confirm' => __('You selected to delete the group "%s". Please confirm this action.', 'podlove'), 'add_new' => __('Add new group', 'podlove'), 'edit' => __('Edit group', 'podlove')));
     add_action('podlove_settings_group_view', function () {
         echo sprintf(__('Use groups to divide contributors by type of participation. Create a group for teams working together or for a supporting community. Team members can be displayed separately by using the %sappropriate option%s to select a group.', 'podlove'), '<a href="http://docs.podlove.org/ref/template-tags.html#contributors" target="_blank">', '</a>');
         $table = new \Podlove\Modules\Contributors\Contributor_Group_List_Table();
         $table->prepare_items();
         $table->display();
     });
 }
Example #9
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()));
        });
    }
    /**
     * Meta Box Template
     */
    public static function post_type_meta_box_callback($post)
    {
        $post_id = $post->ID;
        $podcast = Model\Podcast::get();
        $episode = Model\Episode::find_or_create_by_post_id($post_id);
        wp_nonce_field(\Podlove\PLUGIN_FILE, 'podlove_noncename');
        ?>

		<?php 
        do_action('podlove_episode_meta_box_start');
        ?>

		<input type="hidden" name="show-media-file-base-uri" value="<?php 
        echo $podcast->media_file_base_uri;
        ?>
" />
		<div class="podlove-div-wrapper-form">
			<?php 
        $form_args = array('context' => '_podlove_meta', 'submit_button' => false, 'form' => false, 'is_table' => false);
        $form_data = self::get_form_data($episode);
        \Podlove\Form\build_for($episode, $form_args, function ($form) use($podcast, $form_data) {
            $wrapper = new \Podlove\Form\Input\DivWrapper($form);
            $episode = $form->object;
            foreach ($form_data as $entry) {
                $wrapper->{$entry['type']}($entry['key'], $entry['options']);
            }
        });
        ?>
		</div>

		<?php 
        do_action('podlove_episode_meta_box_end');
        ?>

		<?php 
    }
    private function view_template()
    {
        echo sprintf(__('Episode Templates are an easy way to keep the same structure in all your episodes.
				You can use %sShortcodes%s as well as %sPublisher Template Tags%s to customize your episodes.<br>
				Please read the %sTemplating Guide%s to get started.
				', 'podlove'), '<a href="http://docs.podlove.org/ref/shortcodes.html" target="_blank">', '</a>', '<a href="http://docs.podlove.org/reference/template-tags/" target="_blank">', '</a>', '<a href="http://docs.podlove.org/guides/understanding-templates/" target="_blank">', '</a>');
        ?>
		<div id="template-editor">
			<div class="navigation">
				<ul>
					<?php 
        foreach (Model\Template::all() as $template) {
            ?>
						<li>
							<a href="#" data-id="<?php 
            echo $template->id;
            ?>
">
								<span class="filename"><?php 
            echo $template->title;
            ?>
</span>&nbsp;
							</a>
						</li>
					<?php 
        }
        ?>
				</ul>
				<div class="add">
					<a href="#">+ add new template</a>
				</div>
			</div>
			<div class="editor">
				<div class="toolbar">
					<div class="actions">
						<a href="#" class="delete">delete</a>
						<a href="#" class="save button button-primary">Save</a>
					</div>
					<div class="title">
						<input type="text">
					</div>
					<div class="clear"></div>
				</div>
				<div class="editor-wrapper">
					<div class="main" id="ace-editor"></div>
					<div id="fullscreen" class="fullscreen-on fullscreen-button"></div>
				</div>
			</div>
			<div class="clear"></div>
		</div>

		<h3><?php 
        echo __('Insert templates to content automatically', 'podlove');
        ?>
</h3>
		<form method="post" action="options.php">
			<?php 
        settings_fields(Templates::$pagehook);
        $template_assignment = Model\TemplateAssignment::get_instance();
        $form_attributes = array('context' => 'podlove_template_assignment', 'form' => false);
        \Podlove\Form\build_for($template_assignment, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $templates = array(0 => __('Don\'t insert automatically', 'podlove'));
            foreach (Model\Template::all_globally() as $template) {
                $templates[$template->title] = $template->title;
            }
            $wrapper->select('top', array('label' => __('Insert at top', 'podlove'), 'options' => $templates, 'please_choose' => false));
            $wrapper->select('bottom', array('label' => __('Insert at bottom', 'podlove'), 'options' => $templates, 'please_choose' => false));
        });
        ?>
		</form>
		<?php 
    }
Example #13
0
    public function __construct($handle)
    {
        Settings::$pagehook = add_submenu_page($handle, 'Settings', 'Settings', 'administrator', 'podlove_settings_settings_handle', array($this, 'page'));
        add_settings_section('podlove_settings_general', __('General Settings', 'podlove'), function () {
            /* section head html */
        }, Settings::$pagehook);
        add_settings_field('podlove_setting_merge_episodes', sprintf('<label for="merge_episodes">%s</label>', __('Display episodes on front page together with blog posts', 'podlove')), function () {
            ?>
				<input name="podlove[merge_episodes]" id="merge_episodes" type="checkbox" <?php 
            checked(\Podlove\get_setting('merge_episodes'), 'on');
            ?>
>
				<?php 
        }, Settings::$pagehook, 'podlove_settings_general');
        add_settings_field('podlove_setting_hide_wp_feed_discovery', sprintf('<label for="hide_wp_feed_discovery">%s</label>', __('Hide default WordPress Feeds for blog and comments (no auto-discovery).', 'podlove')), function () {
            ?>
				<input name="podlove[hide_wp_feed_discovery]" id="hide_wp_feed_discovery" type="checkbox" <?php 
            checked(\Podlove\get_setting('hide_wp_feed_discovery'), 'on');
            ?>
>
				<?php 
        }, Settings::$pagehook, 'podlove_settings_general');
        add_settings_field('podlove_setting_custom_episode_slug', sprintf('<label for="custom_episode_slug">%s</label>', __('URL segment prefix for podcast episode posts. Leave empty to remove the prefix.', 'podlove')), function () {
            ?>
				<input name="podlove[custom_episode_slug]" id="custom_episode_slug" type="text" value="<?php 
            echo \Podlove\get_setting('custom_episode_slug');
            ?>
">
				<p>
					<span class="description"><?php 
            echo __('Must be a suitable URL part: lowercase characters, numbers and hyphens.', 'podlove');
            ?>
</span>
				</p>
				<?php 
        }, Settings::$pagehook, 'podlove_settings_general');
        add_settings_section('podlove_settings_modules', __('Modules', 'podlove'), function () {
            /* section head html */
        }, Settings::$pagehook);
        $modules = \Podlove\Modules\Base::get_all_module_names();
        foreach ($modules as $module_name) {
            $class = \Podlove\Modules\Base::get_class_by_module_name($module_name);
            if (!class_exists($class)) {
                continue;
            }
            $module = $class::instance();
            $module_options = $module->get_registered_options();
            if ($module_options) {
                register_setting(Settings::$pagehook, $module->get_module_options_name());
            }
            add_settings_field('podlove_setting_module_' . $module_name, sprintf('<label for="' . $module_name . '">%s</label>', $module->get_module_name()), function () use($module, $module_name, $module_options) {
                ?>
					<label for="<?php 
                echo $module_name;
                ?>
">
						<input name="podlove_active_modules[<?php 
                echo $module_name;
                ?>
]" id="<?php 
                echo $module_name;
                ?>
" type="checkbox" <?php 
                checked(\Podlove\Modules\Base::is_active($module_name), true);
                ?>
>
						<?php 
                echo $module->get_module_description();
                ?>
					</label>
					<?php 
                if ($module_options) {
                    ?>
<h4><?php 
                    echo __('Settings');
                    ?>
</h4><?php 
                    // prepare settings object because form framework expects an object
                    $settings_object = new \stdClass();
                    foreach ($module_options as $key => $value) {
                        $settings_object->{$key} = $module->get_module_option($key);
                    }
                    \Podlove\Form\build_for($settings_object, array('context' => $module->get_module_options_name(), 'submit_button' => false), function ($form) use($module_options) {
                        $wrapper = new \Podlove\Form\Input\TableWrapper($form);
                        foreach ($module_options as $module_option_name => $args) {
                            call_user_func_array(array($wrapper, $args['input_type']), array($module_option_name, $args['args']));
                        }
                    });
                }
            }, Settings::$pagehook, 'podlove_settings_modules');
        }
        register_setting(Settings::$pagehook, 'podlove');
        register_setting(Settings::$pagehook, 'podlove_active_modules');
    }
    public function register_page()
    {
        $podcast = \Podlove\Model\Podcast::get();
        $form_attributes = array('context' => 'podlove_podcast', 'action' => $this->get_url());
        \Podlove\Form\build_for($podcast, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $podcast = $form->object;
            $podcast = \Podlove\Model\Podcast::get();
            $wrapper->string('license_name', array('label' => __('License Name', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input')));
            $wrapper->string('license_url', array('label' => __('License URL', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input', 'data-podlove-input-type' => 'url'), 'description' => __('Example: http://creativecommons.org/licenses/by/3.0/', 'podlove')));
            ?>
				
				<tr class="row_podlove_cc_license_selector_toggle">
					<th></th>
					<td>
						<span id="podlove_cc_license_selector_toggle">
							<span class="_podlove_episode_list_triangle">&#9658;</span>
							<span class="_podlove_episode_list_triangle_expanded">&#9660;</span>
							License Selector
						</span>
					</td>
				</tr>
				<tr class="row_podlove_cc_license_selector">
					<th></th>
					<td>
						<div>
							<label for="license_cc_version" class="podlove_cc_license_selector_label">Version</label>
							<select id="license_cc_version">
								<option value="cc0">Public Domain</option>
								<option value="pdmark">Public Domain Mark</option>
								<option value="cc3">Creative Commons 3.0 and earlier</option>
								<option value="cc4">Creative Commons 4.0</option>
							</select>
						</div>
						<div class="podlove-hide">
							<label for="license_cc_allow_modifications" class="podlove_cc_license_selector_label">Allow modifications of your work?</label>
							<select id="license_cc_allow_modifications">
								<option value="yes">Yes</option>
								<option value="yesbutshare">Yes, as long as others share alike</option>
								<option value="no">No</option>
							</select>
						</div>
						<div class="podlove-hide">
							<label for="license_cc_allow_commercial_use" class="podlove_cc_license_selector_label">Allow commercial uses of your work?</label>
							<select id="license_cc_allow_commercial_use">
								<option value="yes">Yes</option>
								<option value="no">No</option>
							</select>
						</div>
						<div class="podlove-hide">
							<label for="license_cc_license_jurisdiction" class="podlove_cc_license_selector_label">License Jurisdiction</label>
							<select id="license_cc_license_jurisdiction">
								<?php 
            foreach (\Podlove\License\locales_cc() as $locale_key => $locale_description) {
                echo "<option value='" . $locale_key . "' " . ($locale_key == 'international' ? "selected='selected'" : '') . ">" . $locale_description . "</option>\n";
            }
            ?>
			
							</select>
						</div>
					</td>
				</tr>
				<tr class="row_podlove_podcast_license_preview">
					<th scope="row" valign="top">
							<label for="podlove_podcast_subtitle">License Preview</label>
					</th>
					<td>
						<p class="podlove_podcast_license_image"></p>
						<div class="podlove_license">
							<p>
								This work is licensed under the 
								<a class="podlove-license-link" rel="license" href=""></a>.
							</p>
						</div>
					</td>
				</tr>
			<?php 
        });
        ?>
		<script type="text/javascript">
		PODLOVE.License({
			plugin_url: "<?php 
        echo \Podlove\PLUGIN_URL;
        ?>
",

			types: JSON.parse('<?php 
        echo json_encode(\Podlove\License\locales_cc());
        ?>
'),
			locales: JSON.parse('<?php 
        echo json_encode(\Podlove\License\locales_cc());
        ?>
'),
			versions: JSON.parse('<?php 
        echo json_encode(\Podlove\License\version_per_country_cc());
        ?>
'),
			license: JSON.parse('<?php 
        echo json_encode(\Podlove\Model\License::get_license_from_url($podcast->license_url));
        ?>
'),

			license_name_field_id: '#podlove_podcast_license_name',
			license_url_field_id: '#podlove_podcast_license_url'
		});

		</script>
		<?php 
    }
Example #15
0
 private function form_template($format, $action, $button_text = NULL)
 {
     \Podlove\Form\build_for($format, array('context' => 'podlove_file_type', 'hidden' => array('file_type' => $format->id, 'action' => $action)), function ($form) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $wrapper->string('name', array('label' => __('Name', 'podlove'), 'description' => ''));
         $wrapper->select('type', array('label' => __('Document Type', 'podlove'), 'options' => array('audio' => __('Audio', 'podlove'), 'video' => __('Video', 'podlove'), 'ebook' => __('eBook', 'podlove'), 'image' => __('Image', 'podlove'), 'chapters' => __('Chapters', 'podlove'))));
         $wrapper->string('mime_type', array('label' => __('Format Mime Type', 'podlove'), 'description' => __('Example: audio/mp4', 'podlove')));
         $wrapper->string('extension', array('label' => __('Format Extension', 'podlove'), 'description' => __('Example: m4a', 'podlove')));
     });
 }
 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')]);
     });
 }
Example #17
0
 private function form_template($feed, $action, $button_text = NULL)
 {
     $form_args = array('context' => 'podlove_feed', 'hidden' => array('feed' => $feed->id, 'action' => $action));
     \Podlove\Form\build_for($feed, $form_args, function ($form) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $feed = $form->object;
         $episode_assets = \Podlove\Model\EpisodeAsset::all();
         $assets = array();
         foreach ($episode_assets as $asset) {
             $assets[$asset->id] = $asset->title;
         }
         $wrapper->string('name', array('label' => __('Feed Title', 'podlove'), 'description' => __('Some podcast clients may display this title to describe the feed content.', 'podlove'), 'html' => array('class' => 'regular-text required')));
         $wrapper->checkbox('discoverable', array('label' => __('Discoverable?', 'podlove'), 'description' => __('Embed a meta tag into the head of your site so browsers and feed readers will find the link to the feed.', 'podlove'), 'default' => true));
         // TODO: update url
         $wrapper->string('slug', array('label' => __('Slug', 'podlove'), 'description' => $feed ? sprintf(__('Feed identifier. URL: %s', 'podlove'), $feed->get_subscribe_url()) : '', 'html' => array('class' => 'regular-text required')));
         $wrapper->radio('format', array('label' => __('Format', 'podlove'), 'options' => array('rss' => 'RSS', 'atom' => 'Atom'), 'default' => 'rss'));
         $wrapper->select('episode_asset_id', array('label' => __('Episode Media File', 'podlove'), 'options' => $assets, 'html' => array('class' => 'required')));
         $wrapper->string('itunes_feed_id', array('label' => __('iTunes Feed ID', 'podlove'), 'description' => __('Is used to generate a link to the iTunes directory.', 'podlove'), 'html' => array('class' => 'regular-text')));
         // todo: add PING url; see feedburner doc
         $wrapper->string('redirect_url', array('label' => __('Redirect Url', 'podlove'), 'description' => __('e.g. Feedburner URL', 'podlove'), 'html' => array('class' => 'regular-text')));
         $wrapper->checkbox('enable', array('label' => __('Allow Submission to Directories', 'podlove'), 'description' => __('Allow this feed to appear in podcast directories.', 'podlove'), 'default' => true));
         // TODO: choose description format: empty, simple, full-force
         $wrapper->checkbox('show_description', array('label' => __('Include Description?', 'podlove'), 'description' => __('You may want to hide the episode descriptions to reduce the feed file size.', 'podlove'), 'default' => true));
         // todo include summary?
         $wrapper->string('limit_items', array('label' => __('Limit Items', 'podlove'), 'description' => __('A feed only displays the most recent episodes. Define the amount. Leave empty to use the WordPress default.', 'podlove'), 'html' => array('class' => 'regular-text')));
     });
 }
 private function form_template($format, $action, $button_text = NULL)
 {
     $form_args = array('context' => 'podlove_file_type', 'hidden' => array('file_type' => $format->id, 'action' => $action, 'podlove_tab' => $_REQUEST['podlove_tab']), '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($format, $form_args, function ($form) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $types = array();
         foreach (\Podlove\Model\FileType::get_types() as $type) {
             $types[$type] = $type;
         }
         $wrapper->string('name', array('label' => __('Name', 'podlove'), 'html' => array('class' => 'podlove-check-input'), 'description' => ''));
         $wrapper->select('type', array('label' => __('Document Type', 'podlove'), 'options' => $types));
         $wrapper->string('mime_type', array('label' => __('Format Mime Type', 'podlove'), 'html' => array('class' => 'podlove-check-input'), 'description' => __('Example: audio/mp4', 'podlove')));
         $wrapper->string('extension', array('label' => __('Format Extension', 'podlove'), 'html' => array('class' => 'podlove-check-input'), 'description' => __('Example: m4a', '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 
            }));
        });
    }
Example #20
0
    private function form_template($episode_asset, $action, $button_text = NULL)
    {
        $raw_formats = \Podlove\Model\FileType::all();
        $formats = array();
        foreach ($raw_formats as $format) {
            $formats[$format->id] = array('title' => $format->title(), 'extension' => $format->extension);
        }
        $format_optionlist = array_map(function ($f) {
            return $f['title'];
        }, $formats);
        $form_args = array('context' => 'podlove_episode_asset', 'hidden' => array('episode_asset' => $episode_asset->id, 'action' => $action), 'attributes' => array('id' => 'podlove_episode_assets'));
        \Podlove\Form\build_for($episode_asset, $form_args, function ($form) use($format_optionlist) {
            $f = new \Podlove\Form\Input\TableWrapper($form);
            $f->select('file_type_id', array('label' => __('File Format', 'podlove'), 'description' => __('', 'podlove'), 'options' => $format_optionlist));
            $f->string('title', array('label' => __('Title', 'podlove'), 'description' => __('Description to identify the media file type to the user in download buttons.', 'podlove'), 'html' => array('class' => 'regular-text required')));
            $f->string('url_template', array('label' => __('URL Template', 'podlove'), 'description' => sprintf(__('Preview: %s'), '<span class="url_template_preview"></span><br/>', 'podlove'), 'html' => array('class' => 'large-text required'), 'default' => '%media_file_base_url%%episode_slug%.%format_extension%'));
            $f->checkbox('downloadable', array('label' => __('Downloadable', 'podlove'), 'description' => sprintf('Allow downloads for users.', 'podlove'), 'default' => true));
        });
        // hidden fields for JavaScript
        ?>
		<input type="hidden" id="podlove_show_media_file_base_uri" value="<?php 
        echo Model\Podcast::get_instance()->media_file_base_uri;
        ?>
">
		<?php 
    }
    public function __construct($handle)
    {
        Modules::$pagehook = add_submenu_page($handle, 'Modules', 'Modules', 'administrator', 'podlove_settings_modules_handle', array($this, 'page'));
        $this->init_page_documentation(self::$pagehook);
        add_settings_section('podlove_settings_modules', __('', 'podlove'), function () {
            /* section head html */
        }, Modules::$pagehook);
        $grouped_modules = array();
        $modules = \Podlove\Modules\Base::get_all_module_names();
        foreach ($modules as $module_name) {
            $class = \Podlove\Modules\Base::get_class_by_module_name($module_name);
            if (!class_exists($class)) {
                continue;
            }
            if ($class::is_core()) {
                continue;
            }
            $module = $class::instance();
            $module_options = $module->get_registered_options();
            if ($group = $module->get_module_group()) {
                add_settings_section('podlove_setting_module_group_' . $group, ucwords($group), function () {
                }, Modules::$pagehook);
            }
            if ($module_options) {
                register_setting(Modules::$pagehook, $module->get_module_options_name());
            }
            add_settings_field('podlove_setting_module_' . $module_name, sprintf('<label for="' . $module_name . '">%s</label>', $module->get_module_name()), function () use($module, $module_name, $module_options) {
                ?>
					<label for="<?php 
                echo $module_name;
                ?>
">
						<input name="podlove_active_modules[<?php 
                echo $module_name;
                ?>
]" id="<?php 
                echo $module_name;
                ?>
" type="checkbox" <?php 
                checked(\Podlove\Modules\Base::is_active($module_name), true);
                ?>
>
						<?php 
                echo $module->get_module_description();
                ?>
					</label>
					<?php 
                do_action('podlove_module_before_settings_' . $module_name);
                if ($module_options) {
                    ?>
<h4><?php 
                    echo __('Settings');
                    ?>
</h4><?php 
                    // prepare settings object because form framework expects an object
                    $settings_object = new \stdClass();
                    foreach ($module_options as $key => $value) {
                        $settings_object->{$key} = $module->get_module_option($key);
                    }
                    \Podlove\Form\build_for($settings_object, array('context' => $module->get_module_options_name(), 'submit_button' => false, 'form' => false), function ($form) use($module_options) {
                        $wrapper = new \Podlove\Form\Input\TableWrapper($form);
                        foreach ($module_options as $module_option_name => $args) {
                            call_user_func_array(array($wrapper, $args['input_type']), array($module_option_name, $args['args']));
                        }
                    });
                }
                do_action('podlove_module_after_settings_' . $module_name);
            }, Modules::$pagehook, $group ? 'podlove_setting_module_group_' . $group : 'podlove_settings_modules');
        }
        register_setting(Modules::$pagehook, 'podlove_active_modules');
    }
    private function form_template($episode_asset, $action, $button_text = NULL)
    {
        $raw_formats = \Podlove\Model\FileType::all();
        $formats = array();
        foreach ($raw_formats as $format) {
            $formats[$format->id] = array('title' => $format->title(), 'name' => $format->name, 'extension' => $format->extension, 'type' => $format->type);
        }
        $format_optionlist = array_map(function ($f) {
            return array('value' => $f['title'], 'attributes' => 'data-type="' . $f['type'] . '" data-extension="' . $f['extension'] . '" data-name="' . $f['name'] . '"');
        }, $formats);
        $form_args = array('context' => 'podlove_episode_asset', 'hidden' => array('episode_asset' => $episode_asset->id, 'action' => $action), 'attributes' => array('id' => 'podlove_episode_assets'), '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($episode_asset, $form_args, function ($form) use($format_optionlist) {
            $f = new \Podlove\Form\Input\TableWrapper($form);
            if ($form->object->file_type_id) {
                $current_file_type = Model\FileType::find_by_id($form->object->file_type_id)->type;
            } else {
                $current_file_type = '';
            }
            ?>
			<tr class="row_podlove_episode_asset_type">
				<th scope="row" valign="top">
					<label for="podlove_episode_asset_type"><?php 
            echo __('Asset Type', 'podlove');
            ?>
</label>
				</th>
				<td>
					<select name="podlove_episode_asset_type" id="podlove_episode_asset_type">
						<option><?php 
            echo __('Please choose ...', 'podlove');
            ?>
</option>
						<?php 
            foreach (Model\FileType::get_types() as $type) {
                ?>
							<option value="<?php 
                echo $type;
                ?>
" <?php 
                selected($type, $current_file_type);
                ?>
><?php 
                echo $type;
                ?>
</option>	
						<?php 
            }
            ?>
					</select>
					<div id="option_storage" style="display:none"></div>
				</td>
			</tr>
			<?php 
            $f->select('file_type_id', array('label' => __('File Format', 'podlove'), 'description' => __('', 'podlove'), 'options' => $format_optionlist));
            $f->string('title', array('label' => __('Title', 'podlove'), 'description' => __('Description to identify the media file type to the user in download buttons.', 'podlove'), 'html' => array('class' => 'regular-text required podlove-check-input')));
            $f->checkbox('downloadable', array('label' => __('Downloadable', 'podlove'), 'description' => sprintf('Allow downloads for users.', 'podlove'), 'default' => true));
            ?>
			<tr>
				<th colspan="2">
					<h3><?php 
            echo __('Asset File Name', 'podlove');
            ?>
</h3>
				</th>
			</tr>
			<?php 
            $f->string('suffix', array('label' => __('File Name Suffix', 'podlove'), 'description' => __('Optional. Is appended to file name after episode slug.', 'podlove'), 'html' => array('class' => 'regular-text required podlove-check-input')));
            ?>
			<tr class="row_podlove_asset_url_preview">
				<th>
					<?php 
            echo __('URL Preview', 'podlove');
            ?>
				</th>
				<td>
					<div id="url_preview" style="font-size: 1.5em"></div>
					<div id="url_template" style="display: none;"><?php 
            echo Model\Podcast::get()->get_url_template();
            ?>
</div>
				</td>
			</tr>
			<?php 
        });
        // hidden fields for JavaScript
        ?>
		<input type="hidden" id="podlove_show_media_file_base_uri" value="<?php 
        echo Model\Podcast::get()->media_file_base_uri;
        ?>
">
		<?php 
    }
 private function form_template($feed, $action, $button_text = NULL)
 {
     $form_args = array('context' => 'podlove_feed', 'hidden' => array('feed' => $feed->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($feed, $form_args, function ($form) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $feed = $form->object;
         $podcast = \Podlove\Model\Podcast::get();
         $episode_assets = \Podlove\Model\EpisodeAsset::all();
         $assets = array();
         foreach ($episode_assets as $asset) {
             $assets[$asset->id] = $asset->title;
         }
         $wrapper->subheader(__('Basic Settings', 'podlove'));
         $wrapper->select('episode_asset_id', array('label' => __('Episode Media File', 'podlove') . \Podlove\get_help_link('podlove_help_feed_asset'), 'options' => $assets, 'html' => array('class' => 'required')));
         $wrapper->string('name', array('label' => __('Feed Name', 'podlove'), 'description' => __('Some podcast clients may display this title to describe the feed content.', 'podlove'), 'html' => array('class' => 'regular-text required podlove-check-input')));
         $wrapper->checkbox('append_name_to_podcast_title', array('label' => __('Append Feed Name to Podcast title', 'podlove'), 'description' => sprintf(__('Structure of the feed title. Preview: %s', 'podlove'), $podcast->title . '<span id="feed_title_preview_append"></span>'), 'default' => false));
         $wrapper->string('slug', array('label' => __('Slug', 'podlove') . \Podlove\get_help_link('podlove_help_feed_slug'), 'description' => $feed ? sprintf(__('Feed identifier. URL Preview: %s', 'podlove'), '<span id="feed_subscribe_url_preview">' . $feed->get_subscribe_url() . '</span>') : '', 'html' => array('class' => 'regular-text required podlove-check-input')));
         $wrapper->checkbox('discoverable', array('label' => __('Discoverable?', 'podlove'), 'description' => __('Embed a meta tag into the head of your site so browsers and feed readers will find the link to the feed.', 'podlove'), 'default' => true));
         $wrapper->checkbox('embed_content_encoded', array('label' => __('Include HTML Content', 'podlove'), 'description' => __('Include episode show notes in the feed.', 'podlove'), 'default' => false));
         $wrapper->subheader(__('Directory Settings', 'podlove'));
         $wrapper->checkbox('enable', array('label' => __('Allow Submission to Directories', 'podlove'), 'description' => __('Allow this feed to appear in podcast directories.', 'podlove'), 'default' => true));
         do_action('podlove_feeds_directories', $wrapper);
         $wrapper->string('itunes_feed_id', array('label' => __('iTunes Feed ID', 'podlove'), 'description' => __('Is used to generate a link to the iTunes directory.', 'podlove') . ($feed->itunes_feed_id ? ' <a href="http://itunes.apple.com/podcast/id' . $feed->itunes_feed_id . '" target="_blank">' . __('Open in iTunes directory') . '</a>' : ''), 'html' => array('class' => 'regular-text podlove-check-input')));
         $wrapper->subheader(__('Advanced Settings', 'podlove'));
         $wrapper->select('redirect_http_status', array('label' => __('Redirect Method', 'podlove'), 'description' => __('', 'podlove'), 'options' => array('0' => 'Don\'t redirect', '307' => 'Temporary Redirect (HTTP Status 307)', '301' => 'Permanent Redirect (HTTP Status 301)'), 'default' => 0, 'please_choose' => false));
         $wrapper->string('redirect_url', array('label' => __('Redirect Url', 'podlove'), 'description' => __('e.g. Feedburner URL', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input', 'data-podlove-input-type' => 'url')));
         $podcast_settings = get_option('podlove_podcast');
         if ($podcast_settings['limit_items'] < 0) {
             $limit_default = 'No limit';
         } else {
             $limit_default = $podcast_settings['limit_items'];
         }
         $limit_options = array('-2' => __("Use Podlove default (" . $limit_default . ")", 'podlove'), '-1' => __("No limit. Include all items.", 'podlove'), '0' => __('Use WordPress Default', 'podlove') . ' (' . get_option('posts_per_rss') . ')');
         for ($i = 1; $i * 5 <= 100; $i++) {
             $limit_options[$i * 5] = $i * 5;
         }
         $wrapper->select('limit_items', array('label' => __('Limit Items', 'podlove'), 'description' => __('If you have a lot of episodes, you might want to restrict the feed size.', 'podlove'), 'options' => $limit_options, 'please_choose' => false, 'default' => '-2'));
         $wrapper->subheader(__('Protection', 'podlove'));
         $wrapper->checkbox('protected', array('label' => __('Protect feed ', 'podlove'), 'description' => __('The feed will be protected by HTTP Basic Authentication.', 'podlove'), 'default' => false));
         $wrapper->select('protection_type', array('label' => __('Method', 'podlove'), 'description' => __('', 'podlove'), 'options' => array('0' => 'Custom Login', '1' => 'WordPress User database'), 'default' => -1, 'please_choose' => true));
         $wrapper->string('protection_user', array('label' => __('Username', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text required')));
         $wrapper->string('protection_password', array('label' => __('Password', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text required')));
         do_action('podlove_feed_settings_bottom', $wrapper);
     });
 }