dbXapp
2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Toggle main menu visibility
Loading...
Searching...
No Matches
dbxContent_sysdata.class.php
Go to the documentation of this file.
1
<?php
2
namespace
dbx\dbxContent_admin;
3
//dbx()->get_system_obj('dbxForm','use');
4
5
use dbx\dbxContent\dbxContent_permalink;
6
7
require_once dirname(__DIR__, 2) .
'/dbxContent/include/dbxContent_bootstrap_sync.php'
;
8
9
10
11
class
dbxContent_sysdata
extends
\dbxObj
{
12
13
14
Public
$oValidator
;
15
Public
$oTPL
;
16
17
18
public
function
__construct
() {
19
$this->oValidator=
dbx
()->get_system_obj(
'dbxValidator'
);
20
$this->oTPL =
dbx
()->get_system_obj(
'dbxTPL'
);
21
}
22
23
function
make_select_data
($data,$id,$name,$parent=
''
) {
24
$select_data=array();
25
$select_data[0]=
'/ '
;
26
if
(is_array($data)) {
27
foreach
($data as $no => $record) {
28
if
(is_array($record)) {
29
if
( isset($record[$id]) && isset($record[$name]) ) {
30
$xid=$record[$id];
31
$xna=$record[$name];
32
if
($parent && isset($record[$parent])) {
33
$pid=$record[$parent];
34
if
($pid==$xid) $pid=0;
35
if
($pid) {
36
while
($pid > 0) {
37
foreach
($data as $no2 => $rec2) {
38
if
($rec2[$id]==$pid) {
39
$xna=$rec2[$name].
' -> '
.$xna;
40
$pid=$rec2[$parent];
41
break
;
42
}
// == $pid
43
}
//foreach
44
}
// while $pid > 0
45
}
// $pid
46
}
// parent
47
$xna=
'/ -> '
.$xna;
48
$select_data[$xid]=$xna;
49
}
// isset $id && $name
50
}
else
{
51
// ?
52
}
53
}
54
}
55
return
$select_data;
56
}
57
58
function
get_select_tpl
($modul,$pfx=
''
) {
59
$select_data=array();
60
$folder=$this->oTPL->get_tpl_dir($modul).
'htm'
;
61
$folder_files=array_diff(scandir($folder), array(
'..'
,
'.'
));
62
foreach
($folder_files as $no => $filename) {
63
$id=substr($filename, 0 , (strrpos($filename,
"."
)));
64
$na=$id;
65
if
($pfx) {
66
if
(substr($na, 0, strlen($pfx)) != $pfx) $id=0;
67
}
68
if
($id) $select_data[$id]=$na;
69
}
70
//dbx_debug("Directory=($folder)",$folder_files);
71
72
return
$select_data;
73
}
74
75
76
77
78
79
80
81
public
function
run
() {
82
83
//return "ich bin die sysdaten";
84
$content=
''
; $ok=
false
;
85
$uid =
dbx
()->user();
86
$rid =
dbx
()->get_modul_var(
'rid'
,0,
'int'
);
87
$view=
dbx
()->get_modul_var(
'dbx_view'
);
88
//dbx_debug("EDIT-CID=($rid) uid=($uid)");
89
90
if
($uid) {
91
//dbx()->set_system_var('dbx_page','admin');
92
$db
=
dbx
()->get_system_obj(
'dbxDB'
);
93
$lng =
dbx
()->get_system_var(
'dbx_lng'
,
'de'
);
94
95
$tab_content = dbx_lng_name(
'content'
, $lng);
96
$tab_folder = $tab_content.
'_folder'
;
97
98
99
$data =
$db
->select1($tab_content,$rid);
100
$data_folder =
$db
->select($tab_folder);
101
$data_folder =$this->
make_select_data
($data_folder,
'id'
,
'name'
,
'parent_id'
);
102
$data_template=$this->
get_select_tpl
(
'dbxContent'
,
'c-'
);
103
104
$options_groups=array();
105
$user_groups=
$db
->select(
'dbxUser_groups'
,
'active = 1'
,
'*'
,
'name'
);
106
foreach
($user_groups as $no => $record) {
107
$id =$record[
'name'
];
108
$group =$record[
'description'
];
109
$options_groups[$id]=$group;
110
}
111
$options_groups[
'zzzz'
]=
'<hr>'
;
// no grops
112
113
$oForm=
dbx
()->get_system_obj(
'dbxForm'
);
114
$oForm->init(
'dbxContent_edit'
,
'form-sysdata'
);
115
$oForm->_data=$data;
116
//$oForm->_action='?dbx_modul=dbxContent_admin&dbx_run1=sysdata&rid='.$rid; // set_action()
117
$oForm->_action=
"?dbx_modul=dbxContent_admin&dbx_run1=content&dbx_run2=edit_sysdata&dbx_view=$view&rid=$rid"
;
118
$oForm->_msg_info =
'Content Sytemdaten bearbeiten'
;
119
$oForm->_msg_success=
'Content gespeichert'
;
120
//$options_select=$oForm->get_select_data('group_read');
121
122
//add_fld($name,$tpl='dd:',$data='dd:',$rules='dd:',$label='dd:',$tooltip='dd:',$msg='dd:',$placeholder='dd:',$class='',$remap='') { //#
123
124
$oForm->add_fld(
'id'
,
'text-label'
);
//#+
125
126
$oForm->add_fld(
'title'
,
'text-label'
);
127
$oForm->add_fld(
'sorter'
,
'text-label'
);
128
$oForm->add_fld(
'keywords'
,
'text-label'
);
129
$oForm->add_fld(
'permalink'
,
'text-label'
);
130
$oForm->add_fld(
'activ'
,
'checkbox-label'
);
131
$oForm->add_fld(
'hits'
,
'text-label'
);
132
133
134
$oForm->add_fld(
'folder'
,
'select-single-label'
,options: $data_folder);
135
$oForm->add_fld(
'template'
,
'select-single-label'
,options: $data_template);
136
$oForm->add_fld(
'group_read'
,
'multi-select'
,options: $options_groups, rules:
'*'
);
//,$options_select);
137
138
139
$observer=
'obs_content_rid'
;
140
$observ[
'name'
] =
'content_rid'
;
141
$observ[
'observ'
] =
'content_rid'
;
142
$observ[
'value'
] = $rid;
143
$observ[
'old'
] = $rid;
144
$oForm->add_obj($observer,
'dbx|observe'
,$observ);
145
$oForm->add_js_call(
'group_read'
,
'multiselect2'
);
146
147
//$oForm->add_js_observe($observer,'dbx_form_{i}',1500);
148
149
if
($oForm->submit()) {
150
//dbx_debug("#FORM-SUBMIT#");
151
if
(!$oForm->errors()) {
// submit && no errors // we ignore warnings
152
//dbx_debug("#FORM-No-Errors");
153
$change=$oForm->changed();
154
$post_permalink = dbxContent_permalink::normalize($_POST[
'permalink'
] ?? ($data[
'permalink'
] ??
''
));
155
$post_folder = (int)($_POST[
'folder'
] ?? ($data[
'folder'
] ?? 0));
156
$post_title = $_POST[
'title'
] ?? ($data[
'title'
] ??
''
);
157
$post_values = array();
158
if
($post_permalink ===
''
) {
159
$post_values[
'permalink'
] = dbxContent_permalink::build(
$db
, $tab_folder, $post_folder, $post_title);
160
$oForm->set_post(
'permalink'
, $post_values[
'permalink'
]);
161
$change = 1;
162
}
163
if
($change) {
164
//dbx_debug("#Form-Change");
165
$ok=$oForm->save_post($tab_content,$rid,$post_values);
166
if
( $ok) $oForm->_msg_success =
'Daten gespeichert'
;
167
if
(!$ok) $oForm->_msg_success =
'Daten konnten nicht gespeichert werden'
;
168
}
else
{
169
//dbx_debug("#Form-NO-Change");
170
$oForm->_msg_success =
'Keine Änderung'
;
171
}
172
}
173
if
($oForm->errors()) {
174
$flds=
''
;
175
$errors=$oForm->_errors;
176
foreach
($errors as $fld => $msg) {
177
$flds.=$fld.
' '
;
178
// code...
179
}
180
$oForm->_msg_error =
"Prüfen sie bitte ihre Eingaben ($flds)"
;
181
182
}
183
}
184
185
$rid=$oForm->_data[
'id'
];
// Value nach dem speichern
186
$oForm->add_obj(
'obs_rid'
,
'dbx|observe'
,
"name=content_rid&value=$rid"
);
// wird von avatar upload überwacht (observed)
187
188
$content= $oForm->run();
189
190
}
191
192
return
$content;
193
}
// run()
194
195
196
}
// class
197
198
?>
dbx\dbxContent_admin\dbxContent_sysdata
Definition
dbxContent_sysdata.class.php:11
dbx\dbxContent_admin\dbxContent_sysdata\make_select_data
make_select_data($data, $id, $name, $parent='')
Definition
dbxContent_sysdata.class.php:23
dbx\dbxContent_admin\dbxContent_sysdata\run
run()
Definition
dbxContent_sysdata.class.php:81
dbx\dbxContent_admin\dbxContent_sysdata\$oValidator
Public $oValidator
Definition
dbxContent_sysdata.class.php:14
dbx\dbxContent_admin\dbxContent_sysdata\__construct
__construct()
Definition
dbxContent_sysdata.class.php:18
dbx\dbxContent_admin\dbxContent_sysdata\get_select_tpl
get_select_tpl($modul, $pfx='')
Definition
dbxContent_sysdata.class.php:58
dbx\dbxContent_admin\dbxContent_sysdata\$oTPL
Public $oTPL
Definition
dbxContent_sysdata.class.php:15
dbxObj
Gemeinsame Basisklasse fuer dbXapp-System-, Modul- und Include-Objekte.
Definition
dbxKernel.php:63
dbx
DBX schema administration.
$db
$db
Definition
run_context_help_provision.php:38
dbx
modules
dbxContent_admin
include
dbxContent_sysdata.class.php
Generated by
1.17.0