From c1075c3623f0dc8cd46737c493813ec0881fe632 Mon Sep 17 00:00:00 2001 From: jkbockstael Date: Wed, 6 Jul 2011 12:27:55 +0200 Subject: [PATCH] Custom Pages : added a function to get the images belonging to the current URL (or any other). --- custompages/url-images/README | 2 ++ main/inc/lib/custompages.lib.php | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/custompages/url-images/README b/custompages/url-images/README index 929dca9dac..543a49d0c2 100644 --- a/custompages/url-images/README +++ b/custompages/url-images/README @@ -1,3 +1,5 @@ Custom Pages : URL Images This features allows each access URL to have a number of images (currently three) specific to this URL. This allows easier customization of landing pages by access URL. + +You can access a URL's images by calling the static function CustomPages::getURLImages() in your custom page. diff --git a/main/inc/lib/custompages.lib.php b/main/inc/lib/custompages.lib.php index 7f1804a737..57425934cd 100644 --- a/main/inc/lib/custompages.lib.php +++ b/main/inc/lib/custompages.lib.php @@ -3,6 +3,8 @@ // Used to implement the loading of custom pages // 2011, Jean-Karim Bockstael +require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php'; + class CustomPages { public static function displayPage($page_name) { @@ -16,5 +18,20 @@ class CustomPages { error_log('CustomPages::displayPage : could not read file '.$file_name); } } + + public static function getURLImages($url_id = null) { + if (is_null($url_id)) { + $url = 'http://'.$_SERVER['HTTP_HOST'].'/'; + $url_id = UrlManager::get_url_id($url); + } + $url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/'; + $images = array(); + for ($img_id = 1; $img_id <= 3; $img_id++) { + if (file_exists($url_images_dir.$url_id.'_url_image_'.$img_id.'.png')) { + $images[] = api_get_path(WEB_PATH).'custompages/url-images/'.$url_id.'_url_image_'.$img_id.'.png'; + } + } + return $images; + } } ?>