Hallo beisammen, ich versuche gerade unter 4.8.0.2 die /admin/includes/gm/classes/gmOrderPDF.php zu überladen. IMPORTANT! THIS FILE IS DEPRECATED AND WILL BE REPLACED IN THE FUTURE. MODIFY IT ONLY FOR FIXES. DO NOT APPEND IT WITH NEW FEATURES, USE THE NEW GX-ENGINE LIBRARIES INSTEAD. hab ich gelesen. Aber unter GXengine gibts noch gar keine neuen Libraries hierfür, oder? /GXModules/ff-webdesigner/custom/Admin/Overloads/gmOrderPdf/ff_gmOrderPDF.php angelegt. Code: class ff_gmOrderPDF extends ff_gmOrderPDF_parent oder auch class ff_gmOrderPDF_ORIGIN extends ff_gmOrderPDF_ORIGIN_parent und einige andere tests führen immer zu Fehler 500. Wo ist mein Fehler?
Das ist korrekt, ohne die exakte Fehlermeldung zu kennen, ist es nicht möglich rauszufinden wo das Problem liegt.
Der einzige Unterschied zu meinen Overloads ist, dass Du das Verzeichnis gmOrderPdf und ich gmOrderPDF benannt habe. Hast Du denn weiteren Code in der Klasse, so dass da evtl. ein Fehler drin ist.
@Kai Stejuhn: hatte mich oben nur vertippt. Overload Ordner ist gmOrderPDF @Till: bis auf die erste Zeile ist der Inhalt 100% gleich Originaldatei...ich vemute mal da muss ich in den beinhalteten functions noch etwas anpassen? PHP: function __construct($type, $order_right, $order_data, $order_total, $order_info, $pdf_footer, $pdf_fonts, $gm_pdf_values, $gm_order_pdf_values, $gm_use_products_model) {....parent::__construct($gm_pdf_values);parent::SetAuthor($this->pdf_company_adress_left); // -> to the title of the pdfument parent::SetTitle($this->pdf_heading); // -> to set the subject of the pdfument parent::SetSubject($this->pdf_heading); // -> to set the keywords of the pdfument parent::SetKeywords(str_replace("\n", ",", $this->pdf_company_adress_right)); // -> to set the creator of the pdfument parent::SetCreator('fpdf.org/gambio.de'); meine anpassungen befinden sich in function __construct function getBody() function getCells und betreffen einzig das ausbauen aller preise sowie $this->pdf_customer_adress
@ff-webdesigner Also erstmal musst du wenn du die parent::__construct aufrufst immer alle Parameter der Funktion mit übergeben, du darfst hier niemals Parameter weglassen. Zweitens: Wenn die Original Funktion ein return hat, musst du die Daten von der Orginal Funktion auch mit zurückgeben, damit die Überladungskette eingehalten wird.
hier mein overload: PHP: <?phpclass ff_gmOrderPDF extends ff_gmOrderPDF_parent{ function __construct($type, $order_right, $order_data, $order_total, $order_info, $pdf_footer, $pdf_fonts, $gm_pdf_values, $gm_order_pdf_values, $gm_use_products_model) { $this->pdf_type = $type; $this->pdf_fonts = $pdf_fonts; $this->pdf_company_adress_right = $order_right; $this->order_data = $order_data; $this->order_total = $order_total; $this->order_info = $order_info; $this->pdf_footer = $pdf_footer; $this->languageId = (int)($_SESSION['languages_id'] ?? null); $result = xtc_db_query('SELECT l.languages_id, o.language FROM languages l, orders o WHERE o.orders_id = ' . (int)$_GET['oID'] . ' AND l.directory = o.language'); if (xtc_db_num_rows($result)) { $row = xtc_db_fetch_array($result); $this->languageId = (int)$row['languages_id']; } $this->languageTextManager = MainFactory::create('LanguageTextManager', 'gm_pdf_order', $this->languageId); // -> call parent constructor parent::__construct($gm_pdf_values); // -> set defaults $this->pdf_draw_color = parent::getRGB($gm_order_pdf_values['GM_PDF_DRAW_COLOR']); $this->pdf_customer_adr_pos = $gm_order_pdf_values['GM_PDF_CUSTOMER_ADR_POS']; $this->pdf_heading_margin_bottom = $gm_order_pdf_values['GM_PDF_HEADING_MARGIN_BOTTOM']; $this->pdf_heading_margin_top = $gm_order_pdf_values['GM_PDF_HEADING_MARGIN_TOP']; $this->pdf_order_info_margin_top = $gm_order_pdf_values['GM_PDF_ORDER_INFO_MARGIN_TOP']; $this->pdf_use_logo = $gm_order_pdf_values['GM_LOGO_PDF_USE']; $this->pdf_logo_path = $gm_order_pdf_values['GM_PDF_LOGO_LINK'] ?? null; $this->pdf_link = $gm_order_pdf_values['GM_PDF_LINK']; $this->pdf_company_adress_left = $gm_order_pdf_values['GM_PDF_COMPANY_ADRESS_LEFT']; $this->pdf_customer_adress = "xxx"; $this->pdf_heading = $gm_order_pdf_values['GM_PDF_HEADING']; $this->pdf_heading_info = $gm_order_pdf_values['GM_PDF_HEADING_INFO'] ?? null; $this->pdf_heading_conditions = $gm_order_pdf_values['GM_PDF_HEADING_CONDITIONS']; $this->pdf_heading_withdrawal = $gm_order_pdf_values['GM_PDF_HEADING_WITHDRAWAL']; $this->pdf_conditions = $gm_order_pdf_values['GM_PDF_CONDITIONS']; $this->pdf_withdrawal = $gm_order_pdf_values['GM_PDF_WITHDRAWAL']; $this->pdf_use_conditions = $gm_order_pdf_values['GM_PDF_USE_CONDITIONS']; $this->pdf_use_withdrawal = $gm_order_pdf_values['GM_PDF_USE_WITHDRAWAL']; $this->pdf_show_tax = $gm_order_pdf_values['GM_PDF_SHOW_TAX']; $this->pdf_cancel = $gm_order_pdf_values['GM_PDF_CANCEL'] ?? null; $this->pdf_use_products_model = $gm_use_products_model; $this->restoreHtmlEntitiesInArrays(); $this->restoreHtmlEntitiesInStrings(); parent::SetAuthor($this->pdf_company_adress_left); parent::SetTitle($this->pdf_heading); parent::SetSubject($this->pdf_heading); parent::SetKeywords(str_replace("\n", ",", $this->pdf_company_adress_right)); parent::SetCreator('fpdf.org/gambio.de'); $t_order_tax_sql ="SELECT * FROM `orders_total` WHERE `orders_id` = " . (int)$_GET['oID'] . " AND `class` = 'ot_tax' AND value > 0"; $t_order_tax_result = xtc_db_query($t_order_tax_sql); if($this->is_ot_gm_tax_free() && gm_get_conf('TAX_INFO_TAX_FREE') == 'true' || xtc_db_num_rows($t_order_tax_result) == 0) { $this->pdf_show_tax = 0; $this->pdf_ot_gm_tax_free = true; } else { $this->pdf_show_tax = 1; $this->pdf_ot_gm_tax_free = false; } if($this->pdf_type == 'invoice') { if($this->pdf_use_products_model == false) { if($this->pdf_show_tax == 0) { $this->pdf_order_data_cell_width = array(parent::getInnerWidth() * 0, parent::getInnerWidth() * 0.5, parent::getInnerWidth() * 0.1, parent::getInnerWidth() * 0, parent::getInnerWidth() * 0.2, parent::getInnerWidth() * 0.2); } else { $this->pdf_order_data_cell_width = array(parent::getInnerWidth() * 0, parent::getInnerWidth() * 0.4, parent::getInnerWidth() * 0.1, parent::getInnerWidth() * 0.1, parent::getInnerWidth() * 0.25, parent::getInnerWidth() * 0.15); } } else { if($this->pdf_show_tax == 0) { $this->pdf_order_data_cell_width = array(parent::getInnerWidth() * 0.15, parent::getInnerWidth() * 0.35, parent::getInnerWidth() * 0.1, parent::getInnerWidth() * 0, parent::getInnerWidth() * 0.2, parent::getInnerWidth() * 0.2); } else { $this->pdf_order_data_cell_width = array(parent::getInnerWidth() * 0.15, parent::getInnerWidth() * 0.3, parent::getInnerWidth() * 0.1, parent::getInnerWidth() * 0.1, parent::getInnerWidth() * 0.2, parent::getInnerWidth() * 0.15); } } } else { if($this->pdf_use_products_model == false) { $this->pdf_order_data_cell_width = array(parent::getInnerWidth() * 0, parent::getInnerWidth() * 0.9, parent::getInnerWidth() * 0.1); } else { $this->pdf_order_data_cell_width = array(parent::getInnerWidth() * 0.15, parent::getInnerWidth() * 0.75, parent::getInnerWidth() * 0.1); } } $this->pdf_order_total_cell_width = array(parent::getInnerWidth() * 0.8, parent::getInnerWidth() * 0.2); $this->pdf_order_info_cell_width = array(0 => parent::getInnerWidth() * 0.3, 1 => parent::getInnerWidth() * 0.7); return; }} construct und return passen doch so? einzige anpassung: $this->pdf_customer_adress = "xxx"; fehler 500, nichts in logfiles...
@ff-webdesigner Du musst die Funktion mit allen Parametern aufrufen: parent::__construct($gm_pdf_values); Da fehlen die Parameter aus der Funktion selber. Außerdem einfach ein return ist nicht korrekt, du musst auch das zurückgeben, was in der Original-Funktion zurückgegeben wird, sonst funktioniert die Überladungskette nicht mehr.