• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Import类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Import的典型用法代码示例。如果您正苦于以下问题:PHP Import类的具体用法?PHP Import怎么用?PHP Import使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Import类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testImportDataAnalysisResults

 public function testImportDataAnalysisResults()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $import = new Import();
     $serializedData['importRulesType'] = 'Users';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.users.tests.unit.files'));
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'username', 'type' => 'importColumn', 'mappingRulesData' => array()), 'column_1' => array('attributeIndexOrDerivedType' => 'Password', 'type' => 'importColumn', 'mappingRulesData' => array('PasswordDefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_2' => array('attributeIndexOrDerivedType' => 'UserStatus', 'type' => 'importColumn', 'mappingRulesData' => array('UserStatusDefaultValueMappingRuleForm' => array('defaultValue' => UserStatusUtil::ACTIVE))));
     $serializedData = unserialize($import->serializedData);
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $importRules = ImportRulesUtil::makeImportRulesByType('Users');
     $config = array('pagination' => array('pageSize' => 2));
     //This test csv has a header row.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     //Run data analyzer
     $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider);
     foreach ($mappingData as $columnName => $columnMappingData) {
         $importDataAnalyzer->analyzeByColumnNameAndColumnMappingData($columnName, $columnMappingData);
     }
     $messagesData = $importDataAnalyzer->getMessagesData();
     $compareData = array('column_0' => array(array('message' => '1 value(s) are too large for this field. These values will be truncated to a length of 64 upon import.', 'sanitizerUtilType' => 'Truncate', 'moreAvailable' => false)), 'column_1' => array(array('message' => '1 value(s) are too large for this field. These values will be truncated to a length of 32 upon import.', 'sanitizerUtilType' => 'Truncate', 'moreAvailable' => false)), 'column_2' => array(array('message' => '2 user status value(s) are not valid. Users that have these values will be set to active upon import.', 'sanitizerUtilType' => 'UserStatus', 'moreAvailable' => false)));
     $this->assertEquals($compareData, $messagesData);
     $importInstructionsData = $importDataAnalyzer->getImportInstructionsData();
     $compareInstructionsData = array();
     $this->assertEquals($compareInstructionsData, $importInstructionsData);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:30,代码来源:UsersImportDataAnalyzerTest.php


示例2: import

 public function import()
 {
     $page = new AdminPage();
     $panel = new Import();
     $page->addToContainer(1, $panel->getHtml());
     $page->pagePrint();
 }
开发者ID:remarco-mif,项目名称:ppos,代码行数:7,代码来源:ManageAdmin.php


示例3: testProcessStatusAndMessagesForEachRow

 public function testProcessStatusAndMessagesForEachRow()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $testTableName = $import->getTempTableName();
     $this->assertTrue(ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $testTableName));
     $count = ImportDatabaseUtil::getCount($testTableName);
     $this->assertEquals(5, $count);
     //Now add import results.
     $resultsUtil = new ImportResultsUtil($import);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(2);
     $rowDataResultsUtil->setStatusToUpdated();
     $rowDataResultsUtil->addMessage('the first message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(3);
     $rowDataResultsUtil->setStatusToCreated();
     $rowDataResultsUtil->addMessage('the second message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(4);
     $rowDataResultsUtil->setStatusToError();
     $rowDataResultsUtil->addMessage('the third message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $resultsUtil->processStatusAndMessagesForEachRow();
     $sql = 'select * from ' . $testTableName . ' where id != 1';
     $tempTableData = R::getAll($sql);
     $compareData = array(array('id' => 2, 'column_0' => 'abc', 'column_1' => '123', 'column_2' => 'a', 'status' => 1, 'serializedmessages' => serialize(array('the first message'))), array('id' => 3, 'column_0' => 'def', 'column_1' => '563', 'column_2' => 'b', 'status' => 2, 'serializedmessages' => serialize(array('the second message'))), array('id' => 4, 'column_0' => 'efg', 'column_1' => '456', 'column_2' => 'a', 'status' => 3, 'serializedmessages' => serialize(array('the third message'))), array('id' => 5, 'column_0' => 'we1s', 'column_1' => null, 'column_2' => 'b', 'status' => null, 'serializedmessages' => null));
     $this->assertEquals($compareData, $tempTableData);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:31,代码来源:ImportResultsUtilTest.php


示例4: testSequentialProcessViewFactory

 public function testSequentialProcessViewFactory()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'string', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_1' => array('attributeIndexOrDerivedType' => 'phone', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))));
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName());
     $config = array('pagination' => array('pageSize' => 2));
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $sequentialProcess = new ImportDataAnalysisSequentialProcess($import, $dataProvider);
     $sequentialProcess->run(null, null);
     $route = 'default/someAction';
     $view = SequentialProcessViewFactory::makeBySequentialProcess($sequentialProcess, $route);
     $content = $view->render();
     $this->assertNotNull($content);
     $this->assertEquals('SequentialProcessView', get_class($view));
     //Now process the first run. Will process page 0.
     $sequentialProcess = new ImportDataAnalysisSequentialProcess($import, $dataProvider);
     $sequentialProcess->run('processColumns', null);
     $route = 'default/someAction';
     $view = SequentialProcessViewFactory::makeBySequentialProcess($sequentialProcess, $route);
     $content = $view->render();
     $this->assertNotNull($content);
     $this->assertEquals('SequentialProcessView', get_class($view));
     $this->assertEquals(array('columnNameToProcess' => 'column_1'), $sequentialProcess->getNextParams());
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:29,代码来源:ImportDataAnalysisSequentialProcessTest.php


示例5: testRun

 public function testRun()
 {
     $quote = DatabaseCompatibilityUtil::getQuote();
     //Create 2 imports, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true);
     $modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
     $sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $import->getClassId('Item');
     ZurmoRedBean::exec($sql);
     $staleImportId = $import->id;
     $import2 = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import2->serializedData = serialize($serializedData);
     $this->assertTrue($import2->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import2->getTempTableName(), true);
     $this->assertEquals(2, Import::getCount());
     $tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
     $this->assertTrue($tableExists);
     $job = new ImportCleanupJob();
     $this->assertTrue($job->run());
     $tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
     $this->assertFalse($tableExists);
     $imports = Import::getAll();
     $this->assertEquals(1, count($imports));
     $this->assertEquals($import2->id, $imports[0]->id);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:29,代码来源:ImportCleanupJobTest.php


示例6: testImportDataAnalysisResults

 public function testImportDataAnalysisResults()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $import = new Import();
     $serializedData['importRulesType'] = 'Contacts';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.contacts.tests.unit.files'));
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'ContactState', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultStateId' => null))));
     $serializedData = unserialize($import->serializedData);
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $importRules = ImportRulesUtil::makeImportRulesByType('Contacts');
     $config = array('pagination' => array('pageSize' => 15));
     //This test csv has a header row.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     //Run data analyzer
     $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider, $mappingData, array('column_0'));
     $importDataAnalyzer->analyzePage();
     $data = $dataProvider->getData();
     $this->assertEquals(13, count($data));
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is invalid.';
     $this->assertEquals($compareData, unserialize($data[0]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[0]->analysisStatus);
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is invalid.';
     $this->assertEquals($compareData, unserialize($data[1]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[1]->analysisStatus);
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is invalid.';
     $this->assertEquals($compareData, unserialize($data[2]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[2]->analysisStatus);
     $this->assertNull($data[3]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[3]->analysisStatus);
     $this->assertNull($data[4]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[4]->analysisStatus);
     $this->assertNull($data[5]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[5]->analysisStatus);
     $this->assertNull($data[6]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[6]->analysisStatus);
     $this->assertNull($data[7]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[7]->analysisStatus);
     $this->assertNull($data[8]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[8]->analysisStatus);
     $this->assertNull($data[9]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[9]->analysisStatus);
     $this->assertNull($data[10]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[10]->analysisStatus);
     $this->assertNull($data[11]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[11]->analysisStatus);
     $this->assertNull($data[12]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[12]->analysisStatus);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:59,代码来源:ContactsImportDataAnalyzerTest.php


示例7: action

function action($arg)
{
    $f_articles = new Import($arg);
    $variableMetodo = array($f_articles, $arg);
    if (is_callable($variableMetodo)) {
        $f_articles->execute();
    }
}
开发者ID:dice9030,项目名称:GestionLogistico,代码行数:8,代码来源:f_articles.php


示例8: testSimpleUserImportWhereAllRowsSucceed

 public function testSimpleUserImportWhereAllRowsSucceed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $tasks = Task::getAll();
     $this->assertEquals(0, count($tasks));
     $import = new Import();
     $serializedData['importRulesType'] = 'Tasks';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('simpleImportTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.tasks.tests.unit.files'));
     $this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_1' => ImportMappingUtil::makeDateTimeColumnMappingData('dueDateTime'), 'column_2' => ImportMappingUtil::makeDateTimeColumnMappingData('completedDateTime'), 'column_3' => ImportMappingUtil::makeBooleanColumnMappingData('completed'), 'column_4' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived'), 'column_5' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived'), 'column_6' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived'), 'column_7' => ImportMappingUtil::makeTextAreaColumnMappingData('description'));
     $importRules = ImportRulesUtil::makeImportRulesByType('Tasks');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $actionDateTime = substr(DateTimeUtil::convertTimestampToDbFormatDateTime(time()), 0, -3);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 3 models where created.
     $tasks = Task::getAll();
     $this->assertEquals(3, count($tasks));
     $tasks = Task::getByName('task1');
     $this->assertEquals(1, count($tasks[0]));
     $this->assertEquals(1, count($tasks[0]->activityItems));
     $this->assertEquals('testAccount', $tasks[0]->activityItems[0]->name);
     $this->assertEquals('Account', get_class($tasks[0]->activityItems[0]));
     $this->assertNull($tasks[0]->completed);
     $this->assertEquals($actionDateTime, substr($tasks[0]->latestDateTime, 0, -3));
     $tasks = Task::getByName('task2');
     $this->assertEquals(1, count($tasks[0]));
     $this->assertEquals(1, count($tasks[0]->activityItems));
     $this->assertEquals('testContact', $tasks[0]->activityItems[0]->firstName);
     $this->assertEquals('Contact', get_class($tasks[0]->activityItems[0]));
     $this->assertEquals(1, $tasks[0]->completed);
     $this->assertEquals('2011-12-22 06:03', substr($tasks[0]->latestDateTime, 0, -3));
     $tasks = Task::getByName('task3');
     $this->assertEquals(1, count($tasks[0]));
     $this->assertEquals(1, count($tasks[0]->activityItems));
     $this->assertEquals('testOpportunity', $tasks[0]->activityItems[0]->name);
     $this->assertEquals('Opportunity', get_class($tasks[0]->activityItems[0]));
     $this->assertNull($tasks[0]->completed);
     $this->assertEquals($actionDateTime, substr($tasks[0]->latestDateTime, 0, -3));
     //Confirm 10 rows were processed as 'created'.
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
     //Confirm that 0 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 2 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:58,代码来源:TaskImportTest.php


示例9: testSimpleUserImportWhereAllRowsSucceed

 public function testSimpleUserImportWhereAllRowsSucceed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'ProductTemplates';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('productTemplates.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.productTemplates.tests.unit.files'));
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $currencies = Currency::getAll();
     $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_1' => ImportMappingUtil::makeTextAreaColumnMappingData('description'), 'column_2' => ImportMappingUtil::makeIntegerColumnMappingData('sellPriceFormula__type'), 'column_3' => ImportMappingUtil::makeFloatColumnMappingData('sellPriceFormula__discountOrMarkupPercentage'), 'column_4' => ImportMappingUtil::makeCurrencyColumnMappingData('cost', $currencies[0]), 'column_5' => ImportMappingUtil::makeCurrencyColumnMappingData('listPrice', $currencies[0]), 'column_6' => ImportMappingUtil::makeCurrencyColumnMappingData('sellPrice', $currencies[0]), 'column_7' => ImportMappingUtil::makeIntegerColumnMappingData('priceFrequency'), 'column_8' => ImportMappingUtil::makeIntegerColumnMappingData('type'), 'column_9' => ImportMappingUtil::makeIntegerColumnMappingData('status'));
     $importRules = ImportRulesUtil::makeImportRulesByType('ProductTemplates');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 3 models where created.
     $productTemplates = ProductTemplate::getAll();
     $this->assertEquals(2, count($productTemplates));
     $productTemplates = ProductTemplate::getByName('A Gift of Monotheists import');
     $this->assertEquals(1, count($productTemplates[0]));
     $this->assertEquals('A Gift of Monotheists import', $productTemplates[0]->name);
     $this->assertEquals(2, $productTemplates[0]->sellPriceFormula->type);
     $this->assertEquals(10, $productTemplates[0]->sellPriceFormula->discountOrMarkupPercentage);
     $this->assertEquals(180, $productTemplates[0]->sellPrice->value);
     $this->assertEquals(200, $productTemplates[0]->listPrice->value);
     $this->assertEquals(200, $productTemplates[0]->cost->value);
     $this->assertEquals(2, $productTemplates[0]->priceFrequency);
     $this->assertEquals(2, $productTemplates[0]->type);
     $this->assertEquals(2, $productTemplates[0]->status);
     $productTemplates[0]->delete();
     $productTemplates = ProductTemplate::getByName('A Gift of Monotheists import Copy');
     $this->assertEquals(1, count($productTemplates[0]));
     $this->assertEquals('A Gift of Monotheists import Copy', $productTemplates[0]->name);
     $this->assertEquals(2, $productTemplates[0]->sellPriceFormula->type);
     $this->assertEquals(5, $productTemplates[0]->sellPriceFormula->discountOrMarkupPercentage);
     $this->assertEquals(180, $productTemplates[0]->sellPrice->value);
     $this->assertEquals(200, $productTemplates[0]->listPrice->value);
     $this->assertEquals(200, $productTemplates[0]->cost->value);
     $this->assertEquals(2, $productTemplates[0]->priceFrequency);
     $this->assertEquals(2, $productTemplates[0]->type);
     $this->assertEquals(2, $productTemplates[0]->status);
     $productTemplates[0]->delete();
     //Confirm that 2 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 2 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:57,代码来源:ProductTemplateImportTest.php


示例10: resolveCustomFieldsInstructionDataIntoImportAndSaveImport

 protected static function resolveCustomFieldsInstructionDataIntoImportAndSaveImport(ImportDataAnalyzer $importDataAnalyzer, Import $import)
 {
     $adapter = new ImportToCustomFieldsInstructionDataAdapter($import);
     $adapter->appendCustomFieldsInstructionData($importDataAnalyzer->getCustomFieldsInstructionData());
     $saved = $import->save();
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:9,代码来源:ImportDataAnalysisSequentialProcess.php


示例11: testImportDataAnalysisResults

 public function testImportDataAnalysisResults()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $import = new Import();
     $serializedData['importRulesType'] = 'Users';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.users.tests.unit.files'));
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'username', 'type' => 'importColumn', 'mappingRulesData' => array()), 'column_1' => array('attributeIndexOrDerivedType' => 'Password', 'type' => 'importColumn', 'mappingRulesData' => array('PasswordDefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_2' => array('attributeIndexOrDerivedType' => 'UserStatus', 'type' => 'importColumn', 'mappingRulesData' => array('UserStatusDefaultValueMappingRuleForm' => array('defaultValue' => UserStatusUtil::ACTIVE))));
     $serializedData = unserialize($import->serializedData);
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $importRules = ImportRulesUtil::makeImportRulesByType('Users');
     $config = array('pagination' => array('pageSize' => 15));
     //This test csv has a header row.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     //Run data analyzer
     $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider, $mappingData, array('column_0', 'column_1', 'column_2'));
     $importDataAnalyzer->analyzePage();
     $data = $dataProvider->getData();
     $this->assertEquals(10, count($data));
     $this->assertNull($data[0]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[0]->analysisStatus);
     $this->assertNull($data[1]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[1]->analysisStatus);
     $this->assertNull($data[2]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[2]->analysisStatus);
     $this->assertNull($data[3]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[3]->analysisStatus);
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is too long. Maximum length is 64. This value will truncated upon import.';
     $this->assertEquals($compareData, unserialize($data[4]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_WARN, $data[4]->analysisStatus);
     $this->assertNull($data[5]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[5]->analysisStatus);
     $this->assertNull($data[6]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[6]->analysisStatus);
     $compareData = array();
     $compareData['column_2'] = array();
     $compareData['column_2'][] = 'Status value is invalid. This status will be set to active upon import.';
     $this->assertEquals($compareData, unserialize($data[7]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_WARN, $data[7]->analysisStatus);
     $compareData = array();
     $compareData['column_1'] = array();
     $compareData['column_1'][] = 'Is too long. Maximum length is 32. This value will truncated upon import.';
     $this->assertEquals($compareData, unserialize($data[8]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_WARN, $data[8]->analysisStatus);
     $compareData = array();
     $compareData['column_2'] = array();
     $compareData['column_2'][] = 'Status value is invalid. This status will be set to active upon import.';
     $this->assertEquals($compareData, unserialize($data[9]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_WARN, $data[9]->analysisStatus);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:56,代码来源:UsersImportDataAnalyzerTest.php


示例12: testSuperUserMappingRulesEditActionAllAttributeIndexAndDerivedTypes

 public function testSuperUserMappingRulesEditActionAllAttributeIndexAndDerivedTypes()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $import = new Import();
     $import->serializedData = serialize(array('importRulesType' => 'Contacts'));
     $this->assertTrue($import->save());
     //Test contact specific attribute indexes and derived attribute types
     $this->runMappingRulesEditAction($import->id, 'FullName');
     $this->runMappingRulesEditAction($import->id, 'ContactState');
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:10,代码来源:ContactsImportSuperUserWalkthroughTest.php


示例13: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('artist', function (Blueprint $table) {
         $table->increments('id_artist');
         $table->string('name');
         $table->string('description');
         $table->string('image');
         $table->string('tags');
     });
     $data = new Import();
     $data->import("public/assets/artistes.csv", "artist");
 }
开发者ID:marinesl,项目名称:Codepi_Concert,代码行数:17,代码来源:2016_01_12_162952_create_artist_table.php


示例14: testSimpleUserImportWhereAllRowsSucceed

 public function testSimpleUserImportWhereAllRowsSucceed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'Projects';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('projectsSample.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.projects.tests.unit.files'));
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $ownerColumnMappingData = array('attributeIndexOrDerivedType' => 'owner', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USERNAME)));
     $mappingData = array('column_0' => $ownerColumnMappingData, 'column_1' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_2' => ImportMappingUtil::makeTextAreaColumnMappingData('description'), 'column_3' => ImportMappingUtil::makeDropDownColumnMappingData('status'));
     $importRules = ImportRulesUtil::makeImportRulesByType('Projects');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 2 models where created.
     $projects = Project::getAll();
     $this->assertEquals(2, count($projects));
     $projects = Project::getByName('My first project');
     $this->assertEquals(1, count($projects[0]));
     $this->assertEquals('super', $projects[0]->owner->username);
     $this->assertEquals('My first project', $projects[0]->name);
     $this->assertEquals(2, $projects[0]->status);
     //todo ask Jason for it
     //$this->assertEquals('My first project Desc',   $projects[0]->description);
     $projects[0]->delete();
     $projects = Project::getByName('My second project');
     $this->assertEquals(1, count($projects[0]));
     $this->assertEquals('super', $projects[0]->owner->username);
     $this->assertEquals('My second project', $projects[0]->name);
     $this->assertEquals(1, $projects[0]->status);
     //$this->assertEquals('My second project Desc',  $projects[0]->description);
     $projects[0]->delete();
     //Confirm that 2 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 2 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:48,代码来源:ProjectImportTest.php


示例15: init

 function init($zone, $lang = null, $lr = null)
 {
     $this->regional = $zone;
     $this->lr = $lr;
     $this->hl = $lang;
     $this->htmlDOM =& Import::htmlDOM();
 }
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:7,代码来源:crawler-google.php


示例16: _help_article

 function _help_article()
 {
     $cache = Import::ajincache();
     $cache->SetFunction(__FUNCTION__);
     $cache->SetMode('sitemes');
     $fn = $cache->fpath(func_get_args());
     $type = "about";
     if (file_exists($fn) && !$cache->GetClose()) {
         include $fn;
     } else {
         $sql = "SELECT tb1.*,tb2.cat_name,tb2.type FROM `{$this->App->prefix()}article` AS tb1";
         $sql .= " LEFT JOIN `{$this->App->prefix()}article_cate` AS tb2 ON tb1.cat_id=tb2.cat_id";
         $sql .= " WHERE tb2.type='{$type}' AND tb1.is_show='1' ORDER BY  tb2.vieworder ASC,tb1.vieworder ASC,tb1.article_id DESC";
         $rt = $this->App->find($sql);
         if (!empty($rt)) {
             foreach ($rt as $k => $row) {
                 $rts[$row['cat_id']]['cat_name'] = $row['cat_name'];
                 $rts[$row['cat_id']]['url'] = "javascript:void()";
                 $rts[$row['cat_id']]['article'][$k] = $row;
                 $rts[$row['cat_id']]['article'][$k]['url'] = !empty($row['external_link']) ? trim($row['external_link']) : SITE_URL . $type . '/' . $row['article_url'];
             }
             unset($rt);
         }
         $cache->write($fn, $rts, 'rts');
     }
     return $rts;
 }
开发者ID:jasonhzy,项目名称:fx_demo,代码行数:27,代码来源:controller.php


示例17: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('concert', function (Blueprint $table) {
         $table->increments('id_concert');
         $table->string('name_artist');
         $table->string('place');
         $table->string('address');
         $table->string('city');
         $table->dateTime('date');
         $table->string('price');
         //$table->foreign('name_artist')
         //->references('name')->on('artist');
     });
     $data = new Import();
     $data->import("public/assets/concerts.csv", "concert");
 }
开发者ID:marinesl,项目名称:Codepi_Concert,代码行数:21,代码来源:2016_01_12_163036_create_concert_table.php


示例18: read

 /**
  * Read file and returns an array filled up with its' content.
  * 
  * @return array of objects
  */
 protected function read()
 {
     $result = array();
     $path = $this->path;
     if (!is_readable($path)) {
         return array();
     }
     $items = \Import::csv_reader($path);
     foreach ($items as $item) {
         $item = (object) $item;
         $title = isset($item->title) ? trim($item->title) : '';
         $content = isset($item->content) ? trim($item->content) : '';
         $type = isset($item->type) ? trim($item->type) : '';
         $title = \Security::remove_XSS($title);
         $content = \Security::remove_XSS($content);
         $type = \Security::remove_XSS($type);
         $is_blank_line = empty($title) && empty($content) && empty($type);
         if ($is_blank_line) {
             continue;
         }
         $type = CourseDescriptionType::repository()->find_one_by_name($type);
         $type_id = $type ? $type->id : 0;
         $description = CourseDescription::create();
         $description->title = $title;
         $description->content = $content;
         $description->description_type = $type_id;
         $result[] = $description;
     }
     return $result;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:35,代码来源:csv_reader.class.php


示例19: config

 public static function config($name)
 {
     // 如果设置了前缀,则替换conf
     if (isset($name['prefix'])) {
         C('SESSION_PREFIX', $name['prefix']);
     }
     // 根据默认值设置获得根据定义的id设置
     if (C('VAR_SESSION_ID') && isset($_REQUEST[C('VAR_SESSION_ID')])) {
         session_id($_REQUEST[C('VAR_SESSION_ID')]);
     } elseif (isset($name['id'])) {
         session_id($name['id']);
     }
     // session 函数参考,http://www.php.net/manual/zh/ref.session.php
     // session runtime 配置参考,http://www.php.net/manual/zh/session.configuration.php
     ini_set('session.auto_start', 0);
     if (isset($name['name'])) {
         session_name($name['name']);
     }
     if (isset($name['path'])) {
         session_save_path($name['path']);
     }
     if (isset($name['domain'])) {
         ini_set('session.cookie_domain', $name['domain']);
     }
     if (isset($name['expire'])) {
         ini_set('session.gc_maxlifetime', $name['expire']);
     }
     if (isset($name['use_trans_sid'])) {
         ini_set('session.use_trans_sid', $name['use_trans_sid'] ? 1 : 0);
     }
     if (isset($name['use_cookies'])) {
         ini_set('session.use_cookies', $name['use_cookies'] ? 1 : 0);
     }
     if (isset($name['cache_limiter'])) {
         session_cache_limiter($name['cache_limiter']);
     }
     if (isset($name['cache_expire'])) {
         session_cache_expire($name['cache_expire']);
     }
     if (isset($name['type'])) {
         C('SESSION_TYPE', $name['type']);
     }
     // 如果存在其他session类型
     if (C('SESSION_TYPE')) {
         // 读取session驱动
         $class = 'Session' . ucwords(strtolower(C('SESSION_TYPE')));
         // 检查驱动类是否存在并加载,不存在则 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ImportBaseTest类代码示例发布时间:2022-05-23
下一篇:
PHP ImpExData类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap