diff --git a/bl-kernel/admin/controllers/edit-content.php b/bl-kernel/admin/controllers/edit-content.php index 0566ea95..0b5ba1d2 100644 --- a/bl-kernel/admin/controllers/edit-content.php +++ b/bl-kernel/admin/controllers/edit-content.php @@ -64,11 +64,28 @@ 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'); } +// Images prefix directory +define('PAGE_IMAGES_KEY', $page->uuid()); + +// Images and thubmnails directories +if (IMAGE_RESTRICT) { + define('PAGE_IMAGES_DIRECTORY', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : HTML_PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/')); + define('PAGE_IMAGES_URL', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : DOMAIN_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/')); + define('PAGE_THUMBNAILS_DIRECTORY', PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.DS.'thumbnails'.DS); + define('PAGE_THUMBNAILS_HTML', HTML_PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/thumbnails/'); + define('PAGE_THUMBNAILS_URL', DOMAIN_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/thumbnails/'); +} else { + define('PAGE_IMAGES_DIRECTORY', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : HTML_PATH_UPLOADS)); + define('PAGE_IMAGES_URL', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : DOMAIN_UPLOADS)); + define('PAGE_THUMBNAILS_DIRECTORY', PATH_UPLOADS_THUMBNAILS); + define('PAGE_THUMBNAILS_HTML', HTML_PATH_UPLOADS_THUMBNAILS); + define('PAGE_THUMBNAILS_URL', DOMAIN_UPLOADS_THUMBNAILS); +} + // Title of the page $layout['title'] .= ' - '.$L->g('Edit content').' - '.$page->title(); \ No newline at end of file diff --git a/bl-kernel/admin/controllers/new-content.php b/bl-kernel/admin/controllers/new-content.php index 908a4d2a..38486fbc 100644 --- a/bl-kernel/admin/controllers/new-content.php +++ b/bl-kernel/admin/controllers/new-content.php @@ -35,5 +35,26 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { // UUID of the page is need it for autosave and media manager $uuid = $pages->generateUUID(); +// Images prefix directory +define('PAGE_IMAGES_KEY', $uuid); + +// Images and thubmnails directories +if (IMAGE_RESTRICT) { + define('PAGE_IMAGES_DIRECTORY', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : HTML_PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/')); + define('PAGE_IMAGES_URL', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : DOMAIN_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/')); + define('PAGE_THUMBNAILS_DIRECTORY', PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.DS.'thumbnails'.DS); + define('PAGE_THUMBNAILS_HTML', HTML_PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/thumbnails/'); + define('PAGE_THUMBNAILS_URL', DOMAIN_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/thumbnails/'); + + // Create the directory to store the images + Filesystem::mkdir(PAGE_THUMBNAILS_DIRECTORY, true); +} else { + define('PAGE_IMAGES_DIRECTORY', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : HTML_PATH_UPLOADS)); + define('PAGE_IMAGES_URL', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : DOMAIN_UPLOADS)); + define('PAGE_THUMBNAILS_DIRECTORY', PATH_UPLOADS_THUMBNAILS); + define('PAGE_THUMBNAILS_HTML', HTML_PATH_UPLOADS_THUMBNAILS); + define('PAGE_THUMBNAILS_URL', DOMAIN_UPLOADS_THUMBNAILS); +} + // Title of the page $layout['title'] = $L->g('New content').' - '.$layout['title']; \ No newline at end of file diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index d6f3c125..5018f4b9 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -24,7 +24,7 @@ echo Bootstrap::formOpen(array( // The UUID is generated in the controller echo Bootstrap::formInputHidden(array( 'name'=>'uuid', - 'value'=>$uuid + 'value'=>$page->uuid() )); // Type = published, draft, sticky, static @@ -61,20 +61,8 @@ echo Bootstrap::formOpen(array(