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 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>
|
||||
|
|
100
php/home.php
100
php/home.php
|
@ -1,77 +1,31 @@
|
|||
<!-- Section -->
|
||||
<section class="content">
|
||||
<?php foreach ($content as $page): ?>
|
||||
<article class="page">
|
||||
<header>
|
||||
<?php if ( $page->title() ): ?>
|
||||
<h2>
|
||||
<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 $page->coverImage() ?>" alt="<?php echo $page->slug() ?>">
|
||||
<?php endif ?>
|
||||
<?php foreach ($content as $page): ?>
|
||||
<article class="page">
|
||||
<header>
|
||||
<?php if ( $page->title() ): ?>
|
||||
<h2>
|
||||
<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 htmlentities(echo $page->slug(), ENT_QUOTES | ENT_HTML401); ?>"/>
|
||||
<?php endif ?>
|
||||
|
||||
<?php echo $page->content() ?>
|
||||
|
||||
<footer>
|
||||
<a href="<?php echo htmlentities($page->permalink(), ENT_QUOTES | ENT_HTML401)?>">
|
||||
<?php echo htmlentities( $L->get('Read this article.') ); ?>
|
||||
</a>
|
||||
<br/>
|
||||
<?php echo $page->date() ?>
|
||||
</footer>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
<?php echo $page->content() ?>
|
||||
<footer>
|
||||
<a href="<?php echo htmlentities($page->permalink(), ENT_QUOTES | ENT_HTML401)?>">
|
||||
<?php echo htmlentities( $L->get('Read this article.') ); ?>
|
||||
</a>
|
||||
<br/>
|
||||
<?php echo htmlentities($page->date()); ?>
|
||||
</footer>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
|
||||
<!-- Pagination -->
|
||||
<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>
|
||||
<?php include(THEME_DIR_PHP.'pagination.php'); ?>
|
||||
|
|
38
php/page.php
38
php/page.php
|
@ -1,18 +1,26 @@
|
|||
<!-- Section -->
|
||||
<section class="content">
|
||||
<article class="page">
|
||||
<header>
|
||||
<a href="<?php echo $page->permalink() ?>">
|
||||
<h2><?php echo $page->title() ?></h2>
|
||||
</a>
|
||||
<article class="page">
|
||||
<header>
|
||||
<?php if ( $page->title() ): ?>
|
||||
<h2>
|
||||
<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()): ?>
|
||||
<img src="<?php echo $page->coverImage() ?>" alt="<?php echo $page->slug() ?>">
|
||||
<?php endif ?>
|
||||
</header>
|
||||
<?php echo $page->content() ?>
|
||||
<footer>
|
||||
<div class="date"><?php echo $page->date() ?></div>
|
||||
</footer>
|
||||
</article>
|
||||
<?php echo $page->content() ?>
|
||||
|
||||
<footer>
|
||||
<?php echo htmlentities($page->date()); ?>
|
||||
</footer>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<?php include(THEME_DIR_PHP.'pagination.php'); ?>
|
||||
|
|
|
@ -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