Skip to content

Commit

Permalink
Merge pull request #13 from RRZE-Webteam/dev
Browse files Browse the repository at this point in the history
Release ready
  • Loading branch information
xwolfde authored Nov 26, 2021
2 parents 8a6dd49 + cc7e823 commit 22881af
Show file tree
Hide file tree
Showing 15 changed files with 1,168 additions and 516 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#FAU Orga Breadcrumb
# FAU Orga Breadcrumb

## Download

GitHub-Repo: https://github.com/RRZE-Webteam/fau-orga-breadcrumb

## Autor

RRZE-Webteam , http://www.rrze.fau.de

## Copryright

GNU General Public License (GPL) Version 3


## Beschreibung


Dieses Plugin erstellt eine organisatorische Breadcrumb für Einrichtungen
der Friedrich-Alexaner-Universität Erlangen-Nürnberg (FAU).
Expand All @@ -8,6 +24,25 @@ in diesem Plugin definierten Array vordefiniert. Später ist geplant, die
organisatorischen Daten über eine zu schaffende Schnittstelle zum
Organisationsverwaltungssystem FAU.ORG abzurufen.

## Verwendung

Die FAU ORG Breadcrumb kann mittels Shortcode ausgegeben werden:

```html
[fauorga]
```
Bei der Default-Nutzung wird der Eintrag in den Settings resp. aus dem Customizer verwendet.
Zu beachten ist, dass dieser auch abhängig vom gewählten Website-Type sein kann.
Bei Wahl des Website-Types als zentrales FAU-Portal, als Fakultätsportal oder als externe Kooperation wird der Shortcode keine Ausgabe liefern.

Aufruf mit Angabe einer FAU.ORG-Nummer:

```html
[fauorga org="1514000000"]
```

Mit dem Attribut org lässt sich auch der Pfad zu anderen Organisationen darstellen. Als Eingabe dient dabei die FAU.ORG Id.


## Entwickler-Hinweise

Expand Down
32 changes: 23 additions & 9 deletions constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@
'shorttitle' => 'FAU',
'url' => __('https://www.fau.de', 'fau-orga-breadcrumb'),
),
'1011000000' => array(

'1005000000' => array(
'title' => __('Zentrale Universitätsverwaltung', 'fau-orga-breadcrumb'),
'shorttitle' => 'ZUV',
'url' => __('https://www.fau.de', 'fau-orga-breadcrumb'),
'parent' => '1005000000'
),
'1011000000' => array(
'title' => 'Zentrale Einrichtungen',
'parent' => '0000000000',
'hide' => true,
Expand All @@ -53,7 +60,8 @@
'shorttitle' => 'Phil',
'url' => __('https://phil.fau.de', 'fau-orga-breadcrumb'),
'parent' => '0000000000',
'class' => 'phil'
'class' => 'phil',
'faculty' => 'phil'
),
'1111000000' => array(
'title' => __('Department Alte Welt und Asiatische Kulturen', 'fau-orga-breadcrumb'),
Expand Down Expand Up @@ -116,27 +124,30 @@
'parent' => '1100000000'
),


'1200000000' => array(
'title' => __('Rechts- und Wirtschaftswissenschaftliche Fakultät', 'fau-orga-breadcrumb'),
'shorttitle' => 'RW',
'url' => __('https://rw.fau.de', 'fau-orga-breadcrumb'),
'parent' => '0000000000',
'class' => 'rw'

'class' => 'rw',
'faculty' => 'rw'
),
'1211000000' => array(
'title' => __('Fachbereich Rechtswissenschaften', 'fau-orga-breadcrumb'),
'shorttitle' => __('Jura', 'fau-orga-breadcrumb'),
'url' => __('https://jura.rw.fau.de', 'fau-orga-breadcrumb'),
'parent' => '0000000000',
'class' => 'rw'
'class' => 'rw',
'faculty' => 'rw'
),
'1212000000' => array(
'title' => __('Fachbereich Wirtschaftswissenschaften', 'fau-orga-breadcrumb'),
'shorttitle' => 'WiSo',
'url' => __('https://wiso.rw.fau.de', 'fau-orga-breadcrumb'),
'parent' => '0000000000',
'class' => 'rw'
'class' => 'rw',
'faculty' => 'rw'
),


Expand All @@ -145,7 +156,8 @@
'shorttitle' => 'Med',
'url' => __('https://med.fau.de', 'fau-orga-breadcrumb'),
'parent' => '0000000000',
'class' => 'med'
'class' => 'med',
'faculty' => 'medl'
),
'1311000000' => array(
'title' => __('Einrichtungen, die nicht zum Universitätsklinikum Erlangen gehören', 'fau-orga-breadcrumb'),
Expand Down Expand Up @@ -215,7 +227,8 @@
'shorttitle' => 'Nat',
'url' => __('https://nat.fau.de', 'fau-orga-breadcrumb'),
'parent' => '0000000000',
'class' => 'nat'
'class' => 'nat',
'faculty' => 'nat'
),
'1411000000' => array(
'title' => __('Department Biologie', 'fau-orga-breadcrumb'),
Expand Down Expand Up @@ -255,7 +268,8 @@
'shorttitle' => 'TF',
'url' => __('https://tf.fau.de', 'fau-orga-breadcrumb'),
'parent' => '0000000000',
'class' => 'tf'
'class' => 'tf',
'faculty' => 'tf'
),
'1511000000' => array(
'title' => __('Department Chemie- und Bioingenieurwesen', 'fau-orga-breadcrumb'),
Expand Down
2 changes: 1 addition & 1 deletion css/fau-orga-breadcrumb-admin.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/fau-orga-breadcrumb.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
Plugin Name: FAU ORGA Breadcrumb
Version: 1.1.0
Version: 1.1.3
Requires at least: 5.0
Tested up to: 5.8
Requires PHP: 7.4
Expand Down
6 changes: 2 additions & 4 deletions fau-orga-breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: FAU ORGA Breadcrumb
Plugin URI: https://github.com/RRZE-Webteam/fau-orga-breadcrumb
Description: Displays an organisational breadcrumb
Version: 1.1.1
Version: 1.1.4
Author: RRZE-Webteam
Author URI: http://blogs.fau.de/webworking/
License: GNU GPLv2
Expand Down Expand Up @@ -50,9 +50,7 @@ function init() {

include_once('includes/shortcode.php');
// define shortcodes
include_once('includes/widget.php');
// define widgets


include_once('includes/settings.php');
// admin settings

Expand Down
149 changes: 137 additions & 12 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,61 @@
/*-----------------------------------------------------------------------------------*/
/* Global functions for plugin
/*-----------------------------------------------------------------------------------*/
$fau_orga_fautheme = get_fau_orga_fautheme();

/*-----------------------------------------------------------------------------------*/
/* Admin Notice auf der Dashboard, damit man die ORGA Breadcrumb setzt
/*-----------------------------------------------------------------------------------*/
function fau_orga_admin_notice(){
global $pagenow;
global $fau_orga_fautheme;

$website_type = get_theme_mod("website_type");
$form_org = '';
$options = get_option( 'fau_orga_breadcrumb_options' );
if (isset($options['site-orga'])) {
$form_org = esc_attr($options['site-orga']);
}
// Wenn wir in einem FAU Theme sind
// UND der Website-Type = 1 (Einrichtung einer Fakultät) ist
// UND noch keine Zuordnung erfolgte,
// dann zeige den Hinweis, dass man doch bitte eine Zuordnung machen soll


if (isset($website_type) && ($website_type == 1) && (empty($form_org))) {
if ( $pagenow == 'index.php' ) {
$user = wp_get_current_user();
if ( in_array( 'administrator', (array) $user->roles ) ) {
echo '<div class="notice notice-warning">';
echo __('Der Webauftritt ist noch nicht organisatorisch eingeordnet. <br>Bitte rufen Sie die <a href="options-general.php?page=fau_orga_breadcrumb_settings">Einstellung FAU.ORG Breadcrumb</a> auf und geben Sie an, welcher organisatorischen Einheit der Webauftritt angehört.','fau-orga-breadcrumb');
echo '</div>';

}
}
}



}
add_action('admin_notices', 'fau_orga_admin_notice');

/*-----------------------------------------------------------------------------------*/
/* Get FAU.ORG by faculty
/*-----------------------------------------------------------------------------------*/
function get_fau_orga_fauorg_by_faculty( $faculty = '') {
global $fau_orga_breadcrumb_data;
$res = '';
// $fauorg = san_fauorg_number($fauorg);
if (isset($faculty)) {
foreach($fau_orga_breadcrumb_data as $key => $listdata) {
if (isset($listdata['faculty']) && ($listdata['faculty'] == $faculty)) {
$res = $key;
break;
}
}
}
return $res;
}
/*-----------------------------------------------------------------------------------*/
/* Get child elements
/*-----------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -64,33 +118,63 @@ function get_fau_orga_upperclass( $fauorg = '') {
/*-----------------------------------------------------------------------------------*/
/* create option list for forms
/*-----------------------------------------------------------------------------------*/
function get_fau_orga_form_optionlist ( $fauorg = '000000000', $preorg = '000000000', $level = 0, $maxdepth = 4) {
function get_fau_orga_form_optionlist( $fauorg = '000000000', $preorg = '000000000', $level = 0, $maxdepth = 4) {
global $fau_orga_breadcrumb_data;
global $fau_orga_breadcrumb_config;


$fauorg = san_fauorg_number($fauorg);

if (isset($preorg)) {
$org = san_fauorg_number($preorg);
}
$firstlevel = get_fau_orga_childs($fauorg);

$res = '';
$faculty = '';
$website_type = get_theme_mod("website_type");

if (isset($website_type) && ($website_type==0) ) {
// Fakultaetsportal. Kann nur oberste Ebene auswählen.
$key = $fau_orga_breadcrumb_config['root'];
if (isset($fau_orga_breadcrumb_data[$key])) {
$res = '<option value="'.$key.'" '.selected( $org, $key , false).'>'.$fau_orga_breadcrumb_data[$key]['title'].'</option>';
return $res;
}


if (isset($website_type) ) {
if ($website_type==0 ) {
// Fakultaetsportal. Kann nur oberste Ebene auswählen.
$key = $fau_orga_breadcrumb_config['root'];
if (isset($fau_orga_breadcrumb_data[$key])) {
$res = '<option value="'.$key.'" '.selected( $org, $key , false).'>'.$fau_orga_breadcrumb_data[$key]['title'].'</option>';
return $res;
}
} elseif ($website_type==1) {
global $fau_orga_fautheme;
if ($fau_orga_fautheme) {
$faculty = $fau_orga_fautheme;
$debug_website_fakultaet = get_theme_mod('debug_website_fakultaet');
if (isset($debug_website_fakultaet)) {
$faculty = $debug_website_fakultaet;
}

}
} elseif ($website_type==2) {
$faculty = 'zentral';
}
}

$firstlevel = get_fau_orga_childs($fauorg);

if (!empty($firstlevel)) {
foreach($firstlevel as $key) {
if (!empty($faculty)) {
if (($faculty !== 'zentral') && isset($fau_orga_breadcrumb_data[$key]['faculty']) && ($fau_orga_breadcrumb_data[$key]['faculty'] !== $faculty)) {
// wenn wir in einem Fakultatstheme sind, dann lasse alle Einrichtungen die zu anderen Fakultaeten gehören, weg
continue;
}
if (($faculty== 'zentral') && isset($fau_orga_breadcrumb_data[$key]['faculty'])) {
// wenn wir im Zentralbereich sind, dann lasse alle Einträge, die Fakultäten ungeordnet sind, weg
continue;
}
}




$orgclass = get_fau_orga_upperclass($key);

if ($orgclass) {
$class = 'depth-'.$level.' '.$orgclass;
} else {
Expand Down Expand Up @@ -205,7 +289,48 @@ function get_fau_orga_breadcrumb($form_org) {
}
return;
}
/*-----------------------------------------------------------------------------------*/
/* get FAU Theme to find out if the website belongs to a faculty
* returns
* false if no FAU theme
* the string with the faculty nat,phil,tf,rw,med if one of the faculty theme
* the string zentral if other FAU Theme
*/
/*-----------------------------------------------------------------------------------*/
function get_fau_orga_fautheme() {

$active_theme = wp_get_theme();
$active_theme = $active_theme->get( 'Name' );


global $known_themes;

if (in_array($active_theme, $known_themes['fauthemes'])) {

switch($active_theme) {
case 'FAU-Philfak':
$res = 'phil';
break;
case 'FAU-RWFak':
$res = 'rw';
break;
case 'FAU-Natfak':
$res = 'nat';
break;
case 'FAU-Medfak':
$res = 'med';
break;
case 'FAU-Techfak':
$res = 'tf';
break;
default:
$res = 'zentral';
}
return $res;
}
return false;

}

/*-----------------------------------------------------------------------------------*/
/* enqueue with filter by theme
Expand Down
Loading

0 comments on commit 22881af

Please sign in to comment.