Merge pull request 'Sanitizing html output and using page.php' (#10) from feature_bugifix/issues_#4_and_#1/sanitizing_html_output_and_using_page.php into master
This commit is contained in:
commit
733abef266
@ -16,7 +16,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<?php include(THEME_DIR_PHP.'home.php') ?>
|
<?php
|
||||||
|
if ( $WHERE_AM_I === 'home' ) {
|
||||||
|
include(THEME_DIR_PHP.'home.php');
|
||||||
|
} elseif ( $WHERE_AM_I === 'page' ) {
|
||||||
|
include(THEME_DIR_PHP.'page.php');
|
||||||
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
100
php/home.php
100
php/home.php
@ -1,77 +1,31 @@
|
|||||||
<!-- Section -->
|
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<?php foreach ($content as $page): ?>
|
<?php foreach ($content as $page): ?>
|
||||||
<article class="page">
|
<article class="page">
|
||||||
<header>
|
<header>
|
||||||
<?php if ( $page->title() ): ?>
|
<?php if ( $page->title() ): ?>
|
||||||
<h2>
|
<h2>
|
||||||
<a href="<?php echo htmlentities($page->permalink(), ENT_QUOTES | ENT_HTML401)?>">
|
<a href="<?php echo htmlentities($page->permalink(), ENT_QUOTES | ENT_HTML401)?>">
|
||||||
<?php
|
<?php
|
||||||
echo htmlentities( $page->title() );
|
echo htmlentities( $page->title() );
|
||||||
?>
|
?>
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</header>
|
</header>
|
||||||
<?php if ($page->coverImage()): ?>
|
<?php if ($page->coverImage()): ?>
|
||||||
<img src="<?php echo $page->coverImage() ?>" alt="<?php echo $page->slug() ?>">
|
<img src="<?php echo htmlentities($page->coverImage(), ENT_QUOTES | ENT_HTML401); ?>" alt="<?php htmlentities(echo $page->slug(), ENT_QUOTES | ENT_HTML401); ?>"/>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php echo $page->content() ?>
|
<?php echo $page->content() ?>
|
||||||
|
<footer>
|
||||||
<footer>
|
<a href="<?php echo htmlentities($page->permalink(), ENT_QUOTES | ENT_HTML401)?>">
|
||||||
<a href="<?php echo htmlentities($page->permalink(), ENT_QUOTES | ENT_HTML401)?>">
|
<?php echo htmlentities( $L->get('Read this article.') ); ?>
|
||||||
<?php echo htmlentities( $L->get('Read this article.') ); ?>
|
</a>
|
||||||
</a>
|
<br/>
|
||||||
<br/>
|
<?php echo htmlentities($page->date()); ?>
|
||||||
<?php echo $page->date() ?>
|
</footer>
|
||||||
</footer>
|
</article>
|
||||||
</article>
|
<?php endforeach ?>
|
||||||
<?php endforeach ?>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- Pagination -->
|
<?php include(THEME_DIR_PHP.'pagination.php'); ?>
|
||||||
<ul class="pagination">
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$isPage = $WHERE_AM_I === 'page';
|
|
||||||
$isHome = $WHERE_AM_I === 'home';
|
|
||||||
$pageHandler = new Pages();
|
|
||||||
$previousLink = null;
|
|
||||||
$nextLink = null;
|
|
||||||
$areTherePages = !!count($content);
|
|
||||||
if ( $isPage && $areTherePages ) {
|
|
||||||
$currentPage = $content[0];
|
|
||||||
if( isset($currentPage) ) {
|
|
||||||
if ( $currentPage->previousKey() ) {
|
|
||||||
$previousLink = buildPage($currentPage->previousKey())->permalink();
|
|
||||||
}
|
|
||||||
if ( $currentPage->nextKey() ) {
|
|
||||||
$nextLink = buildPage($currentPage->nextKey())->permalink();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( $isHome ) {
|
|
||||||
if ( Paginator::showPrev() ) {
|
|
||||||
$previousLink = Paginator::previousPageUrl();
|
|
||||||
}
|
|
||||||
if ( Paginator::showNext() ) {
|
|
||||||
$nextLink = Paginator::nextPageUrl();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<?php if ( isset($previousLink) ): ?>
|
|
||||||
<li class="float-left">
|
|
||||||
<a href="<?php echo htmlentities( $previousLink, ENT_QUOTES | ENT_HTML401 ); ?>">
|
|
||||||
<?php echo $L->get('Previous page') ?>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ( isset($nextLink) ): ?>
|
|
||||||
<li class="float-right">
|
|
||||||
<a href="<?php echo htmlentities( $nextLink, ENT_QUOTES | ENT_HTML401 ); ?>">
|
|
||||||
<?php echo $L->get('Next page') ?>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<?php endif; ?>
|
|
||||||
</ul>
|
|
||||||
|
40
php/page.php
40
php/page.php
@ -1,18 +1,26 @@
|
|||||||
<!-- Section -->
|
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<article class="page">
|
<article class="page">
|
||||||
<header>
|
<header>
|
||||||
<a href="<?php echo $page->permalink() ?>">
|
<?php if ( $page->title() ): ?>
|
||||||
<h2><?php echo $page->title() ?></h2>
|
<h2>
|
||||||
</a>
|
<a href="<?php echo htmlentities($page->permalink(), ENT_QUOTES | ENT_HTML401)?>">
|
||||||
|
<?php
|
||||||
|
echo htmlentities( $page->title() );
|
||||||
|
?>
|
||||||
|
</a>
|
||||||
|
</h2>
|
||||||
|
<?php endif; ?>
|
||||||
|
</header>
|
||||||
|
<?php if ($page->coverImage()): ?>
|
||||||
|
<img src="<?php echo htmlentities($page->coverImage(), ENT_QUOTES | ENT_HTML401); ?>" alt="<?php echo htmlentities($page->slug(), ENT_QUOTES | ENT_HTML401); ?>"/>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if($page->coverImage()): ?>
|
<?php echo $page->content() ?>
|
||||||
<img src="<?php echo $page->coverImage() ?>" alt="<?php echo $page->slug() ?>">
|
|
||||||
<?php endif ?>
|
<footer>
|
||||||
</header>
|
<?php echo htmlentities($page->date()); ?>
|
||||||
<?php echo $page->content() ?>
|
</footer>
|
||||||
<footer>
|
</article>
|
||||||
<div class="date"><?php echo $page->date() ?></div>
|
</section>
|
||||||
</footer>
|
|
||||||
</article>
|
<?php include(THEME_DIR_PHP.'pagination.php'); ?>
|
||||||
</section>
|
|
||||||
|
42
php/pagination.php
Normal file
42
php/pagination.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<!-- Pagination -->
|
||||||
|
<ul class="pagination">
|
||||||
|
<?php
|
||||||
|
$isPage = $WHERE_AM_I === 'page';
|
||||||
|
$isHome = $WHERE_AM_I === 'home';
|
||||||
|
$pageHandler = new Pages();
|
||||||
|
$previousLink = null;
|
||||||
|
$nextLink = null;
|
||||||
|
if ( $isPage && isset($page) ) {
|
||||||
|
if( isset($page) ) {
|
||||||
|
if ( $page->previousKey() ) {
|
||||||
|
$previousLink = buildPage($page->previousKey())->permalink();
|
||||||
|
}
|
||||||
|
if ( $page->nextKey() ) {
|
||||||
|
$nextLink = buildPage($page->nextKey())->permalink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( $isHome ) {
|
||||||
|
if ( Paginator::showPrev() ) {
|
||||||
|
$previousLink = Paginator::previousPageUrl();
|
||||||
|
}
|
||||||
|
if ( Paginator::showNext() ) {
|
||||||
|
$nextLink = Paginator::nextPageUrl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php if ( isset($previousLink) ): ?>
|
||||||
|
<li class="float-left">
|
||||||
|
<a href="<?php echo htmlentities( $previousLink, ENT_QUOTES | ENT_HTML401 ); ?>">
|
||||||
|
<?php echo $L->get('Previous page') ?>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ( isset($nextLink) ): ?>
|
||||||
|
<li class="float-right">
|
||||||
|
<a href="<?php echo htmlentities( $nextLink, ENT_QUOTES | ENT_HTML401 ); ?>">
|
||||||
|
<?php echo $L->get('Next page') ?>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
</ul>
|
Loading…
Reference in New Issue
Block a user