Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions gigadb/app/services/URLsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,58 @@ public function checkURLs(ClientInterface $webClient): array

return $badUrls;
}

/**
* Manages query parameters for the current URL based on the current route and $_GET params.
* It allows for adding, modifying, and removing parameters in a single call.
*
* @param array $addOrModifyParams Associative array of parameters to add or overwrite (e.g., ['key' => 'value']).
* @param array $removeParams A simple array of parameter keys to remove from the URL (e.g., ['key1', 'key2']).
* @return string The newly generated URL.
*/
public static function editUrlQueryParams(array $addOrModifyParams = [], array $removeParams = []): string
{
foreach ($addOrModifyParams as $key => $value) {
if (!is_string($key) || preg_match('/[^\w.-]/', $key)) {
throw new \InvalidArgumentException('Invalid character in parameter key. Only word characters, dots, and hyphens are allowed.');
}
if (!is_scalar($value) && !is_null($value)) {
throw new \InvalidArgumentException('Invalid value type. Only scalar values or null are allowed.');
}
}

foreach ($removeParams as $param) {
if (!is_string($param) || preg_match('/[^\w.-]/', $param)) {
throw new \InvalidArgumentException('Invalid character in parameter to remove. Only word characters, dots, and hyphens are allowed.');
}
}

$uri = Yii::app()->request->getRequestUri();
$parts = parse_url($uri);

$queryParams = [];
if (isset($parts['query']) && $parts['query'] !== '') {
parse_str($parts['query'], $queryParams);
}

foreach ($removeParams as $param) {
unset($queryParams[$param]);
}

foreach ($addOrModifyParams as $key => $value) {
$queryParams[$key] = $value;
}

$newQuery = http_build_query($queryParams);

$newUri = ($parts['path'] ?? '');
if ($newQuery !== '') {
$newUri .= '?' . $newQuery;
}
if (isset($parts['fragment'])) {
$newUri .= '#' . $parts['fragment'];
}

return $newUri;
}
}
2 changes: 2 additions & 0 deletions less/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@
@import "modules/carousel-slider.less";
@import "modules/news-section.less";
@import "modules/dataset-feed-section.less";
@import "layout/print.less";
@import "pages/dataset-print.less";
44 changes: 44 additions & 0 deletions less/layout/print.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// print styles not specific to a module or page
body.print {
.print-hidden {
display: none!important;
}

div {
display: block;
}
header, footer, nav, aside, video, iframe, .mobile-navigation, .skip-to-main-link {
display: none!important;
}

[role="dialog"], [role="tooltip"], [role="tablist"] {
display: none!important;
}
[role="tabpanel"] {
display: block!important;
}

.left-border-title {
all: unset;
}

.left-border-title-lg {
all: unset;
}

.badge {
all: unset;
}

// hide hypothes.is widget
hypothesis-sidebar {
display: none!important;
}
}


body:not(.print) {
.print-only {
display: none!important;
}
}
204 changes: 204 additions & 0 deletions less/pages/dataset-print.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
body.print .dataset-view-container {
*,
*::before,
*::after {
background: transparent !important;
color: @color-true-black !important;
box-shadow: none !important;
text-shadow: none !important;
border-color: initial !important;
}

font-size: 12pt;
line-height: 1.4;

a,
a:visited {
text-decoration: underline;
}

a:hover {
text-decoration: underline;
}

a[href]:not(.print__collapse-href):after {
content: " (" attr(href) ")";
font-size: 90%;
}

a[href^="#"]:after,
a[href^="javascript:"]:after {
content: "";
}

:is(h1, h2, h3, h4, h5, h6, p, .subsection) {
margin-bottom: 1em;
}

h1 { font-size: 24pt; }
h2 { font-size: 18pt; }
h3 { font-size: 14pt; }

img {
display: none;
}

.dataset-color-background-block {
padding: 0;
}
.result-sub-links {
text-wrap: wrap;
}
.media-left {
display: none;
}
.media-body {
width: auto;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-items: flex-start;
justify-content: flex-start;
gap: 0.5em;
}

#dropdown-div {
float: none;
margin: 0;

.drop-citation-btn {
display: none !important;
}

.dropdown-box,
ul {
position: static;
border: none;
list-style: disc inside;
padding: 0;
margin: 0 0 0 20px;
}

li {
a,
a:hover {
background: none !important;
color: initial !important;
padding: 0;
}
}
}
.citation-popup:before {
content: attr(data-content)": ";
}
.dataset-des-images {
display: none!important;
}
.content-popup {
display: none!important;
}

.sort-message {
display: none!important;
}

#samples_table_settings, #files_table_settings {
display: none!important;
}

#\33 dmodels {
display: none!important;
}

#\33 dsketchfab {
display: none!important;
}

[role="tabpanel"]#protocolsio,
[role="tabpanel"]#jbrowse,
[role="tabpanel"]#codeocean {
display: none!important;
}

table.table {
border: none;
border-top: 3px double @color-true-black;
border-bottom: 3px double @color-true-black;
padding: 5px 0;
thead {
display: none;
}

tbody {
display: block;
border: none;
margin-top: 1em;

tr {
border: none;
padding-bottom: 1em;
display: block;
&:not(:last-child) {
border-bottom: 1px solid @color-true-black;
margin-bottom: 1em;
}

th,
td {
flex: 1 1 100%;
border: none;
display: block;
padding: 2px 0;

&::before {
content: attr(data-header) ": ";
display: inline-block;
font-weight: 400;
width: 135px;
font-size: 10pt;
}
}

[class*="js-short-"] {
display: none;
}
[class*="js-long-"] {
display: block!important;
}
[class*="js-long-"] + button {
display: none;
}

.button-column {
display: none;
}

> *:first-child {
flex: 0 0 40%;
font-weight: bold;
text-align: left;
}

> *:not(:first-child) {
flex: 1 0 60%;
text-align: left;
word-break: break-word;
}

&::after {
content: "";
display: block;
width: 100%;
}
}
}
}

.table-footer .pagination-wrapper {
display: none;
}
}

body.print .sibling-dataset-links {
display: none;
}
Loading