9 changed files with 145 additions and 143 deletions
@ -1,33 +0,0 @@
|
||||
<?php |
||||
|
||||
namespace Aldine; |
||||
|
||||
use Sober\Controller\Controller; |
||||
|
||||
class FrontPage extends Controller |
||||
{ |
||||
public function blockCount() |
||||
{ |
||||
global $_wp_sidebars_widgets; |
||||
if (!empty($_wp_sidebars_widgets['front-page-block'])) { |
||||
return count($_wp_sidebars_widgets['front-page-block']); |
||||
} |
||||
return 1; |
||||
} |
||||
|
||||
public function latestBooksTitle() |
||||
{ |
||||
$title = get_option('pb_front_page_catalog_title'); |
||||
if ($title) { |
||||
return $title; |
||||
} |
||||
|
||||
return __('Our Latest Titles', 'aldine'); |
||||
} |
||||
|
||||
public function catalogData() |
||||
{ |
||||
$page = (get_query_var('page')) ? get_query_var('page') : 1; |
||||
return App::catalogData($page, 3); |
||||
} |
||||
} |
||||
@ -1,35 +0,0 @@
|
||||
<?php |
||||
|
||||
namespace Aldine; |
||||
|
||||
use Sober\Controller\Controller; |
||||
|
||||
class PageCatalog extends Controller |
||||
{ |
||||
public function licenses() |
||||
{ |
||||
if (function_exists('pb_meets_minimum_requirements') && pb_meets_minimum_requirements()) { |
||||
$licenses = (new \Pressbooks\Licensing())->getSupportedTypes(); |
||||
foreach ($licenses as $key => $value) { |
||||
$licenses[$key] = preg_replace("/\([^)]+\)/", '', $value['desc']); |
||||
} |
||||
return $licenses; |
||||
} else { |
||||
return []; |
||||
} |
||||
} |
||||
|
||||
public function subjectGroups() |
||||
{ |
||||
return \Pressbooks\Metadata\get_thema_subjects(); |
||||
} |
||||
|
||||
public function catalogData() |
||||
{ |
||||
$page = (get_query_var('paged')) ? get_query_var('paged') : 1; |
||||
$orderby = (get_query_var('orderby')) ? get_query_var('orderby') : 'title'; |
||||
$subject = (get_query_var('subject')) ? get_query_var('subject') : ''; |
||||
$license = (get_query_var('license')) ? get_query_var('license') : ''; |
||||
return App::catalogData($page, 9, $orderby, $license, $subject); |
||||
} |
||||
} |
||||
@ -0,0 +1,24 @@
|
||||
<?php |
||||
/** |
||||
* The template for displaying the catalog page |
||||
* |
||||
* Template Name: Catalog |
||||
* |
||||
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ |
||||
* |
||||
* @package Aldine |
||||
*/ |
||||
|
||||
get_header(); ?> |
||||
|
||||
<div id="primary" class="content-area"> |
||||
<main id="main" class="site-main"> |
||||
|
||||
<?php get_template_part( 'partials/content', 'page-catalog' ); ?> |
||||
|
||||
</main><!-- #main --> |
||||
</div><!-- #primary --> |
||||
|
||||
<?php |
||||
get_sidebar(); |
||||
get_footer(); |
||||
@ -0,0 +1,89 @@
|
||||
<?php |
||||
/** |
||||
* Template part for displaying the catalog page content |
||||
* |
||||
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ |
||||
* |
||||
* @package Aldine |
||||
*/ |
||||
|
||||
?> |
||||
|
||||
<?php |
||||
|
||||
use function Aldine\Helpers\get_catalog_data; |
||||
use function Aldine\Helpers\get_catalog_licenses; |
||||
|
||||
$current_page = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; |
||||
$orderby = ( get_query_var( 'orderby' ) ) ? get_query_var( 'orderby' ) : 'title'; |
||||
$subject = ( get_query_var( 'subject' ) ) ? get_query_var( 'subject' ) : ''; |
||||
$license = ( get_query_var( 'license' ) ) ? get_query_var( 'license' ) : ''; |
||||
$catalog_data = get_catalog_data( $current_page, 9, $orderby, $license, $subject ); |
||||
$previous_page = ( $current_page > 1 ) ? $current_page - 1 : 0; |
||||
$next_page = $current_page + 1; |
||||
$licenses = get_catalog_licenses(); |
||||
$subject_groups = ( function_exists( '\\Pressbooks\\Metadata\\get_thema_subjects' ) ) ? \Pressbooks\Metadata\get_thema_subjects() : []; |
||||
|
||||
?> |
||||
|
||||
<?php get_template_part( 'partials/page', 'header' ); ?> |
||||
<section class="network-catalog"> |
||||
<div class="controls"> |
||||
<div class="search"> |
||||
<h2><a href="#search"><?php _e( 'Search by titles or keyword', 'aldine' ); ?> <svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a></h2>
|
||||
</div> |
||||
<div class="filters"> |
||||
<a href="#filter"><?php _e( 'Filter by', 'aldine' ); ?> <svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a>
|
||||
<div id="filter" class="filter-groups"> |
||||
<?php foreach ( $subject_groups as $key => $val ) : ?> |
||||
<div class="<?php echo $key; ?> subjects" id="<?php echo $key; ?>">
|
||||
<a href="#<?php echo $key; ?>"><?php echo $val['label']; ?> <svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a>
|
||||
<ul class="filter-list"> |
||||
<?php foreach ( $val['children'] as $k => $v ) : |
||||
if ( strlen( $k ) === 2 ) : ?> |
||||
<li><a data-filter="{{ $k }}"><?php echo $v; ?><span class="close">×</span></a></li>
|
||||
<?php endif; ?> |
||||
<?php endforeach; ?> |
||||
</ul> |
||||
</div> |
||||
<?php endforeach; ?> |
||||
</div> |
||||
<div class="licenses" id="licenses"> |
||||
<a href="#licenses"><?php _e( 'Licenses', 'aldine' ); ?><svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a>
|
||||
<ul class="filter-list"> |
||||
<?php foreach ( $licenses as $key => $value ) : ?> |
||||
<li><a data-filter="<?php echo $key; ?>"><?php echo $value; ?><span class="close">×</span></a></li>
|
||||
<?php endforeach; ?> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="sort"> |
||||
<a href="#sort"><?php _e( 'Sort by', 'aldine' ); ?> <svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a>
|
||||
<ul id="sort" class="sorts"> |
||||
<li><a data-sort="title" href="<?php echo "/catalog/page/$current_page/?orderby=title"; ?>"><?php _e( 'Title', 'aldine' ); ?></a></li>
|
||||
<li><a data-sort="subject" href="<?php echo "/catalog/page/$current_page/?orderby=subject"; ?>"><?php _e( 'Subject', 'aldine' ); ?></a></li>
|
||||
<li><a data-sort="latest" href="<?php echo "/catalog/page/$current_page/?orderby=latest"; ?>"><?php _e( 'Latest', 'aldine' ); ?></a></li>
|
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="books"> |
||||
<?php foreach ( $catalog_data['books'] as $book ) : |
||||
include( locate_template( 'partials/book.php' ) ); |
||||
endforeach; ?> |
||||
</div> |
||||
<?php if ( $catalog_data['pages'] > 1 ) : ?> |
||||
<nav class="catalog-navigation"> |
||||
<?php if ( $previous_page ) : ?><a class="previous" data-page="<?php echo $previous_page; ?>" href="<?php echo network_home_url( "/catalog/page/$previous_page/" ); ?>"><?php _e( 'Previous', 'aldine' ); ?></a><?php endif; ?> |
||||
<div class="pages"> |
||||
<?php for ( $i = 1; $i <= $catalog_data['pages']; $i++ ) : |
||||
if ( $i === $current_page ) : ?> |
||||
<span class="current"><?php echo $i; ?></span>
|
||||
<?php else : ?> |
||||
<a href="<?php echo network_home_url( "/catalog/page/$i/" ); ?>"><?php echo $i; ?></a>
|
||||
<?php endif; ?> |
||||
<?php endfor; ?> |
||||
</div> |
||||
<?php if ( $next_page <= $catalog_data['pages'] ) : ?><a class="next" data-page="<?php echo $next_page; ?>" href="<?php echo network_home_url( "/catalog/page/$next_page/" ); ?>"><?php _e( 'Next', 'aldine' ); ?></a><?php endif; ?> |
||||
</nav> |
||||
<?php endif; ?> |
||||
</section> |
||||
@ -1,69 +0,0 @@
|
||||
{{-- |
||||
Template Name: Catalog |
||||
--}} |
||||
|
||||
@extends('layouts.app') |
||||
|
||||
@section('content') |
||||
@include('partials.page-header') |
||||
<section class="network-catalog"> |
||||
<div class="controls"> |
||||
<div class="search"> |
||||
<h2><a href="#search">{{ __('Search by titles or keyword', 'aldine') }} <svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a></h2> |
||||
</div> |
||||
<div class="filters"> |
||||
<a href="#filter">{{ __('Filter by', 'aldine') }} <svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a> |
||||
<div id="filter" class="filter-groups"> |
||||
@foreach($subject_groups as $key => $val) |
||||
<div class="{{ $key }} subjects" id="{{ $key }}"> |
||||
<a href="#{{ $key }}">{{ $val['label'] }} <svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a> |
||||
<ul class="filter-list"> |
||||
@foreach($val['children'] as $k => $v) |
||||
@if(strlen($k) === 2) |
||||
<li><a data-filter="{{ $k }}">{{ $v }}<span class="close">×</span></a></li> |
||||
@endif |
||||
@endforeach |
||||
</ul> |
||||
</div> |
||||
@endforeach |
||||
</div> |
||||
<div class="licenses" id="licenses"> |
||||
<a href="#licenses">{{ __('Licenses', 'aldine' ) }}<svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a> |
||||
<ul class="filter-list"> |
||||
@foreach($licenses as $key => $value) |
||||
<li><a data-filter="{{ $key }}">{{ $value }}<span class="close">×</span></a></li> |
||||
@endforeach |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="sort"> |
||||
<a href="#sort">{{ __('Sort by', 'aldine') }} <svg class="arrow" width="13" height="8" viewBox="0 0 13 8" xmlns="http://www.w3.org/2000/svg"><path d="M6.255 8L0 0h12.51z" fill="#b01109" fill-rule="evenodd"/></svg></a> |
||||
<ul id="sort" class="sorts"> |
||||
<li><a data-sort="title" href="{{ "/catalog/page/$current_page/?orderby=title" }}">{{ __('Title', 'aldine') }}</a></li> |
||||
<li><a data-sort="subject" href="{{ "/catalog/page/$current_page/?orderby=subject" }}">{{ __('Subject', 'aldine') }}</a></li> |
||||
<li><a data-sort="latest" href="{{ "/catalog/page/$current_page/?orderby=latest" }}">{{ __('Latest', 'aldine') }}</a></li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="books"> |
||||
@foreach($catalog_data['books'] as $book) |
||||
@include('partials.book', ['book' => $book]) |
||||
@endforeach |
||||
</div> |
||||
@if($catalog_data['pages'] > 1) |
||||
<nav class="catalog-navigation"> |
||||
@if($previous_page)<a class="previous" data-page="{{ $previous_page }}" href="{{ network_home_url("/catalog/page/$previous_page/") }}">@php(include get_theme_file_path() . '/dist/' . Aldine\asset_dir('images/left-arrow.svg')) {{ __('Previous', 'aldine') }}</a>@endif |
||||
<div class="pages"> |
||||
@for($i = 1; $i <= $catalog_data['pages']; $i++) |
||||
@if($i === $current_page) |
||||
<span class="current">{{ $i }}</span> |
||||
@else |
||||
<a href="{{ network_home_url("/catalog/page/$i/") }}">{{ $i }}</a> |
||||
@endif |
||||
@endfor |
||||
</div> |
||||
@if($next_page <= $catalog_data['pages'])<a class="next" data-page="{{ $next_page }}" href="{{ network_home_url("/catalog/page/$next_page/") }}">{{ __('Next', 'aldine') }} @php(include get_theme_file_path() . '/dist/' . Aldine\asset_dir('images/right-arrow.svg'))</a>@endif |
||||
</nav> |
||||
@endif |
||||
</section> |
||||
@endsection |
||||
@ -1,3 +0,0 @@
|
||||
<div class="page-header"> |
||||
<h1>{!! App::title() !!}</h1> |
||||
</div> |
||||
Loading…
Reference in new issue