declared class properties

This commit is contained in:
benson
2023-04-29 21:15:52 +08:00
parent 13fd802180
commit a197f66d6d
16 changed files with 65 additions and 14 deletions

View File

@@ -8,7 +8,7 @@ Search for torrents within the app from mutiple BT sites;
Control Aria2 and manage download tasks from the web; Control Aria2 and manage download tasks from the web;
download videos from 700+ video sites(youtube,youku,vimo,dailymotion,twitter,facebook and the likes download videos from 700+ video sites(youtube,youku,vimo,dailymotion,twitter,facebook and the likes
</description> </description>
<version>1.0.6</version> <version>1.0.7</version>
<licence>agpl</licence> <licence>agpl</licence>
<author mail="freefallbenson@gmail.com" homepage="https://github.com/shiningw">jiaxinhuang</author> <author mail="freefallbenson@gmail.com" homepage="https://github.com/shiningw">jiaxinhuang</author>
<namespace>NCDownloader</namespace> <namespace>NCDownloader</namespace>

View File

@@ -16,7 +16,7 @@ class Aria2
//optional token for authenticating with Aria2 //optional token for authenticating with Aria2
private $token = null; private $token = null;
//the aria2 method being invoked //the aria2 method being invoked
private $method = null; public $methodName = null;
//the aria2c binary path //the aria2c binary path
private $bin = null; private $bin = null;
// return the following items when getting downloads info by default // return the following items when getting downloads info by default
@@ -35,6 +35,13 @@ class Aria2
private $rpcUrl; private $rpcUrl;
//php binary path; //php binary path;
private $php; private $php;
//curl handle
private $ch;
//aria2 global options
private $onDownloadStart;
private $content;
private $torrentsDir;
public function __construct($options = array()) public function __construct($options = array())
{ {
$options += [ $options += [

View File

@@ -25,6 +25,16 @@ class MainController extends Controller
private $config; private $config;
private $aria2Opts; private $aria2Opts;
private $l10n; private $l10n;
private $urlGenerator;
private $uid;
private $isAdmin;
private $hideError;
private $disable_bt_nonadmin;
private $aria2;
private $dbconn;
private $counters;
private $ytdl;
private $accessDenied;
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl) public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl)
{ {

View File

@@ -10,10 +10,13 @@ use OCA\NCDownloader\Tools\Helper;
class SearchController extends Controller class SearchController extends Controller
{ {
private $userId; private $uid;
private $settings = null; private $settings = null;
//@config OC\AppConfig //@config OC\AppConfig
private $l10n; private $l10n;
private $urlGenerator;
private $search;
public function __construct($appName, IRequest $request, $UserId) public function __construct($appName, IRequest $request, $UserId)
{ {

View File

@@ -15,13 +15,15 @@ class SettingsController extends Controller
//@config OC\AppConfig //@config OC\AppConfig
private $config; private $config;
public function __construct($AppName, IRequest $Request, $UserId) //, IL10N $L10N) private $uid;
private $settings;
public function __construct($AppName, IRequest $Request, $uid) //, IL10N $L10N)
{ {
parent::__construct($AppName, $Request); parent::__construct($AppName, $Request);
$this->UserId = $UserId; $this->uid = $uid;
//$this->L10N = $L10N; //$this->L10N = $L10N;
$this->settings = new Settings($UserId); $this->settings = new Settings($uid);
//$this->config = \OC::$server->getAppConfig(); //$this->config = \OC::$server->getAppConfig();
} }
@@ -94,7 +96,7 @@ class SettingsController extends Controller
public function saveCustomAria2() public function saveCustomAria2()
{ {
$noAria2Settings = (bool) Helper::getAdminSettings("disallow_aria2_settings"); $noAria2Settings = (bool) Helper::getAdminSettings("disallow_aria2_settings");
if ($noAria2Settings && !\OC_User::isAdminUser($this->UserId)) { if ($noAria2Settings && !\OC_User::isAdminUser($this->uid)) {
$resp = ["error" => "forbidden", "status" => false]; $resp = ["error" => "forbidden", "status" => false];
return new JSONResponse($resp); return new JSONResponse($resp);
} }

View File

@@ -17,6 +17,15 @@ class YtdlController extends Controller
//@config OC\AppConfig //@config OC\AppConfig
private $l10n; private $l10n;
private $audio_extensions = array("mp3", "m4a", "vorbis"); private $audio_extensions = array("mp3", "m4a", "vorbis");
private $video_extensions = array("mp4", "webm", "mkv");
private $uid;
private $downloadDir;
private $dbconn;
private $ytdl;
private $aria2;
private $urlGenerator;
private $tablename;
private $dataDir;
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl) public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl)
{ {

View File

@@ -7,6 +7,8 @@ class Helper
//@var OC\DB\ConnectionAdapter //@var OC\DB\ConnectionAdapter
private $conn; private $conn;
private $table = "ncdownloader_info"; private $table = "ncdownloader_info";
private $prefixedTable;
public $queryBuilder;
public function __construct() public function __construct()
{ {

View File

@@ -86,7 +86,7 @@ class Settings extends AllConfig
$this->allConfig->setAppValue($this->appName, $key, $value); $this->allConfig->setAppValue($this->appName, $key, $value);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
return ['error' => $e->getMessage]; return ['error' => $e->getMessage()];
} }
return ['message' => "Saved!"]; return ['message' => "Saved!"];

View File

@@ -7,6 +7,7 @@ use Symfony\Component\HttpClient\HttpClient;
final class Client final class Client
{ {
private $client;
public function __construct(?array $options = null) public function __construct(?array $options = null)
{ {
$this->client = HttpClient::create($this->configure($options)); $this->client = HttpClient::create($this->configure($options));

View File

@@ -8,6 +8,9 @@ abstract class searchBase
protected $tableTitles = []; protected $tableTitles = [];
protected $rows = []; protected $rows = [];
protected $errors = []; protected $errors = [];
protected $searchUrl;
protected $crawler;
protected $client;
protected $actionLinks = [["name" => 'download', 'path' => '/index.php/apps/ncdownloader/new'], ['name' => 'clipboard']]; protected $actionLinks = [["name" => 'download', 'path' => '/index.php/apps/ncdownloader/new'], ['name' => 'clipboard']];
public function getTableTitles(): array public function getTableTitles(): array

View File

@@ -29,8 +29,6 @@ class Admin implements ISettings
$this->connection = $connection; $this->connection = $connection;
$this->timeFactory = $timeFactory; $this->timeFactory = $timeFactory;
$this->config = $config; $this->config = $config;
$this->UserId = \OC::$server->getUserSession()->getUser()->getUID();
$this->settings = new Settings($this->UserId);
} }
/** /**

View File

@@ -19,6 +19,8 @@ class Personal implements ISettings
private $timeFactory; private $timeFactory;
/** @var IConfig */ /** @var IConfig */
private $config; private $config;
private $uid;
private $settings;
public function __construct( public function __construct(
IDBConnection $connection, IDBConnection $connection,
@@ -28,8 +30,8 @@ class Personal implements ISettings
$this->connection = $connection; $this->connection = $connection;
$this->timeFactory = $timeFactory; $this->timeFactory = $timeFactory;
$this->config = $config; $this->config = $config;
$this->UserId = \OC::$server->getUserSession()->getUser()->getUID(); $this->uid = \OC::$server->getUserSession()->getUser()->getUID();
$this->settings = new Settings($this->UserId); $this->settings = new Settings($this->uid);
} }
/** /**
@@ -46,7 +48,7 @@ class Personal implements ISettings
'ncd_seed_time' => $this->settings->get("ncd_seed_time"), 'ncd_seed_time' => $this->settings->get("ncd_seed_time"),
"path" => '/apps/ncdownloader/personal/save', "path" => '/apps/ncdownloader/personal/save',
"disallow_aria2_settings" => Helper::getAdminSettings("disallow_aria2_settings"), "disallow_aria2_settings" => Helper::getAdminSettings("disallow_aria2_settings"),
"is_admin" => \OC_User::isAdminUser($this->UserId), "is_admin" => \OC_User::isAdminUser($this->uid),
] ]
]; ];

View File

@@ -8,6 +8,9 @@ use OCA\NCDownloader\Db\Helper as DbHelper;
class Counters class Counters
{ {
private $minmax = [0, 999]; private $minmax = [0, 999];
private $aria2;
private $dbconn;
private $uid;
public function __construct(Aria2 $aria2, DbHelper $dbconn, $uid) public function __construct(Aria2 $aria2, DbHelper $dbconn, $uid)
{ {

View File

@@ -11,6 +11,8 @@ class folderScan
private $user; private $user;
private $path; private $path;
private $realDir; private $realDir;
private $logger;
private $scanner;
public function __construct($path = null, $user = null) public function __construct($path = null, $user = null)
{ {
$this->user = $user ?? Helper::getUID(); $this->user = $user ?? Helper::getUID();

View File

@@ -8,6 +8,13 @@ class Helper
{ {
public $file = null; public $file = null;
protected $pid = 0; protected $pid = 0;
protected $dbconn;
protected $tablename;
protected $user;
protected $tools;
protected $gid;
protected $ytdl;
protected $status;
public function __construct() public function __construct()
{ {
$this->dbconn = new DbHelper(); $this->dbconn = new DbHelper();

View File

@@ -20,6 +20,8 @@ class Ytdl
private $defaultDir = "/tmp/downloads"; private $defaultDir = "/tmp/downloads";
private $env = []; private $env = [];
private $bin; private $bin;
private $cmd;
public $helper;
public function __construct(array $options) public function __construct(array $options)
{ {