- system/ vervangen door CodeIgniter 3.4.5 (pocketarc/codeigniter, PHP 8.2-8.5 compatibel) - config.php, mimes.php, user_agents.php en error-views bijgewerkt naar 3.4.5 - composer.json: php-constraint "^7.4 || ^8.0" zodat composer install op 8.3 werkt - PHP 8-fatals opgelost: count()/array-functies op FALSE/null, rekenen met lege strings, delen door nul, property zetten op FALSE, curly-brace string offsets, ongedefinieerde constanten, foute curl_setopt in Phantom_model::create_img - dynamic properties gedeclareerd in libraries, optionele parameters voor verplichte opgelost - vergelijkingen waar '' == 0 in PHP 8 anders uitvalt gecast naar (int) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
192 lines
6.1 KiB
PHP
192 lines
6.1 KiB
PHP
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Hoofdstuk
|
|
{
|
|
private $content;
|
|
private $hoofdstukkeuze;
|
|
private $volgorde;
|
|
private $views;
|
|
private $orgversie;
|
|
private $versie;
|
|
private $labels;
|
|
private $label;
|
|
private $sopkeuze;
|
|
private $view;
|
|
private $tab;
|
|
private $tabelid;
|
|
private $imagedata;
|
|
private $vervangingscode;
|
|
private $contentid;
|
|
private $hoofdstuk;
|
|
private $chapterid;
|
|
private $orgversieid;
|
|
private $profielid;
|
|
|
|
|
|
private $CI;
|
|
|
|
public function __construct($chapterid, $profielid, $orgversieid = false)
|
|
{
|
|
$this->CI =& get_instance();
|
|
$this->chapterid = $chapterid;
|
|
$this->orgversieid = $orgversieid;
|
|
$this->profielid = $profielid;
|
|
$this->handle();
|
|
}
|
|
|
|
|
|
private function handle()
|
|
{
|
|
$this->setTekst();
|
|
|
|
$this->setHoofdstukKeuze();
|
|
|
|
$this->setSchool();
|
|
|
|
$this->setVersie();
|
|
|
|
$this->setSopKeuze();
|
|
|
|
$this->setLabels();
|
|
|
|
$this->setVolgordeInleiding();
|
|
|
|
$this->setVolgordeHoofdstukken();
|
|
|
|
$this->getViews();
|
|
|
|
$this->loopViews();
|
|
|
|
$this->saveContent();
|
|
}
|
|
|
|
|
|
private function setTekst(){
|
|
$this->content = $this->CI->Standaardteksten_model->get_fieldvalue(
|
|
["soort" => 1, "chapter_id" => $this->chapterid], 'content');
|
|
}
|
|
|
|
private function setHoofdstukKeuze(){
|
|
$hoofdstukkeuze =
|
|
new Hoofdstukkeuze($this->chapterid, $this->orgversieid);
|
|
$this->hoofdstukkeuze = $hoofdstukkeuze->getHoofdstukKeuze();
|
|
}
|
|
|
|
private function setSchool(){
|
|
if( !($this->hoofdstukkeuze['data']) ) return;
|
|
$this->hoofdstukkeuze['data']['school'] = $this->CI->Organisaties_model->get_record_by_id($this->CI->globorgid);
|
|
}
|
|
|
|
private function setVersie(){
|
|
if( !($this->hoofdstukkeuze['data'])) return;
|
|
if(! isset($this->orgversieid) || $this->orgversieid == "" || $this->orgversieid == null || $this->orgversieid ==0) return;
|
|
$this->orgversie = $this->CI->Orgversies_model->get_record_by_id($this->orgversieid);
|
|
$this->versie = $this->CI->Versies_model->get_record_by_id($this->orgversie->versie_id);
|
|
$this->versie->naam = $this->versie->naam . ', periode: ' . $this->orgversie->periodenummer . ':
|
|
' . $this->orgversie->geldigvanaf . ' - ' . $this->orgversie->geldigtm;
|
|
$this->hoofdstukkeuze['data']['versie'] = $this->versie;
|
|
}
|
|
|
|
|
|
private function setSopKeuze(){
|
|
$this->sopkeuze = new Sopkeuze($this->profielid);
|
|
}
|
|
|
|
private function setLabels(){
|
|
$this->labels = $this->sopkeuze->getHoofdstukLabels();
|
|
}
|
|
|
|
private function setVolgordeInleiding()
|
|
{
|
|
if ($this->hoofdstukkeuze['soort'] != 'INLEIDING') return;
|
|
$this->volgorde = 10;
|
|
}
|
|
|
|
private function setVolgordeHoofdstukken() {
|
|
if ($this->hoofdstukkeuze['soort'] === 'INLEIDING') return;
|
|
|
|
if(!$this->labels){
|
|
$this->volgorde = 20;}
|
|
|
|
if($this->labels){
|
|
$hoogste = 0;
|
|
foreach ($this->labels as $this->label) {
|
|
if($this->label->volgorde > $hoogste){
|
|
$hoogste = $this->label->volgorde;
|
|
}
|
|
}
|
|
$this->volgorde = $hoogste + 10;
|
|
}
|
|
}
|
|
|
|
|
|
private function getViews(){
|
|
$this->views = $this->CI->Sopviews_model->get_records_where(
|
|
['soort' =>$this->hoofdstukkeuze['soort']]);
|
|
}
|
|
|
|
private function loopViews(){
|
|
if(! $this->views) return;
|
|
if( !($this->hoofdstukkeuze['data']) ) return;
|
|
foreach ($this->views as $index => $this->view) {
|
|
$this->loadView($index);
|
|
$this->maakAfbeelding($index);
|
|
$this->plaatsAfbeelding();
|
|
}
|
|
}
|
|
|
|
private function loadView($index){
|
|
$pad = $this->view->pad;
|
|
$this->view->tab = $this->CI->load->view("monpas/sopkeuze/" . $pad, ['data' => $this->hoofdstukkeuze['data']], TRUE);
|
|
|
|
}
|
|
|
|
private function maakAfbeelding($index){
|
|
if ($this->view->type != 'GRA') return;
|
|
//ls okt 2020 if(!$this->view->imagecode) return;
|
|
if(!$this->view->tabelid) return;
|
|
$this->view->grafiek = $this->CI->Phantom_model->create_img($this->view->tab, 'test', FALSE, FALSE, array(650, 0));
|
|
//ls okt 2020 $this->imagedata = "<img src='data:image/png;base64," . $this->view->grafiek ."' id='" . $this->view->imagecode . "' />";
|
|
|
|
$this->imagedata = "<img src='data:image/png;base64," . $this->view->grafiek ."' id='" . $this->view->tabelid . "' />";
|
|
}
|
|
|
|
private function plaatsAfbeelding()
|
|
{
|
|
$afbeelding = "";
|
|
$vervang = $this->view->vervangingscode;
|
|
if (strpos($this->content, $vervang)) {
|
|
$lengte = strlen($vervang);
|
|
$pos = strpos($this->content, $vervang);
|
|
if($this->view->type === 'GRA'){
|
|
$afbeelding = $this->imagedata;
|
|
}
|
|
if($this->view->type === 'TAB'){
|
|
$afbeelding = $this->view->tab;
|
|
}
|
|
|
|
if ($afbeelding == "") return;
|
|
$this->content = substr_replace($this->content, $afbeelding, $pos, $lengte);
|
|
}
|
|
}
|
|
|
|
private function saveContent(){
|
|
|
|
if( !($this->hoofdstukkeuze['data'])) return false;
|
|
|
|
|
|
|
|
$this->hoofdstuk = array( 'profiel_id' => $this->profielid,
|
|
'chapter_id' => $this->chapterid,
|
|
'content' => $this->content,
|
|
'orgversieid' => $this->orgversieid,
|
|
'volgorde' => $this->volgorde);
|
|
|
|
$oldID = $this->CI->Sopinhouden_model->get(['profiel_id' => $this->profielid, 'chapter_id'=> $this->chapterid], 'id' , true) ;
|
|
if ($oldID){
|
|
$this->CI->Sopinhouden_model->update_record($this->hoofdstuk, $oldID);
|
|
} else {
|
|
$this->CI->Sopinhouden_model->insert_record($this->hoofdstuk);
|
|
}
|
|
}
|
|
} |