-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAcfConfigDefault.php
More file actions
66 lines (58 loc) · 1.7 KB
/
Copy pathAcfConfigDefault.php
File metadata and controls
66 lines (58 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php namespace ProcessWire;
/**
* AcfConfigLegacy (AcfConfig module)
*
* Admin Custom Files (ProcessWire 3.x)
* Copyright (C) 2018 by Martijn Geerts
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
*/
class AcfConfigDefault extends AcfConfig implements Module {
/**
* Required jsConfig method
*
* @return array
*/
public function jsConfig() {
$user = $this->wire('user');
$config = $this->wire('config');
$process = $this->wire('process');
$array = array(
'host' => $config->httpHost,
'process' => $process->className(),
'adminTheme' => $this->adminCustomFiles->getThemeName(),
'user' => array(),
'roles' => array(),
'permissions' => array(),
);
foreach($user->template->fieldgroup as $field) {
$value = $user->get($field->name);
$array['user'][$field->name] = $field->type->___exportValue($user, $field, $value);
}
foreach ($user->roles as $role) {
$array['roles'][] = $role->name;
foreach ($role->permissions->each(['name', 'title']) as $arrayrray) {
$array['permissions'][$arrayrray['name']] = $arrayrray['title'];
}
}
if ($process instanceof ProcessPageEdit) {
$page = $process->getPage();
$array['template'] = $page->template->name;
$fields = array();
foreach ($page->template->fields as $field) $fields[$field->name] = $field->data;
$array['fields'] = $fields;
$array['page'] = array(
'id' => $page->id,
'name' => $page->name,
'path' => $page->path,
'parentID' => $page->parentID,
'numChildren' => $page->numChildren,
'created' => $page->created,
'modified' => $page->modified,
'createdUser' => $page->createdUser->name,
'modifiedUser' => $page->modifiedUser->name,
);
}
return $array;
}
}