POST to Language

Discussion forum for MOD Writers regarding MOD Development.
Locked
cheechm
Registered User
Posts: 69
Joined: Mon Jan 15, 2007 10:28 pm

POST to Language

Post by cheechm » Fri Apr 18, 2008 9:11 pm

I am trying to make all customised language files accessible from an easy page. What is going wrong with the code? Do I need to include directories or something?

Code: Select all

<!-- BEGIN language -->	<!-- IF language.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
		<td style="text-align: center;">{language.FILE}</td>
		<td style="text-align: center;"><form method="post" action="index.php?i=language&sid=b129bfaa6fa51526a31b230ecdfc451b&mode=lang_packs&action=details&id=1#entries">
		<input type="hidden" name="language_file" id="language_file" value="{language.FILE}" />
		
<input type="image" name="submit" src="images/icon_edit.gif" border="0" /></form></td>
	<!-- END language -->
{language.FILE} = something like "site_index" (with no .php)
location: language/en/mods/

The form throws "Form invalid error"

How can I open that file in the language editor.

Thanks

cheechm
Registered User
Posts: 69
Joined: Mon Jan 15, 2007 10:28 pm

Re: POST to Language

Post by cheechm » Sat Apr 19, 2008 11:13 am

?
Thanks

User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Re: POST to Language

Post by A_Jelly_Doughnut » Sun Apr 20, 2008 12:39 am

You need to include an {S_FORM_KEY} element in your form.

You should also remove the session ID from your form action.
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish

cheechm
Registered User
Posts: 69
Joined: Mon Jan 15, 2007 10:28 pm

Re: POST to Language

Post by cheechm » Sun Apr 20, 2008 9:25 pm

How do I include the sid in the link?
Do I need to use the append_sid() function in the .php file?

cheechm
Registered User
Posts: 69
Joined: Mon Jan 15, 2007 10:28 pm

Re: POST to Language

Post by cheechm » Sun Apr 20, 2008 9:51 pm

I've appended the sid, and added

Code: Select all

		{S_FORM_KEY}
	{S_FORM_TOKEN}
at the end of my form as well as

Code: Select all

		$form_name = 'acp_sitelanguage';
		add_form_key($form_name);
in the function file.

I get

Selected language file is invalid.

cheechm
Registered User
Posts: 69
Joined: Mon Jan 15, 2007 10:28 pm

Re: POST to Language

Post by cheechm » Mon Apr 21, 2008 7:41 am

Bump? Am I "POSTing" the wrong thing?

cheechm
Registered User
Posts: 69
Joined: Mon Jan 15, 2007 10:28 pm

Re: POST to Language

Post by cheechm » Mon Apr 21, 2008 4:16 pm

Any help here?

User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Re: POST to Language

Post by A_Jelly_Doughnut » Mon Apr 21, 2008 8:01 pm

What file are you modifying? What PHP code have you changed?
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish

cheechm
Registered User
Posts: 69
Joined: Mon Jan 15, 2007 10:28 pm

Re: POST to Language

Post by cheechm » Mon Apr 21, 2008 8:36 pm

I am editing my module files:
Now have this:
functions file:

Code: Select all

<?php
/**
 *
 * @package acp
 * @author Nick Rhodes
 * @copyright 2008
 *
 */

/**
 * @package acp
 */
class acp_sitelanguage
{
    var $u_action;

    function main()
    {
        global $db, $user, $auth, $template;
        global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;

        $user->add_lang('mods/sitelanguage');

        // Set up the page
        $this->tpl_name = 'acp_sitelanguage';
        $this->page_title = 'ACP_SITELANGUAGE';

		$form_name = 'acp_sitelanguage';
		add_form_key($form_name);
        // Set up general vars
        $action = request_var('dir', '');

        if (!$action)
        {
            // directory path can be either absolute or relative
            $dirPath = '/home/niick/public_html/qw/forum/language/en/mods/';

            // open the specified directory and check if it's opened successfully
            if ($handle = opendir($dirPath))
            {

                // keep reading the directory entries 'til the end
                while (false !== ($file = readdir($handle)))
                {

                    // just skip the reference to current and parent directory
                    if ($file != "." && $file != "..")
                    {
$lang = substr($file, 0, strrpos($file, '.'));
                        $template->assign_block_vars('language', array('FILE' => $lang));
                          $template->assign_vars(array('LINK' => append_sid("{$phpbb_root_path}/adm/index.$phpEx?i=language&mode=lang_packs&action=details&id=1#entries")));


                    }
                }


                // Close what we opened
                closedir($handle);
            }

        }
    }

}
?>
html file:

Code: Select all

<!-- INCLUDE overall_header.html -->

	<h1>{L_ACP_NEWS_MANAGE}</h1>

	<p>{L_ACP_NEWS_EXPLAIN}</p>

	<form id="acp_sitelanguage" method="post" action="{U_ACTION}">
	<fieldset class="tabulated">
	<legend>{L_ACP_NEWS_MANAGE}</legend>

	<table cellspacing="1">
	<thead>
	<tr>	
		<th>Contents</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	
	
<!-- BEGIN language -->	<!-- IF language.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
		<td style="text-align: center;">{language.FILE}</td>
		<td style="text-align: center;"><form method="post" action="{LINK}">
		<input type="hidden" name="language_file" id="language_file" value="{language.FILE}." />
		
<input type="image" name="submit" src="images/icon_edit.gif" border="0" />
	{S_FORM_TOKEN}
</form></td>
	<!-- END language -->
	</tr>
	</tbody>
	</table>
<!-- INCLUDE overall_footer.html -->
This is the bit I am not sure about:

Code: Select all

		<input type="hidden" name="language_file" id="language_file" value="{language.FILE}." />
{language.FILE} would be something like "news"
So I then post "news."
The directory of that is phpbb root/language/en/mods
When I get to the language page, it says Language file invalid.
Thanks

cheechm
Registered User
Posts: 69
Joined: Mon Jan 15, 2007 10:28 pm

Re: POST to Language

Post by cheechm » Tue Apr 22, 2008 3:49 pm

Bump..

cheechm
Registered User
Posts: 69
Joined: Mon Jan 15, 2007 10:28 pm

Re: POST to Language

Post by cheechm » Tue Apr 22, 2008 7:49 pm

Fixed.

Needed to be:

Code: Select all

		<input type="hidden" name="language_file" id="language_file" value="mods|{language.FILE}.php" />

Locked

Return to “[3.0.x] MOD Writers Discussion”