<?php
|
|
use JVBase\managers\Cache;
|
use JVBase\meta\Form;
|
|
if (!defined('ABSPATH')) {
|
exit; // Exit if accessed directly
|
}
|
if (!isOurPeople()) {
|
wp_redirect(get_home_url(null, '/dash'));
|
exit;
|
}
|
$cache = Cache::for('news', 3600);
|
$check = $cache->get('type-options');
|
|
if ($check) {
|
$typeOptions = $check;
|
} else {
|
$terms = get_terms([
|
'taxonomy' => BASE.'ntype',
|
'hide_empty' => false,
|
]);
|
$typeOptions = [];
|
if ($terms && !is_wp_error($terms)) {
|
foreach ($terms as $term) {
|
$typeOptions[] = [
|
'id' => $term->term_id,
|
'name' => html_entity_decode($term->name),
|
'count' => $term->count,
|
];
|
}
|
}
|
$cache->set('type-options', $typeOptions);
|
}
|
|
?>
|
<div class="container news">
|
<!-- Tab navigation -->
|
<div class="tabs" role="tablist">
|
<button type="button" class="tab active" data-tab="news" role="tab" aria-selected="true">
|
<h2><?= jvbIcon('newspaper')?>News</h2>
|
</button>
|
<button type="button" class="tab" data-tab="mine" role="tab" aria-selected="false">
|
<h2>Yours</h2>
|
</button>
|
<button type="button" class="tab" data-tab="watching" role="tab" aria-selected="false">
|
<h2><?= jvbIcon('star')?>Watching</h2>
|
</button>
|
|
<button type="button" class="add-item-btn">
|
<?= jvbIcon('plus-square', ['title' =>'Add News']) ?>
|
<span>Post</span>
|
</button>
|
</div>
|
|
<div class="tab-content active" data-tab="news" role="tabpanel">
|
<h1>Behind the Scenes<small>Check the pulse on the local scene</small></h1>
|
</div>
|
|
<div class="tab-content" data-tab="mine" role="tabpanel">
|
<h2>Your Content</h2>
|
<?= jvbCrudManagement('news'); ?>
|
|
<dialog class="bulk-edit-modal">
|
<div class="wrap">
|
<h2>Bulk Edit <span class="selected-count"></span></h2>
|
<form class="bulk-edit-form" data-form-id="bulk-edit-news" data-nocache data-save="news">
|
<div class="selected"></div>
|
<p class="description">You can unselect items by clicking them here.</p>
|
<div class="fields">
|
<div class="field-group radio-options row">
|
<?php
|
$bulkActions = jvbGetBulkActions('news');
|
|
foreach ($bulkActions as $status => $options) {
|
$disabled = ($options['disabled']) ? ' disabled' : '';
|
?>
|
<input type="radio"
|
name="bulk_status"
|
value="<?=$status?>"
|
id="bulk-status-<?=$status?>>"<?=$disabled;?>>
|
<label for="bulk-status-<?=$status?>">
|
<?= jvbIcon($options['icon']) ?>
|
<span><?= $options['label'] ?></span>
|
</label>
|
<?php
|
}
|
?>
|
</div>
|
<div class="taxonomies">
|
<div class="taxonomies">
|
<label>Type</label>
|
|
<?php
|
foreach ($typeOptions as $type) {
|
?>
|
<input type="radio" name="type" id="bulk-<?=$type['id']?>">
|
<label for="bulk-<?=$type['id']?>"><?=$type['name']?></label>
|
<?php
|
}
|
?>
|
</div>
|
|
</div>
|
</div>
|
</form>
|
<div class="actions row">
|
<button type="button" class="cancel">Cancel</button>
|
<button type="button" class="save">Apply to Selected</button>
|
</div>
|
</div>
|
</dialog>
|
|
</div>
|
|
<div class="tab-content" data-tab="watching" role="tabpanel">
|
<h2>Content You're Watching</h2>
|
</div>
|
|
<details class="type-filters">
|
<summary class="row x-btw">Filters:
|
<button class="clear-filters row">
|
<?= jvbIcon('x', ['title' => 'Clear Filters'])?>
|
<span>Clear Filters</span>
|
</span>
|
</button>
|
</summary>
|
<form type="dialog" class="filters" data-nocache data-form-id="news-filters" data-get="news">
|
<div class="filters">
|
<?php
|
$manager = new JVBase\managers\NewsRelationships();
|
|
$artists = $manager->getAllArtistsWithNews();
|
$shops = $manager->getAllShopsNews();
|
|
$filters = [
|
'type' => [
|
'type' => 'taxonomy',
|
'label' => 'Type',
|
'icon' => 'theme',
|
'options' => $typeOptions,
|
],
|
'shop' => [
|
'type' => 'taxonomy',
|
'label' => 'Shop',
|
'icon' => 'shop',
|
'options' => $shops,
|
],
|
'artist' => [
|
'type' => 'post',
|
'label' => 'Artist',
|
'icon' => 'artist',
|
'options' => $artists,
|
],
|
];
|
|
foreach ($filters as $key => $filter) {
|
$out = sprintf(
|
'<div><label for="filter-%s">%s<span class="screen-reader-text">Filter by %s</span></label>
|
<select id="filter-%s" class="filter %s" name="%s" data-%s="%s">
|
<option value="">[ %s ]</option>',
|
$key,
|
jvbIcon($filter['icon']),
|
esc_html($filter['label']),
|
$key,
|
$key,
|
$key,
|
$key,
|
$key,
|
$filter['label']
|
);
|
|
foreach ($filter['options'] as $option) {
|
$out .= sprintf(
|
'<option value="%s">%s — ( %s )</option>',
|
esc_attr($option['id']),
|
esc_html($option['name']),
|
esc_html($option['count'])
|
);
|
}
|
$out .= '</select></div>';
|
echo $out;
|
}
|
|
echo jvbRenderDateFilter('news');
|
?>
|
</div>
|
<div class="order-options">
|
<div class="order-by">
|
<span class="type-filter label">ORDER:</span>
|
<div class="radio-group-label">
|
<input type="radio" id="order-title" class="btn" name="orderby" value="title">
|
<label for="order-title" title="Order by Name" class="row">
|
<?= jvbIcon('alphabetical') ?>
|
<span class="label">Name</span>
|
</label>
|
|
<input type="radio" id="order-date" class="btn" name="orderby" value="date" checked>
|
<label for="order-date" title="Order by Date" class="row">
|
<?= jvbIcon('calendar', ['title'=>'Date']) ?>
|
<span class="label">Date</span>
|
</label>
|
|
<input type="radio" id="order-karma" class="btn" name="orderby" value="karma">
|
<label for="order-karma" title="Order by Standing" class="row">
|
<?= jvbIcon('scales') ?>
|
<span class="label">Standing</span>
|
</label>
|
|
<input type="radio" id="order-random" class="btn" name="orderby" value="random">
|
<label for="order-random" title="Random Order" class="row">
|
<?= jvbIcon('shuffle') ?>
|
<span class="label">Random</span>
|
</label>
|
</div>
|
</div>
|
|
<div class="order-direction radio-group-label" data-for-order="date,title,karma">
|
<input type="radio" id="order-desc" class="btn" name="order" value="DESC" checked>
|
<label for="order-desc" title="Newest First" class="row">
|
<?= jvbIcon('sort-descending') ?>
|
</label>
|
|
<input type="radio" id="order-asc" class="btn" name="order" value="ASC">
|
<label for="order-asc" title="Oldest First" class="row">
|
<?= jvbIcon('sort-ascending') ?>
|
</label>
|
</div>
|
</div>
|
</form>
|
</details>
|
<section class="item-grid list-view">
|
|
</section>
|
|
</div>
|
|
<!-- Create News Modal -->
|
<dialog class="create-modal">
|
<form method="dialog" data-nocache data-form-id="create-news" data-save="news">
|
<h2>Make an Announcement</h2>
|
|
<div class="field">
|
<label for="type-select">Type:</label>
|
<select name="type" id="type-select" required>
|
<option>... select type</option>
|
<?php $taxonomies = get_terms([
|
'taxonomy' => BASE.'ntype',
|
'hide_empty' => false,
|
'fields' => 'id=>name',
|
]);
|
if ($taxonomies && !is_wp_error($taxonomies)) {
|
foreach ($taxonomies as $ID => $name) {
|
echo '<option value="'.$ID.'">'.$name.'</option>';
|
//echo '<input type="radio" name="type" id="type-'.$ID.'" value="'.$ID.'"><label for="type-'.$ID.'">'.$name.'</label>';
|
}
|
}
|
?>
|
</select>
|
</div>
|
<?php
|
$handler = JVB()->getContent('news');
|
|
foreach ($handler->getFields() as $field_name => $field_config) {
|
echo Form::render($field_name, null, $field_config);
|
}
|
?>
|
|
<div class="actions row">
|
<button type="button" class="cancel cancel">Cancel</button>
|
<button type="submit" class="create" >Add Update</button>
|
</div>
|
</form>
|
</dialog>
|
<template class="template-own">
|
<details class="news item" data-keyboard-nav="true" tabindex="0">
|
<summary class="row x-btw">
|
<div class="item-select">
|
<input type="checkbox" class="select-checkbox">
|
<label>
|
<span class="screen-reader-text">Select this news update</span>
|
</label>
|
</div>
|
<button class="favourite-button" data-type="news" title="Add to watch list" onclick="toggleFavourite(this)">
|
<?= jvbIcon('star') ?>
|
</button>
|
<div class="image"></div>
|
<div class="summary">
|
<div class="header">
|
<h3></h3>
|
<span class="published"></span>
|
</div>
|
<span class="byline">
|
<a class="artist" title="Visit their profile"></a>
|
<a class="shop"></a>
|
</span>
|
<div class="tldr"></div>
|
</div>
|
<div class="item-actions">
|
<button type="button" class="action" data-action="edit" title="Edit tattoo">
|
<?= jvbIcon('pencil-simple') ?>
|
<span class="screen-reader-text">Edit news item</span>
|
</button>
|
<button type="button" class="action" data-action="trash" title="Scrap tattoo">
|
<?= jvbIcon('trash') ?>
|
<span class="screen-reader-text">Scrap news item</span>
|
</button>
|
<button type="button" class="action" data-action="toggle-status">
|
<?= jvbIcon('eye') ?>
|
<span class="screen-reader-text">Toggle news item Visibility</span>
|
</button>
|
</div>
|
</summary>
|
<div class="item-info">
|
</div>
|
</details>
|
</template>
|
<template class="template-all template-watching">
|
<details class="news item" data-keyboard-nav="true" tabindex="0">
|
<summary class="row x-btw">
|
<button class="favourite-button" data-type="news" title="Add to watch list" onclick="toggleFavourite(this)">
|
|
</button>
|
<div class="image"></div>
|
<div class="summary">
|
<div class="header">
|
<h3></h3>
|
<span class="published"></span>
|
</div>
|
<span class="byline">
|
<a class="artist" title="Visit their profile"></a>
|
<a class="shop"></a>
|
</span>
|
<div class="tldr"></div>
|
</div>
|
</summary>
|
<div class="item-info">
|
</div>
|
</details>
|
</template>
|
<?= jvbGetReplyTemplate() ?>
|
<?= jvbGetCommentTemplate() ?>
|
<?= jvbGetReplyToTemplate() ?>
|