function run($max_time)
 {
     $i18n = new Internationalization('en_US');
     $forms = $i18n->getTemplate('form.yaml')->getData();
     foreach ($forms as $f) {
         DynamicForm::create($f);
     }
 }
Exemplo n.º 2
0
 /**
  * Auto-installer. Necessary for 1.8 users between the RC1 release and
  * the stable release who don't have the form in their database because
  * it wan't in the yaml file for installation or upgrade.
  */
 function __loadDefaultForm()
 {
     require_once INCLUDE_DIR . 'class.i18n.php';
     $i18n = new Internationalization();
     $tpl = $i18n->getTemplate('form.yaml');
     foreach ($tpl->getData() as $f) {
         if ($f['type'] == 'C') {
             $form = DynamicForm::create($f);
             $form->save();
             break;
         }
     }
 }
Exemplo n.º 3
0
         }
         if ($field->get('name')) {
             $names[] = $field->get('name');
         }
         if ($field->isValid()) {
             $form_fields[] = $field;
         } else {
             # notrans (not shown)
             $errors["field-{$id}"] = __('Field has validation errors');
         }
         // Keep track of the last sort number
         $max_sort = max($max_sort, $field->get('sort'));
     }
     break;
 case 'add':
     $form = DynamicForm::create();
     foreach ($fields as $f) {
         if (in_array($f, $required) && !$_POST[$f]) {
             $errors[$f] = sprintf('%s is required', mb_convert_case($f, MB_CASE_TITLE));
         } elseif (isset($_POST[$f])) {
             $form->set($f, $_POST[$f]);
         }
     }
     break;
 case 'mass_process':
     if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
         $errors['err'] = sprintf(__('You must select at least %s'), __('one custom form'));
     } else {
         $count = count($_POST['ids']);
         switch (strtolower($_POST['a'])) {
             case 'delete':
Exemplo n.º 4
0
 static function create($ht = false, &$errors = array())
 {
     $inst = parent::create($ht);
     $inst->set('created', new SqlFunction('NOW'));
     if (isset($ht['properties'])) {
         $inst->save();
         $ht['properties']['type'] = 'L' . $inst->getId();
         $form = DynamicForm::create($ht['properties']);
         $form->save();
     }
     if (isset($ht['configuration'])) {
         $inst->save();
         $c = new Config('list.' . $inst->getId());
         $c->set('configuration', JsonDataEncoder::encode($ht['configuration']));
     }
     if (isset($ht['items'])) {
         $inst->save();
         foreach ($ht['items'] as $i) {
             $i['list_id'] = $inst->getId();
             $item = DynamicListItem::create($i);
             $item->save();
         }
     }
     return $inst;
 }
Exemplo n.º 5
0
 static function __loadDefaultForm()
 {
     require_once INCLUDE_DIR . 'class.i18n.php';
     $i18n = new Internationalization();
     $tpl = $i18n->getTemplate('form.yaml');
     foreach ($tpl->getData() as $f) {
         if ($f['type'] == 'O') {
             $form = DynamicForm::create($f);
             $form->save();
             break;
         }
     }
     if (!$form || !($o = static::objects())) {
         return false;
     }
     // Create sample organization.
     if ($orgs = $i18n->getTemplate('organization.yaml')->getData()) {
         foreach ($orgs as $org) {
             Organization::__create($org);
         }
     }
     return $o[0];
 }
Exemplo n.º 6
0
         } else {
             # notrans (not shown)
             $errors["field-{$id}"] = 'Field has validation errors';
         }
         // Keep track of the last sort number
         $max_sort = max($max_sort, $field->get('sort'));
     }
     break;
 case 'add':
     foreach ($fields as $f) {
         if (in_array($f, $required) && !$_POST[$f]) {
             $errors[$f] = sprintf('%s is required', mb_convert_case($f, MB_CASE_TITLE));
         }
     }
     $list = DynamicList::create(array('name' => $_POST['name'], 'name_plural' => $_POST['name_plural'], 'sort_mode' => $_POST['sort_mode'], 'notes' => $_POST['notes']));
     $form = DynamicForm::create(array('title' => $_POST['name'] . ' Properties'));
     if ($errors) {
         $errors['err'] = 'Unable to create custom list. Correct any error(s) below and try again.';
     } elseif (!$list->save(true)) {
         $errors['err'] = 'Unable to create custom list: Unknown internal error';
     }
     $form->set('type', 'L' . $list->get('id'));
     if (!$errors && !$form->save(true)) {
         $errors['err'] = 'Unable to create properties for custom list: Unknown internal error';
     } else {
         $msg = 'Custom list added successfully';
     }
     break;
 case 'mass_process':
     if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
         $errors['err'] = 'You must select at least one API key';
Exemplo n.º 7
0
<?php

ob_start();
header('Content-type: text/html; charset=utf8');
require '../dynamicForm.php';
$form = new DynamicForm(array('variable' => 'ayarlar', 'file' => 'ayarlar.php', 'path' => realpath('.')));
$form->config(array(array('Kişisel Bilgiler'), array('name' => 'adsoyad', 'text' => 'Adınız ve soyadınız!'), array('name' => 'eposta', 'text' => 'E-posta adresini yazın!', 'desc' => 'Geçerli bir eposta adresi girin!'), array('name' => 'telefon', 'text' => 'Telefon numarası'), array('name' => 'web', 'text' => 'Site adresi'), array('name' => 'hakkinda', 'text' => 'Bir şeyler söyleyin', 'field' => 'textarea'), array('Sosyal Bilgiler'), array('name' => 'facebook', 'text' => 'Facebook Adresiniz'), array('name' => 'twitter', 'text' => 'Twitter Adresiniz'), array('name' => 'youtube', 'text' => 'Youtube Adresiniz')));
?>

<form action="" method="post">
    <?php 
$form->create();
?>
    <input type="submit" name="submit" value="Kaydet" />
</form>

<?php 
if (isset($_POST['submit'])) {
    $form->update();
    header('Location:admin.php');
}