Added basic version of main menu that will allow to edit, add and remove

This commit is contained in:
Marc Alexander
2010-09-30 21:35:06 +00:00
parent b3f0f852fa
commit 8e11e32347
3 changed files with 77 additions and 6 deletions

View File

@@ -17,7 +17,7 @@
<form id="acp_portal_links" method="post" action="{U_ACTION}"> <form id="acp_portal_links" method="post" action="{U_ACTION}">
<fieldset> <fieldset>
<legend>{L_ACP_PORTAL_LINKS}</legend> <legend>{L_ACP_PORTAL_MENU_LINK}</legend>
<dl> <dl>
<dt><label for="link_title">{L_LINK_TITLE}:</label></dt> <dt><label for="link_title">{L_LINK_TITLE}:</label></dt>
<dd><input name="link_title" type="text" id="link_title" value="{LINK_TITLE}" maxlength="255" /></dd> <dd><input name="link_title" type="text" id="link_title" value="{LINK_TITLE}" maxlength="255" /></dd>
@@ -30,7 +30,7 @@
<!-- IF S_LINK_IS_CAT --><div id="url" style="display: none;"><!-- ELSE --><div id="url"><!-- ENDIF --> <!-- IF S_LINK_IS_CAT --><div id="url" style="display: none;"><!-- ELSE --><div id="url"><!-- ENDIF -->
<dl> <dl>
<dt> <dt>
<label for="link_tpye">{L_ACP_PORTAL_MENU_TYPE}:</label><br /> <label for="link_type">{L_ACP_PORTAL_MENU_TYPE}:</label><br />
<span>{L_ACP_PORTAL_MENU_TYPE_EXP}</span> <span>{L_ACP_PORTAL_MENU_TYPE_EXP}</span>
</dt> </dt>
<dd> <dd>
@@ -39,11 +39,36 @@
</dd> </dd>
</dl> </dl>
<dl> <dl>
<dt><label for="link_url">{L_LINK_URL}:</label></dt> <dt>
<label for="link_url">{L_ACP_PORTAL_MENU_URL}:</label><br />
<span>{L_ACP_PORTAL_MENU_URL_EXP}</span>
</dt>
<dd><input name="link_url" type="text" id="link_url" value="{LINK_URL}" maxlength="255" /></dd> <dd><input name="link_url" type="text" id="link_url" value="{LINK_URL}" maxlength="255" /></dd>
</dl> </dl>
</div> </div>
</fieldset>
<fieldset>
<legend>{L_ACP_PORTAL_MENU_INT_OPTIONS}</legend>
<dl>
<dt>
<label for="link_query1">{L_ACP_PORTAL_MENU_QUERY1}:</label><br />
<span>{L_ACP_PORTAL_MENU_QUERY1_EXP}</span>
</dt>
<dd><input name="link_query1" type="text" id="link_query1" value="{LINK_QUERY1}" maxlength="255" /></dd><br />
<dt>
<label for="link_query2">{L_ACP_PORTAL_MENU_QUERY2}:</label><br />
<span>{L_ACP_PORTAL_MENU_QUERY2_EXP}</span>
</dt>
<dd><input name="link_query2" type="text" id="link_query2" value="{LINK_QUERY2}" maxlength="255" /></dd><br />
<dt>
<label for="link_query3">{L_ACP_PORTAL_MENU_QUERY3}:</label><br />
<span>{L_ACP_PORTAL_MENU_QUERY3_EXP}</span>
</dt>
<dd><input name="link_query3" type="text" id="link_query3" value="{LINK_QUERY3}" maxlength="255" /></dd>
</dl>
</fieldset>
<fieldset>
<legend>{L_ACP_SUBMIT_CHANGES}</legend>
<p class="submit-buttons"> <p class="submit-buttons">
<input type="hidden" name="action" value="save" /> <input type="hidden" name="action" value="save" />

View File

@@ -49,10 +49,19 @@ $lang = array_merge($lang, array(
'ACP_PORTAL_MENU_INT' => 'Internal link', 'ACP_PORTAL_MENU_INT' => 'Internal link',
'ACP_PORTAL_MENU_EXT' => 'External link', 'ACP_PORTAL_MENU_EXT' => 'External link',
'ACP_PORTAL_MENU_TITLE' => 'Title', 'ACP_PORTAL_MENU_TITLE' => 'Title',
'ACP_PORTAL_MENU_URL' => 'URL', 'ACP_PORTAL_MENU_URL' => 'Link URL',
'ACP_PORTAL_MENU_TYPE' => 'Link type', 'ACP_PORTAL_MENU_TYPE' => 'Link type',
'ACP_PORTAL_MENU_TYPE_EXP' => 'If you have a link to a page of your board, choose "Internal link" in order to prevent unwanted logouts.', 'ACP_PORTAL_MENU_TYPE_EXP' => 'If you have a link to a page of your board, choose "Internal link" in order to prevent unwanted logouts.',
'ACP_PORTAL_MENU_CREATE_CAT' => 'You need to create a category first.', 'ACP_PORTAL_MENU_CREATE_CAT' => 'You need to create a category first.',
'ACP_PORTAL_MENU_URL_EXP' => 'External links:<br />All links should be entered with a http://<br /><br />Internal links:<br />Only enter the php file as link url, i.e. index.php.<br />If you would like to add a query string, then define the values below.<br />If your link is index.php?style=4, then enter index.php as link url and style=4 in the textfield for the first post variable.',
'ACP_PORTAL_MENU_QUERY1' => 'First post variable',
'ACP_PORTAL_MENU_QUERY1_EXP' => 'Enter the first post variable. Example: style=4',
'ACP_PORTAL_MENU_QUERY2' => 'Second post variable',
'ACP_PORTAL_MENU_QUERY2_EXP' => 'Enter the second post variable. Example: style=4',
'ACP_PORTAL_MENU_QUERY3' => 'Third post variable',
'ACP_PORTAL_MENU_QUERY3_EXP' => 'Enter the third post variable. Example: style=4',
'ACP_PORTAL_MENU_LINK' => 'Link settings',
'ACP_PORTAL_MENU_INT_OPTIONS' => 'Internal links options',
)); ));
?> ?>

View File

@@ -79,7 +79,8 @@ class portal_main_menu_module
{ {
if($links_options[$i] == B3_LINKS_INT) if($links_options[$i] == B3_LINKS_INT)
{ {
$cur_url = append_sid($phpbb_root_path . $links_urls[$i]); $links_urls[$i] = str_replace('&', '&amp;', $links_urls[$i]); // we need to do this in order to prevent XHTML validation errors
$cur_url = append_sid($phpbb_root_path . $links_urls[$i]); // the user should know what kind of file it is
} }
else else
{ {
@@ -178,6 +179,41 @@ class portal_main_menu_module
$link_is_cat = request_var('link_is_cat', 0); $link_is_cat = request_var('link_is_cat', 0);
$link_type = (!$link_is_cat) ? request_var('link_type', 0) : B3_LINKS_CAT; $link_type = (!$link_is_cat) ? request_var('link_type', 0) : B3_LINKS_CAT;
$link_url = ($link_is_cat) ? ' ' : request_var('link_url', ' '); $link_url = ($link_is_cat) ? ' ' : request_var('link_url', ' ');
if($link_type == B3_LINKS_INT)
{
$link_query1 = utf8_normalize_nfc(request_var('link_query1', ''));
$link_query2 = utf8_normalize_nfc(request_var('link_query2', ''));
$link_query3 = utf8_normalize_nfc(request_var('link_query3', ''));
$link_query_string = '';
if($link_query1 != '')
{
$link_query_string .= '?' . $link_query1;
if($link_query2 != '')
{
$link_query_string .= '&' . $link_query2;
}
if($link_query3)
{
$link_query_string .= '&' . $link_query3;
}
}
elseif($link_query2 != '')
{
$link_query_string .= '?' . $link_query2;
if($link_query3)
{
$link_query_string .= '&' . $link_query3;
}
}
elseif($link_query3)
{
$link_query_string .= '&' . $link_query3;
}
$link_url .= $link_query_string;
}
if (!$link_title) if (!$link_title)
{ {
@@ -189,6 +225,7 @@ class portal_main_menu_module
trigger_error($user->lang['NO_LINK_URL'] . adm_back_link($u_action), E_USER_WARNING); trigger_error($user->lang['NO_LINK_URL'] . adm_back_link($u_action), E_USER_WARNING);
} }
// overwrite already existing links and make sure we don't try to save a link outside of the normal array size of $links_urls
if (isset($link_id) && $link_id < sizeof($links_urls)) if (isset($link_id) && $link_id < sizeof($links_urls))
{ {
$message = $user->lang['LINK_UPDATED']; $message = $user->lang['LINK_UPDATED'];