Skip to content

Commit

Permalink
project view changes, child view special view reverted
Browse files Browse the repository at this point in the history
  • Loading branch information
nczirjak-acdh committed Jun 9, 2020
1 parent acf47ac commit bb0f65f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
8 changes: 4 additions & 4 deletions inst/dbfunctions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ LANGUAGE 'plpgsql';
* _orderby = the ordering property -> https://vocabs.acdh.oeaw.ac.at/schema#hasTitle
* _lang = 'en' or 'de'
*/
CREATE OR REPLACE FUNCTION gui.child_views_func(_parentid text, _limit text, _page text, _orderby text, _orderprop text, _lang text DEFAULT 'en')
CREATE OR REPLACE FUNCTION gui.child_views_func(_parentid text, _limit text, _page text, _orderby text, _orderprop text, _lang text DEFAULT 'en', _rdftype text[] DEFAULT '{}' )
RETURNS table (id bigint, title text, avDate timestamp, description text, accesres text, titleimage text, acdhtype text)
AS $func$
DECLARE _lang2 text := 'de';
Expand Down Expand Up @@ -257,7 +257,7 @@ DROP TABLE IF EXISTS child_ids;
from relations as r
left join identifiers as i on i.id = r.target_id
left join metadata_view as mv on mv.id = r.id
where r.property = 'https://vocabs.acdh.oeaw.ac.at/schema#isPartOf'
where r.property = ANY (_rdftype)
and mv.property = _orderprop
and i.ids = _parentid
order by
Expand All @@ -279,7 +279,7 @@ LANGUAGE 'plpgsql';
* get the sum of the child gui view resources for the pager
* _parentid = full url -> https://repo.hephaistos.arz.oeaw.ac.at/api/207984
*/
CREATE OR REPLACE FUNCTION gui.child_sum_views_func(_parentid text)
CREATE OR REPLACE FUNCTION gui.child_sum_views_func(_parentid text, _rdftype text[] DEFAULT '{}')
RETURNS table (countid bigint)
AS $func$

Expand All @@ -291,7 +291,7 @@ BEGIN
r.id
from relations as r
left join identifiers as i on i.id = r.target_id
where r.property = 'https://vocabs.acdh.oeaw.ac.at/schema#isPartOf'
where r.property = ANY (_rdftype)
and i.ids = _parentid
) select * from ids
);
Expand Down
18 changes: 12 additions & 6 deletions src/Model/ChildApiModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ public function getAcdhtype(): string
public function getViewData(string $identifier = "", int $limit = 10, int $page = 0, string $orderby = "titleasc"): array
{
$order = $this->ordering($orderby);

if (empty($this->sqlTypes)) {
$this->sqlTypes = "ARRAY[]::text[]";
}
//get the requested sorting
try {
$query = $this->repodb->query(
"select * from gui.child_views_func(:id, :limit, :page, :order, :orderprop, :lang);",
"select * from gui.child_views_func(:id, :limit, :page, :order, :orderprop, :lang, $this->sqlTypes);",
array(
':id' => $identifier,
':limit' => $limit,
Expand Down Expand Up @@ -109,15 +111,19 @@ private function ordering(string $orderby = "titleasc"): object
*/
public function getCount(string $identifier): int
{
if (empty($this->sqlTypes)) {
$this->sqlTypes = "ARRAY['https://vocabs.acdh.oeaw.ac.at/schema#isPartOf']";
}

try {
$query = $this->repodb->query(
"select * from gui.child_sum_views_func(:id);",
"select * from gui.child_sum_views_func(:id, $this->sqlTypes);",
array(
':id' => $identifier
)
':id' => $identifier
)
);
$result = $query->fetch();

$this->changeBackDBConnection();
if (isset($result->countid)) {
return (int)$result->countid;
Expand Down
4 changes: 2 additions & 2 deletions templates/acdh-repo-gui-detail-project.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ set furtherProperties = {
{{ include('/modules/contrib/arche-gui/templates/helper-displayField.html.twig', {'data': basic.getData(key), 'icon': value.icon, 'label': value.label, 'url_only': value.url_only, 'repoid': value.repoid } ) }}
{% endif%}
{% endfor %}

<!--
<h3 class="single-res-heading">{{"Further Information"|trans }}</h3>
{% for key, value in furtherProperties %}
{% if basic.getData(key) %}
{{ include('/modules/contrib/arche-gui/templates/helper-displayField.html.twig', {'data': basic.getData(key), 'icon': value.icon, 'label': value.label, 'url_only': value.url_only, 'repoid': value.repoid } ) }}
{% endif%}
{% endfor %}

-->
{% if basic.isTitleImage() %}</div>{% endif%}

{% if basic.isTitleImage() %}
Expand Down
8 changes: 4 additions & 4 deletions templates/helper-displayField.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
{% endif %}
{% elseif (external_url_title) %}
{% if (value.title and value.uri ) %}
<a id='archeHref' href="{{ value.uri }}">{{ value.title }}</a>
<a href="{{ value.uri }}" target="_blank">{{ value.title }}</a>
{% else %}
<a id='archeHref' href="{{ value.uri }}">{{ value.uri }}</a>
<a href="{{ value.uri }}" target="_blank">{{ value.uri }}</a>
{% endif %}
{% elseif (repoid) %}
{% if (value.repoid) and (value.title) %}
Expand Down Expand Up @@ -61,9 +61,9 @@
{% elseif (value.insideUri) and (value.title) %}
<a id='archeHref' href="/browser/oeaw_detail/{{ value.insideUri }}">{{ value.title|nl2br }}</a>
{% elseif value.title and value.uri %}
<a id='archeHref' href="{{ value.uri }}">{{ value.title|nl2br }}</a>
<a href="{{ value.uri }}" target="_blank">{{ value.title|nl2br }}</a>
{% elseif value.uri %}
<a id='archeHref' href="{{ value.uri }}">{{ value.uri }}</a>
<a href="{{ value.uri }}" target="_blank">{{ value.uri }}</a>
{% elseif value.title %}
{{ value.title }}
{% elseif value.value %}
Expand Down

0 comments on commit bb0f65f

Please sign in to comment.