diff --git a/application/controllers/jobs/OrganigrammTest.php b/application/controllers/jobs/OrganigrammTest.php index e02135ca9..07244453c 100644 --- a/application/controllers/jobs/OrganigrammTest.php +++ b/application/controllers/jobs/OrganigrammTest.php @@ -8,11 +8,11 @@ if (!defined("BASEPATH")) exit("No direct script access allowed"); */ class OrganigrammTest extends JOB_Controller { - const DEFAULT_XOFFSET = 50; - const DEFAULT_YOFFSET = 25; - const DEFAULT_WIDTH = 165; + const DEFAULT_XOFFSET = 40; + const DEFAULT_YOFFSET = 30; + const DEFAULT_WIDTH = 160; const DEFAULT_HEIGHT = 50; - const DEFAULT_SPACING = 50; + const DEFAULT_SPACING = 40; const DEFAULT_FONTSIZE = 8; const RENDER_CHILDS_HORIZONTAL = 1; const RENDER_CHILDS_VERTICAL = 2; @@ -35,7 +35,11 @@ class OrganigrammTest extends JOB_Controller $sql = <<oe_kurzbz, array('depAngewandteMath', 'depEntrepreneurshipComm')) ) - { - file_put_contents( "php://stderr", print_r($assocoe, true), FILE_APPEND); - } if( $assocoe->oe_parent_kurzbz === NULL ) { $roots[$assocoe->oe_kurzbz] = $assocoe; @@ -99,7 +100,8 @@ EOSQL; 'Lehrgang', 'Studiengang', 'Kompetenzfeld', - 'Forschungsfeld' + 'Forschungsfeld', + 'Container' ); } else @@ -129,13 +131,13 @@ EOSQL; HEADER; - file_put_contents( "php://stderr", count($roots), FILE_APPEND); + foreach($roots AS &$root) { $this->maxxoffset = self::DEFAULT_XOFFSET; $this->donotrenderchildsoftype = $root->donotrenderchildsoftype; - $this->resetChildsOffset($root); - + $this->prepareChildsToRender($root); + $bezeichnung = htmlspecialchars($root->bezeichnung); echo <<childstorender = array(); + $oe->renderchilds = self::RENDER_CHILDS_HORIZONTAL; if( isset($oe->childsxoffset) ) { unset($oe->childsxoffset); } - foreach($oe->childs AS $oechild ) + foreach($oe->childs AS &$oechild ) { - $this->resetChildsOffset($oechild); - } + $this->prepareChildsToRender($oechild); + if( !in_array($oechild->organisationseinheittyp_kurzbz, $this->donotrenderchildsoftype) ) + { + $oe->childstorender[] = $oechild; + } + } + + $nurLehrgaengeOderStudiengaengeOhneKinder = true; + foreach($oe->childstorender AS &$oechildtorender ) + { +/* + if( !(($oechild->organisationseinheittyp_kurzbz == 'Studiengang' + || $oechild->organisationseinheittyp_kurzbz == 'Lehrgang') + && count($oechild->childs) === 0) ) +*/ + if( !(count($oechildtorender->childstorender) === 0) ) + { + $nurLehrgaengeOderStudiengaengeOhneKinder = false; + } + } + + if( $nurLehrgaengeOderStudiengaengeOhneKinder && $oe->parent !== NULL ) + { + $oe->renderchilds = self::RENDER_CHILDS_VERTICAL; + } } - + protected function renderOE($oe, $level, $parentrenderedchildcount) { $width = self::DEFAULT_WIDTH; @@ -203,7 +229,7 @@ FOOTER; $curxoffset = $this->maxxoffset; - if( count($oe->childs) > 0 ) + if( count($oe->childstorender) > 0 ) { if( !isset($oe->childsxoffset) ) { @@ -212,36 +238,19 @@ FOOTER; 'max' => $curxoffset ); } - - $nurLehrgaengeOderStudiengaengeOhneKinder = true; - foreach($oe->childs AS &$oechild ) - { -/* - if( !(($oechild->organisationseinheittyp_kurzbz == 'Studiengang' - || $oechild->organisationseinheittyp_kurzbz == 'Lehrgang') - && count($oechild->childs) === 0) ) - */ - if( !(count($oechild->childs) === 0) ) - { - $nurLehrgaengeOderStudiengaengeOhneKinder = false; - } - if( !in_array($oechild->organisationseinheittyp_kurzbz, $this->donotrenderchildsoftype) ) - { - $oe->childstorender[] = $oechild; - } - } - if( $nurLehrgaengeOderStudiengaengeOhneKinder ) - { - $oe->renderchilds = self::RENDER_CHILDS_VERTICAL; - } foreach($oe->childstorender AS $child) { - $oe->childsxoffset->max = $this->renderOE($child, $nextlevel, $renderedchildcount); + $ret = $this->renderOE($child, $nextlevel, $renderedchildcount); $renderedchildcount++; + if( $renderedchildcount === 1 ) + { + $oe->childsxoffset->min = $ret->minx; + } + $oe->childsxoffset->max = $ret->maxx; } - if( count($oe->childstorender) > 0 && count($oe->childstorender) === $renderedchildcount ) + if( count($oe->childstorender) === $renderedchildcount ) { $curxoffset = $oe->childsxoffset->min + floor((($oe->childsxoffset->max - $oe->childsxoffset->min) / 2)) - @@ -252,13 +261,6 @@ FOOTER; if( $oe->parent !== null && $oe->parent->renderchilds === self::RENDER_CHILDS_VERTICAL ) { -/* - if($parentrenderedchildcount === 0) - { - $curxoffset += ($width + $spacing); - $this->maxxoffset = $curxoffset; - } - */ $x = $curxoffset; $y = self::DEFAULT_YOFFSET + (($level - 1) * ($height + $spacing)) @@ -272,10 +274,14 @@ FOOTER; $bezeichnung = htmlspecialchars($oe->bezeichnung); $leitung = ($oe->leitung_uid !== null) ? htmlspecialchars($oe->leitung_uid) : 'N.N.'; $fillcolors = array( - 'Team' => '#ffe6cc', - 'Abteilung' => '#e6ffcc', - 'Studiengang' => '#cce6ff', - 'Lehrgang' => '#e6ccff' + 'Team' => '#ffe6cc', + 'Abteilung' => '#e6ffcc', + 'Studiengang' => '#cce6ff', + 'Lehrgang' => '#e6ccff', + 'Fakultaet' => '#f8cecc', + 'Department' => '#fff2cc', + 'Forschungsfeld' => '#e1d5e7', + 'Kompetenzfeld' => '#f5f5f5' ); $fillcolor = (isset($fillcolors[$oe->organisationseinheittyp_kurzbz])) ? $fillcolors[$oe->organisationseinheittyp_kurzbz] : '#ffffff'; echo << + {$edgegeom} @@ -324,9 +330,15 @@ EDGE; { $this->maxxoffset = ($x + $width + $spacing); } - return ($x + $width + $spacing); + return (object) array( + 'minx' => $curxoffset, + 'maxx' => ($x + $width + $spacing) + ); } - return $x; + return (object) array( + 'minx' => $curxoffset, + 'maxx' => $x + ); } if( $this->maxxoffset < ($x + $width + $spacing) ) @@ -334,6 +346,9 @@ EDGE; $this->maxxoffset = ($x + $width + $spacing); } - return ($x + $width + $spacing); + return (object) array( + 'minx' => $curxoffset, + 'maxx' => ($x + $width + $spacing) + ); } }