diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 2aeacc7ac46bdbc73f151fecb4bd11ce3dc57823..7c9e84b515d9eae4be05c2f87a4df56a2ae9e665 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -1392,9 +1392,10 @@ class SelectionField extends FormField { } class TypeaheadSelectionWidget extends ChoicesWidget { - function render($how) { - if ($how == 'search') - return parent::render($how); + function render($options=array()) { + + if ($options['mode'] == 'search') + return parent::render($options); $name = $this->getEnteredValue(); $config = $this->field->getConfiguration(); diff --git a/include/class.forms.php b/include/class.forms.php index 048a05e4ef3abe8e7489d47a17f07826e3a4dd8d..9b86046926406355a24d70ba72f6a1869cbe7c38 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -654,15 +654,15 @@ class FormField { return array(); } - function render($mode=null) { - $rv = $this->getWidget()->render($mode); + function render($options=array()) { + $rv = $this->getWidget()->render($options); if ($v = $this->get('visibility')) { $v->emitJavascript($this); } return $rv; } - function renderExtras($mode=null) { + function renderExtras($options=array()) { return; } @@ -2131,7 +2131,7 @@ class Widget { class TextboxWidget extends Widget { static $input_type = 'text'; - function render($mode=false) { + function render($options=array()) { $config = $this->field->getConfiguration(); if (isset($config['size'])) $size = "size=\"{$config['size']}\""; @@ -2173,7 +2173,7 @@ class PasswordWidget extends TextboxWidget { } class TextareaWidget extends Widget { - function render($mode=false) { + function render($options=array()) { $config = $this->field->getConfiguration(); $class = $cols = $rows = $maxlength = ""; if (isset($config['rows'])) @@ -2202,7 +2202,7 @@ class TextareaWidget extends Widget { } class PhoneNumberWidget extends Widget { - function render($mode=false) { + function render($options=array()) { $config = $this->field->getConfiguration(); list($phone, $ext) = explode("X", $this->value); ?> @@ -2230,7 +2230,9 @@ class PhoneNumberWidget extends Widget { } class ChoicesWidget extends Widget { - function render($mode=false) { + function render($options=array()) { + + $mode = isset($options['mode']) ? $options['mode'] : null; if ($mode == 'view') { if (!($val = (string) $this->field)) @@ -2334,7 +2336,7 @@ class CheckboxWidget extends Widget { $this->name = '_field-checkboxes'; } - function render($mode=false) { + function render($options=array()) { $config = $this->field->getConfiguration(); if (!isset($this->value)) $this->value = $this->field->get('default'); @@ -2363,7 +2365,7 @@ class CheckboxWidget extends Widget { } class DatetimePickerWidget extends Widget { - function render($mode=false) { + function render($options=array()) { global $cfg; $config = $this->field->getConfiguration(); @@ -2440,7 +2442,7 @@ class DatetimePickerWidget extends Widget { } class SectionBreakWidget extends Widget { - function render($mode=false) { + function render($options=array()) { ?><div class="form-header section-break"><h3><?php echo Format::htmlchars($this->field->getLocal('label')); ?></h3><em><?php echo Format::htmlchars($this->field->getLocal('hint')); @@ -2450,17 +2452,18 @@ class SectionBreakWidget extends Widget { } class ThreadEntryWidget extends Widget { - function render($client=null) { + function render($options=array()) { global $cfg; $object_id = false; - if (!$client) { - $namespace = 'ticket.staff'; - } - else { - $namespace = 'ticket.client'; - $object_id = substr(session_id(), -12); + if ($options['client']) { + $namespace = $options['draft-namespace'] + ?: 'ticket.client'; + $object_id = substr(session_id(), -12); + } else { + $namespace = $options['draft-namespace'] ?: 'ticket.staff'; } + list($draft, $attrs) = Draft::getDraftAndDataAttrs($namespace, $object_id, $this->value); ?> <span class="required"><?php @@ -2478,7 +2481,7 @@ class ThreadEntryWidget extends Widget { return; $attachments = $this->getAttachments($config); - print $attachments->render($client); + print $attachments->render($options); foreach ($attachments->getMedia() as $type=>$urls) { foreach ($urls as $url) Form::emitMedia($url, $type); @@ -2506,7 +2509,7 @@ class FileUploadWidget extends Widget { ), ); - function render($how) { + function render($options) { $config = $this->field->getConfiguration(); $name = $this->field->getFormName(); $id = substr(md5(spl_object_hash($this)), 10); @@ -2608,7 +2611,7 @@ class FreeTextField extends FormField { } class FreeTextWidget extends Widget { - function render($mode=false) { + function render($options=array()) { $config = $this->field->getConfiguration(); ?><div class=""><h3><?php echo Format::htmlchars($this->field->getLocal('label')); diff --git a/include/client/templates/dynamic-form.tmpl.php b/include/client/templates/dynamic-form.tmpl.php index 0672b2263829dea6aa804a6345c2c2489ff84c61..14bcf5432cff883ab27b256b52d650d962a5eb08 100644 --- a/include/client/templates/dynamic-form.tmpl.php +++ b/include/client/templates/dynamic-form.tmpl.php @@ -37,12 +37,12 @@ <br/> <?php } - $field->render('client'); + $field->render(array('client'=>true)); ?></label><?php foreach ($field->errors() as $e) { ?> <div class="error"><?php echo $e; ?></div> <?php } - $field->renderExtras('client'); + $field->renderExtras(array('client'=>true)); ?> </td> </tr> diff --git a/include/client/view.inc.php b/include/client/view.inc.php index 8e3aa3fcf49e1828ff7766ec3374c1d76f3a1da3..4c93a7b3bcb5b21eeac0657c1ccaf84ebe133b53 100644 --- a/include/client/view.inc.php +++ b/include/client/view.inc.php @@ -184,7 +184,7 @@ if (!$ticket->isClosed() || $ticket->isReopenable()) { ?> <?php if ($messageField->isAttachmentsEnabled()) { ?> <?php - print $attachments->render(true); + print $attachments->render(array('client'=>true)); ?> <?php } ?> diff --git a/include/staff/templates/dynamic-form.tmpl.php b/include/staff/templates/dynamic-form.tmpl.php index b0a3d7d47457eaffb4bc2998a4994ae0ca557aef..487ce9a56f863a735abe6808f29a95c56bf2dc9f 100644 --- a/include/staff/templates/dynamic-form.tmpl.php +++ b/include/staff/templates/dynamic-form.tmpl.php @@ -56,7 +56,7 @@ if (isset($options['entry']) && $options['mode'] == 'edit') { ?> <?php echo Format::htmlchars($field->getLocal('label')); ?>:</td> <td><div style="position:relative"><?php } - $field->render(); ?> + $field->render($options); ?> <?php if (!$field->isBlockLevel() && $field->isRequiredForStaff()) { ?> <span class="error">*</span> <?php diff --git a/include/staff/templates/list-item-properties.tmpl.php b/include/staff/templates/list-item-properties.tmpl.php index df6487fd814857d2ffac204829a59110b4a57b03..def77747a2bea226a3e73bece150c380aea696bd 100644 --- a/include/staff/templates/list-item-properties.tmpl.php +++ b/include/staff/templates/list-item-properties.tmpl.php @@ -29,7 +29,7 @@ </div><div> <?php if ($internal && !$f->isEditable()) - $f->render('view'); + $f->render(array('mode'=>'view')); else { $f->render(); if ($f->get('required')) { ?>