Passed
Branchmaster (a7791e)
by Laurent
02:57
created
programs/customfield.class.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -47,78 +47,78 @@  discard block
 block discarded – undo
47 47
     /**
48 48
      * @param Func_App $App
49 49
      */
50
-	public function __construct(Func_App $App = null)
51
-	{
52
-		parent::__construct($App);
53
-
54
-		$this->setDescription('Custom field');
55
-
56
-		$this->setPrimaryKey('id');
57
-
58
-		$this->addFields(
59
-			ORM_StringField('name')
60
-				->setDescription('Name of field used for display'),
61
-			ORM_StringField('fieldname')
62
-				->setDescription('Name of field used in table, not modifiable'),
63
-			ORM_TextField('description')
64
-				->setDescription('Optional description'),
65
-			ORM_EnumField('object', $this->getObjects())
66
-				->setDescription('Name of object in App ex : Article, Contact, Organization...'),
67
-			ORM_EnumField('fieldtype', $this->getFieldTypes())
68
-				->setDescription('Name of ORM field ex : Enum, String, Text, Bool...'),
69
-			ORM_TextField('enumvalues')
70
-				->setDescription('serialized array of values for enum fields'),
71
-			ORM_BoolField('mandatory')
72
-				->setDescription('Mandatory')
73
-		);
74
-
75
-		if ($App->onlineShop) {
76
-			$this->addFields(
77
-				ORM_BoolField('visible_in_shop')
78
-			);
79
-		}
80
-	}
81
-
82
-
83
-
84
-	/**
85
-	 * List of objects where custom fields are applicable.
86
-	 *
87
-	 * @return string[]
88
-	 */
89
-	public function getObjects()
90
-	{
91
-		$App = $this->App();
92
-
93
-		$arr = array();
94
-
95
-		if (isset($App->Article)) {
96
-			$arr['Article'] = $App->translate('Products database');
97
-		}
98
-
99
-		return $arr;
100
-	}
101
-
102
-	/**
103
-	 * list of ORM fields to use for a custom field
104
-	 */
105
-	public function getFieldTypes()
106
-	{
107
-		$App = $this->App();
108
-
109
-		return array(
110
-			'String' 	=> $App->translate('Line edit'),
111
-			'Text'		=> $App->translate('Text edit'),
112
-			'Bool'		=> $App->translate('Checkbox'),
113
-			'Int'		=> $App->translate('Integer number'),
114
-			'Decimal'	=> $App->translate('Decimal number'),
115
-			'Date'		=> $App->translate('Date'),
116
-			'DateTime'	=> $App->translate('Date and time'),
117
-			'Enum' 		=> $App->translate('Selection list'),
118
-			'Url' 		=> $App->translate('Url'),
119
-			'Email' 	=> $App->translate('Email address'),
120
-		);
121
-	}
50
+    public function __construct(Func_App $App = null)
51
+    {
52
+        parent::__construct($App);
53
+
54
+        $this->setDescription('Custom field');
55
+
56
+        $this->setPrimaryKey('id');
57
+
58
+        $this->addFields(
59
+            ORM_StringField('name')
60
+                ->setDescription('Name of field used for display'),
61
+            ORM_StringField('fieldname')
62
+                ->setDescription('Name of field used in table, not modifiable'),
63
+            ORM_TextField('description')
64
+                ->setDescription('Optional description'),
65
+            ORM_EnumField('object', $this->getObjects())
66
+                ->setDescription('Name of object in App ex : Article, Contact, Organization...'),
67
+            ORM_EnumField('fieldtype', $this->getFieldTypes())
68
+                ->setDescription('Name of ORM field ex : Enum, String, Text, Bool...'),
69
+            ORM_TextField('enumvalues')
70
+                ->setDescription('serialized array of values for enum fields'),
71
+            ORM_BoolField('mandatory')
72
+                ->setDescription('Mandatory')
73
+        );
74
+
75
+        if ($App->onlineShop) {
76
+            $this->addFields(
77
+                ORM_BoolField('visible_in_shop')
78
+            );
79
+        }
80
+    }
81
+
82
+
83
+
84
+    /**
85
+     * List of objects where custom fields are applicable.
86
+     *
87
+     * @return string[]
88
+     */
89
+    public function getObjects()
90
+    {
91
+        $App = $this->App();
92
+
93
+        $arr = array();
94
+
95
+        if (isset($App->Article)) {
96
+            $arr['Article'] = $App->translate('Products database');
97
+        }
98
+
99
+        return $arr;
100
+    }
101
+
102
+    /**
103
+     * list of ORM fields to use for a custom field
104
+     */
105
+    public function getFieldTypes()
106
+    {
107
+        $App = $this->App();
108
+
109
+        return array(
110
+            'String' 	=> $App->translate('Line edit'),
111
+            'Text'		=> $App->translate('Text edit'),
112
+            'Bool'		=> $App->translate('Checkbox'),
113
+            'Int'		=> $App->translate('Integer number'),
114
+            'Decimal'	=> $App->translate('Decimal number'),
115
+            'Date'		=> $App->translate('Date'),
116
+            'DateTime'	=> $App->translate('Date and time'),
117
+            'Enum' 		=> $App->translate('Selection list'),
118
+            'Url' 		=> $App->translate('Url'),
119
+            'Email' 	=> $App->translate('Email address'),
120
+        );
121
+    }
122 122
 
123 123
     /**
124 124
      * @return ORM_Criteria
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             case 'Bool':
184 184
                 $field = ORM_BoolField($this->fieldname);
185 185
                 $field->setOutputOptions(
186
-                       $this->App()->translate('No'),
186
+                        $this->App()->translate('No'),
187 187
                     $this->App()->translate('Yes')
188 188
                 );
189 189
                 break;
@@ -200,80 +200,80 @@  discard block
 block discarded – undo
200 200
     }
201 201
 
202 202
 
203
-	/**
204
-	 * @return string[]
205
-	 */
206
-	public function getEnumValues()
207
-	{
208
-	    return unserialize($this->enumvalues);
209
-	}
210
-
211
-
212
-	/**
213
-	 * @return Widget_LabelledWidget
214
-	 */
215
-	public function getWidget()
216
-	{
217
-		$W = bab_Widgets();
218
-		$App = $this->App();
219
-
220
-		switch ($this->fieldtype) {
221
-			case 'Text':
222
-				$widget = $W->TextEdit()->setLines(3)->setColumns(70);
223
-				break;
224
-
225
-			case 'Bool':
226
-				$widget = $W->Checkbox();
227
-				break;
228
-
229
-			case 'Enum':
230
-				$options = array('' => '') + $this->getEnumValues();
231
-				$widget = $W->Select()->setOptions($options);
232
-				break;
233
-
234
-			case 'Date':
235
-				$widget = $W->DatePicker();
236
-				break;
237
-
238
-			case 'DateTime':
239
-				$widget = $W->DateTimePicker();
240
-				break;
241
-
242
-			case 'Int':
243
-				$widget = $W->RegExpLineEdit();
244
-				$widget->setRegExp(Widget_RegExpLineEdit::INT_FORMAT)
245
-					->setSubmitMessage(sprintf($App->translate('The field %s should be a integer number'), $this->name))
246
-					->setSize(10);
247
-				break;
248
-
249
-			case 'Decimal':
250
-				$widget = $W->RegExpLineEdit();
251
-				$widget->setRegExp(Widget_RegExpLineEdit::FLOAT_FORMAT)
252
-					->setSubmitMessage(sprintf($App->translate('The field %s should be a decimal number'), $this->name))
253
-					->setSize(10);
254
-				break;
255
-
256
-			case 'Url':
257
-				$widget = $W->UrlLineEdit();
258
-				break;
259
-
260
-			case 'Email':
261
-				$widget = $W->EmailLineEdit();
262
-				break;
263
-
264
-			default:
265
-			case 'String':
266
-				$widget = $W->LineEdit()->setSize(70)->setMaxSize(255);
267
-				break;
268
-		}
269
-
270
-		$labelledItem = $W->LabelledWidget($this->name, $widget, null);
271
-		$labelledItem->setName($this->fieldname);
272
-
273
-		if (!empty($this->description)) {
274
-			$labelledItem->setDescription($this->description);
275
-		}
276
-
277
-		return $labelledItem;
278
-	}
203
+    /**
204
+     * @return string[]
205
+     */
206
+    public function getEnumValues()
207
+    {
208
+        return unserialize($this->enumvalues);
209
+    }
210
+
211
+
212
+    /**
213
+     * @return Widget_LabelledWidget
214
+     */
215
+    public function getWidget()
216
+    {
217
+        $W = bab_Widgets();
218
+        $App = $this->App();
219
+
220
+        switch ($this->fieldtype) {
221
+            case 'Text':
222
+                $widget = $W->TextEdit()->setLines(3)->setColumns(70);
223
+                break;
224
+
225
+            case 'Bool':
226
+                $widget = $W->Checkbox();
227
+                break;
228
+
229
+            case 'Enum':
230
+                $options = array('' => '') + $this->getEnumValues();
231
+                $widget = $W->Select()->setOptions($options);
232
+                break;
233
+
234
+            case 'Date':
235
+                $widget = $W->DatePicker();
236
+                break;
237
+
238
+            case 'DateTime':
239
+                $widget = $W->DateTimePicker();
240
+                break;
241
+
242
+            case 'Int':
243
+                $widget = $W->RegExpLineEdit();
244
+                $widget->setRegExp(Widget_RegExpLineEdit::INT_FORMAT)
245
+                    ->setSubmitMessage(sprintf($App->translate('The field %s should be a integer number'), $this->name))
246
+                    ->setSize(10);
247
+                break;
248
+
249
+            case 'Decimal':
250
+                $widget = $W->RegExpLineEdit();
251
+                $widget->setRegExp(Widget_RegExpLineEdit::FLOAT_FORMAT)
252
+                    ->setSubmitMessage(sprintf($App->translate('The field %s should be a decimal number'), $this->name))
253
+                    ->setSize(10);
254
+                break;
255
+
256
+            case 'Url':
257
+                $widget = $W->UrlLineEdit();
258
+                break;
259
+
260
+            case 'Email':
261
+                $widget = $W->EmailLineEdit();
262
+                break;
263
+
264
+            default:
265
+            case 'String':
266
+                $widget = $W->LineEdit()->setSize(70)->setMaxSize(255);
267
+                break;
268
+        }
269
+
270
+        $labelledItem = $W->LabelledWidget($this->name, $widget, null);
271
+        $labelledItem->setName($this->fieldname);
272
+
273
+        if (!empty($this->description)) {
274
+            $labelledItem->setDescription($this->description);
275
+        }
276
+
277
+        return $labelledItem;
278
+    }
279 279
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@
 block discarded – undo
189 189
                 break;
190 190
 
191 191
             default:
192
-                $function = 'ORM_'.$this->fieldtype.'Field';
192
+                $function = 'ORM_' . $this->fieldtype . 'Field';
193 193
                 $field = $function($this->fieldname);
194 194
                 break;
195 195
         }
Please login to merge, or discard this patch.
programs/customfield.ctrl.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 
95 95
 
96 96
 
97
-	/**
98
-	 * @return Widget_Page
99
-	 */
100
-	public function edit($customfield = null)
101
-	{
102
-		$W = bab_Widgets();
103
-		$App = $this->App();
97
+    /**
98
+     * @return Widget_Page
99
+     */
100
+    public function edit($customfield = null)
101
+    {
102
+        $W = bab_Widgets();
103
+        $App = $this->App();
104 104
 // 		$access = $Crm->Access();
105 105
 
106 106
 // 		if (!$access->viewShopAdmin()) {
@@ -109,134 +109,134 @@  discard block
 block discarded – undo
109 109
 
110 110
 // 		crm_BreadCrumbs::setCurrentPosition($this->proxy()->edit($customfield), $Crm->translate('Edit custom field'));
111 111
 
112
-		/* @var $Ui app_Ui */
113
-		$Ui = $App->Ui();
114
-		$page = $Ui->Page();
112
+        /* @var $Ui app_Ui */
113
+        $Ui = $App->Ui();
114
+        $page = $Ui->Page();
115 115
 
116
-		$page->addClass('app-page-editor');
117
-		$page->setTitle($App->translate('Edit custom field'));
116
+        $page->addClass('app-page-editor');
117
+        $page->setTitle($App->translate('Edit custom field'));
118 118
 
119
-		if (null !== $customfield) {
120
-		    $set = $App->CustomFieldSet();
121
-			$customfield = $set->request($customfield);
122
-		}
119
+        if (null !== $customfield) {
120
+            $set = $App->CustomFieldSet();
121
+            $customfield = $set->request($customfield);
122
+        }
123 123
 
124 124
 
125 125
 
126
-		$form = $Ui->CustomFieldEditor($customfield);
126
+        $form = $Ui->CustomFieldEditor($customfield);
127 127
 
128
-		$page->addItem($form);
128
+        $page->addItem($form);
129 129
 
130
-		if ($customfield instanceof app_CustomField) {
131
-			$actionsFrame = $page->ActionsFrame();
132
-			$page->addContextItem($actionsFrame);
130
+        if ($customfield instanceof app_CustomField) {
131
+            $actionsFrame = $page->ActionsFrame();
132
+            $page->addContextItem($actionsFrame);
133 133
 
134
-			$actionsFrame->addItem($W->Link($W->Icon($App->translate('Delete'), Func_Icons::ACTIONS_EDIT_DELETE), $this->proxy()->delete($customfield->id)));
135
-		}
134
+            $actionsFrame->addItem($W->Link($W->Icon($App->translate('Delete'), Func_Icons::ACTIONS_EDIT_DELETE), $this->proxy()->delete($customfield->id)));
135
+        }
136 136
 
137
-		return $page;
138
-	}
137
+        return $page;
138
+    }
139 139
 
140 140
 
141
-	/**
142
-	 * @return bool
143
-	 */
144
-	public function save($customfield = null)
145
-	{
146
-	    $App = $this->App();
141
+    /**
142
+     * @return bool
143
+     */
144
+    public function save($customfield = null)
145
+    {
146
+        $App = $this->App();
147 147
 // 		$access = $Crm->Access();
148 148
 
149 149
 // 		if (!$access->viewShopAdmin()) {
150 150
 // 			throw new crm_AccessException($Crm->translate('Access denied to online shop administration'));
151 151
 // 		}
152 152
 
153
-	    $set = $App->CustomFieldSet();
153
+        $set = $App->CustomFieldSet();
154 154
 
155
-		if (empty($customfield['id'])) {
156
-			$record = $set->newRecord();
157
-		} else {
158
-			$record = $set->get($customfield['id']);
155
+        if (empty($customfield['id'])) {
156
+            $record = $set->newRecord();
157
+        } else {
158
+            $record = $set->get($customfield['id']);
159 159
 // 			if (null == $record) {
160 160
 // 				throw new crm_SaveException($Crm->translate('This custom field does not exists'));
161 161
 // 			}
162
-		}
162
+        }
163 163
 
164
-		if ('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']) {
165
-		    $enumvalues = array();
166
-		    foreach ($customfield['enumvalues'] as $enumkey => $enumvalue) {
167
-		        $enumvalues[$enumkey] = $set->enumvalues->input($enumvalue);
168
-		    }
169
-			$record->enumvalues = serialize($enumvalues);
170
-		} else {
171
-			$record->enumvalues = '';
172
-		}
164
+        if ('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']) {
165
+            $enumvalues = array();
166
+            foreach ($customfield['enumvalues'] as $enumkey => $enumvalue) {
167
+                $enumvalues[$enumkey] = $set->enumvalues->input($enumvalue);
168
+            }
169
+            $record->enumvalues = serialize($enumvalues);
170
+        } else {
171
+            $record->enumvalues = '';
172
+        }
173 173
 
174
-		unset($customfield['enumvalues']);
175
-		$record->setFormInputValues($customfield);
174
+        unset($customfield['enumvalues']);
175
+        $record->setFormInputValues($customfield);
176 176
 
177 177
 
178
-		$record->save();
178
+        $record->save();
179 179
 
180 180
 
181
-		// refresh target table structure
181
+        // refresh target table structure
182 182
 
183
-		$object = $record->object.'Set';
184
-		$mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']);
183
+        $object = $record->object.'Set';
184
+        $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']);
185 185
 
186
-		$recordSet = $App->$object();
187
-		if (method_exists($recordSet, 'useLang')) {
188
-		    // This is necessary if the recordSet constructor uses a setLang().
189
-		    // We need to revert to multilang fields before synchronizing.
190
-		    $recordSet->useLang(false);
191
-		}
186
+        $recordSet = $App->$object();
187
+        if (method_exists($recordSet, 'useLang')) {
188
+            // This is necessary if the recordSet constructor uses a setLang().
189
+            // We need to revert to multilang fields before synchronizing.
190
+            $recordSet->useLang(false);
191
+        }
192 192
 
193
-		$sql = $mysqlbackend->setToSql($recordSet);
193
+        $sql = $mysqlbackend->setToSql($recordSet);
194 194
 
195
-		require_once $GLOBALS['babInstallPath'].'utilit/devtools.php';
196
-		$synchronize = new bab_synchronizeSql();
197
-		$synchronize->fromSqlString($sql);
195
+        require_once $GLOBALS['babInstallPath'].'utilit/devtools.php';
196
+        $synchronize = new bab_synchronizeSql();
197
+        $synchronize->fromSqlString($sql);
198 198
 
199
-		return true;
200
-	}
199
+        return true;
200
+    }
201 201
 
202 202
 
203 203
     /**
204 204
      * {@inheritDoc}
205 205
      * @see app_CtrlRecord::delete()
206 206
      */
207
-	public function delete($customfield)
208
-	{
209
-	    $App = $this->App();
207
+    public function delete($customfield)
208
+    {
209
+        $App = $this->App();
210 210
 // 		$access = $Crm->Access();
211 211
 
212 212
 // 		if (!$access->viewShopAdmin()) {
213 213
 // 			throw new crm_AccessException($Crm->translate('Access denied to online shop administration'));
214 214
 // 		}
215 215
 
216
-		if (!$customfield)
217
-		{
218
-		    throw new app_AccessException($App->translate('Access denied'));
219
-		}
216
+        if (!$customfield)
217
+        {
218
+            throw new app_AccessException($App->translate('Access denied'));
219
+        }
220 220
 
221
-		$set = $App->CustomFieldSet();
222
-		$record = $set->request($customfield);
223
-		$object = $record->object.'Set';
224
-		$set->delete($set->id->is($customfield));
221
+        $set = $App->CustomFieldSet();
222
+        $record = $set->request($customfield);
223
+        $object = $record->object.'Set';
224
+        $set->delete($set->id->is($customfield));
225 225
 
226
-		$recordSet = $App->$object();
227
-		if (method_exists($recordSet, 'useLang')) {
228
-		    // This is necessary if the recordSet constructor uses a setLang().
229
-		    // We need to revert to multilang fields before synchronizing.
230
-		    $recordSet->useLang(false);
231
-		}
226
+        $recordSet = $App->$object();
227
+        if (method_exists($recordSet, 'useLang')) {
228
+            // This is necessary if the recordSet constructor uses a setLang().
229
+            // We need to revert to multilang fields before synchronizing.
230
+            $recordSet->useLang(false);
231
+        }
232 232
 
233
-		$mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']);
234
-		$sql = $mysqlbackend->setToSql($recordSet);
233
+        $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']);
234
+        $sql = $mysqlbackend->setToSql($recordSet);
235 235
 
236
-		require_once $GLOBALS['babInstallPath'].'utilit/devtools.php';
237
-		$synchronize = new bab_synchronizeSql();
238
-		$synchronize->fromSqlString($sql);
236
+        require_once $GLOBALS['babInstallPath'].'utilit/devtools.php';
237
+        $synchronize = new bab_synchronizeSql();
238
+        $synchronize->fromSqlString($sql);
239 239
 
240
-		return true;
241
-	}
240
+        return true;
241
+    }
242 242
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             $W->Link(
40 40
                 $App->translate('Add a custom field'),
41 41
                 $this->proxy()->edit()
42
-            )->addClass('icon',  Func_Icons::ACTIONS_LIST_ADD)
42
+            )->addClass('icon', Func_Icons::ACTIONS_LIST_ADD)
43 43
             ->setOpenMode(Widget_Link::OPEN_DIALOG_AND_RELOAD)
44 44
         );
45 45
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 		// refresh target table structure
182 182
 
183
-		$object = $record->object.'Set';
183
+		$object = $record->object . 'Set';
184 184
 		$mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']);
185 185
 
186 186
 		$recordSet = $App->$object();
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$sql = $mysqlbackend->setToSql($recordSet);
194 194
 
195
-		require_once $GLOBALS['babInstallPath'].'utilit/devtools.php';
195
+		require_once $GLOBALS['babInstallPath'] . 'utilit/devtools.php';
196 196
 		$synchronize = new bab_synchronizeSql();
197 197
 		$synchronize->fromSqlString($sql);
198 198
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 
221 221
 		$set = $App->CustomFieldSet();
222 222
 		$record = $set->request($customfield);
223
-		$object = $record->object.'Set';
223
+		$object = $record->object . 'Set';
224 224
 		$set->delete($set->id->is($customfield));
225 225
 
226 226
 		$recordSet = $App->$object();
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		$mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']);
234 234
 		$sql = $mysqlbackend->setToSql($recordSet);
235 235
 
236
-		require_once $GLOBALS['babInstallPath'].'utilit/devtools.php';
236
+		require_once $GLOBALS['babInstallPath'] . 'utilit/devtools.php';
237 237
 		$synchronize = new bab_synchronizeSql();
238 238
 		$synchronize->fromSqlString($sql);
239 239
 
Please login to merge, or discard this patch.
programs/functions.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 }
27 27
 
28 28
 
29
-require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
29
+require_once $GLOBALS['babInstallPath'] . 'utilit/urlincl.php';
30 30
 
31 31
 /**
32 32
  * Translates the string.
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         $url = $url->url();
125 125
     }
126 126
     if (!empty($babBody->msgerror)) {
127
-        $url .=  '&msgerror=' . urlencode($babBody->msgerror);
127
+        $url .= '&msgerror=' . urlencode($babBody->msgerror);
128 128
     }
129 129
     if (isset($message)) {
130 130
         $lines = explode("\n", $message);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
  */
166 166
 function app_fileUploadError($error)
167 167
 {
168
-    switch($error) {
168
+    switch ($error) {
169 169
         case UPLOAD_ERR_OK:
170 170
             return null;
171 171
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
         $hour = '00:00:00';
223 223
     }
224 224
 
225
-    return $date.' '.$hour;
225
+    return $date . ' ' . $hour;
226 226
 }
227 227
 
228 228
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         return '[' . join(',', $result) . ']';
273 273
     } else {
274 274
         foreach ($a as $k => $v) {
275
-            $result[] = app_json_encode($k).':'.app_json_encode($v);
275
+            $result[] = app_json_encode($k) . ':' . app_json_encode($v);
276 276
         }
277 277
         return '{' . join(',', $result) . '}';
278 278
     }
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -233,9 +233,15 @@
 block discarded – undo
233 233
  */
234 234
 function app_json_encode($a)
235 235
 {
236
-    if (is_null($a)) return 'null';
237
-    if ($a === false) return 'false';
238
-    if ($a === true) return 'true';
236
+    if (is_null($a)) {
237
+        return 'null';
238
+    }
239
+    if ($a === false) {
240
+        return 'false';
241
+    }
242
+    if ($a === true) {
243
+        return 'true';
244
+    }
239 245
     if (is_scalar($a)) {
240 246
         if (is_float($a)) {
241 247
             // Always use "." for floats.
Please login to merge, or discard this patch.
programs/controller.class.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@
 block discarded – undo
30 30
 
31 31
 class app_UnknownActionException extends Exception
32 32
 {
33
-	public function __construct($action, $code = 0)
34
-	{
35
-		$message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"';
36
-		parent::__construct($message, $code);
37
-	}
33
+    public function __construct($action, $code = 0)
34
+    {
35
+        $message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"';
36
+        parent::__construct($message, $code);
37
+    }
38 38
 }
39 39
 
40 40
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 
24 24
 require_once $GLOBALS['babInstallPath'] . 'utilit/controller.class.php';
25
-require_once dirname(__FILE__). '/functions.php';
25
+require_once dirname(__FILE__) . '/functions.php';
26 26
 
27 27
 $App = app_App();
28 28
 $App->includeBase();
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
         if (!$App)
221 221
         {
222
-            throw new app_Exception('Faild to autodetect functionality App/' . $functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead');
222
+            throw new app_Exception('Faild to autodetect functionality App/' . $functionalityName . ', the getInstance method is deprecated, use $App->ControllerProxy() instead');
223 223
         }
224 224
 
225 225
         $controller = $App->ControllerProxy($classname, $proxy);
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
         $action->setParameters($actionParams);
395 395
 
396 396
 
397
-        list(,,$file) = explode('/', $App->controllerTg);
397
+        list(,, $file) = explode('/', $App->controllerTg);
398 398
 
399
-        $action->setParameter('addon', $App->getAddonName().'.'.$file);
399
+        $action->setParameter('addon', $App->getAddonName() . '.' . $file);
400 400
         $action->setParameter('idx', $idx);
401 401
 
402 402
         return $action;
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
             return false;
419 419
         }
420 420
 
421
-        list($objectName, ) = explode('.', $method);
421
+        list($objectName,) = explode('.', $method);
422 422
 
423 423
         if (!method_exists($this, $objectName)) {
424 424
             header('HTTP/1.0 400 Bad Request');
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
         }
427 427
 
428 428
         $objectController = $this->{$objectName}(false);
429
-        if ( ! ($objectController instanceof app_Controller)) {
429
+        if (!($objectController instanceof app_Controller)) {
430 430
             return false;
431 431
         }
432 432
 
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
         $popup->babEcho(
679 679
             '<h1>' . $this->App()->translate('There was a problem when trying to perform this operation') . '</h1>'
680 680
             . '<h2 class="error">' . $this->App()->translate('Additional debugging information:') . '</h2>'
681
-            . '<p class="error">' . $e->getMessage() . ' ' .  $e->getFile() . ' ' . $e->getLine()  . ' ' . $e->getTraceAsString() . '</p>'
681
+            . '<p class="error">' . $e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine() . ' ' . $e->getTraceAsString() . '</p>'
682 682
             );
683 683
 
684 684
 
Please login to merge, or discard this patch.
programs/traceablerecord.class.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
      */
305 305
     private function uuid()
306 306
     {
307
-        return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
308
-            mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
309
-            mt_rand( 0, 0x0fff ) | 0x4000,
310
-            mt_rand( 0, 0x3fff ) | 0x8000,
311
-            mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) );
307
+        return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
308
+            mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
309
+            mt_rand(0, 0x0fff) | 0x4000,
310
+            mt_rand(0, 0x3fff) | 0x8000,
311
+            mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
312 312
     }
313 313
 
314 314
     /**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 
399 399
         $linkSet->hasOne('sourceId', get_class($this));
400 400
 
401
-        $criteria =	$linkSet->targetClass->is(get_class($target))
401
+        $criteria = $linkSet->targetClass->is(get_class($target))
402 402
             ->_AND_($linkSet->targetId->is($target->id))
403 403
             ->_AND_($linkSet->sourceClass->is($this->getRecordClassName()));
404 404
         if (isset($linkType)) {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 
429 429
         $linkSet->hasOne('targetId', get_class($this));
430 430
 
431
-        $criteria =	$linkSet->sourceClass->is(get_class($source))
431
+        $criteria = $linkSet->sourceClass->is(get_class($source))
432 432
             ->_AND_($linkSet->sourceId->is($source->id))
433 433
             ->_AND_($linkSet->targetClass->is($this->getRecordClassName()));
434 434
         if (isset($linkType)) {
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
             $sourcesCriteria[] = $linkSet->sourceClass->is($sourceClass)->_AND_($linkSet->sourceId->in($sourceIds));
473 473
         }
474 474
 
475
-        $criteria =	$linkSet->all(
475
+        $criteria = $linkSet->all(
476 476
             $linkSet->targetClass->is($this->getRecordClassName()),
477 477
             $linkSet->any($sourcesCriteria)
478 478
         );
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
             $targetsCriteria[] = $linkSet->targetClass->is($targetClass)->_AND_($linkSet->targetId->in($targetIds));
518 518
         }
519 519
 
520
-        $criteria =	$linkSet->all(
520
+        $criteria = $linkSet->all(
521 521
             $linkSet->sourceClass->is($this->getRecordClassName()),
522 522
             $linkSet->any($targetsCriteria)
523 523
         );
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
     {
576 576
         $linkSet = $this->App()->LinkSet();
577 577
 
578
-        $criteria =	$linkSet->sourceClass->is(get_class($source))
578
+        $criteria = $linkSet->sourceClass->is(get_class($source))
579 579
             ->_AND_($linkSet->sourceId->is($source->id))
580 580
             ->_AND_($linkSet->targetClass->is(get_class($this)))
581 581
             ->_AND_($linkSet->targetId->is($this->id));
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
     {
606 606
         $linkSet = $this->App()->LinkSet();
607 607
 
608
-        $criteria =	$linkSet->targetClass->is(get_class($target))
608
+        $criteria = $linkSet->targetClass->is(get_class($target))
609 609
             ->_AND_($linkSet->targetId->is($target->id))
610 610
             ->_AND_($linkSet->sourceClass->is(get_class($this)))
611 611
             ->_AND_($linkSet->sourceId->is($this->id));
Please login to merge, or discard this patch.
programs/link.class.php 2 patches
Indentation   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -69,205 +69,205 @@
 block discarded – undo
69 69
 
70 70
 
71 71
 
72
-	/**
73
-	 * @param	string	$sourceClass
74
-	 */
75
-	public function joinSource($sourceClass)
76
-	{
77
-	    if (get_class($this->sourceId) !== $sourceClass . 'Set') {
78
-    	    $this->hasOne('sourceId', $sourceClass . 'Set');
79
-    		$this->join('sourceId');
80
-	    }
81
-	}
82
-
83
-
84
-	/**
85
-	 * @param	string	$targetClass
86
-	 */
87
-	public function joinTarget($targetClass = null)
88
-	{
89
-	    if (get_class($this->targetId) !== $targetClass . 'Set') {
90
-    		$this->hasOne('targetId', $targetClass . 'Set');
91
-    		$this->join('targetId');
92
-	    }
93
-	}
94
-
95
-
96
-
97
-	public function sourceIsA($recordClass)
98
-	{
99
-		return $this->sourceClass->is($recordClass);
100
-	}
101
-
102
-	/**
103
-	 *
104
-	 * @return ORM_Iterator
105
-	 */
106
-	public function selectForSource(app_Record $object, $targetClass = null, $linkType = null)
107
-	{
108
-		$criteria = $this->sourceId->is($object->id)
72
+    /**
73
+     * @param	string	$sourceClass
74
+     */
75
+    public function joinSource($sourceClass)
76
+    {
77
+        if (get_class($this->sourceId) !== $sourceClass . 'Set') {
78
+            $this->hasOne('sourceId', $sourceClass . 'Set');
79
+            $this->join('sourceId');
80
+        }
81
+    }
82
+
83
+
84
+    /**
85
+     * @param	string	$targetClass
86
+     */
87
+    public function joinTarget($targetClass = null)
88
+    {
89
+        if (get_class($this->targetId) !== $targetClass . 'Set') {
90
+            $this->hasOne('targetId', $targetClass . 'Set');
91
+            $this->join('targetId');
92
+        }
93
+    }
94
+
95
+
96
+
97
+    public function sourceIsA($recordClass)
98
+    {
99
+        return $this->sourceClass->is($recordClass);
100
+    }
101
+
102
+    /**
103
+     *
104
+     * @return ORM_Iterator
105
+     */
106
+    public function selectForSource(app_Record $object, $targetClass = null, $linkType = null)
107
+    {
108
+        $criteria = $this->sourceId->is($object->id)
109 109
             ->_AND_($this->sourceClass->is(get_class($object)));
110 110
 
111
-		if (isset($targetClass)) {
112
-		    $this->joinTarget($targetClass);
113
-		    $criteria = $criteria->_AND_($this->targetClass->is($targetClass));
114
-		}
115
-
116
-		if (isset($linkType)) {
117
-			if (is_array($linkType)) {
118
-				$criteria = $criteria->_AND_($this->type->in($linkType));
119
-			} else {
120
-				$criteria = $criteria->_AND_($this->type->is($linkType));
121
-			}
122
-		}
123
-
124
-		if (is_a($this->targetId, 'app_TraceableRecordSet')) {
125
-			$criteria = $criteria->_AND_($this->targetId->deleted->is(false));
126
-		}
127
-
128
-		return $this->select($criteria);
129
-	}
130
-
131
-
132
-	/**
133
-	 *
134
-	 * @return ORM_Iterator
135
-	 */
136
-	public function selectForSources($objects, $targetClass, $linkType = null)
137
-	{
138
-		$sourceClass = null;
139
-		$sourceIds = array();
140
-
141
-		foreach ($objects as $obj) {
142
-			if (is_null($sourceClass)) {
143
-				$sourceClass = get_class($obj);
144
-			}
145
-			$sourceIds[] = $obj->id;
146
-		}
147
-		$criteria = $this->sourceId->in($sourceIds)
148
-			->_AND_($this->sourceClass->is($sourceClass));
149
-
150
-		if (isset($targetClass)) {
151
-		    $this->joinTarget($targetClass);
152
-		    $criteria = $criteria->_AND_($this->targetClass->is($targetClass));
153
-		}
154
-
155
-		if (isset($linkType)) {
156
-			if (is_array($linkType)) {
157
-				$criteria = $criteria->_AND_($this->type->in($linkType));
158
-			} else {
159
-				$criteria = $criteria->_AND_($this->type->is($linkType));
160
-			}
161
-		}
162
-		return $this->select($criteria);
163
-	}
164
-
165
-
166
-	/**
167
-	 *
168
-	 * @return ORM_Iterator
169
-	 */
170
-	public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null)
171
-	{
172
-		$criteria = $this->targetId->is($object->id)
173
-			->_AND_($this->targetClass->is(get_class($object)));
174
-
175
-		if (isset($sourceClass)) {
176
-		    $this->joinSource($sourceClass);
177
-			$criteria = $criteria->_AND_($this->sourceClass->is($sourceClass));
178
-		}
179
-
180
-		if (isset($linkType)) {
181
-			if (is_array($linkType)) {
182
-				$criteria = $criteria->_AND_($this->type->in($linkType));
183
-			} else {
184
-				$criteria = $criteria->_AND_($this->type->is($linkType));
185
-			}
186
-		}
187
-
188
-		return $this->select($criteria);
189
-	}
190
-
191
-
192
-	/**
193
-	 *
194
-	 * @return ORM_Iterator
195
-	 */
196
-	public function selectForTargets($objects, $sourceClass = null, $linkType = null)
197
-	{
198
-		$targetClass = null;
199
-		$targetIds = array();
200
-
201
-		foreach ($objects as $obj) {
202
-			if (is_null($targetClass)) {
203
-				$targetClass = get_class($obj);
204
-			}
205
-			$targetIds[] = $obj->id;
206
-		}
207
-		$criteria = $this->targetId->in($targetIds)
208
-			->_AND_($this->targetClass->is($targetClass));
209
-
210
-		if (isset($sourceClass)) {
211
-		    $this->joinSource($sourceClass);
212
-			$criteria = $criteria->_AND_($this->sourceClass->is($sourceClass));
213
-		}
214
-
215
-		if (isset($linkType)) {
216
-			if (is_array($linkType)) {
217
-				$criteria = $criteria->_AND_($this->type->in($linkType));
218
-			} else {
219
-				$criteria = $criteria->_AND_($this->type->is($linkType));
220
-			}
221
-		}
222
-
223
-		return $this->select($criteria);
224
-	}
225
-
226
-
227
-
228
-	/**
229
-	 * delete all links to an object
230
-	 *
231
-	 * @param	app_Record		$object
232
-	 * @param	string			$targetClass 	if target class is set, links will be deleted only for target classes
233
-	 * @param	bool			$deleteTarget	if set to true, the target will be deleted to
234
-	 */
235
-	public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null)
236
-	{
237
-		$set = clone $this;
238
-		$App = $object->App();
239
-
240
-		$criteria = $set->sourceId->is($object->id)->_AND_(
241
-			$set->sourceClass->is(get_class($object))
242
-		);
243
-
244
-		if (null !== $targetClass) {
245
-			$criteria = $criteria->_AND_(
246
-				$set->targetClass->is($targetClass)
247
-			);
248
-		}
249
-		if (null !== $linkType) {
250
-			$criteria = $criteria->_AND_(
251
-				$set->type->is($linkType)
252
-			);
253
-		}
254
-
255
-		if ($deleteTarget) {
256
-			foreach($set->select($criteria) as $link) {
257
-
258
-				$className = $link->targetClass.'Set';
259
-
260
-				// remove prefix
261
-
262
-				$className = mb_substr($className, 1 + mb_strpos($className, '_'));
263
-				$targetSet = $App->$className();
264
-
265
-				$targetSet->delete($targetSet->id->is($link->targetId));
266
-			}
267
-		}
268
-
269
-		return $set->delete($criteria);
270
-	}
111
+        if (isset($targetClass)) {
112
+            $this->joinTarget($targetClass);
113
+            $criteria = $criteria->_AND_($this->targetClass->is($targetClass));
114
+        }
115
+
116
+        if (isset($linkType)) {
117
+            if (is_array($linkType)) {
118
+                $criteria = $criteria->_AND_($this->type->in($linkType));
119
+            } else {
120
+                $criteria = $criteria->_AND_($this->type->is($linkType));
121
+            }
122
+        }
123
+
124
+        if (is_a($this->targetId, 'app_TraceableRecordSet')) {
125
+            $criteria = $criteria->_AND_($this->targetId->deleted->is(false));
126
+        }
127
+
128
+        return $this->select($criteria);
129
+    }
130
+
131
+
132
+    /**
133
+     *
134
+     * @return ORM_Iterator
135
+     */
136
+    public function selectForSources($objects, $targetClass, $linkType = null)
137
+    {
138
+        $sourceClass = null;
139
+        $sourceIds = array();
140
+
141
+        foreach ($objects as $obj) {
142
+            if (is_null($sourceClass)) {
143
+                $sourceClass = get_class($obj);
144
+            }
145
+            $sourceIds[] = $obj->id;
146
+        }
147
+        $criteria = $this->sourceId->in($sourceIds)
148
+            ->_AND_($this->sourceClass->is($sourceClass));
149
+
150
+        if (isset($targetClass)) {
151
+            $this->joinTarget($targetClass);
152
+            $criteria = $criteria->_AND_($this->targetClass->is($targetClass));
153
+        }
154
+
155
+        if (isset($linkType)) {
156
+            if (is_array($linkType)) {
157
+                $criteria = $criteria->_AND_($this->type->in($linkType));
158
+            } else {
159
+                $criteria = $criteria->_AND_($this->type->is($linkType));
160
+            }
161
+        }
162
+        return $this->select($criteria);
163
+    }
164
+
165
+
166
+    /**
167
+     *
168
+     * @return ORM_Iterator
169
+     */
170
+    public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null)
171
+    {
172
+        $criteria = $this->targetId->is($object->id)
173
+            ->_AND_($this->targetClass->is(get_class($object)));
174
+
175
+        if (isset($sourceClass)) {
176
+            $this->joinSource($sourceClass);
177
+            $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass));
178
+        }
179
+
180
+        if (isset($linkType)) {
181
+            if (is_array($linkType)) {
182
+                $criteria = $criteria->_AND_($this->type->in($linkType));
183
+            } else {
184
+                $criteria = $criteria->_AND_($this->type->is($linkType));
185
+            }
186
+        }
187
+
188
+        return $this->select($criteria);
189
+    }
190
+
191
+
192
+    /**
193
+     *
194
+     * @return ORM_Iterator
195
+     */
196
+    public function selectForTargets($objects, $sourceClass = null, $linkType = null)
197
+    {
198
+        $targetClass = null;
199
+        $targetIds = array();
200
+
201
+        foreach ($objects as $obj) {
202
+            if (is_null($targetClass)) {
203
+                $targetClass = get_class($obj);
204
+            }
205
+            $targetIds[] = $obj->id;
206
+        }
207
+        $criteria = $this->targetId->in($targetIds)
208
+            ->_AND_($this->targetClass->is($targetClass));
209
+
210
+        if (isset($sourceClass)) {
211
+            $this->joinSource($sourceClass);
212
+            $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass));
213
+        }
214
+
215
+        if (isset($linkType)) {
216
+            if (is_array($linkType)) {
217
+                $criteria = $criteria->_AND_($this->type->in($linkType));
218
+            } else {
219
+                $criteria = $criteria->_AND_($this->type->is($linkType));
220
+            }
221
+        }
222
+
223
+        return $this->select($criteria);
224
+    }
225
+
226
+
227
+
228
+    /**
229
+     * delete all links to an object
230
+     *
231
+     * @param	app_Record		$object
232
+     * @param	string			$targetClass 	if target class is set, links will be deleted only for target classes
233
+     * @param	bool			$deleteTarget	if set to true, the target will be deleted to
234
+     */
235
+    public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null)
236
+    {
237
+        $set = clone $this;
238
+        $App = $object->App();
239
+
240
+        $criteria = $set->sourceId->is($object->id)->_AND_(
241
+            $set->sourceClass->is(get_class($object))
242
+        );
243
+
244
+        if (null !== $targetClass) {
245
+            $criteria = $criteria->_AND_(
246
+                $set->targetClass->is($targetClass)
247
+            );
248
+        }
249
+        if (null !== $linkType) {
250
+            $criteria = $criteria->_AND_(
251
+                $set->type->is($linkType)
252
+            );
253
+        }
254
+
255
+        if ($deleteTarget) {
256
+            foreach($set->select($criteria) as $link) {
257
+
258
+                $className = $link->targetClass.'Set';
259
+
260
+                // remove prefix
261
+
262
+                $className = mb_substr($className, 1 + mb_strpos($className, '_'));
263
+                $targetSet = $App->$className();
264
+
265
+                $targetSet->delete($targetSet->id->is($link->targetId));
266
+            }
267
+        }
268
+
269
+        return $set->delete($criteria);
270
+    }
271 271
 
272 272
 
273 273
     /**
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 		}
254 254
 
255 255
 		if ($deleteTarget) {
256
-			foreach($set->select($criteria) as $link) {
256
+			foreach ($set->select($criteria) as $link) {
257 257
 
258
-				$className = $link->targetClass.'Set';
258
+				$className = $link->targetClass . 'Set';
259 259
 
260 260
 				// remove prefix
261 261
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         $object = substr($this->sourceClass, strlen($App->classPrefix));
326 326
 
327 327
         /* @var $set app_RecordSet */
328
-        $set = $App->{$object.'Set'}();
328
+        $set = $App->{$object . 'Set'}();
329 329
         return $set->get($this->sourceId);
330 330
     }
331 331
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         $object = substr($this->sourceClass, strlen($App->classPrefix));
339 339
 
340 340
         /* @var $set app_RecordSet */
341
-        $set = $App->{$object.'Set'}();
341
+        $set = $App->{$object . 'Set'}();
342 342
         return $set->get($this->targetId);
343 343
     }
344 344
 }
Please login to merge, or discard this patch.