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,9 +16,8 @@
// POST Method // POST Method
// ============================================================================ // ============================================================================
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
{ if (createPage($_POST)!==false) {
if( createPage($_POST)!==false ) {
Alert::set( $Language->g('Page added successfully') ); 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">'; echo '<li id="sidebar-images-view" class="sidebar-view">';
// --- BLUDIT COVER IMAGE --- // --- 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 --- // --- BLUDIT QUICK IMAGES ---
HTML::bluditQuickImages(); HTML::bluditQuickImages();
@ -183,6 +190,15 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'label'=>$L->g('Position') '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 // Slug input
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'slug', 'name'=>'slug',

View File

@ -164,6 +164,15 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'label'=>$L->g('Position') '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 // Slug input
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'slug', 'name'=>'slug',

View File

@ -260,10 +260,16 @@ function createPage($args) {
// The user is always the one loggued // The user is always the one loggued
$args['username'] = Session::get('username'); $args['username'] = Session::get('username');
if( Text::isEmpty($args['username']) ) { if ( Text::isEmpty($args['username']) ) {
return false; return false;
} }
// External Cover Image
if ( Text::isNotEmpty(($args['externalCoverImage'])) ) {
$args['coverImage'] = $args['externalCoverImage'];
unset($args['externalCoverImage']);
}
$key = $dbPages->add($args); $key = $dbPages->add($args);
if ($key) { if ($key) {
// Call the plugins after page created // Call the plugins after page created
@ -298,17 +304,23 @@ function editPage($args) {
// The user is always the one loggued // The user is always the one loggued
$args['username'] = Session::get('username'); $args['username'] = Session::get('username');
if( Text::isEmpty($args['username']) ) { if ( Text::isEmpty($args['username']) ) {
Log::set('Function editPage()'.LOG_SEP.'Empty username.'); Log::set('Function editPage()'.LOG_SEP.'Empty username.');
return false; return false;
} }
if(!isset($args['parent'])) { // External Cover Image
if ( Text::isNotEmpty(($args['externalCoverImage'])) ) {
$args['coverImage'] = $args['externalCoverImage'];
unset($args['externalCoverImage']);
}
if (!isset($args['parent'])) {
$args['parent'] = ''; $args['parent'] = '';
} }
$key = $dbPages->edit($args); $key = $dbPages->edit($args);
if($key) { if ($key) {
// Call the plugins after page modified // Call the plugins after page modified
Theme::plugins('afterPageModify'); Theme::plugins('afterPageModify');

View File

@ -289,16 +289,22 @@ class Page {
return json_encode($tmp); 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 // (boolean) $absolute, TRUE returns the absolute path and file name, FALSE just the file name
public function coverImage($absolute=true) public function coverImage($absolute=true)
{ {
$fileName = $this->getValue('coverImage'); $fileName = $this->getValue('coverImage');
if(empty($fileName)) { if (empty($fileName)) {
return false; return false;
} }
if($absolute) { // Check if external cover image, is a valid URL
if (filter_var($fileName, FILTER_VALIDATE_URL)) {
return $fileName;
}
if ($absolute) {
return DOMAIN_UPLOADS.$fileName; return DOMAIN_UPLOADS.$fileName;
} }