dbXapp 2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Loading...
Searching...
No Matches
dbxTplEdit.class.php
Go to the documentation of this file.
1<?php
2namespace dbx\dbxAdmin;
3
4Class dbxTplEdit {
5
6 private function save_tpl($type,$modul,$file,$design,$lng,$tpl) {
7 //dbx_debug("SAVE-TPL T=($type) M=($modul) F=($file) D=($design) L=($lng)");
8 $file_type=$file.'.'.$type;
9 //if ($modul == 'dbx') $dir_file=dbx_get_base_dir()."dbx/tpl/$type/$file_type";
10 //if ($modul != 'dbx')
11 $dir_file=dbx_get_base_dir()."dbx/modules/$modul/tpl/$type/$file_type";
12 $dir_file=dbx_os_path_file($dir_file);
13 file_put_contents($dir_file,$tpl);
14 return $dir_file;
15 }
16
17
18 public function run($rid=0) {
19 $content=''; $ok=false;
20 $uid =dbx()->user();
21 $modul =dbx()->get_request_var('modul' ,'' ,'parameter');
22 $type =dbx()->get_request_var('type' ,'htm','parameter');
23 $file =dbx()->get_request_var('tpl' ,'' ,'parameter');
24 $oTPL =dbx()->get_system_obj('dbxTPL');
25
26 dbx()->set_system_var('dbx_page' ,'_tpledit');
27 dbx()->set_system_var('dbx_editor',1);
28
29 //dbx_debug("#### EDIT#### Uid=($uid) Type=($type) Modul=($modul) File=($file) ");
30 //return "edit=$file";
31
32 $tpl=$oTPL->read_tpl($modul,$file,$type);
33
34 //dbx_debug("#tpl ($modul,$file,$type)",$tpl);
35
36 $data['tpl'] = $tpl;
37 $data['file'] = $file;
38 $data['modul'] = $modul;
39
40
41 $oForm=dbx()->get_system_obj('dbxForm');
42 $oForm->init('form-tpl-edit');
43
44 $oForm->_data = $data;
45 $oForm->_action ='?dbx_modul=dbxAdmin&dbx_run1=_edittpl'; // &modul='.$modul.'&file='.$file.'&design='.$design.'&lng='.$lng;
46 $oForm->_msg_info = 'TPL: '.$modul.'/'.$file.'.'.$type;
47 //$oForm->_editor_fld='tpl';
48
49 $oForm->add_fld('modul' ,'text-label' ,rules: 'parameter' ,label: 'TPL-Modul');
50 $oForm->add_fld('file' ,'text-label' ,rules: 'parameter' ,label: 'TPL-File');
51 $oForm->add_fld('tpl' ,'textarea-tpl' ,rules: '*' ,label: 'TPL-Content',data: 'rows=22');
52 $oForm->add_obj('button_save','dbx|button-submit','label=Speichern'); //#+
53
54
55 $oForm->add_js_call('tpl','editor-ace'); // -ace
56
57 if($oForm->submit()) {
58 if($oForm->changed()) { // submit && no errors // we ignore warnings
59 $tpl =$oForm->get_post('tpl','','*');
60 $file =$oForm->get_post('file');
61 $design=$oForm->get_post('design');
62 $lng =$oForm->get_post('lng');
63 if (!$oForm->errors()) {
64 $path_file=$this->save_tpl($type,$modul,$file,$design,$lng,$tpl);
65 if (!$path_file) $oForm->_msg_error = '#error_save_data#';
66 if ( $path_file) {
67 $oForm->_msg_success = "Save: ($path_file)";
68 }
69 } else {
70 $oForm->_msg_success = '#no_change#';
71 }
72 } else {
73 $oForm->_msg_errr = '#check_input#';
74 }
75 }
76 $content= $oForm->run();
77 $content=dbx()->norep($content);
78 dbx()->set_system_var('dbx_editor',0);
79
80 //dbx_debug("#RETURN-CONTENT=",$content);
81
82
83 return $content;
84 } // run()
85
86
87}
88
89?>
dbx_os_path_file($path_file)
Definition index.php:164
$path_file
Definition index.php:270
dbx_get_base_dir($cut_Data=0)
Definition index.php:157