Happy New Year
[squirrelmail.git] / functions / template / general_util.php
index 512b9f1c8d1517deacc6ea9b09aaf1763c3544c4..cdc9a0a41d3c077643de70d70364423b93d1682a 100644 (file)
@@ -6,7 +6,7 @@
  * This file is intended to contain helper functions for template sets
  * that would like to use them.
  *
  * This file is intended to contain helper functions for template sets
  * that would like to use them.
  *
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright 1999-2018 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
   * @param boolean $alt       Whether or not this is an alternate 
   *                           stylesheet (optional; default TRUE).
   * @param string  $mtype     The target media display type (optional; default "screen").
   * @param boolean $alt       Whether or not this is an alternate 
   *                           stylesheet (optional; default TRUE).
   * @param string  $mtype     The target media display type (optional; default "screen").
-  * @param string  $xhtml_end The XHTML-compliant close tag syntax to 
-  *                           use (optional; default "/")
   *
   * @return string The full text of the stylesheet link.
   *
   */
   *
   * @return string The full text of the stylesheet link.
   *
   */
-function create_css_link($uri, $name='', $alt=TRUE, $mtype='screen', $xhtml_end='/') {
+function create_css_link($uri, $name='', $alt=TRUE, $mtype='screen') {
 // FIXME: Add closing / to link and meta elements only after 
 //        switching to xhtml 1.0 Transitional.
 //        It is not compatible with html 4.01 Transitional
 // FIXME: Add closing / to link and meta elements only after 
 //        switching to xhtml 1.0 Transitional.
 //        It is not compatible with html 4.01 Transitional
-$xhtml_end='';
-
     if (empty($uri)) {
         return '';
     }
     if (empty($uri)) {
         return '';
     }
@@ -72,7 +68,7 @@ $xhtml_end='';
         $rel   = 'rel="'.( $alt ? 'alternate ' : '' ).'stylesheet" ';
     }
 
         $rel   = 'rel="'.( $alt ? 'alternate ' : '' ).'stylesheet" ';
     }
 
-    return '<link '.$media.$title.$rel.'type="text/css" '.$href." $xhtml_end>\n";
+    return '<link '.$media.$title.$rel.'type="text/css" '.$href." />\n";
 }
 
 
 }
 
 
@@ -83,14 +79,16 @@ $xhtml_end='';
  * @param string $icon_theme_path User's chosen icon set
  * @param string $icon_name File name of the desired icon
  * @param string $text_icon Text-based icon to display if desired
  * @param string $icon_theme_path User's chosen icon set
  * @param string $icon_name File name of the desired icon
  * @param string $text_icon Text-based icon to display if desired
- * @param string $alt_text Optional.  Text for alt/title attribute of image
+ * @param string $alt_text Text for alt/title attribute of image
  * @param integer $w Optional.  Width of requested image.
  * @param integer $h Optional.  Height of requested image.
  * @param integer $w Optional.  Width of requested image.
  * @param integer $h Optional.  Height of requested image.
+ *
  * @return string $icon String containing icon that can be echo'ed
  * @return string $icon String containing icon that can be echo'ed
+ *
  * @author Steve Brown
  * @since 1.5.2
  */
  * @author Steve Brown
  * @since 1.5.2
  */
-function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL, $h=NULL) {
+function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text, $w=NULL, $h=NULL) {
     $icon = '';
     if (is_null($icon_theme_path)) {
         $icon = $text_icon;
     $icon = '';
     if (is_null($icon_theme_path)) {
         $icon = $text_icon;
@@ -100,25 +98,8 @@ function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL
         // If we found an icon, build an img tag to display it.  If we didn't
         // find an image, we will revert back to the text icon.
         if (!is_null($icon_path)) {
         // If we found an icon, build an img tag to display it.  If we didn't
         // find an image, we will revert back to the text icon.
         if (!is_null($icon_path)) {
-            global $oTemplate;
-            $oTemplate->assign('src', $icon_path);
-            $oTemplate->assign('alt', $alt_text);
-            $oTemplate->assign('title', $alt_text);
-            $oTemplate->assign('width', $w);
-            $oTemplate->assign('height', $h);
-
-            // blank other attributes because the template 
-            // object might already contain values due to 
-            // having been used to show another image before
-            // this one
-            //
-            $oTemplate->assign('onclick', '');
-            $oTemplate->assign('align', '');
-            $oTemplate->assign('border', '');
-            $oTemplate->assign('hspace', '');
-            $oTemplate->assign('vspace', '');
-
-            $icon = $oTemplate->fetch('image.tpl');
+            $icon = create_image($icon_path, $alt_text, $w, $h, '', '', '', 
+                                 '', $alt_text, '', '', '', $text_icon);
         } else {
             $icon = $text_icon;
         }
         } else {
             $icon = $text_icon;
         }
@@ -134,10 +115,13 @@ function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL
  *
  * @param string $icon_theme_path User's chosen icon set
  * @param string $icon_name File name of the desired icon
  *
  * @param string $icon_theme_path User's chosen icon set
  * @param string $icon_name File name of the desired icon
+ *
  * @return string $icon String containing path to icon that can be used in
  *                      an IMG tag, or NULL if the image is not found.
  * @return string $icon String containing path to icon that can be used in
  *                      an IMG tag, or NULL if the image is not found.
+ *
  * @author Steve Brown
  * @since 1.5.2
  * @author Steve Brown
  * @since 1.5.2
+ *
  */
 function getIconPath ($icon_theme_path, $icon_name) {
     global $fallback_icon_theme_path;
  */
 function getIconPath ($icon_theme_path, $icon_name) {
     global $fallback_icon_theme_path;
@@ -146,14 +130,17 @@ function getIconPath ($icon_theme_path, $icon_name) {
         return NULL;
 
     // Desired icon exists in the current theme?
         return NULL;
 
     // Desired icon exists in the current theme?
+//FIXME: this assumes a URI path will be valid when used as a filesystem path - this will fail for some systems -- OTOH, if $icon_theme_path is meant as an internal filesystem path to the user's chosen theme directory, then the assumption that is wrong here is that this internal filesystem path is always correct for use as part of a URI.  This really should be mapped to/from an internal path to a URI path -- or can we guarantee that the two are always the same?
     if (is_file($icon_theme_path . $icon_name)) {
         return $icon_theme_path . $icon_name;
 
     // Icon not found, check for the admin-specified fallback
     if (is_file($icon_theme_path . $icon_name)) {
         return $icon_theme_path . $icon_name;
 
     // Icon not found, check for the admin-specified fallback
+//FIXME: same problem here as above
     } elseif (!is_null($fallback_icon_theme_path) && is_file($fallback_icon_theme_path . $icon_name)) {
         return $fallback_icon_theme_path . $icon_name;
 
     // Icon not found, return the SQM default icon
     } elseif (!is_null($fallback_icon_theme_path) && is_file($fallback_icon_theme_path . $icon_name)) {
         return $fallback_icon_theme_path . $icon_name;
 
     // Icon not found, return the SQM default icon
+//FIXME: same problem here -- SM_PATH is *NOT* intended for use in URIs
     } elseif (is_file(SM_PATH . 'images/themes/default/'.$icon_name)) {
         return SM_PATH . 'images/themes/default/'.$icon_name;
     }
     } elseif (is_file(SM_PATH . 'images/themes/default/'.$icon_name)) {
         return SM_PATH . 'images/themes/default/'.$icon_name;
     }
@@ -188,5 +175,3 @@ function displayErrors () {
 function humanReadableSize ($size) {
     return show_readable_size($size);
 }
 function humanReadableSize ($size) {
     return show_readable_size($size);
 }
-
-