Image per pages, removed convert relative to absolute path, media manager improves
This commit is contained in:
parent
8221fbb40b
commit
7d16e13903
|
@ -216,10 +216,10 @@ class Plugin {
|
|||
|
||||
// Create workspace
|
||||
$workspace = $this->workspace();
|
||||
mkdir($workspace, 0755, true);
|
||||
mkdir($workspace, DIR_PERMISSIONS, true);
|
||||
|
||||
// Create plugin directory for the database
|
||||
mkdir(PATH_PLUGINS_DATABASES.$this->directoryName, 0755, true);
|
||||
mkdir(PATH_PLUGINS_DATABASES.$this->directoryName, DIR_PERMISSIONS, true);
|
||||
|
||||
$this->dbFields['position'] = $position;
|
||||
// Sanitize default values to store in the file
|
||||
|
|
|
@ -22,6 +22,12 @@ function updateBludit() {
|
|||
}
|
||||
}
|
||||
|
||||
// Updates only for version less than Bludit v3.1
|
||||
if ($site->currentBuild()<'20180921') {
|
||||
@mkdir(PATH_UPLOADS_PAGES, DIR_PERMISSIONS, true);
|
||||
$site->set(array('imageRelativeToAbsolute'=>true, 'imageRestrict'=>false));
|
||||
}
|
||||
|
||||
// Set the current build number
|
||||
$site->set(array('currentBuild'=>BLUDIT_BUILD));
|
||||
Log::set('UPDATE SYSTEM - Finished.');
|
||||
|
|
|
@ -64,6 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
try {
|
||||
$pageKey = $layout['parameters'];
|
||||
$page = new Page($pageKey);
|
||||
$uuid = $page->uuid();
|
||||
} catch (Exception $e) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey, LOG_TYPE_ERROR);
|
||||
Redirect::page('content');
|
||||
|
|
|
@ -32,5 +32,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
// Main after POST
|
||||
// ============================================================================
|
||||
|
||||
// UUID of the page is need it for autosave and media manager
|
||||
$uuid = $pages->generateUUID();
|
||||
|
||||
// Title of the page
|
||||
$layout['title'] = $L->g('New content').' - '.$layout['title'];
|
|
@ -1,11 +1,20 @@
|
|||
<?php
|
||||
// Preload the first 10 files to not call via AJAX when the user open the first time the media manager
|
||||
$listOfFiles = Filesystem::listFiles(PATH_UPLOADS_THUMBNAILS, '*', '*', $GLOBALS['BLUDIT_MEDIA_MANAGER_SORT_BY_DATE'], false);
|
||||
$listOfFilesByPage = array_chunk($listOfFiles, $GLOBALS['BLUDIT_MEDIA_MANAGER_AMOUNT_OF_FILES']);
|
||||
if (IMAGE_RESTRICT) {
|
||||
$imagesDirectory = (IMAGE_RELATIVE_TO_ABSOLUTE? '' : HTML_PATH_UPLOADS_PAGES.$uuid.DS);
|
||||
$thumbnailDirectory = PATH_UPLOADS_PAGES.$uuid.DS.'thumbnails'.DS;
|
||||
$thumbnailHTML = HTML_PATH_UPLOADS_PAGES.$uuid.'/thumbnails/';
|
||||
} else {
|
||||
$imagesDirectory = (IMAGE_RELATIVE_TO_ABSOLUTE? '' : HTML_PATH_UPLOADS);
|
||||
$thumbnailDirectory = PATH_UPLOADS_THUMBNAILS;
|
||||
$thumbnailHTML = HTML_PATH_UPLOADS_THUMBNAILS;
|
||||
}
|
||||
$listOfFilesByPage = Filesystem::listFiles($thumbnailDirectory, '*', '*', $GLOBALS['MEDIA_MANAGER_SORT_BY_DATE'], $GLOBALS['MEDIA_MANAGER_NUMBER_OF_FILES']);
|
||||
$preLoadFiles = array();
|
||||
if (!empty($listOfFilesByPage[0])) {
|
||||
foreach ($listOfFilesByPage[0] as $file) {
|
||||
array_push($preLoadFiles, basename($file));
|
||||
$filename = basename($file);
|
||||
array_push($preLoadFiles, $filename);
|
||||
}
|
||||
}
|
||||
// Amount of pages for the paginator
|
||||
|
@ -26,7 +35,6 @@ $numberOfPages = count($listOfFilesByPage);
|
|||
|
||||
<!-- Form and Input file -->
|
||||
<form name="bluditFormUpload" id="jsbluditFormUpload" enctype="multipart/form-data">
|
||||
<input type="hidden" name="tokenCSRF" value="<?php echo $security->getTokenCSRF() ?>">
|
||||
<div class="custom-file">
|
||||
<input type="file" class="custom-file-input" id="jsbluditInputFiles" name="bluditInputFiles[]" multiple>
|
||||
<label class="custom-file-label" for="jsbluditInputFiles"><?php $L->p('Choose images to upload'); ?></label>
|
||||
|
@ -91,12 +99,15 @@ function displayFiles(files) {
|
|||
cleanFiles();
|
||||
// Regenerate the table
|
||||
$.each(files, function(key, filename) {
|
||||
var thumbnail = "<?php echo $thumbnailHTML; ?>"+filename;
|
||||
var path = "<?php echo $imagesDirectory; ?>";
|
||||
|
||||
tableRow = '<tr id="js'+filename+'">'+
|
||||
'<td style="width:80px"><img class="img-thumbnail" alt="200x200" src="<?php echo HTML_PATH_UPLOADS_THUMBNAILS ?>'+filename+'" style="width: 50px; height: 50px;"><\/td>'+
|
||||
'<td style="width:80px"><img class="img-thumbnail" alt="200x200" src="'+thumbnail+'" style="width: 50px; height: 50px;"><\/td>'+
|
||||
'<td class="information">'+
|
||||
'<div class="pb-2">'+filename+'<\/div>'+
|
||||
'<div>'+
|
||||
'<button type="button" class="btn btn-primary btn-sm mr-2" onClick="editorInsertMedia(\''+filename+'\'); closeMediaManager();"><?php $L->p('Insert') ?><\/button>'+
|
||||
'<button type="button" class="btn btn-primary btn-sm mr-2" onClick="editorInsertMedia(\''+path+filename+'\'); closeMediaManager();"><?php $L->p('Insert') ?><\/button>'+
|
||||
'<button type="button" class="btn btn-primary btn-sm" onClick="setCoverImage(\''+filename+'\'); closeMediaManager();"><?php $L->p('Set as cover image') ?><\/button>'+
|
||||
'<button type="button" class="btn btn-secondary btn-sm float-right" onClick="deleteMedia(\''+filename+'\')"><?php $L->p('Delete') ?><\/button>'+
|
||||
'<\/div>'+
|
||||
|
@ -108,25 +119,28 @@ function displayFiles(files) {
|
|||
|
||||
// Get the list of files via AJAX, filter by the page number
|
||||
function getFiles(pageNumber) {
|
||||
$.post("<?php echo HTML_PATH_ADMIN_ROOT ?>ajax/list-files",
|
||||
$.post(HTML_PATH_ADMIN_ROOT+"ajax/list-images",
|
||||
{ tokenCSRF: tokenCSRF,
|
||||
pageNumber: pageNumber,
|
||||
path: "thumbnails" // the path are defined in the list-files
|
||||
uuid: "<?php echo $uuid; ?>",
|
||||
path: "thumbnails" // the paths are defined in the list-images.php
|
||||
},
|
||||
function(data) {
|
||||
displayFiles(data.files);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Delete the file and the thumbnail if exist
|
||||
function deleteMedia(filename) {
|
||||
$.post("<?php echo HTML_PATH_ADMIN_ROOT ?>ajax/delete-file",
|
||||
$.post(HTML_PATH_ADMIN_ROOT+"ajax/delete-file",
|
||||
{ tokenCSRF: tokenCSRF,
|
||||
filename: filename
|
||||
},
|
||||
function(data) {
|
||||
getFiles(1);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function setCoverImage(filename) {
|
||||
|
@ -144,10 +158,18 @@ $(document).ready(function() {
|
|||
// Check file size ?
|
||||
// Check file type/extension ?
|
||||
|
||||
$("#jsbluditProgressBar").width("1%");
|
||||
|
||||
// Data to send via AJAX
|
||||
var uuid = $("#jsuuid").val();
|
||||
var formData = new FormData($("#jsbluditFormUpload")[0]);
|
||||
formData.append('uuid', uuid);
|
||||
formData.append('tokenCSRF', tokenCSRF);
|
||||
|
||||
$.ajax({
|
||||
url: "<?php echo HTML_PATH_ADMIN_ROOT ?>ajax/upload-files",
|
||||
url: HTML_PATH_ADMIN_ROOT+"ajax/upload-images",
|
||||
type: "POST",
|
||||
data: new FormData($("#jsbluditFormUpload")[0]),
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
// UUID
|
||||
echo Bootstrap::formInputHidden(array(
|
||||
'name'=>'uuid',
|
||||
'value'=>$pages->generateUUID()
|
||||
'value'=>$uuid
|
||||
));
|
||||
|
||||
// Status = published, draft, sticky, static
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
header('Content-Type: application/json');
|
||||
|
||||
$text = isset($_POST['text']) ? $_POST['text'] : '';
|
||||
$parent = isset($_POST['parentKey']) ? $_POST['parentKey'] : PARENT;
|
||||
$parent = isset($_POST['parentKey']) ? $_POST['parentKey'] : '';
|
||||
$oldKey = isset($_POST['currentKey']) ? $_POST['currentKey'] : '';
|
||||
|
||||
$slug = $pages->generateKey($text, $parent, $returnSlug=true, $oldKey);
|
||||
|
|
|
@ -4,14 +4,23 @@ header('Content-Type: application/json');
|
|||
// $_POST
|
||||
// ----------------------------------------------------------------------------
|
||||
// (integer) $_POST['pageNumber'] > 0
|
||||
$pageNumber = !empty($_POST['pageNumber']) ? (int)$_POST['pageNumber'] : 1;
|
||||
$pageNumber = empty($_POST['pageNumber']) ? 1 : (int)$_POST['pageNumber'];
|
||||
$pageNumber = $pageNumber - 1;
|
||||
|
||||
// (string) $_POST['path']
|
||||
$path = isset($_POST['path']) ? $_POST['path'] : false;
|
||||
$path = empty($_POST['path']) ? false : $_POST['path'];
|
||||
|
||||
// (string) $_POST['uuid']
|
||||
$uuid = empty($_POST['uuid']) ? false : $_POST['uuid'];
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Set the path to get the file list
|
||||
if ($path=='thumbnails') {
|
||||
$path = PATH_UPLOADS_THUMBNAILS;
|
||||
if ($uuid && IMAGE_RESTRICT) {
|
||||
$path = PATH_UPLOADS_PAGES.$uuid.DS.'thumbnails'.DS;
|
||||
} else {
|
||||
$path = PATH_UPLOADS_THUMBNAILS;
|
||||
}
|
||||
} else {
|
||||
exit (json_encode(array(
|
||||
'status'=>1,
|
||||
|
@ -20,15 +29,17 @@ if ($path=='thumbnails') {
|
|||
}
|
||||
|
||||
// Get all files from the directory $path, also split the array by numberOfItems
|
||||
$listOfFilesByPage = Filesystem::listFiles($path, '*', '*', $GLOBALS['BLUDIT_MEDIA_MANAGER_SORT_BY_DATE'], $GLOBALS['BLUDIT_MEDIA_MANAGER_AMOUNT_OF_FILES']);
|
||||
// The function listFiles split in chunks
|
||||
$listOfFilesByPage = Filesystem::listFiles($path, '*', '*', $GLOBALS['MEDIA_MANAGER_SORT_BY_DATE'], $GLOBALS['MEDIA_MANAGER_NUMBER_OF_FILES']);
|
||||
|
||||
// Check if the page number exists in the chunks
|
||||
if (isset($listOfFilesByPage[$pageNumber])) {
|
||||
|
||||
// Get only the filename from the chunk
|
||||
$tmp = array();
|
||||
$files = array();
|
||||
foreach ($listOfFilesByPage[$pageNumber] as $file) {
|
||||
array_push($tmp, basename($file));
|
||||
$filename = basename($file);
|
||||
array_push($files, $filename);
|
||||
}
|
||||
|
||||
// Returns the number of chunks for the paginator
|
||||
|
@ -36,7 +47,7 @@ if (isset($listOfFilesByPage[$pageNumber])) {
|
|||
exit (json_encode(array(
|
||||
'status'=>0,
|
||||
'numberOfPages'=>count($listOfFilesByPage),
|
||||
'files'=>$tmp
|
||||
'files'=>$files
|
||||
)));
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
foreach ($_FILES['bluditInputFiles']['name'] as $key=>$filename) {
|
||||
|
||||
if ($_FILES['bluditInputFiles']['error'][$key] != 0) {
|
||||
$message = 'Error occurred uploading the image, max file size allowed: '.ini_get('upload_max_filesize');
|
||||
Log::set($message, LOG_TYPE_ERROR);
|
||||
exit (json_encode(array(
|
||||
'status'=>1,
|
||||
'message'=>$message
|
||||
)));
|
||||
}
|
||||
|
||||
// Get the next filename if already exist the file to not overwrite the original file
|
||||
$nextFilename = Filesystem::nextFilename(PATH_UPLOADS, $filename);
|
||||
|
||||
// File extension
|
||||
$fileExtension = pathinfo($nextFilename, PATHINFO_EXTENSION);
|
||||
|
||||
// Move from temporary directory to uploads folder
|
||||
rename($_FILES['bluditInputFiles']['tmp_name'][$key], PATH_UPLOADS.$nextFilename);
|
||||
chmod(PATH_UPLOADS.$nextFilename, 0644);
|
||||
|
||||
// Generate Thumbnail
|
||||
|
||||
// Exclude generate thumbnail for SVG format and generate a symlink to the svg
|
||||
if ($fileExtension == 'svg') {
|
||||
symlink(PATH_UPLOADS.$nextFilename, PATH_UPLOADS_THUMBNAILS.$nextFilename);
|
||||
} else {
|
||||
$Image = new Image();
|
||||
$Image->setImage(PATH_UPLOADS.$nextFilename, $GLOBALS['THUMBNAILS_WIDTH'], $GLOBALS['THUMBNAILS_HEIGHT'], 'crop');
|
||||
$Image->saveImage(PATH_UPLOADS_THUMBNAILS.$nextFilename, $GLOBALS['THUMBNAILS_QUALITY'], true);
|
||||
}
|
||||
}
|
||||
|
||||
$absoluteURL = DOMAIN_UPLOADS.$nextFilename;
|
||||
$absoluteURLThumbnail = DOMAIN_UPLOADS_THUMBNAILS.$nextFilename;
|
||||
$absolutePath = PATH_UPLOADS.$nextFilename;
|
||||
|
||||
exit (json_encode(array(
|
||||
'status'=>0,
|
||||
'message'=>'Image uploaded success.',
|
||||
'filename'=>$nextFilename,
|
||||
'absoluteURL'=>$absoluteURL,
|
||||
'absoluteURLThumbnail'=>$absoluteURLThumbnail,
|
||||
'absolutePath'=>$absolutePath
|
||||
)));
|
||||
|
||||
?>
|
|
@ -0,0 +1,80 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// $_POST
|
||||
// ----------------------------------------------------------------------------
|
||||
// (string) $_POST['uuid']
|
||||
$uuid = empty($_POST['uuid']) ? false : $_POST['uuid'];
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Set upload directory
|
||||
if ($uuid && IMAGE_RESTRICT) {
|
||||
$uploadDirectory = PATH_UPLOADS_PAGES.$uuid.DS;
|
||||
$thumbnailDirectory = $uploadDirectory.'thumbnails'.DS;
|
||||
} else {
|
||||
$uploadDirectory = PATH_UPLOADS;
|
||||
$thumbnailDirectory = PATH_UPLOADS_THUMBNAILS;
|
||||
}
|
||||
|
||||
// Create directory for images
|
||||
if (!is_dir($uploadDirectory)){
|
||||
Filesystem::mkdir($uploadDirectory, true);
|
||||
}
|
||||
|
||||
// Create directory for thumbnails
|
||||
if (!is_dir($thumbnailDirectory)){
|
||||
Filesystem::mkdir($thumbnailDirectory, true);
|
||||
}
|
||||
|
||||
// File extensions allowed
|
||||
$allowedExtensions = array('gif', 'png', 'jpg', 'jpeg', 'svg');
|
||||
|
||||
// Upload all images
|
||||
foreach ($_FILES['bluditInputFiles']['name'] as $key=>$filename) {
|
||||
|
||||
// Check for errors
|
||||
if ($_FILES['bluditInputFiles']['error'][$key] != 0) {
|
||||
$message = 'Error occurred uploading the image, max file size allowed: '.ini_get('upload_max_filesize');
|
||||
Log::set($message, LOG_TYPE_ERROR);
|
||||
exit (json_encode(array(
|
||||
'status'=>1,
|
||||
'message'=>$message
|
||||
)));
|
||||
}
|
||||
|
||||
// Check file extension
|
||||
$fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExtension, $allowedExtensions) ) {
|
||||
$message = 'Extension file not supported.';
|
||||
Log::set($message, LOG_TYPE_ERROR);
|
||||
exit (json_encode(array(
|
||||
'status'=>1,
|
||||
'message'=>$message
|
||||
)));
|
||||
}
|
||||
|
||||
// Get the next filename to not overwrite the original file
|
||||
$nextFilename = Filesystem::nextFilename($uploadDirectory, $filename);
|
||||
|
||||
// Move from temporary directory to uploads folder
|
||||
rename($_FILES['bluditInputFiles']['tmp_name'][$key], $uploadDirectory.$nextFilename);
|
||||
chmod($uploadDirectory.$nextFilename, 0644);
|
||||
|
||||
// Generate Thumbnail
|
||||
// Exclude generate thumbnail for SVG format and generate a symlink to the svg
|
||||
if ($fileExtension == 'svg') {
|
||||
symlink($uploadDirectory.$nextFilename, $thumbnailDirectory.$nextFilename);
|
||||
} else {
|
||||
$Image = new Image();
|
||||
$Image->setImage($uploadDirectory.$nextFilename, $GLOBALS['THUMBNAILS_WIDTH'], $GLOBALS['THUMBNAILS_HEIGHT'], 'crop');
|
||||
$Image->saveImage($thumbnailDirectory.$nextFilename, $GLOBALS['THUMBNAILS_QUALITY'], true);
|
||||
}
|
||||
}
|
||||
|
||||
exit (json_encode(array(
|
||||
'status'=>0,
|
||||
'message'=>'Image uploaded success.',
|
||||
'filename'=>$nextFilename
|
||||
)));
|
||||
|
||||
?>
|
|
@ -40,6 +40,7 @@ define('PATH_TMP', PATH_CONTENT.'tmp'.DS);
|
|||
define('PATH_UPLOADS', PATH_CONTENT.'uploads'.DS);
|
||||
define('PATH_WORKSPACES', PATH_CONTENT.'workspaces'.DS);
|
||||
|
||||
define('PATH_UPLOADS_PAGES', PATH_UPLOADS.'pages'.DS);
|
||||
define('PATH_UPLOADS_PROFILES', PATH_UPLOADS.'profiles'.DS);
|
||||
define('PATH_UPLOADS_THUMBNAILS', PATH_UPLOADS.'thumbnails'.DS);
|
||||
|
||||
|
@ -171,6 +172,7 @@ define('HTML_PATH_CORE_JS', HTML_PATH_ROOT.'bl-kernel/js/');
|
|||
define('HTML_PATH_CORE_CSS', HTML_PATH_ROOT.'bl-kernel/css/');
|
||||
define('HTML_PATH_CONTENT', HTML_PATH_ROOT.'bl-content/');
|
||||
define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'bl-content/uploads/');
|
||||
define('HTML_PATH_UPLOADS_PAGES', HTML_PATH_UPLOADS.'pages/');
|
||||
define('HTML_PATH_UPLOADS_PROFILES', HTML_PATH_UPLOADS.'profiles/');
|
||||
define('HTML_PATH_UPLOADS_THUMBNAILS', HTML_PATH_UPLOADS.'thumbnails/');
|
||||
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
|
||||
|
@ -199,6 +201,12 @@ define('EXTREME_FRIENDLY_URL', $site->extremeFriendly());
|
|||
// Minutes to execute the autosave function
|
||||
define('AUTOSAVE_INTERVAL', $site->autosaveInterval());
|
||||
|
||||
// TRUE for upload images restric to a pages, FALSE to upload images in common
|
||||
define('IMAGE_RESTRICT', $site->imageRestrict());
|
||||
|
||||
// TRUE to convert relatives images to absoultes, FALSE No changes apply
|
||||
define('IMAGE_RELATIVE_TO_ABSOLUTE', $site->imageRelativeToAbsolute());
|
||||
|
||||
// --- PHP paths with dependency ---
|
||||
// This paths are absolutes for the OS
|
||||
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$site->theme().DS);
|
||||
|
@ -222,6 +230,7 @@ define('DOMAIN_ADMIN_THEME', DOMAIN.HTML_PATH_ADMIN_THEME);
|
|||
define('DOMAIN_ADMIN_THEME_CSS', DOMAIN.HTML_PATH_ADMIN_THEME_CSS);
|
||||
define('DOMAIN_ADMIN_THEME_JS', DOMAIN.HTML_PATH_ADMIN_THEME_JS);
|
||||
define('DOMAIN_UPLOADS', DOMAIN.HTML_PATH_UPLOADS);
|
||||
define('DOMAIN_UPLOADS_PAGES', DOMAIN.HTML_PATH_UPLOADS_PAGES);
|
||||
define('DOMAIN_UPLOADS_PROFILES', DOMAIN.HTML_PATH_UPLOADS_PROFILES);
|
||||
define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS);
|
||||
define('DOMAIN_PLUGINS', DOMAIN.HTML_PATH_PLUGINS);
|
||||
|
|
|
@ -20,19 +20,14 @@ define('ALERT_STATUS_OK', 0);
|
|||
// Alert status fail
|
||||
define('ALERT_STATUS_FAIL', 1);
|
||||
|
||||
// Amount of thumbnails shown on Bludit Quick images
|
||||
define('THUMBNAILS_AMOUNT', 6);
|
||||
|
||||
// Thubmnails size
|
||||
define('THUMBNAILS_WIDTH', 400);
|
||||
define('THUMBNAILS_HEIGHT', 400);
|
||||
define('THUMBNAILS_QUALITY', 100); // 100%
|
||||
|
||||
// Profile image size
|
||||
define('PROFILE_IMG_WIDTH', 400);
|
||||
define('PROFILE_IMG_HEIGHT', 400);
|
||||
define('PROFILE_IMG_QUALITY', 100); // 100%
|
||||
|
||||
// Items per page for admin area
|
||||
define('ITEMS_PER_PAGE_ADMIN', 20);
|
||||
|
||||
// Password length
|
||||
define('PASSWORD_LENGTH', 6);
|
||||
|
||||
|
@ -42,18 +37,6 @@ define('SALT_LENGTH', 8);
|
|||
// Page brake string
|
||||
define('PAGE_BREAK', '<!-- pagebreak -->');
|
||||
|
||||
// Parent key for the array $pagesByParents
|
||||
define('PARENT', 'BLUDIT3849abb4cb7abd24c2d8dac17b216f17');
|
||||
|
||||
// Items per page for admin area
|
||||
define('ITEMS_PER_PAGE_ADMIN', 20);
|
||||
|
||||
// Cli mode, status for new pages
|
||||
define('CLI_STATUS', 'published');
|
||||
|
||||
// Cli mode, username for new pages
|
||||
define('CLI_USERNAME', 'admin');
|
||||
|
||||
// Remember me
|
||||
define('REMEMBER_COOKIE_USERNAME', 'BLUDITREMEMBERUSERNAME');
|
||||
define('REMEMBER_COOKIE_TOKEN', 'BLUDITREMEMBERTOKEN');
|
||||
|
@ -109,15 +92,17 @@ define('SESSION_GC_MAXLIFETIME', 3600);
|
|||
// The value 0 means until the browser is closed
|
||||
define('SESSION_COOKIE_LIFE_TIME', 0);
|
||||
|
||||
// New Global Variables
|
||||
$GLOBALS['BLUDIT_MEDIA_MANAGER_AMOUNT_OF_FILES'] = 5;
|
||||
$GLOBALS['BLUDIT_MEDIA_MANAGER_SORT_BY_DATE'] = true;
|
||||
// Alert notification dissappear in X seconds
|
||||
$GLOBALS['ALERT_DISSAPEAR_IN'] = 3; // Seconds
|
||||
|
||||
// Number of images to show in the media manager per page
|
||||
$GLOBALS['MEDIA_MANAGER_NUMBER_OF_FILES'] = 5;
|
||||
|
||||
// Sort the image by date
|
||||
$GLOBALS['MEDIA_MANAGER_SORT_BY_DATE'] = true;
|
||||
|
||||
// Thubmnails size
|
||||
$GLOBALS['THUMBNAILS_WIDTH'] = 400;
|
||||
$GLOBALS['THUMBNAILS_HEIGHT'] = 400;
|
||||
$GLOBALS['THUMBNAILS_QUALITY'] = 100;
|
||||
|
||||
// Alert
|
||||
$GLOBALS['ALERT_DISSAPEAR_IN'] = 3; // Seconds
|
||||
|
||||
|
|
|
@ -52,8 +52,7 @@ class Filesystem {
|
|||
|
||||
public static function mkdir($pathname, $recursive=false)
|
||||
{
|
||||
// DEBUG: Ver permisos si son correctos
|
||||
return mkdir($pathname, 0755, $recursive);
|
||||
return mkdir($pathname, DIR_PERMISSIONS, $recursive);
|
||||
}
|
||||
|
||||
public static function rmdir($pathname)
|
||||
|
@ -98,7 +97,7 @@ class Filesystem {
|
|||
// Check $destionation directory if exists
|
||||
if (!self::directoryExists($destination)) {
|
||||
// Create the $destination directory
|
||||
if (!mkdir($destination, 0755, true)) {
|
||||
if (!mkdir($destination, DIR_PERMISSIONS, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ echo 'var HTML_PATH_ADMIN_THEME = "'.HTML_PATH_ADMIN_THEME.'";'.PHP_EOL;
|
|||
echo 'var HTML_PATH_ADMIN_THEME_IMG = "'.HTML_PATH_ADMIN_THEME_IMG.'";'.PHP_EOL;
|
||||
echo 'var HTML_PATH_UPLOADS = "'.HTML_PATH_UPLOADS.'";'.PHP_EOL;
|
||||
echo 'var HTML_PATH_UPLOADS_THUMBNAILS = "'.HTML_PATH_UPLOADS_THUMBNAILS.'";'.PHP_EOL;
|
||||
echo 'var PARENT = "'.PARENT.'";'.PHP_EOL;
|
||||
echo 'var BLUDIT_VERSION = "'.BLUDIT_VERSION.'";'.PHP_EOL;
|
||||
echo 'var BLUDIT_BUILD = "'.BLUDIT_BUILD.'";'.PHP_EOL;
|
||||
echo 'var DOMAIN_UPLOADS = "'.DOMAIN_UPLOADS.'";'.PHP_EOL;
|
||||
|
|
|
@ -83,7 +83,10 @@ class Page {
|
|||
$content = $parsedown->text($content);
|
||||
|
||||
// Parse img src relative to absolute (with domain)
|
||||
$content = Text::imgRel2Abs($content, DOMAIN_UPLOADS);
|
||||
if (IMAGE_RELATIVE_TO_ABSOLUTE) {
|
||||
$domain = IMAGE_RESTRICT?DOMAIN_UPLOADS_PAGES.$this->uuid().'/':DOMAIN_UPLOADS;
|
||||
$content = Text::imgRel2Abs($content, $domain);
|
||||
}
|
||||
|
||||
if ($sanitize) {
|
||||
return Sanitize::html($content);
|
||||
|
|
|
@ -38,7 +38,9 @@ class Site extends dbJSON {
|
|||
'titleFormatHomepage'=> '{{site-slogan}} | {{site-title}}',
|
||||
'titleFormatPages'=> '{{page-title}} | {{site-title}}',
|
||||
'titleFormatCategory'=> '{{category-name}} | {{site-title}}',
|
||||
'titleFormatTag'=> '{{tag-name}} | {{site-title}}'
|
||||
'titleFormatTag'=> '{{tag-name}} | {{site-title}}',
|
||||
'imageRestrict'=> true,
|
||||
'imageRelativeToAbsolute'=> false
|
||||
);
|
||||
|
||||
function __construct()
|
||||
|
@ -168,6 +170,16 @@ class Site extends dbJSON {
|
|||
return $this->getField('orderBy');
|
||||
}
|
||||
|
||||
public function imageRestrict()
|
||||
{
|
||||
return $this->getField('imageRestrict');
|
||||
}
|
||||
|
||||
public function imageRelativeToAbsolute()
|
||||
{
|
||||
return $this->getField('imageRelativeToAbsolute');
|
||||
}
|
||||
|
||||
// Returns the site title
|
||||
public function title()
|
||||
{
|
||||
|
|
|
@ -94,10 +94,10 @@ class pluginRemoteContent extends Plugin {
|
|||
|
||||
Filesystem::deleteRecursive(PATH_PAGES);
|
||||
Filesystem::deleteRecursive(PATH_UPLOADS);
|
||||
mkdir(PATH_PAGES, 0755, true);
|
||||
mkdir(PATH_UPLOADS, 0755, true);
|
||||
mkdir(PATH_UPLOADS_PROFILES, 0755, true);
|
||||
mkdir(PATH_UPLOADS_THUMBNAILS, 0755, true);
|
||||
mkdir(PATH_PAGES, DIR_PERMISSIONS, true);
|
||||
mkdir(PATH_UPLOADS, DIR_PERMISSIONS, true);
|
||||
mkdir(PATH_UPLOADS_PROFILES, DIR_PERMISSIONS, true);
|
||||
mkdir(PATH_UPLOADS_THUMBNAILS, DIR_PERMISSIONS, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class pluginRemoteContent extends Plugin {
|
|||
{
|
||||
$workspace = $this->workspace();
|
||||
Filesystem::deleteRecursive($workspace.DS);
|
||||
mkdir($workspace, 0755, true);
|
||||
mkdir($workspace, DIR_PERMISSIONS, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,6 @@ tinymce.init({
|
|||
paste_as_text: true,
|
||||
relative_urls: true,
|
||||
remove_script_host: false,
|
||||
document_base_url: DOMAIN_UPLOADS,
|
||||
plugins: ["$plugins"],
|
||||
toolbar1: "$toolbar1",
|
||||
toolbar2: "$toolbar2",
|
||||
|
@ -130,6 +129,8 @@ tinymce.init({
|
|||
|
||||
</script>
|
||||
EOF;
|
||||
// document_base_url: DOMAIN_UPLOADS,
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
|
|
|
@ -305,6 +305,11 @@ function install($adminPassword, $timezone)
|
|||
error_log('[ERROR] '.$errorText, 0);
|
||||
}
|
||||
|
||||
if (!mkdir(PATH_UPLOADS_PAGES, DIR_PERMISSIONS, true)) {
|
||||
$errorText = 'Error when trying to created the directory=>'.PATH_UPLOADS_PAGES;
|
||||
error_log('[ERROR] '.$errorText, 0);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Create files
|
||||
// ============================================================================
|
||||
|
@ -391,7 +396,9 @@ function install($adminPassword, $timezone)
|
|||
'titleFormatHomepage'=>'{{site-slogan}} | {{site-title}}',
|
||||
'titleFormatPages'=>'{{page-title}} | {{site-title}}',
|
||||
'titleFormatCategory'=>'{{category-name}} | {{site-title}}',
|
||||
'titleFormatTag'=>'{{tag-name}} | {{site-title}}'
|
||||
'titleFormatTag'=>'{{tag-name}} | {{site-title}}',
|
||||
'imageRestrict'=>true,
|
||||
'imageRelativeToAbsolute'=>false
|
||||
);
|
||||
file_put_contents(PATH_DATABASES.'site.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
||||
|
||||
|
|
Loading…
Reference in New Issue