コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: ManageAdmin.php プロジェクト: remarco-mif/ppos
 public function import()
 {
     $page = new AdminPage();
     $panel = new Import();
     $page->addToContainer(1, $panel->getHtml());
     $page->pagePrint();
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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());
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 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);
 }
コード例 #7
0
function action($arg)
{
    $f_articles = new Import($arg);
    $variableMetodo = array($f_articles, $arg);
    if (is_callable($variableMetodo)) {
        $f_articles->execute();
    }
}
コード例 #8
0
ファイル: TaskImportTest.php プロジェクト: youprofit/Zurmo
 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));
 }
コード例 #9
0
 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));
 }
コード例 #10
0
 protected static function resolveCustomFieldsInstructionDataIntoImportAndSaveImport(ImportDataAnalyzer $importDataAnalyzer, Import $import)
 {
     $adapter = new ImportToCustomFieldsInstructionDataAdapter($import);
     $adapter->appendCustomFieldsInstructionData($importDataAnalyzer->getCustomFieldsInstructionData());
     $saved = $import->save();
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
 }
コード例 #11
0
 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);
 }
コード例 #12
0
 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');
 }
コード例 #13
0
 /**
  * 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");
 }
コード例 #14
0
 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));
 }
コード例 #15
0
 function init($zone, $lang = null, $lr = null)
 {
     $this->regional = $zone;
     $this->lr = $lr;
     $this->hl = $lang;
     $this->htmlDOM =& Import::htmlDOM();
 }
コード例 #16
0
ファイル: controller.php プロジェクト: jasonhzy/fx_demo
 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;
 }
 /**
  * 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");
 }
コード例 #18
0
 /**
  * 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;
 }
コード例 #19
0
 public function __construct($upload_id)
 {
     parent::__construct('matches', $upload_id);
     $this->string('competition')->position(0);
     $this->date('date', 'd/m/Y')->position(1);
     $this->string('day')->position(2);
     $this->time('time', 'H:i:s')->position(3);
     $this->string('home_club')->position(4);
     $this->string('away_club')->position(5);
     $this->integer('attendance')->position(6)->insert();
     $this->integer('capacity')->position(7)->insert();
     $this->string('broadcaster')->position(8);
     $this->string('season')->position(9);
     $this->date('start', 'Y-m-d H:i:s')->insert();
     $this->integer('competition_id')->insert();
     $this->integer('season_id')->insert();
     $this->integer('broadcaster_id')->insert();
     $this->integer('home_club_id')->insert();
     $this->integer('away_club_id')->insert();
     $this->integer('upload_id')->insert();
     $this->relation('competitions', 'competition_id')->field('name', 'competition')->onBeforeInsert(array($this, 'makeAbb'))->onBeforeInsert(array($this, 'makeTimestamps'));
     $this->relation('clubs', 'home_club_id')->field('name', 'home_club')->onBeforeInsert(array($this, 'makeAbb'))->onBeforeInsert(array($this, 'makeTimestamps'));
     $this->relation('clubs', 'away_club_id')->field('name', 'away_club')->onBeforeInsert(array($this, 'makeAbb'))->onBeforeInsert(array($this, 'makeTimestamps'));
     $this->relation('seasons', 'season_id')->field('name', 'season')->onBeforeInsert(array($this, 'makeTimestamps'));
     $this->relation('broadcasters', 'broadcaster_id')->field('name', 'broadcaster')->onBeforeInsert(array($this, 'makeTimestamps'));
     $this->on('parsed', function ($row) {
         $row['start'] = $row['date'] . ' ' . $row['time'];
         return $row;
     });
     $this->on('parsed', [$this, 'makeTimestamps']);
 }
コード例 #20
0
ファイル: Session.php プロジェクト: minowu/smartthink
 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')));
         // 检查驱动类是否存在并加载,不存在则抛出错误
         if (Import::load(EXTEND_PATH . 'Driver/Session/' . $class . '.class.php')) {
             $hander = new $class();
             $hander->execute();
         } else {
             // 类没有定义
             Debug::throw_exception(L('_CLASS_NOT_EXIST_') . ': ' . $class);
         }
     }
     // 启动session
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
 }
コード例 #21
0
ファイル: Phantomjs.php プロジェクト: awwthentic1234/hey
 public static function callScript($script = null, $args = array())
 {
     if (is_null($script)) {
         throw new Exception("script is null");
     }
     //---------------------------------------------
     $script = $_ENV["phantomjs_scripts"] . '/' . $script;
     //---------------------------------------------
     $arr = FileFolder::fileExistInFolder($script, ["init.werm.js"], true);
     //---------------------------------------------
     $content = "";
     foreach ($arr as $value) {
         $content .= Import::replaceEnv($value);
         //krumo($content);
     }
     //---------------------------------------------
     $content .= FileFolder::file_get_contents($script);
     //print_r($arr);
     //---------------------------------------------
     FileFolder::file_put_contents($script = Import::newPath_CFG($script) . ".js", $content);
     //---------------------------------------------
     $cmd = $_ENV["phantomjs"] . ' ' . $script;
     //---------------------------------------------
     if (sizeof($args) > 0) {
         $cmd .= " " . implode(" ", $args);
     }
     //---------------------------------------------
     $cmd .= ' > /dev/null 2>/dev/null &';
     //---------------------------------------------
     exec($cmd, $outputAndErrors, $return_value);
     //---------------------------------------------
     return $outputAndErrors;
 }
コード例 #22
0
 public function __construct()
 {
     $this->bootstrap = Bootstrap::getInstance();
     $this->import = Import::getInstance();
     $this->resolver = Resolver::getInstance();
     foreach ($this->bootstrap->appSettings->wpbootstrap->menus as $menu => $locations) {
         $dir = BASEPATH . "/bootstrap/menus/{$menu}";
         $newMenu = new \stdClass();
         $newMenu->slug = $menu;
         $newMenu->locations = $locations;
         $newMenu->items = array();
         foreach ($this->getFiles($dir) as $file) {
             $menuItem = new \stdClass();
             $menuItem->done = false;
             $menuItem->id = 0;
             $menuItem->parentId = 0;
             $menuItem->slug = $file;
             $menuItem->menu = unserialize(file_get_contents($dir . '/' . $file));
             $newMenu->items[] = $menuItem;
         }
         usort($newMenu->items, function ($a, $b) {
             return (int) $a->menu->menu_order - (int) $b->menu->menu_order;
         });
         $this->menus[] = $newMenu;
     }
     $baseUrl = get_option('siteurl');
     $neutralUrl = Bootstrap::NETURALURL;
     $this->resolver->fieldSearchReplace($this->menus, Bootstrap::NETURALURL, $this->import->baseUrl);
     $this->process();
 }
コード例 #23
0
 /**
  * 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) : '';
         $description = isset($item->description) ? trim($item->description) : '';
         $name = \Security::remove_XSS($name);
         $description = \Security::remove_XSS($description);
         $is_blank_line = empty($name) && empty($description);
         if ($is_blank_line) {
             continue;
         }
         $item = new Notebook();
         $item->title = $title;
         $item->description = $description;
         $result[] = $item;
     }
     return $result;
 }
コード例 #24
0
 public function __construct()
 {
     $this->bootstrap = Bootstrap::getInstance();
     $this->import = Import::getInstance();
     $this->resolver = Resolver::getInstance();
     $dir = BASEPATH . '/bootstrap/sidebars';
     foreach ($this->bootstrap->getFiles($dir) as $sidebar) {
         $subdir = BASEPATH . "/bootstrap/sidebars/{$sidebar}";
         $newSidebar = new \stdClass();
         $newSidebar->slug = $sidebar;
         $newSidebar->items = array();
         $newSidebar->meta = unserialize(file_get_contents($subdir . '/meta'));
         foreach ($newSidebar->meta as $key => $widgetRef) {
             $widget = new \stdClass();
             $parts = explode('-', $widgetRef);
             $ord = end($parts);
             $type = substr($widgetRef, 0, -1 * strlen('-' . $ord));
             $widget->type = $type;
             $widget->ord = $ord;
             $widget->meta = unserialize(file_get_contents($subdir . '/' . $widgetRef));
             $newSidebar->items[] = $widget;
         }
         $this->sidebars[] = $newSidebar;
     }
     $baseUrl = get_option('siteurl');
     $neutralUrl = Bootstrap::NETURALURL;
     $this->resolver->fieldSearchReplace($this->sidebars, Bootstrap::NETURALURL, $this->import->baseUrl);
     $this->process();
 }
コード例 #25
0
ファイル: cls_smtp.php プロジェクト: jasonhzy/fx_demo
 function connect($params = array())
 {
     if (!isset($this->status)) {
         $obj = new Ecshop_smtp($params);
         if ($obj->connect()) {
             $obj->status = SMTP_STATUS_CONNECTED;
         }
         return $obj;
     } else {
         if (!empty($GLOBALS['LANG']['smtp_ssl'])) {
             $this->host = "ssl://" . $this->host;
         }
         $this->connection = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
         if ($this->connection === false) {
             $this->errors[] = 'Access is denied.';
             return false;
         }
         @socket_set_timeout($this->connection, 0, 250000);
         $greeting = $this->get_data();
         if (is_resource($this->connection)) {
             $this->status = 2;
             return $this->auth ? $this->ehlo() : $this->helo();
         } else {
             Import::basic()->log_write($errstr, __FILE__, __LINE__);
             //记录错误信息
             $this->errors[] = 'Failed to connect to server: ' . $errstr;
             return false;
         }
     }
 }
コード例 #26
0
 function shoppingsn($data = array())
 {
     $rt = $this->App->find("SELECT * FROM `{$this->App->prefix()}shipping_name`");
     $this->set('rt', $rt);
     //分页
     $page = isset($_GET['page']) ? $_GET['page'] : 1;
     if (empty($page)) {
         $page = 1;
     }
     $list = 20;
     $start = ($page - 1) * $list;
     $comd = array();
     $w = "";
     if (isset($_GET['sid']) && $_GET['sid'] > 0) {
         $comd[] = "tb1.shipping_id = '" . intval($_GET['sid']) . "'";
     }
     if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
         $comd[] = "tb1.shipping_sn LIKE '%" . trim($_GET['keyword']) . "%'";
     }
     if (!empty($comd)) {
         $w = "WHERE " . implode(' AND ', $comd);
     }
     $sql = "SELECT COUNT(tb1.id) FROM `{$this->App->prefix()}shipping_sn` AS tb1 LEFT JOIN `{$this->App->prefix()}shipping_name` AS tb2 ON tb1.shipping_id = tb2.shipping_id {$w}";
     $tt = $this->App->findvar($sql);
     $rts['pages'] = Import::basic()->getpage($tt, $list, $page, '?page=', true);
     $sql = "SELECT tb1.*,tb2.shipping_name FROM `{$this->App->prefix()}shipping_sn` AS tb1 LEFT JOIN `{$this->App->prefix()}shipping_name` AS tb2 ON tb1.shipping_id = tb2.shipping_id {$w} ORDER BY tb1.id DESC LIMIT {$start},{$list}";
     $rts['lists'] = $this->App->find($sql);
     $this->set('rts', $rts);
     $this->template('shoppingsn');
 }
コード例 #27
0
ファイル: controller.php プロジェクト: jasonhzy/fx_demo
 function index($id = 0)
 {
     $this->css("top.css");
     $this->js('time.js');
     if (!($id > 0)) {
         $id = 6;
     }
     if (!($id > 0)) {
         $this->action('common', 'show404tpl');
     }
     $json = Import::json();
     $rt = $this->Cache->read(3600);
     if (is_null($rt)) {
         $time = mktime();
         $sql = "SELECT * FROM `{$this->App->prefix()}topic` WHERE topic_id='{$id}' AND end_time > '{$time}' LIMIT 1";
         $rt['info'] = $this->App->findrow($sql);
         if (empty($rt['info'])) {
             $this->jump(SITE_URL, '', "该专题已经超过有效期!");
         }
         $rt['info']['goods_ids'] = addcslashes($rt['info']['goods_ids'], "'");
         $tmp = @unserialize($rt['info']["goods_ids"]);
         $arr = (array) $tmp;
         $goods_id = array();
         foreach ($arr as $key => $value) {
             foreach ($value as $k => $val) {
                 $opt = explode('|', $val);
                 $arr[$key][$k] = $opt[1];
                 $goods_id[] = $opt[1];
             }
         }
         $sql = "SELECT goods_id,goods_name,goods_thumb,goods_img,shop_price,pifa_price FROM `{$this->App->prefix()}goods` WHERE goods_id IN(" . implode(',', $goods_id) . ")";
         $rts = $this->App->find($sql);
         foreach ($rts as $rows) {
             foreach ($arr as $key => $value) {
                 foreach ($value as $val) {
                     if ($val == $rows['goods_id']) {
                         $key = $key == 'default' ? 'default' : $key;
                         $sort_goods_arr[$key][] = $rows;
                     }
                 }
             }
         }
         $rt['goodslist'] = $sort_goods_arr;
         unset($sort_goods_arr, $tts);
         //预告
         $t1 = date('Y-m-d', mktime() + 24 * 3600);
         //$t2 = date('Y-m-d',mktime()-24*3600);
         $rt['yugao'] = array();
         $sql = "SELECT tb1.article_title,tb1.article_img,tb2.cat_name,tb2.cat_title AS date1 FROM `{$this->App->prefix()}article` AS tb1 LEFT JOIN `{$this->App->prefix()}article_cate` AS tb2 ON tb1.cat_id = tb2.cat_id WHERE tb2.type='case' AND tb2.cat_name ='{$t1}'  ORDER BY tb2.cat_title DESC";
         $rt['yugao'] = $this->App->find($sql);
         $this->Cache->write($rt);
     }
     $title = $rt['info']['topic_name'];
     $this->title($title . ' - ' . $GLOBALS['LANG']['site_name']);
     $this->meta("title", $title);
     $this->meta("keywords", htmlspecialchars($rt['info']['meta_keys']));
     $this->meta("description", htmlspecialchars($rt['info']['meta_desc']));
     $this->set('rt', $rt);
     $this->template('topgoods');
 }
コード例 #28
0
 public function __construct($upload_id)
 {
     parent::__construct('commercialauditing', $upload_id);
     $regions = Config::get('plr.frontend.filter_order.commercial-auditing.region');
     $regions = array_pluck($regions, 'dbLabel');
     $this->string('country')->position(0);
     $this->string('reference')->position(1)->insert();
     $this->string('company')->position(2)->insert();
     $this->string('brand')->position(3)->insert();
     $this->string('product')->position(4)->insert();
     $this->integer('spots')->position(5)->insert();
     $this->seconds('airtime')->position(6)->insert();
     $this->enum('region', $regions)->position(7);
     $this->string('channel')->position(8);
     $this->string('season')->position(9);
     $this->integer('productcategory_id')->insert();
     $this->integer('territory_id')->insert();
     $this->integer('channel_id')->insert();
     $this->integer('upload_id')->insert();
     $this->integer('season_id')->insert();
     $this->datetime('created_at', 'Y-m-d H:i:s')->insert();
     $this->datetime('updated_at', 'Y-m-d H:i:s')->insert();
     $this->relation('productcategories', 'productcategory_id')->field('name', 'product')->onBeforeInsert([$this, 'makeTimestamps']);
     $this->relation('territories', 'territory_id')->field('name', 'country')->field('region', 'region')->onBeforeInsert([$this, 'makeAbb'])->onBeforeInsert([$this, 'makeTimestamps']);
     $this->relation('channels', 'channel_id')->field('name', 'channel')->onBeforeInsert([$this, 'addUploadId'])->onBeforeInsert([$this, 'makeAbb'])->onBeforeInsert([$this, 'makeTimestamps']);
     $this->relation('seasons', 'season_id')->field('name', 'season')->onBeforeInsert([$this, 'makeTimestamps']);
     $this->on('parsed', [$this, 'makeTimestamps']);
 }
コード例 #29
0
 function ajax_select_goods($maxattr = 0, $page = 1)
 {
     $cid = isset($_COOKIE['GZ_cid']) ? $_COOKIE['GZ_cid'] : 0;
     $subcid = array();
     if ($cid > 0) {
         $subcid = $this->action('catalog', 'get_goods_sub_cat_ids', $cid);
     }
     //分类
     ///
     isset($_COOKIE['GZ_bid']) && intval($_COOKIE['GZ_bid']) > 0 ? $comd[] = "b.brand_id = '" . intval($_COOKIE['GZ_bid']) . "'" : 0;
     //品牌
     if ($maxattr > 0) {
         for ($i = 0; $i < $maxattr; $i++) {
             isset($_COOKIE['GZ_' . $i]) && !empty($_COOKIE['GZ_' . $i]) ? $comd[] = "ga.attr_value = '" . $_COOKIE['GZ_' . $i] . "'" : 0;
             //属性
         }
     }
     if (!empty($subcid)) {
         $comd[] = "gc.cat_id " . db_create_in($subcid);
     }
     $w = !empty($comd) ? " WHERE " . implode(' AND ', $comd) : "";
     $tt = $this->__get_user_goods_select_count($w);
     $rt['count'] = $tt;
     $list = 12;
     $rt['goodslist'] = $this->__get_user_goods_select($w, $page, $list);
     $rt['goodspage'] = Import::basic()->ajax_page($tt, $list, $page, 'get_select_goods_page');
     $this->set('rt', $rt);
     $con = $this->fetch('ajax_user_goods_select', true);
     die($con);
 }
コード例 #30
0
/**
 * Read the CSV-file
 * @param string $file Path to the CSV-file
 * @return array All userinformation read from the file
 */
function parse_csv_data($file)
{
    $skills = Import::csv_to_array($file);
    foreach ($skills as $index => $skill) {
        $skills[$index] = $skill;
    }
    return $skills;
}