Setting tag plewww-5.2-3
[plewww.git] / plekit / php / linetabs.php
index f83241a..d2be029 100644 (file)
@@ -45,13 +45,16 @@ drupal_set_html_head('
 //     (the form gets submitted whatever the confirmation....)
 // (*) you need to tune the image size, which is wrong, as the image should rather be bottom-aligned 
 
-function plekit_linetabs ($array, $id=NULL) {
+function plekit_linetabs ($tabs, $id=NULL) {
+  // do not output anything if $tabs has no entry (unpleasant rendering)
+  if (empty ($tabs)) return;
+  $active_line_tab=$_GET['active_line_tab'];
   // need id to pass to the onclick function attached to the input buttons
   $id="linetabs";
   if (! $id) $id .= '-' + $id;
   print "<div id='$id' class='linetabs'>";
   print "<ul>";
-  foreach ($array as $label=>$todo) {
+  foreach ($tabs as $label=>$todo) {
     // in case we have a simple string, rewrite it as an array
     if (is_string ($todo)) $todo=array('method'=>'GET','url'=>$todo);
     // the 'label' key, if set in the hash, supersedes key
@@ -75,9 +78,12 @@ function plekit_linetabs ($array, $id=NULL) {
     if ( ! $values) $values = array();
     if ($url_values) $values = array_merge($values,$url_values);
     if ( $values ) foreach ($values as $key=>$value) {
-       print "<input type='hidden' name='$key' value='$value' />";
-      }
-    $tracer="class='linetabs-submit'";
+      if ($key != "active_line_tab")
+        print "<input type='hidden' name='$key' value='$value' />";
+    }
+    print "<input type='hidden' name='active_line_tab' value='$label' />";
+    if ($label == $active_line_tab) $tracer = "class='linetabs-submit active'";
+    else $tracer="class='linetabs-submit'";
     // image and its companions 'height' 
     if ($todo['image']) {
       $what=$todo['image'];
@@ -89,10 +95,10 @@ function plekit_linetabs ($array, $id=NULL) {
     } else {
       $type="type='button' value='$label'";
     }
-    $bubble=$todo['bubble'];
+    $bubble=htmlspecialchars($todo['bubble'], ENT_QUOTES);
     print "<span title='$bubble'>";
     $message="";
-    if ($todo['confirm']) $message=$todo['confirm'] . " ?";
+    if ($todo['confirm']) $message=htmlspecialchars($todo['confirm'], ENT_QUOTES) . " ?";
     print "<input $tracer $type onclick='linetabs_namespace.submit(\"$id\",\"$message\")' />";
     print "</span>";
     print "</fieldset></form></li>\n";