private function view_template()
    {
        echo __('Use network templates to share common templates in your podcast sites. 
			They are available in all podcast sites.
			If you define a local template for a template ID that also exists network-wide, the local template takes precedence.', 'podlove');
        $templates = Template::with_network_scope(function () {
            return Template::all();
        });
        ?>

		<div id="template-editor">
			<div class="navigation">
				<ul>
					<?php 
        foreach ($templates 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>
		<?php 
    }
function podlove_get_template_deprecations()
{
    $deprecations = [];
    $deprecation_matcher = ['shortcode' => ['data' => podlove_get_deprecated_shortcodes(), 'matcher' => array_keys(podlove_get_deprecated_shortcodes())], 'template tag' => ['data' => podlove_get_deprecated_template_tags(), 'matcher' => array_keys(podlove_get_deprecated_template_tags())]];
    foreach (\Podlove\Model\Template::all() as $template) {
        foreach ($deprecation_matcher as $deprecated_type => $matcher) {
            foreach ($matcher['matcher'] as $regex) {
                if (preg_match("/" . $regex . "/", $template->content, $matches)) {
                    $deprecations[] = ['context' => ['type' => 'template', 'id' => $template->id], 'deprecated' => ['type' => $deprecated_type, 'content' => $matches[0]], 'instead' => $matcher['data'][$regex]];
                }
            }
        }
    }
    return $deprecations;
}
 /**
  * Returns all local + network templates.
  * 
  * Local template override global templates with same title.
  * 
  * @return array
  */
 public static function all_globally()
 {
     if (!is_multisite()) {
         return Template::all();
     }
     $local = Template::all();
     $global = Template::with_network_scope(function () {
         return Template::all();
     });
     $all = [];
     foreach ($global as $template) {
         $all[$template->title] = $template;
     }
     foreach ($local as $template) {
         $all[$template->title] = $template;
     }
     ksort($all);
     return array_values($all);
 }
    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 
    }