function run($max_time) { $i18n = new Internationalization('en_US'); $forms = $i18n->getTemplate('form.yaml')->getData(); foreach ($forms as $f) { DynamicForm::create($f); } }
function getOptions() { $form_choices = array('0' => '--None--'); foreach (DynamicForm::objects()->filter(array('type' => 'G')) as $group) { $form_choices[$group->get('id')] = $group->get('title'); } return array('equipment_backend_enable' => new BooleanField(array('id' => 'equipment_backend_enable', 'label' => 'Enable Backend', 'configuration' => array('desc' => 'Staff backend interface'))), 'equipment_frontend_enable' => new BooleanField(array('id' => 'equipment_frontend_enable', 'label' => 'Enable Frontend', 'configuration' => array('desc' => 'Client facing interface'))), 'equipment_custom_form' => new ChoiceField(array('id' => 'equipment_custom_form', 'label' => 'Custom Form Name', 'choices' => $form_choices, 'configuration' => array('desc' => 'Custom form to use for equipment')))); }
function getForm($form_id) { $form = DynamicForm::lookup($form_id); if (!$form) { return; } foreach ($form->getFields() as $field) { $field->render(); } }
/** * 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; } } }
function updateForms($ticket_id) { global $thisstaff; if (!$thisstaff) { Http::response(403, "Login required"); } elseif (!($ticket = Ticket::lookup($ticket_id))) { Http::response(404, "No such ticket"); } elseif (!$ticket->checkStaffAccess($thisstaff)) { Http::response(403, "Access Denied"); } elseif (!isset($_POST['forms'])) { Http::response(422, "Send updated forms list"); } // Add new forms $forms = DynamicFormEntry::forTicket($ticket_id); foreach ($_POST['forms'] as $sort => $id) { $found = false; foreach ($forms as $e) { if ($e->get('form_id') == $id) { $e->set('sort', $sort); $e->save(); $found = true; break; } } // New form added if (!$found && ($new = DynamicForm::lookup($id))) { $f = $new->instanciate(); $f->set('sort', $sort); $f->setTicketId($ticket_id); $f->save(); } } // Deleted forms foreach ($forms as $idx => $e) { if (!in_array($e->get('form_id'), $_POST['forms'])) { $e->delete(); } } Http::response(201, 'Successfully managed'); }
function getForm() { if (!isset($this->_form)) { $this->_form = DynamicForm::lookup($this->get('form_id')); if ($this->_form && isset($this->id)) { $this->_form->data($this); } } return $this->_form; }
function getForm() { $form = DynamicForm::lookup($this->get('form_id')); if ($form) { if (isset($this->id)) { $form->data($this); } if ($this->errors()) { $form->addErrors($this->errors(), true); } } return $form; }
public function openNewTicketAction() { $id = $_POST['id']; if (isset($id)) { $item = new \model\Equipment($id); if (isset($item)) { $form_id = $item->getTicketFormId(); $form = \DynamicForm::lookup($form_id); if (isset($form)) { $data_id = $form->getField('asset_id')->getWidget()->name; $_SESSION[':form-data'] = array($data_id => $item->getAsset_id()); header("Location: " . OST_WEB_ROOT . "scp/tickets.php?a=open"); die; } } } }
$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': $i = 0; foreach ($_POST['ids'] as $k => $v) { if (($t = DynamicForm::lookup($v)) && $t->delete()) { $i++; } } if ($i && $i == $count) { $msg = sprintf(__('Successfully deleted %s'), _N('selected custom form', 'selected custom forms', $count)); } elseif ($i > 0) { $warn = sprintf(__('%1$d of %1$d %3$s deleted'), $i, $count, _N('selected custom form', 'selected custom forms', $count)); } elseif (!$errors['err']) { $errors['err'] = sprintf(__('Unable to delete %s'), _N('selected custom form', 'selected custom forms', $count)); } break; } } break; }
function getForm() { if (!$this->_form && $this->_list) { $this->_form = DynamicForm::lookup(array('type' => 'L' . $this->_list->getId())); } return $this->_form; }
} 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';
<?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'); }
<select name="new-form" onchange="javascript: var $sel = $(this).find('option:selected'); $('#ticket-entries').append($('<div></div>').addClass('sortable row-item') .text(' '+$sel.text()) .data('id', $sel.val()) .prepend($('<i>').addClass('icon-reorder')) .append($('<input/>').attr({name:'forms[]', type:'hidden'}).val($sel.val())) .append($('<div></div>').addClass('button-group') .append($('<div></div>').addClass('delete') .append($('<a href=\'#\'>').append($('<i>').addClass('icon-trash'))) )) ); $sel.prop('disabled',true);"> <option selected="selected" disabled="disabled"><?php echo __('Add a form'); ?></option> <?php foreach (DynamicForm::objects()->filter(array( 'type'=>'G')) as $f ) { if (in_array($f->get('id'), $current_list)) continue; ?><option value="<?php echo $f->get('id'); ?>"><?php echo $f->getTitle(); ?></option><?php } ?> </select> <div id="delete-warning" style="display:none"> <hr> <div id="msg_warning"><?php echo __( 'Clicking <strong>Save Changes</strong> will permanently delete data associated with the deleted forms' ); ?> </div> </div>
</select> <i class="help-tip icon-question-sign" href="#parent_topic"></i> <span class="error"> <?php echo $errors['pid']; ?></span> </td> </tr> <tr><th colspan="2"><em><?php echo __('New ticket options');?></em></th></tr> <tr> <td><strong><?php echo __('Custom Form'); ?></strong>:</td> <td><select name="form_id"> <option value="0" <?php if ($info['form_id'] == '0') echo 'selected="selected"'; ?>>— <?php echo __('None'); ?> —</option> <option value="<?php echo Topic::FORM_USE_PARENT; ?>" <?php if ($info['form_id'] == Topic::FORM_USE_PARENT) echo 'selected="selected"'; ?>>— <?php echo __('Use Parent Form'); ?> —</option> <?php foreach (DynamicForm::objects()->filter(array('type'=>'G')) as $group) { ?> <option value="<?php echo $group->get('id'); ?>" <?php if ($group->get('id') == $info['form_id']) echo 'selected="selected"'; ?>> <?php echo $group->get('title'); ?> </option> <?php } ?> </select> <span class="error"> <?php echo $errors['form_id']; ?></span> <i class="help-tip icon-question-sign" href="#custom_form"></i> </td> </tr> <tr> <td width="180" class="required"> <?php echo __('Department'); ?>: </td>
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]; }
function updateForms($user_id) { global $thisstaff; if (!$thisstaff) { Http::response(403, "Login required"); } elseif (!($user = User::lookup($user_id))) { Http::response(404, "No such customer"); } elseif (!isset($_POST['forms'])) { Http::response(422, "Send updated forms list"); } // Add new forms $forms = DynamicFormEntry::forUser($user_id); foreach ($_POST['forms'] as $sort => $id) { $found = false; foreach ($forms as $e) { if ($e->get('form_id') == $id) { $e->set('sort', $sort); $e->save(); $found = true; break; } } // New form added if (!$found && ($new = DynamicForm::lookup($id))) { $user->addForm($new, $sort); } } // Deleted forms foreach ($forms as $idx => $e) { if (!in_array($e->get('form_id'), $_POST['forms'])) { $e->delete(); } } Http::response(201, 'Successfully managed'); }
<thead> <tr> <th width="7"> </th> <th><?php echo __('Custom Forms'); ?> </th> <th><?php echo __('Last Updated'); ?> </th> </tr> </thead> <tbody> <?php foreach (DynamicForm::objects()->filter(array('type' => 'G'))->order_by('title')->limit($pageNav->getLimit())->offset($pageNav->getStart()) as $form) { $sel = false; if ($ids && in_array($form->get('id'), $ids)) { $sel = true; } ?> <tr> <td><?php if ($form->isDeletable()) { ?> <input type="checkbox" class="ckb" name="ids[]" value="<?php echo $form->get('id'); ?> " <?php echo $sel ? 'checked="checked"' : '';
function getForm() { $id = $this->getFormId(); if ($id == self::FORM_USE_PARENT && ($p = $this->getParent())) { $this->form = $p->getForm(); } elseif ($id && !$this->form) { $this->form = DynamicForm::lookup($id); } return $this->form; }
.text(' '+$sel.text()) .data('id', $sel.val()) .prepend($('<i>').addClass('icon-reorder')) .append($('<input/>').attr({name:'forms[]', type:'hidden'}).val($sel.val())) .append($('<div></div>').addClass('button-group') .append($('<div></div>').addClass('delete') .append($('<a href=\'#\'>').append($('<i>').addClass('icon-trash'))) )) ); $sel.prop('disabled',true);"> <option selected="selected" disabled="disabled"><?php echo __('Add a form'); ?> </option> <?php foreach (DynamicForm::objects()->filter(array('type' => 'G')) as $f) { if (in_array($f->get('id'), $current_list)) { continue; } ?> <option value="<?php echo $f->get('id'); ?> "><?php echo $f->getTitle(); ?> </option><?php } ?> </select> <div id="delete-warning" style="display:none">
function getConfigurationForm() { if (!$this->_form) { $this->_form = DynamicForm::lookup(array('type' => 'L' . $this->get('list_id'))); } return $this->_form; }
public static function saveDynamicData($form_id, $id, $data) { if (intval($id) > 0) { $form = \DynamicForm::lookup($form_id); if (isset($form)) { $form_entry = static::getDynamicData($id); $one = $form_entry->one(); if (isset($one)) { $one->getSaved(); } else { $one = $form->instanciate(); $one->set('object_type', 'E'); $one->setObjectId($id); } $one->setSource($data); $one->save(); } } }