NewTorrent = $NewTorrent; $this->Torrent = $Torrent; $this->Error = $Error; $this->UploadForm = $UploadForm; $this->Categories = $Categories; $this->TorrentID = $TorrentID; # Formats # See classes/config.php $this->SeqFormats = $SeqFormats; $this->ProtFormats = $ProtFormats; $this->GraphXmlFormats = $GraphXmlFormats; $this->GraphTxtFormats = $GraphTxtFormats; $this->ImgFormats = $ImgFormats; $this->MapVectorFormats = $MapVectorFormats; $this->MapRasterFormats = $MapRasterFormats; $this->BinDocFormats = $BinDocFormats; $this->CpuGenFormats = $CpuGenFormats; $this->PlainFormats = $PlainFormats; $this->Resolutions = $Resolutions; # Quick constructor test if ($this->Torrent && $this->Torrent['GroupID']) { $this->Disabled = ' readonly="readonly"'; $this->DisabledFlag = true; } } /** * ==================== * = Twig-based class = * ==================== */ /** * render * * TorrentForm Twig wrapper. * Hopefully more pleasant. */ public function render() { $ENV = ENV::go(); $Twig = Twig::go(); /** * Upload notice */ if ($this->NewTorrent) { echo $Twig->render('torrent_form/notice.html'); } /** * Announce and source */ if ($this->NewTorrent) { $Announces = ANNOUNCE_URLS[0]; #$Announces = call_user_func_array('array_merge', ANNOUNCE_URLS); $TorrentPass = G::$LoggedUser['torrent_pass']; $TorrentSource = Users::get_upload_sources()[0]; echo $Twig->render( 'torrent_form/announce_source.html', [ 'announces' => $Announces, 'torrent_pass' => $TorrentPass, 'torrent_source' => $TorrentSource, ] ); } /** * Errors * (Twig unjustified) */ if ($this->Error) { echo <<

$this->Error

HTML; } /** * head * IMPORTANT! */ echo $this->head(); /** * upload_form * Where the fields are. */ echo $this->upload_form(); /** * foot */ echo $this->foot(); } # End render() /** * head * * Everything up to the main form tag open: *
* Kept as an HTML function because it's simpler. */ private function head() { $ENV = ENV::go(); G::$DB->query( " SELECT COUNT(`ID`) FROM `torrents` WHERE `UserID` = ".G::$LoggedUser['ID'] ); list($Uploads) = G::$DB->next_record(); # Torrent form hidden values $AuthKey = G::$LoggedUser['AuthKey']; $HTML = << HTML; if (!$this->NewTorrent) { # Edit form hidden fields $TorrentID = display_str($this->TorrentID); $CategoryID = display_str($this->Torrent['CategoryID'] - 1); $HTML .= << HTML; } # fi !NewTorrent else { # Torrent upload hidden fields if ($this->Torrent && $this->Torrent['GroupID']) { $GroupID = display_str($this->Torrent['GroupID']); $CategoryID = display_str($this->Torrent['CategoryID'] - 1); $HTML .= << HTML; } # Request hidden fields (new or edit?) if ($this->Torrent && ($this->Torrent['RequestID'] ?? false)) { $RequestID = display_str($this->Torrent['RequestID']); $HTML .= << HTML; } } # else /** * Start printing the torrent form */ $HTML .= ''; /** * New torrent options: * file and category */ if ($this->NewTorrent) { $HTML .= '

Basic Info

'; $HTML .= << HTML; $DisabledFlag = ($this->DisabledFlag) ? ' disabled="disabled"' : ''; $HTML .= <<

Set the private flag, e.g., mktorrent -p -a <announce> <target folder>

HTML; } # fi NewTorrent # Start the dynamic form $HTML .= '
'; return $HTML; } # End head() /** * foot * * Make the endmatter. */ private function foot() { $Torrent = $this->Torrent; echo ' HTML; } } # fi !NewTorrent # For new torrents only if ($this->NewTorrent) { # Rules notice echo <<'; } /** * Submit button */ $Value = ($this->NewTorrent) ? 'Upload' : 'Edit'; echo <<
HTML; /** * Freeleech reasons */ $FL = array('N/A', 'Staff Pick', 'Perma-FL', 'Freeleechizer', 'Site-Wide FL'); foreach ($FL as $Key => $Name) { $Selected = ($Key === $Torrent['FreeLeechType']) ? ' selected="selected"' : ''; echo << $Name HTML; } echo <<
HTML; } # End foot() /** * upload_form * * Finally the "real" upload form. * Contains all the fields you'd expect. * * This is currently one enormous function. * It has sub-functions, variables, and everything. * It continues to the end of the class. */ private function upload_form() { $ENV = ENV::go(); $Twig = Twig::go(); $QueryID = G::$DB->get_query_id(); $Torrent = $this->Torrent; # Start printing the form echo '

Torrent Form

'; echo ''; /** * Accession Number */ $CatalogueNumber = display_str($Torrent['CatalogueNumber']); $Disabled = $this->Disabled; echo $Twig->render( 'torrent_form/identifier.html', [ 'db' => $ENV->DB->identifier, 'identifier' => $CatalogueNumber, ] ); /** * Version */ $Version = display_str($Torrent['Version']); echo $Twig->render( 'torrent_form/version.html', [ 'db' => $ENV->DB->version, 'version' => $Version, ] ); /** * Title Fields */ # New torrent upload if ($this->NewTorrent) { $Title1 = display_str($Torrent['Title']); $Title2 = display_str($Torrent['Title2']); $Title3 = display_str($Torrent['TitleJP']); #$Disabled = $this->Disabled; echo $Twig->render( 'torrent_form/titles.html', [ 'db' => $ENV->DB, 'title' => $Title1, 'subject' => $Title2, 'object' => $Title3, ] ); } # fi NewTorrent /** * Creator(s) * CURRENTLY BROKEN * * Gazelle supports multiple creators per torrent. * One day I want to integrate the creator DB to join: * - DOI publication info in `torrents_screenshots` * - Attributions listed on the creator pages * - Stats about creator vs. total DOI citations */ if ($this->NewTorrent) { # Useful variables $Disabled = $this->Disabled; $AutocompleteOption = Users::has_autocomplete_enabled('other'); $AddRemoveBrackets = <<+ HTML; echo <<'; } # fi $NewTorrent /** * Workgroup */ if ($this->NewTorrent) { $Affiliation = display_str($Torrent['Studio']); echo $Twig->render( 'torrent_form/workgroup.html', [ 'db' => $ENV->DB->workgroup, 'workgroup' => $Affiliation, ] ); } /** * Location * * The location of the studio, lab, etc. * Currently not sanitized to a standard format. */ if ($this->NewTorrent) { $TorrentLocation = display_str($Torrent['Series']); echo $Twig->render( 'torrent_form/location.html', [ 'db' => $ENV->DB->location, 'location' => $TorrentLocation, ] ); } /** * ============================ * = End if NewTorrent fields = * ============================ */ /** * Year */ $TorrentYear = display_str($Torrent['Year']); echo $Twig->render( 'torrent_form/year.html', [ 'db' => $ENV->DB->year, 'year' => $TorrentYear, ] ); /** * Misc meta * * Used in OT Gazelle as Codec. * Used in Bio Gazelle as License. * * Unsure what to call the final field. * Some essential, specific one-off info. */ echo << HTML; /** * ==================================== * = Begin if NewTorrent fields again = * ==================================== */ /** * Media * * The class of technology associated with the data. * Answers the question: "Where does the data come from?" * * This could be the data genesis platform or program, * or a genre of physical media (e.g., vinyl record). */ /** * Make select element * * Takes an ID, label, torrent, and media list. * Returns a media select option as on upload.php. */ function mediaSelect($trID = '', $Label = '', $Torrent = [], $Media = [], $Desc = '') { echo << HTML; } # End mediaSelect() /** * Platform: Sequences */ if ($this->NewTorrent) { mediaSelect( $trID = 'media_tr', $Label = 'Platform', $Torrent = $Torrent, $Media = $ENV->CATS->{1}->Platforms ); /** * Platform: Graphs */ mediaSelect( $trID = 'media_graphs_tr', $Label = 'Platform', $Torrent = $Torrent, $Media = $ENV->CATS->{2}->Platforms ); /** * Platform: Scalars/Vectors */ mediaSelect( $trID = 'media_scalars_vectors_tr', $Label = 'Platform', $Torrent = $Torrent, $Media = $ENV->CATS->{5}->Platforms ); /** * Platform: Images */ mediaSelect( $trID = 'media_images_tr', $Label = 'Platform', $Torrent = $Torrent, $Media = $ENV->CATS->{8}->Platforms ); /** * Platform: Documents */ mediaSelect( $trID = 'media_documents_tr', $Label = 'Platform', $Torrent = $Torrent, $Media = $ENV->CATS->{11}->Platforms ); /** * Platform: Machine Data */ mediaSelect( $trID = 'media_machine_data_tr', $Label = 'Platform', $Torrent = $Torrent, $Media = $ENV->CATS->{12}->Platforms ); } # fi NewTorrent else { $TorrentMedia = $Torrent['Media']; echo << HTML; } /** * Format * * Simple: the data's file format. * Called Container in OT Gazelle, same diff. * In the future, $ENV will automagically set this. */ function formatSelect($trID = '', $Label = '', $Torrent = [], $FileTypes = []) { #var_dump($FileTypes); echo << HTML; } # End formatSelect() /** * Format: Sequences */ formatSelect( $trID = 'container_tr', $Label = 'Format', $Torrent = $Torrent, $FileTypes = $ENV->CATS->{1}->Formats ); /** * Format: Graphs */ formatSelect( $trID = 'container_graphs_tr', $Label = 'Format', $Torrent = $Torrent, #$FileTypes = array_column($ENV->META, $Formats) $FileTypes = $ENV->CATS->{2}->Formats ); /** * Format: Scalars/Vectors */ formatSelect( $trID = 'container_scalars_vectors_tr', $Label = 'Format', $Torrent = $Torrent, #$FileTypes = $ENV->flatten($ENV->CATS->{5}->Formats) $FileTypes = $ENV->CATS->{5}->Formats ); /** * Format: Images */ formatSelect( $trID = 'container_images_tr', $Label = 'Format', $Torrent = $Torrent, #$FileTypes = array_merge($this->ImgFormats) $FileTypes = $ENV->CATS->{8}->Formats ); /** * Format: Spatial */ formatSelect( $trID = 'container_spatial_tr', $Label = 'Format', $Torrent = $Torrent, #$FileTypes = array_merge($this->MapVectorFormats, $this->MapRasterFormats, $this->ImgFormats, $this->PlainFormats) $FileTypes = $ENV->CATS->{9}->Formats ); /** * Format: Documents */ formatSelect( $trID = 'container_documents_tr', $Label = 'Format', $Torrent = $Torrent, #$FileTypes = array_merge($this->BinDocFormats, $this->CpuGenFormats, $this->PlainFormats) $FileTypes = $ENV->CATS->{11}->Formats ); /** * Format: Compression */ formatSelect( $trID = 'archive_tr', $Label = 'Archive', $Torrent = $Torrent, # $ENV->Archives nests -1 deep $FileTypes = [$ENV->META->Formats->Archives] ); /** * Scope * * How complete the data are. * Relatively, how much information does it contain? */ $TorrentResolution = ($Torrent['Resolution']) ?? ''; echo << HTML; /** * ==================================== * = Begin if NewTorrent fields again = * ==================================== */ /** * Tags * * Simple enough. * I won't rehash tag management. */ if ($this->NewTorrent) { echo << HTML; } # fi NewTorrent /** * Picture * * Another obvious field. */ if ($this->NewTorrent) { $TorrentImage = display_str($Torrent['Image']); $Disabled = $this->Disabled; echo $Twig->render( 'torrent_form/picture.html', [ 'db' => $ENV->DB->picture, 'picture' => $TorrentImage, ] ); } /** * Mirrors * * This should be in the `torrents` table not `torrents_group.` * The intended use is for web seeds, Dat mirrors, etc. */ if (!$this->DisabledFlag && $this->NewTorrent) { $TorrentMirrors = display_str($Torrent['Mirrors']); echo $Twig->render( 'torrent_form/mirrors.html', [ 'db' => $ENV->DB->mirrors, 'mirrors' => $TorrentMirrors, ] ); } /** * Samples * * Called Screenshots in OT Gazelle. * Called Publication in Bio Gazelle. * Eventually this will be a proper database in itself, * pulling info from DOI to populate the schema. */ if (!$this->DisabledFlag && $this->NewTorrent) { $TorrentSamples = display_str($Torrent['Screenshots']); echo << HTML; } /** * Seqhash */ if ($ENV->FEATURE_BIOPHP && !$this->DisabledFlag && $this->NewTorrent) { $TorrentSeqhash = display_str($Torrent['Seqhash']); echo $Twig->render( 'torrent_form/seqhash.html', [ 'db' => $ENV->DB->seqhash, 'seqhash' => $TorrentSeqhash, ] ); } /** * Torrent group description * * The text on the main torrent pages, * between torrent info and torrent comments, * visible even if individual torrents are collapsed. */ if ($this->NewTorrent) { echo <<'; } # fi NewTorrent /** * ============================ * = End if NewTorrent fields = * ============================ */ /** * Torrent description * * The test displayed when torrent info is expanded. * It should describe the specific torrent, not the group. */ echo <<'; /** * Boolean options * * Simple checkboxes that do stuff. * Currently checks for data annotations and anonymous uploads. * More fields could be created as the need arises. */ /** * Aligned/Annontated * * Called Censored in OT Gazelle. */ $TorrentAnnotated = ($Torrent['Censored'] ?? 0) ? ' checked' : ''; echo << HTML; /** * Upload Anonymously */ $TorrentAnonymous = ($Torrent['Anonymous'] ?? false) ? ' checked' : ''; echo << HTML; # End the giant dynamic form table echo '

One per field, e.g., Robert K. Mortimer [+] David Schild

HTML; # If there are already creators listed if (!empty($Torrent['Artists'])) { foreach ($Torrent['Artists'] as $Num => $Artist) { $ArtistName = display_str($Artist['name']); $AddRemoveBrackets = ($Num === 0) ?: null; echo << $AddRemoveBrackets HTML; } } else { echo << $AddRemoveBrackets HTML; } echo '

How complete the data is, specifically or conceptually

HTML; $GenreTags = G::$Cache->get_value('genre_tags'); if (!$GenreTags) { G::$DB->query(" SELECT `Name` FROM `tags` WHERE `TagType` = 'genre' ORDER BY `Name` "); $GenreTags = G::$DB->collect('Name'); G::$Cache->cache_value('genre_tags', $GenreTags, 3600*6); } # todo: Find a better place for these $Disabled = ($this->DisabledFlag) ? ' disabled="disabled"' : null; $TorrentTagList = display_str(implode(', ', explode(',', $Torrent['TagList']))); $AutocompleteOption = Users::has_autocomplete_enabled('other'); echo << HTML; foreach (Misc::display_array($GenreTags) as $Genre) { echo << $Genre HTML; } echo <<
HTML; new TEXTAREA_PREVIEW( $Name = 'album_desc', $ID = 'album_desc', $Value = display_str($Torrent['GroupDescription']) ?? '', $Placeholder = "General info about the torrent subject's function or significance", ); echo '
HTML; new TEXTAREA_PREVIEW( $Name = 'release_desc', $ID = 'release_desc', $Value = display_str($Torrent['TorrentDescription'] ?? ''), $Placeholder = 'Specific info about the protocols and equipment used to produce the data', ); echo '
  Whether the torrent contains alignments, annotations, or other structural metadata
  Hide your username from other users on the torrent details page
'; # Drink a stiff one G::$DB->set_query_id($QueryID); } # End upload_form() } # End TorrentForm()