I'm writing my first extension right now and have troubles with getting the language file loaded or using the language file I created.
So I worked myself through the tutorial and modified it a bit, trying to make a MCP module, which should later show the contents of a mysql database. Unfortunatly there is a PHP error while calling the add_lang() or load() function, here the error log from apache:
Code: Select all
[Sun Nov 04 19:13:53.510943 2018] [php7:error] [pid 23380] [client 127.0.0.1:60750] PHP Fatal error: Uncaught Error: Call to a member function add_lang() on null in /srv/http/illumina-phpbb3/ext/illumina/chemtags/mcp/main_module.php:16\nStack trace:\n#0 /srv/http/illumina-phpbb3/includes/functions_module.php(676): illumina\\chemtags\\mcp\\main_module->main('\\\\illumina\\\\chemt...', 'settings')\n#1 /srv/http/illumina-phpbb3/mcp.php(312): p_master->load_active()\n#2 {main}\n thrown in /srv/http/illumina-phpbb3/ext/illumina/chemtags/mcp/main_module.php on line 16, referer: http://127.0.0.1/illumina-phpbb3/mcp.php?sid=25243112b1c3ce08b2230e66feb3451f&i=149
Code: Select all
public function main($id, $mode)
{
global $language, $template, $request, $config;
// Load a single language file from illumina/chemtags/language/en/common.php
$language->add_lang(‘info_mcp_chemtags’, ‘illumina/chemtags’);
$this->tpl_name = 'mcp_chemtags_body';
$this->page_title = $language->lang('MCP_CHEMTAGS_TITLE');
//$this->page_title = 'testkacke';
add_form_key('illumina_chemtags_settings');
if ($request->is_set_post('submit'))
{
if (!check_form_key('illumina_chemtags_settings')) // check form key, to verify a valid form
{
trigger_error('FORM_INVALID');
}
$config->set('illumina_chemtags_goodbye', $request->variable('illumina_chemtags_goodbye', 0));
trigger_error(/*$language->lang('MCP_CHEMTAGS_SETTING_SAVED')*/'Settings saved' /*. mcp_back_link($this->u_action)*/);// TODO: backlink
}
I assume something is maybe wrong about the namespace or so, that it doesn't find the function, but also adding the corresponding namespace in front made no success. I'm also not really a PHP programmer and just learning it by the way, even if most syntax is selfexplaining (I'm a bit used to Java and more to C).
I was searching quite a bit and tried fiddling around with it, but had no success. Oh and maybe another question: I'm having trouble finding correct functions, is there any reference documentation or so besideds area51.phpbb.com ? E.g. I'm currently looking for the mcp variant of "acp_back_link()" or similar.
I'm appreciating any help from you, thanks!
P.S: phpBB 3.2.2 and PHP Version 7.2.11 are being used.