コード例 #1
0
 /**
  * Export products
  */
 public function actionExport()
 {
     $exporter = new CsvExporter();
     if (Yii::app()->request->isPostRequest && isset($_POST['attributes']) && !empty($_POST['attributes'])) {
         $exporter->export($_POST['attributes']);
     }
     $this->render('export', array('exporter' => $exporter, 'importer' => new CsvImporter()));
 }
コード例 #2
0
ファイル: CsvExporterTest.php プロジェクト: Baabah/mikko-test
 /**
  * Export to .csv without data
  */
 public function testBadExport()
 {
     $data = [];
     $expectedHeadings = ['Month', 'Bonus date', 'Salary date'];
     // Mock getExportArray method to return $data
     $this->paymentMock->expects($this->any())->method('getExportArray')->will($this->returnValue($data));
     // Check for errors when exporting
     $this->assertTrue($this->csvExporter->export($this->paymentMock));
     // Check if file is created
     $this->assertFileExists($this->path);
     // Check if file contents are correct
     $csvFile = fopen($this->path, 'r');
     $headings = fgetcsv($csvFile, null, ';');
     $this->assertEquals($headings, $expectedHeadings);
     $firstLine = fgetcsv($csvFile, null, ';');
     $this->assertFalse($firstLine);
 }
コード例 #3
0
 /**
  * Export products
  */
 public function actionExport()
 {
     $this->pageName = Yii::t('CsvModule.admin', 'EXPORT_PRODUCTS');
     $exporter = new CsvExporter();
     if (Yii::app()->request->isPostRequest && isset($_POST['attributes']) && !empty($_POST['attributes'])) {
         $exporter->export($_POST['attributes']);
     }
     $this->render('export', array('exporter' => $exporter, 'importer' => new CsvImporter()));
 }
コード例 #4
0
ファイル: export.lib.php プロジェクト: rhertzog/lcs
/**
 * Exports a CSV file from a list of user id's
 * @param array $userIdList id of the class
 * @param array $fields optionnal names for the headers of the generated csv
 * @return string
 * @author schampagne <http://forum.claroline.net/memberlist.php?mode=viewprofile&u=45044>
 */
function csv_export_user_list($userIdList, $fields = array('user_id', 'username', 'lastname', 'firstname', 'email', 'officialCode'))
{
    $csv = new CsvExporter(',', '"');
    $csvData = array();
    $csvData[0] = $fields;
    foreach ($userIdList as $userId) {
        $userInfo = user_get_properties($userId);
        $row = array();
        foreach ($fields as $field) {
            if (isset($userInfo[$field])) {
                $row[$field] = $userInfo[$field];
            } else {
                $row[$field] = '';
            }
        }
        $csvData[] = $row;
    }
    return $csv->export($csvData);
}
コード例 #5
0
ファイル: files_stats.php プロジェクト: rhertzog/lcs
                $csvSubTab = array();
                $csvSubTab['courseCode'] = $key;
                $csvSubTab['courseTitle'] = $elmt['courseTitle'];
                $csvSubTab['courseTitulars'] = $elmt['courseTitulars'];
                foreach ($elmt['courseStats'] as $key => $elmt2) {
                    $csvSubTab[$key . '_count'] = $elmt2['count'];
                    $csvSubTab[$key . '_size'] = round($elmt2['size'] / 1024);
                }
                foreach ($elmt['courseCategory'] as $key => $cat) {
                    $csvSubTab[$key . '_courseCategory'] = $cat;
                }
                $csvTab[] = $csvSubTab;
            }
            $csvExporter = new CsvExporter(';', '"');
            $fileName = get_lang('files_stats') . '_' . claro_date('d-m-Y') . '.csv';
            $stream = $csvExporter->export($csvTab);
            claro_send_stream($stream, $fileName, 'text/csv');
        }
    } else {
        $dialogBox->warning(get_lang('Statistics in progress, please don\'t refresh until further instructions ! ') . '<br />' . get_lang('Course actually treated : ') . $course['title'] . '<br />' . get_lang(' Number of course treated : ') . count($stats));
        $claroline->display->body->appendContent($dialogBox->render());
        echo $claroline->display->render();
    }
} else {
    $dialogBox = new DialogBox();
    $dialogBox->warning(get_lang('Caution: building files\' statistics is a pretty heavy work.  It might take a while and a lot of resources, depending of the size of your campus.'));
    if (!empty($extensions)) {
        $dialogBox->info(get_lang('You\'ve chosen to isolate the following extensions: %types.  If you wish to modify these extensions, check the advanced platform settings', array('%types' => implode(', ', $extensions))));
    } else {
        $dialogBox->info(get_lang('You don\'t have chosen any extension to isolate.  If you wish to isolate extensions in your statistics, check the advanced platform settings'));
    }