plugin wip
This commit is contained in:
@ -434,8 +434,11 @@ class Bookmarks extends Controller {
|
||||
}
|
||||
|
||||
public function import() {
|
||||
// echo '<pre>';
|
||||
|
||||
if ( !App::$isMember ) {
|
||||
Issues::add( 'notice', 'You must have an active membership to import bookmarks.' );
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
if ( ! Input::exists('submit') ) {
|
||||
return Views::view( 'bookmarks.import' );
|
||||
}
|
||||
@ -489,6 +492,11 @@ class Bookmarks extends Controller {
|
||||
}
|
||||
|
||||
public function export() {
|
||||
if ( !App::$isMember ) {
|
||||
Issues::add( 'notice', 'You must have an active membership to export bookmarks.' );
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
$folders = self::$folders->byUser();
|
||||
|
||||
if ( ! Input::exists('submit') ) {
|
||||
@ -544,6 +552,35 @@ class Bookmarks extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function share( $id = '' ) {
|
||||
$panelArray = [];
|
||||
$folders = self::$folders->byUser();
|
||||
if ( empty( $folders ) ) {
|
||||
return Views::view( 'bookmarks.share' );
|
||||
}
|
||||
foreach ( $folders as $key => $folder ) {
|
||||
$panel = new \stdClass();
|
||||
$folderObject = new \stdClass();
|
||||
if ( $folder->privacy == 'private' ) {
|
||||
$links = self::$bookmarks->publicByFolder( $folder->ID );
|
||||
} else {
|
||||
$links = self::$bookmarks->byFolder( $folder->ID );
|
||||
}
|
||||
$folderObject->bookmarks = $links;
|
||||
|
||||
$folderObject->ID = $folder->ID;
|
||||
$folderObject->uuid = $folder->uuid;
|
||||
$folderObject->title = $folder->title;
|
||||
$folderObject->color = $folder->color;
|
||||
$folderObject->privacyBadge = $folder->privacyBadge;
|
||||
|
||||
$folderObject->bookmarkListRows = Views::simpleView( 'bookmarks.components.shareListRows', $folderObject->bookmarks );
|
||||
$panel->panel = Views::simpleView( 'bookmarks.components.shareListPanel', [$folderObject] );
|
||||
$panelArray[] = $panel;
|
||||
}
|
||||
return Views::view( 'bookmarks.share', $panelArray );
|
||||
}
|
||||
|
||||
private function exportFolder( $title, $editedAt, $createdAt, $links ) {
|
||||
$htmlDoc = '<DT><H3 ADD_DATE="'.$createdAt.'" LAST_MODIFIED="'.$editedAt.'">'.$title.'</H3>' . PHP_EOL;
|
||||
$htmlDoc .= '<DL><p>' . PHP_EOL;
|
||||
@ -561,37 +598,7 @@ class Bookmarks extends Controller {
|
||||
return $htmlDoc;
|
||||
}
|
||||
|
||||
public function share( $id = '' ) {
|
||||
$panelArray = [];
|
||||
$folders = self::$folders->byUser();
|
||||
foreach ( $folders as $key => $folder ) {
|
||||
$panel = new \stdClass();
|
||||
$folderObject = new \stdClass();
|
||||
if ( $folder->privacy == 'private' ) {
|
||||
$folderObject->privacyBadge = '<span class="mx-2 badge bg-success">Private</span>';
|
||||
$links = self::$bookmarks->publicByFolder( $folder->ID );
|
||||
} else {
|
||||
$folderObject->privacyBadge = '<span class="mx-2 badge bg-danger">Public</span>';
|
||||
$links = self::$bookmarks->byFolder( $folder->ID );
|
||||
}
|
||||
$folderObject->bookmarks = $links;
|
||||
|
||||
$folderObject->ID = $folder->ID;
|
||||
$folderObject->uuid = $folder->uuid;
|
||||
$folderObject->title = $folder->title;
|
||||
$folderObject->color = $folder->color;
|
||||
|
||||
|
||||
|
||||
$folderObject->bookmarkListRows = Views::simpleView( 'bookmarks.components.shareListRows', $folderObject->bookmarks );
|
||||
$panel->panel = Views::simpleView( 'bookmarks.components.shareListPanel', [$folderObject] );
|
||||
$panelArray[] = $panel;
|
||||
}
|
||||
return Views::view( 'bookmarks.share', $panelArray );
|
||||
}
|
||||
|
||||
public function parseBookmarks($htmlContent)
|
||||
{
|
||||
private function parseBookmarks($htmlContent) {
|
||||
$started = false;
|
||||
$out = [];
|
||||
$currentFolder = [];
|
||||
|
@ -35,29 +35,6 @@ class Shared extends Controller {
|
||||
Components::set( 'SITE_URL', Routes::getAddress() );
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$bookmarks = self::$bookmarks->noFolder();
|
||||
$folders = self::$folders->byUser();
|
||||
|
||||
$panelArray = [];
|
||||
if ( !empty( $folders ) ) {
|
||||
foreach ( $folders as $folder ) {
|
||||
$panel = new \stdClass();
|
||||
$folderObject = new \stdClass();
|
||||
$folderObject->bookmarks = self::$bookmarks->byFolder( $folder->ID );
|
||||
$folderObject->ID = $folder->ID;
|
||||
$folderObject->title = $folder->title;
|
||||
$folderObject->color = $folder->color;
|
||||
$folderObject->bookmarkListRows = Views::simpleView( 'bookmarks.components.bookmarkListRows', $folderObject->bookmarks );
|
||||
$panelArray[] = $folderObject;
|
||||
}
|
||||
}
|
||||
Components::set( 'foldersList', Views::simpleView( 'bookmarks.folders.list', $folders ) );
|
||||
Components::set( 'folderPanels', Views::simpleView( 'bookmarks.components.bookmarkListPanel', $panelArray ) );
|
||||
Components::set( 'bookmarksList', Views::simpleView( 'bookmarks.bookmarks.list', $bookmarks ) );
|
||||
return Views::view( 'bookmarks.dash' );
|
||||
}
|
||||
|
||||
public function shared( $type = '', $id = '' ) {
|
||||
if ( empty( $type ) ) {
|
||||
Session::flash( 'error', 'Unknown share' );
|
||||
@ -105,7 +82,7 @@ class Shared extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Views::view( 'bookmarks.shareLink', $bookmark );
|
||||
return Views::view( 'bookmarks.public.bookmark', $bookmark );
|
||||
}
|
||||
|
||||
public function folder( $id = '' ) {
|
||||
@ -122,6 +99,9 @@ class Shared extends Controller {
|
||||
Session::flash( 'error', 'Unknown share' );
|
||||
return Redirect::to( 'home/index' );
|
||||
}
|
||||
return Views::view( 'bookmarks.shareFolder', $folder );
|
||||
$folder->bookmarks = self::$bookmarks->unsafeByFolder( $folder->ID );
|
||||
$folder->bookmarkListRows = Views::simpleView( 'bookmarks.components.publicListRows', $folder->bookmarks );
|
||||
$folder->panel = Views::simpleView( 'bookmarks.components.publicList', [$folder] );
|
||||
return Views::view( 'bookmarks.public.folder', $folder );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user