Code

Updated smarty image function
[gosa.git] / gosa-core / include / functions.inc
index fd8252b1ff4e11c06ba8bf22bf764c4cd765e8fb..aeb543b7e0c7e89c3243e312f90c2284b6ec1769 100644 (file)
@@ -3519,8 +3519,12 @@ function mark($needle, $haystack, $ignorecase= true)
 
 
 /* Return an image description using the path */
-function image($path, $label= null)
+function image($path, $action= "", $title= "", $align= "middle")
 {
+  global $config;
+  global $BASE_DIR;
+  $label= null;
+
   // Bail out, if there's no style file
   if(!session::global_is_set("img-styles")){
 
@@ -3541,6 +3545,11 @@ function image($path, $label= null)
   }
   $styles= session::global_get('img-styles');
 
+  /* Extract labels from path */
+  if (preg_match("/\.png\[(.*)\]$/", $path, $matches)) {
+    $label= $matches[1];
+  }
+
   $lbl= "";
   if ($label) {
     if (isset($styles["images/label-".$label.".png"])) {
@@ -3548,9 +3557,26 @@ function image($path, $label= null)
     } else {
       die("Invalid label specified: $label\n");
     }
+
+    $path= preg_replace("/\[.*\]$/", "", $path);
   }
 
-  return "<div class='img' style='".$styles[$path]."'>$lbl</div>";
+  // Non middle layout?
+  if ($align == "middle") {
+    $align= "";
+  } else {
+    $align= ";vertical-align:$align";
+  }
+
+  // Clickable image or not?
+  if ($title != "") {
+    $title= "title='$title'";
+  }
+  if ($action == "") {
+    return "<div class='img' $title style='".$styles[$path]."$align'>$lbl</div>";
+  } else {
+    return "<input type='submit' class='img' id='$action' value='' name='$action' $title style='".$styles[$path]."$align'>";
+  }
 }