public function getDate($field_id) { $result = array(); $result = FieldDateTable::instance()->getDateByFieldId($field_id)->toArray(); return $result[0]; }
public function getFieldItems(WorkflowSlotField $field, $type, sfContext $context, $versionid) { $result = array(); $a = 0; switch ($type) { case 'TEXTFIELD': $items = WorkflowSlotFieldTextfieldTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray(); $fieldData = FieldTextfieldTable::instance()->getTextfieldByFieldId($field->getFieldId())->toArray(); $replaceObj = new ReplaceTags($versionid, $items[0]['value'], $this->culture, $context); $value = $replaceObj->getText(); $result['value'] = $value; $result['regex'] = $fieldData[0]['regex']; $result['id'] = $items[0]['id']; break; case 'CHECKBOX': $items = WorkflowSlotFieldCheckboxTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray(); $result['value'] = $items[0]['value']; $result['id'] = $items[0]['id']; break; case 'NUMBER': $items = WorkflowSlotFieldNumberTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray(); $fieldData = FieldNumberTable::instance()->getNumberByFieldId($field->getFieldId())->toArray(); if($fieldData[0]['comboboxvalue'] != 'EMPTY') { $result['emptytext'] = $context->getI18N()->__($fieldData[0]['comboboxvalue'] ,null,'field'); } else { $result['emptytext'] = $fieldData[0]['regex']; } $result['value'] = $items[0]['value']; $result['regex'] = $fieldData[0]['regex']; $result['id'] = $items[0]['id']; break; case 'DATE': $items = WorkflowSlotFieldDateTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray(); $format = FieldDateTable::instance()->getDateByFieldId($field->getFieldId())->toArray(); $result['value'] = $items[0]['value']; $result['dateformat'] = $format[0]['dateformat']; $result['regex'] = $format[0]['regex']; $result['id'] = $items[0]['id']; break; case 'TEXTAREA': $items = WorkflowSlotFieldTextareaTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray(); $textarea = FieldTextareaTable::instance()->getTextareaById($field->getFieldId())->toArray(); $result['value'] = $items[0]['value']; $result['contenttype'] = $textarea[0]['contenttype']; $result['id'] = $items[0]['id']; break; case 'RADIOGROUP': $items = WorkflowSlotFieldRadiogroupTable::instance()->getAllItemsByWorkflowFieldId($field->getId()); foreach($items as $item) { $name = FieldRadiogroupTable::instance()->getRadiogroupItemById($item->getFieldradiogroupId())->toArray(); $result[$a]['value'] = $item->getValue(); $result[$a]['id'] = $item->getId(); $result[$a++]['name'] = $name[0]['value']; } break; case 'CHECKBOXGROUP': $items = WorkflowSlotFieldCheckboxgroupTable::instance()->getAllItemsByWorkflowFieldId($field->getId()); foreach($items as $item) { $name = FieldCheckboxgroupTable::instance()->getCheckboxgroupItemById($item->getFieldcheckboxgroupId())->toArray(); $result[$a]['value'] = $item->getValue(); $result[$a]['id'] = $item->getId(); $result[$a++]['name'] = $name[0]['value']; } break; case 'COMBOBOX': $items = WorkflowSlotFieldComboboxTable::instance()->getAllItemsByWorkflowFieldId($field->getId()); foreach($items as $item) { $name = FieldComboboxTable::instance()->getComboboxItemById($item->getFieldcomboboxId())->toArray(); $result[$a]['value'] = $item->getValue(); $result[$a]['id'] = $item->getId(); $result[$a++]['name'] = $name[0]['value']; } break; case 'FILE': $file = WorkflowSlotFieldFileTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray(); $workflowtemplate = WorkflowVersionTable::instance()->getWorkflowVersionById($versionid)->toArray(); $result['filepath'] = sfConfig::get('sf_upload_dir') . '/' . $workflowtemplate[0]['workflowtemplate_id'] . '/' . $versionid . '/' . $file[0]['hashname'] ; $result['hashname'] = $file[0]['hashname']; $result['filename'] = $file[0]['filename']; $url = $this->serverUrl . '/file/ShowAttachment'; $plainUrl = $this->serverUrl . '/file/ShowAttachment'; $url .= '/workflowid/' . $workflowtemplate[0]['workflowtemplate_id'] . '/versionid/' . $versionid. '/attachmentid/' . $file[0]['id'] . '/file/1'; $plainUrl .= '/workflowid/' . $workflowtemplate[0]['workflowtemplate_id'] . '/versionid/' . $versionid. '/attachmentid/' . $file[0]['id'] . '/file/1'; $result['plainurl'] = $plainUrl; $result['url'] = $url; $result['link'] = '<a href="'.$url.'" target="_blank">'.$result['filename'].'</a>'; break; } return $result; }
/** * Add all fields with its values to the slot. Value depends on the flag if old values are used or not * @param <type> $type * @param <type> $field_id * @param <type> $workflowslotfield_id * @return <type> */ public function getItems($type, $field_id, $workflowslotfield_id) { $result = array(); $a = 0; switch($type) { case 'TEXTFIELD': if($this->newValue == 0) { $data = FieldTextfieldTable::instance()->getTextfieldByFieldId($field_id)->toArray(); $result[0]['value'] = $data[0]['defaultvalue']; return $result; } else { $data = WorkflowSlotFieldTextfieldTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray(); $result[0]['value'] = $data[0]['value']; return $result; } break; case 'CHECKBOX': if($this->newValue == 0) { $result[0]['value'] = 0; return $result; } else { $data = WorkflowSlotFieldCheckboxTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray(); $result[0]['value'] = $data[0]['value']; return $result; } break; case 'NUMBER': if($this->newValue == 0) { $data = FieldNumberTable::instance()->getNumberByFieldId($field_id)->toArray(); $result[0]['value'] = $data[0]['defaultvalue']; return $result; } else { $data = WorkflowSlotFieldNumberTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray(); $result[0]['value'] = $data[0]['value']; return $result; } break; case 'DATE': if($this->newValue == 0) { $data = FieldDateTable::instance()->getDateByFieldId($field_id)->toArray(); $result[0]['value'] = $data[0]['defaultvalue']; return $result; } else { $data = WorkflowSlotFieldDateTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray(); $result[0]['value'] = $data[0]['value']; return $result; } break; case 'TEXTAREA': if($this->newValue == 0) { $data = FieldTextareaTable::instance()->getTextareaByFieldId($field_id)->toArray(); $result[0]['value'] = $data[0]['content']; return $result; } else { $data = WorkflowSlotFieldTextareaTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray(); $result[0]['value'] = $data[0]['value']; return $result; } break; case 'RADIOGROUP': if($this->newValue == 0) { $data = FieldRadiogroupTable::instance()->findRadiogroupByFieldId($field_id)->toArray(); foreach($data as $item) { $result[$a]['value'] = $item['isactive']; $result[$a]['fieldradiogroup_id'] = $item['id']; $result[$a++]['position'] = $item['position']; } return $result; } else { $data = WorkflowSlotFieldRadiogroupTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray(); foreach($data as $item) { $result[$a]['value'] = $item['value']; $result[$a]['fieldradiogroup_id'] = $item['fieldradiogroup_id']; $result[$a++]['position'] = $item['position']; } return $result; } break; case 'CHECKBOXGROUP': if($this->newValue == 0) { $data = FieldCheckboxgroupTable::instance()->findCheckboxgroupByFieldId($field_id)->toArray(); foreach($data as $item) { $result[$a]['value'] = $item['isactive']; $result[$a]['fieldradiogroup_id'] = $item['id']; $result[$a++]['position'] = $item['position']; } return $result; } else { $data = WorkflowSlotFieldCheckboxgroupTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray(); foreach($data as $item) { $result[$a]['value'] = $item['value']; $result[$a]['fieldradiogroup_id'] = $item['fieldcheckboxgroup_id']; $result[$a++]['position'] = $item['position']; } return $result; } break; case 'COMBOBOX': if($this->newValue == 0) { $data = FieldComboboxTable::instance()->findComboboxByFieldId($field_id)->toArray(); foreach($data as $item) { $result[$a]['value'] = $item['isactive']; $result[$a]['fieldradiogroup_id'] = $item['id']; $result[$a++]['position'] = $item['position']; } return $result; } else { $data = WorkflowSlotFieldComboboxTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray(); foreach($data as $item) { $result[$a]['value'] = $item['value']; $result[$a]['fieldradiogroup_id'] = $item['fieldcombobox_id']; $result[$a++]['position'] = $item['position']; } return $result; } break; case 'FILE': $data = WorkflowSlotFieldFileTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray(); return $data; break; } }
/** * update a field * @param sfWebRequest $request * @return <type> */ public function executeUpdateField(sfWebRequest $request) { $fieldType = FieldTable::instance()->getFieldById($request->getParameter('id')); $data = $request->getPostParameters(); $fieldClass = new FieldClass(); $data = $fieldClass->prepareSaveData($data); // prepare the data to save, set color and writeprotected flag FieldTable::instance()->updateFieldById($request->getParameter('id'), $data); switch ($fieldType[0]->getType()) { case 'TEXTFIELD': FieldTextfieldTable::instance()->updateFieldTextfieldById($request->getParameter('id'), $data); break; case 'CHECKBOX': break; case 'NUMBER': FieldNumberTable::instance()->updateFieldNumberById($request->getParameter('id'), $data); break; case 'DATE': FieldDateTable::instance()->updateFieldDateById($request->getParameter('id'), $data); break; case 'TEXTAREA': $data['fieldTextarea_content'] = $data['fieldTextarea_contenttype'] == 'plain' ? $data['fieldTextarea_textarea']: $data['fieldTextarea_htmlarea']; FieldTextareaTable::instance()->updateFieldTextareaById($request->getParameter('id'), $data); break; case 'RADIOGROUP': $fieldClass->saveRadiogroup($request->getParameter('id'), $data); break; case 'CHECKBOXGROUP': $fieldClass->saveCheckboxgroup($request->getParameter('id'), $data); break; case 'COMBOBOX': $fieldClass->saveCombobox($request->getParameter('id'), $data); break; case 'FILE': FieldFileTable::instance()->updateFieldFileById($request->getParameter('id'), $data); break; } $this->renderText('{success:true}'); return sfView::NONE; }