_substitution_parameters(); $this->_init(); $this->_open(); } protected function _substitution_parameters() { global $include_path; global $deflt2docs_location; //Globalisons tout d'abord les paramètres communs à toutes les localisations if (file_exists($include_path."/parameters_subst/pdf_per_localisations_subst.xml")){ $parameter_subst = new parameters_subst($include_path."/parameters_subst/pdf_per_localisations_subst.xml", 0); } else { $parameter_subst = new parameters_subst($include_path."/parameters_subst/pdf_per_localisations.xml", 0); } $parameter_subst->extract(); if(isset($deflt2docs_location)) { if (file_exists($include_path."/parameters_subst/pdf_per_localisations_subst.xml")){ $parameter_subst = new parameters_subst($include_path."/parameters_subst/pdf_per_localisations_subst.xml", $deflt2docs_location); } else { $parameter_subst = new parameters_subst($include_path."/parameters_subst/pdf_per_localisations.xml", $deflt2docs_location); } $parameter_subst->extract(); } } protected function _init_default_parameters() { } protected function _init_default_positions() { } protected function _init() { global $pmb_pdf_font; $this->_init_PDF(); $this->_init_marges(); $this->w = $this->largeur_page-$this->marge_gauche-$this->marge_droite; $this->font = $pmb_pdf_font; if($this->get_parameter_value('text_size')) { $this->fs = $this->get_parameter_value('text_size'); } $this->_init_default_parameters(); $this->_init_default_positions(); } protected function _open() { $this->PDF->Open(); $this->PDF->SetMargins($this->marge_gauche, $this->marge_haut, $this->marge_droite); $this->PDF->setFont($this->font); $this->PDF->footer_type=1; } protected function get_parameter_value($name) { $parameter_name = static::get_parameter_prefix().'_'.$name; global $$parameter_name; return $$parameter_name; } protected function set_parameter_value($name, $value) { $parameter_name = static::get_parameter_prefix().'_'.$name; global $$parameter_name; $$parameter_name = $value; } protected function _init_marges() { $marges_page = $this->get_parameter_value('marges_page'); if(!empty($marges_page)) { $marges_page = explode(',', $marges_page); if (!empty($marges_page[0])) $this->marge_haut = $marges_page[0]; if (!empty($marges_page[1])) $this->marge_bas = $marges_page[1]; if (!empty($marges_page[2])) $this->marge_droite = $marges_page[2]; if (!empty($marges_page[3])) $this->marge_gauche = $marges_page[3]; } else { $marge_page_droite = $this->get_parameter_value('marge_page_droite'); if (!empty($marge_page_droite)) $this->marge_droite = $marge_page_droite; $marge_page_gauche = $this->get_parameter_value('marge_page_gauche'); if (!empty($marge_page_gauche)) $this->marge_gauche = $marge_page_gauche; } } protected function _init_position($name, $position=array()) { if (isset($position[0]) && $position[0]) $this->{"x_".$name} = $position[0]; if (isset($position[1]) && $position[1]) $this->{"y_".$name} = $position[1]; if (isset($position[2]) && $position[2]) $this->{"l_".$name} = $position[2]; if (isset($position[3]) && $position[3]) $this->{"h_".$name} = $position[3]; if (isset($position[4]) && $position[4]) $this->{"fs_".$name} = $position[4]; } protected function get_position_values($name) { $values = array(); if (isset($this->{"x_".$name})) $values[0] = $this->{"x_".$name}; if (isset($this->{"y_".$name})) $values[1] = $this->{"y_".$name}; if (isset($this->{"l_".$name})) $values[2] = $this->{"l_".$name}; if (isset($this->{"h_".$name})) $values[3] = $this->{"h_".$name}; if (isset($this->{"fs_".$name})) $values[4] = $this->{"fs_".$name}; return $values; } public function getLettre($format=0,$name='lettre.pdf') { if (!$format) { return $this->PDF->OutPut(); } else { return $this->PDF->OutPut($name,'S'); } } public function getFileName() { return $this->filename; } protected static function get_parameter_prefix() { return ''; } public function reset_default_positions() { $this->_init_default_positions(); } public static function get_instance($group='') { global $msg, $charset; global $base_path, $class_path, $include_path; $className = static::class; if(!isset(static::$instances[$className])) { if($group) { $prefix = static::get_parameter_prefix(); $print_parameter = $prefix."_print"; global ${$print_parameter}; if(!empty(${$print_parameter}) && file_exists($class_path."/pdf/".$group."/".${$print_parameter}.".class.php")) { require_once($class_path."/pdf/".$group."/".${$print_parameter}.".class.php"); $className = ${$print_parameter}; } else { require_once($class_path."/pdf/".$group."/".$className.".class.php"); } } else { if(!empty(${$print_parameter}) && file_exists($class_path."/pdf/".${$print_parameter}.".class.php")) { require_once($class_path."/pdf/".${$print_parameter}.".class.php"); $className = ${$print_parameter}; } else { require_once($class_path."/pdf/".$className.".class.php"); } } static::$instances[$className] = new $className(); } else { //Ré-initialisation des positions pour démarrer une nouvelle page static::$instances[$className]->reset_default_positions(); } return static::$instances[$className]; } }