Regex Rel to Abs img, improves on manage content

This commit is contained in:
Diego Najar 2017-08-02 01:11:57 +02:00
parent 3111c11ca3
commit 05c67fc473
4 changed files with 43 additions and 22 deletions

View File

@ -139,7 +139,7 @@
$keys = array_keys($scheduledPages); $keys = array_keys($scheduledPages);
foreach($keys as $key) { foreach($keys as $key) {
$page = buildPage($key); $page = buildPage($key);
echo '<li><span class="label-draft">'.$Language->g('Page').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>'; echo '<li><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
} }
} }
?> ?>

View File

@ -4,6 +4,7 @@ HTML::title(array('title'=>$L->g('Manage content'), 'icon'=>'folder'));
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-page"><i class="uk-icon-plus"></i> '.$L->g('Add new content').'</a>'; echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-page"><i class="uk-icon-plus"></i> '.$L->g('Add new content').'</a>';
// Fixed page list
echo ' echo '
<table class="uk-table uk-table-striped"> <table class="uk-table uk-table-striped">
<thead> <thead>
@ -20,21 +21,43 @@ echo '
<tbody> <tbody>
'; ';
foreach($pages as $page) { function table($status, $icon='arrow-circle-o-down') {
$status = false; global $pages;
if($page->status()!='published') { global $Url;
$status = $Language->g( $page->status() ); $showLegend = true;
foreach ($pages as $key=>$page) {
if ($page->status()==$status) {
if ($showLegend) {
$showLegend = false;
echo '<tr>
<td style="color: #aaa; font-size: 0.9em; text-transform: uppercase;"><i class="fa fa-'.$icon.'" aria-hidden="true"></i> '.$status.'</td>
<td></td>
<td></td>
</tr>';
}
unset($pages[$key]);
echo '<tr>';
echo '<td>
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'
.($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
.'</a>
</td>';
echo '<td class="uk-text-center">'.( (ORDER_BY=='date') ? $page->dateRaw() : $page->position() ).'</td>';
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$page->key() : '/'.$Url->filters('page').'/'.$page->key();
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
echo '</tr>';
}
} }
echo '<tr>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($status?'<span class="label-'.$page->status().'">'.$status.'</span>':'').($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a></td>';
echo '<td class="uk-text-center">'.( (ORDER_BY=='date') ? $page->dateRaw() : $page->position() ).'</td>';
$friendlyURL = Text::isEmpty($Url->filters('page')) ? '/'.$page->key() : '/'.$Url->filters('page').'/'.$page->key();
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
echo '</tr>';
} }
table('draft', 'spinner');
table('scheduled', 'clock-o');
table('fixed', 'thumb-tack');
table('sticky', 'sticky-note-o');
table('published', 'check');
echo ' echo '
</tbody> </tbody>
</table> </table>
@ -47,7 +70,7 @@ echo '
<?php <?php
// Show previus page link // Show previus page link
if(Paginator::showPrev()) { if(Paginator::showPrev()) {
echo '<li class="first"><a href="'.Paginator::prevPageUrl().'" class="previous"><- Previous</a></li>'; echo '<li class="first"><a href="'.Paginator::prevPageUrl().'" class="previous"><i class="fa fa-arrow-circle-o-left"></i> Previous</a></li>';
} }
for($i=1; $i<=Paginator::amountOfPages(); $i++) { for($i=1; $i<=Paginator::amountOfPages(); $i++) {
@ -56,7 +79,7 @@ echo '
// Show next page link // Show next page link
if(Paginator::showNext()) { if(Paginator::showNext()) {
echo '<li class="next"><a href="'.Paginator::nextPageUrl().'" class="next">Next -></a></li>'; echo '<li class="next"><a href="'.Paginator::nextPageUrl().'" class="next">Next <i class="fa fa-arrow-circle-o-right"></i></a></li>';
} }
?> ?>
</ul> </ul>

View File

@ -215,7 +215,10 @@ class Text {
public static function imgRel2Abs($string, $base) public static function imgRel2Abs($string, $base)
{ {
return preg_replace('/(src)="([^:"]*)(?:")/', "$1=\"$base$2\"", $string); $pattern = "/<img([^>]*) src=\"([^http|https|ftp|\/\/][^\"]*)\"/";
$replace = "<img\${1} src=\"".$base. "\${2}\"";
return preg_replace($pattern, $replace, $string);
} }
public static function pre2htmlentities($string) public static function pre2htmlentities($string)
@ -224,5 +227,4 @@ class Text {
create_function('$input', 'return "<pre><code $input[1]>".htmlentities($input[2])."</code></pre>";'), create_function('$input', 'return "<pre><code $input[1]>".htmlentities($input[2])."</code></pre>";'),
$string); $string);
} }
} }

View File

@ -18,14 +18,10 @@
<!-- Section --> <!-- Section -->
<section> <section>
<header class="major">
<h2>Pages</h2>
</header>
<div class="posts"> <div class="posts">
<?php foreach ($pages as $page): ?> <?php foreach ($pages as $page): ?>
<article> <article>
<a href="#" class="image"><img src="<?php echo $page->coverImage() ?>" alt="" /></a> <a href="<?php echo $page->permalink() ?>" class="image"><img src="<?php echo $page->coverImage() ?>" alt="" /></a>
<h3><?php echo $page->title() ?></h3> <h3><?php echo $page->title() ?></h3>
<p><?php echo $page->description() ?></p> <p><?php echo $page->description() ?></p>
<ul class="actions"> <ul class="actions">