| @@ 195-223 (lines=29) @@ | ||
| 192 | * @since 1.5 |
|
| 193 | * @return string|false |
|
| 194 | */ |
|
| 195 | public function print_csv_rows() { |
|
| 196 | ||
| 197 | $row_data = ''; |
|
| 198 | $data = $this->get_data(); |
|
| 199 | $cols = $this->get_csv_cols(); |
|
| 200 | ||
| 201 | if ( $data ) { |
|
| 202 | ||
| 203 | // Output each row |
|
| 204 | foreach ( $data as $row ) { |
|
| 205 | $i = 1; |
|
| 206 | foreach ( $row as $col_id => $column ) { |
|
| 207 | // Make sure the column is valid |
|
| 208 | if ( array_key_exists( $col_id, $cols ) ) { |
|
| 209 | $row_data .= '"' . addslashes( preg_replace( '/"/', "'", $column ) ) . '"'; |
|
| 210 | $row_data .= $i == count( $cols ) ? '' : ','; |
|
| 211 | $i ++; |
|
| 212 | } |
|
| 213 | } |
|
| 214 | $row_data .= "\r\n"; |
|
| 215 | } |
|
| 216 | ||
| 217 | $this->stash_step_data( $row_data ); |
|
| 218 | ||
| 219 | return $row_data; |
|
| 220 | } |
|
| 221 | ||
| 222 | return false; |
|
| 223 | } |
|
| 224 | ||
| 225 | /** |
|
| 226 | * Return the calculated completion percentage. |
|
| @@ 567-595 (lines=29) @@ | ||
| 564 | * |
|
| 565 | * @return string|false |
|
| 566 | */ |
|
| 567 | public function print_csv_rows() { |
|
| 568 | ||
| 569 | $row_data = ''; |
|
| 570 | $data = $this->get_data(); |
|
| 571 | $cols = $this->get_csv_cols(); |
|
| 572 | ||
| 573 | if ( $data ) { |
|
| 574 | ||
| 575 | // Output each row |
|
| 576 | foreach ( $data as $row ) { |
|
| 577 | $i = 1; |
|
| 578 | foreach ( $row as $col_id => $column ) { |
|
| 579 | // Make sure the column is valid |
|
| 580 | if ( array_key_exists( $col_id, $cols ) ) { |
|
| 581 | $row_data .= '"' . preg_replace( '/"/', "'", $column ) . '"'; |
|
| 582 | $row_data .= $i == count( $cols ) ? '' : ','; |
|
| 583 | $i ++; |
|
| 584 | } |
|
| 585 | } |
|
| 586 | $row_data .= "\r\n"; |
|
| 587 | } |
|
| 588 | ||
| 589 | $this->stash_step_data( $row_data ); |
|
| 590 | ||
| 591 | return $row_data; |
|
| 592 | } |
|
| 593 | ||
| 594 | return false; |
|
| 595 | } |
|
| 596 | } |
|
| 597 | ||