Worked further on the menu block and the basic version works now

This commit is contained in:
Marc Alexander
2010-09-13 23:11:16 +00:00
parent fb33da9e43
commit b3f0f852fa
4 changed files with 59 additions and 71 deletions

View File

@@ -50,19 +50,56 @@ class portal_main_menu_module
* custom acp template
* file must be in "adm/style/portal/"
*/
var $custom_acp_tpl = 'acp_portal_links';
var $custom_acp_tpl = 'acp_portal_menu';
function get_template_side($module_id)
{
global $config, $template, $phpEx, $phpbb_root_path;
// @todo: merge into constants file, maybe even portal contants file
define('B3_LINKS_CAT', 0);
define('B3_LINKS_INT', 1);
define('B3_LINKS_EXT', 2);
$links_urls = $links_options = $links_titles = array();
$links_urls = explode(';', $config['board3_links_urls']);
$links_options = explode(';', $config['board3_links_options']);
$links_titles = explode(';', $config['board3_links_titles']);
for ($i = 0; $i < sizeof($links_urls); $i++)
{
if($links_options[$i] == B3_LINKS_CAT)
{
$template->assign_block_vars('portalmenu', array(
'CAT_TITLE' => $links_titles[$i],
));
}
else
{
if($links_options[$i] == B3_LINKS_INT)
{
$cur_url = append_sid($phpbb_root_path . $links_urls[$i]);
}
else
{
$cur_url = $links_urls[$i];
}
$template->assign_block_vars('portalmenu.links', array(
'LINK_TITLE' => $links_titles[$i],
'LINK_URL' => $cur_url,
));
}
}
$template->assign_vars(array(
'U_M_BBCODE' => append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode'),
'U_M_TERMS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'),
'U_M_PRV' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'),
));
return 'main_menu_side.html';
return 'main_menu_new.html';
}
function get_template_acp($module_id)
@@ -331,74 +368,6 @@ class portal_main_menu_module
'S_LINK_IS_CAT' => ($links_options[$i] == B3_LINKS_CAT) ? true : false,
));
}
$db->sql_freeresult($result);
}
/*
* create a table that lets the user manage the links
* @todo: finish the main menu manage section
* links_options:
* 0 = category
* 1 = internal link
* 2 = external link
* links_urls: contains the URLs or titles (for categories)
*/
function manage_links_old($key)
{
global $config, $phpbb_admin_path, $user, $phpEx, $db;
// @todo: merge into constants file, maybe even portal contants file
define('B3_LINKS_CAT', 0);
define('B3_LINKS_INT', 1);
define('B3_LINKS_EXT', 2);
$sql = 'SELECT module_id FROM ' . PORTAL_MODULES_TABLE . " WHERE module_classname = 'main_menu'";
$result = $db->sql_query($sql);
$module_id = $db->sql_fetchfield('module_id');
$db->sql_freeresult($result);
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id);
// opening code of the table
$table_begin = "<table id='board3_links_manage' cellspacing='1'>\n<col class='row1' />\n<col class='row1' />\n<col class='row1' />\n<col class='row2' />\n<thead><tr><th>{$user->lang['ACP_PORTAL_MENU_TITLE']}</th><th>{$user->lang['ACP_PORTAL_MENU_URL']}</th><th>{$user->lang['ACP_PORTAL_MENU_TYPE']}</th><th>{$user->lang['ACTIONS']}</th></tr></thead>\n<tbody>";
// code of the table end
$table_end = "</tbody>\n</table>";
$table_content = ''; // make sure this is empty before we begin
$links_urls = explode(';', $config['board3_links_urls']);
$links_options = explode(';', $config['board3_links_options']);
$links_titles = explode(';', $config['board3_links_titles']);
$links = array();
for ($i = 0; $i < sizeof($links_urls); $i++)
{
// Cats will have a blueish background, normal links have white
$table_row = ($links_options[$i] == B3_LINKS_CAT) ? "class='row2'": "class='row1'";
// Define the drop-down box for the type of the link
$drop_down_box = "<select id='board3_links_options$i' name='board3_links_options$i'>";
$drop_down_box .= ($links_options[$i] == B3_LINKS_CAT) ? "<option value='0' selected='selected'>{$user->lang['ACP_PORTAL_MENU_CAT']}</option>" : "<option value='0'>{$user->lang['ACP_PORTAL_MENU_CAT']}</option>";
$drop_down_box .= ($links_options[$i] == B3_LINKS_INT) ? "<option value='1' selected='selected'>{$user->lang['ACP_PORTAL_MENU_INT']}</option>" : "<option value='1'>{$user->lang['ACP_PORTAL_MENU_INT']}</option>";
$drop_down_box .= ($links_options[$i] == B3_LINKS_EXT) ? "<option value='2' selected='selected'>{$user->lang['ACP_PORTAL_MENU_EXT']}</option>" : "<option value='2'>{$user->lang['ACP_PORTAL_MENU_EXT']}</option>";
$drop_down_box .= '</select>';
// Define the links
$move_up_link = ($i == 0) ? '<img src="' . $phpbb_admin_path . 'images/icon_up_disabled.gif" alt="' . $user->lang['MOVE_UP'] . '" title="' . $user->lang['MOVE_UP'] . '" />' : '<a href="' . $u_action . '&amp;menu=' . $i . '&amp;menu_action=move_up"><img src="' . $phpbb_admin_path . 'images/icon_up.gif" alt="' . $user->lang['MOVE_UP'] . '" title="' . $user->lang['MOVE_UP'] . '" /></a>';
$move_down_link = ($i >= (sizeof($links_urls) - 1)) ? '<img src="' . $phpbb_admin_path . 'images/icon_down_disabled.gif" alt="' . $user->lang['MOVE_DOWN'] . '" title="' . $user->lang['MOVE_DOWN'] . '" />' : '<a href="' . $u_action . '&amp;menu=' . $i . '&amp;menu_action=move_down"><img src="' . $phpbb_admin_path . 'images/icon_down.gif" alt="' . $user->lang['MOVE_DOWN'] . '" title="' . $user->lang['MOVE_DOWN'] . '" /></a>';
$delete_link = '<a href="' . $u_action . '&amp;menu=' . $i . '&amp;menu_action=delete"><img src="' . $phpbb_admin_path . 'images/icon_delete.gif" alt="' . $user->lang['DELETE'] . '" title="' . $user->lang['DELETE'] . '" /></a>';
// Throw it all together
$table_content .= "<tr><td $table_row><input id='board3_links_title$i' name='board3_links_title$i' type='text' size='16' value='{$links_titles[$i]}' /></td><td $table_row><input id='board3_links$i' name='board3_links$i' type='text' size='32' value='{$links_urls[$i]}' /></td><td $table_row>$drop_down_box</td><td>$move_up_link&nbsp;$move_down_link&nbsp;$delete_link</td></tr>";
}
$return_ary = '';
$return_ary .= $table_begin;
$return_ary .= $table_content;
$return_ary .= $table_end;
//echo $config['board3_links_options']; // remove after testing
return $return_ary;
}
function update_links($key)