template.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * template.php
  4. *
  5. * This file is intended to contain helper functions for template sets
  6. * that would like to use them.
  7. FIXME: potentially create a separate directory and separate functions into different files?
  8. *
  9. * @copyright &copy; 1999-2006 The SquirrelMail Project Team
  10. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11. * @version $Id$
  12. * @package squirrelmail
  13. */
  14. /**
  15. * Create stylesheet links that will work for multiple browsers
  16. *
  17. * @param string $uri The URI to the linked stylesheet.
  18. * @param string $name The title of the stylesheet (optional; default empty).
  19. * @param boolean $alt Whether or not this is an alternate
  20. * stylesheet (optional; default TRUE).
  21. * @param string $mtype The target media display type (optional; default "screen").
  22. * @param string $xhtml_end The XHTML-compliant close tag syntax to
  23. * use (optional; default "/")
  24. *
  25. * @return string The full text of the stylesheet link.
  26. *
  27. */
  28. function create_css_link($uri, $name='', $alt=TRUE, $mtype='screen', $xhtml_end='/') {
  29. // FIXME: Add closing / to link and meta elements only after
  30. // switching to xhtml 1.0 Transitional.
  31. // It is not compatible with html 4.01 Transitional
  32. $xhtml_end='';
  33. if (empty($uri)) {
  34. return '';
  35. }
  36. // set to lower case to avoid errors
  37. //
  38. sqGetGlobalVar('HTTP_USER_AGENT', $browser_user_agent, SQ_SERVER);
  39. $browser_user_agent = strtolower($browser_user_agent);
  40. if (stristr($browser_user_agent, "msie 4")) {
  41. $browser = 'msie4';
  42. $dom_browser = false;
  43. $is_IE = true;
  44. } elseif (stristr($browser_user_agent, "msie")) {
  45. $browser = 'msie';
  46. $dom_browser = true;
  47. $is_IE = true;
  48. }
  49. if ((strpos($uri, '-ie')!== false) and !$is_IE) {
  50. //not IE, so don't render this sheet
  51. return;
  52. }
  53. if ( strpos($uri, 'print') !== false )
  54. $mtype = 'print';
  55. $href = 'href="'.$uri.'" ';
  56. $media = 'media="'.$mtype.'" ';
  57. if ( empty($name) ) {
  58. $title = '';
  59. $rel = 'rel="stylesheet" ';
  60. } else {
  61. $title = 'title="'.$name.'" ';
  62. $rel = 'rel="'.( $alt ? 'alternate ' : '' ).'stylesheet" ';
  63. }
  64. return '<link '.$media.$title.$rel.'type="text/css" '.$href." $xhtml_end>\n";
  65. }