Completed
Branch scrutinizer-patch-1 (42a7d0)
by Ben
02:17
created
src/Former/Interfaces/FrameworkInterface.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -8,141 +8,141 @@
 block discarded – undo
8 8
  */
9 9
 interface FrameworkInterface
10 10
 {
11
-	/**
12
-	 * Filter buttons classes
13
-	 *
14
-	 * @param  array $classes An array of classes
15
-	 *
16
-	 * @return array A filtered array
17
-	 */
18
-	public function filterButtonClasses($classes);
19
-
20
-	/**
21
-	 * Filter field classes
22
-	 *
23
-	 * @param  array $classes An array of classes
24
-	 *
25
-	 * @return array A filtered array
26
-	 */
27
-	public function filterFieldClasses($classes);
28
-
29
-	/**
30
-	 * Add classes to a field
31
-	 *
32
-	 * @param Field $field
33
-	 * @param array $classes The possible classes to add
34
-	 *
35
-	 * @return Field
36
-	 */
37
-	public function getFieldClasses(Field $field, $classes);
38
-
39
-	/**
40
-	 * Add group classes
41
-	 *
42
-	 * @return string A list of group classes
43
-	 */
44
-	public function getGroupClasses();
45
-
46
-	/**
47
-	 * Add label classes
48
-	 *
49
-	 * @return array An array of attributes with the label class
50
-	 */
51
-	public function getLabelClasses();
52
-
53
-	/**
54
-	 * Add uneditable field classes
55
-	 *
56
-	 * @return array An array of attributes with the uneditable class
57
-	 */
58
-	public function getUneditableClasses();
59
-
60
-	/**
61
-	 * Add plain text field classes
62
-	 *
63
-	 * @return array An array of attributes with the plain text class
64
-	 */
65
-	public function getPlainTextClasses();
66
-
67
-	/**
68
-	 * Add form class
69
-	 *
70
-	 * @param  string $type The type of form to add
71
-	 *
72
-	 * @return array
73
-	 */
74
-	public function getFormClasses($type);
75
-
76
-	/**
77
-	 * Add actions block class
78
-	 *
79
-	 * @return array
80
-	 */
81
-	public function getActionClasses();
82
-
83
-	/**
84
-	 * Render an help text
85
-	 *
86
-	 * @param string $text
87
-	 * @param array  $attributes
88
-	 *
89
-	 * @return string
90
-	 */
91
-	public function createHelp($text, $attributes = array());
92
-
93
-	/**
94
-	 * Render a disabled field
95
-	 *
96
-	 * @param Field $field
97
-	 *
98
-	 * @return string
99
-	 */
100
-	public function createDisabledField(Field $field);
101
-
102
-	/**
103
-	 * Render a plain text field
104
-	 *
105
-	 * @param Field $field
106
-	 *
107
-	 * @return string
108
-	 */
109
-	public function createPlainTextField(Field $field);
110
-
111
-	/**
112
-	 * Render an icon
113
-	 *
114
-	 * @param array $attributes Its attributes
115
-	 *
116
-	 * @return string
117
-	 */
118
-	public function createIcon($iconType, $attributes = array());
119
-
120
-	/**
121
-	 * Wrap an item to be prepended or appended to the current field
122
-	 *
123
-	 * @param  string $item
124
-	 *
125
-	 * @return string A wrapped item
126
-	 */
127
-	public function placeAround($item);
128
-
129
-	/**
130
-	 * Wrap a field with prepended and appended items
131
-	 *
132
-	 * @param  Field $field
133
-	 * @param  array $prepend
134
-	 * @param  array $append
135
-	 *
136
-	 * @return string A field concatented with prepended and/or appended items
137
-	 */
138
-	public function prependAppend($field, $prepend, $append);
139
-
140
-	/**
141
-	 * Wrap a field with potential additional tags
142
-	 *
143
-	 * @param  Field $field
144
-	 *
145
-	 * @return string A wrapped field
146
-	 */
147
-	public function wrapField($field);
11
+    /**
12
+     * Filter buttons classes
13
+     *
14
+     * @param  array $classes An array of classes
15
+     *
16
+     * @return array A filtered array
17
+     */
18
+    public function filterButtonClasses($classes);
19
+
20
+    /**
21
+     * Filter field classes
22
+     *
23
+     * @param  array $classes An array of classes
24
+     *
25
+     * @return array A filtered array
26
+     */
27
+    public function filterFieldClasses($classes);
28
+
29
+    /**
30
+     * Add classes to a field
31
+     *
32
+     * @param Field $field
33
+     * @param array $classes The possible classes to add
34
+     *
35
+     * @return Field
36
+     */
37
+    public function getFieldClasses(Field $field, $classes);
38
+
39
+    /**
40
+     * Add group classes
41
+     *
42
+     * @return string A list of group classes
43
+     */
44
+    public function getGroupClasses();
45
+
46
+    /**
47
+     * Add label classes
48
+     *
49
+     * @return array An array of attributes with the label class
50
+     */
51
+    public function getLabelClasses();
52
+
53
+    /**
54
+     * Add uneditable field classes
55
+     *
56
+     * @return array An array of attributes with the uneditable class
57
+     */
58
+    public function getUneditableClasses();
59
+
60
+    /**
61
+     * Add plain text field classes
62
+     *
63
+     * @return array An array of attributes with the plain text class
64
+     */
65
+    public function getPlainTextClasses();
66
+
67
+    /**
68
+     * Add form class
69
+     *
70
+     * @param  string $type The type of form to add
71
+     *
72
+     * @return array
73
+     */
74
+    public function getFormClasses($type);
75
+
76
+    /**
77
+     * Add actions block class
78
+     *
79
+     * @return array
80
+     */
81
+    public function getActionClasses();
82
+
83
+    /**
84
+     * Render an help text
85
+     *
86
+     * @param string $text
87
+     * @param array  $attributes
88
+     *
89
+     * @return string
90
+     */
91
+    public function createHelp($text, $attributes = array());
92
+
93
+    /**
94
+     * Render a disabled field
95
+     *
96
+     * @param Field $field
97
+     *
98
+     * @return string
99
+     */
100
+    public function createDisabledField(Field $field);
101
+
102
+    /**
103
+     * Render a plain text field
104
+     *
105
+     * @param Field $field
106
+     *
107
+     * @return string
108
+     */
109
+    public function createPlainTextField(Field $field);
110
+
111
+    /**
112
+     * Render an icon
113
+     *
114
+     * @param array $attributes Its attributes
115
+     *
116
+     * @return string
117
+     */
118
+    public function createIcon($iconType, $attributes = array());
119
+
120
+    /**
121
+     * Wrap an item to be prepended or appended to the current field
122
+     *
123
+     * @param  string $item
124
+     *
125
+     * @return string A wrapped item
126
+     */
127
+    public function placeAround($item);
128
+
129
+    /**
130
+     * Wrap a field with prepended and appended items
131
+     *
132
+     * @param  Field $field
133
+     * @param  array $prepend
134
+     * @param  array $append
135
+     *
136
+     * @return string A field concatented with prepended and/or appended items
137
+     */
138
+    public function prependAppend($field, $prepend, $append);
139
+
140
+    /**
141
+     * Wrap a field with potential additional tags
142
+     *
143
+     * @param  Field $field
144
+     *
145
+     * @return string A wrapped field
146
+     */
147
+    public function wrapField($field);
148 148
 }
Please login to merge, or discard this patch.
src/Former/Interfaces/FieldInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@
 block discarded – undo
6 6
  */
7 7
 interface FieldInterface
8 8
 {
9
-	/**
10
-	 * Renders the field
11
-	 *
12
-	 * @return string
13
-	 */
14
-	public function render();
9
+    /**
10
+     * Renders the field
11
+     *
12
+     * @return string
13
+     */
14
+    public function render();
15 15
 }
Please login to merge, or discard this patch.
src/Former/FormerServiceProvider.php 1 patch
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -15,197 +15,197 @@
 block discarded – undo
15 15
  */
16 16
 class FormerServiceProvider extends ServiceProvider
17 17
 {
18
-	/**
19
-	 * Indicates if loading of the provider is deferred.
20
-	 *
21
-	 * @var bool
22
-	 */
23
-	protected $defer = true;
24
-
25
-	/**
26
-	 * Register Former's package with Laravel
27
-	 *
28
-	 * @return void
29
-	 */
30
-	public function register()
31
-	{
32
-		$this->app = static::make($this->app);
33
-	}
34
-
35
-	/**
36
-	 * Get the services provided by the provider.
37
-	 *
38
-	 * @return string[]
39
-	 */
40
-	public function provides()
41
-	{
42
-		return array('former', 'Former\Former');
43
-	}
44
-
45
-	////////////////////////////////////////////////////////////////////
46
-	/////////////////////////// CLASS BINDINGS /////////////////////////
47
-	////////////////////////////////////////////////////////////////////
48
-
49
-	/**
50
-	 * Create a Former container
51
-	 *
52
-	 * @param  Container $app
53
-	 *
54
-	 * @return Container
55
-	 */
56
-	public static function make($app = null)
57
-	{
58
-		if (!$app) {
59
-			$app = new Container();
60
-		}
61
-
62
-		// Bind classes to container
63
-		$provider = new static($app);
64
-		$app      = $provider->bindCoreClasses($app);
65
-		$app      = $provider->bindFormer($app);
66
-
67
-		return $app;
68
-	}
69
-
70
-	/**
71
-	 * Bind the core classes to the Container
72
-	 *
73
-	 * @param  Container $app
74
-	 *
75
-	 * @return Container
76
-	 */
77
-	public function bindCoreClasses(Container $app)
78
-	{
79
-		// Cancel if in the scope of a Laravel application
80
-		if ($app->bound('events')) {
81
-			return $app;
82
-		}
83
-
84
-		// Core classes
85
-		//////////////////////////////////////////////////////////////////
86
-
87
-		$app->bindIf('files', 'Illuminate\Filesystem\Filesystem');
88
-		$app->bindIf('url', 'Illuminate\Routing\UrlGenerator');
89
-
90
-		// Session and request
91
-		//////////////////////////////////////////////////////////////////
92
-
93
-		$app->bindIf('session.manager', function($app) {
94
-			return new SessionManager($app);
95
-		});
96
-
97
-		$app->bindIf('session', function($app) {
98
-			return $app['session.manager']->driver('array');
99
-		}, true);
100
-
101
-		$app->bindIf('request', function($app) {
102
-			$request = Request::createFromGlobals();
103
-			if (method_exists($request, 'setSessionStore')) {
104
-				$request->setSessionStore($app['session']);
105
-			} else {
106
-				$request->setSession($app['session']);
107
-			}
108
-
109
-			return $request;
110
-		}, true);
111
-
112
-		// Config
113
-		//////////////////////////////////////////////////////////////////
114
-
115
-		$app->bindIf('path.config', function($app) {
116
-			return __DIR__.'/../config/';
117
-		}, true);
118
-
119
-		$app->bindIf('config', function($app) {
120
-			$config = new Repository;
121
-			$this->loadConfigurationFiles($app, $config);
122
-			return $config;
123
-		}, true);
124
-
125
-		// Localization
126
-		//////////////////////////////////////////////////////////////////
127
-
128
-		$app->bindIf('translation.loader', function($app) {
129
-			return new FileLoader($app['files'], 'src/config');
130
-		});
131
-
132
-		$app->bindIf('translator', function($app) {
133
-			$loader = new FileLoader($app['files'], 'lang');
134
-
135
-			return new Translator($loader, 'fr');
136
-		});
137
-
138
-		return $app;
139
-	}
140
-
141
-	/**
142
-	 * Load the configuration items from all of the files.
143
-	 *
144
-	 * @param  Container $app
145
-	 * @param  Repository  $config
146
-	 * @return void
147
-	 */
148
-	protected function loadConfigurationFiles($app, Repository $config)
149
-	{
150
-		foreach ($this->getConfigurationFiles($app) as $key => $path)
151
-		{
152
-			$config->set($key, require $path);
153
-		}
154
-	}
155
-
156
-	/**
157
-	 * Get all of the configuration files for the application.
158
-	 *
159
-	 * @param  Container $app
160
-	 * @return array
161
-	 */
162
-	protected function getConfigurationFiles($app)
163
-	{
164
-		$files = array();
165
-
166
-		foreach (Finder::create()->files()->name('*.php')->in($app['path.config']) as $file)
167
-		{
168
-			$files[basename($file->getRealPath(), '.php')] = $file->getRealPath();
169
-		}
170
-
171
-		return $files;
172
-	}
173
-
174
-	/**
175
-	 * Bind Former classes to the container
176
-	 *
177
-	 * @param  Container $app
178
-	 *
179
-	 * @return Container
180
-	 */
181
-	public function bindFormer(Container $app)
182
-	{
183
-		// Add config namespace
184
-		$configPath = __DIR__.'/../config/former.php';
185
-		$this->mergeConfigFrom($configPath, 'former');
186
-		$this->publishes([$configPath => $app['path.config'].'/former.php']);
18
+    /**
19
+     * Indicates if loading of the provider is deferred.
20
+     *
21
+     * @var bool
22
+     */
23
+    protected $defer = true;
24
+
25
+    /**
26
+     * Register Former's package with Laravel
27
+     *
28
+     * @return void
29
+     */
30
+    public function register()
31
+    {
32
+        $this->app = static::make($this->app);
33
+    }
34
+
35
+    /**
36
+     * Get the services provided by the provider.
37
+     *
38
+     * @return string[]
39
+     */
40
+    public function provides()
41
+    {
42
+        return array('former', 'Former\Former');
43
+    }
44
+
45
+    ////////////////////////////////////////////////////////////////////
46
+    /////////////////////////// CLASS BINDINGS /////////////////////////
47
+    ////////////////////////////////////////////////////////////////////
48
+
49
+    /**
50
+     * Create a Former container
51
+     *
52
+     * @param  Container $app
53
+     *
54
+     * @return Container
55
+     */
56
+    public static function make($app = null)
57
+    {
58
+        if (!$app) {
59
+            $app = new Container();
60
+        }
61
+
62
+        // Bind classes to container
63
+        $provider = new static($app);
64
+        $app      = $provider->bindCoreClasses($app);
65
+        $app      = $provider->bindFormer($app);
66
+
67
+        return $app;
68
+    }
69
+
70
+    /**
71
+     * Bind the core classes to the Container
72
+     *
73
+     * @param  Container $app
74
+     *
75
+     * @return Container
76
+     */
77
+    public function bindCoreClasses(Container $app)
78
+    {
79
+        // Cancel if in the scope of a Laravel application
80
+        if ($app->bound('events')) {
81
+            return $app;
82
+        }
83
+
84
+        // Core classes
85
+        //////////////////////////////////////////////////////////////////
86
+
87
+        $app->bindIf('files', 'Illuminate\Filesystem\Filesystem');
88
+        $app->bindIf('url', 'Illuminate\Routing\UrlGenerator');
89
+
90
+        // Session and request
91
+        //////////////////////////////////////////////////////////////////
92
+
93
+        $app->bindIf('session.manager', function($app) {
94
+            return new SessionManager($app);
95
+        });
96
+
97
+        $app->bindIf('session', function($app) {
98
+            return $app['session.manager']->driver('array');
99
+        }, true);
100
+
101
+        $app->bindIf('request', function($app) {
102
+            $request = Request::createFromGlobals();
103
+            if (method_exists($request, 'setSessionStore')) {
104
+                $request->setSessionStore($app['session']);
105
+            } else {
106
+                $request->setSession($app['session']);
107
+            }
108
+
109
+            return $request;
110
+        }, true);
111
+
112
+        // Config
113
+        //////////////////////////////////////////////////////////////////
114
+
115
+        $app->bindIf('path.config', function($app) {
116
+            return __DIR__.'/../config/';
117
+        }, true);
118
+
119
+        $app->bindIf('config', function($app) {
120
+            $config = new Repository;
121
+            $this->loadConfigurationFiles($app, $config);
122
+            return $config;
123
+        }, true);
124
+
125
+        // Localization
126
+        //////////////////////////////////////////////////////////////////
127
+
128
+        $app->bindIf('translation.loader', function($app) {
129
+            return new FileLoader($app['files'], 'src/config');
130
+        });
131
+
132
+        $app->bindIf('translator', function($app) {
133
+            $loader = new FileLoader($app['files'], 'lang');
134
+
135
+            return new Translator($loader, 'fr');
136
+        });
137
+
138
+        return $app;
139
+    }
140
+
141
+    /**
142
+     * Load the configuration items from all of the files.
143
+     *
144
+     * @param  Container $app
145
+     * @param  Repository  $config
146
+     * @return void
147
+     */
148
+    protected function loadConfigurationFiles($app, Repository $config)
149
+    {
150
+        foreach ($this->getConfigurationFiles($app) as $key => $path)
151
+        {
152
+            $config->set($key, require $path);
153
+        }
154
+    }
155
+
156
+    /**
157
+     * Get all of the configuration files for the application.
158
+     *
159
+     * @param  Container $app
160
+     * @return array
161
+     */
162
+    protected function getConfigurationFiles($app)
163
+    {
164
+        $files = array();
165
+
166
+        foreach (Finder::create()->files()->name('*.php')->in($app['path.config']) as $file)
167
+        {
168
+            $files[basename($file->getRealPath(), '.php')] = $file->getRealPath();
169
+        }
170
+
171
+        return $files;
172
+    }
173
+
174
+    /**
175
+     * Bind Former classes to the container
176
+     *
177
+     * @param  Container $app
178
+     *
179
+     * @return Container
180
+     */
181
+    public function bindFormer(Container $app)
182
+    {
183
+        // Add config namespace
184
+        $configPath = __DIR__.'/../config/former.php';
185
+        $this->mergeConfigFrom($configPath, 'former');
186
+        $this->publishes([$configPath => $app['path.config'].'/former.php']);
187 187
 		
188
-		$framework = $app['config']->get('former.framework');
188
+        $framework = $app['config']->get('former.framework');
189 189
 		
190
-		$app->bind('former.framework', function($app) {
191
-			return $app['former']->getFrameworkInstance($app['config']->get('former.framework'));
192
-		});
190
+        $app->bind('former.framework', function($app) {
191
+            return $app['former']->getFrameworkInstance($app['config']->get('former.framework'));
192
+        });
193 193
 
194
-		$app->singleton('former.populator', function($app) {
195
-			return new Populator();
196
-		});
194
+        $app->singleton('former.populator', function($app) {
195
+            return new Populator();
196
+        });
197 197
 
198
-		$app->singleton('former.dispatcher', function($app) {
199
-			return new MethodDispatcher($app, Former::FIELDSPACE);
200
-		});
198
+        $app->singleton('former.dispatcher', function($app) {
199
+            return new MethodDispatcher($app, Former::FIELDSPACE);
200
+        });
201 201
 
202
-		$app->singleton('former', function($app) {
203
-			return new Former($app, $app->make('former.dispatcher'));
204
-		});
205
-		$app->alias('former', 'Former\Former');
202
+        $app->singleton('former', function($app) {
203
+            return new Former($app, $app->make('former.dispatcher'));
204
+        });
205
+        $app->alias('former', 'Former\Former');
206 206
 
207
-		Helpers::setApp($app);
207
+        Helpers::setApp($app);
208 208
 
209
-		return $app;
210
-	}
209
+        return $app;
210
+    }
211 211
 }
Please login to merge, or discard this patch.
src/Former/Populator.php 1 patch
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -11,171 +11,171 @@
 block discarded – undo
11 11
  */
12 12
 class Populator extends Collection
13 13
 {
14
-	/**
15
-	 * Create a new collection.
16
-	 *
17
-	 * @param  array|Model $items
18
-	 *
19
-	 * @return void
20
-	 */
21
-	public function __construct($items = array())
22
-	{
23
-		$this->items = $items;
24
-	}
25
-
26
-	////////////////////////////////////////////////////////////////////
27
-	///////////////////////// INDIVIDUAL VALUES ////////////////////////
28
-	////////////////////////////////////////////////////////////////////
29
-
30
-	/**
31
-	 * Get the value of a field
32
-	 *
33
-	 * @param string $field The field's name
34
-	 *
35
-	 * @return mixed
36
-	 */
37
-	public function get($field, $fallback = null)
38
-	{
39
-		// Anonymous fields should not return any value
40
-		if ($field == null) {
41
-			return null;
42
-		}
43
-
44
-		// Plain array
45
-		if (is_array($this->items) and !str_contains($field, '[')) {
46
-			return parent::get($field, $fallback);
47
-		}
48
-
49
-		// Transform the name into an array
50
-		$value = $this->items;
51
-		$field = $this->parseFieldAsArray($field);
52
-
53
-		// Dive into the model
54
-		foreach ($field as $relationship) {
55
-
56
-			// Get attribute from model
57
-			if (!is_array($value)) {
58
-				$value = $this->getAttributeFromModel($value, $relationship, $fallback);
59
-
60
-				continue;
61
-			}
62
-
63
-			// Get attribute from model
64
-			if (array_key_exists($relationship, $value)) {
65
-				$value = $value[$relationship];
66
-			} else {
67
-				// Check array for submodels that may contain the relationship
68
-				$inSubmodel = false;
69
-
70
-				foreach ($value as $key => $submodel) {
71
-					$value[$key] = $this->getAttributeFromModel($submodel, $relationship, $fallback);
72
-
73
-					if ($value[$key] !== $fallback) {
74
-						$inSubmodel = true;
75
-					}
76
-				}
77
-
78
-				// If no submodels contained the relationship, return the fallback, not an array of fallbacks
79
-				if (!$inSubmodel) {
80
-					$value = $fallback;
81
-					break;
82
-				}
83
-			}
84
-		}
85
-
86
-		return $value;
87
-	}
88
-
89
-	////////////////////////////////////////////////////////////////////
90
-	///////////////////////////// SWAPPERS /////////////////////////////
91
-	////////////////////////////////////////////////////////////////////
92
-
93
-	/**
94
-	 * Replace the items
95
-	 *
96
-	 * @param  mixed $items
97
-	 *
98
-	 * @return void
99
-	 */
100
-	public function replace($items)
101
-	{
102
-		$this->items = $items;
103
-	}
104
-
105
-	/**
106
-	 * Reset the current values array
107
-	 *
108
-	 * @return void
109
-	 */
110
-	public function reset()
111
-	{
112
-		$this->items = array();
113
-	}
114
-
115
-	////////////////////////////////////////////////////////////////////
116
-	////////////////////////////// HELPERS /////////////////////////////
117
-	////////////////////////////////////////////////////////////////////
118
-
119
-	/**
120
-	 * Parses the name of a field to a tree of fields
121
-	 *
122
-	 * @param string $field The field's name
123
-	 *
124
-	 * @return array A tree of field
125
-	 */
126
-	protected function parseFieldAsArray($field)
127
-	{
128
-		if (Str::contains($field, '[]')) {
129
-			return (array) $field;
130
-		}
131
-
132
-		// Transform array notation to dot notation
133
-		if (Str::contains($field, '[')) {
134
-			$field = preg_replace("/[\[\]]/", '.', $field);
135
-			$field = str_replace('..', '.', $field);
136
-			$field = trim($field, '.');
137
-		}
138
-
139
-		// Parse dot notation
140
-		if (Str::contains($field, '.')) {
141
-			$field = explode('.', $field);
142
-		} else {
143
-			$field = (array) $field;
144
-		}
145
-
146
-		return $field;
147
-	}
148
-
149
-	/**
150
-	 * Get an attribute from a model
151
-	 *
152
-	 * @param object $model     The model
153
-	 * @param string $attribute The attribute's name
154
-	 * @param string $fallback  Fallback value
155
-	 *
156
-	 * @return mixed
157
-	 */
158
-	public function getAttributeFromModel($model, $attribute, $fallback)
159
-	{
160
-		if ($model instanceof Model) {
161
-			// Return fallback if attribute is null
162
-			$value = $model->getAttribute($attribute);
163
-			return is_null($value) ? $fallback : $value;
164
-		}
165
-
166
-		if ($model instanceof Collection) {
167
-			return $model->get($attribute, $fallback);
168
-		}
169
-
170
-		if (is_object($model) && method_exists($model, 'toArray')) {
171
-			$model = $model->toArray();
172
-		} else {
173
-			$model = (array) $model;
174
-		}
175
-		if (array_key_exists($attribute, $model)) {
176
-			return $model[$attribute];
177
-		}
178
-
179
-		return $fallback;
180
-	}
14
+    /**
15
+     * Create a new collection.
16
+     *
17
+     * @param  array|Model $items
18
+     *
19
+     * @return void
20
+     */
21
+    public function __construct($items = array())
22
+    {
23
+        $this->items = $items;
24
+    }
25
+
26
+    ////////////////////////////////////////////////////////////////////
27
+    ///////////////////////// INDIVIDUAL VALUES ////////////////////////
28
+    ////////////////////////////////////////////////////////////////////
29
+
30
+    /**
31
+     * Get the value of a field
32
+     *
33
+     * @param string $field The field's name
34
+     *
35
+     * @return mixed
36
+     */
37
+    public function get($field, $fallback = null)
38
+    {
39
+        // Anonymous fields should not return any value
40
+        if ($field == null) {
41
+            return null;
42
+        }
43
+
44
+        // Plain array
45
+        if (is_array($this->items) and !str_contains($field, '[')) {
46
+            return parent::get($field, $fallback);
47
+        }
48
+
49
+        // Transform the name into an array
50
+        $value = $this->items;
51
+        $field = $this->parseFieldAsArray($field);
52
+
53
+        // Dive into the model
54
+        foreach ($field as $relationship) {
55
+
56
+            // Get attribute from model
57
+            if (!is_array($value)) {
58
+                $value = $this->getAttributeFromModel($value, $relationship, $fallback);
59
+
60
+                continue;
61
+            }
62
+
63
+            // Get attribute from model
64
+            if (array_key_exists($relationship, $value)) {
65
+                $value = $value[$relationship];
66
+            } else {
67
+                // Check array for submodels that may contain the relationship
68
+                $inSubmodel = false;
69
+
70
+                foreach ($value as $key => $submodel) {
71
+                    $value[$key] = $this->getAttributeFromModel($submodel, $relationship, $fallback);
72
+
73
+                    if ($value[$key] !== $fallback) {
74
+                        $inSubmodel = true;
75
+                    }
76
+                }
77
+
78
+                // If no submodels contained the relationship, return the fallback, not an array of fallbacks
79
+                if (!$inSubmodel) {
80
+                    $value = $fallback;
81
+                    break;
82
+                }
83
+            }
84
+        }
85
+
86
+        return $value;
87
+    }
88
+
89
+    ////////////////////////////////////////////////////////////////////
90
+    ///////////////////////////// SWAPPERS /////////////////////////////
91
+    ////////////////////////////////////////////////////////////////////
92
+
93
+    /**
94
+     * Replace the items
95
+     *
96
+     * @param  mixed $items
97
+     *
98
+     * @return void
99
+     */
100
+    public function replace($items)
101
+    {
102
+        $this->items = $items;
103
+    }
104
+
105
+    /**
106
+     * Reset the current values array
107
+     *
108
+     * @return void
109
+     */
110
+    public function reset()
111
+    {
112
+        $this->items = array();
113
+    }
114
+
115
+    ////////////////////////////////////////////////////////////////////
116
+    ////////////////////////////// HELPERS /////////////////////////////
117
+    ////////////////////////////////////////////////////////////////////
118
+
119
+    /**
120
+     * Parses the name of a field to a tree of fields
121
+     *
122
+     * @param string $field The field's name
123
+     *
124
+     * @return array A tree of field
125
+     */
126
+    protected function parseFieldAsArray($field)
127
+    {
128
+        if (Str::contains($field, '[]')) {
129
+            return (array) $field;
130
+        }
131
+
132
+        // Transform array notation to dot notation
133
+        if (Str::contains($field, '[')) {
134
+            $field = preg_replace("/[\[\]]/", '.', $field);
135
+            $field = str_replace('..', '.', $field);
136
+            $field = trim($field, '.');
137
+        }
138
+
139
+        // Parse dot notation
140
+        if (Str::contains($field, '.')) {
141
+            $field = explode('.', $field);
142
+        } else {
143
+            $field = (array) $field;
144
+        }
145
+
146
+        return $field;
147
+    }
148
+
149
+    /**
150
+     * Get an attribute from a model
151
+     *
152
+     * @param object $model     The model
153
+     * @param string $attribute The attribute's name
154
+     * @param string $fallback  Fallback value
155
+     *
156
+     * @return mixed
157
+     */
158
+    public function getAttributeFromModel($model, $attribute, $fallback)
159
+    {
160
+        if ($model instanceof Model) {
161
+            // Return fallback if attribute is null
162
+            $value = $model->getAttribute($attribute);
163
+            return is_null($value) ? $fallback : $value;
164
+        }
165
+
166
+        if ($model instanceof Collection) {
167
+            return $model->get($attribute, $fallback);
168
+        }
169
+
170
+        if (is_object($model) && method_exists($model, 'toArray')) {
171
+            $model = $model->toArray();
172
+        } else {
173
+            $model = (array) $model;
174
+        }
175
+        if (array_key_exists($attribute, $model)) {
176
+            return $model[$attribute];
177
+        }
178
+
179
+        return $fallback;
180
+    }
181 181
 }
Please login to merge, or discard this patch.
src/Laravel/File.php 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -7,128 +7,128 @@
 block discarded – undo
7 7
 
8 8
 class File
9 9
 {
10
-	private static $mimes = array(
11
-		'ai'    => 'application/postscript',
12
-		'aif'   => 'audio/x-aiff',
13
-		'aifc'  => 'audio/x-aiff',
14
-		'aiff'  => 'audio/x-aiff',
15
-		'avi'   => 'video/x-msvideo',
16
-		'bin'   => 'application/macbinary',
17
-		'bmp'   => 'image/bmp',
18
-		'class' => 'application/octet-stream',
19
-		'cpt'   => 'application/mac-compactpro',
20
-		'css'   => 'text/css',
21
-		'csv'   => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream'),
22
-		'dcr'   => 'application/x-director',
23
-		'dir'   => 'application/x-director',
24
-		'dll'   => 'application/octet-stream',
25
-		'dms'   => 'application/octet-stream',
26
-		'doc'   => 'application/msword',
27
-		'docx'  => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
28
-		'dvi'   => 'application/x-dvi',
29
-		'dxr'   => 'application/x-director',
30
-		'eml'   => 'message/rfc822',
31
-		'eps'   => 'application/postscript',
32
-		'exe'   => array('application/octet-stream', 'application/x-msdownload'),
33
-		'gif'   => 'image/gif',
34
-		'gtar'  => 'application/x-gtar',
35
-		'gz'    => 'application/x-gzip',
36
-		'hqx'   => 'application/mac-binhex40',
37
-		'htm'   => 'text/html',
38
-		'html'  => 'text/html',
39
-		'jpe'   => array('image/jpeg', 'image/pjpeg'),
40
-		'jpeg'  => array('image/jpeg', 'image/pjpeg'),
41
-		'jpg'   => array('image/jpeg', 'image/pjpeg'),
42
-		'js'    => 'application/x-javascript',
43
-		'json'  => array('application/json', 'text/json'),
44
-		'lha'   => 'application/octet-stream',
45
-		'log'   => array('text/plain', 'text/x-log'),
46
-		'lzh'   => 'application/octet-stream',
47
-		'mid'   => 'audio/midi',
48
-		'midi'  => 'audio/midi',
49
-		'mif'   => 'application/vnd.mif',
50
-		'mov'   => 'video/quicktime',
51
-		'movie' => 'video/x-sgi-movie',
52
-		'mp2'   => 'audio/mpeg',
53
-		'mp3'   => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
54
-		'mpe'   => 'video/mpeg',
55
-		'mpeg'  => 'video/mpeg',
56
-		'mpg'   => 'video/mpeg',
57
-		'mpga'  => 'audio/mpeg',
58
-		'oda'   => 'application/oda',
59
-		'odp'   => 'application/vnd.oasis.opendocument.presentation',
60
-		'ods'   => 'application/vnd.oasis.opendocument.spreadsheet',
61
-		'odt'   => 'application/vnd.oasis.opendocument.text',
62
-		'pdf'   => array('application/pdf', 'application/x-download'),
63
-		'php'   => array('application/x-httpd-php', 'text/x-php'),
64
-		'php3'  => 'application/x-httpd-php',
65
-		'php4'  => 'application/x-httpd-php',
66
-		'phps'  => 'application/x-httpd-php-source',
67
-		'phtml' => 'application/x-httpd-php',
68
-		'png'   => 'image/png',
69
-		'pps'   => array('application/mspowerpoint', 'application/vnd.ms-powerpoint'),
70
-		'ppsx'  => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
71
-		'ppt'   => array('application/vnd.ms-powerpoint', 'application/powerpoint'),
72
-		'pptx'  => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
73
-		'ps'    => 'application/postscript',
74
-		'psd'   => 'application/x-photoshop',
75
-		'qt'    => 'video/quicktime',
76
-		'ra'    => 'audio/x-realaudio',
77
-		'ram'   => 'audio/x-pn-realaudio',
78
-		'rm'    => 'audio/x-pn-realaudio',
79
-		'rpm'   => 'audio/x-pn-realaudio-plugin',
80
-		'rtf'   => array('application/rtf', 'text/rtf'),
81
-		'rtx'   => 'text/richtext',
82
-		'rv'    => 'video/vnd.rn-realvideo',
83
-		'sea'   => 'application/octet-stream',
84
-		'shtml' => 'text/html',
85
-		'sit'   => 'application/x-stuffit',
86
-		'smi'   => 'application/smil',
87
-		'smil'  => 'application/smil',
88
-		'so'    => 'application/octet-stream',
89
-		'swf'   => 'application/x-shockwave-flash',
90
-		'tar'   => 'application/x-tar',
91
-		'text'  => 'text/plain',
92
-		'tgz'   => array('application/x-tar', 'application/x-gzip-compressed'),
93
-		'tif'   => 'image/tiff',
94
-		'tiff'  => 'image/tiff',
95
-		'txt'   => 'text/plain',
96
-		'wav'   => 'audio/x-wav',
97
-		'wbxml' => 'application/wbxml',
98
-		'wmlc'  => 'application/wmlc',
99
-		'word'  => array('application/msword', 'application/octet-stream'),
100
-		'xht'   => 'application/xhtml+xml',
101
-		'xhtml' => 'application/xhtml+xml',
102
-		'xl'    => 'application/excel',
103
-		'xls'   => array('application/vnd.ms-excel', 'application/excel', 'application/msexcel'),
104
-		'xlsx'  => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
105
-		'xml'   => 'text/xml',
106
-		'xsl'   => 'text/xml',
107
-		'zip'   => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
108
-	);
10
+    private static $mimes = array(
11
+        'ai'    => 'application/postscript',
12
+        'aif'   => 'audio/x-aiff',
13
+        'aifc'  => 'audio/x-aiff',
14
+        'aiff'  => 'audio/x-aiff',
15
+        'avi'   => 'video/x-msvideo',
16
+        'bin'   => 'application/macbinary',
17
+        'bmp'   => 'image/bmp',
18
+        'class' => 'application/octet-stream',
19
+        'cpt'   => 'application/mac-compactpro',
20
+        'css'   => 'text/css',
21
+        'csv'   => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream'),
22
+        'dcr'   => 'application/x-director',
23
+        'dir'   => 'application/x-director',
24
+        'dll'   => 'application/octet-stream',
25
+        'dms'   => 'application/octet-stream',
26
+        'doc'   => 'application/msword',
27
+        'docx'  => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
28
+        'dvi'   => 'application/x-dvi',
29
+        'dxr'   => 'application/x-director',
30
+        'eml'   => 'message/rfc822',
31
+        'eps'   => 'application/postscript',
32
+        'exe'   => array('application/octet-stream', 'application/x-msdownload'),
33
+        'gif'   => 'image/gif',
34
+        'gtar'  => 'application/x-gtar',
35
+        'gz'    => 'application/x-gzip',
36
+        'hqx'   => 'application/mac-binhex40',
37
+        'htm'   => 'text/html',
38
+        'html'  => 'text/html',
39
+        'jpe'   => array('image/jpeg', 'image/pjpeg'),
40
+        'jpeg'  => array('image/jpeg', 'image/pjpeg'),
41
+        'jpg'   => array('image/jpeg', 'image/pjpeg'),
42
+        'js'    => 'application/x-javascript',
43
+        'json'  => array('application/json', 'text/json'),
44
+        'lha'   => 'application/octet-stream',
45
+        'log'   => array('text/plain', 'text/x-log'),
46
+        'lzh'   => 'application/octet-stream',
47
+        'mid'   => 'audio/midi',
48
+        'midi'  => 'audio/midi',
49
+        'mif'   => 'application/vnd.mif',
50
+        'mov'   => 'video/quicktime',
51
+        'movie' => 'video/x-sgi-movie',
52
+        'mp2'   => 'audio/mpeg',
53
+        'mp3'   => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
54
+        'mpe'   => 'video/mpeg',
55
+        'mpeg'  => 'video/mpeg',
56
+        'mpg'   => 'video/mpeg',
57
+        'mpga'  => 'audio/mpeg',
58
+        'oda'   => 'application/oda',
59
+        'odp'   => 'application/vnd.oasis.opendocument.presentation',
60
+        'ods'   => 'application/vnd.oasis.opendocument.spreadsheet',
61
+        'odt'   => 'application/vnd.oasis.opendocument.text',
62
+        'pdf'   => array('application/pdf', 'application/x-download'),
63
+        'php'   => array('application/x-httpd-php', 'text/x-php'),
64
+        'php3'  => 'application/x-httpd-php',
65
+        'php4'  => 'application/x-httpd-php',
66
+        'phps'  => 'application/x-httpd-php-source',
67
+        'phtml' => 'application/x-httpd-php',
68
+        'png'   => 'image/png',
69
+        'pps'   => array('application/mspowerpoint', 'application/vnd.ms-powerpoint'),
70
+        'ppsx'  => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
71
+        'ppt'   => array('application/vnd.ms-powerpoint', 'application/powerpoint'),
72
+        'pptx'  => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
73
+        'ps'    => 'application/postscript',
74
+        'psd'   => 'application/x-photoshop',
75
+        'qt'    => 'video/quicktime',
76
+        'ra'    => 'audio/x-realaudio',
77
+        'ram'   => 'audio/x-pn-realaudio',
78
+        'rm'    => 'audio/x-pn-realaudio',
79
+        'rpm'   => 'audio/x-pn-realaudio-plugin',
80
+        'rtf'   => array('application/rtf', 'text/rtf'),
81
+        'rtx'   => 'text/richtext',
82
+        'rv'    => 'video/vnd.rn-realvideo',
83
+        'sea'   => 'application/octet-stream',
84
+        'shtml' => 'text/html',
85
+        'sit'   => 'application/x-stuffit',
86
+        'smi'   => 'application/smil',
87
+        'smil'  => 'application/smil',
88
+        'so'    => 'application/octet-stream',
89
+        'swf'   => 'application/x-shockwave-flash',
90
+        'tar'   => 'application/x-tar',
91
+        'text'  => 'text/plain',
92
+        'tgz'   => array('application/x-tar', 'application/x-gzip-compressed'),
93
+        'tif'   => 'image/tiff',
94
+        'tiff'  => 'image/tiff',
95
+        'txt'   => 'text/plain',
96
+        'wav'   => 'audio/x-wav',
97
+        'wbxml' => 'application/wbxml',
98
+        'wmlc'  => 'application/wmlc',
99
+        'word'  => array('application/msword', 'application/octet-stream'),
100
+        'xht'   => 'application/xhtml+xml',
101
+        'xhtml' => 'application/xhtml+xml',
102
+        'xl'    => 'application/excel',
103
+        'xls'   => array('application/vnd.ms-excel', 'application/excel', 'application/msexcel'),
104
+        'xlsx'  => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
105
+        'xml'   => 'text/xml',
106
+        'xsl'   => 'text/xml',
107
+        'zip'   => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
108
+    );
109 109
 
110
-	/**
111
-	 * Get a file MIME type by extension.
112
-	 * <code>
113
-	 *    // Determine the MIME type for the .tar extension
114
-	 *    $mime = File::mime('tar');
115
-	 *    // Return a default value if the MIME can't be determined
116
-	 *    $mime = File::mime('ext', 'application/octet-stream');
117
-	 * </code>
118
-	 *
119
-	 * @param  string $extension
120
-	 * @param  string $default
121
-	 *
122
-	 * @return string
123
-	 */
124
-	public static function mime($extension, $default = 'application/octet-stream')
125
-	{
126
-		$mimes = self::$mimes;
110
+    /**
111
+     * Get a file MIME type by extension.
112
+     * <code>
113
+     *    // Determine the MIME type for the .tar extension
114
+     *    $mime = File::mime('tar');
115
+     *    // Return a default value if the MIME can't be determined
116
+     *    $mime = File::mime('ext', 'application/octet-stream');
117
+     * </code>
118
+     *
119
+     * @param  string $extension
120
+     * @param  string $default
121
+     *
122
+     * @return string
123
+     */
124
+    public static function mime($extension, $default = 'application/octet-stream')
125
+    {
126
+        $mimes = self::$mimes;
127 127
 
128
-		if (!array_key_exists($extension, $mimes)) {
129
-			return $default;
130
-		}
128
+        if (!array_key_exists($extension, $mimes)) {
129
+            return $default;
130
+        }
131 131
 
132
-		return (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];
133
-	}
132
+        return (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];
133
+    }
134 134
 }
Please login to merge, or discard this patch.
src/config/former.php 1 patch
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -1,184 +1,184 @@
 block discarded – undo
1 1
 <?php return array(
2 2
 
3
-	// Markup
4
-	////////////////////////////////////////////////////////////////////
5
-
6
-	// Whether labels should be automatically computed from name
7
-	'automatic_label'         => true,
8
-
9
-	// The default form type
10
-	'default_form_type'       => 'horizontal',
11
-
12
-	// Validation
13
-	////////////////////////////////////////////////////////////////////
14
-
15
-	// Whether Former should fetch errors from Session
16
-	'fetch_errors'            => true,
17
-
18
-	// Whether Former should try to apply Validator rules as attributes
19
-	'live_validation'         => true,
20
-
21
-	// Whether Former should automatically fetch error messages and
22
-	// display them next to the matching fields
23
-	'error_messages'          => true,
24
-
25
-	// Checkables
26
-	////////////////////////////////////////////////////////////////////
27
-
28
-	// Whether checkboxes should always be present in the POST data,
29
-	// no matter if you checked them or not
30
-	'push_checkboxes'         => false,
31
-
32
-	// The value a checkbox will have in the POST array if unchecked
33
-	'unchecked_value'         => 0,
34
-
35
-	// Required fields
36
-	////////////////////////////////////////////////////////////////////
37
-
38
-	// The class to be added to required fields
39
-	'required_class'          => 'required',
40
-
41
-	// A facultative text to append to the labels of required fields
42
-	'required_text'           => '<sup>*</sup>',
43
-
44
-	// Translations
45
-	////////////////////////////////////////////////////////////////////
46
-
47
-	// Where Former should look for translations
48
-	'translate_from'          => 'validation.attributes',
49
-
50
-	// Whether text that comes out of the translated
51
-	// should be capitalized (ex: email => Email) automatically
52
-	'capitalize_translations' => true,
53
-
54
-	// An array of attributes to automatically translate
55
-	'translatable'            => array(
56
-		'help',
57
-		'inlineHelp',
58
-		'blockHelp',
59
-		'placeholder',
60
-		'data_placeholder',
61
-		'label',
62
-	),
63
-
64
-	// Framework
65
-	////////////////////////////////////////////////////////////////////
66
-
67
-	// The framework to be used by Former
68
-	'framework'               => 'TwitterBootstrap3',
69
-
70
-	'TwitterBootstrap3'       => array(
71
-
72
-		// Map Former-supported viewports to Bootstrap 3 equivalents
73
-		'viewports'   => array(
74
-			'large'  => 'lg',
75
-			'medium' => 'md',
76
-			'small'  => 'sm',
77
-			'mini'   => 'xs',
78
-		),
79
-		// Width of labels for horizontal forms expressed as viewport => grid columns
80
-		'labelWidths' => array(
81
-			'large' => 2,
82
-			'small' => 4,
83
-		),
84
-		// HTML markup and classes used by Bootstrap 3 for icons
85
-		'icon'        => array(
86
-			'tag'    => 'span',
87
-			'set'    => 'glyphicon',
88
-			'prefix' => 'glyphicon',
89
-		),
90
-
91
-	),
92
-
93
-	'Nude'                    => array(  // No-framework markup
94
-		'icon' => array(
95
-			'tag'    => 'i',
96
-			'set'    => null,
97
-			'prefix' => 'icon',
98
-		),
99
-	),
100
-
101
-	'TwitterBootstrap'        => array( // Twitter Bootstrap version 2
102
-		'icon' => array(
103
-			'tag'    => 'i',
104
-			'set'    => null,
105
-			'prefix' => 'icon',
106
-		),
107
-	),
108
-
109
-	'ZurbFoundation5'         => array(
110
-		// Map Former-supported viewports to Foundation 5 equivalents
111
-		'viewports'           => array(
112
-			'large'  => 'large',
113
-			'medium' => null,
114
-			'small'  => 'small',
115
-			'mini'   => null,
116
-		),
117
-		// Width of labels for horizontal forms expressed as viewport => grid columns
118
-		'labelWidths'         => array(
119
-			'small' => 3,
120
-		),
121
-		// Classes to be applied to wrapped labels in horizontal forms
122
-		'wrappedLabelClasses' => array('right', 'inline'),
123
-		// HTML markup and classes used by Foundation 5 for icons
124
-		'icon'                => array(
125
-			'tag'    => 'i',
126
-			'set'    => null,
127
-			'prefix' => 'fi',
128
-		),
129
-		// CSS for inline validation errors
130
-		'error_classes'       => array('class' => 'error'),
131
-	),
132
-
133
-	'ZurbFoundation4'         => array(
134
-		// Foundation 4 also has an experimental "medium" breakpoint
135
-		// explained at http://foundation.zurb.com/docs/components/grid.html
136
-		'viewports'           => array(
137
-			'large'  => 'large',
138
-			'medium' => null,
139
-			'small'  => 'small',
140
-			'mini'   => null,
141
-		),
142
-		// Width of labels for horizontal forms expressed as viewport => grid columns
143
-		'labelWidths'         => array(
144
-			'small' => 3,
145
-		),
146
-		// Classes to be applied to wrapped labels in horizontal forms
147
-		'wrappedLabelClasses' => array('right', 'inline'),
148
-		// HTML markup and classes used by Foundation 4 for icons
149
-		'icon'                => array(
150
-			'tag'    => 'i',
151
-			'set'    => 'general',
152
-			'prefix' => 'foundicon',
153
-		),
154
-		// CSS for inline validation errors
155
-		'error_classes'       => array('class' => 'alert-box radius warning'),
156
-	),
157
-
158
-	'ZurbFoundation'          => array( // Foundation 3
159
-		'viewports'           => array(
160
-			'large'  => '',
161
-			'medium' => null,
162
-			'small'  => 'mobile-',
163
-			'mini'   => null,
164
-		),
165
-		// Width of labels for horizontal forms expressed as viewport => grid columns
166
-		'labelWidths'         => array(
167
-			'large' => 2,
168
-			'small' => 4,
169
-		),
170
-		// Classes to be applied to wrapped labels in horizontal forms
171
-		'wrappedLabelClasses' => array('right', 'inline'),
172
-		// HTML markup and classes used by Foundation 3 for icons
173
-		'icon'                => array(
174
-			'tag'    => 'i',
175
-			'set'    => null,
176
-			'prefix' => 'fi',
177
-		),
178
-		// CSS for inline validation errors
179
-		// should work for Zurb 2 and 3
180
-		'error_classes'       => array('class' => 'alert-box alert error'),
181
-	),
3
+    // Markup
4
+    ////////////////////////////////////////////////////////////////////
5
+
6
+    // Whether labels should be automatically computed from name
7
+    'automatic_label'         => true,
8
+
9
+    // The default form type
10
+    'default_form_type'       => 'horizontal',
11
+
12
+    // Validation
13
+    ////////////////////////////////////////////////////////////////////
14
+
15
+    // Whether Former should fetch errors from Session
16
+    'fetch_errors'            => true,
17
+
18
+    // Whether Former should try to apply Validator rules as attributes
19
+    'live_validation'         => true,
20
+
21
+    // Whether Former should automatically fetch error messages and
22
+    // display them next to the matching fields
23
+    'error_messages'          => true,
24
+
25
+    // Checkables
26
+    ////////////////////////////////////////////////////////////////////
27
+
28
+    // Whether checkboxes should always be present in the POST data,
29
+    // no matter if you checked them or not
30
+    'push_checkboxes'         => false,
31
+
32
+    // The value a checkbox will have in the POST array if unchecked
33
+    'unchecked_value'         => 0,
34
+
35
+    // Required fields
36
+    ////////////////////////////////////////////////////////////////////
37
+
38
+    // The class to be added to required fields
39
+    'required_class'          => 'required',
40
+
41
+    // A facultative text to append to the labels of required fields
42
+    'required_text'           => '<sup>*</sup>',
43
+
44
+    // Translations
45
+    ////////////////////////////////////////////////////////////////////
46
+
47
+    // Where Former should look for translations
48
+    'translate_from'          => 'validation.attributes',
49
+
50
+    // Whether text that comes out of the translated
51
+    // should be capitalized (ex: email => Email) automatically
52
+    'capitalize_translations' => true,
53
+
54
+    // An array of attributes to automatically translate
55
+    'translatable'            => array(
56
+        'help',
57
+        'inlineHelp',
58
+        'blockHelp',
59
+        'placeholder',
60
+        'data_placeholder',
61
+        'label',
62
+    ),
63
+
64
+    // Framework
65
+    ////////////////////////////////////////////////////////////////////
66
+
67
+    // The framework to be used by Former
68
+    'framework'               => 'TwitterBootstrap3',
69
+
70
+    'TwitterBootstrap3'       => array(
71
+
72
+        // Map Former-supported viewports to Bootstrap 3 equivalents
73
+        'viewports'   => array(
74
+            'large'  => 'lg',
75
+            'medium' => 'md',
76
+            'small'  => 'sm',
77
+            'mini'   => 'xs',
78
+        ),
79
+        // Width of labels for horizontal forms expressed as viewport => grid columns
80
+        'labelWidths' => array(
81
+            'large' => 2,
82
+            'small' => 4,
83
+        ),
84
+        // HTML markup and classes used by Bootstrap 3 for icons
85
+        'icon'        => array(
86
+            'tag'    => 'span',
87
+            'set'    => 'glyphicon',
88
+            'prefix' => 'glyphicon',
89
+        ),
90
+
91
+    ),
92
+
93
+    'Nude'                    => array(  // No-framework markup
94
+        'icon' => array(
95
+            'tag'    => 'i',
96
+            'set'    => null,
97
+            'prefix' => 'icon',
98
+        ),
99
+    ),
100
+
101
+    'TwitterBootstrap'        => array( // Twitter Bootstrap version 2
102
+        'icon' => array(
103
+            'tag'    => 'i',
104
+            'set'    => null,
105
+            'prefix' => 'icon',
106
+        ),
107
+    ),
108
+
109
+    'ZurbFoundation5'         => array(
110
+        // Map Former-supported viewports to Foundation 5 equivalents
111
+        'viewports'           => array(
112
+            'large'  => 'large',
113
+            'medium' => null,
114
+            'small'  => 'small',
115
+            'mini'   => null,
116
+        ),
117
+        // Width of labels for horizontal forms expressed as viewport => grid columns
118
+        'labelWidths'         => array(
119
+            'small' => 3,
120
+        ),
121
+        // Classes to be applied to wrapped labels in horizontal forms
122
+        'wrappedLabelClasses' => array('right', 'inline'),
123
+        // HTML markup and classes used by Foundation 5 for icons
124
+        'icon'                => array(
125
+            'tag'    => 'i',
126
+            'set'    => null,
127
+            'prefix' => 'fi',
128
+        ),
129
+        // CSS for inline validation errors
130
+        'error_classes'       => array('class' => 'error'),
131
+    ),
132
+
133
+    'ZurbFoundation4'         => array(
134
+        // Foundation 4 also has an experimental "medium" breakpoint
135
+        // explained at http://foundation.zurb.com/docs/components/grid.html
136
+        'viewports'           => array(
137
+            'large'  => 'large',
138
+            'medium' => null,
139
+            'small'  => 'small',
140
+            'mini'   => null,
141
+        ),
142
+        // Width of labels for horizontal forms expressed as viewport => grid columns
143
+        'labelWidths'         => array(
144
+            'small' => 3,
145
+        ),
146
+        // Classes to be applied to wrapped labels in horizontal forms
147
+        'wrappedLabelClasses' => array('right', 'inline'),
148
+        // HTML markup and classes used by Foundation 4 for icons
149
+        'icon'                => array(
150
+            'tag'    => 'i',
151
+            'set'    => 'general',
152
+            'prefix' => 'foundicon',
153
+        ),
154
+        // CSS for inline validation errors
155
+        'error_classes'       => array('class' => 'alert-box radius warning'),
156
+    ),
157
+
158
+    'ZurbFoundation'          => array( // Foundation 3
159
+        'viewports'           => array(
160
+            'large'  => '',
161
+            'medium' => null,
162
+            'small'  => 'mobile-',
163
+            'mini'   => null,
164
+        ),
165
+        // Width of labels for horizontal forms expressed as viewport => grid columns
166
+        'labelWidths'         => array(
167
+            'large' => 2,
168
+            'small' => 4,
169
+        ),
170
+        // Classes to be applied to wrapped labels in horizontal forms
171
+        'wrappedLabelClasses' => array('right', 'inline'),
172
+        // HTML markup and classes used by Foundation 3 for icons
173
+        'icon'                => array(
174
+            'tag'    => 'i',
175
+            'set'    => null,
176
+            'prefix' => 'fi',
177
+        ),
178
+        // CSS for inline validation errors
179
+        // should work for Zurb 2 and 3
180
+        'error_classes'       => array('class' => 'alert-box alert error'),
181
+    ),
182 182
 
183 183
 
184 184
 );
Please login to merge, or discard this patch.