|
@@ -21,8 +21,6 @@ class TorrentForm
|
21
|
21
|
public $ImgPlatforms = [];
|
22
|
22
|
public $DocPlatforms = [];
|
23
|
23
|
public $RawPlatforms = [];
|
24
|
|
- #public $Media = [];
|
25
|
|
- #public $MediaManga = [];
|
26
|
24
|
|
27
|
25
|
# Formats
|
28
|
26
|
# See classes/config.php
|
|
@@ -36,22 +34,12 @@ class TorrentForm
|
36
|
34
|
public $BinDocFormats = [];
|
37
|
35
|
public $CpuGenFormats = [];
|
38
|
36
|
public $PlainFormats = [];
|
39
|
|
- #public $Containers = [];
|
40
|
|
- #public $ContainersGames = [];
|
41
|
|
- #public $ContainersProt = [];
|
42
|
|
- #public $ContainersExtra = [];
|
43
|
37
|
|
44
|
38
|
# Misc
|
45
|
39
|
public $Codecs = [];
|
46
|
40
|
public $Archives = [];
|
47
|
41
|
public $Resolutions = [];
|
48
|
42
|
|
49
|
|
- # Deprecated
|
50
|
|
- #public $Formats = [];
|
51
|
|
- #public $Versions = [];
|
52
|
|
- #public $Bitrates = [];
|
53
|
|
- #public $Platform = [];
|
54
|
|
-
|
55
|
43
|
# Gazelle
|
56
|
44
|
public $NewTorrent = false;
|
57
|
45
|
public $Torrent = [];
|
|
@@ -84,7 +72,6 @@ class TorrentForm
|
84
|
72
|
$this->RawPlatforms = $RawPlatforms;
|
85
|
73
|
|
86
|
74
|
# Formats
|
87
|
|
- # See classes/config.php
|
88
|
75
|
$this->SeqFormats = $SeqFormats;
|
89
|
76
|
$this->ProtFormats = $ProtFormats;
|
90
|
77
|
$this->GraphXmlFormats = $GraphXmlFormats;
|
|
@@ -110,105 +97,91 @@ class TorrentForm
|
110
|
97
|
|
111
|
98
|
|
112
|
99
|
/**
|
113
|
|
- * ========================
|
114
|
|
- * = New functional class =
|
115
|
|
- * ========================
|
116
|
|
- *
|
117
|
|
- * Contains functions that output discreet torrent form fields.
|
118
|
|
- * Useful for <?= echoing in skeleton tables in the sections.
|
119
|
|
- */
|
|
100
|
+ * ====================
|
|
101
|
+ * = Twig based class =
|
|
102
|
+ * ====================
|
|
103
|
+ */
|
120
|
104
|
|
121
|
105
|
|
122
|
106
|
/**
|
123
|
|
- * Upload notice
|
|
107
|
+ * render
|
124
|
108
|
*
|
125
|
|
- * Broken into multiple NewTorrent tests for sanity.
|
126
|
|
- * Each if statement should contain one discreet content block.
|
|
109
|
+ * TorrentForm Twig wrapper.
|
|
110
|
+ * Hopefully more pleasant.
|
127
|
111
|
*/
|
128
|
|
- public function uploadNotice()
|
|
112
|
+ public function render()
|
129
|
113
|
{
|
130
|
|
- if ($this->NewTorrent) {
|
131
|
|
- $Twig = Twig::go();
|
132
|
|
- echo $Twig->render('torrent_form/upload_notice.html');
|
133
|
|
- } # fi NewTorrent
|
134
|
|
- }
|
135
|
|
-
|
|
114
|
+ $ENV = ENV::go();
|
|
115
|
+ $Twig = Twig::go();
|
136
|
116
|
|
137
|
|
- /**
|
138
|
|
- * Announce URLs
|
139
|
|
- *
|
140
|
|
- * Announce URLs displayed on the form.
|
141
|
|
- * They're added to torrents in torrentsdl.class.php.
|
142
|
|
- * Bio Gazelle supports tiered swarms, T1 private and T2 public.
|
143
|
|
- */
|
144
|
|
- public function announceSource()
|
145
|
|
- {
|
|
117
|
+ /**
|
|
118
|
+ * Upload notice
|
|
119
|
+ */
|
146
|
120
|
if ($this->NewTorrent) {
|
147
|
|
- $HTML = '<aside class="announce_source">';
|
|
121
|
+ echo $Twig->render('torrent_form/notice.html');
|
|
122
|
+ }
|
148
|
123
|
|
|
124
|
+ /**
|
|
125
|
+ * Announce and source
|
|
126
|
+ */
|
|
127
|
+ if ($this->NewTorrent) {
|
149
|
128
|
$Announces = ANNOUNCE_URLS[0];
|
150
|
129
|
#$Announces = call_user_func_array('array_merge', ANNOUNCE_URLS);
|
|
130
|
+
|
151
|
131
|
$TorrentPass = G::$LoggedUser['torrent_pass'];
|
|
132
|
+ $TorrentSource = Users::get_upload_sources()[0];
|
152
|
133
|
|
153
|
|
- foreach ($Announces as $Announce) {
|
154
|
|
- $HTML .= <<<HTML
|
155
|
|
- <p>
|
156
|
|
- <strong>Announce</strong>
|
157
|
|
- <input type="text"
|
158
|
|
- value="$Announce/$TorrentPass/announce"
|
159
|
|
- size="60" readonly="readonly"
|
160
|
|
- onclick="this.select();" />
|
161
|
|
- </p>
|
162
|
|
-HTML;
|
163
|
|
- }
|
|
134
|
+ echo $Twig->render(
|
|
135
|
+ 'torrent_form/announce_source.html',
|
|
136
|
+ [
|
|
137
|
+ 'announces' => $Announces,
|
|
138
|
+ 'torrent_pass' => $TorrentPass,
|
|
139
|
+ 'torrent_source' => $TorrentSource,
|
|
140
|
+ ]
|
|
141
|
+ );
|
|
142
|
+ }
|
164
|
143
|
|
165
|
|
- /**
|
166
|
|
- * Source (randomize infohash)
|
167
|
|
- */
|
168
|
|
- $TorrentSource = Users::get_upload_sources()[0];
|
169
|
|
- $HTML .= <<<HTML
|
170
|
|
- <p>
|
171
|
|
- <strong>Source</strong>
|
172
|
|
- <input type="text"
|
173
|
|
- value="$TorrentSource"
|
174
|
|
- size="30" readonly="readonly"
|
175
|
|
- onclick="this.select();" />
|
176
|
|
- </p>
|
|
144
|
+ /**
|
|
145
|
+ * Errors
|
|
146
|
+ * (Twig unjustified)
|
|
147
|
+ */
|
|
148
|
+ if ($this->Error) {
|
|
149
|
+ echo <<<HTML
|
|
150
|
+ <aside class="upload_error">
|
|
151
|
+ <p>$this->Error</p>
|
|
152
|
+ </aside>
|
177
|
153
|
HTML;
|
|
154
|
+ }
|
178
|
155
|
|
179
|
|
- $HTML .= '</aside>';
|
180
|
|
- } # fi NewTorrent
|
181
|
|
- return $HTML;
|
182
|
|
- }
|
|
156
|
+ /**
|
|
157
|
+ * head
|
|
158
|
+ * IMPORTANT!
|
|
159
|
+ */
|
|
160
|
+ echo $this->head();
|
183
|
161
|
|
|
162
|
+ /**
|
|
163
|
+ * upload_form
|
|
164
|
+ * Where the fields are.
|
|
165
|
+ */
|
|
166
|
+ echo $this->upload_form();
|
184
|
167
|
|
185
|
|
- /**
|
186
|
|
- * Display torrent upload errors
|
187
|
|
- */
|
188
|
|
- public function error()
|
189
|
|
- {
|
190
|
|
- if ($this->NewTorrent) {
|
191
|
|
- if ($this->Error) {
|
192
|
|
- echo <<<HTML
|
193
|
|
- <aside class="upload_error">
|
194
|
|
- <p>$this->Error</p>
|
195
|
|
- </aside>
|
196
|
|
-HTML;
|
197
|
|
- }
|
198
|
|
- } # fi NewTorrent
|
199
|
|
- }
|
|
168
|
+ /**
|
|
169
|
+ * foot
|
|
170
|
+ */
|
|
171
|
+ echo $this->foot();
|
|
172
|
+ } # End render()
|
200
|
173
|
|
201
|
174
|
|
202
|
175
|
/**
|
203
|
176
|
* head
|
204
|
177
|
*
|
205
|
|
- * Everything until the catalogue number field.
|
206
|
|
- * Server-side torrent scrubbing admonishment.
|
|
178
|
+ * Everything up to the main form tag open:
|
|
179
|
+ * <div id="dynamic_form">
|
|
180
|
+ * Kept as an HTML function because it's simpler.
|
207
|
181
|
*/
|
208
|
|
- public function head()
|
|
182
|
+ private function head()
|
209
|
183
|
{
|
210
|
184
|
$ENV = ENV::go();
|
211
|
|
-
|
212
|
185
|
G::$DB->query(
|
213
|
186
|
"
|
214
|
187
|
SELECT
|
|
@@ -266,19 +239,13 @@ HTML;
|
266
|
239
|
* Start printing the torrent form
|
267
|
240
|
*/
|
268
|
241
|
$HTML .= '<table class="torrent_form">';
|
269
|
|
- return $HTML;
|
270
|
|
- }
|
271
|
242
|
|
272
|
|
-
|
273
|
|
- /**
|
274
|
|
- * New torrent options: file
|
275
|
|
- */
|
276
|
|
- public function basicInfo()
|
277
|
|
- {
|
278
|
|
- $ENV = ENV::go();
|
279
|
|
-
|
|
243
|
+ /**
|
|
244
|
+ * New torrent options:
|
|
245
|
+ * file and category
|
|
246
|
+ */
|
280
|
247
|
if ($this->NewTorrent) {
|
281
|
|
- $HTML = '<h2 class="header">Basic Info</h2>';
|
|
248
|
+ $HTML .= '<h2 class="header">Basic Info</h2>';
|
282
|
249
|
$HTML .= <<<HTML
|
283
|
250
|
<tr>
|
284
|
251
|
<td>
|
|
@@ -297,14 +264,8 @@ HTML;
|
297
|
264
|
</td>
|
298
|
265
|
</tr>
|
299
|
266
|
HTML;
|
300
|
|
- } # fi NewTorrent
|
301
|
267
|
|
302
|
|
- /**
|
303
|
|
- * New torrent options: category
|
304
|
|
- */
|
305
|
|
- if ($this->NewTorrent) {
|
306
|
268
|
$DisabledFlag = ($this->DisabledFlag) ? ' disabled="disabled"' : '';
|
307
|
|
-
|
308
|
269
|
$HTML .= <<<HTML
|
309
|
270
|
<tr>
|
310
|
271
|
<td>
|
|
@@ -353,7 +314,7 @@ HTML;
|
353
|
314
|
*
|
354
|
315
|
* Make the endmatter.
|
355
|
316
|
*/
|
356
|
|
- public function foot()
|
|
317
|
+ private function foot()
|
357
|
318
|
{
|
358
|
319
|
$Torrent = $this->Torrent;
|
359
|
320
|
echo '<table class="torrent_form>';
|
|
@@ -470,17 +431,14 @@ HTML;
|
470
|
431
|
* It has sub-functions, variables, and everything.
|
471
|
432
|
* It continues to the end of the class.
|
472
|
433
|
*/
|
473
|
|
- public function upload_form()
|
|
434
|
+ private function upload_form()
|
474
|
435
|
{
|
475
|
436
|
$ENV = ENV::go();
|
|
437
|
+ $Twig = Twig::go();
|
476
|
438
|
|
477
|
439
|
$QueryID = G::$DB->get_query_id();
|
478
|
440
|
$Torrent = $this->Torrent;
|
479
|
441
|
|
480
|
|
- # Moved to their own functions
|
481
|
|
- #echo $this->head();
|
482
|
|
- #echo $this->basicInfo();
|
483
|
|
-
|
484
|
442
|
# Start printing the form
|
485
|
443
|
echo '<h2 class="header">Torrent Form</h2>';
|
486
|
444
|
echo '<table class="torrent_form">';
|
|
@@ -488,77 +446,17 @@ HTML;
|
488
|
446
|
|
489
|
447
|
/**
|
490
|
448
|
* Accession Number
|
491
|
|
- *
|
492
|
|
- * The headings below refer to a new generic input schema.
|
493
|
|
- * The HTML labels and various user-visible text should come from $ENV.
|
494
|
|
- *
|
495
|
|
- * RecursiveArrayObject->toArray() returns arrays from, e.g., $ENV->A->B->C.
|
496
|
|
- * This makes it easy to get and program with any subset of config objects.
|
497
|
449
|
*/
|
498
|
450
|
$CatalogueNumber = display_str($Torrent['CatalogueNumber']);
|
499
|
451
|
$Disabled = $this->Disabled;
|
500
|
|
-
|
501
|
|
- # DOI
|
502
|
|
- echo <<<HTML
|
503
|
|
- <tr id="javdb_tr">
|
504
|
|
- <td>
|
505
|
|
- <label for="catalogue">
|
506
|
|
- Accession Number
|
507
|
|
- </label>
|
508
|
|
- </td>
|
509
|
|
-
|
510
|
|
- <td>
|
511
|
|
- <input type="text"
|
512
|
|
- id="catalogue" name="catalogue" size="30"
|
513
|
|
- placeholder="RefSeq and UniProt preferred"
|
514
|
|
- value="$CatalogueNumber" />
|
515
|
|
-
|
516
|
|
- <input type="button" autofill="jav" value="Autofill"
|
517
|
|
- style="pointer-events: none; opacity: 0.5;">
|
518
|
|
- </input>
|
519
|
|
- </td>
|
520
|
|
- </tr>
|
521
|
|
-HTML;
|
522
|
|
-
|
523
|
|
- # RefSeq
|
524
|
|
- $DisabledFlagInput = (!$this->DisabledFlag)
|
525
|
|
- ? '<input type="button" autofill="anime" value="Autofill" />'
|
526
|
|
- : null;
|
527
|
|
-
|
528
|
|
- echo <<<HTML
|
529
|
|
- <tr id="anidb_tr" class="hidden">
|
530
|
|
- <td>
|
531
|
|
- <label for="anidb">
|
532
|
|
- AniDB Autofill (optional)
|
533
|
|
- </label>
|
534
|
|
- </td>
|
535
|
|
-
|
536
|
|
- <td>
|
537
|
|
- <input type="text" id="anidb" size="10" $Disabled />
|
538
|
|
- $DisabledFlagInput
|
539
|
|
- </td>
|
540
|
|
- </tr>
|
541
|
|
-HTML;
|
542
|
452
|
|
543
|
|
- # UniProt
|
544
|
|
- $DisabledFlagInput = (!$this->DisabledFlag)
|
545
|
|
- ? '<input type="button" autofill="anime" value="Autofill" />'
|
546
|
|
- : null;
|
547
|
|
-
|
548
|
|
- echo <<<HTML
|
549
|
|
- <tr id="anidb_tr" class="hidden">
|
550
|
|
- <td>
|
551
|
|
- <label for="douj">
|
552
|
|
- e-hentai URL (optional)
|
553
|
|
- </label>
|
554
|
|
- </td>
|
555
|
|
-
|
556
|
|
- <td>
|
557
|
|
- <input type="text" id="douj" size="10" $Disabled />
|
558
|
|
- $DisabledFlagInput
|
559
|
|
- </td>
|
560
|
|
- </tr>
|
561
|
|
-HTML;
|
|
453
|
+ echo $Twig->render(
|
|
454
|
+ 'torrent_form/identifier.html',
|
|
455
|
+ [
|
|
456
|
+ 'db' => $ENV->DB->identifier,
|
|
457
|
+ 'identifier' => $CatalogueNumber,
|
|
458
|
+ ]
|
|
459
|
+ );
|
562
|
460
|
|
563
|
461
|
|
564
|
462
|
/**
|
|
@@ -566,104 +464,36 @@ HTML;
|
566
|
464
|
*/
|
567
|
465
|
|
568
|
466
|
$Version = display_str($Torrent['Version']);
|
569
|
|
- echo <<<HTML
|
570
|
|
- <tr id="audio_tr">
|
571
|
|
- <td>
|
572
|
|
- <label for="version">
|
573
|
|
- Version
|
574
|
|
- </label>
|
575
|
|
- </td>
|
576
|
467
|
|
577
|
|
- <td>
|
578
|
|
- <input type="text"
|
579
|
|
- id="version" name="version"
|
580
|
|
- size="12" pattern="\d+\.*\d*\.*\d*"
|
581
|
|
- placeholder="Start with 0.1.0"
|
582
|
|
- value="$Version" />
|
583
|
|
-
|
584
|
|
- <p>
|
585
|
|
- Please see
|
586
|
|
- <a href="https://semver.org target=" _blank">Semantic Versioning</a>
|
587
|
|
- </p>
|
588
|
|
- </td>
|
589
|
|
- </tr>
|
590
|
|
-HTML;
|
|
468
|
+ echo $Twig->render(
|
|
469
|
+ 'torrent_form/identifier.html',
|
|
470
|
+ [
|
|
471
|
+ 'db' => $ENV->DB->version,
|
|
472
|
+ 'version' => $Version,
|
|
473
|
+ ]
|
|
474
|
+ );
|
591
|
475
|
|
592
|
476
|
|
593
|
477
|
/**
|
594
|
|
- * Title fields
|
595
|
|
- *
|
596
|
|
- * Gazelle has three title fields available, regrettably hardcoded.
|
597
|
|
- * Ideally we could rank them in importance in the site ontology,
|
598
|
|
- * then update one config file to apply custom metadata across the board.
|
|
478
|
+ * Title Fields
|
599
|
479
|
*/
|
600
|
480
|
|
601
|
481
|
# New torrent upload
|
602
|
482
|
if ($this->NewTorrent) {
|
603
|
|
- $Disabled = $this->Disabled;
|
604
|
|
-
|
605
|
|
-
|
606
|
|
- /**
|
607
|
|
- * Title 1
|
608
|
|
- */
|
609
|
483
|
$Title1 = display_str($Torrent['Title']);
|
610
|
|
- echo <<<HTML
|
611
|
|
- <tr id="title_tr">
|
612
|
|
- <td>
|
613
|
|
- <label for="title" class="required">
|
614
|
|
- Torrent Title
|
615
|
|
- </label>
|
616
|
|
- </td>
|
617
|
|
-
|
618
|
|
- <td>
|
619
|
|
- <input type="text" id="title" name="title" size="60"
|
620
|
|
- placeholder="Definition line, e.g., Alcohol dehydrogenase ADH1"
|
621
|
|
- value="$Title1" $Disabled />
|
622
|
|
- </td>
|
623
|
|
- </tr>
|
624
|
|
-HTML;
|
625
|
|
-
|
626
|
|
-
|
627
|
|
- /**
|
628
|
|
- * Title 2
|
629
|
|
- */
|
630
|
484
|
$Title2 = display_str($Torrent['Title2']);
|
631
|
|
- echo <<<HTML
|
632
|
|
- <tr id="title_rj_tr">
|
633
|
|
- <td>
|
634
|
|
- <label for="title_rj">
|
635
|
|
- Organism
|
636
|
|
- </label>
|
637
|
|
- </td>
|
638
|
|
-
|
639
|
|
- <td>
|
640
|
|
- <input type="text" id="title_rj" name="title_rj" size="60"
|
641
|
|
- placeholder="Organism line binomial, e.g., Saccharomyces cerevisiae"
|
642
|
|
- value="$Title2" $Disabled />
|
643
|
|
- </td>
|
644
|
|
- </tr>
|
645
|
|
-HTML;
|
646
|
|
-
|
647
|
|
-
|
648
|
|
- /**
|
649
|
|
- * Title 3
|
650
|
|
- */
|
651
|
485
|
$Title3 = display_str($Torrent['TitleJP']);
|
652
|
|
- echo <<<HTML
|
653
|
|
- <tr id="title_jp_tr">
|
654
|
|
- <td>
|
655
|
|
- <label for="title_jp">
|
656
|
|
- Strain/Variety
|
657
|
|
- </label>
|
658
|
|
- </td>
|
659
|
|
-
|
660
|
|
- <td>
|
661
|
|
- <input type="text" id="title_jp" name="title_jp" size="60"
|
662
|
|
- placeholder="Organism line if any, e.g., S288C"
|
663
|
|
- value="$Title3" $Disabled />
|
664
|
|
- </td>
|
665
|
|
- </tr>
|
666
|
|
-HTML;
|
|
486
|
+ #$Disabled = $this->Disabled;
|
|
487
|
+
|
|
488
|
+ echo $Twig->render(
|
|
489
|
+ 'torrent_form/titles.html',
|
|
490
|
+ [
|
|
491
|
+ 'db' => $ENV->DB,
|
|
492
|
+ 'title' => $Title1,
|
|
493
|
+ 'subject' => $Title2,
|
|
494
|
+ 'object' => $Title3,
|
|
495
|
+ ]
|
|
496
|
+ );
|
667
|
497
|
} # fi NewTorrent
|
668
|
498
|
|
669
|
499
|
|
|
@@ -726,29 +556,18 @@ HTML;
|
726
|
556
|
|
727
|
557
|
|
728
|
558
|
/**
|
729
|
|
- * Affiliation
|
730
|
|
- *
|
731
|
|
- * The company, studio, lab, etc., that did the work.
|
732
|
|
- * todo: Add creator affiliation and pick a predetermined one
|
733
|
|
- * (in our case, last author's institution).
|
|
559
|
+ * Workgroup
|
734
|
560
|
*/
|
735
|
561
|
if ($this->NewTorrent) {
|
736
|
562
|
$Affiliation = display_str($Torrent['Studio']);
|
737
|
|
- echo <<<HTML
|
738
|
|
- <tr id="studio_tr">
|
739
|
|
- <td>
|
740
|
|
- <label for="studio" class="required">
|
741
|
|
- Department/Lab
|
742
|
|
- </label>
|
743
|
|
- </td>
|
744
|
|
-
|
745
|
|
- <td>
|
746
|
|
- <input type="text" id="studio" name="studio" size="60"
|
747
|
|
- placeholder="Last author's institution, e.g., Lawrence Berkeley Laboratory"
|
748
|
|
- value="$Affiliation" $Disabled />
|
749
|
|
- </td>
|
750
|
|
- </tr>
|
751
|
|
-HTML;
|
|
563
|
+
|
|
564
|
+ echo $Twig->render(
|
|
565
|
+ 'torrent_form/workgroup.html',
|
|
566
|
+ [
|
|
567
|
+ 'db' => $ENV->DB->workgroup,
|
|
568
|
+ 'workgroup' => $Affiliation,
|
|
569
|
+ ]
|
|
570
|
+ );
|
752
|
571
|
}
|
753
|
572
|
|
754
|
573
|
|
|
@@ -760,22 +579,15 @@ HTML;
|
760
|
579
|
*/
|
761
|
580
|
if ($this->NewTorrent) {
|
762
|
581
|
$TorrentLocation = display_str($Torrent['Series']);
|
763
|
|
- echo <<<HTML
|
764
|
|
- <tr id="series_tr">
|
765
|
|
- <td>
|
766
|
|
- <label for="series">
|
767
|
|
- Location
|
768
|
|
- </label>
|
769
|
|
- </td>
|
770
|
|
-
|
771
|
|
- <td>
|
772
|
|
- <input type="text" id="series" name="series" size="60"
|
773
|
|
- placeholder="Physical location, e.g., Berkeley, CA 94720"
|
774
|
|
- value="$TorrentLocation" $Disabled />
|
775
|
|
- </td>
|
776
|
|
- </tr>
|
777
|
|
-HTML;
|
778
|
|
- } # fi NewTorrent
|
|
582
|
+
|
|
583
|
+ echo $Twig->render(
|
|
584
|
+ 'torrent_form/location.html',
|
|
585
|
+ [
|
|
586
|
+ 'db' => $ENV->DB->location,
|
|
587
|
+ 'location' => $TorrentLocation,
|
|
588
|
+ ]
|
|
589
|
+ );
|
|
590
|
+ }
|
779
|
591
|
|
780
|
592
|
|
781
|
593
|
/**
|
|
@@ -1433,7 +1245,6 @@ HTML;
|
1433
|
1245
|
echo '</table>';
|
1434
|
1246
|
|
1435
|
1247
|
# Drink a stiff one
|
1436
|
|
- $this->foot();
|
1437
|
1248
|
G::$DB->set_query_id($QueryID);
|
1438
|
1249
|
} # End upload_form()
|
1439
|
1250
|
} # End TorrentForm()
|