Bläddra i källkod

Allow control over white space wrapping of auto-generated SquirrelMail option widgets

pdontthink 17 år sedan
förälder
incheckning
60ff13d11e
3 ändrade filer med 22 tillägg och 1 borttagningar
  1. 2 0
      ChangeLog
  2. 19 0
      functions/options.php
  3. 1 1
      templates/default/options.tpl

+ 2 - 0
ChangeLog

@@ -263,6 +263,8 @@ Version 1.5.2 - SVN
     using POP before SMTP.
   - Seed random number generator in one place during script init.
   - Add native output buffering.
+  - Allow control over white space wrapping of auto-generated SquirrelMail
+    option widgets.
 
 Version 1.5.1 (branched on 2006-02-12)
 --------------------------------------

+ 19 - 0
functions/options.php

@@ -34,6 +34,11 @@ class SquirrelOption {
      * @var string
      */
     var $caption;
+    /**
+     * Whether or not the caption text is allowed to wrap
+     * @var boolean
+     */
+    var $caption_wrap;
     /**
      * The type of INPUT element
      *
@@ -177,6 +182,7 @@ class SquirrelOption {
         $this->raw_option_array = $raw_option_array;
         $this->name = $name;
         $this->caption = $caption;
+        $this->caption_wrap = TRUE;
         $this->type = $type;
         $this->refresh_level = $refresh_level;
         $this->possible_values = $possible_values;
@@ -238,6 +244,14 @@ class SquirrelOption {
         $this->new_value = $new_value;
     }
 
+    /**
+     * Set whether the caption is allowed to wrap for this option.
+     * @param boolean $caption_wrap
+     */
+    function setCaptionWrap($caption_wrap) {
+        $this->caption_wrap = $caption_wrap;
+    }
+
     /**
      * Set the size for this option.
      * @param integer $size
@@ -910,6 +924,11 @@ function create_option_groups($optgrps, $optvals) {
                     (isset($optset['htmlencoded']) ? $optset['htmlencoded'] : false)
                     );
 
+            /* If provided, set if the caption is allowed to wrap for this option. */
+            if (isset($optset['caption_wrap'])) {
+                $next_option->setCaptionWrap($optset['caption_wrap']);
+            }
+
             /* If provided, set the size for this option. */
             if (isset($optset['size'])) {
                 $next_option->setSize($optset['size']);

+ 1 - 1
templates/default/options.tpl

@@ -45,7 +45,7 @@ foreach ($options as $option) {
     foreach ($option['options'] as $opt) {
         if ($opt->type != SMOPT_TYPE_HIDDEN) {
             echo   "<tr>\n" .
-                   " <td class=\"optionName\">\n  ";
+                   " <td class=\"optionName\"" . ($opt->caption_wrap ? '' : ' style="white-space:nowrap"') . ">\n  ";
 
             if ($opt->type == SMOPT_TYPE_BOOLEAN_CHECKBOX
              || $opt->type == SMOPT_TYPE_BOOLEAN) {