40 $this->obligationMap = $GLOBALS[
'container']->get(
'businessrules.obligationmap');
66 public function createCsv($ob=0, $generateJson=
false)
69 $sql =
"SELECT ob_pk,ob_type AS Type,ob_topic AS \"Obligation or Risk topic\",ob_text AS \"Full Text\",
70 ob_classification AS Classification,ob_modifications AS \"Apply on modified source code\",ob_comment AS Comment
73 $stmt = __METHOD__.
'.ob';
74 $sql .=
' WHERE ob_pk=$1;';
75 $row = $this->
dbManager->getSingleRow($sql, [$ob], $stmt);
76 $liclist = $this->obligationMap->getLicenseList($ob);
77 $candidatelist = $this->obligationMap->getLicenseList($ob, True);
79 $row[
"Associated Licenses"] = $liclist;
80 $row[
"Associated candidate Licenses"] = $candidatelist;
89 foreach ($vars as $row) {
90 $liclist = $this->obligationMap->getLicenseList($row[
'ob_pk']);
91 $candidatelist = $this->obligationMap->getLicenseList($row[
'ob_pk'], True);
93 $row[
"Associated Licenses"] = $liclist;
94 $row[
"Associated candidate Licenses/"] = $candidatelist;
99 return json_encode($csvarray, JSON_PRETTY_PRINT);
101 $out = fopen(
'php://output',
'w');
103 $head = array(
'Type',
'Obligation or Risk topic',
'Full Text',
'Classification',
'Apply on modified source code',
'Comment',
'Associated Licenses',
'Associated candidate Licenses');
104 fputcsv($out, $head, $this->delimiter, $this->enclosure);
105 foreach ($csvarray as $row) {
106 fputcsv($out, $row, $this->delimiter, $this->enclosure);
108 $content = ob_get_contents();
Helper class to export obligations as a CSV.
createCsv($ob=0, $generateJson=false)
Create CSV from the obligations.
setDelimiter($delimiter=',')
Update the delimiter.
__construct(DbManager $dbManager)
setEnclosure($enclosure='"')
Update the enclosure.
fo_dbManager * dbManager
fo_dbManager object
Utility functions for specific applications.