custompages.lib.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. // Custom Pages lib
  3. // Used to implement the loading of custom pages
  4. // 2011, Jean-Karim Bockstael <jeankarim@cblue.be>
  5. require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
  6. class CustomPages {
  7. public static function displayPage($page_name, $content=array()) {
  8. $pages_dir = api_get_path(SYS_PATH).'custompages/';
  9. $file_name = $pages_dir.$page_name.'.php';
  10. if (file_exists($file_name)) {
  11. include($file_name);
  12. exit;
  13. }
  14. else {
  15. error_log('CustomPages::displayPage : could not read file '.$file_name);
  16. }
  17. }
  18. public static function getURLImages($url_id = null) {
  19. if (is_null($url_id)) {
  20. $url = 'http://'.$_SERVER['HTTP_HOST'].'/';
  21. $url_id = UrlManager::get_url_id($url);
  22. }
  23. $url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';
  24. $images = array();
  25. for ($img_id = 1; $img_id <= 3; $img_id++) {
  26. if (file_exists($url_images_dir.$url_id.'_url_image_'.$img_id.'.png')) {
  27. $images[] = api_get_path(WEB_PATH).'custompages/url-images/'.$url_id.'_url_image_'.$img_id.'.png';
  28. }
  29. }
  30. return $images;
  31. }
  32. }
  33. ?>