-
-
Save Skouat/4e2295afce0da171b232525cfd876068 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package phpBB Extension - LMDI Multilinks | |
* @copyright (c) 2017 Pierre Duhem - LMDI | |
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 | |
* | |
*/ | |
namespace lmdi\multilinks\acp; | |
class multilinks_module | |
{ | |
public $u_action; | |
protected $action; | |
public function main($id, $mode) | |
{ | |
global $phpbb_container; | |
/** @type \phpbb\language\language $language */ | |
$language = $phpbb_container->get('language'); | |
/** @type \phpbb\request\request $request */ | |
$request = $phpbb_container->get('request'); | |
/** @type \phpbb\template\template $template */ | |
$template = $phpbb_container->get('template'); | |
// Add form key | |
$form_name = 'acp_multilinks_add_url'; | |
add_form_key($form_name); | |
$config_text = $phpbb_container->get('config_text'); | |
$language->add_lang('acp_multilinks', 'lmdi/multilinks'); | |
$this->tpl_name = 'acp_multilinks_body'; | |
$this->page_title = $language->lang('ACP_MULTILINKS_TITLE'); | |
$action = $request->variable('action', ''); | |
$submit = $request->is_set_post('submit'); | |
if (($action == 'add_pp' || $action == 'add_ap') && $submit) | |
{ | |
$action = 'save_pp'; | |
} | |
if ($action) | |
{ | |
if (!check_form_key($form_name) && $submit) | |
{ | |
trigger_error($language->lang('FORM_INVALID') . adm_back_link($this->u_action)); | |
} | |
switch ($action) | |
{ | |
case 'move_up' : | |
break; | |
case 'move_down' : | |
break; | |
case 'delete' : | |
break; | |
case 'edit' : | |
break; | |
case 'add_pp' : | |
$template->assign_vars(array( | |
'PP_ACTION' => $this->u_action . '&action=add_pp', | |
'S_ADD_URL' => true, | |
'S_ADD_PP' => true, | |
)); | |
break; | |
case 'save_pp' : | |
$anchor = $request->variable('ml_anchor', '', true); | |
$url = $request->variable('ml_url', '', true); | |
// $blank = $request->variable ('ml_blank', false); | |
$blank = $request->variable('ml_blank', false); | |
/* | |
var_dump ($anchor); | |
var_dump ($url); | |
var_dump ($blank); | |
*/ | |
$links = $config_text->get('lmdi_multilinks_pp'); | |
// var_dump ($links); | |
$rows = json_decode($links, true); | |
$rows[] = array('anchor' => $anchor, 'url' => $url, 'blank' => $blank); | |
$links = json_encode($rows); | |
$config_text->set('lmdi_multilinks_pp', $links); | |
trigger_error($language->lang('MULTILINK_CONFIG_UPDATED') . adm_back_link($this->u_action)); | |
break; | |
case 'add_ap' : | |
$template->assign_vars(array( | |
'AP_ACTION' => $this->u_action . '&action=add_ap', | |
'S_ADD_URL' => true, | |
'S_ADD_AP' => true, | |
)); | |
break; | |
case 'save_ap' : | |
trigger_error($language->lang('MULTILINK_CONFIG_UPDATED') . adm_back_link($this->u_action)); | |
break; | |
} | |
} | |
else | |
{ | |
$links = $config_text->get('lmdi_multilinks_pp'); | |
$rows = json_decode($links, true); | |
$nb = count($rows); | |
for ($i = 0; $i < $nb; $i++) | |
{ | |
$row = $rows[$i]; | |
$template->assign_block_vars('mlpp', array( | |
'NAME' => $row['anchor'], | |
'URL' => $row['url'], | |
'BLANK' => $row['blank'], | |
'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $i, | |
'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $i, | |
'U_EDIT' => $this->u_action . '&action=edit&id=' . $i, | |
'U_DELETE' => $this->u_action . '&action=delete&id=' . $i, | |
)); | |
} | |
$template->assign_vars(array( | |
'PP_ACTION' => $this->u_action . '&action=add_pp', | |
'AP_ACTION' => $this->u_action . '&action=add_ap', | |
'S_CONFIG_PAGE' => true, | |
'U_ACTION' => $this->u_action, | |
)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment