@@ -104,243 +104,243 @@ |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * @param string $sourceClass |
|
| 109 | - */ |
|
| 110 | - public function joinSource($sourceClass) |
|
| 111 | - {
|
|
| 112 | - if (get_class($this->sourceId) !== $sourceClass . 'Set') {
|
|
| 113 | - $this->hasOne('sourceId', $sourceClass . 'Set');
|
|
| 114 | - $this->join('sourceId');
|
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @param string $targetClass |
|
| 121 | - */ |
|
| 122 | - public function joinTarget($targetClass = null) |
|
| 123 | - {
|
|
| 124 | - if (get_class($this->targetId) !== $targetClass . 'Set') {
|
|
| 125 | - $this->hasOne('targetId', $targetClass . 'Set');
|
|
| 126 | - $this->join('targetId');
|
|
| 127 | - } |
|
| 128 | - } |
|
| 107 | + /** |
|
| 108 | + * @param string $sourceClass |
|
| 109 | + */ |
|
| 110 | + public function joinSource($sourceClass) |
|
| 111 | + {
|
|
| 112 | + if (get_class($this->sourceId) !== $sourceClass . 'Set') {
|
|
| 113 | + $this->hasOne('sourceId', $sourceClass . 'Set');
|
|
| 114 | + $this->join('sourceId');
|
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @param string $targetClass |
|
| 121 | + */ |
|
| 122 | + public function joinTarget($targetClass = null) |
|
| 123 | + {
|
|
| 124 | + if (get_class($this->targetId) !== $targetClass . 'Set') {
|
|
| 125 | + $this->hasOne('targetId', $targetClass . 'Set');
|
|
| 126 | + $this->join('targetId');
|
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @param string $recordClass |
|
| 133 | + * @return ORM_IsCriterion |
|
| 134 | + */ |
|
| 135 | + public function sourceIsA($recordClass) |
|
| 136 | + {
|
|
| 137 | + return $this->sourceClass->is($recordClass); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * @param app_Record $record |
|
| 143 | + * @return ORM_Criteria |
|
| 144 | + */ |
|
| 145 | + public function sourceIs(app_Record $record) |
|
| 146 | + {
|
|
| 147 | + return $this->all( |
|
| 148 | + $this->sourceId->is($record->id), |
|
| 149 | + $this->sourceIsA(get_class($record)) |
|
| 150 | + ); |
|
| 151 | + } |
|
| 129 | 152 | |
| 130 | 153 | |
| 131 | 154 | /** |
| 132 | 155 | * @param string $recordClass |
| 133 | 156 | * @return ORM_IsCriterion |
| 134 | 157 | */ |
| 135 | - public function sourceIsA($recordClass) |
|
| 136 | - {
|
|
| 137 | - return $this->sourceClass->is($recordClass); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @param app_Record $record |
|
| 143 | - * @return ORM_Criteria |
|
| 144 | - */ |
|
| 145 | - public function sourceIs(app_Record $record) |
|
| 146 | - {
|
|
| 147 | - return $this->all( |
|
| 148 | - $this->sourceId->is($record->id), |
|
| 149 | - $this->sourceIsA(get_class($record)) |
|
| 150 | - ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @param string $recordClass |
|
| 156 | - * @return ORM_IsCriterion |
|
| 157 | - */ |
|
| 158 | - public function targetIsA($recordClass) |
|
| 159 | - {
|
|
| 160 | - return $this->targetClass->is($recordClass); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @param app_Record $record |
|
| 166 | - * @return ORM_Criteria |
|
| 167 | - */ |
|
| 168 | - public function targetIs(app_Record $record) |
|
| 169 | - {
|
|
| 170 | - return $this->all( |
|
| 171 | - $this->targetId->is($record->id), |
|
| 172 | - $this->targetIsA(get_class($record)) |
|
| 158 | + public function targetIsA($recordClass) |
|
| 159 | + {
|
|
| 160 | + return $this->targetClass->is($recordClass); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @param app_Record $record |
|
| 166 | + * @return ORM_Criteria |
|
| 167 | + */ |
|
| 168 | + public function targetIs(app_Record $record) |
|
| 169 | + {
|
|
| 170 | + return $this->all( |
|
| 171 | + $this->targetId->is($record->id), |
|
| 172 | + $this->targetIsA(get_class($record)) |
|
| 173 | 173 | ); |
| 174 | - } |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * |
|
| 179 | - * @return ORM_Iterator |
|
| 180 | - */ |
|
| 181 | - public function selectForSource(app_Record $object, $targetClass = null, $linkType = null) |
|
| 182 | - {
|
|
| 183 | - $criteria = $this->sourceIs($object); |
|
| 184 | - |
|
| 185 | - if (isset($targetClass)) {
|
|
| 186 | - $this->joinTarget($targetClass); |
|
| 187 | - $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - if (isset($linkType)) {
|
|
| 191 | - if (is_array($linkType)) {
|
|
| 192 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
| 193 | - } else {
|
|
| 194 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - if (is_a($this->targetId, 'app_TraceableRecordSet')) {
|
|
| 199 | - $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - return $this->select($criteria); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * |
|
| 208 | - * @return ORM_Iterator |
|
| 209 | - */ |
|
| 210 | - public function selectForSources($objects, $targetClass, $linkType = null) |
|
| 211 | - {
|
|
| 212 | - $sourceClass = null; |
|
| 213 | - $sourceIds = array(); |
|
| 214 | - |
|
| 215 | - foreach ($objects as $obj) {
|
|
| 216 | - if (is_null($sourceClass)) {
|
|
| 217 | - $sourceClass = get_class($obj); |
|
| 218 | - } |
|
| 219 | - $sourceIds[] = $obj->id; |
|
| 220 | - } |
|
| 221 | - $criteria = $this->sourceId->in($sourceIds) |
|
| 222 | - ->_AND_($this->sourceClass->is($sourceClass)); |
|
| 223 | - |
|
| 224 | - if (isset($targetClass)) {
|
|
| 225 | - $this->joinTarget($targetClass); |
|
| 226 | - $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - if (isset($linkType)) {
|
|
| 230 | - if (is_array($linkType)) {
|
|
| 231 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
| 232 | - } else {
|
|
| 233 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
| 234 | - } |
|
| 235 | - } |
|
| 236 | - return $this->select($criteria); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * |
|
| 242 | - * @return ORM_Iterator |
|
| 243 | - */ |
|
| 244 | - public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null) |
|
| 245 | - {
|
|
| 246 | - $criteria = $this->targetIs($object); |
|
| 247 | - |
|
| 248 | - if (isset($sourceClass)) {
|
|
| 249 | - $this->joinSource($sourceClass); |
|
| 250 | - $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - if (isset($linkType)) {
|
|
| 254 | - if (is_array($linkType)) {
|
|
| 255 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
| 256 | - } else {
|
|
| 257 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - return $this->select($criteria); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * |
|
| 267 | - * @return ORM_Iterator |
|
| 268 | - */ |
|
| 269 | - public function selectForTargets($objects, $sourceClass = null, $linkType = null) |
|
| 270 | - {
|
|
| 271 | - $targetClass = null; |
|
| 272 | - $targetIds = array(); |
|
| 273 | - |
|
| 274 | - foreach ($objects as $obj) {
|
|
| 275 | - if (is_null($targetClass)) {
|
|
| 276 | - $targetClass = get_class($obj); |
|
| 277 | - } |
|
| 278 | - $targetIds[] = $obj->id; |
|
| 279 | - } |
|
| 280 | - $criteria = $this->targetId->in($targetIds) |
|
| 281 | - ->_AND_($this->targetClass->is($targetClass)); |
|
| 282 | - |
|
| 283 | - if (isset($sourceClass)) {
|
|
| 284 | - $this->joinSource($sourceClass); |
|
| 285 | - $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - if (isset($linkType)) {
|
|
| 289 | - if (is_array($linkType)) {
|
|
| 290 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
| 291 | - } else {
|
|
| 292 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - return $this->select($criteria); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * delete all links to an object |
|
| 303 | - * |
|
| 304 | - * @param app_Record $object |
|
| 305 | - * @param string $targetClass if target class is set, links will be deleted only for target classes |
|
| 306 | - * @param bool $deleteTarget if set to true, the target will be deleted to |
|
| 307 | - */ |
|
| 308 | - public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null) |
|
| 309 | - {
|
|
| 310 | - $set = clone $this; |
|
| 311 | - $App = $object->App(); |
|
| 312 | - |
|
| 313 | - $criteria = $set->sourceId->is($object->id)->_AND_( |
|
| 314 | - $set->sourceClass->is(get_class($object)) |
|
| 315 | - ); |
|
| 316 | - |
|
| 317 | - if (null !== $targetClass) {
|
|
| 318 | - $criteria = $criteria->_AND_( |
|
| 319 | - $set->targetClass->is($targetClass) |
|
| 320 | - ); |
|
| 321 | - } |
|
| 322 | - if (null !== $linkType) {
|
|
| 323 | - $criteria = $criteria->_AND_( |
|
| 324 | - $set->type->is($linkType) |
|
| 325 | - ); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - if ($deleteTarget) {
|
|
| 329 | - foreach($set->select($criteria) as $link) {
|
|
| 330 | - |
|
| 331 | - $className = $link->targetClass.'Set'; |
|
| 332 | - |
|
| 333 | - // remove prefix |
|
| 334 | - |
|
| 335 | - $className = mb_substr($className, 1 + mb_strpos($className, '_')); |
|
| 336 | - $targetSet = $App->$className(); |
|
| 337 | - |
|
| 338 | - $targetSet->delete($targetSet->id->is($link->targetId)); |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - return $set->delete($criteria); |
|
| 343 | - } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * |
|
| 179 | + * @return ORM_Iterator |
|
| 180 | + */ |
|
| 181 | + public function selectForSource(app_Record $object, $targetClass = null, $linkType = null) |
|
| 182 | + {
|
|
| 183 | + $criteria = $this->sourceIs($object); |
|
| 184 | + |
|
| 185 | + if (isset($targetClass)) {
|
|
| 186 | + $this->joinTarget($targetClass); |
|
| 187 | + $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + if (isset($linkType)) {
|
|
| 191 | + if (is_array($linkType)) {
|
|
| 192 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
| 193 | + } else {
|
|
| 194 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + if (is_a($this->targetId, 'app_TraceableRecordSet')) {
|
|
| 199 | + $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + return $this->select($criteria); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * |
|
| 208 | + * @return ORM_Iterator |
|
| 209 | + */ |
|
| 210 | + public function selectForSources($objects, $targetClass, $linkType = null) |
|
| 211 | + {
|
|
| 212 | + $sourceClass = null; |
|
| 213 | + $sourceIds = array(); |
|
| 214 | + |
|
| 215 | + foreach ($objects as $obj) {
|
|
| 216 | + if (is_null($sourceClass)) {
|
|
| 217 | + $sourceClass = get_class($obj); |
|
| 218 | + } |
|
| 219 | + $sourceIds[] = $obj->id; |
|
| 220 | + } |
|
| 221 | + $criteria = $this->sourceId->in($sourceIds) |
|
| 222 | + ->_AND_($this->sourceClass->is($sourceClass)); |
|
| 223 | + |
|
| 224 | + if (isset($targetClass)) {
|
|
| 225 | + $this->joinTarget($targetClass); |
|
| 226 | + $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + if (isset($linkType)) {
|
|
| 230 | + if (is_array($linkType)) {
|
|
| 231 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
| 232 | + } else {
|
|
| 233 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + return $this->select($criteria); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * |
|
| 242 | + * @return ORM_Iterator |
|
| 243 | + */ |
|
| 244 | + public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null) |
|
| 245 | + {
|
|
| 246 | + $criteria = $this->targetIs($object); |
|
| 247 | + |
|
| 248 | + if (isset($sourceClass)) {
|
|
| 249 | + $this->joinSource($sourceClass); |
|
| 250 | + $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + if (isset($linkType)) {
|
|
| 254 | + if (is_array($linkType)) {
|
|
| 255 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
| 256 | + } else {
|
|
| 257 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + return $this->select($criteria); |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * |
|
| 267 | + * @return ORM_Iterator |
|
| 268 | + */ |
|
| 269 | + public function selectForTargets($objects, $sourceClass = null, $linkType = null) |
|
| 270 | + {
|
|
| 271 | + $targetClass = null; |
|
| 272 | + $targetIds = array(); |
|
| 273 | + |
|
| 274 | + foreach ($objects as $obj) {
|
|
| 275 | + if (is_null($targetClass)) {
|
|
| 276 | + $targetClass = get_class($obj); |
|
| 277 | + } |
|
| 278 | + $targetIds[] = $obj->id; |
|
| 279 | + } |
|
| 280 | + $criteria = $this->targetId->in($targetIds) |
|
| 281 | + ->_AND_($this->targetClass->is($targetClass)); |
|
| 282 | + |
|
| 283 | + if (isset($sourceClass)) {
|
|
| 284 | + $this->joinSource($sourceClass); |
|
| 285 | + $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + if (isset($linkType)) {
|
|
| 289 | + if (is_array($linkType)) {
|
|
| 290 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
| 291 | + } else {
|
|
| 292 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + return $this->select($criteria); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * delete all links to an object |
|
| 303 | + * |
|
| 304 | + * @param app_Record $object |
|
| 305 | + * @param string $targetClass if target class is set, links will be deleted only for target classes |
|
| 306 | + * @param bool $deleteTarget if set to true, the target will be deleted to |
|
| 307 | + */ |
|
| 308 | + public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null) |
|
| 309 | + {
|
|
| 310 | + $set = clone $this; |
|
| 311 | + $App = $object->App(); |
|
| 312 | + |
|
| 313 | + $criteria = $set->sourceId->is($object->id)->_AND_( |
|
| 314 | + $set->sourceClass->is(get_class($object)) |
|
| 315 | + ); |
|
| 316 | + |
|
| 317 | + if (null !== $targetClass) {
|
|
| 318 | + $criteria = $criteria->_AND_( |
|
| 319 | + $set->targetClass->is($targetClass) |
|
| 320 | + ); |
|
| 321 | + } |
|
| 322 | + if (null !== $linkType) {
|
|
| 323 | + $criteria = $criteria->_AND_( |
|
| 324 | + $set->type->is($linkType) |
|
| 325 | + ); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + if ($deleteTarget) {
|
|
| 329 | + foreach($set->select($criteria) as $link) {
|
|
| 330 | + |
|
| 331 | + $className = $link->targetClass.'Set'; |
|
| 332 | + |
|
| 333 | + // remove prefix |
|
| 334 | + |
|
| 335 | + $className = mb_substr($className, 1 + mb_strpos($className, '_')); |
|
| 336 | + $targetSet = $App->$className(); |
|
| 337 | + |
|
| 338 | + $targetSet->delete($targetSet->id->is($link->targetId)); |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + return $set->delete($criteria); |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | 345 | |
| 346 | 346 | /** |
@@ -30,19 +30,19 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | class app_CustomFieldTableView extends app_TableModelView |
| 32 | 32 | { |
| 33 | - /** |
|
| 34 | - * @param ORM_Record $record |
|
| 35 | - * @param string $fieldPath |
|
| 36 | - * @return Widget_Item |
|
| 37 | - */ |
|
| 38 | - protected function computeCellContent(ORM_Record $record, $fieldPath) |
|
| 39 | - { |
|
| 40 | - $W = bab_Widgets(); |
|
| 41 | - $App = $record->App(); |
|
| 33 | + /** |
|
| 34 | + * @param ORM_Record $record |
|
| 35 | + * @param string $fieldPath |
|
| 36 | + * @return Widget_Item |
|
| 37 | + */ |
|
| 38 | + protected function computeCellContent(ORM_Record $record, $fieldPath) |
|
| 39 | + { |
|
| 40 | + $W = bab_Widgets(); |
|
| 41 | + $App = $record->App(); |
|
| 42 | 42 | |
| 43 | - $editAction = $App->Controller()->CustomField()->edit($record->id); |
|
| 43 | + $editAction = $App->Controller()->CustomField()->edit($record->id); |
|
| 44 | 44 | |
| 45 | - switch ($fieldPath) { |
|
| 45 | + switch ($fieldPath) { |
|
| 46 | 46 | |
| 47 | 47 | case '_actions_': |
| 48 | 48 | $box = $W->FlowItems(); |
@@ -62,19 +62,19 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | return $box; |
| 64 | 64 | |
| 65 | - case 'mandatory': |
|
| 66 | - case 'visible_in_shop': |
|
| 67 | - if (self::getRecordFieldValue($record, $fieldPath)) |
|
| 68 | - { |
|
| 69 | - return $W->Label($App->translate('Yes')); |
|
| 70 | - } else { |
|
| 71 | - return $W->Label($App->translate('No')); |
|
| 72 | - } |
|
| 73 | - break; |
|
| 74 | - } |
|
| 65 | + case 'mandatory': |
|
| 66 | + case 'visible_in_shop': |
|
| 67 | + if (self::getRecordFieldValue($record, $fieldPath)) |
|
| 68 | + { |
|
| 69 | + return $W->Label($App->translate('Yes')); |
|
| 70 | + } else { |
|
| 71 | + return $W->Label($App->translate('No')); |
|
| 72 | + } |
|
| 73 | + break; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return parent::computeCellContent($record, $fieldPath); |
|
| 77 | - } |
|
| 76 | + return parent::computeCellContent($record, $fieldPath); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | ->addClass('widget-close-dialog') |
| 215 | 215 | ->setLabel($App->translate('Cancel')) |
| 216 | 216 | ); |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | protected function section() |
@@ -371,27 +371,27 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | |
| 373 | 373 | |
| 374 | - public function mandatory() |
|
| 375 | - { |
|
| 376 | - $App = $this->App(); |
|
| 377 | - $W = $this->widgets; |
|
| 374 | + public function mandatory() |
|
| 375 | + { |
|
| 376 | + $App = $this->App(); |
|
| 377 | + $W = $this->widgets; |
|
| 378 | 378 | |
| 379 | - return $this->labelledField( |
|
| 380 | - $App->translate('Mandatory field'), |
|
| 381 | - $W->Checkbox(), |
|
| 382 | - __FUNCTION__ |
|
| 383 | - ); |
|
| 384 | - } |
|
| 379 | + return $this->labelledField( |
|
| 380 | + $App->translate('Mandatory field'), |
|
| 381 | + $W->Checkbox(), |
|
| 382 | + __FUNCTION__ |
|
| 383 | + ); |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - public function visible_in_shop() |
|
| 387 | - { |
|
| 388 | - $App = $this->App(); |
|
| 389 | - $W = $this->widgets; |
|
| 386 | + public function visible_in_shop() |
|
| 387 | + { |
|
| 388 | + $App = $this->App(); |
|
| 389 | + $W = $this->widgets; |
|
| 390 | 390 | |
| 391 | - return $this->labelledField( |
|
| 392 | - $App->translate('Visible in online shop'), |
|
| 393 | - $W->Checkbox(), |
|
| 394 | - __FUNCTION__ |
|
| 395 | - ); |
|
| 396 | - } |
|
| 391 | + return $this->labelledField( |
|
| 392 | + $App->translate('Visible in online shop'), |
|
| 393 | + $W->Checkbox(), |
|
| 394 | + __FUNCTION__ |
|
| 395 | + ); |
|
| 396 | + } |
|
| 397 | 397 | } |
@@ -1104,7 +1104,7 @@ discard block |
||
| 1104 | 1104 | $W->SubmitButton() |
| 1105 | 1105 | ->setAjaxAction($confirmedAction) |
| 1106 | 1106 | ->setLabel($App->translate('Delete')) |
| 1107 | - ); |
|
| 1107 | + ); |
|
| 1108 | 1108 | $form->addButton($W->SubmitButton()->setLabel($App->translate('Cancel'))->addClass('widget-close-dialog')); |
| 1109 | 1109 | $page->addItem($form); |
| 1110 | 1110 | |
@@ -1374,8 +1374,8 @@ discard block |
||
| 1374 | 1374 | |
| 1375 | 1375 | |
| 1376 | 1376 | /** |
| 1377 | - * @return string[] |
|
| 1378 | - */ |
|
| 1377 | + * @return string[] |
|
| 1378 | + */ |
|
| 1379 | 1379 | public function getFilterNames() |
| 1380 | 1380 | { |
| 1381 | 1381 | $id = $this->getModelViewDefaultId(); |
@@ -86,122 +86,122 @@ |
||
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @return Widget_Page |
|
| 91 | - */ |
|
| 92 | - public function edit($customfield = null) |
|
| 93 | - {
|
|
| 94 | - $W = bab_Widgets(); |
|
| 95 | - $App = $this->App(); |
|
| 96 | - $Ui = $App->Ui(); |
|
| 97 | - $page = $Ui->Page(); |
|
| 89 | + /** |
|
| 90 | + * @return Widget_Page |
|
| 91 | + */ |
|
| 92 | + public function edit($customfield = null) |
|
| 93 | + {
|
|
| 94 | + $W = bab_Widgets(); |
|
| 95 | + $App = $this->App(); |
|
| 96 | + $Ui = $App->Ui(); |
|
| 97 | + $page = $Ui->Page(); |
|
| 98 | 98 | |
| 99 | - $page->addClass('app-page-editor');
|
|
| 100 | - $page->setTitle($App->translate('Edit custom field'));
|
|
| 99 | + $page->addClass('app-page-editor');
|
|
| 100 | + $page->setTitle($App->translate('Edit custom field'));
|
|
| 101 | 101 | |
| 102 | - if (null !== $customfield) {
|
|
| 103 | - $set = $App->CustomFieldSet(); |
|
| 104 | - $customfield = $set->request($customfield); |
|
| 105 | - } |
|
| 102 | + if (null !== $customfield) {
|
|
| 103 | + $set = $App->CustomFieldSet(); |
|
| 104 | + $customfield = $set->request($customfield); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - $form = $Ui->CustomFieldEditor($customfield); |
|
| 107 | + $form = $Ui->CustomFieldEditor($customfield); |
|
| 108 | 108 | |
| 109 | - $page->addItem($form); |
|
| 109 | + $page->addItem($form); |
|
| 110 | 110 | |
| 111 | - if ($customfield instanceof app_CustomField) {
|
|
| 112 | - $actionsFrame = $page->ActionsFrame(); |
|
| 113 | - $page->addContextItem($actionsFrame); |
|
| 111 | + if ($customfield instanceof app_CustomField) {
|
|
| 112 | + $actionsFrame = $page->ActionsFrame(); |
|
| 113 | + $page->addContextItem($actionsFrame); |
|
| 114 | 114 | |
| 115 | - $actionsFrame->addItem($W->Link($W->Icon($App->translate('Delete'), Func_Icons::ACTIONS_EDIT_DELETE), $this->proxy()->delete($customfield->id)));
|
|
| 116 | - } |
|
| 115 | + $actionsFrame->addItem($W->Link($W->Icon($App->translate('Delete'), Func_Icons::ACTIONS_EDIT_DELETE), $this->proxy()->delete($customfield->id)));
|
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - return $page; |
|
| 119 | - } |
|
| 118 | + return $page; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * @return bool |
|
| 124 | - */ |
|
| 125 | - public function save($customfield = null) |
|
| 126 | - {
|
|
| 127 | - $App = $this->App(); |
|
| 122 | + /** |
|
| 123 | + * @return bool |
|
| 124 | + */ |
|
| 125 | + public function save($customfield = null) |
|
| 126 | + {
|
|
| 127 | + $App = $this->App(); |
|
| 128 | 128 | |
| 129 | - $set = $App->CustomFieldSet(); |
|
| 129 | + $set = $App->CustomFieldSet(); |
|
| 130 | 130 | |
| 131 | - if (empty($customfield['id'])) {
|
|
| 132 | - $record = $set->newRecord(); |
|
| 133 | - } else {
|
|
| 134 | - $record = $set->get($customfield['id']); |
|
| 135 | - } |
|
| 131 | + if (empty($customfield['id'])) {
|
|
| 132 | + $record = $set->newRecord(); |
|
| 133 | + } else {
|
|
| 134 | + $record = $set->get($customfield['id']); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - if ('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']) {
|
|
| 138 | - $enumvalues = array(); |
|
| 139 | - foreach ($customfield['enumvalues'] as $enumkey => $enumvalue) {
|
|
| 140 | - $enumvalues[$enumkey] = $set->enumvalues->input($enumvalue); |
|
| 141 | - } |
|
| 142 | - $record->enumvalues = serialize($enumvalues); |
|
| 143 | - } else {
|
|
| 144 | - $record->enumvalues = ''; |
|
| 145 | - } |
|
| 137 | + if ('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']) {
|
|
| 138 | + $enumvalues = array(); |
|
| 139 | + foreach ($customfield['enumvalues'] as $enumkey => $enumvalue) {
|
|
| 140 | + $enumvalues[$enumkey] = $set->enumvalues->input($enumvalue); |
|
| 141 | + } |
|
| 142 | + $record->enumvalues = serialize($enumvalues); |
|
| 143 | + } else {
|
|
| 144 | + $record->enumvalues = ''; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - unset($customfield['enumvalues']); |
|
| 148 | - $record->setFormInputValues($customfield); |
|
| 147 | + unset($customfield['enumvalues']); |
|
| 148 | + $record->setFormInputValues($customfield); |
|
| 149 | 149 | |
| 150 | - $record->save(); |
|
| 150 | + $record->save(); |
|
| 151 | 151 | |
| 152 | - // refresh target table structure |
|
| 152 | + // refresh target table structure |
|
| 153 | 153 | |
| 154 | - $object = $record->object.'Set'; |
|
| 155 | - $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); |
|
| 154 | + $object = $record->object.'Set'; |
|
| 155 | + $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); |
|
| 156 | 156 | |
| 157 | - $recordSet = $App->$object(); |
|
| 158 | - if (method_exists($recordSet, 'useLang')) {
|
|
| 159 | - // This is necessary if the recordSet constructor uses a setLang(). |
|
| 160 | - // We need to revert to multilang fields before synchronizing. |
|
| 161 | - $recordSet->useLang(false); |
|
| 162 | - } |
|
| 157 | + $recordSet = $App->$object(); |
|
| 158 | + if (method_exists($recordSet, 'useLang')) {
|
|
| 159 | + // This is necessary if the recordSet constructor uses a setLang(). |
|
| 160 | + // We need to revert to multilang fields before synchronizing. |
|
| 161 | + $recordSet->useLang(false); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - $sql = $mysqlbackend->setToSql($recordSet); |
|
| 164 | + $sql = $mysqlbackend->setToSql($recordSet); |
|
| 165 | 165 | |
| 166 | - require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
| 167 | - $synchronize = new bab_synchronizeSql(); |
|
| 168 | - $synchronize->fromSqlString($sql); |
|
| 166 | + require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
| 167 | + $synchronize = new bab_synchronizeSql(); |
|
| 168 | + $synchronize->fromSqlString($sql); |
|
| 169 | 169 | |
| 170 | - return true; |
|
| 171 | - } |
|
| 170 | + return true; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | 175 | * {@inheritDoc}
|
| 176 | 176 | * @see app_CtrlRecord::delete() |
| 177 | 177 | */ |
| 178 | - public function delete($customfield) |
|
| 179 | - {
|
|
| 180 | - $App = $this->App(); |
|
| 181 | - |
|
| 182 | - if (!$customfield) {
|
|
| 183 | - throw new app_AccessException($App->translate('Access denied'));
|
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - $set = $App->CustomFieldSet(); |
|
| 187 | - $record = $set->request($customfield); |
|
| 188 | - $object = $record->object.'Set'; |
|
| 189 | - $set->delete($set->id->is($customfield)); |
|
| 190 | - |
|
| 191 | - $recordSet = $App->$object(); |
|
| 192 | - if (method_exists($recordSet, 'useLang')) {
|
|
| 193 | - // This is necessary if the recordSet constructor uses a setLang(). |
|
| 194 | - // We need to revert to multilang fields before synchronizing. |
|
| 195 | - $recordSet->useLang(false); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); |
|
| 199 | - $sql = $mysqlbackend->setToSql($recordSet); |
|
| 200 | - |
|
| 201 | - require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
| 202 | - $synchronize = new bab_synchronizeSql(); |
|
| 203 | - $synchronize->fromSqlString($sql); |
|
| 204 | - |
|
| 205 | - return true; |
|
| 206 | - } |
|
| 178 | + public function delete($customfield) |
|
| 179 | + {
|
|
| 180 | + $App = $this->App(); |
|
| 181 | + |
|
| 182 | + if (!$customfield) {
|
|
| 183 | + throw new app_AccessException($App->translate('Access denied'));
|
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + $set = $App->CustomFieldSet(); |
|
| 187 | + $record = $set->request($customfield); |
|
| 188 | + $object = $record->object.'Set'; |
|
| 189 | + $set->delete($set->id->is($customfield)); |
|
| 190 | + |
|
| 191 | + $recordSet = $App->$object(); |
|
| 192 | + if (method_exists($recordSet, 'useLang')) {
|
|
| 193 | + // This is necessary if the recordSet constructor uses a setLang(). |
|
| 194 | + // We need to revert to multilang fields before synchronizing. |
|
| 195 | + $recordSet->useLang(false); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); |
|
| 199 | + $sql = $mysqlbackend->setToSql($recordSet); |
|
| 200 | + |
|
| 201 | + require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
| 202 | + $synchronize = new bab_synchronizeSql(); |
|
| 203 | + $synchronize->fromSqlString($sql); |
|
| 204 | + |
|
| 205 | + return true; |
|
| 206 | + } |
|
| 207 | 207 | } |