Page URL from title, UUID for pages files
This commit is contained in:
parent
347bc6fbbb
commit
1d6e1d8fc0
3 changed files with 36 additions and 30 deletions
|
@ -38,7 +38,7 @@
|
|||
// Set the global variable with the page key
|
||||
_pageKey = response.data.key;
|
||||
// Set Friendly URL
|
||||
$('#friendlyURL').val(response.data.key);
|
||||
//$('#friendlyURL').val(response.data.key);
|
||||
// Get current files
|
||||
fmGetFiles();
|
||||
} else {
|
||||
|
@ -76,7 +76,7 @@
|
|||
// The page key can change after save the page so you need to set again the variable
|
||||
_pageKey = response.data.key;
|
||||
// Set friendly URL with the key
|
||||
$('#friendlyURL').val(response.data.key);
|
||||
//$('#friendlyURL').val(response.data.key);
|
||||
} else {
|
||||
logs('An error occurred while trying to save the current page.');
|
||||
showAlertError(response.message);
|
||||
|
@ -138,6 +138,7 @@
|
|||
customFields[field] = value
|
||||
});
|
||||
var args = {
|
||||
slug: $('#friendlyURL').val(),
|
||||
title: $('#title').val(),
|
||||
content: editorGetContent(),
|
||||
custom: customFields,
|
||||
|
@ -191,8 +192,8 @@
|
|||
var value = $(this).val()
|
||||
customFields[field] = value
|
||||
});
|
||||
|
||||
var args = {
|
||||
slug: $('#friendlyURL').val(),
|
||||
title: $('#title').val(),
|
||||
content: editorGetContent(),
|
||||
custom: customFields,
|
||||
|
@ -215,6 +216,7 @@
|
|||
});
|
||||
|
||||
$('#coverImagePreview').dblclick(function() {
|
||||
logs('Removing cover image.');
|
||||
$('#coverImage').val('');
|
||||
$(this).attr('src', HTML_PATH_CORE_IMG + 'default.svg');
|
||||
var args = { coverImage: '' }
|
||||
|
@ -389,6 +391,7 @@
|
|||
});
|
||||
|
||||
var args = {
|
||||
slug: $('#friendlyURL').val(),
|
||||
title: $('#title').val(),
|
||||
content: content,
|
||||
custom: customFields,
|
||||
|
|
|
@ -153,8 +153,14 @@ class Pages extends dbJSON {
|
|||
}
|
||||
|
||||
// Create the upload directory for the page
|
||||
if (Filesystem::mkdir(PATH_UPLOADS_PAGES.$key, true) === false) {
|
||||
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to create the directory: '.PATH_UPLOADS_PAGES.$key, LOG_TYPE_ERROR);
|
||||
if (Filesystem::mkdir(PATH_UPLOADS_PAGES.$row['uuid'], true) === false) {
|
||||
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to create the directory: '.PATH_UPLOADS_PAGES.$row['uuid'], LOG_TYPE_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create symlink for the upload directory
|
||||
if (symlink(PATH_UPLOADS_PAGES.$row['uuid'], PATH_UPLOADS_PAGES.$key) === false) {
|
||||
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to create the symlink: '.PATH_UPLOADS_PAGES.$key, LOG_TYPE_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -238,8 +244,12 @@ class Pages extends dbJSON {
|
|||
// If the user send an empty slug the page key doesn't change
|
||||
// This variable is not belong to the database so is not defined in $row
|
||||
if (empty($args['slug'])) {
|
||||
if (!empty($args['title'])) {
|
||||
$slug = $args['title'];
|
||||
} else {
|
||||
$explode = explode('/', $key);
|
||||
$slug = end($explode);
|
||||
}
|
||||
} else {
|
||||
$slug = $args['slug'];
|
||||
}
|
||||
|
@ -271,7 +281,9 @@ class Pages extends dbJSON {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Filesystem::mv(PATH_UPLOADS_PAGES.$key, PATH_UPLOADS_PAGES.$newKey) === false) {
|
||||
// Regenerate the symlink to a proper directory
|
||||
unlink(PATH_UPLOADS_PAGES.$key);
|
||||
if (symlink(PATH_UPLOADS_PAGES.$row['uuid'], PATH_UPLOADS_PAGES.$newKey) === false) {
|
||||
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to move the directory: '.PATH_UPLOADS_PAGES.$newKey, LOG_TYPE_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -954,26 +954,17 @@ class pluginAPI extends Plugin {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Returns all files uploaded for a specific page.
|
||||
Includes all files types.
|
||||
|
||||
@pageKey string The page's key
|
||||
|
||||
@return['data'] array The list of files
|
||||
/**
|
||||
* Returns all files uploaded for a specific page.
|
||||
* @param string $pageKey Page's key
|
||||
* @return array List of files in return['data'], status in return['status']
|
||||
*/
|
||||
private function getFiles($pageKey)
|
||||
{
|
||||
$chunk = false;
|
||||
$sortByDate = true;
|
||||
$path = PATH_UPLOADS_PAGES.$pageKey.DS;
|
||||
|
||||
if (Sanitize::pathFile($path) === false) {
|
||||
return array(
|
||||
'status'=>'1',
|
||||
'message'=>'Invalid path.'
|
||||
);
|
||||
}
|
||||
$page = new Page($pageKey);
|
||||
$path = PATH_UPLOADS_PAGES.$page->uuid().DS;
|
||||
|
||||
$files = array();
|
||||
$listFiles = Filesystem::listFiles($path, '*', '*', $sortByDate, $chunk);
|
||||
|
@ -984,17 +975,17 @@ class pluginAPI extends Plugin {
|
|||
|
||||
$filename = Filesystem::filename($file);
|
||||
$fileExtension = Filesystem::extension($file);
|
||||
$absoluteURL = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename.'.'.$fileExtension;
|
||||
$absolutePath = PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'.'.$fileExtension;
|
||||
$absoluteURL = DOMAIN_UPLOADS_PAGES.$page->uuid().DS.$filename.'.'.$fileExtension;
|
||||
$absolutePath = PATH_UPLOADS_PAGES.$page->uuid().DS.$filename.'.'.$fileExtension;
|
||||
|
||||
$thumbnailSmall = '';
|
||||
if (Filesystem::fileExists(PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-s.'.$fileExtension)) {
|
||||
$thumbnailSmall = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-s.'.$fileExtension;
|
||||
if (Filesystem::fileExists(PATH_UPLOADS_PAGES.$page->uuid().DS.$filename.'-thumbnail-s.'.$fileExtension)) {
|
||||
$thumbnailSmall = DOMAIN_UPLOADS_PAGES.$page->uuid().DS.$filename.'-thumbnail-s.'.$fileExtension;
|
||||
}
|
||||
|
||||
$thumbnailMedium = '';
|
||||
if (Filesystem::fileExists(PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-m.'.$fileExtension)) {
|
||||
$thumbnailMedium = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-m.'.$fileExtension;
|
||||
if (Filesystem::fileExists(PATH_UPLOADS_PAGES.$page->uuid().DS.$filename.'-thumbnail-m.'.$fileExtension)) {
|
||||
$thumbnailMedium = DOMAIN_UPLOADS_PAGES.$page->uuid().DS.$filename.'-thumbnail-m.'.$fileExtension;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
|
|
Loading…
Add table
Reference in a new issue