<?php
/**
*
*/

/**
* No direct access.
*/
defined('ABSPATH') or die("Access denied");

// Allow view to enqueue scripts and styles.
$this->enqueueScripts();
$this->enqueueStyles();
$this->suppressPrintScriptsHook();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
<?php wp_print_head_scripts() ?>
<?php wp_print_styles() ?>
    </head>
    <body>
        <div id="cjtoolbox_popup">

            <form id="templates-lookup" class="cjt-form">
<?php            if (empty($this->items)) : ?>

<?php           else : ?>

                <div id="templates-list">

                    <ul>

<?php           foreach (CJTTemplatesLookupView::$displayNames as $type => $displayName) : ?>

                        <li><a href="#templates-type-content-<?php echo $type ?>"><?php echo cssJSToolbox::_($displayName); ?></a></li>

<?php           endforeach; ?>

                    </ul>
                    <?php         foreach ($this->items as $type => $authors) : ?>
                    <div id="templates-type-content-<?php echo $type ?>" class="templates-list">
                        <ul class="authors-list">
<?php
                                foreach ($authors as $author => $templates) :
                                    $authorIdentifier ="{$type}_" . str_replace(array(' ', '-', '_'), '', $author);
?>
                                <li>
                                    <span class="author-name"><?php echo cssJSToolbox::_('User') ?>: <a class="name" href="#<?php echo "{$authorIdentifier}" ?>"><?php echo esc_html($author) ?></a></span>
                                    <ul id="<?php echo "{$authorIdentifier}" ?>-author-templates" class="templates">
<?php                         foreach ($templates as $id => $template) : ?>
                                        <li class="template-item">
                                            <div class="title" title="<?php echo esc_attr($template->description) ?>"><?php echo esc_html($template->name) ?></div>
                                            <span class="options">
                                                <a href="#embedded(<?php echo $id ?>)" class="template-action"><?php echo cssJSToolbox::_('Embed') ?></a>
<?php if ($template->linked) : ?>
                                               | <a href="#unlink(<?php echo $id ?>)" class="template-action unlink-template"><?php echo cssJSToolbox::_('Unlink') ?></a>
<?php else : ?>
                         | <a href="#link(<?php echo $id ?>)" class="template-action link-template"><?php echo cssJSToolbox::_('Link') ?></a>
<?php   endif; ?>
<?php if (!$template->systemTemplate) : // Allow editing noo-system templates only ?>
                           | <a href="#edit(<?php echo $id ?>)" class="template-action edit-template"><?php echo cssJSToolbox::_('Edit') ?></a>
<?php endif; ?>
                                            </span>
                                        </li>
<?php                         endforeach;    ?>
                                    </ul>
                                </li>
<?php             endforeach;    ?>
                            </ul>
                    </div>
<?php         endforeach; ?>
                </div>
<?php endif; ?>
            </form>
            <div class="sweep">
                        <span class="wrap">
                            <span class="filters-title"><?php echo cssJSToolbox::_('Show') ?></span>
                            <span class="filters">
                                <a href="#linked"><?php echo cssJSToolbox::_('Linked') ?></a>
                                <span class="cjt-link-sep-pipe">|</span>
                                <a href="#unlinked"><?php echo cssJSToolbox::_('Unlinked') ?></a>
                                <span class="cjt-link-sep-pipe">|</span>
                                <a href="#all" class="active"><?php echo cssJSToolbox::_('All') ?></a>
                            </span>
                        </span>
                        <span class="actions">
                             <a href="#unlink-all"><?php echo cssJSToolbox::_('Unlink All') ?></a>
                        </span>
                    </div>
        </div>
<?php wp_print_footer_scripts() ?>
    </body>
</html>