Completed
Pull Request — master (#607)
by Tortue
01:28
created
src/Former/Framework/TwitterBootstrap.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@
 block discarded – undo
124 124
 		$classes = array_intersect($classes, $this->fields);
125 125
 
126 126
 		// Prepend field type
127
-		$classes = array_map(function ($class) {
127
+		$classes = array_map(function($class) {
128 128
 			return Str::startsWith($class, 'span') ? $class : 'input-'.$class;
129 129
 		}, $classes);
130 130
 
Please login to merge, or discard this patch.
Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -14,374 +14,374 @@
 block discarded – undo
14 14
  */
15 15
 class TwitterBootstrap extends Framework implements FrameworkInterface
16 16
 {
17
-	/**
18
-	 * Form types that trigger special styling for this Framework
19
-	 *
20
-	 * @var array
21
-	 */
22
-	protected $availableTypes = array('horizontal', 'vertical', 'inline', 'search');
23
-
24
-	/**
25
-	 * The button types available
26
-	 *
27
-	 * @var array
28
-	 */
29
-	private $buttons = array(
30
-		'large',
31
-		'small',
32
-		'mini',
33
-		'block',
34
-		'danger',
35
-		'info',
36
-		'inverse',
37
-		'link',
38
-		'primary',
39
-		'success',
40
-		'warning',
41
-	);
42
-
43
-	/**
44
-	 * The field sizes available
45
-	 *
46
-	 * @var array
47
-	 */
48
-	private $fields = array(
49
-		'mini',
50
-		'small',
51
-		'medium',
52
-		'large',
53
-		'xlarge',
54
-		'xxlarge',
55
-		'span1',
56
-		'span2',
57
-		'span3',
58
-		'span4',
59
-		'span5',
60
-		'span6',
61
-		'span7',
62
-		'span8',
63
-		'span9',
64
-		'span10',
65
-		'span11',
66
-		'span12',
67
-	);
68
-
69
-	/**
70
-	 * The field states available
71
-	 *
72
-	 * @var array
73
-	 */
74
-	protected $states = array(
75
-		'success',
76
-		'warning',
77
-		'error',
78
-		'info',
79
-	);
80
-
81
-	/**
82
-	 * Create a new TwitterBootstrap instance
83
-	 *
84
-	 * @param \Illuminate\Container\Container $app
85
-	 */
86
-	public function __construct(Container $app)
87
-	{
88
-		$this->app = $app;
89
-		$this->setFrameworkDefaults();
90
-	}
91
-
92
-	////////////////////////////////////////////////////////////////////
93
-	/////////////////////////// FILTER ARRAYS //////////////////////////
94
-	////////////////////////////////////////////////////////////////////
95
-
96
-	/**
97
-	 * Filter buttons classes
98
-	 *
99
-	 * @param  array $classes An array of classes
100
-	 *
101
-	 * @return string[] A filtered array
102
-	 */
103
-	public function filterButtonClasses($classes)
104
-	{
105
-		// Filter classes
106
-		// $classes = array_intersect($classes, $this->buttons);
107
-
108
-		// Prepend button type
109
-		$classes   = $this->prependWith($classes, 'btn-');
110
-		$classes[] = 'btn';
111
-
112
-		return $classes;
113
-	}
114
-
115
-	/**
116
-	 * Filter field classes
117
-	 *
118
-	 * @param  array $classes An array of classes
119
-	 *
120
-	 * @return array A filtered array
121
-	 */
122
-	public function filterFieldClasses($classes)
123
-	{
124
-		// Filter classes
125
-		$classes = array_intersect($classes, $this->fields);
126
-
127
-		// Prepend field type
128
-		$classes = array_map(function ($class) {
129
-			return Str::startsWith($class, 'span') ? $class : 'input-'.$class;
130
-		}, $classes);
131
-
132
-		return $classes;
133
-	}
134
-
135
-	////////////////////////////////////////////////////////////////////
136
-	///////////////////////////// ADD CLASSES //////////////////////////
137
-	////////////////////////////////////////////////////////////////////
138
-
139
-	/**
140
-	 * Add classes to a field
141
-	 *
142
-	 * @param Field $field
143
-	 * @param array $classes The possible classes to add
144
-	 *
145
-	 * @return Field
146
-	 */
147
-	public function getFieldClasses(Field $field, $classes)
148
-	{
149
-		// Add inline class for checkables
150
-		if ($field->isCheckable() and in_array('inline', $classes)) {
151
-			$field->inline();
152
-		}
153
-
154
-		// Filter classes according to field type
155
-		if ($field->isButton()) {
156
-			$classes = $this->filterButtonClasses($classes);
157
-		} else {
158
-			$classes = $this->filterFieldClasses($classes);
159
-		}
160
-
161
-		return $this->addClassesToField($field, $classes);
162
-	}
163
-
164
-	/**
165
-	 * Add group classes
166
-	 *
167
-	 * @return string A list of group classes
168
-	 */
169
-	public function getGroupClasses()
170
-	{
171
-		return 'control-group';
172
-	}
173
-
174
-	/**
175
-	 * Add label classes
176
-	 *
177
-	 * @return string An array of attributes with the label class
178
-	 */
179
-	public function getLabelClasses()
180
-	{
181
-		return 'control-label';
182
-	}
183
-
184
-	/**
185
-	 * Add uneditable field classes
186
-	 *
187
-	 * @return string An array of attributes with the uneditable class
188
-	 */
189
-	public function getUneditableClasses()
190
-	{
191
-		return 'uneditable-input';
192
-	}
193
-
194
-	public function getPlainTextClasses()
195
-	{
196
-		return null;
197
-	}
198
-
199
-	/**
200
-	 * Add form class
201
-	 *
202
-	 * @param  string $type The type of form to add
203
-	 *
204
-	 * @return string|null
205
-	 */
206
-	public function getFormClasses($type)
207
-	{
208
-		return $type ? 'form-'.$type : null;
209
-	}
210
-
211
-	/**
212
-	 * Add actions block class
213
-	 *
214
-	 * @return string
215
-	 */
216
-	public function getActionClasses()
217
-	{
218
-		return 'form-actions';
219
-	}
220
-
221
-	////////////////////////////////////////////////////////////////////
222
-	//////////////////////////// RENDER BLOCKS /////////////////////////
223
-	////////////////////////////////////////////////////////////////////
224
-
225
-	/**
226
-	 * Render an help text
227
-	 *
228
-	 * @param string $text
229
-	 * @param array  $attributes
230
-	 *
231
-	 * @return Element
232
-	 */
233
-	public function createHelp($text, $attributes = array())
234
-	{
235
-		return Element::create('span', $text, $attributes)->addClass('help-inline');
236
-	}
237
-
238
-	/**
239
-	 * Render a block help text
240
-	 *
241
-	 * @param string $text
242
-	 * @param array  $attributes
243
-	 *
244
-	 * @return Element
245
-	 */
246
-	public function createBlockHelp($text, $attributes = array())
247
-	{
248
-		return Element::create('p', $text, $attributes)->addClass('help-block');
249
-	}
250
-
251
-	/**
252
-	 * Render a disabled field
253
-	 *
254
-	 * @param Field $field
255
-	 *
256
-	 * @return Element
257
-	 */
258
-	public function createDisabledField(Field $field)
259
-	{
260
-		return Element::create('span', $field->getValue(), $field->getAttributes());
261
-	}
262
-
263
-	/**
264
-	 * Render a plain text field
265
-	 * Which fallback to a disabled field
266
-	 *
267
-	 * @param Field $field
268
-	 *
269
-	 * @return Element
270
-	 */
271
-	public function createPlainTextField(Field $field)
272
-	{
273
-		return $this->createDisabledField($field);
274
-	}
275
-
276
-	/**
277
-	 * Render an icon
278
-	 *
279
-	 * @param array $attributes Its general attributes
280
-	 *
281
-	 * @return string
282
-	 */
283
-	public function createIcon($iconType, $attributes = array(), $iconSettings = array())
284
-	{
285
-		// Check for empty icons
286
-		if (!$iconType) {
287
-			return false;
288
-		}
289
-
290
-		// Create tag
291
-		$tag  = Arr::get($iconSettings, 'tag', $this->iconTag);
292
-		$icon = Element::create($tag, null, $attributes);
293
-
294
-		// White icons ignore user overrides to use legacy Bootstrap styling
295
-		if (Str::contains($iconType, 'white')) {
296
-			$iconType = str_replace('white', '', $iconType);
297
-			$iconType = trim($iconType, '-');
298
-			$icon->addClass('icon-white');
299
-			$set    = null;
300
-			$prefix = 'icon';
301
-		} else {
302
-			$set    = Arr::get($iconSettings, 'set', $this->iconSet);
303
-			$prefix = Arr::get($iconSettings, 'prefix', $this->iconPrefix);
304
-		}
305
-		$icon->addClass("$set $prefix-$iconType");
306
-
307
-		return $icon;
308
-	}
309
-
310
-	////////////////////////////////////////////////////////////////////
311
-	//////////////////////////// WRAP BLOCKS ///////////////////////////
312
-	////////////////////////////////////////////////////////////////////
313
-
314
-	/**
315
-	 * Wrap an item to be prepended or appended to the current field
316
-	 *
317
-	 * @param  string $item
318
-	 *
319
-	 * @return string A wrapped item
320
-	 */
321
-	public function placeAround($item)
322
-	{
323
-		// Render object
324
-		if (is_object($item) and method_exists($item, '__toString')) {
325
-			$item = $item->__toString();
326
-		}
327
-
328
-		// Return unwrapped if button
329
-		if (strpos($item, '<button') !== false) {
330
-			return $item;
331
-		}
332
-
333
-		return Element::create('span', $item)->addClass('add-on');
334
-	}
335
-
336
-	/**
337
-	 * Wrap a field with prepended and appended items
338
-	 *
339
-	 * @param  Field $field
340
-	 * @param  array $prepend
341
-	 * @param  array $append
342
-	 *
343
-	 * @return string A field concatented with prepended and/or appended items
344
-	 */
345
-	public function prependAppend($field, $prepend, $append)
346
-	{
347
-		$class = array();
348
-		if ($prepend) {
349
-			$class[] = 'input-prepend';
350
-		}
351
-		if ($append) {
352
-			$class[] = 'input-append';
353
-		}
354
-
355
-		$return = '<div class="'.join(' ', $class).'">';
356
-		$return .= join(null, $prepend);
357
-		$return .= $field->render();
358
-		$return .= join(null, $append);
359
-		$return .= '</div>';
360
-
361
-		return $return;
362
-	}
363
-
364
-	/**
365
-	 * Wrap a field with potential additional tags
366
-	 *
367
-	 * @param  Field $field
368
-	 *
369
-	 * @return Element A wrapped field
370
-	 */
371
-	public function wrapField($field)
372
-	{
373
-		return Element::create('div', $field)->addClass('controls');
374
-	}
375
-
376
-	/**
377
-	 * Wrap actions block with potential additional tags
378
-	 *
379
-	 * @param  Actions $actions
380
-	 *
381
-	 * @return string A wrapped actions block
382
-	 */
383
-	public function wrapActions($actions)
384
-	{
385
-		return $actions;
386
-	}
17
+    /**
18
+     * Form types that trigger special styling for this Framework
19
+     *
20
+     * @var array
21
+     */
22
+    protected $availableTypes = array('horizontal', 'vertical', 'inline', 'search');
23
+
24
+    /**
25
+     * The button types available
26
+     *
27
+     * @var array
28
+     */
29
+    private $buttons = array(
30
+        'large',
31
+        'small',
32
+        'mini',
33
+        'block',
34
+        'danger',
35
+        'info',
36
+        'inverse',
37
+        'link',
38
+        'primary',
39
+        'success',
40
+        'warning',
41
+    );
42
+
43
+    /**
44
+     * The field sizes available
45
+     *
46
+     * @var array
47
+     */
48
+    private $fields = array(
49
+        'mini',
50
+        'small',
51
+        'medium',
52
+        'large',
53
+        'xlarge',
54
+        'xxlarge',
55
+        'span1',
56
+        'span2',
57
+        'span3',
58
+        'span4',
59
+        'span5',
60
+        'span6',
61
+        'span7',
62
+        'span8',
63
+        'span9',
64
+        'span10',
65
+        'span11',
66
+        'span12',
67
+    );
68
+
69
+    /**
70
+     * The field states available
71
+     *
72
+     * @var array
73
+     */
74
+    protected $states = array(
75
+        'success',
76
+        'warning',
77
+        'error',
78
+        'info',
79
+    );
80
+
81
+    /**
82
+     * Create a new TwitterBootstrap instance
83
+     *
84
+     * @param \Illuminate\Container\Container $app
85
+     */
86
+    public function __construct(Container $app)
87
+    {
88
+        $this->app = $app;
89
+        $this->setFrameworkDefaults();
90
+    }
91
+
92
+    ////////////////////////////////////////////////////////////////////
93
+    /////////////////////////// FILTER ARRAYS //////////////////////////
94
+    ////////////////////////////////////////////////////////////////////
95
+
96
+    /**
97
+     * Filter buttons classes
98
+     *
99
+     * @param  array $classes An array of classes
100
+     *
101
+     * @return string[] A filtered array
102
+     */
103
+    public function filterButtonClasses($classes)
104
+    {
105
+        // Filter classes
106
+        // $classes = array_intersect($classes, $this->buttons);
107
+
108
+        // Prepend button type
109
+        $classes   = $this->prependWith($classes, 'btn-');
110
+        $classes[] = 'btn';
111
+
112
+        return $classes;
113
+    }
114
+
115
+    /**
116
+     * Filter field classes
117
+     *
118
+     * @param  array $classes An array of classes
119
+     *
120
+     * @return array A filtered array
121
+     */
122
+    public function filterFieldClasses($classes)
123
+    {
124
+        // Filter classes
125
+        $classes = array_intersect($classes, $this->fields);
126
+
127
+        // Prepend field type
128
+        $classes = array_map(function ($class) {
129
+            return Str::startsWith($class, 'span') ? $class : 'input-'.$class;
130
+        }, $classes);
131
+
132
+        return $classes;
133
+    }
134
+
135
+    ////////////////////////////////////////////////////////////////////
136
+    ///////////////////////////// ADD CLASSES //////////////////////////
137
+    ////////////////////////////////////////////////////////////////////
138
+
139
+    /**
140
+     * Add classes to a field
141
+     *
142
+     * @param Field $field
143
+     * @param array $classes The possible classes to add
144
+     *
145
+     * @return Field
146
+     */
147
+    public function getFieldClasses(Field $field, $classes)
148
+    {
149
+        // Add inline class for checkables
150
+        if ($field->isCheckable() and in_array('inline', $classes)) {
151
+            $field->inline();
152
+        }
153
+
154
+        // Filter classes according to field type
155
+        if ($field->isButton()) {
156
+            $classes = $this->filterButtonClasses($classes);
157
+        } else {
158
+            $classes = $this->filterFieldClasses($classes);
159
+        }
160
+
161
+        return $this->addClassesToField($field, $classes);
162
+    }
163
+
164
+    /**
165
+     * Add group classes
166
+     *
167
+     * @return string A list of group classes
168
+     */
169
+    public function getGroupClasses()
170
+    {
171
+        return 'control-group';
172
+    }
173
+
174
+    /**
175
+     * Add label classes
176
+     *
177
+     * @return string An array of attributes with the label class
178
+     */
179
+    public function getLabelClasses()
180
+    {
181
+        return 'control-label';
182
+    }
183
+
184
+    /**
185
+     * Add uneditable field classes
186
+     *
187
+     * @return string An array of attributes with the uneditable class
188
+     */
189
+    public function getUneditableClasses()
190
+    {
191
+        return 'uneditable-input';
192
+    }
193
+
194
+    public function getPlainTextClasses()
195
+    {
196
+        return null;
197
+    }
198
+
199
+    /**
200
+     * Add form class
201
+     *
202
+     * @param  string $type The type of form to add
203
+     *
204
+     * @return string|null
205
+     */
206
+    public function getFormClasses($type)
207
+    {
208
+        return $type ? 'form-'.$type : null;
209
+    }
210
+
211
+    /**
212
+     * Add actions block class
213
+     *
214
+     * @return string
215
+     */
216
+    public function getActionClasses()
217
+    {
218
+        return 'form-actions';
219
+    }
220
+
221
+    ////////////////////////////////////////////////////////////////////
222
+    //////////////////////////// RENDER BLOCKS /////////////////////////
223
+    ////////////////////////////////////////////////////////////////////
224
+
225
+    /**
226
+     * Render an help text
227
+     *
228
+     * @param string $text
229
+     * @param array  $attributes
230
+     *
231
+     * @return Element
232
+     */
233
+    public function createHelp($text, $attributes = array())
234
+    {
235
+        return Element::create('span', $text, $attributes)->addClass('help-inline');
236
+    }
237
+
238
+    /**
239
+     * Render a block help text
240
+     *
241
+     * @param string $text
242
+     * @param array  $attributes
243
+     *
244
+     * @return Element
245
+     */
246
+    public function createBlockHelp($text, $attributes = array())
247
+    {
248
+        return Element::create('p', $text, $attributes)->addClass('help-block');
249
+    }
250
+
251
+    /**
252
+     * Render a disabled field
253
+     *
254
+     * @param Field $field
255
+     *
256
+     * @return Element
257
+     */
258
+    public function createDisabledField(Field $field)
259
+    {
260
+        return Element::create('span', $field->getValue(), $field->getAttributes());
261
+    }
262
+
263
+    /**
264
+     * Render a plain text field
265
+     * Which fallback to a disabled field
266
+     *
267
+     * @param Field $field
268
+     *
269
+     * @return Element
270
+     */
271
+    public function createPlainTextField(Field $field)
272
+    {
273
+        return $this->createDisabledField($field);
274
+    }
275
+
276
+    /**
277
+     * Render an icon
278
+     *
279
+     * @param array $attributes Its general attributes
280
+     *
281
+     * @return string
282
+     */
283
+    public function createIcon($iconType, $attributes = array(), $iconSettings = array())
284
+    {
285
+        // Check for empty icons
286
+        if (!$iconType) {
287
+            return false;
288
+        }
289
+
290
+        // Create tag
291
+        $tag  = Arr::get($iconSettings, 'tag', $this->iconTag);
292
+        $icon = Element::create($tag, null, $attributes);
293
+
294
+        // White icons ignore user overrides to use legacy Bootstrap styling
295
+        if (Str::contains($iconType, 'white')) {
296
+            $iconType = str_replace('white', '', $iconType);
297
+            $iconType = trim($iconType, '-');
298
+            $icon->addClass('icon-white');
299
+            $set    = null;
300
+            $prefix = 'icon';
301
+        } else {
302
+            $set    = Arr::get($iconSettings, 'set', $this->iconSet);
303
+            $prefix = Arr::get($iconSettings, 'prefix', $this->iconPrefix);
304
+        }
305
+        $icon->addClass("$set $prefix-$iconType");
306
+
307
+        return $icon;
308
+    }
309
+
310
+    ////////////////////////////////////////////////////////////////////
311
+    //////////////////////////// WRAP BLOCKS ///////////////////////////
312
+    ////////////////////////////////////////////////////////////////////
313
+
314
+    /**
315
+     * Wrap an item to be prepended or appended to the current field
316
+     *
317
+     * @param  string $item
318
+     *
319
+     * @return string A wrapped item
320
+     */
321
+    public function placeAround($item)
322
+    {
323
+        // Render object
324
+        if (is_object($item) and method_exists($item, '__toString')) {
325
+            $item = $item->__toString();
326
+        }
327
+
328
+        // Return unwrapped if button
329
+        if (strpos($item, '<button') !== false) {
330
+            return $item;
331
+        }
332
+
333
+        return Element::create('span', $item)->addClass('add-on');
334
+    }
335
+
336
+    /**
337
+     * Wrap a field with prepended and appended items
338
+     *
339
+     * @param  Field $field
340
+     * @param  array $prepend
341
+     * @param  array $append
342
+     *
343
+     * @return string A field concatented with prepended and/or appended items
344
+     */
345
+    public function prependAppend($field, $prepend, $append)
346
+    {
347
+        $class = array();
348
+        if ($prepend) {
349
+            $class[] = 'input-prepend';
350
+        }
351
+        if ($append) {
352
+            $class[] = 'input-append';
353
+        }
354
+
355
+        $return = '<div class="'.join(' ', $class).'">';
356
+        $return .= join(null, $prepend);
357
+        $return .= $field->render();
358
+        $return .= join(null, $append);
359
+        $return .= '</div>';
360
+
361
+        return $return;
362
+    }
363
+
364
+    /**
365
+     * Wrap a field with potential additional tags
366
+     *
367
+     * @param  Field $field
368
+     *
369
+     * @return Element A wrapped field
370
+     */
371
+    public function wrapField($field)
372
+    {
373
+        return Element::create('div', $field)->addClass('controls');
374
+    }
375
+
376
+    /**
377
+     * Wrap actions block with potential additional tags
378
+     *
379
+     * @param  Actions $actions
380
+     *
381
+     * @return string A wrapped actions block
382
+     */
383
+    public function wrapActions($actions)
384
+    {
385
+        return $actions;
386
+    }
387 387
 }
Please login to merge, or discard this patch.
src/Former/Framework/ZurbFoundation.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
 	 *
127 127
 	 * @param Field $field
128 128
 	 *
129
-	 * @return Element
129
+	 * @return Input
130 130
 	 */
131 131
 	public function createPlainTextField(Field $field)
132 132
 	{
Please login to merge, or discard this patch.
Indentation   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -13,274 +13,274 @@
 block discarded – undo
13 13
  */
14 14
 class ZurbFoundation extends Framework implements FrameworkInterface
15 15
 {
16
-	/**
17
-	 * Form types that trigger special styling for this Framework
18
-	 *
19
-	 * @var array
20
-	 */
21
-	protected $availableTypes = array('horizontal', 'vertical');
22
-
23
-	/**
24
-	 * The field sizes available
25
-	 *
26
-	 * @var array
27
-	 */
28
-	private $fields = array(
29
-		1  => 'one',
30
-		2  => 'two',
31
-		3  => 'three',
32
-		4  => 'four',
33
-		5  => 'five',
34
-		6  => 'six',
35
-		7  => 'seven',
36
-		8  => 'eight',
37
-		9  => 'nine',
38
-		10 => 'ten',
39
-		11 => 'eleven',
40
-		12 => 'twelve',
41
-	);
42
-
43
-	/**
44
-	 * The field states available
45
-	 *
46
-	 * @var array
47
-	 */
48
-	protected $states = array(
49
-		'error',
50
-	);
51
-
52
-	/**
53
-	 * Create a new ZurbFoundation instance
54
-	 *
55
-	 * @param Container $app
56
-	 */
57
-	public function __construct(Container $app)
58
-	{
59
-		$this->app = $app;
60
-		$this->setFrameworkDefaults();
61
-	}
62
-
63
-	////////////////////////////////////////////////////////////////////
64
-	/////////////////////////// FILTER ARRAYS //////////////////////////
65
-	////////////////////////////////////////////////////////////////////
66
-
67
-	public function filterButtonClasses($classes)
68
-	{
69
-		return $classes;
70
-	}
71
-
72
-	public function filterFieldClasses($classes)
73
-	{
74
-		// Filter classes
75
-		$classes = array_intersect($classes, $this->fields);
76
-
77
-		return $classes;
78
-	}
79
-
80
-	////////////////////////////////////////////////////////////////////
81
-	///////////////////// EXPOSE FRAMEWORK SPECIFICS ///////////////////
82
-	////////////////////////////////////////////////////////////////////
83
-
84
-	protected function setFieldWidths($labelWidths)
85
-	{
86
-		$labelWidthClass = $fieldWidthClass = $fieldOffsetClass = '';
87
-
88
-		$viewports = $this->getFrameworkOption('viewports');
89
-
90
-		foreach ($labelWidths as $viewport => $columns) {
91
-			if ($viewport) {
92
-				$labelWidthClass .= $viewports[$viewport].$this->fields[$columns].' ';
93
-				$fieldWidthClass .= $viewports[$viewport].$this->fields[12 - $columns].' ';
94
-				$fieldOffsetClass .= $viewports[$viewport].'offset-by-'.$this->fields[$columns].' ';
95
-			}
96
-		}
97
-
98
-		$this->labelWidth  = $labelWidthClass.'columns';
99
-		$this->fieldWidth  = $fieldWidthClass.'columns';
100
-		$this->fieldOffset = $fieldOffsetClass.'columns';
101
-	}
102
-
103
-	////////////////////////////////////////////////////////////////////
104
-	///////////////////////////// ADD CLASSES //////////////////////////
105
-	////////////////////////////////////////////////////////////////////
106
-
107
-	public function getFieldClasses(Field $field, $classes = array())
108
-	{
109
-		$classes = $this->filterFieldClasses($classes);
110
-
111
-		return $this->addClassesToField($field, $classes);
112
-	}
113
-
114
-	public function getGroupClasses()
115
-	{
116
-		if ($this->app['former.form']->isOfType('horizontal')) {
117
-			return 'row';
118
-		} else {
119
-			return null;
120
-		}
121
-	}
122
-
123
-	/**
124
-	 * Add label classes
125
-	 *
126
-	 * @return string|null An array of attributes with the label class
127
-	 */
128
-	public function getLabelClasses()
129
-	{
130
-		if ($this->app['former.form']->isOfType('horizontal')) {
131
-			return $this->getFrameworkOption('wrappedLabelClasses');
132
-		} else {
133
-			return null;
134
-		}
135
-	}
136
-
137
-	public function getUneditableClasses()
138
-	{
139
-		return null;
140
-	}
141
-
142
-	public function getPlainTextClasses()
143
-	{
144
-		return null;
145
-	}
146
-
147
-	public function getFormClasses($type)
148
-	{
149
-		return null;
150
-	}
151
-
152
-	public function getActionClasses()
153
-	{
154
-		return null;
155
-	}
156
-
157
-	////////////////////////////////////////////////////////////////////
158
-	//////////////////////////// RENDER BLOCKS /////////////////////////
159
-	////////////////////////////////////////////////////////////////////
160
-
161
-	public function createHelp($text, $attributes = null)
162
-	{
163
-		if (is_null($attributes) or empty($attributes)) {
164
-			$attributes = $this->getFrameworkOption('error_classes');
165
-		}
166
-
167
-		return Element::create('span', $text, $attributes);
168
-	}
169
-
170
-	/**
171
-	 * Render a disabled field
172
-	 *
173
-	 * @param Field $field
174
-	 *
175
-	 * @return Input
176
-	 */
177
-	public function createDisabledField(Field $field)
178
-	{
179
-		$field->disabled();
180
-
181
-		return Input::create('text', $field->getName(), $field->getValue(), $field->getAttributes());
182
-	}
183
-
184
-	/**
185
-	 * Render a plain text field
186
-	 * Which fallback to a disabled field
187
-	 *
188
-	 * @param Field $field
189
-	 *
190
-	 * @return Element
191
-	 */
192
-	public function createPlainTextField(Field $field)
193
-	{
194
-		return $this->createDisabledField($field);
195
-	}
196
-
197
-	////////////////////////////////////////////////////////////////////
198
-	//////////////////////////// WRAP BLOCKS ///////////////////////////
199
-	////////////////////////////////////////////////////////////////////
200
-
201
-	/**
202
-	 * Wrap an item to be prepended or appended to the current field.
203
-	 * For Zurb we return the item and handle the wrapping in prependAppend
204
-	 * as wrapping is dependent on whether we're prepending or appending.
205
-	 *
206
-	 * @return string A wrapped item
207
-	 */
208
-	public function placeAround($item)
209
-	{
210
-		return $item;
211
-	}
212
-
213
-	/**
214
-	 * Wrap a field with prepended and appended items
215
-	 *
216
-	 * @param  Field $field
217
-	 * @param  array $prepend
218
-	 * @param  array $append
219
-	 *
220
-	 * @return string A field concatented with prepended and/or appended items
221
-	 */
222
-	public function prependAppend($field, $prepend, $append)
223
-	{
224
-		$return = '';
225
-
226
-		foreach ($prepend as $item) {
227
-			$return .= '<div class="two mobile-one columns"><span class="prefix">'.$item.'</span></div>';
228
-		}
229
-
230
-		$return .= '<div class="ten mobile-three columns">'.$field->render().'</div>';
231
-
232
-		foreach ($append as $item) {
233
-			$return .= '<div class="two mobile-one columns"><span class="postfix">'.$item.'</span></div>';
234
-		}
235
-
236
-		return $return;
237
-	}
238
-
239
-	/**
240
-	 * Wraps all label contents with potential additional tags.
241
-	 *
242
-	 * @param  string $label
243
-	 *
244
-	 * @return string A wrapped label
245
-	 */
246
-	public function wrapLabel($label)
247
-	{
248
-		if ($this->app['former.form']->isOfType('horizontal')) {
249
-			return Element::create('div', $label)->addClass($this->labelWidth);
250
-		} else {
251
-			return $label;
252
-		}
253
-	}
254
-
255
-	/**
256
-	 * Wraps all field contents with potential additional tags.
257
-	 *
258
-	 * @param  Field $field
259
-	 *
260
-	 * @return Element A wrapped field
261
-	 */
262
-	public function wrapField($field)
263
-	{
264
-		if ($this->app['former.form']->isOfType('horizontal')) {
265
-			return Element::create('div', $field)->addClass($this->fieldWidth);
266
-		} else {
267
-			return $field;
268
-		}
269
-	}
270
-
271
-	/**
272
-	 * Wrap actions block with potential additional tags
273
-	 *
274
-	 * @param  Actions $actions
275
-	 *
276
-	 * @return string A wrapped actions block
277
-	 */
278
-	public function wrapActions($actions)
279
-	{
280
-		if ($this->app['former.form']->isOfType('horizontal')) {
281
-			return Element::create('div', $actions)->addClass(array($this->fieldOffset, $this->fieldWidth));
282
-		} else {
283
-			return $actions;
284
-		}
285
-	}
16
+    /**
17
+     * Form types that trigger special styling for this Framework
18
+     *
19
+     * @var array
20
+     */
21
+    protected $availableTypes = array('horizontal', 'vertical');
22
+
23
+    /**
24
+     * The field sizes available
25
+     *
26
+     * @var array
27
+     */
28
+    private $fields = array(
29
+        1  => 'one',
30
+        2  => 'two',
31
+        3  => 'three',
32
+        4  => 'four',
33
+        5  => 'five',
34
+        6  => 'six',
35
+        7  => 'seven',
36
+        8  => 'eight',
37
+        9  => 'nine',
38
+        10 => 'ten',
39
+        11 => 'eleven',
40
+        12 => 'twelve',
41
+    );
42
+
43
+    /**
44
+     * The field states available
45
+     *
46
+     * @var array
47
+     */
48
+    protected $states = array(
49
+        'error',
50
+    );
51
+
52
+    /**
53
+     * Create a new ZurbFoundation instance
54
+     *
55
+     * @param Container $app
56
+     */
57
+    public function __construct(Container $app)
58
+    {
59
+        $this->app = $app;
60
+        $this->setFrameworkDefaults();
61
+    }
62
+
63
+    ////////////////////////////////////////////////////////////////////
64
+    /////////////////////////// FILTER ARRAYS //////////////////////////
65
+    ////////////////////////////////////////////////////////////////////
66
+
67
+    public function filterButtonClasses($classes)
68
+    {
69
+        return $classes;
70
+    }
71
+
72
+    public function filterFieldClasses($classes)
73
+    {
74
+        // Filter classes
75
+        $classes = array_intersect($classes, $this->fields);
76
+
77
+        return $classes;
78
+    }
79
+
80
+    ////////////////////////////////////////////////////////////////////
81
+    ///////////////////// EXPOSE FRAMEWORK SPECIFICS ///////////////////
82
+    ////////////////////////////////////////////////////////////////////
83
+
84
+    protected function setFieldWidths($labelWidths)
85
+    {
86
+        $labelWidthClass = $fieldWidthClass = $fieldOffsetClass = '';
87
+
88
+        $viewports = $this->getFrameworkOption('viewports');
89
+
90
+        foreach ($labelWidths as $viewport => $columns) {
91
+            if ($viewport) {
92
+                $labelWidthClass .= $viewports[$viewport].$this->fields[$columns].' ';
93
+                $fieldWidthClass .= $viewports[$viewport].$this->fields[12 - $columns].' ';
94
+                $fieldOffsetClass .= $viewports[$viewport].'offset-by-'.$this->fields[$columns].' ';
95
+            }
96
+        }
97
+
98
+        $this->labelWidth  = $labelWidthClass.'columns';
99
+        $this->fieldWidth  = $fieldWidthClass.'columns';
100
+        $this->fieldOffset = $fieldOffsetClass.'columns';
101
+    }
102
+
103
+    ////////////////////////////////////////////////////////////////////
104
+    ///////////////////////////// ADD CLASSES //////////////////////////
105
+    ////////////////////////////////////////////////////////////////////
106
+
107
+    public function getFieldClasses(Field $field, $classes = array())
108
+    {
109
+        $classes = $this->filterFieldClasses($classes);
110
+
111
+        return $this->addClassesToField($field, $classes);
112
+    }
113
+
114
+    public function getGroupClasses()
115
+    {
116
+        if ($this->app['former.form']->isOfType('horizontal')) {
117
+            return 'row';
118
+        } else {
119
+            return null;
120
+        }
121
+    }
122
+
123
+    /**
124
+     * Add label classes
125
+     *
126
+     * @return string|null An array of attributes with the label class
127
+     */
128
+    public function getLabelClasses()
129
+    {
130
+        if ($this->app['former.form']->isOfType('horizontal')) {
131
+            return $this->getFrameworkOption('wrappedLabelClasses');
132
+        } else {
133
+            return null;
134
+        }
135
+    }
136
+
137
+    public function getUneditableClasses()
138
+    {
139
+        return null;
140
+    }
141
+
142
+    public function getPlainTextClasses()
143
+    {
144
+        return null;
145
+    }
146
+
147
+    public function getFormClasses($type)
148
+    {
149
+        return null;
150
+    }
151
+
152
+    public function getActionClasses()
153
+    {
154
+        return null;
155
+    }
156
+
157
+    ////////////////////////////////////////////////////////////////////
158
+    //////////////////////////// RENDER BLOCKS /////////////////////////
159
+    ////////////////////////////////////////////////////////////////////
160
+
161
+    public function createHelp($text, $attributes = null)
162
+    {
163
+        if (is_null($attributes) or empty($attributes)) {
164
+            $attributes = $this->getFrameworkOption('error_classes');
165
+        }
166
+
167
+        return Element::create('span', $text, $attributes);
168
+    }
169
+
170
+    /**
171
+     * Render a disabled field
172
+     *
173
+     * @param Field $field
174
+     *
175
+     * @return Input
176
+     */
177
+    public function createDisabledField(Field $field)
178
+    {
179
+        $field->disabled();
180
+
181
+        return Input::create('text', $field->getName(), $field->getValue(), $field->getAttributes());
182
+    }
183
+
184
+    /**
185
+     * Render a plain text field
186
+     * Which fallback to a disabled field
187
+     *
188
+     * @param Field $field
189
+     *
190
+     * @return Element
191
+     */
192
+    public function createPlainTextField(Field $field)
193
+    {
194
+        return $this->createDisabledField($field);
195
+    }
196
+
197
+    ////////////////////////////////////////////////////////////////////
198
+    //////////////////////////// WRAP BLOCKS ///////////////////////////
199
+    ////////////////////////////////////////////////////////////////////
200
+
201
+    /**
202
+     * Wrap an item to be prepended or appended to the current field.
203
+     * For Zurb we return the item and handle the wrapping in prependAppend
204
+     * as wrapping is dependent on whether we're prepending or appending.
205
+     *
206
+     * @return string A wrapped item
207
+     */
208
+    public function placeAround($item)
209
+    {
210
+        return $item;
211
+    }
212
+
213
+    /**
214
+     * Wrap a field with prepended and appended items
215
+     *
216
+     * @param  Field $field
217
+     * @param  array $prepend
218
+     * @param  array $append
219
+     *
220
+     * @return string A field concatented with prepended and/or appended items
221
+     */
222
+    public function prependAppend($field, $prepend, $append)
223
+    {
224
+        $return = '';
225
+
226
+        foreach ($prepend as $item) {
227
+            $return .= '<div class="two mobile-one columns"><span class="prefix">'.$item.'</span></div>';
228
+        }
229
+
230
+        $return .= '<div class="ten mobile-three columns">'.$field->render().'</div>';
231
+
232
+        foreach ($append as $item) {
233
+            $return .= '<div class="two mobile-one columns"><span class="postfix">'.$item.'</span></div>';
234
+        }
235
+
236
+        return $return;
237
+    }
238
+
239
+    /**
240
+     * Wraps all label contents with potential additional tags.
241
+     *
242
+     * @param  string $label
243
+     *
244
+     * @return string A wrapped label
245
+     */
246
+    public function wrapLabel($label)
247
+    {
248
+        if ($this->app['former.form']->isOfType('horizontal')) {
249
+            return Element::create('div', $label)->addClass($this->labelWidth);
250
+        } else {
251
+            return $label;
252
+        }
253
+    }
254
+
255
+    /**
256
+     * Wraps all field contents with potential additional tags.
257
+     *
258
+     * @param  Field $field
259
+     *
260
+     * @return Element A wrapped field
261
+     */
262
+    public function wrapField($field)
263
+    {
264
+        if ($this->app['former.form']->isOfType('horizontal')) {
265
+            return Element::create('div', $field)->addClass($this->fieldWidth);
266
+        } else {
267
+            return $field;
268
+        }
269
+    }
270
+
271
+    /**
272
+     * Wrap actions block with potential additional tags
273
+     *
274
+     * @param  Actions $actions
275
+     *
276
+     * @return string A wrapped actions block
277
+     */
278
+    public function wrapActions($actions)
279
+    {
280
+        if ($this->app['former.form']->isOfType('horizontal')) {
281
+            return Element::create('div', $actions)->addClass(array($this->fieldOffset, $this->fieldWidth));
282
+        } else {
283
+            return $actions;
284
+        }
285
+    }
286 286
 }
Please login to merge, or discard this patch.
src/Former/Framework/ZurbFoundation4.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
 	 *
127 127
 	 * @param Field $field
128 128
 	 *
129
-	 * @return Element
129
+	 * @return Input
130 130
 	 */
131 131
 	public function createPlainTextField(Field $field)
132 132
 	{
Please login to merge, or discard this patch.
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -13,281 +13,281 @@
 block discarded – undo
13 13
  */
14 14
 class ZurbFoundation4 extends Framework implements FrameworkInterface
15 15
 {
16
-	/**
17
-	 * Form types that trigger special styling for this Framework
18
-	 *
19
-	 * @var array
20
-	 */
21
-	protected $availableTypes = array('horizontal', 'vertical');
22
-
23
-	/**
24
-	 * The button types available
25
-	 *
26
-	 * @var array
27
-	 */
28
-	private $buttons = array(
29
-		'tiny',
30
-		'small',
31
-		'medium',
32
-		'large',
33
-		'success',
34
-		'radius',
35
-		'round',
36
-		'disabled',
37
-		'prefix',
38
-		'postfix',
39
-	);
40
-
41
-	/**
42
-	 * The field sizes available
43
-	 * Zurb Foundation 4 does not apply sizes to the form element, but to the wrapper div
44
-	 *
45
-	 * @var array
46
-	 */
47
-	private $fields = array();
48
-
49
-	/**
50
-	 * The field states available
51
-	 *
52
-	 * @var array
53
-	 */
54
-	protected $states = array(
55
-		'error',
56
-	);
57
-
58
-	/**
59
-	 * Create a new ZurbFoundation instance
60
-	 *
61
-	 * @param \Illuminate\Container\Container $app
62
-	 */
63
-	public function __construct(Container $app)
64
-	{
65
-		$this->app = $app;
66
-		$this->setFrameworkDefaults();
67
-	}
68
-
69
-	////////////////////////////////////////////////////////////////////
70
-	/////////////////////////// FILTER ARRAYS //////////////////////////
71
-	////////////////////////////////////////////////////////////////////
72
-
73
-	public function filterButtonClasses($classes)
74
-	{
75
-		// Filter classes
76
-		$classes   = array_intersect($classes, $this->buttons);
77
-		$classes[] = 'button';
78
-
79
-		return $classes;
80
-	}
81
-
82
-	public function filterFieldClasses($classes)
83
-	{
84
-		return null;
85
-	}
86
-
87
-	////////////////////////////////////////////////////////////////////
88
-	///////////////////// EXPOSE FRAMEWORK SPECIFICS ///////////////////
89
-	////////////////////////////////////////////////////////////////////
90
-
91
-	protected function setFieldWidths($labelWidths)
92
-	{
93
-		$labelWidthClass = $fieldWidthClass = $fieldOffsetClass = '';
94
-
95
-		$viewports = $this->getFrameworkOption('viewports');
96
-
97
-		foreach ($labelWidths as $viewport => $columns) {
98
-			if ($viewport) {
99
-				$labelWidthClass .= $viewports[$viewport].'-'.$columns.' ';
100
-				$fieldWidthClass .= $viewports[$viewport].'-'.(12 - $columns).' ';
101
-				$fieldOffsetClass .= $viewports[$viewport].'-offset-'.$columns.' ';
102
-			}
103
-		}
104
-
105
-		$this->labelWidth  = $labelWidthClass.'columns';
106
-		$this->fieldWidth  = $fieldWidthClass.'columns';
107
-		$this->fieldOffset = $fieldOffsetClass.'columns';
108
-	}
109
-
110
-	////////////////////////////////////////////////////////////////////
111
-	///////////////////////////// ADD CLASSES //////////////////////////
112
-	////////////////////////////////////////////////////////////////////
113
-
114
-	public function getFieldClasses(Field $field, $classes = array())
115
-	{
116
-		if ($field->isButton()) {
117
-			$classes = $this->filterButtonClasses($classes);
118
-		} else {
119
-			$classes = $this->filterFieldClasses($classes);
120
-		}
121
-
122
-		return $this->addClassesToField($field, $classes);
123
-	}
124
-
125
-	public function getGroupClasses()
126
-	{
127
-		if ($this->app['former.form']->isOfType('horizontal')) {
128
-			return 'row';
129
-		} else {
130
-			return null;
131
-		}
132
-	}
133
-
134
-	/**
135
-	 * Add label classes
136
-	 *
137
-	 * @return string|null An array of attributes with the label class
138
-	 */
139
-	public function getLabelClasses()
140
-	{
141
-		if ($this->app['former.form']->isOfType('horizontal')) {
142
-			return $this->getFrameworkOption('wrappedLabelClasses');
143
-		} else {
144
-			return null;
145
-		}
146
-	}
147
-
148
-	public function getUneditableClasses()
149
-	{
150
-		return null;
151
-	}
152
-
153
-	public function getPlainTextClasses()
154
-	{
155
-		return null;
156
-	}
157
-
158
-	public function getFormClasses($type)
159
-	{
160
-		return null;
161
-	}
162
-
163
-	public function getActionClasses()
164
-	{
165
-		return null;
166
-	}
167
-
168
-	////////////////////////////////////////////////////////////////////
169
-	//////////////////////////// RENDER BLOCKS /////////////////////////
170
-	////////////////////////////////////////////////////////////////////
171
-
172
-	public function createHelp($text, $attributes = null)
173
-	{
174
-		if (is_null($attributes) or empty($attributes)) {
175
-			$attributes = $this->getFrameworkOption('error_classes');
176
-		}
177
-
178
-		return Element::create('span', $text, $attributes);
179
-	}
180
-
181
-	/**
182
-	 * Render a disabled field
183
-	 *
184
-	 * @param Field $field
185
-	 *
186
-	 * @return Input
187
-	 */
188
-	public function createDisabledField(Field $field)
189
-	{
190
-		$field->disabled();
191
-
192
-		return Input::create('text', $field->getName(), $field->getValue(), $field->getAttributes());
193
-	}
194
-
195
-	/**
196
-	 * Render a plain text field
197
-	 * Which fallback to a disabled field
198
-	 *
199
-	 * @param Field $field
200
-	 *
201
-	 * @return Element
202
-	 */
203
-	public function createPlainTextField(Field $field)
204
-	{
205
-		return $this->createDisabledField($field);
206
-	}
207
-
208
-	////////////////////////////////////////////////////////////////////
209
-	//////////////////////////// WRAP BLOCKS ///////////////////////////
210
-	////////////////////////////////////////////////////////////////////
211
-
212
-	/**
213
-	 * Wrap an item to be prepended or appended to the current field.
214
-	 * For Zurb we return the item and handle the wrapping in prependAppend
215
-	 * as wrapping is dependent on whether we're prepending or appending.
216
-	 *
217
-	 * @return string A wrapped item
218
-	 */
219
-	public function placeAround($item)
220
-	{
221
-		return $item;
222
-	}
223
-
224
-	/**
225
-	 * Wrap a field with prepended and appended items
226
-	 *
227
-	 * @param  Field $field
228
-	 * @param  array $prepend
229
-	 * @param  array $append
230
-	 *
231
-	 * @return string A field concatented with prepended and/or appended items
232
-	 */
233
-	public function prependAppend($field, $prepend, $append)
234
-	{
235
-		$return = '';
236
-
237
-		foreach ($prepend as $item) {
238
-			$return .= '<div class="large-2 small-3 columns"><span class="prefix">'.$item.'</span></div>';
239
-		}
240
-
241
-		$return .= '<div class="large-10 small-9 columns">'.$field->render().'</div>';
242
-
243
-		foreach ($append as $item) {
244
-			$return .= '<div class="large-2 small-3 columns"><span class="postfix">'.$item.'</span></div>';
245
-		}
246
-
247
-		return $return;
248
-	}
249
-
250
-	/**
251
-	 * Wraps all label contents with potential additional tags.
252
-	 *
253
-	 * @param  string $label
254
-	 *
255
-	 * @return string A wrapped label
256
-	 */
257
-	public function wrapLabel($label)
258
-	{
259
-		if ($this->app['former.form']->isOfType('horizontal')) {
260
-			return Element::create('div', $label)->addClass($this->labelWidth);
261
-		} else {
262
-			return $label;
263
-		}
264
-	}
265
-
266
-	/**
267
-	 * Wraps all field contents with potential additional tags.
268
-	 *
269
-	 * @param  Field $field
270
-	 *
271
-	 * @return Element A wrapped field
272
-	 */
273
-	public function wrapField($field)
274
-	{
275
-		if ($this->app['former.form']->isOfType('horizontal')) {
276
-			return Element::create('div', $field)->addClass($this->fieldWidth);
277
-		} else {
278
-			return $field;
279
-		}
280
-	}
281
-
282
-	/**
283
-	 * Wrap actions block with potential additional tags
284
-	 *
285
-	 * @param  Actions $actions
286
-	 *
287
-	 * @return string A wrapped actions block
288
-	 */
289
-	public function wrapActions($actions)
290
-	{
291
-		return $actions;
292
-	}
16
+    /**
17
+     * Form types that trigger special styling for this Framework
18
+     *
19
+     * @var array
20
+     */
21
+    protected $availableTypes = array('horizontal', 'vertical');
22
+
23
+    /**
24
+     * The button types available
25
+     *
26
+     * @var array
27
+     */
28
+    private $buttons = array(
29
+        'tiny',
30
+        'small',
31
+        'medium',
32
+        'large',
33
+        'success',
34
+        'radius',
35
+        'round',
36
+        'disabled',
37
+        'prefix',
38
+        'postfix',
39
+    );
40
+
41
+    /**
42
+     * The field sizes available
43
+     * Zurb Foundation 4 does not apply sizes to the form element, but to the wrapper div
44
+     *
45
+     * @var array
46
+     */
47
+    private $fields = array();
48
+
49
+    /**
50
+     * The field states available
51
+     *
52
+     * @var array
53
+     */
54
+    protected $states = array(
55
+        'error',
56
+    );
57
+
58
+    /**
59
+     * Create a new ZurbFoundation instance
60
+     *
61
+     * @param \Illuminate\Container\Container $app
62
+     */
63
+    public function __construct(Container $app)
64
+    {
65
+        $this->app = $app;
66
+        $this->setFrameworkDefaults();
67
+    }
68
+
69
+    ////////////////////////////////////////////////////////////////////
70
+    /////////////////////////// FILTER ARRAYS //////////////////////////
71
+    ////////////////////////////////////////////////////////////////////
72
+
73
+    public function filterButtonClasses($classes)
74
+    {
75
+        // Filter classes
76
+        $classes   = array_intersect($classes, $this->buttons);
77
+        $classes[] = 'button';
78
+
79
+        return $classes;
80
+    }
81
+
82
+    public function filterFieldClasses($classes)
83
+    {
84
+        return null;
85
+    }
86
+
87
+    ////////////////////////////////////////////////////////////////////
88
+    ///////////////////// EXPOSE FRAMEWORK SPECIFICS ///////////////////
89
+    ////////////////////////////////////////////////////////////////////
90
+
91
+    protected function setFieldWidths($labelWidths)
92
+    {
93
+        $labelWidthClass = $fieldWidthClass = $fieldOffsetClass = '';
94
+
95
+        $viewports = $this->getFrameworkOption('viewports');
96
+
97
+        foreach ($labelWidths as $viewport => $columns) {
98
+            if ($viewport) {
99
+                $labelWidthClass .= $viewports[$viewport].'-'.$columns.' ';
100
+                $fieldWidthClass .= $viewports[$viewport].'-'.(12 - $columns).' ';
101
+                $fieldOffsetClass .= $viewports[$viewport].'-offset-'.$columns.' ';
102
+            }
103
+        }
104
+
105
+        $this->labelWidth  = $labelWidthClass.'columns';
106
+        $this->fieldWidth  = $fieldWidthClass.'columns';
107
+        $this->fieldOffset = $fieldOffsetClass.'columns';
108
+    }
109
+
110
+    ////////////////////////////////////////////////////////////////////
111
+    ///////////////////////////// ADD CLASSES //////////////////////////
112
+    ////////////////////////////////////////////////////////////////////
113
+
114
+    public function getFieldClasses(Field $field, $classes = array())
115
+    {
116
+        if ($field->isButton()) {
117
+            $classes = $this->filterButtonClasses($classes);
118
+        } else {
119
+            $classes = $this->filterFieldClasses($classes);
120
+        }
121
+
122
+        return $this->addClassesToField($field, $classes);
123
+    }
124
+
125
+    public function getGroupClasses()
126
+    {
127
+        if ($this->app['former.form']->isOfType('horizontal')) {
128
+            return 'row';
129
+        } else {
130
+            return null;
131
+        }
132
+    }
133
+
134
+    /**
135
+     * Add label classes
136
+     *
137
+     * @return string|null An array of attributes with the label class
138
+     */
139
+    public function getLabelClasses()
140
+    {
141
+        if ($this->app['former.form']->isOfType('horizontal')) {
142
+            return $this->getFrameworkOption('wrappedLabelClasses');
143
+        } else {
144
+            return null;
145
+        }
146
+    }
147
+
148
+    public function getUneditableClasses()
149
+    {
150
+        return null;
151
+    }
152
+
153
+    public function getPlainTextClasses()
154
+    {
155
+        return null;
156
+    }
157
+
158
+    public function getFormClasses($type)
159
+    {
160
+        return null;
161
+    }
162
+
163
+    public function getActionClasses()
164
+    {
165
+        return null;
166
+    }
167
+
168
+    ////////////////////////////////////////////////////////////////////
169
+    //////////////////////////// RENDER BLOCKS /////////////////////////
170
+    ////////////////////////////////////////////////////////////////////
171
+
172
+    public function createHelp($text, $attributes = null)
173
+    {
174
+        if (is_null($attributes) or empty($attributes)) {
175
+            $attributes = $this->getFrameworkOption('error_classes');
176
+        }
177
+
178
+        return Element::create('span', $text, $attributes);
179
+    }
180
+
181
+    /**
182
+     * Render a disabled field
183
+     *
184
+     * @param Field $field
185
+     *
186
+     * @return Input
187
+     */
188
+    public function createDisabledField(Field $field)
189
+    {
190
+        $field->disabled();
191
+
192
+        return Input::create('text', $field->getName(), $field->getValue(), $field->getAttributes());
193
+    }
194
+
195
+    /**
196
+     * Render a plain text field
197
+     * Which fallback to a disabled field
198
+     *
199
+     * @param Field $field
200
+     *
201
+     * @return Element
202
+     */
203
+    public function createPlainTextField(Field $field)
204
+    {
205
+        return $this->createDisabledField($field);
206
+    }
207
+
208
+    ////////////////////////////////////////////////////////////////////
209
+    //////////////////////////// WRAP BLOCKS ///////////////////////////
210
+    ////////////////////////////////////////////////////////////////////
211
+
212
+    /**
213
+     * Wrap an item to be prepended or appended to the current field.
214
+     * For Zurb we return the item and handle the wrapping in prependAppend
215
+     * as wrapping is dependent on whether we're prepending or appending.
216
+     *
217
+     * @return string A wrapped item
218
+     */
219
+    public function placeAround($item)
220
+    {
221
+        return $item;
222
+    }
223
+
224
+    /**
225
+     * Wrap a field with prepended and appended items
226
+     *
227
+     * @param  Field $field
228
+     * @param  array $prepend
229
+     * @param  array $append
230
+     *
231
+     * @return string A field concatented with prepended and/or appended items
232
+     */
233
+    public function prependAppend($field, $prepend, $append)
234
+    {
235
+        $return = '';
236
+
237
+        foreach ($prepend as $item) {
238
+            $return .= '<div class="large-2 small-3 columns"><span class="prefix">'.$item.'</span></div>';
239
+        }
240
+
241
+        $return .= '<div class="large-10 small-9 columns">'.$field->render().'</div>';
242
+
243
+        foreach ($append as $item) {
244
+            $return .= '<div class="large-2 small-3 columns"><span class="postfix">'.$item.'</span></div>';
245
+        }
246
+
247
+        return $return;
248
+    }
249
+
250
+    /**
251
+     * Wraps all label contents with potential additional tags.
252
+     *
253
+     * @param  string $label
254
+     *
255
+     * @return string A wrapped label
256
+     */
257
+    public function wrapLabel($label)
258
+    {
259
+        if ($this->app['former.form']->isOfType('horizontal')) {
260
+            return Element::create('div', $label)->addClass($this->labelWidth);
261
+        } else {
262
+            return $label;
263
+        }
264
+    }
265
+
266
+    /**
267
+     * Wraps all field contents with potential additional tags.
268
+     *
269
+     * @param  Field $field
270
+     *
271
+     * @return Element A wrapped field
272
+     */
273
+    public function wrapField($field)
274
+    {
275
+        if ($this->app['former.form']->isOfType('horizontal')) {
276
+            return Element::create('div', $field)->addClass($this->fieldWidth);
277
+        } else {
278
+            return $field;
279
+        }
280
+    }
281
+
282
+    /**
283
+     * Wrap actions block with potential additional tags
284
+     *
285
+     * @param  Actions $actions
286
+     *
287
+     * @return string A wrapped actions block
288
+     */
289
+    public function wrapActions($actions)
290
+    {
291
+        return $actions;
292
+    }
293 293
 }
Please login to merge, or discard this patch.
src/Former/Framework/ZurbFoundation5.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
 	 *
127 127
 	 * @param Field $field
128 128
 	 *
129
-	 * @return Element
129
+	 * @return Input
130 130
 	 */
131 131
 	public function createPlainTextField(Field $field)
132 132
 	{
Please login to merge, or discard this patch.
Indentation   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -13,283 +13,283 @@
 block discarded – undo
13 13
  */
14 14
 class ZurbFoundation5 extends Framework implements FrameworkInterface
15 15
 {
16
-	/**
17
-	 * Form types that trigger special styling for this Framework
18
-	 *
19
-	 * @var array
20
-	 */
21
-	protected $availableTypes = array('horizontal', 'vertical');
22
-
23
-	/**
24
-	 * The button types available
25
-	 *
26
-	 * @var array
27
-	 */
28
-	private $buttons = array(
29
-		'tiny',
30
-		'small',
31
-		'medium',
32
-		'large',
33
-		'success',
34
-		'radius',
35
-		'round',
36
-		'disabled',
37
-		'prefix',
38
-		'postfix',
39
-	);
40
-
41
-	/**
42
-	 * The field sizes available
43
-	 * Zurb Foundation 5 does not apply sizes to the form element, but to the wrapper div
44
-	 *
45
-	 * @var array
46
-	 */
47
-	private $fields = array();
48
-
49
-	/**
50
-	 * The field states available
51
-	 *
52
-	 * @var array
53
-	 */
54
-	protected $states = array(
55
-		'error',
56
-	);
57
-
58
-	/**
59
-	 * Create a new ZurbFoundation instance
60
-	 *
61
-	 * @param \Illuminate\Container\Container $app
62
-	 */
63
-	public function __construct(Container $app)
64
-	{
65
-		$this->app = $app;
66
-		$this->setFrameworkDefaults();
67
-	}
68
-
69
-	////////////////////////////////////////////////////////////////////
70
-	/////////////////////////// FILTER ARRAYS //////////////////////////
71
-	////////////////////////////////////////////////////////////////////
72
-
73
-	public function filterButtonClasses($classes)
74
-	{
75
-		// Filter classes
76
-		$classes   = array_intersect($classes, $this->buttons);
77
-		$classes[] = 'button';
78
-
79
-		return $classes;
80
-	}
81
-
82
-	public function filterFieldClasses($classes)
83
-	{
84
-		return null;
85
-	}
86
-
87
-	////////////////////////////////////////////////////////////////////
88
-	///////////////////// EXPOSE FRAMEWORK SPECIFICS ///////////////////
89
-	////////////////////////////////////////////////////////////////////
90
-
91
-	protected function setFieldWidths($labelWidths)
92
-	{
93
-		$labelWidthClass = $fieldWidthClass = $fieldOffsetClass = '';
94
-
95
-		$viewports = $this->getFrameworkOption('viewports');
96
-
97
-		foreach ($labelWidths as $viewport => $columns) {
98
-			if ($viewport) {
99
-				$labelWidthClass .= $viewports[$viewport].'-'.$columns.' ';
100
-				$fieldWidthClass .= $viewports[$viewport].'-'.(12 - $columns).' ';
101
-				$fieldOffsetClass .= $viewports[$viewport].'-offset-'.$columns.' ';
102
-			}
103
-		}
104
-
105
-		$this->labelWidth  = $labelWidthClass.'columns';
106
-		$this->fieldWidth  = $fieldWidthClass.'columns';
107
-		$this->fieldOffset = $fieldOffsetClass.'columns';
108
-	}
109
-
110
-	////////////////////////////////////////////////////////////////////
111
-	///////////////////////////// ADD CLASSES //////////////////////////
112
-	////////////////////////////////////////////////////////////////////
113
-
114
-	public function getFieldClasses(Field $field, $classes = array())
115
-	{
116
-		if ($field->isButton()) {
117
-			$classes = $this->filterButtonClasses($classes);
118
-		} else {
119
-			$classes = $this->filterFieldClasses($classes);
120
-		}
121
-
122
-		return $this->addClassesToField($field, $classes);
123
-	}
124
-
125
-	public function getGroupClasses()
126
-	{
127
-		if ($this->app['former.form']->isOfType('horizontal')) {
128
-			return 'row';
129
-		} else {
130
-			return null;
131
-		}
132
-	}
133
-
134
-	/**
135
-	 * Add label classes
136
-	 *
137
-	 * @return string|null An array of attributes with the label class
138
-	 */
139
-	public function getLabelClasses()
140
-	{
141
-		if ($this->app['former.form']->isOfType('horizontal')) {
142
-			return $this->getFrameworkOption('wrappedLabelClasses');
143
-		} else {
144
-			return null;
145
-		}
146
-	}
147
-
148
-	public function getUneditableClasses()
149
-	{
150
-		return null;
151
-	}
152
-
153
-	public function getPlainTextClasses()
154
-	{
155
-		return null;
156
-	}
157
-
158
-	public function getFormClasses($type)
159
-	{
160
-		return null;
161
-	}
162
-
163
-	public function getActionClasses()
164
-	{
165
-		return null;
166
-	}
167
-
168
-	////////////////////////////////////////////////////////////////////
169
-	//////////////////////////// RENDER BLOCKS /////////////////////////
170
-	////////////////////////////////////////////////////////////////////
171
-
172
-	public function createHelp($text, $attributes = null)
173
-	{
174
-		if (is_null($attributes) or empty($attributes)) {
175
-			$attributes = $this->getFrameworkOption('error_classes');
176
-		}
177
-
178
-		return Element::create('small', $text, $attributes);
179
-	}
180
-
181
-	/**
182
-	 * Render a disabled field
183
-	 *
184
-	 * @param Field $field
185
-	 *
186
-	 * @return Input
187
-	 */
188
-	public function createDisabledField(Field $field)
189
-	{
190
-		$field->disabled();
191
-
192
-		return Input::create('text', $field->getName(), $field->getValue(), $field->getAttributes());
193
-	}
194
-
195
-	/**
196
-	 * Render a plain text field
197
-	 * Which fallback to a disabled field
198
-	 *
199
-	 * @param Field $field
200
-	 *
201
-	 * @return Element
202
-	 */
203
-	public function createPlainTextField(Field $field)
204
-	{
205
-		return $this->createDisabledField($field);
206
-	}
207
-
208
-	////////////////////////////////////////////////////////////////////
209
-	//////////////////////////// WRAP BLOCKS ///////////////////////////
210
-	////////////////////////////////////////////////////////////////////
211
-
212
-	/**
213
-	 * Wrap an item to be prepended or appended to the current field.
214
-	 * For Zurb we return the item and handle the wrapping in prependAppend
215
-	 * as wrapping is dependent on whether we're prepending or appending.
216
-	 *
217
-	 * @return string A wrapped item
218
-	 */
219
-	public function placeAround($item)
220
-	{
221
-		return $item;
222
-	}
223
-
224
-	/**
225
-	 * Wrap a field with prepended and appended items
226
-	 *
227
-	 * @param  Field $field
228
-	 * @param  array $prepend
229
-	 * @param  array $append
230
-	 *
231
-	 * @return string A field concatented with prepended and/or appended items
232
-	 */
233
-	public function prependAppend($field, $prepend, $append)
234
-	{
235
-		$return = '<div class="row collapse">';
236
-
237
-		foreach ($prepend as $item) {
238
-			$return .= '<div class="large-2 small-3 columns"><span class="prefix">'.$item.'</span></div>';
239
-		}
240
-
241
-		$return .= '<div class="large-10 small-9 columns">'.$field->render().'</div>';
242
-
243
-		foreach ($append as $item) {
244
-			$return .= '<div class="large-2 small-3 columns"><span class="postfix">'.$item.'</span></div>';
245
-		}
246
-
247
-		$return .= '</div>';
248
-
249
-		return $return;
250
-	}
251
-
252
-	/**
253
-	 * Wraps all label contents with potential additional tags.
254
-	 *
255
-	 * @param  string $label
256
-	 *
257
-	 * @return string A wrapped label
258
-	 */
259
-	public function wrapLabel($label)
260
-	{
261
-		if ($this->app['former.form']->isOfType('horizontal')) {
262
-			return Element::create('div', $label)->addClass($this->labelWidth);
263
-		} else {
264
-			return $label;
265
-		}
266
-	}
267
-
268
-	/**
269
-	 * Wraps all field contents with potential additional tags.
270
-	 *
271
-	 * @param  Field $field
272
-	 *
273
-	 * @return Element A wrapped field
274
-	 */
275
-	public function wrapField($field)
276
-	{
277
-		if ($this->app['former.form']->isOfType('horizontal')) {
278
-			return Element::create('div', $field)->addClass($this->fieldWidth);
279
-		} else {
280
-			return $field;
281
-		}
282
-	}
283
-
284
-	/**
285
-	 * Wrap actions block with potential additional tags
286
-	 *
287
-	 * @param  Actions $actions
288
-	 *
289
-	 * @return string A wrapped actions block
290
-	 */
291
-	public function wrapActions($actions)
292
-	{
293
-		return $actions;
294
-	}
16
+    /**
17
+     * Form types that trigger special styling for this Framework
18
+     *
19
+     * @var array
20
+     */
21
+    protected $availableTypes = array('horizontal', 'vertical');
22
+
23
+    /**
24
+     * The button types available
25
+     *
26
+     * @var array
27
+     */
28
+    private $buttons = array(
29
+        'tiny',
30
+        'small',
31
+        'medium',
32
+        'large',
33
+        'success',
34
+        'radius',
35
+        'round',
36
+        'disabled',
37
+        'prefix',
38
+        'postfix',
39
+    );
40
+
41
+    /**
42
+     * The field sizes available
43
+     * Zurb Foundation 5 does not apply sizes to the form element, but to the wrapper div
44
+     *
45
+     * @var array
46
+     */
47
+    private $fields = array();
48
+
49
+    /**
50
+     * The field states available
51
+     *
52
+     * @var array
53
+     */
54
+    protected $states = array(
55
+        'error',
56
+    );
57
+
58
+    /**
59
+     * Create a new ZurbFoundation instance
60
+     *
61
+     * @param \Illuminate\Container\Container $app
62
+     */
63
+    public function __construct(Container $app)
64
+    {
65
+        $this->app = $app;
66
+        $this->setFrameworkDefaults();
67
+    }
68
+
69
+    ////////////////////////////////////////////////////////////////////
70
+    /////////////////////////// FILTER ARRAYS //////////////////////////
71
+    ////////////////////////////////////////////////////////////////////
72
+
73
+    public function filterButtonClasses($classes)
74
+    {
75
+        // Filter classes
76
+        $classes   = array_intersect($classes, $this->buttons);
77
+        $classes[] = 'button';
78
+
79
+        return $classes;
80
+    }
81
+
82
+    public function filterFieldClasses($classes)
83
+    {
84
+        return null;
85
+    }
86
+
87
+    ////////////////////////////////////////////////////////////////////
88
+    ///////////////////// EXPOSE FRAMEWORK SPECIFICS ///////////////////
89
+    ////////////////////////////////////////////////////////////////////
90
+
91
+    protected function setFieldWidths($labelWidths)
92
+    {
93
+        $labelWidthClass = $fieldWidthClass = $fieldOffsetClass = '';
94
+
95
+        $viewports = $this->getFrameworkOption('viewports');
96
+
97
+        foreach ($labelWidths as $viewport => $columns) {
98
+            if ($viewport) {
99
+                $labelWidthClass .= $viewports[$viewport].'-'.$columns.' ';
100
+                $fieldWidthClass .= $viewports[$viewport].'-'.(12 - $columns).' ';
101
+                $fieldOffsetClass .= $viewports[$viewport].'-offset-'.$columns.' ';
102
+            }
103
+        }
104
+
105
+        $this->labelWidth  = $labelWidthClass.'columns';
106
+        $this->fieldWidth  = $fieldWidthClass.'columns';
107
+        $this->fieldOffset = $fieldOffsetClass.'columns';
108
+    }
109
+
110
+    ////////////////////////////////////////////////////////////////////
111
+    ///////////////////////////// ADD CLASSES //////////////////////////
112
+    ////////////////////////////////////////////////////////////////////
113
+
114
+    public function getFieldClasses(Field $field, $classes = array())
115
+    {
116
+        if ($field->isButton()) {
117
+            $classes = $this->filterButtonClasses($classes);
118
+        } else {
119
+            $classes = $this->filterFieldClasses($classes);
120
+        }
121
+
122
+        return $this->addClassesToField($field, $classes);
123
+    }
124
+
125
+    public function getGroupClasses()
126
+    {
127
+        if ($this->app['former.form']->isOfType('horizontal')) {
128
+            return 'row';
129
+        } else {
130
+            return null;
131
+        }
132
+    }
133
+
134
+    /**
135
+     * Add label classes
136
+     *
137
+     * @return string|null An array of attributes with the label class
138
+     */
139
+    public function getLabelClasses()
140
+    {
141
+        if ($this->app['former.form']->isOfType('horizontal')) {
142
+            return $this->getFrameworkOption('wrappedLabelClasses');
143
+        } else {
144
+            return null;
145
+        }
146
+    }
147
+
148
+    public function getUneditableClasses()
149
+    {
150
+        return null;
151
+    }
152
+
153
+    public function getPlainTextClasses()
154
+    {
155
+        return null;
156
+    }
157
+
158
+    public function getFormClasses($type)
159
+    {
160
+        return null;
161
+    }
162
+
163
+    public function getActionClasses()
164
+    {
165
+        return null;
166
+    }
167
+
168
+    ////////////////////////////////////////////////////////////////////
169
+    //////////////////////////// RENDER BLOCKS /////////////////////////
170
+    ////////////////////////////////////////////////////////////////////
171
+
172
+    public function createHelp($text, $attributes = null)
173
+    {
174
+        if (is_null($attributes) or empty($attributes)) {
175
+            $attributes = $this->getFrameworkOption('error_classes');
176
+        }
177
+
178
+        return Element::create('small', $text, $attributes);
179
+    }
180
+
181
+    /**
182
+     * Render a disabled field
183
+     *
184
+     * @param Field $field
185
+     *
186
+     * @return Input
187
+     */
188
+    public function createDisabledField(Field $field)
189
+    {
190
+        $field->disabled();
191
+
192
+        return Input::create('text', $field->getName(), $field->getValue(), $field->getAttributes());
193
+    }
194
+
195
+    /**
196
+     * Render a plain text field
197
+     * Which fallback to a disabled field
198
+     *
199
+     * @param Field $field
200
+     *
201
+     * @return Element
202
+     */
203
+    public function createPlainTextField(Field $field)
204
+    {
205
+        return $this->createDisabledField($field);
206
+    }
207
+
208
+    ////////////////////////////////////////////////////////////////////
209
+    //////////////////////////// WRAP BLOCKS ///////////////////////////
210
+    ////////////////////////////////////////////////////////////////////
211
+
212
+    /**
213
+     * Wrap an item to be prepended or appended to the current field.
214
+     * For Zurb we return the item and handle the wrapping in prependAppend
215
+     * as wrapping is dependent on whether we're prepending or appending.
216
+     *
217
+     * @return string A wrapped item
218
+     */
219
+    public function placeAround($item)
220
+    {
221
+        return $item;
222
+    }
223
+
224
+    /**
225
+     * Wrap a field with prepended and appended items
226
+     *
227
+     * @param  Field $field
228
+     * @param  array $prepend
229
+     * @param  array $append
230
+     *
231
+     * @return string A field concatented with prepended and/or appended items
232
+     */
233
+    public function prependAppend($field, $prepend, $append)
234
+    {
235
+        $return = '<div class="row collapse">';
236
+
237
+        foreach ($prepend as $item) {
238
+            $return .= '<div class="large-2 small-3 columns"><span class="prefix">'.$item.'</span></div>';
239
+        }
240
+
241
+        $return .= '<div class="large-10 small-9 columns">'.$field->render().'</div>';
242
+
243
+        foreach ($append as $item) {
244
+            $return .= '<div class="large-2 small-3 columns"><span class="postfix">'.$item.'</span></div>';
245
+        }
246
+
247
+        $return .= '</div>';
248
+
249
+        return $return;
250
+    }
251
+
252
+    /**
253
+     * Wraps all label contents with potential additional tags.
254
+     *
255
+     * @param  string $label
256
+     *
257
+     * @return string A wrapped label
258
+     */
259
+    public function wrapLabel($label)
260
+    {
261
+        if ($this->app['former.form']->isOfType('horizontal')) {
262
+            return Element::create('div', $label)->addClass($this->labelWidth);
263
+        } else {
264
+            return $label;
265
+        }
266
+    }
267
+
268
+    /**
269
+     * Wraps all field contents with potential additional tags.
270
+     *
271
+     * @param  Field $field
272
+     *
273
+     * @return Element A wrapped field
274
+     */
275
+    public function wrapField($field)
276
+    {
277
+        if ($this->app['former.form']->isOfType('horizontal')) {
278
+            return Element::create('div', $field)->addClass($this->fieldWidth);
279
+        } else {
280
+            return $field;
281
+        }
282
+    }
283
+
284
+    /**
285
+     * Wrap actions block with potential additional tags
286
+     *
287
+     * @param  Actions $actions
288
+     *
289
+     * @return string A wrapped actions block
290
+     */
291
+    public function wrapActions($actions)
292
+    {
293
+        return $actions;
294
+    }
295 295
 }
Please login to merge, or discard this patch.
src/Former/Form/Fields/Button.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -10,105 +10,105 @@
 block discarded – undo
10 10
  */
11 11
 class Button extends Field
12 12
 {
13
-	/**
14
-	 * The Button default element
15
-	 *
16
-	 * @var string
17
-	 */
18
-	protected $element = 'input';
13
+    /**
14
+     * The Button default element
15
+     *
16
+     * @var string
17
+     */
18
+    protected $element = 'input';
19 19
 
20
-	/**
21
-	 * Default value for self-closing
22
-	 *
23
-	 * @var boolean
24
-	 */
25
-	protected $isSelfClosing = true;
20
+    /**
21
+     * Default value for self-closing
22
+     *
23
+     * @var boolean
24
+     */
25
+    protected $isSelfClosing = true;
26 26
 
27
-	/**
28
-	 * A list of class properties to be added to attributes
29
-	 *
30
-	 * @var array
31
-	 */
32
-	protected $injectedProperties = array(
33
-		'name',
34
-		'type',
35
-		'value',
36
-	);
27
+    /**
28
+     * A list of class properties to be added to attributes
29
+     *
30
+     * @var array
31
+     */
32
+    protected $injectedProperties = array(
33
+        'name',
34
+        'type',
35
+        'value',
36
+    );
37 37
 
38
-	////////////////////////////////////////////////////////////////////
39
-	/////////////////////////// CORE METHODS ///////////////////////////
40
-	////////////////////////////////////////////////////////////////////
38
+    ////////////////////////////////////////////////////////////////////
39
+    /////////////////////////// CORE METHODS ///////////////////////////
40
+    ////////////////////////////////////////////////////////////////////
41 41
 
42
-	/**
43
-	 * Easier arguments order for button fields
44
-	 *
45
-	 * @param Container $app        The Container
46
-	 * @param string    $type       button/submit/reset/etc
47
-	 * @param string    $value      The text of the button
48
-	 * @param string    $link       Its link
49
-	 * @param array     $attributes Its attributes
50
-	 */
51
-	public function __construct(Container $app, $type, $value, $link, $attributes)
52
-	{
53
-		$this->app        = $app;
54
-		$this->attributes = (array) $attributes;
55
-		$this->type       = $type;
56
-		$this->value($value);
42
+    /**
43
+     * Easier arguments order for button fields
44
+     *
45
+     * @param Container $app        The Container
46
+     * @param string    $type       button/submit/reset/etc
47
+     * @param string    $value      The text of the button
48
+     * @param string    $link       Its link
49
+     * @param array     $attributes Its attributes
50
+     */
51
+    public function __construct(Container $app, $type, $value, $link, $attributes)
52
+    {
53
+        $this->app        = $app;
54
+        $this->attributes = (array) $attributes;
55
+        $this->type       = $type;
56
+        $this->value($value);
57 57
 
58
-		// Set correct element for the various button patterns
59
-		switch ($type) {
60
-			case 'button':
61
-				$this->element       = 'button';
62
-				$this->isSelfClosing = false;
63
-				break;
64
-			case 'link':
65
-				$this->type               = null;
66
-				$this->element            = 'a';
67
-				$this->attributes['href'] = $link;
68
-				$this->isSelfClosing      = false;
69
-				break;
70
-		}
71
-	}
58
+        // Set correct element for the various button patterns
59
+        switch ($type) {
60
+            case 'button':
61
+                $this->element       = 'button';
62
+                $this->isSelfClosing = false;
63
+                break;
64
+            case 'link':
65
+                $this->type               = null;
66
+                $this->element            = 'a';
67
+                $this->attributes['href'] = $link;
68
+                $this->isSelfClosing      = false;
69
+                break;
70
+        }
71
+    }
72 72
 
73
-	////////////////////////////////////////////////////////////////////
74
-	////////////////////////// FIELD METHODS ///////////////////////////
75
-	////////////////////////////////////////////////////////////////////
73
+    ////////////////////////////////////////////////////////////////////
74
+    ////////////////////////// FIELD METHODS ///////////////////////////
75
+    ////////////////////////////////////////////////////////////////////
76 76
 
77
-	/**
78
-	 * Check if the field is a button
79
-	 *
80
-	 * @return boolean
81
-	 */
82
-	public function isButton()
83
-	{
84
-		return true;
85
-	}
77
+    /**
78
+     * Check if the field is a button
79
+     *
80
+     * @return boolean
81
+     */
82
+    public function isButton()
83
+    {
84
+        return true;
85
+    }
86 86
 
87
-	/**
88
-	 * Prepend an icon to the button
89
-	 *
90
-	 * @param  string $icon
91
-	 * @param  array  $attributes
92
-	 *
93
-	 * @return self
94
-	 */
95
-	public function icon($icon, $attributes = array())
96
-	{
97
-		$icon        = $this->app['former.framework']->createIcon($icon, $attributes);
98
-		$this->value = $icon.' '.$this->value;
87
+    /**
88
+     * Prepend an icon to the button
89
+     *
90
+     * @param  string $icon
91
+     * @param  array  $attributes
92
+     *
93
+     * @return self
94
+     */
95
+    public function icon($icon, $attributes = array())
96
+    {
97
+        $icon        = $this->app['former.framework']->createIcon($icon, $attributes);
98
+        $this->value = $icon.' '.$this->value;
99 99
 
100
-		return $this;
101
-	}
100
+        return $this;
101
+    }
102 102
 
103
-	/**
104
-	 * Hijack Former's Object model value method
105
-	 *
106
-	 * @param  string $value The new button text
107
-	 */
108
-	public function value($value)
109
-	{
110
-		$this->value = Helpers::translate($value);
103
+    /**
104
+     * Hijack Former's Object model value method
105
+     *
106
+     * @param  string $value The new button text
107
+     */
108
+    public function value($value)
109
+    {
110
+        $this->value = Helpers::translate($value);
111 111
 
112
-		return $this;
113
-	}
112
+        return $this;
113
+    }
114 114
 }
Please login to merge, or discard this patch.
src/Former/Form/Fields/Checkbox.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -8,28 +8,28 @@
 block discarded – undo
8 8
  */
9 9
 class Checkbox extends Checkable
10 10
 {
11
-	/**
12
-	 * The current checkable type
13
-	 *
14
-	 * @var string
15
-	 */
16
-	protected $checkable = 'checkbox';
11
+    /**
12
+     * The current checkable type
13
+     *
14
+     * @var string
15
+     */
16
+    protected $checkable = 'checkbox';
17 17
 
18
-	////////////////////////////////////////////////////////////////////
19
-	////////////////////////// FIELD METHODS ///////////////////////////
20
-	////////////////////////////////////////////////////////////////////
18
+    ////////////////////////////////////////////////////////////////////
19
+    ////////////////////////// FIELD METHODS ///////////////////////////
20
+    ////////////////////////////////////////////////////////////////////
21 21
 
22
-	/**
23
-	 * Create a serie of checkboxes
24
-	 */
25
-	public function checkboxes()
26
-	{
27
-		if ($this->isGrouped()) {
28
-			// Remove any possible items added by the Populator.
29
-			$this->items = array();
30
-		}
31
-		$this->items(func_get_args());
22
+    /**
23
+     * Create a serie of checkboxes
24
+     */
25
+    public function checkboxes()
26
+    {
27
+        if ($this->isGrouped()) {
28
+            // Remove any possible items added by the Populator.
29
+            $this->items = array();
30
+        }
31
+        $this->items(func_get_args());
32 32
 
33
-		return $this;
34
-	}
33
+        return $this;
34
+    }
35 35
 }
Please login to merge, or discard this patch.
src/Former/Form/Fields/Radio.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
  */
9 9
 class Radio extends Checkable
10 10
 {
11
-	/**
12
-	 * The current checkable type
13
-	 *
14
-	 * @var string
15
-	 */
16
-	protected $checkable = 'radio';
11
+    /**
12
+     * The current checkable type
13
+     *
14
+     * @var string
15
+     */
16
+    protected $checkable = 'radio';
17 17
 
18
-	////////////////////////////////////////////////////////////////////
19
-	////////////////////////// FIELD METHODS ///////////////////////////
20
-	////////////////////////////////////////////////////////////////////
18
+    ////////////////////////////////////////////////////////////////////
19
+    ////////////////////////// FIELD METHODS ///////////////////////////
20
+    ////////////////////////////////////////////////////////////////////
21 21
 
22
-	/**
23
-	 * Create a serie of radios
24
-	 */
25
-	public function radios()
26
-	{
27
-		$this->items(func_get_args());
22
+    /**
23
+     * Create a serie of radios
24
+     */
25
+    public function radios()
26
+    {
27
+        $this->items(func_get_args());
28 28
 
29
-		return $this;
30
-	}
29
+        return $this;
30
+    }
31 31
 }
Please login to merge, or discard this patch.
src/Former/Form/Fields/Hidden.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -12,31 +12,31 @@
 block discarded – undo
12 12
 class Hidden extends Field
13 13
 {
14 14
 
15
-	////////////////////////////////////////////////////////////////////
16
-	/////////////////////////// CORE METHODS ///////////////////////////
17
-	////////////////////////////////////////////////////////////////////
15
+    ////////////////////////////////////////////////////////////////////
16
+    /////////////////////////// CORE METHODS ///////////////////////////
17
+    ////////////////////////////////////////////////////////////////////
18 18
 
19
-	/**
20
-	 * Easier arguments order for hidden fields
21
-	 *
22
-	 * @param Container $app        The Container
23
-	 * @param string    $type       hidden
24
-	 * @param string    $name       Field names
25
-	 * @param string    $value      Its value
26
-	 * @param array     $attributes Attributes
27
-	 */
28
-	public function __construct(Container $app, $type, $name, $value, $attributes)
29
-	{
30
-		parent::__construct($app, $type, $name, '', $value, $attributes);
31
-	}
19
+    /**
20
+     * Easier arguments order for hidden fields
21
+     *
22
+     * @param Container $app        The Container
23
+     * @param string    $type       hidden
24
+     * @param string    $name       Field names
25
+     * @param string    $value      Its value
26
+     * @param array     $attributes Attributes
27
+     */
28
+    public function __construct(Container $app, $type, $name, $value, $attributes)
29
+    {
30
+        parent::__construct($app, $type, $name, '', $value, $attributes);
31
+    }
32 32
 
33
-	/**
34
-	 * Outputs a hidden field
35
-	 *
36
-	 * @return string An <input type="hidden" />
37
-	 */
38
-	public function render()
39
-	{
40
-		return HtmlInput::create('hidden', $this->name, Helpers::encode($this->value), $this->attributes)->render();
41
-	}
33
+    /**
34
+     * Outputs a hidden field
35
+     *
36
+     * @return string An <input type="hidden" />
37
+     */
38
+    public function render()
39
+    {
40
+        return HtmlInput::create('hidden', $this->name, Helpers::encode($this->value), $this->attributes)->render();
41
+    }
42 42
 }
Please login to merge, or discard this patch.
src/Former/Form/Fields/Input.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -10,146 +10,146 @@
 block discarded – undo
10 10
  */
11 11
 class Input extends Field
12 12
 {
13
-	/**
14
-	 * Current datalist stored
15
-	 *
16
-	 * @var array
17
-	 */
18
-	protected $datalist = array();
19
-
20
-	/**
21
-	 * Properties to be injected as attributes
22
-	 *
23
-	 * @var array
24
-	 */
25
-	protected $injectedProperties = array('type', 'name', 'value');
26
-
27
-	////////////////////////////////////////////////////////////////////
28
-	/////////////////////////// CORE METHODS ///////////////////////////
29
-	////////////////////////////////////////////////////////////////////
30
-
31
-	/**
32
-	 * Build an input field
33
-	 *
34
-	 * @param Container $app        The Container
35
-	 * @param string    $type       The input type
36
-	 * @param string    $name       Field name
37
-	 * @param string    $label      Its label
38
-	 * @param string    $value      Its value
39
-	 * @param array     $attributes Attributes
40
-	 */
41
-	public function __construct(Container $app, $type, $name, $label, $value, $attributes)
42
-	{
43
-		parent::__construct($app, $type, $name, $label, $value, $attributes);
44
-
45
-		// Multiple models population
46
-		if (is_array($this->value)) {
47
-			$values = array();
48
-			foreach ($this->value as $value) {
49
-				$values[] = is_object($value) ? $value->__toString() : $value;
50
-			}
51
-			if (isset($values)) {
52
-				$this->value = implode(', ', $values);
53
-			}
54
-		}
55
-	}
56
-
57
-	/**
58
-	 * Prints out the current tag
59
-	 *
60
-	 * @return string An input tag
61
-	 */
62
-	public function render()
63
-	{
64
-		// Particular case of the search element
65
-		if ($this->isOfType('search')) {
66
-			$this->asSearch();
67
-		}
68
-
69
-		$this->setId();
70
-
71
-		// Render main input
72
-		$input = parent::render();
73
-
74
-		// If we have a datalist to append, print it out
75
-		if ($this->datalist) {
76
-			$input .= $this->createDatalist($this->list, $this->datalist);
77
-		}
78
-
79
-		return $input;
80
-	}
81
-
82
-	////////////////////////////////////////////////////////////////////
83
-	////////////////////////// FIELD METHODS ///////////////////////////
84
-	////////////////////////////////////////////////////////////////////
85
-
86
-	/**
87
-	 * Adds a datalist to the current field
88
-	 *
89
-	 * @param  array  $datalist An array to use a source
90
-	 * @param  string $value    The field to use as value
91
-	 * @param  string $key      The field to use as key
92
-	 */
93
-	public function useDatalist($datalist, $value = null, $key = null)
94
-	{
95
-		$datalist = Helpers::queryToArray($datalist, $value, $key);
96
-
97
-		$list = $this->list ?: 'datalist_'.$this->name;
98
-
99
-		// Create the link to the datalist
100
-		$this->list     = $list;
101
-		$this->datalist = $datalist;
102
-
103
-		return $this;
104
-	}
105
-
106
-	/**
107
-	 * Add range to the input
108
-	 *
109
-	 * @param  integer $min
110
-	 * @param  integer $max
111
-	 *
112
-	 * @return self
113
-	 */
114
-	public function range($min, $max)
115
-	{
116
-		$this->min($min);
117
-		$this->max($max);
118
-
119
-		return $this;
120
-	}
121
-
122
-	////////////////////////////////////////////////////////////////////
123
-	/////////////////////////////// HELPERS ////////////////////////////
124
-	////////////////////////////////////////////////////////////////////
125
-
126
-	/**
127
-	 * Render a text element as a search element
128
-	 */
129
-	private function asSearch()
130
-	{
131
-		$this->type = 'text';
132
-		$this->addClass('search-query');
133
-
134
-		return $this;
135
-	}
136
-
137
-	/**
138
-	 * Renders a datalist
139
-	 *
140
-	 * @param string $id     The datalist's id attribute
141
-	 * @param array  $values Its values
142
-	 *
143
-	 * @return string A <datalist> tag
144
-	 */
145
-	private function createDatalist($id, $values)
146
-	{
147
-		$datalist = '<datalist id="'.$id.'">';
148
-		foreach ($values as $key => $value) {
149
-			$datalist .= '<option value="'.$value.'">'.$key.'</option>';
150
-		}
151
-		$datalist .= '</datalist>';
152
-
153
-		return $datalist;
154
-	}
13
+    /**
14
+     * Current datalist stored
15
+     *
16
+     * @var array
17
+     */
18
+    protected $datalist = array();
19
+
20
+    /**
21
+     * Properties to be injected as attributes
22
+     *
23
+     * @var array
24
+     */
25
+    protected $injectedProperties = array('type', 'name', 'value');
26
+
27
+    ////////////////////////////////////////////////////////////////////
28
+    /////////////////////////// CORE METHODS ///////////////////////////
29
+    ////////////////////////////////////////////////////////////////////
30
+
31
+    /**
32
+     * Build an input field
33
+     *
34
+     * @param Container $app        The Container
35
+     * @param string    $type       The input type
36
+     * @param string    $name       Field name
37
+     * @param string    $label      Its label
38
+     * @param string    $value      Its value
39
+     * @param array     $attributes Attributes
40
+     */
41
+    public function __construct(Container $app, $type, $name, $label, $value, $attributes)
42
+    {
43
+        parent::__construct($app, $type, $name, $label, $value, $attributes);
44
+
45
+        // Multiple models population
46
+        if (is_array($this->value)) {
47
+            $values = array();
48
+            foreach ($this->value as $value) {
49
+                $values[] = is_object($value) ? $value->__toString() : $value;
50
+            }
51
+            if (isset($values)) {
52
+                $this->value = implode(', ', $values);
53
+            }
54
+        }
55
+    }
56
+
57
+    /**
58
+     * Prints out the current tag
59
+     *
60
+     * @return string An input tag
61
+     */
62
+    public function render()
63
+    {
64
+        // Particular case of the search element
65
+        if ($this->isOfType('search')) {
66
+            $this->asSearch();
67
+        }
68
+
69
+        $this->setId();
70
+
71
+        // Render main input
72
+        $input = parent::render();
73
+
74
+        // If we have a datalist to append, print it out
75
+        if ($this->datalist) {
76
+            $input .= $this->createDatalist($this->list, $this->datalist);
77
+        }
78
+
79
+        return $input;
80
+    }
81
+
82
+    ////////////////////////////////////////////////////////////////////
83
+    ////////////////////////// FIELD METHODS ///////////////////////////
84
+    ////////////////////////////////////////////////////////////////////
85
+
86
+    /**
87
+     * Adds a datalist to the current field
88
+     *
89
+     * @param  array  $datalist An array to use a source
90
+     * @param  string $value    The field to use as value
91
+     * @param  string $key      The field to use as key
92
+     */
93
+    public function useDatalist($datalist, $value = null, $key = null)
94
+    {
95
+        $datalist = Helpers::queryToArray($datalist, $value, $key);
96
+
97
+        $list = $this->list ?: 'datalist_'.$this->name;
98
+
99
+        // Create the link to the datalist
100
+        $this->list     = $list;
101
+        $this->datalist = $datalist;
102
+
103
+        return $this;
104
+    }
105
+
106
+    /**
107
+     * Add range to the input
108
+     *
109
+     * @param  integer $min
110
+     * @param  integer $max
111
+     *
112
+     * @return self
113
+     */
114
+    public function range($min, $max)
115
+    {
116
+        $this->min($min);
117
+        $this->max($max);
118
+
119
+        return $this;
120
+    }
121
+
122
+    ////////////////////////////////////////////////////////////////////
123
+    /////////////////////////////// HELPERS ////////////////////////////
124
+    ////////////////////////////////////////////////////////////////////
125
+
126
+    /**
127
+     * Render a text element as a search element
128
+     */
129
+    private function asSearch()
130
+    {
131
+        $this->type = 'text';
132
+        $this->addClass('search-query');
133
+
134
+        return $this;
135
+    }
136
+
137
+    /**
138
+     * Renders a datalist
139
+     *
140
+     * @param string $id     The datalist's id attribute
141
+     * @param array  $values Its values
142
+     *
143
+     * @return string A <datalist> tag
144
+     */
145
+    private function createDatalist($id, $values)
146
+    {
147
+        $datalist = '<datalist id="'.$id.'">';
148
+        foreach ($values as $key => $value) {
149
+            $datalist .= '<option value="'.$value.'">'.$key.'</option>';
150
+        }
151
+        $datalist .= '</datalist>';
152
+
153
+        return $datalist;
154
+    }
155 155
 }
Please login to merge, or discard this patch.