Introducing the AlbumHeaderBox. Removes a hack.

This commit is contained in:
Aaron van Geffen 2016-09-03 22:23:27 +02:00
parent fdc437b29c
commit 3220d361c3
3 changed files with 85 additions and 21 deletions

View File

@ -26,32 +26,36 @@ class ViewPhotoAlbum extends HTMLController
$tag = Tag::fromSlug($_GET['tag']);
$id_tag = $tag->id_tag;
$title = $tag->tag;
$description = !empty($tag->description) ? '<p>' . $tag->description . '</p>' : '';
$description = !empty($tag->description) ? $tag->description : '';
// Can we go up a level?
if ($tag->id_parent != 0)
{
$ptag = Tag::fromId($tag->id_parent);
$description .= '<p><a href="' . BASEURL . '/' . (!empty($ptag->slug) ? $ptag->slug . '/' : '') . '">&laquo; Go back to &quot;' . $ptag->tag . '&quot;</a></p>';
$back_link = BASEURL . '/' . (!empty($ptag->slug) ? $ptag->slug . '/' : '');
$back_link_title = 'Back to &quot;' . $ptag->tag . '&quot;';
}
elseif ($tag->kind === 'Person')
$description .= '<p><a href="' . BASEURL . '/people/">&laquo; Go back to &quot;People&quot;</a></p>';
{
$back_link = BASEURL . '/people/';
$back_link_title = 'Back to &quot;People&quot;';
}
$header_box = new AlbumHeaderBox($title, $description, $back_link, $back_link_title);
}
// View the album root.
else
{
$id_tag = 1;
$title = 'Albums';
$description = '';
}
// What page are we at?
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
parent::__construct($title . ' - Page ' . $page . ' - ' . SITE_TITLE);
if ($id_tag !== 1)
$this->page->adopt(new DummyBox($title, $description, 'page_title_box'));
if (isset($header_box))
$this->page->adopt($header_box);
// Fetch subalbums, but only if we're on the first page.
if ($page === 1)

View File

@ -141,10 +141,11 @@ ul#nav li a:hover {
/* Tiled grid
---------------*/
.tiled_header, .page_title_box {
.tiled_header {
background: #fff;
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
color: #000;
clear: both;
float: left;
margin: 0 0 1.5% 0;
font: 400 18px/2.2 "Open Sans", sans-serif;
@ -153,19 +154,6 @@ ul#nav li a:hover {
white-space: nowrap;
overflow: hidden;
}
.page_title_box {
padding: 6px 22px !important;
clear: both;
display: inline-block;
float: none;
font: inherit;
}
.page_title_box h2 {
font: 400 18px/2.2 "Open Sans", sans-serif !important;
}
.page_title_box p {
margin: 0 0 10px;
}
.tiled_grid {
margin: 0;
@ -291,6 +279,43 @@ ul#nav li a:hover {
float: right;
}
/* Album title boxes
----------------------*/
.album_title_box {
margin-left: -46px;
width: 100%;
}
.album_title_box > a {
background: #fff;
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
display: inline-block;
float: left;
font-size: 2em;
line-height: 1;
padding: 8px 10px 14px;
}
.album_title_box > div {
background: #fff;
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
float: left;
font: inherit;
padding: 6px 22px;
max-width: 90%;
margin: 0 0 1.5% 0;
}
.album_title_box h2 {
color: #487C96;
font: 400 18px/2 "Open Sans", sans-serif !important;
margin: 0;
}
.album_title_box p {
margin: 0 0 10px;
}
/* Generic boxed content
--------------------------*/
.boxed_content {
background: #fff;
padding: 25px;

View File

@ -0,0 +1,35 @@
<?php
/*****************************************************************************
* AlbumHeaderBox.php
* Defines the AlbumHeaderBox template.
*
* Kabuki CMS (C) 2013-2016, Aaron van Geffen
*****************************************************************************/
class AlbumHeaderBox extends SubTemplate
{
public function __construct($title, $description, $back_link, $back_link_title)
{
$this->title = $title;
$this->description = $description;
$this->back_link = $back_link;
$this->back_link_title = $back_link_title;
}
protected function html_content()
{
echo '
<div class="album_title_box">
<a class="back_button" href="', $this->back_link, '" title="', $this->back_link_title, '">&larr;</a>
<div>
<h2>', $this->title, '</h2>';
if (!empty($this->description))
echo '
<p>', $this->description, '</p>';
echo '
</div>
</div>';
}
}