コード例 #1
0
 protected function viewHelper($formXml, $handler, $formCollection, $tabTitle = 'surname')
 {
     $browserTabId = $this->params()->fromPost('browserTabId', '');
     $id = $this->params('id', false);
     $windowId = $this->params('windowId', false);
     if ($this->params('id', false)) {
         $form = file_get_contents('public/' . $formXml);
         $response = new Response($form);
         if (is_array($formCollection)) {
             $fields = array();
             foreach ($formCollection as $collection) {
                 $fields = array_replace_recursive($fields, $response->getCollection($collection));
             }
         } else {
             $fields = $response->getCollection($formCollection);
         }
         // add
         // the
         // answers
         $fields['fields']['answers'] = array('document' => 'MoveIn4FormPortal\\Document\\FormPortalAnswerDocument', 'fields' => array('data' => 'data', 'formId' => 'formId', 'lang' => 'lang'));
         $data = array('id' => $this->params('id'), 'fields' => $fields['fields'], 'display' => 'true');
         $messageId = $this->_message->addAction($this->defaultQueue, 'getOne', $data, $handler);
         //get the formconfig row to get the filename of the translation xml file
         $data = array('id_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields/answers/formId'), 'fields' => array('translationXml'));
         $formConfig = $this->_message->addAction($this->defaultQueue, 'getOne', $data, 'MoveIn4FormConfig\\Model\\FormConfig');
         $data = array('values' => array('values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields/answers')));
         $formMessageId = $this->_message->addAction($this->defaultQueue, 'getFormUploadFields', $data, 'MoveIn4FormConfig\\Model\\FormConfig');
         $config = $this->getServiceLocator()->get('config');
         $data = array('channel' => array('tab_' . $browserTabId), 'message' => array('windowId' => $windowId, 'viewModelFunction' => array(array('functionName' => 'addTab', 'viewModelFunctionData' => array('tabTitle_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields/' . $tabTitle), 'template' => 'viewTemplate', 'tabClosable' => 'true', 'tabId' => $id, 'tabFunction' => 'view', 'tabData' => array('application' => array('formTranslationXML_attr' => array('xpath' => '//response/action[@id="' . $formConfig . '"]/data/fields/translationXml'), 'files_attr' => array('xpath' => '//response/action[@id="' . $formMessageId . '"]/data/fields'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields'), 'moveIn4FormPortalPDFViewUrlMask' => $config['moveIn4FormPortalPDFViewUrlMask'], 'instanceName' => getenv('APPLICATION_INSTANCE')), 'sections' => array(array('section' => array('template' => 'simpleListSection', 'column' => 1, 'sectionData' => array('title' => 'label_personal_details', 'dataSet' => array(array('structure' => $fields['structure']['person'], 'fields' => array('countryOfBirth', 'dateOfBirth', 'firstName', 'gender', 'placeOfBirth', 'surname', 'title'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')))))), array('section' => array('template' => 'commaListSection', 'column' => 1, 'sectionData' => array('dataSet' => array(array('structure' => $fields['structure']['nationality'], 'parent' => 'nationality', 'fields' => array('nationality'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')))))), array('section' => array('template' => 'photoSection', 'column' => 0, 'sectionData' => array('title' => 'label_personal_details', 'dataSet' => array(array('structure' => $fields['structure']['person2'], 'fields' => array('photo'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')))))), array('section' => array('template' => 'simpleListSection', 'column' => 1, 'sectionData' => array('title' => 'label_contact_details', 'dataSet' => array(array('structure' => $fields['structure']['socialMediaProfile'], 'parent' => 'socialMediaProfile', 'fields' => array('socialMedia', 'url'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')), array('structure' => $fields['structure']['instantMessaging'], 'parent' => 'instantMessaging', 'fields' => array('service', 'userId'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')), array('structure' => $fields['structure']['email'], 'parent' => 'email', 'fields' => array('email'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')), array('structure' => $fields['structure']['phoneNumber'], 'parent' => 'phoneNumber', 'fields' => array('number', 'type'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')), array('structure' => $fields['structure']['address'], 'parent' => 'address', 'fields' => array('city', 'co', 'country', 'createdOn', 'deleted', 'postCode', 'remarks', 'state', 'street1', 'street2'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')))))), array('section' => array('template' => 'simpleListSection', 'column' => 2, 'sectionData' => array('title' => 'label_lead', 'dataSet' => array(array('structure' => $fields['structure']['lead'], 'parent' => 'lead', 'fields' => array('capturedOn', 'generatingTool', 'source1', 'source2'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')))))), array('section' => array('template' => 'simpleListSection', 'column' => 2, 'sectionData' => array('title' => 'label_opportunity', 'dataSet' => array(array('structure' => $fields['structure']['opportunity'], 'parent' => 'opportunity', 'fields' => array('programType', 'program', 'interest', 'lead', 'levelOfEngagement', 'person', 'relevance'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')))))), array('section' => array('template' => 'scocialMessagingSection', 'column' => 0, 'sectionData' => array('title' => 'label_scocal_messagning', 'dataSet' => array(array('structure' => $fields['structure']['instantMessaging'], 'parent' => 'instantMessaging', 'fields' => array('service', 'userId'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')), array('structure' => $fields['structure']['socialMediaProfile'], 'parent' => 'socialMediaProfile', 'fields' => array('socialMedia', 'url'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')))))), array('section' => array('template' => 'tagsSection', 'column' => 0, 'sectionData' => array('title' => 'entity_groups', 'dataSet' => array(array('structure' => $fields['structure']['group'], 'parent' => 'group', 'fields' => array('group'), 'values_attr' => array('xpath' => '//response/action[@id="' . $messageId . '"]/data/fields')))))))))))), 'jsFunction' => 'viewModelFunctions', 'jsClass' => 'knockout');
         $this->_message->addAction('response', 'send', $data, 'SocketResponse');
         $data = array('channel' => array('tab_' . $browserTabId), 'message' => array('file' => 'file_523980f0bdfde-trimformtrans.xml'), 'jsFunction' => 'translate', 'jsClass' => 'translator');
         // $this->_message->addAction('response', 'send', $data,'SocketResponse');
         $this->queue($this->_message);
     }
 }