diff --git a/.gitignore b/.gitignore index 2c74cbb..eaa41c2 100644 --- a/.gitignore +++ b/.gitignore @@ -56,7 +56,6 @@ Temporary Items .htaccess app/config/* !app/config/constants.php -uploads/images/* logs/* .vscode/ mail.log diff --git a/app/plugins/bookmarks/controllers/bookmarks.php b/app/plugins/bookmarks/controllers/bookmarks.php index 3b5cffe..27a1aa6 100644 --- a/app/plugins/bookmarks/controllers/bookmarks.php +++ b/app/plugins/bookmarks/controllers/bookmarks.php @@ -434,8 +434,11 @@ class Bookmarks extends Controller { } public function import() { - // echo '
'; - + 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 = '
' . 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 = 'Private';
- $links = self::$bookmarks->publicByFolder( $folder->ID );
- } else {
- $folderObject->privacyBadge = 'Public';
- $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 = [];
diff --git a/app/plugins/bookmarks/controllers/shared.php b/app/plugins/bookmarks/controllers/shared.php
index 55c4b72..322c709 100644
--- a/app/plugins/bookmarks/controllers/shared.php
+++ b/app/plugins/bookmarks/controllers/shared.php
@@ -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 );
}
}
diff --git a/app/plugins/bookmarks/models/bookmarks.php b/app/plugins/bookmarks/models/bookmarks.php
index 7c95374..9d289fa 100644
--- a/app/plugins/bookmarks/models/bookmarks.php
+++ b/app/plugins/bookmarks/models/bookmarks.php
@@ -42,7 +42,7 @@ class Bookmarks extends DatabaseModel {
[ 'hiddenAt', 'int', '11' ],
[ 'order', 'int', '11' ],
[ 'linkType', 'varchar', '32' ],
- [ 'uuid', 'char', '36' ],
+ [ 'uuid', 'uuid', '36' ],
];
/**
@@ -132,6 +132,20 @@ class Bookmarks extends DatabaseModel {
return $this->filter( $bookmarks->results() );
}
+ public function unsafeByFolder( $id, $limit = null ) {
+ $whereClause = [ 'folderID', '=', $id ];
+ if ( empty( $limit ) ) {
+ $bookmarks = self::$db->get( $this->tableName, $whereClause );
+ } else {
+ $bookmarks = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] );
+ }
+ if ( !$bookmarks->count() ) {
+ Debug::info( 'No Bookmarks found.' );
+ return false;
+ }
+ return $this->filter( $bookmarks->results() );
+ }
+
public function byFolder( $id, $limit = null ) {
$whereClause = ['createdBy', '=', App::$activeUser->ID, 'AND'];
@@ -349,34 +363,48 @@ class Bookmarks extends DatabaseModel {
$instance->iconHtml = '';
}
}
-
+
if ( $instance->privacy == 'private' ) {
- $instance->privacyBadge = 'Private';
+ $instance->privacyBadge = 'Private';
} else {
- $instance->privacyBadge = 'Public';
+ $instance->privacyBadge = 'Public';
+ }
+
+ if ( $instance->privacy == 'private' ) {
+ $instance->publish = '
+
+
+ ';
+ } else {
+ $instance->publish = '
+
+
+ ';
}
if ( empty( $instance->hiddenAt ) ) {
$instance->hideBtn = '
-
+
';
} else {
$instance->hideBtn = '
-
+
';
}
+
if ( empty( $instance->archivedAt ) ) {
$instance->archiveBtn = '
-
+
';
} else {
$instance->archiveBtn = '
-
+
';
}
+
if ( ! empty( $instance->refreshedAt ) && time() < ( $instance->refreshedAt + ( 60 * 10 ) ) ) {
$instance->refreshBtn = '
@@ -445,6 +473,7 @@ class Bookmarks extends DatabaseModel {
}
return true;
}
+
public function retract( $id ) {
if ( !Check::id( $id ) ) {
Debug::info( 'Bookmarks: illegal ID.' );
@@ -461,7 +490,6 @@ class Bookmarks extends DatabaseModel {
return true;
}
-
public function archive( $id ) {
if ( !Check::id( $id ) ) {
Debug::info( 'Bookmarks: illegal ID.' );
diff --git a/app/plugins/bookmarks/models/bookmarkviews.php b/app/plugins/bookmarks/models/bookmarkviews.php
index 29a4e54..75fab4c 100644
--- a/app/plugins/bookmarks/models/bookmarkviews.php
+++ b/app/plugins/bookmarks/models/bookmarkviews.php
@@ -25,10 +25,20 @@ class Bookmarkviews extends DatabaseModel {
[ 'title', 'varchar', '256' ],
[ 'description', 'text', '' ],
[ 'privacy', 'varchar', '48' ],
+
+
+
+
+
+
+
+
+
+
[ 'createdBy', 'int', '11' ],
[ 'createdAt', 'int', '11' ],
[ 'updatedAt', 'int', '11' ],
- [ 'uuid', 'char', '36' ],
+ [ 'uuid', 'text', '' ],
];
/**
diff --git a/app/plugins/bookmarks/models/folders.php b/app/plugins/bookmarks/models/folders.php
index d153783..a04b05a 100644
--- a/app/plugins/bookmarks/models/folders.php
+++ b/app/plugins/bookmarks/models/folders.php
@@ -29,7 +29,7 @@ class Folders extends DatabaseModel {
[ 'folderID', 'int', '11' ],
[ 'createdBy', 'int', '11' ],
[ 'createdAt', 'int', '11' ],
- [ 'uuid', 'char', '36' ],
+ [ 'uuid', 'text', '' ],
];
/**
@@ -197,6 +197,13 @@ class Folders extends DatabaseModel {
// Real Work Starts Here
$instance->prettyPrivacy = ucfirst( $instance->privacy );
$instance->prettyTitle = ucfirst( $instance->title );
+
+ if ( $instance->privacy == 'private' ) {
+ $instance->privacyBadge = 'Private';
+ } else {
+ $instance->privacyBadge = 'Public';
+ }
+
// Real Work Ends Here
$out[] = $instance;
if ( !empty( $end ) ) {
diff --git a/app/plugins/bookmarks/plugin.php b/app/plugins/bookmarks/plugin.php
index 45b5b43..2eec9ac 100644
--- a/app/plugins/bookmarks/plugin.php
+++ b/app/plugins/bookmarks/plugin.php
@@ -43,6 +43,10 @@ class Bookmarks extends Plugin {
'url' => '{ROOT_URL}bookmarks/index',
'filter' => 'loggedin',
],
+ [
+ 'text' => 'Extensions',
+ 'url' => '{ROOT_URL}extensions/index',
+ ],
];
public $configMatrix = [
'enabled' => [
diff --git a/app/plugins/bookmarks/views/bookmarks/create.html b/app/plugins/bookmarks/views/bookmarks/create.html
index 8069266..f4559a1 100644
--- a/app/plugins/bookmarks/views/bookmarks/create.html
+++ b/app/plugins/bookmarks/views/bookmarks/create.html
@@ -1,51 +1,56 @@
-