protected function renderContent()
 {
     $this->renderScripts();
     $mappingFormLayoutUtil = ImportToMappingFormLayoutUtil::make(get_class($this->model), new ZurmoActiveForm(), $this->model->importRulesType, $this->mappableAttributeIndicesAndDerivedTypes);
     $mappingDataMetadataWithRenderedElements = $this->resolveMappingDataMetadataWithRenderedElements($mappingFormLayoutUtil, $this->mappingDataMetadata, $this->model->firstRowIsHeaderRow, $this->model->importRulesType, $this->model->id);
     return MappingFormLayoutUtil::renderMappingDataMetadataWithRenderedElements($mappingDataMetadataWithRenderedElements);
 }
コード例 #2
0
 public function testGetMappableAttributeIndicesAndDerivedTypes()
 {
     $data = ImportModelTestItemImportRules::getMappableAttributeIndicesAndDerivedTypes();
     $compareData = array('boolean' => 'Boolean', 'createdByUser' => 'Created By User', 'createdDateTime' => 'Created Date Time', 'currencyValue' => 'Currency Value', 'date' => 'Date', 'dateTime' => 'Date Time', 'decimal' => 'Decimal', 'dropDown' => 'Drop Down', 'firstName' => 'First Name', 'float' => 'Float', 'FullName' => 'Full Name', 'hasOne' => 'Has One', 'hasOneAlso' => 'Has One Also', 'id' => 'Id', 'ImportModelTestItem3Derived' => 'ImportModelTestItem3', 'integer' => 'Integer', 'lastName' => 'Last Name', 'modifiedByUser' => 'Modified By User', 'modifiedDateTime' => 'Modified Date Time', 'multiDropDown' => 'Multi Drop Down', 'numerical' => 'Numerical', 'owner' => 'Owner', 'phone' => 'Phone', 'primaryAddress__city' => 'Primary Address - City', 'primaryAddress__country' => 'Primary Address - Country', 'primaryAddress__invalid' => 'Primary Address - Invalid', 'primaryAddress__latitude' => 'Primary Address - Latitude', 'primaryAddress__longitude' => 'Primary Address - Longitude', 'primaryAddress__postalCode' => 'Primary Address - Postal Code', 'primaryAddress__state' => 'Primary Address - State', 'primaryAddress__street1' => 'Primary Address - Street 1', 'primaryAddress__street2' => 'Primary Address - Street 2', 'primaryEmail__emailAddress' => 'Primary Email - Email Address', 'primaryEmail__isInvalid' => 'Primary Email - Is Invalid', 'primaryEmail__optOut' => 'Primary Email - Opt Out', 'radioDropDown' => 'Radio Drop Down', 'secondaryEmail__emailAddress' => 'Secondary Email - Email Address', 'secondaryEmail__isInvalid' => 'Secondary Email - Is Invalid', 'secondaryEmail__optOut' => 'Secondary Email - Opt Out', 'string' => 'String', 'tagCloud' => 'Tag Cloud', 'textArea' => 'Text Area', 'url' => 'Url');
     $this->assertEquals(serialize($compareData), serialize($data));
     $mappingFormLayoutUtil = ImportToMappingFormLayoutUtil::make('ImportModelTestItem', new ZurmoActiveForm(), 'ImportModelTestItem', $data);
     $this->assertEquals(serialize($compareData), serialize($mappingFormLayoutUtil->getMappableAttributeIndicesAndDerivedTypesForImportColumns()));
     $compareData2 = array('boolean' => 'Boolean', 'currencyValue' => 'Currency Value', 'date' => 'Date', 'dateTime' => 'Date Time', 'decimal' => 'Decimal', 'dropDown' => 'Drop Down', 'firstName' => 'First Name', 'float' => 'Float', 'FullName' => 'Full Name', 'hasOne' => 'Has One', 'hasOneAlso' => 'Has One Also', 'ImportModelTestItem3Derived' => 'ImportModelTestItem3', 'integer' => 'Integer', 'lastName' => 'Last Name', 'multiDropDown' => 'Multi Drop Down', 'numerical' => 'Numerical', 'owner' => 'Owner', 'phone' => 'Phone', 'primaryAddress__city' => 'Primary Address - City', 'primaryAddress__country' => 'Primary Address - Country', 'primaryAddress__invalid' => 'Primary Address - Invalid', 'primaryAddress__latitude' => 'Primary Address - Latitude', 'primaryAddress__longitude' => 'Primary Address - Longitude', 'primaryAddress__postalCode' => 'Primary Address - Postal Code', 'primaryAddress__state' => 'Primary Address - State', 'primaryAddress__street1' => 'Primary Address - Street 1', 'primaryAddress__street2' => 'Primary Address - Street 2', 'primaryEmail__emailAddress' => 'Primary Email - Email Address', 'primaryEmail__isInvalid' => 'Primary Email - Is Invalid', 'primaryEmail__optOut' => 'Primary Email - Opt Out', 'radioDropDown' => 'Radio Drop Down', 'secondaryEmail__emailAddress' => 'Secondary Email - Email Address', 'secondaryEmail__isInvalid' => 'Secondary Email - Is Invalid', 'secondaryEmail__optOut' => 'Secondary Email - Opt Out', 'string' => 'String', 'tagCloud' => 'Tag Cloud', 'textArea' => 'Text Area', 'url' => 'Url');
     $this->assertEquals(serialize($compareData2), serialize($mappingFormLayoutUtil->getMappableAttributeIndicesAndDerivedTypesForExtraColumns()));
 }
コード例 #3
0
 /**
  * Override to produce a form layout that does not follow the
  * standard form layout for EditView.
  */
 protected function renderFormLayout($form = null)
 {
     assert('$form != null && $form instanceof ZurmoActiveForm');
     $mappingFormLayoutUtil = ImportToMappingFormLayoutUtil::make(get_class($this->model), $form, $this->model->importRulesType, $this->mappableAttributeIndicesAndDerivedTypes);
     $mappingDataMetadataWithRenderedElements = $this->resolveMappingDataMetadataWithRenderedElements($mappingFormLayoutUtil, $this->mappingDataMetadata, $this->model->firstRowIsHeaderRow, $this->model->importRulesType, $this->model->id);
     $headerColumns = $this->getFormLayoutHeaderColumnsContent();
     assert('count($headerColumns) > 0');
     $content = $form->errorSummary($this->model);
     $content .= '<h3>' . Zurmo::t('ImportModule', 'Please map the fields you would like to import.') . '</h3>';
     $content .= $this->renderRequiredAttributesLabelsDataContent();
     $content .= '<table>';
     $content .= '<colgroup>';
     if (count($headerColumns) == 4) {
         $content .= '<col style="width:20%" />';
         $content .= '<col style="width:20%" />';
         $content .= '<col style="width:25%" />';
         $content .= '<col style="width:35%" />';
     } else {
         $content .= '<col style="width:20%" />';
         $content .= '<col style="width:25%" />';
         $content .= '<col style="width:55%" />';
     }
     $content .= '</colgroup>';
     $content .= '<tbody>';
     $content .= '<tr>';
     foreach ($headerColumns as $headerColumnContent) {
         $content .= '<th>' . $headerColumnContent . '</th>';
     }
     $content .= '</tr>';
     $content .= MappingFormLayoutUtil::renderMappingDataMetadataWithRenderedElements($mappingDataMetadataWithRenderedElements);
     $content .= '<tr>';
     $content .= '<td colspan="' . count($headerColumns) . '">';
     $content .= $this->renderAddExtraColumnContent(count($this->mappingDataMetadata));
     $content .= '</td>';
     $content .= '</tr>';
     $content .= '</tbody>';
     $content .= '</table>';
     return $content;
 }
コード例 #4
0
 public function testRenderImportColumnContent()
 {
     $super = SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = $super;
     $data = ImportModelTestItemImportRules::getMappableAttributeIndicesAndDerivedTypes();
     $mappingFormLayoutUtil = ImportToMappingFormLayoutUtil::make('ImportModelTestItem', new ZurmoActiveForm(), 'ImportModelTestItem', $data);
     $sampleValue = 'a';
     $columnName = 'SampleColumnName';
     $content = $mappingFormLayoutUtil->renderImportColumnContent($columnName, $sampleValue);
     $this->assertEquals($content, '<div id="' . $columnName . '-import-data" class="column-import-data" title="' . $sampleValue . '">' . $sampleValue . '</div>');
     $sampleValue = str_repeat('a', 24);
     $content = $mappingFormLayoutUtil->renderImportColumnContent($columnName, $sampleValue);
     $this->assertEquals($content, '<div id="' . $columnName . '-import-data" class="column-import-data" title="' . $sampleValue . '">' . $sampleValue . '</div>');
 }
コード例 #5
0
 /**
  * Step 4 ajax process.  When you change the attribute dropdown, new mapping rule information is retrieved
  * and displayed in the user interface.
  */
 public function actionMappingRulesEdit($id, $attributeIndexOrDerivedType, $columnName, $columnType)
 {
     $import = Import::getById((int) $_GET['id']);
     $importWizardForm = ImportWizardUtil::makeFormByImport($import);
     $importRulesClassName = ImportRulesUtil::getImportRulesClassNameByType($importWizardForm->importRulesType);
     $mappableAttributeIndicesAndDerivedTypes = $importRulesClassName::getMappableAttributeIndicesAndDerivedTypes();
     $mappingFormLayoutUtil = ImportToMappingFormLayoutUtil::make(get_class($importWizardForm), new ZurmoActiveForm(), $importWizardForm->importRulesType, $mappableAttributeIndicesAndDerivedTypes);
     $content = $mappingFormLayoutUtil->renderMappingRulesElements($columnName, $attributeIndexOrDerivedType, $importWizardForm->importRulesType, $columnType, array());
     DropDownUtil::registerScripts(CClientScript::POS_END);
     Yii::app()->getClientScript()->setToAjaxMode();
     Yii::app()->getClientScript()->render($content);
     echo $content;
 }