External Cover Image

This commit is contained in:
Diego Najar 2017-08-11 21:22:26 +02:00
parent 252fe7df13
commit 7ae2d9749c
5 changed files with 53 additions and 11 deletions

View File

@ -16,8 +16,7 @@
// POST Method
// ============================================================================
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
if (createPage($_POST)!==false) {
Alert::set( $Language->g('Page added successfully') );
}

View File

@ -94,7 +94,14 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
echo '<li id="sidebar-images-view" class="sidebar-view">';
// --- BLUDIT COVER IMAGE ---
HTML::bluditCoverImage($page->coverImage(false));
$coverImage = $page->coverImage(false);
$externalCoverImage = '';
if (filter_var($coverImage, FILTER_VALIDATE_URL)) {
$coverImage = '';
$externalCoverImage = $page->coverImage(false);
}
HTML::bluditCoverImage($coverImage);
// --- BLUDIT QUICK IMAGES ---
HTML::bluditQuickImages();
@ -183,6 +190,15 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'label'=>$L->g('Position')
));
// External Coverimage
HTML::formInputText(array(
'name'=>'externalCoverImage',
'value'=>$externalCoverImage,
'class'=>'uk-width-1-1 uk-form-medium',
'label'=>$L->g('External Cover Image'),
'tip'=>$L->g('Image URL')
));
// Slug input
HTML::formInputText(array(
'name'=>'slug',

View File

@ -164,6 +164,15 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'label'=>$L->g('Position')
));
// External Coverimage
HTML::formInputText(array(
'name'=>'externalCoverImage',
'value'=>'',
'class'=>'uk-width-1-1 uk-form-medium',
'label'=>$L->g('External Cover Image'),
'tip'=>$L->g('Image URL')
));
// Slug input
HTML::formInputText(array(
'name'=>'slug',

View File

@ -264,6 +264,12 @@ function createPage($args) {
return false;
}
// External Cover Image
if ( Text::isNotEmpty(($args['externalCoverImage'])) ) {
$args['coverImage'] = $args['externalCoverImage'];
unset($args['externalCoverImage']);
}
$key = $dbPages->add($args);
if ($key) {
// Call the plugins after page created
@ -303,6 +309,12 @@ function editPage($args) {
return false;
}
// External Cover Image
if ( Text::isNotEmpty(($args['externalCoverImage'])) ) {
$args['coverImage'] = $args['externalCoverImage'];
unset($args['externalCoverImage']);
}
if (!isset($args['parent'])) {
$args['parent'] = '';
}

View File

@ -289,7 +289,8 @@ class Page {
return json_encode($tmp);
}
// Returns the file name of the cover image, FALSE there isn't a cover image setted
// Returns the file name, FALSE there isn't a cover image setted
// If the user defined an External Cover Image the complete URL is going to be returned
// (boolean) $absolute, TRUE returns the absolute path and file name, FALSE just the file name
public function coverImage($absolute=true)
{
@ -298,6 +299,11 @@ class Page {
return false;
}
// Check if external cover image, is a valid URL
if (filter_var($fileName, FILTER_VALIDATE_URL)) {
return $fileName;
}
if ($absolute) {
return DOMAIN_UPLOADS.$fileName;
}