Browse code

bgcolor und pen wurden nicht korrekt übernommen

Hagen Klemp authored on22/09/2023 20:10:32
Showing1 changed files
... ...
@@ -3,7 +3,7 @@
3 3
 /**
4 4
  * Extension for Contao 4
5 5
  *
6
- * @copyright  Softleister 2019
6
+ * @copyright  Softleister 2019-2023
7 7
  * @author     Softleister <info@softleister.de>
8 8
  * @package    contao-signature-formfield-bundle
9 9
  *             based on jSignature (https://github.com/brinley/jSignature)
... ...
@@ -12,6 +12,9 @@
12 12
 
13 13
 namespace Softleister;
14 14
 
15
+use Contao\Widget;
16
+use Contao\StringUtil;
17
+
15 18
 /**
16 19
  * Class FormSignature
17 20
  *
... ...
@@ -23,75 +26,67 @@ namespace Softleister;
23 26
  * @property integer $rows
24 27
  * @property integer $cols
25 28
  */
26
-class FormSignature extends \Widget
29
+class FormSignature extends Widget
27 30
 {
28
-	protected $blnSubmitInput = true;					// Submit user input		@var boolean
29
-	protected $strTemplate = 'form_signature';			// Template					@var string
30
-	protected $strPrefix = 'widget widget-signature';	// The CSS class prefix		@var string
31
-
32
-	/**
33
-	 * Add specific attributes
34
-	 *
35
-	 * @param string $strKey   The attribute name
36
-	 * @param mixed  $varValue The attribute value
37
-	 */
38
-	public function __set( $strKey, $varValue )
39
-	{
40
-		switch( $strKey ) {
41
-			case 'sig_size':		$arrSize = \StringUtil::deserialize($varValue);
42
-									$this->intWidth = is_numeric($arrSize[0]) ? $arrSize[0] : 500;
43
-									$this->intHeight = is_numeric($arrSize[1]) ? $arrSize[1] : 250;
44
-									break;
45
-
46
-			case 'sig_bgcolor':		$this->sig_bgcolor = empty($this->sig_bgcolor) ? 'transparent' : '#' . $this->sig_bgcolor;
47
-									break;
48
-
49
-			case 'sig_width':		$this->sig_width = is_numeric($this->sig_width) && ($this->sig_width > 0) ? $this->sig_width : 5;
50
-									break;
51
-
52
-			case 'sig_color':		$varValue = $varValue == '' ? '000' : $varValue;
31
+    protected $blnSubmitInput = true;                   // Submit user input        @var boolean
32
+    protected $strTemplate = 'form_signature';          // Template                 @var string
33
+    protected $strPrefix = 'widget widget-signature';   // The CSS class prefix     @var string
53 34
 
54
-			default:				parent::__set($strKey, $varValue);
55
-		}
56
-	}
35
+    /**
36
+     * Add specific attributes
37
+     *
38
+     * @param string $strKey   The attribute name
39
+     * @param mixed  $varValue The attribute value
40
+     */
41
+    public function __set( $strKey, $varValue )
42
+    {
43
+        switch( $strKey ) {
44
+            case 'sig_size':        $arrSize = StringUtil::deserialize( $varValue );
45
+                                    $this->intWidth = is_numeric( $arrSize[0] ) ? $arrSize[0] : 500;
46
+                                    $this->intHeight = is_numeric( $arrSize[1] ) ? $arrSize[1] : 250;
47
+                                    break;
57 48
 
58
-	/**
59
-	 * Return a parameter
60
-	 *
61
-	 * @param string $strKey The parameter key
62
-	 *
63
-	 * @return mixed The parameter value
64
-	 */
65
-	public function __get( $strKey )
66
-	{
67
-		switch( $strKey ) {
68
-			case 'width':			return $this->intWidth;
69
-									break;
49
+            case 'sig_bgcolor':     
50
+                                    $this->sig_bgcolor = empty( $varValue ) ? 'transparent' : '#' . $varValue;
51
+                                    break;
70 52
 
71
-			case 'height':			return $this->intHeight;
72
-									break;
53
+            case 'sig_width':       
54
+                                    $this->sig_width = is_numeric( $varValue ) && ($varValue > 0) ? $varValue : 5;
55
+                                    break;
73 56
 
74
-			case 'pen':				return $this->sig_width;
75
-									break;
57
+            case 'sig_color':       $varValue = $varValue == '' ? '#000' : '#' . $varValue;
76 58
 
77
-			case 'color':			return $this->sig_color;
78
-									break;
59
+            default:                parent::__set( $strKey, $varValue );
60
+        }
61
+    }
79 62
 
80
-			case 'bgcolor':			return $this->sig_bgcolor;
81
-									break;
63
+    /**
64
+     * Return a parameter
65
+     *
66
+     * @param string $strKey The parameter key
67
+     *
68
+     * @return mixed The parameter value
69
+     */
70
+    public function __get( $strKey )
71
+    {
72
+        switch( $strKey ) {
73
+            case 'width':           return $this->intWidth;
74
+            case 'height':          return $this->intHeight;
75
+            case 'pen':             return $this->sig_width;
76
+            case 'color':           return $this->sig_color;
77
+            case 'bgcolor':         return $this->sig_bgcolor;
82 78
 
83
-			default:				return parent::__get($strKey);
84
-									break;
85
-		}
86
-	}
79
+            default:                return parent::__get( $strKey );
80
+        }
81
+    }
87 82
 
88
-	/**
89
-	 * Generate the widget and return it as string
90
-	 *
91
-	 * @return string The widget markup
92
-	 */
93
-	public function generate( )
94
-	{
95
-		return '';
96
-	}
83
+    /**
84
+     * Generate the widget and return it as string
85
+     *
86
+     * @return string The widget markup
87
+     */
88
+    public function generate( )
89
+    {
90
+        return '';
91
+    }
97 92
 }
Browse code

Stiftfarbe

Hagen Klemp authored on18/02/2019 17:47:20
Showing1 changed files
... ...
@@ -46,12 +46,11 @@ class FormSignature extends \Widget
46 46
 			case 'sig_bgcolor':		$this->sig_bgcolor = empty($this->sig_bgcolor) ? 'transparent' : '#' . $this->sig_bgcolor;
47 47
 									break;
48 48
 
49
-			case 'sig_color':		if(empty($this->sig_color)) $this->sig_color = '000';
50
-									break;
51
-
52 49
 			case 'sig_width':		$this->sig_width = is_numeric($this->sig_width) && ($this->sig_width > 0) ? $this->sig_width : 5;
53 50
 									break;
54 51
 
52
+			case 'sig_color':		$varValue = $varValue == '' ? '000' : $varValue;
53
+
55 54
 			default:				parent::__set($strKey, $varValue);
56 55
 		}
57 56
 	}
Browse code

Initial

Hagen Klemp authored on03/02/2019 23:08:50
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,98 @@
1
+<?php
2
+
3
+/**
4
+ * Extension for Contao 4
5
+ *
6
+ * @copyright  Softleister 2019
7
+ * @author     Softleister <info@softleister.de>
8
+ * @package    contao-signature-formfield-bundle
9
+ *             based on jSignature (https://github.com/brinley/jSignature)
10
+ * @licence    MIT License
11
+ */
12
+
13
+namespace Softleister;
14
+
15
+/**
16
+ * Class FormSignature
17
+ *
18
+ * @property string  $value
19
+ * @property integer $maxlength
20
+ * @property boolean $mandatory
21
+ * @property string  $placeholder
22
+ * @property string  $size
23
+ * @property integer $rows
24
+ * @property integer $cols
25
+ */
26
+class FormSignature extends \Widget
27
+{
28
+	protected $blnSubmitInput = true;					// Submit user input		@var boolean
29
+	protected $strTemplate = 'form_signature';			// Template					@var string
30
+	protected $strPrefix = 'widget widget-signature';	// The CSS class prefix		@var string
31
+
32
+	/**
33
+	 * Add specific attributes
34
+	 *
35
+	 * @param string $strKey   The attribute name
36
+	 * @param mixed  $varValue The attribute value
37
+	 */
38
+	public function __set( $strKey, $varValue )
39
+	{
40
+		switch( $strKey ) {
41
+			case 'sig_size':		$arrSize = \StringUtil::deserialize($varValue);
42
+									$this->intWidth = is_numeric($arrSize[0]) ? $arrSize[0] : 500;
43
+									$this->intHeight = is_numeric($arrSize[1]) ? $arrSize[1] : 250;
44
+									break;
45
+
46
+			case 'sig_bgcolor':		$this->sig_bgcolor = empty($this->sig_bgcolor) ? 'transparent' : '#' . $this->sig_bgcolor;
47
+									break;
48
+
49
+			case 'sig_color':		if(empty($this->sig_color)) $this->sig_color = '000';
50
+									break;
51
+
52
+			case 'sig_width':		$this->sig_width = is_numeric($this->sig_width) && ($this->sig_width > 0) ? $this->sig_width : 5;
53
+									break;
54
+
55
+			default:				parent::__set($strKey, $varValue);
56
+		}
57
+	}
58
+
59
+	/**
60
+	 * Return a parameter
61
+	 *
62
+	 * @param string $strKey The parameter key
63
+	 *
64
+	 * @return mixed The parameter value
65
+	 */
66
+	public function __get( $strKey )
67
+	{
68
+		switch( $strKey ) {
69
+			case 'width':			return $this->intWidth;
70
+									break;
71
+
72
+			case 'height':			return $this->intHeight;
73
+									break;
74
+
75
+			case 'pen':				return $this->sig_width;
76
+									break;
77
+
78
+			case 'color':			return $this->sig_color;
79
+									break;
80
+
81
+			case 'bgcolor':			return $this->sig_bgcolor;
82
+									break;
83
+
84
+			default:				return parent::__get($strKey);
85
+									break;
86
+		}
87
+	}
88
+
89
+	/**
90
+	 * Generate the widget and return it as string
91
+	 *
92
+	 * @return string The widget markup
93
+	 */
94
+	public function generate( )
95
+	{
96
+		return '';
97
+	}
98
+}