/** * Metoda statyczna generująca plik CSV z wszystkimi komentarzami */ public static function exportAllComments() { header("Content-Disposition: attachment; filename=all_comments.csv"); echo ""; $comments = Db::getInstance()->getAll("SELECT c.*,p.name AS product_name, w.name AS website_name FROM `comments` c LEFT JOIN products p ON(p.id_product=c.id_product) LEFT JOIN websites w ON(w.id_website=c.id_website)"); echo "Nazwa produktu;Serwis;Polecany;Autor;Ocena;Treść;Zalety;Wady;Przydatne;Nie przydatne\n"; foreach ($comments as $c) { $summary = ""; if ($c["product_review_summary"] == 0) { $summary = "Nie polecam"; } else { if ($c["product_review_summary"] == 1) { $summary = "Polecam"; } } echo $c["product_name"] . ";" . $c["website_name"] . ";" . $summary . ";" . trim($c["author"]) . ";" . $c["rating"] . ";" . "\"" . str_replace("\"", "'", $c["description"]) . "\";" . "\"" . errorCodding(implode("\n", json_decode($c["pros"], true))) . "\";" . "\"" . errorCodding(implode("\n", json_decode($c["cons"], true))) . "\";" . "\"" . $c["usefulnes_yes"] . "\";" . "\"" . $c["usefulnes_no"] . "\"" . "\n"; } }
</td> <td><?php $pros = json_decode($comment["pros"]); $html = "<ul>"; foreach ($pros as $p) { $html .= "<li>" . errorCodding($p) . "</li>"; } $html .= "</ul>"; echo $html; ?> </td> <td><?php $cons = json_decode($comment["cons"]); $html = "<ul>"; foreach ($cons as $c) { $html .= "<li>" . errorCodding($c) . "</li>"; } $html .= "</ul>"; echo $html; ?> </td> <td> <?php echo html_entity_decode($comment["description"]); ?> </td> </tr> <?php } ?> </tbody> </table>