aboutsummaryrefslogtreecommitdiff
path: root/classes/helpers/CinisisDisplayHelper.php
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-08-23 16:21:12 -0300
committerSilvio <silvio@devlet.com.br>2010-08-23 16:21:12 -0300
commit9fb011b14ef82caf9adf266d81a4984b17280822 (patch)
tree4cedf7656f254a731a681c73e1eb41c7f653331a /classes/helpers/CinisisDisplayHelper.php
parent3fa521d2a74df3e243f36bbf6995eea8082573cb (diff)
downloadcinisis-9fb011b14ef82caf9adf266d81a4984b17280822.tar.gz
cinisis-9fb011b14ef82caf9adf266d81a4984b17280822.tar.bz2
Refactoring CSV app using IsisConnector
Diffstat (limited to 'classes/helpers/CinisisDisplayHelper.php')
-rw-r--r--classes/helpers/CinisisDisplayHelper.php72
1 files changed, 70 insertions, 2 deletions
diff --git a/classes/helpers/CinisisDisplayHelper.php b/classes/helpers/CinisisDisplayHelper.php
index 0a4b7f7..2f8fa65 100644
--- a/classes/helpers/CinisisDisplayHelper.php
+++ b/classes/helpers/CinisisDisplayHelper.php
@@ -11,8 +11,10 @@ class CinisisDisplayHelper {
* Page title;
*/
function __construct($title) {
- $this->header($title);
- $this->title($title);
+ if ($title != NULL) {
+ $this->header($title);
+ $this->title($title);
+ }
}
/**
@@ -347,4 +349,70 @@ class CinisisDisplayHelper {
protected static function cliDump($var) {
print_r($var);
}
+
+ /**
+ * Set the response helper.
+ *
+ * @param $mime
+ * MIME type.
+ *
+ * @param $filename
+ * File name.
+ */
+ protected static function webHttpHeader($mime, $filename) {
+ header("Content-type: $mime");
+ header("Content-Disposition: attachment; filename=$filename");
+ header("Pragma: no-cache");
+ header("Expires: 0");
+ }
+
+ /**
+ * Display a value with CSV format.
+ *
+ * @param $value
+ * Value entry.
+ */
+ protected static function webCsv($value = NULL) {
+ echo '"'. preg_replace('/"/', '""', $value) .'",';
+ }
+
+ /**
+ * Display CSV titles.
+ *
+ * @param $format
+ * ISIS database format.
+ */
+ protected static function webCsvTitles($format) {
+ // Format fields.
+ foreach ($format['fields'] as $field) {
+ self::csv($field['name']);
+ if (isset($field['subfields']) && is_array($field['subfields'])) {
+ foreach ($field['subfields'] as $key => $value) {
+ self::csv($field['name'] .': '. $value);
+ }
+ }
+ }
+ }
+
+ /**
+ * Display a new CSV row.
+ */
+ protected static function webCsvRow() {
+ echo "\n";
+ }
+
+ /**
+ * Merge items in a CSV roll.
+ *
+ * @param $items
+ * Array with items to be merged.
+ */
+ protected function webMergeCsvItems($items) {
+ if (!empty($items)) {
+ self::csv(implode(';', $items));
+ }
+ else {
+ self::csv();
+ }
+ }
}