mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-02-08 07:54:13 +01:00
fix phpdoc, resolve a dependency
This commit is contained in:
parent
ba3d2aeeaf
commit
f8ad93e23a
@ -45,12 +45,20 @@ class Application extends App {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$container->registerService('BookmarkController', function($c) {
|
$container->registerService('BookmarkController', function($c) {
|
||||||
|
if(method_exists($c->query('ServerContainer'), 'getL10NFactory')) {
|
||||||
|
$l = $c->query('ServerContainer')->getL10NFactory()->get('bookmarks');
|
||||||
|
} else {
|
||||||
|
// OC 8.1 compatibility
|
||||||
|
$l = new \OC_L10N('bookmarks');
|
||||||
|
}
|
||||||
|
|
||||||
/** @var IContainer $c */
|
/** @var IContainer $c */
|
||||||
return new BookmarkController(
|
return new BookmarkController(
|
||||||
$c->query('AppName'),
|
$c->query('AppName'),
|
||||||
$c->query('Request'),
|
$c->query('Request'),
|
||||||
$c->query('ServerContainer')->getUserSession()->getUser()->getUID(),
|
$c->query('ServerContainer')->getUserSession()->getUser()->getUID(),
|
||||||
$c->query('ServerContainer')->getDb()
|
$c->query('ServerContainer')->getDb(),
|
||||||
|
$l
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class Bookmarks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Finds all tags for bookmarks
|
* @brief Finds all tags for bookmarks
|
||||||
* @param $userId UserId
|
* @param string $userId UserId
|
||||||
* @param IDb $db Database Interface
|
* @param IDb $db Database Interface
|
||||||
* @param filterTags array of tag to look for if empty then every tag
|
* @param filterTags array of tag to look for if empty then every tag
|
||||||
* @param offset integer offset
|
* @param offset integer offset
|
||||||
@ -62,10 +62,10 @@ class Bookmarks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Finds Bookmark with certain ID
|
* @brief Finds Bookmark with certain ID
|
||||||
* @param $id BookmarkId
|
* @param int $id BookmarkId
|
||||||
* @param $userId UserId
|
* @param string $userId UserId
|
||||||
* @param IDb $db Database Interface
|
* @param IDb $db Database Interface
|
||||||
* @return Specific Bookmark
|
* @return array Specific Bookmark
|
||||||
*/
|
*/
|
||||||
public static function findUniqueBookmark($id, $userId, IDb $db) {
|
public static function findUniqueBookmark($id, $userId, IDb $db) {
|
||||||
$CONFIG_DBTYPE = \OCP\Config::getSystemValue('dbtype', 'sqlite');
|
$CONFIG_DBTYPE = \OCP\Config::getSystemValue('dbtype', 'sqlite');
|
||||||
@ -104,7 +104,7 @@ class Bookmarks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Finds all bookmarks, matching the filter
|
* @brief Finds all bookmarks, matching the filter
|
||||||
* @param $userid UserId
|
* @param string $userid UserId
|
||||||
* @param IDb $db Database Interface
|
* @param IDb $db Database Interface
|
||||||
* @param int $offset offset
|
* @param int $offset offset
|
||||||
* @param string $sqlSortColumn result with this column
|
* @param string $sqlSortColumn result with this column
|
||||||
@ -229,9 +229,9 @@ class Bookmarks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delete bookmark with specific id
|
* @brief Delete bookmark with specific id
|
||||||
* @param $userId UserId
|
* @param string $userId UserId
|
||||||
* @param IDb $db Database Interface
|
* @param IDb $db Database Interface
|
||||||
* @param $id Bookmark ID to delete
|
* @param int $id Bookmark ID to delete
|
||||||
* @return boolean Success of operation
|
* @return boolean Success of operation
|
||||||
*/
|
*/
|
||||||
public static function deleteUrl($userId, IDb $db, $id) {
|
public static function deleteUrl($userId, IDb $db, $id) {
|
||||||
@ -363,7 +363,7 @@ class Bookmarks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit a bookmark
|
* Edit a bookmark
|
||||||
* @param $userid UserId
|
* @param string $userid UserId
|
||||||
* @param IDb $db Database Interface
|
* @param IDb $db Database Interface
|
||||||
* @param int $id The id of the bookmark to edit
|
* @param int $id The id of the bookmark to edit
|
||||||
* @param string $url The url to set
|
* @param string $url The url to set
|
||||||
@ -417,7 +417,7 @@ class Bookmarks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a bookmark
|
* Add a bookmark
|
||||||
* @param $userid UserId
|
* @param string $userid UserId
|
||||||
* @param IDb $db Database Interface
|
* @param IDb $db Database Interface
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param string $title Name of the bookmark
|
* @param string $title Name of the bookmark
|
||||||
@ -510,9 +510,9 @@ class Bookmarks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Import Bookmarks from html formatted file
|
* @brief Import Bookmarks from html formatted file
|
||||||
* @param $user User imported Bookmarks should belong to
|
* @param string $user User imported Bookmarks should belong to
|
||||||
* @param IDb $db Database Interface
|
* @param IDb $db Database Interface
|
||||||
* @param $file Content to import
|
* @param string $file Content to import
|
||||||
* @return null
|
* @return null
|
||||||
* */
|
* */
|
||||||
public static function importFile($user, IDb $db, $file) {
|
public static function importFile($user, IDb $db, $file) {
|
||||||
@ -543,9 +543,10 @@ class Bookmarks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Load Url and receive Metadata (Title)
|
* @brief Load Url and receive Metadata (Title)
|
||||||
* @param $url Url to load and analyze
|
* @param string $url Url to load and analyze
|
||||||
* @return array Metadata for url;
|
* @return array Metadata for url;
|
||||||
* */
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public static function getURLMetadata($url) {
|
public static function getURLMetadata($url) {
|
||||||
|
|
||||||
$metadata = array();
|
$metadata = array();
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace OCA\Bookmarks\Controller\Rest;
|
namespace OCA\Bookmarks\Controller\Rest;
|
||||||
|
|
||||||
|
use OCP\IL10N;
|
||||||
use \OCP\IRequest;
|
use \OCP\IRequest;
|
||||||
use \OCP\AppFramework\ApiController;
|
use \OCP\AppFramework\ApiController;
|
||||||
use \OCP\AppFramework\Http\JSONResponse;
|
use \OCP\AppFramework\Http\JSONResponse;
|
||||||
@ -20,20 +21,29 @@ use \OCP\IDb;
|
|||||||
use \OCA\Bookmarks\Controller\Lib\Bookmarks;
|
use \OCA\Bookmarks\Controller\Lib\Bookmarks;
|
||||||
use \OCA\Bookmarks\Controller\Lib\ExportResponse;
|
use \OCA\Bookmarks\Controller\Lib\ExportResponse;
|
||||||
use \OCA\Bookmarks\Controller\Lib\Helper;
|
use \OCA\Bookmarks\Controller\Lib\Helper;
|
||||||
|
use OCP\Util;
|
||||||
|
|
||||||
class BookmarkController extends ApiController {
|
class BookmarkController extends ApiController {
|
||||||
|
|
||||||
private $userId;
|
private $userId;
|
||||||
private $db;
|
private $db;
|
||||||
|
private $l10n;
|
||||||
|
|
||||||
public function __construct($appName, IRequest $request, $userId, IDb $db) {
|
public function __construct($appName, IRequest $request, $userId, IDb $db, IL10N $l10n) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
$this->l10n = $l10n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string $type
|
||||||
|
* @param string $tag
|
||||||
|
* @param int $page
|
||||||
|
* @param string $sort
|
||||||
|
* @return JSONResponse
|
||||||
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function legacyGetBookmarks($type = "bookmark", $tag = '', $page = 0, $sort = "bookmarks_sorting_recent") {
|
public function legacyGetBookmarks($type = "bookmark", $tag = '', $page = 0, $sort = "bookmarks_sorting_recent") {
|
||||||
@ -41,6 +51,12 @@ class BookmarkController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string $type
|
||||||
|
* @param string $tag
|
||||||
|
* @param int $page
|
||||||
|
* @param string $sort
|
||||||
|
* @return JSONResponse
|
||||||
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function getBookmarks($type = "bookmark", $tag = '', $page = 0, $sort = "bookmarks_sorting_recent") {
|
public function getBookmarks($type = "bookmark", $tag = '', $page = 0, $sort = "bookmarks_sorting_recent") {
|
||||||
@ -65,10 +81,18 @@ class BookmarkController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string $url
|
||||||
|
* @param array $item
|
||||||
|
* @param int $from_own
|
||||||
|
* @param string $title
|
||||||
|
* @param bool $is_public
|
||||||
|
* @param string $description
|
||||||
|
* @return JSONResponse
|
||||||
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function newBookmark($url = "", $item = array(), $from_own = 0, $title = "", $is_public = false, $description = "") {
|
public function newBookmark($url = "", $item = array(), $from_own = 0, $title = "", $is_public = false, $description = "") {
|
||||||
|
$url_http = $url_https = '';
|
||||||
if ($from_own == 0) {
|
if ($from_own == 0) {
|
||||||
// allow only http(s) and (s)ftp
|
// allow only http(s) and (s)ftp
|
||||||
$protocols = '/^(https?|s?ftp)\:\/\//i';
|
$protocols = '/^(https?|s?ftp)\:\/\//i';
|
||||||
@ -110,11 +134,16 @@ class BookmarkController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@NoAdminRequired
|
|
||||||
*
|
|
||||||
* @param int $id
|
* @param int $id
|
||||||
|
* @param string $url
|
||||||
|
* @param array $item
|
||||||
|
* @param string $title
|
||||||
* @param bool $is_public Description
|
* @param bool $is_public Description
|
||||||
* @return \OCP\AppFramework\Http\TemplateResponse
|
* @param null $record_id
|
||||||
|
* @param string $description
|
||||||
|
* @return Http\TemplateResponse
|
||||||
|
*
|
||||||
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
//TODO id vs record_id?
|
//TODO id vs record_id?
|
||||||
public function legacyEditBookmark($id = null, $url = "", $item = array(), $title = "", $is_public = false, $record_id = null, $description = "") {
|
public function legacyEditBookmark($id = null, $url = "", $item = array(), $title = "", $is_public = false, $record_id = null, $description = "") {
|
||||||
@ -126,11 +155,16 @@ class BookmarkController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@NoAdminRequired
|
|
||||||
*
|
|
||||||
* @param int $id
|
* @param int $id
|
||||||
|
* @param string $url
|
||||||
|
* @param array $item
|
||||||
|
* @param string $title
|
||||||
* @param bool $is_public Description
|
* @param bool $is_public Description
|
||||||
* @return \OCP\AppFramework\Http\TemplateResponse
|
* @param null $record_id
|
||||||
|
* @param string $description
|
||||||
|
* @return JSONResponse
|
||||||
|
*
|
||||||
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function editBookmark($id = null, $url = "", $item = array(), $title = "", $is_public = false, $record_id = null, $description = "") {
|
public function editBookmark($id = null, $url = "", $item = array(), $title = "", $is_public = false, $record_id = null, $description = "") {
|
||||||
|
|
||||||
@ -155,22 +189,20 @@ class BookmarkController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@NoAdminRequired
|
|
||||||
*
|
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param bool $is_public Description
|
* @return JSONResponse
|
||||||
* @return \OCP\AppFramework\Http\JSONResponse
|
*
|
||||||
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function legacyDeleteBookmark($id = -1) {
|
public function legacyDeleteBookmark($id = -1) {
|
||||||
return $this->deleteBookmark($id);
|
return $this->deleteBookmark($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@NoAdminRequired
|
|
||||||
*
|
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param bool $is_public Description
|
|
||||||
* @return \OCP\AppFramework\Http\JSONResponse
|
* @return \OCP\AppFramework\Http\JSONResponse
|
||||||
|
*
|
||||||
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function deleteBookmark($id = -1) {
|
public function deleteBookmark($id = -1) {
|
||||||
if ($id == -1) {
|
if ($id == -1) {
|
||||||
@ -217,15 +249,12 @@ class BookmarkController extends ApiController {
|
|||||||
* @return \OCP\AppFramework\Http\JSONResponse
|
* @return \OCP\AppFramework\Http\JSONResponse
|
||||||
*/
|
*/
|
||||||
public function importBookmark() {
|
public function importBookmark() {
|
||||||
|
|
||||||
$l = new \OC_l10n('bookmarks');
|
|
||||||
|
|
||||||
$full_input = $this->request->getUploadedFile("bm_import");
|
$full_input = $this->request->getUploadedFile("bm_import");
|
||||||
|
|
||||||
if (empty($full_input)) {
|
if (empty($full_input)) {
|
||||||
\OCP\Util::writeLog('bookmarks', "No file provided for import", \OCP\Util::WARN);
|
Util::writeLog('bookmarks', "No file provided for import", Util::WARN);
|
||||||
$error = array();
|
$error = array();
|
||||||
$error[] = $l->t('No file provided for import');
|
$error[] = $this->l10n->t('No file provided for import');
|
||||||
} else {
|
} else {
|
||||||
$error = array();
|
$error = array();
|
||||||
$file = $full_input['tmp_name'];
|
$file = $full_input['tmp_name'];
|
||||||
@ -235,7 +264,7 @@ class BookmarkController extends ApiController {
|
|||||||
return new JSONResponse(array('status' => 'success'));
|
return new JSONResponse(array('status' => 'success'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error[] = $l->t('Unsupported file type for import');
|
$error[] = $this->l10n->t('Unsupported file type for import');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +274,7 @@ class BookmarkController extends ApiController {
|
|||||||
/**
|
/**
|
||||||
@NoAdminRequired
|
@NoAdminRequired
|
||||||
*
|
*
|
||||||
* @return \OCP\AppFramework\Http\JSONResponse
|
* @return \OCP\AppFramework\Http\Response
|
||||||
*/
|
*/
|
||||||
public function exportBookmark() {
|
public function exportBookmark() {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user