/**
  * Add a line to the content
  *
  * @param Array $line Array containing the elements of a csv line
  *
  * @return void
  */
 function addLine($line)
 {
     foreach ($line as $element) {
         $this->content .= tocsv($element) . $this->separator;
     }
     $this->content = substr($this->content, 0, -1);
     $this->addEmptyLine();
 }
Example #2
0
function build_csv_record($col_list, $record)
{
    $line = '';
    reset($col_list);
    while (list(, $col) = each($col_list)) {
        $line .= tocsv($record[$col]) . get_csv_separator();
    }
    $line = substr($line, 0, -1);
    return $line;
}
        $data[] = "Other";
    }
    $c = 0;
    $solrProduct = SolrSearch::getProductsForIDs(array($product->id), $c);
    $data[] = str_replace('large', 'thickbox', $solrProduct[0]['image_link_large']);
    $c = 2;
    foreach ($solrProduct[0]['image_links'] as $oImage) {
        if ($oImage !== $solrProduct[0]['image_link_large']) {
            $data[] = str_replace('large', 'thickbox', $oImage);
            $c++;
            if ($c == 6) {
                break;
            }
        }
    }
    $cdata .= tocsv($data) . "\n";
}
echo $cdata = str_replace("\r", "", $cdata);
exit;
function tocsv($data)
{
    $line = '';
    foreach ($data as $value) {
        if (!isset($value) || $value == "") {
            $value = ",";
        } else {
            $value = str_replace('"', '""', $value);
            $value = '"' . $value . '"' . ",";
        }
        $line .= $value;
    }
 public function toCSV()
 {
     $output = $this->gatherPermissions();
     $sep = get_csv_separator();
     $date = util_timestamp_to_userdateformat($_SERVER['REQUEST_TIME'], true);
     $filename = 'export_permissions_' . $this->group->getUnixName() . '_' . $date . '.csv';
     header('Content-Disposition: filename=' . $filename);
     header('Content-Type: text/csv');
     // Context
     echo $GLOBALS['Language']->getText('plugin_docman', 'format_export_project') . $sep . tocsv($this->group->getPublicName(), $sep) . $sep . tocsv($this->group->getUnixName(), $sep) . $sep . $this->group->getId() . PHP_EOL;
     echo $GLOBALS['Language']->getText('plugin_docman', 'format_export_date') . $sep . format_date(util_get_user_preferences_export_datefmt(), $_SERVER['REQUEST_TIME']) . PHP_EOL;
     echo PHP_EOL;
     // Datas
     echo $GLOBALS['Language']->getText('plugin_docman', 'format_id') . $sep;
     echo $GLOBALS['Language']->getText('plugin_docman', 'format_path') . $sep;
     echo $GLOBALS['Language']->getText('plugin_docman', 'format_type') . $sep;
     foreach ($this->getUgroups() as $id => $name) {
         echo $name . $sep;
     }
     echo PHP_EOL;
     foreach ($output as $itemid => $row) {
         echo $itemid . $sep;
         echo tocsv($row['title'], $sep) . $sep;
         echo $this->itemTypeToString($row['type']) . $sep;
         foreach ($this->getUgroups() as $id => $name) {
             if (isset($row[$id])) {
                 $this->itemPermToString($row[$id]);
             }
             echo $sep;
         }
         echo PHP_EOL;
     }
 }