Skip to main content
Topic: Placement of ManageLanguages.controller.php for custom theme (Read 2574 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Placement of ManageLanguages.controller.php for custom theme

I made a few edits to sources/admin/ManageLanguages.controller.php to satisfy a custom theme I am working on. I placed the edited file in the theme root directory and changes did not appear. Of course if left in the sources/admin directory the changes are visible.

How do I get around leaving the edited ManageLanguages.controller.php file in sources/admin? I would like to leave it in the theme directory if it is possible.

thanks

Re: Placement of ManageLanguages.controller.php for custom theme

Reply #1

Not really understanding what you're asking but what changes did you need to make? If it can be done using the event system you future proof your mod and make it more likely to install.

Re: Placement of ManageLanguages.controller.php for custom theme

Reply #2

Hello Joshua,

I added 'class' => 'centertext' to 5 or so lines so the title and text in the Languages>Edit Languages would center properly. Well, properly in my mind anyway.

Not sure about the event system you are talking about. 

Thanks

Re: Placement of ManageLanguages.controller.php for custom theme

Reply #3

Can you post the file or tell me which lines or what function(s)? There are a bunch of hooks that will make that possible without needing to actually edit the files. Then in your package, you'd add those hooks.

Are you editing any other files (besides theme files)?

Re: Placement of ManageLanguages.controller.php for custom theme

Reply #4

I have the feeling createList (or actually the class equivalent), should not allow to specify class names. It should generate "standard" class names and assign them to the columns (rows should be easy to target with css), so the it is not necessary to do what Lou is trying to do, it will be enough to add some css code with proper selectors.

ETA: BTW, Lou, what you are trying to do may be possible with some trick, I'd have to check the code you changed. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: Placement of ManageLanguages.controller.php for custom theme

Reply #5

Code: [Select]
    /**
     * This lists all the current languages and allows editing of them.
     */
    public function action_edit()
    {
        global $txt, $context, $scripturl, $language;

        require_once(SUBSDIR . '/Language.subs.php');

        // Setting a new default?
        if (!empty($_POST['set_default']) && !empty($_POST['def_language']))
        {
            checkSession();
            validateToken('admin-lang');

            $lang_exists = false;
            $available_langs = getLanguages();
            foreach ($available_langs as $lang)
            {
                if ($_POST['def_language'] == $lang['filename'])
                {
                    $lang_exists = true;
                    break;
                }
            }

            if ($_POST['def_language'] != $language && $lang_exists)
            {
                require_once(SUBSDIR . '/SettingsForm.class.php');
                Settings_Form::save_file(array('language' => '\'' . $_POST['def_language'] . '\''));
                $language = $_POST['def_language'];
            }
        }

        // Create another one time token here.
        createToken('admin-lang');

        $listOptions = array(
            'id' => 'language_list',
            'items_per_page' => 20,
            'base_href' => $scripturl . '?action=admin;area=languages',
            'title' => $txt['edit_languages'],
            'data_check' => array(
                'class' => create_function('$rowData', '
                    if ($rowData[\'default\'])
                        return \'highlight2\';
                    else
                        return \'\';
                ')
            ),
            'get_items' => array(
                'function' => 'list_getLanguages',
            ),
            'get_count' => array(
                'function' => 'list_getNumLanguages',
            ),
            'columns' => array(
                'default' => array(
                    'header' => array(
                        'value' => $txt['languages_default'],
                        'class' => 'centertext',
                    ),
                    'data' => array(
                        'function' => create_function('$rowData', '
                            return \'<input type="radio" name="def_language" value="\' . $rowData[\'id\'] . \'" \' . ($rowData[\'default\'] ? \'checked="checked"\' : \'\') . \' class="input_radio" />\';
                        '),
                        'style' => 'width: 8%;',
                        'class' => 'centertext',
                    ),
                ),
                'name' => array(
                    'header' => array(
                        'value' => $txt['languages_lang_name'],
                        'class' => 'centertext',
                    ),
                    'data' => array(
                        'class' => 'centertext',
                        'function' => create_function('$rowData', '
                            global $scripturl;
                            return sprintf(\'<a href="%1$s?action=admin;area=languages;sa=editlang;lid=%2$s">%3$s</a>\', $scripturl, $rowData[\'id\'], $rowData[\'name\']);
                        '),
                    ),
                ),
                'count' => array(
                    'header' => array(
                        'value' => $txt['languages_users'],
                        'class' => 'centertext',
                    ),
                    'data' => array(
                        'db_htmlsafe' => 'count',
                        'class' => 'centertext',
                    ),
                ),
                'locale' => array(
                    'header' => array(
                        'value' => $txt['languages_locale'],
                        'class' => 'centertext',
                    ),
                    'data' => array(
                        'db_htmlsafe' => 'locale',
                        'class' => 'centertext',
                    ),
                ),
            ),
            'form' => array(
                'href' => $scripturl . '?action=admin;area=languages',
                'token' => 'admin-lang',
            ),
            'additional_rows' => array(
                array(
                    'position' => 'bottom_of_list',
                    'value' => '
                        <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
                        <input type="submit" name="set_default" value="' . $txt['save'] . '"' . (is_writable(BOARDDIR . '/Settings.php') ? '' : ' disabled="disabled"') . ' class="right_submit" />',
                ),
            ),
            // For highlighting the default.
            'javascript' => '
                initHighlightSelection(\'language_list\');
            ',
        );

        // Display a warning if we cannot edit the default setting.
        if (!is_writable(BOARDDIR . '/Settings.php'))
            $listOptions['additional_rows'][] = array(
                'position' => 'after_title',
                'value' => $txt['language_settings_writable'],
                'class' => 'smalltext alert',
            );

        require_once(SUBSDIR . '/GenericList.class.php');
        createList($listOptions);

        $context['sub_template'] = 'show_list';
        $context['default_list'] = 'language_list';
    }

This is the only function in ManageLanguages.controller.php that I edited. Only added the 'class' => 'centertext' . 

Also edited PackageServers.template.php and ProfileInfo.template.php but they are in the theme directory already. No idea about hooks to be honest. But I do appreciate the help and the lesson. 

thanks


Re: Placement of ManageLanguages.controller.php for custom theme

Reply #6

Quote from: emanuele – I have the feeling createList (or actually the class equivalent), should not allow to specify class names. It should generate "standard" class names and assign them to the columns (rows should be easy to target with css), so the it is not necessary to do what Lou is trying to do, it will be enough to add some css code with proper selectors.

ETA: BTW, Lou, what you are trying to do may be possible with some trick, I'd have to check the code you changed. ;)
Here is an image. Just center aligned the text.


Re: Placement of ManageLanguages.controller.php for custom theme

Reply #7

I think you could use #wrapper_language_list to do that with some simple CSS.

Alternatively, the hook is 'integrate_list_language_list'. I don't know if we have a tutorial on how to use hooks. Would be good.

Re: Placement of ManageLanguages.controller.php for custom theme

Reply #8

Hi Joshua,

Thank you for the reply. I will give your suggestion a go and see how it turns out.  :)


 

Re: Placement of ManageLanguages.controller.php for custom theme

Reply #9

Yep, I forgot about that!
Code: [Select]
#language_list .standard_row td:nth-child(n+1) {
text-align: center;
}

or just:
Code: [Select]
#language_list .standard_row td {
text-align: center;
}
Bugs creator.
Features destroyer.
Template killer.