diff --git a/application/controllers/Export.php b/application/controllers/Export.php index efb5668a..5bbf6f26 100644 --- a/application/controllers/Export.php +++ b/application/controllers/Export.php @@ -70,4 +70,113 @@ public function index() } } + /** + * Generate HTML export file for current user + * Spec: Based on Netscape / Firefox export HTML + */ + public function html() + { + + $html = " + + + Unmark Export +

Bookmarks

" . "\n\n"; + + $html .= "
" . "\n"; + // Enable export library + $this->load->library('JSONExport'); + // Add import version info + //$this->jsonexport->addMeta('export_version', self::EXPORT_FILE_VERSION); + //$this->jsonexport->addMeta('export_date', date('Y-m-d H:i:s')); + // Retrieve user marks + $this->load->model('users_to_marks_model', 'user_marks'); + $where = 'users_to_marks.user_id='. $this->user_id; + $marksCount = $this->user_marks->count($where); + // Number of marks + //$this->jsonexport->addMeta('marks_count', $marksCount); + $pages = ceil((double) $marksCount / (double) self::PAGE_SIZE); + // Get page of data + for($curPage=1;$curPage<=$pages;$curPage++){ + $pageResults = $this->user_marks->readComplete($where, self::PAGE_SIZE, $curPage); + + // Add all retrieved marks + if(is_array($pageResults)){ + foreach($pageResults as $key=>$singleMark){ + + //$this->jsonexport->addMark($singleMark); + //print_r($key); + //print_r($singleMark); + $html .= "
url . "\" + ADD_DATE=\"" . strtotime( $singleMark->created_on ) . "\""; + if ( !empty($singleMark->tags) && count($singleMark->tags) > 0 ) : + //print_r($singleMark->tags); + $tags = ""; + + foreach($singleMark->tags as $tag=>$meta) { + $tags .= $tag . ","; + } + + $html .= " TAGS=" . $tags; + endif; + + $html .= ">" . $singleMark->title . "" . "\n"; + + if ( !empty($singleMark->notes) ) : + $html .= "
" . $singleMark->notes . "\n\n"; + else : + $html .= "\n"; + endif; + } + // Add single mark + } else if(!empty($pageResults)){ + + //$this->jsonexport->addMark($pageResults); + $singleMark = $pageResults; + //$this->jsonexport->addMark($singleMark); + //print_r($key); + //print_r($singleMark); + $html .= "
url . "\" + ADD_DATE=\"" . strtotime( $singleMark->created_on ) . "\""; + if ( !empty($singleMark->tags) && count($singleMark->tags) > 0 ) : + //print_r($singleMark->tags); + $tags = ""; + + foreach($singleMark->tags as $tag=>$meta) { + $tags .= $tag . ","; + } + + $html .= " TAGS=" . $tags; + endif; + + $html .= ">" . $singleMark->title . "" . "\n"; + + if ( !empty($singleMark->notes) ) : + $html .= "
" . $singleMark->notes . "\n\n"; + else : + $html .= "\n"; + endif; + } + } + + $html .= "
" . "\n\n"; + + echo $html; + exit; + + // Write the file as attachment + //$file = $this->jsonexport->getFileForOutput(); + header('Content-type: text/html'); + header('Content-Disposition: attachment; filename=' . 'unmark-export.html'); + + echo $html; + //while (!$file->eof()) { + // $this->output->append_output($file->fgets()); + //} + } + } \ No newline at end of file diff --git a/application/views/layouts/userforms.php b/application/views/layouts/userforms.php index c7666278..6352a4de 100644 --- a/application/views/layouts/userforms.php +++ b/application/views/layouts/userforms.php @@ -31,9 +31,14 @@
-

+

- +
+ +
+
+ +
diff --git a/assets/css/partials/_overlays.scss b/assets/css/partials/_overlays.scss index 0379ab98..ff9d8270 100644 --- a/assets/css/partials/_overlays.scss +++ b/assets/css/partials/_overlays.scss @@ -7,7 +7,7 @@ padding-bottom: 20px; } } - .from-unmark, .from-other { + .from-unmark, .from-other, .to-html, .to-unmark { padding: 0 0 12px; p { font-size: 12px; diff --git a/assets/js/unmark.client.js b/assets/js/unmark.client.js index 816caede..c690b5fc 100644 --- a/assets/js/unmark.client.js +++ b/assets/js/unmark.client.js @@ -97,11 +97,16 @@ } }; - // Export Data + // Export Data to Unmark unmark.export_data = function () { return window.location.href = "/export"; }; + // Export Data to HTML + unmark.export_data_html = function () { + return window.location.href = "/export/html"; + }; + // Import Data unmark.import_data = function () { return $('#importerUnmark').trigger('click');