External Cover Image
This commit is contained in:
parent
252fe7df13
commit
7ae2d9749c
@ -16,9 +16,8 @@
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if( createPage($_POST)!==false ) {
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
|
||||
if (createPage($_POST)!==false) {
|
||||
Alert::set( $Language->g('Page added successfully') );
|
||||
}
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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',
|
||||
|
@ -260,10 +260,16 @@ function createPage($args) {
|
||||
|
||||
// The user is always the one loggued
|
||||
$args['username'] = Session::get('username');
|
||||
if( Text::isEmpty($args['username']) ) {
|
||||
if ( Text::isEmpty($args['username']) ) {
|
||||
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
|
||||
@ -298,17 +304,23 @@ function editPage($args) {
|
||||
|
||||
// The user is always the one loggued
|
||||
$args['username'] = Session::get('username');
|
||||
if( Text::isEmpty($args['username']) ) {
|
||||
if ( Text::isEmpty($args['username']) ) {
|
||||
Log::set('Function editPage()'.LOG_SEP.'Empty username.');
|
||||
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'] = '';
|
||||
}
|
||||
|
||||
$key = $dbPages->edit($args);
|
||||
if($key) {
|
||||
if ($key) {
|
||||
// Call the plugins after page modified
|
||||
Theme::plugins('afterPageModify');
|
||||
|
||||
|
@ -289,16 +289,22 @@ 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)
|
||||
{
|
||||
$fileName = $this->getValue('coverImage');
|
||||
if(empty($fileName)) {
|
||||
if (empty($fileName)) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user