Pārlūkot izejas kodu

include basic a form building content element

master
Dom SP pirms 3 gadiem
vecāks
revīzija
9c1da2fc64
3 mainītis faili ar 104 papildinājumiem un 1 dzēšanām
  1. +33
    -1
      app/modules/filesinfolders.php
  2. +70
    -0
      app/views/form.htm
  3. +1
    -0
      routes.cfg

+ 33
- 1
app/modules/filesinfolders.php Parādīt failu

@@ -397,6 +397,38 @@ class FilesInFolders {
$toc);
break;

case 'form':
$token_db = $f3->get('TEMP') . "CEform/";
$form_config_file = sprintf("%s%s.cfg",
ROOT.$this->folder,
$request[1]);

$db = new \DB\Jig($token_db,\DB\Jig::FORMAT_JSON);
$formcall = new \DB\Jig\Mapper($db,'form_calls');
$timestamp = time();
$token = md5($timestamp . $form_config_file . rand(100,999));
$f3->config($form_config_file);
$f3->set('fields',
array_merge(
$f3->get('fields'),
['xss-token'=>[
'type'=>'hidden',
'value'=>$token,
'length'=>strlen($token)
]]
));
$formcall->token = $token;
$formcall->timestamp = $timestamp;
$formcall->form = $form_config_file;
$formcall->save();
$form_view = new \Template;
$new=$form_view->render('form.htm');

break;
case 'box':
array_shift($request); //get rid of identifier
$type = array_shift($request);
@@ -406,7 +438,7 @@ class FilesInFolders {
if (count($body) >= 3) {
$caption = ['normal'=>['cap1' => array_shift($body),
'cap2' => array_shift($body)],
'hover'=> ['cap1' => array_shift($body),
'hover'=> ['cap1' => array_shift($body),
'cap2' => array_shift($body)]];
$caption_html=[];
foreach ($caption as $state => $set) {

+ 70
- 0
app/views/form.htm Parādīt failu

@@ -0,0 +1,70 @@
<form action="{{ @target }}" method="post">
<repeat group="{{ @fields }}" key="{{ @name }}" value="{{ @info }}">
<check if="{{ @info.type == 'text' }}">
<true>
<input
name="{{ @name }}"
id="{{ @name }}"
type="text"
size="{{ @info.length }}"
value="{{ @info.value }}" />
<label for="{{ @name }}">{{ @info.description }}</label><br>
</true>
</check>
<check if="{{ @info.type == 'hidden' }}">
<true>
<input
name="{{ @name }}"
id="{{ @name }}"
type="hidden"
value="{{ @info.value }}"/>
</true>
</check>
<check if="{{ @info.type == 'textarea' }}">
<true>
<textarea
name="{{ @name }}"
id="{{ @name }}"
cols="{{ @info.cols }}"
rows="{{ @info.rows }}" >{{ @info.value }}</textarea>
<label for="{{ @name }}">{{ @info.description }}</label><br>
</true>
</check>
<check if="{{ @info.type == 'checkbox' }}">
<true>
<repeat group="{{ @info.options }}" key="{{ @key }}" value="{{ @val }}">
<input
type="checkbox"
id="{{ sprintf('%s[%s]',@name,@key) }}"
name="{{ sprintf('%s[%s]',@name,@key) }}"
value="true"
{{ is_array(@info.checked) ? in_array(@key,@info.checked) ? 'checked' : '' : !strcmp(@key,@info.checked) ? 'checked' : '' }} />
<label for="{{ sprintf('%s[%s]',@name,@key) }}">
{{ @val }}</label><br>
</repeat>
</true>
</check>
<check if="{{ @info.type == 'radio' }}">
<true>
<repeat group="{{ @info.options }}" key="{{ @key }}" value="{{ @val }}">
<input
type="radio"
id="{{ sprintf('%s-%s',@name,@key) }}"
name="{{ sprintf('%s',@name) }}"
value="true"
{{ is_array(@info.checked) ? in_array(@key,@info.checked) ? 'checked' : '' : !strcmp(@key,@info.checked) ? 'checked' : '' }} />
<label for="{{ sprintf('%s-%s',@name,@key) }}">
{{ @val }}</label>
</repeat>
<br>
</true>
</check>
</repeat>
<button type="submit" >{{ @submit_text ? : 'save' }}</button>
</form>

+ 1
- 0
routes.cfg Parādīt failu

@@ -8,3 +8,4 @@ GET @page: /@page = Controller\Page->index
GET /@level1/@level2 = Controller\Page->secondLevel
GET /@level1/@level2/@level3 = Controller\Page->thirdLevel
GET /@level1/@level2/@level3/@level4 = Controller\Page->fourthLevel
POST /email = Controller\Email->send

Notiek ielāde…
Atcelt
Saglabāt