Skip to content

Commit

Permalink
List of publications that are linked to a research area RRZE-Webteam#317
Browse files Browse the repository at this point in the history
  • Loading branch information
aajusah98 committed Nov 20, 2024
1 parent 778de19 commit 03e1a22
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 23 deletions.
22 changes: 16 additions & 6 deletions fau-cris.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Plugin Name: FAU CRIS
* Description: Anzeige von Daten aus dem FAU-Forschungsportal CRIS in WP-Seiten
* Version: 3.24.1
* Version: 3.24.2
* Author: RRZE-Webteam
* Author URI: http://blogs.fau.de/webworking/
* Text Domain: fau-cris
Expand Down Expand Up @@ -80,7 +80,7 @@ class FAU_CRIS
/**
* Get Started
*/
const version = '3.24.1';
const version = '3.24.2';
const option_name = '_fau_cris';
const version_option_name = '_fau_cris_version';
const textdomain = 'fau-cris';
Expand Down Expand Up @@ -1223,7 +1223,8 @@ private static function cris_shortcode_parameter($atts, $content = '', $tag = ''
'projects_status'=>'',
'projects_start'=>'',
'author_position'=>'',
'publicationsum'=>''
'publicationsum'=>'',
'useprojpubls'=>'false'
];

// Attributes
Expand Down Expand Up @@ -1293,6 +1294,7 @@ private static function cris_shortcode_parameter($atts, $content = '', $tag = ''
$sc_param['projects_start'] = sanitize_text_field($projects_start);
$sc_param['author_position'] = sanitize_text_field($author_position);
$sc_param['publicationsum'] = sanitize_text_field($publicationsum);
$sc_param['useprojpubls'] = strtolower(sanitize_text_field($useprojpubls));

switch ($sortby) {
case 'created':
Expand Down Expand Up @@ -1357,14 +1359,22 @@ private static function cris_shortcode_parameter($atts, $content = '', $tag = ''
$sc_param['equipment'] = explode(',', $sc_param['equipment']);
}
$sc_param['entity_id'] = $sc_param['equipment'];
} elseif ($sc_param['field'] != '') {
} elseif ($sc_param['field'] != '' && $sc_param['useprojpubls'] == 'false') {
$sc_param['entity'] = 'field';
if (strpos($sc_param['field'], ',') !== false) {
$sc_param['field'] = str_replace(' ', '', $sc_param['field']);
$sc_param['field'] = explode(',', $sc_param['field']);
}
$sc_param['entity_id'] = $sc_param['field'];
} elseif (isset($sc_param['activity']) && $sc_param['activity'] != '') {
$sc_param['entity_id'] = $sc_param['field']; }
elseif ($sc_param['field'] != '' && $sc_param['useprojpubls'] == 'true') {
$sc_param['entity'] = 'field_incl_proj';
if (strpos($sc_param['field'], ',') !== false) {
$sc_param['field'] = str_replace(' ', '', $sc_param['field']);
$sc_param['field'] = explode(',', $sc_param['field']);
}
$sc_param['entity_id'] = $sc_param['field'];
}
elseif (isset($sc_param['activity']) && $sc_param['activity'] != '') {
$sc_param['entity'] = 'activity';
$sc_param['entity_id'] = $sc_param['activity'];
} elseif (isset($sc_param['patent']) && $sc_param['patent'] != '') {
Expand Down
7 changes: 7 additions & 0 deletions includes/Forschungsbereiche.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ private function make_custom_single($fields, $content, $param = array()): string
$field_details['#project_publications#'] = $project_publications;
}
}
// $field_details['#publications_incl_projects#'] = '';
// if (strpos($content, '#publications_incl_projects#') !== false) {
// $project_publications = $this->get_field_publications($param, 'field_incl_proj');
// if ($project_publications) {
// $field_details['#publications_incl_projects#'] = $project_publications;
// }
// }
$field_details['#image1#'] = '';
$field_details['#images#'] = '';
if (strpos($content, '#image') !== false) {
Expand Down
59 changes: 42 additions & 17 deletions includes/Publikationen.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class Publikationen
public $cris_pub_title_link_order;
public function __construct($einheit = '', $id = '', $nameorder = '', $page_lang = 'de', $sc_lang = 'de')
{



if (strpos($_SERVER['PHP_SELF'], "vkdaten/tools/")) {
$this->cms = 'wbk';
$this->options = CRIS::ladeConf();
Expand All @@ -59,6 +62,8 @@ public function __construct($einheit = '', $id = '', $nameorder = '', $page_lang
$this->univis = Tools::get_univis();
}



if (strlen(trim($nameorder))) {
$this->nameorder = $nameorder;
} else {
Expand All @@ -72,7 +77,7 @@ public function __construct($einheit = '', $id = '', $nameorder = '', $page_lang
$this->langdiv_open = '<div class="cris" lang="' . $sc_lang . '">';
}

if (in_array($einheit, array("person", "orga", "award", "awardnameid", "project", "field"))) {
if (in_array($einheit, array("person", "orga", "award", "awardnameid", "project", "field","field_incl_proj"))) {
$this->einheit = $einheit;
} else {
$this->einheit = "orga";
Expand All @@ -84,6 +89,9 @@ public function __construct($einheit = '', $id = '', $nameorder = '', $page_lang
__('Bitte geben Sie die CRIS-ID der Organisation, Person oder des Projektes an.', 'fau-cris')
);
}



}

/**
Expand Down Expand Up @@ -168,7 +176,7 @@ public function pubNachJahr(
$project = ''
): string {
// Extracting parameters from the $param array

error_log(sprintf("pubNachJahr, field %s",$field));
$year = $param['year'] ?: ''; // The year of publication
$start = $param['start'] ?: ''; // The start of year from where publication is needed
$end = $param['end'] ?: ''; // The end of year from where publication is needed
Expand All @@ -183,14 +191,15 @@ public function pubNachJahr(
$language = $param['language'] ?: '';
$sortby = $param['sortby'] ?: 'virtualdate';
$authorPositionArray=$param['author_position'];
$muteheadings = $param['muteheadings'] ?? 0;
// it will use for showing number of publication by year or in total
$total_publication_html='';
if (!is_array($param['publicationsum'])) {
$publicationSumArray=array($param['publicationsum']);
}else{
$publicationSumArray=$param['publicationsum'];
}

// fetching the publication
$pubArray = $this->fetch_publications($year, $start, $end, $type, $subtype, $fau, $peerreviewed, $notable, $field, $language, $fsp, $project,$authorPositionArray );

Expand Down Expand Up @@ -227,11 +236,12 @@ public function pubNachJahr(
$output = '';
$showsubtype = ($subtype == '') ? 1 : 0;

if (shortcode_exists('collapsibles') && $format == 'accordion') {

if (shortcode_exists('collapsibles') && $format == 'accordion'){
$total_number_publication_in_accordion=0;
$shortcode_data = '';
if (empty($year) || strpos($year, ',') !== false) {
if ((empty($year) || strpos($year, ',') !== false) && ($muteheadings!=1))
{
$openfirst = ' load="open"';
$expandall = ' expand-all-link="true"';
} else {
Expand Down Expand Up @@ -294,7 +304,7 @@ public function pubNachJahr(
else{
$subtotal_publication_html='';
}
if (empty($year)) {
if (empty($year) && ($muteheadings!=1)) {
$output .= '<h3>' . $array_year . $subtotal_publication_html .'</h3>';
}

Expand Down Expand Up @@ -673,6 +683,7 @@ public function fieldPub(
$param = array(),
$seed = false
): string {

$pubArray = [];

$filter = Tools::publication_filter($param['publications_year'], $param['publications_start'], $param['publications_end'], $param['publications_type'], $param['publications_subtype'], $param['publications_fau'], $param['publications_peerreviewed'], $param['publications_language']);
Expand All @@ -698,6 +709,12 @@ public function fieldPub(
$sortby = null;
$orderby = __('O.A.', 'fau-cris');
}

if ($this->einheit == 'field_incl_proj') {
$sortby = 'relauthors';
$orderby = 'relauthors';
}

$formatter = new Formatter(null, null, $sortby, SORT_ASC);
$res = $formatter->execute($pubArray);
$pubList = $res[$orderby] ?? [];
Expand Down Expand Up @@ -821,8 +838,8 @@ private function fetch_publications($year = '', $start = '', $end = '', $type =
if ($this->einheit === "project") {
$pubArray = $ws->by_project($this->id, $filter, $notable);
}
if ($this->einheit === "field" || $this->einheit === "field_proj") {
$pubArray = $ws->by_field($field, $filter, $fsp, $this->einheit);
if ($this->einheit === "field" || $this->einheit === "field_proj" || $this->einheit === "field_incl_proj") {
$pubArray = $ws->by_field($this->id, $filter, $fsp, $this->einheit);
}
if ($this->einheit === "publication") {
$pubArray = $ws->by_id($this->id);
Expand Down Expand Up @@ -1569,22 +1586,30 @@ public function by_field($fieldID = null, &$filter = null, $fsp = false, $entity
}

$requests = array();
$retaions = array();
switch ($entity) {
case 'field_proj':
$relation = $fsp ? 'fsp_proj_publ' : 'fobe_proj_publ';
$relations[] = $fsp ? 'fsp_proj_publ' : 'fobe_proj_publ';
break;
case 'field_notable':
$relation = 'FOBE_has_cur_PUBL';
$relations[] = 'FOBE_has_cur_PUBL';
break;
case 'field_incl_proj':
$relations[] = $fsp ? 'FOBE_FSP_has_PUBL' : 'fobe_has_top_publ';
$relations[] = $fsp ? 'fsp_proj_publ' : 'fobe_proj_publ';
break;
case 'field':
default:
$relation = $fsp ? 'FOBE_FSP_has_PUBL' : 'fobe_has_top_publ';
}

$relations[] = $fsp ? 'FOBE_FSP_has_PUBL' : 'fobe_has_top_publ';
}
foreach ($fieldID as $_p) {
$requests[] =sprintf( 'getrelated/Forschungsbereich/%d/', $_p ) . $relation;
}
return $this->retrieve($requests, $filter);
foreach ($relations as $_r) {
$requests[] =sprintf( 'getrelated/Forschungsbereich/%d/', $_p ) . $_r;
}
}
$publs=$this->retrieve($requests, $filter);

return $publs;
}

public function by_equipment($equiID = null, &$filter = null): array
Expand Down

0 comments on commit 03e1a22

Please sign in to comment.