function podlove_episode_license_add_js()
{
    $episode = Model\Episode::find_or_create_by_post_id(get_the_ID());
    ?>
	<script type="text/javascript">
	PODLOVE.License({
		plugin_url: "<?php 
    echo \Podlove\PLUGIN_URL;
    ?>
",

		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($episode->license_url));
    ?>
'),

		license_name_field_id: '#_podlove_meta_license_name',
		license_url_field_id:  '#_podlove_meta_license_url'
	});
	</script>
	<?php 
}
    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 
    }
 public static function get_url_from_license($license)
 {
     $versions = \Podlove\License\version_per_country_cc();
     if (!is_array($license)) {
         return;
     }
     if ($license['version'] == "cc0") {
         return "http://creativecommons.org/publicdomain/zero/1.0/";
     }
     if ($license['version'] == "pdmark") {
         return "http://creativecommons.org/publicdomain/mark/1.0/";
     }
     if ($license['version'] == "cc4") {
         return 'http://creativecommons.org/licenses/by' . ($license['commercial_use'] == 'no' ? '-nc' : '') . ($license['modification'] == 'yes' ? '/' : ($license['modification'] == 'no' ? '-nd/' : '-sa/')) . "4.0";
     }
     return 'http://creativecommons.org/licenses/by' . ($license['commercial_use'] == 'no' ? '-nc' : '') . ($license['modification'] == 'yes' ? '/' : ($license['modification'] == 'no' ? '-nd/' : '-sa/')) . $versions[$license['jurisdiction']]['version'] . ($license['jurisdiction'] == 'international' ? '/' : '/' . $license['jurisdiction'] . '/') . 'deed.en';
 }