Inside Mod Manager v12 Main

From TNG_Wiki
Jump to: navigation, search

Main Mod Manager Script

Admin_modhandler.php is the main control script for Mod Manager v12. It displays the mod listing and handles requests from the listing to install and remove mods using the appropriate Mod Manager objects.

Each time the script is called it sets up the header, horizontal tabs and inner menu links. Then it includes classes/modobjinits.php to provide standard initialization values.

Initialize Mod Manager Objects

Each Mod Manager object must be initialized with data when it is instantiated. Data includes Mod Manager user options, TNG configuration settings, language support, etc. To ensure all objects have the same data, the $objinits array is defined in classes/modobjinits.php which admin_modhandler.php includes after all the data is available to it and before it instantiates an object.

$objinits = array (
   'rootpath'     => $rootpath,
   'subroot'      => $subroot,
   'modspath'     => $modspath,
   'extspath'     => $extspath,
   'options'      => $options,
   'time_offset'  => $time_offset,
   'sitever'      => $sitever,
   'currentuserdesc' => $mhuser,
   'admtext'      => $admtext,
   'templatenum'  => $templatenum,
   'tng_version'  => $tng_version
);

Display The Mod Listing

The first time it is called, admin_modhandler.php includes classes/modlister.class.php and creates a new Modlister object to display the Mod Manager v12 Listing using the site's current template.

$oModlist = new modlister( $objinits );
$oModlist->filter = $filter;
$oModlist->fbox_checked = $fbox_checked;
$oModlist->modlist = $modlist;
//$oModlist->templatenum = $templatenum;
$oModlist->list_mods();

The first statement creates a new Modlister object initialized with $objinits.

The next few statements provide data to the Modlister object:

  • $filter contains a list of filtered mod file names stored in the sessions when the "Lock" checkbox is checked to allow the listing to remember which mods are displayed between operations on a mod in the list.
  • $fbox_checked reminds Modlister if this box should be checked.
  • $templatenum sets the template for the listing. This is redundant and should be removed since the template number is passed in the $objinits array.
  • $modlist is a list of mods, which if not empty, will be listed instead of all the mods in the mods directory or a filtered subset thereof.

Finally, the object's list_mods() function is invoked to create the listing.

Install a Mod

If the user clicks an Install button in the mod listing, the command is sent back to this script via a query line: admin_modhandler.php?a=1&m=modfilepath for execution. INSTALL is defined as 1, thus a=1.

Admin_modhandler.php includes classes/modinstaller.class.php, instantiates a Modinstaller object and invokes its install() function:

$obj = new modinstaller($objinits);
$obj->install($cfgpath);

$cfgpath is the path to a mod config file.

After installation Modinstaller returns control here unless there is an error and the option $options['redirect2log'] is set, in which case control is passed to admin_showmodslog.php.

Remove a Mod

If the user clicks a Remove button in the mod listing, the command is sent back to this script via a query line: admin_modhandler.php?a=2&m=modfilepath for execution. REMOVE is defined as 2, thus a=2.

Admin_modhandler.php includes classes/modremover.class.php, instantiates a Modremover object and invokes its remove() function:

$obj = new modremover($objinits);
$obj->remove($cfgpath);

$cfgpath is the path to a mod config file.

After removal Modremover returns control here unless there is an error and the option $options['redirect2log'] is set, in which case control is passed to admin_showmodslog.php.

Cleanup a Mod

Modremover is used for this operation. Cleaning up a mod is a matter of uninstalling all installed components. Modremover does not complain if it finds component is not installed; it just moves on to the next component. The result is that all installed components are removed if possible, ideally leaving the mod OK to install.

If the user clicks a Clean Up button in the mod listing, the command is sent back to this script via a query line: admin_modhandler.php?a=4&m=modfilepath for execution. CLEANUP is defined as 4, thus a=4.

Admin_modhandler.php includes classes/modremover.class.php, instantiates a Modremover object and invokes its remove() function:

$obj = new modremover($objinits);
$obj->remove($cfgpath);

$cfgpath is the path to a mod config file.

After removal Modremover returns control here unless there is an error and the option $options['redirect2log'] is set, in which case control is passed to admin_showmodslog.php.

Delete a Mod

If the user clicks a Delete button in the mod listing, the command is sent back to this script via a query line: admin_modhandler.php?a=3&m=modfilepath for execution. DELETE is defined as 3, thus a=3.

Admin_modhandler.php includes classes/moddeletrer.class.php, instantiates a Moddeleter object and invokes its delete_mod() function:

$obj = new moddeleter($objinits);
$obj->delete_mod($cfgpath);

$cfgpath is the path to a mod config file.

If the user option $options['delete_support'] is set, Moddeleter will delete the associated support folder if there is one.

After deletion, Moddeleter returns control here unless there is an error and the option $options['redirect2log'] is set, in which case control is passed to admin_showmodslog.php.

Batch Install Mods

If a user selects a group of files from a filtered list and clicks on Install, a list of selected mods ($mods) is $_POSTed back to Admin_modhandler.php.

This script includes classes/modinstaller.class.php, instantiates a modinstaller object and invokes its batch_install() function.

$oInstaller = new modinstaller($objinits);
$oInstaller->batch_install($modlist);

$modlist is a list of selected mods $_POSTed back here by Modlister.

After installation Modinstaller returns control here unless there is an error and the option $options['redirect2log'] is set, in which case control is passed to admin_showmodslog.php.

Batch Remove Mods

If a user selects a group of files from a filtered list and clicks on Remove, a list of selected mods ($mods) is $_POSTed back to Admin_modhandler.php.

This script includes classes/modremover.class.php, instantiates a Modremover object and invokes its batch_remove() function.

$oRemover = new modremover($objinits);
$oRemover->batch_remove($modlist);

$modlist is a list of selected mods $_POSTed back here by Modlister.

After removal Modremover returns control here unless there is an error and the option $options['redirect2log'] is set, in which case control is passed to admin_showmodslog.php.

Batch Clean Up Mods

If a user selects a group of files from a filtered list and clicks on Clean Up, a list of selected mods ($mods) is $_POSTed back to Admin_modhandler.php, which instantiates a Modremover object and runs its $obj->batch_remove() function on the list.

This function loops through the list and calls the object's remove() function for each mod one at a time.

Functions

This script uses two functions to build the Mod Manager page Heading:

set_horizontal_tabs()
set_innermenu_links()

See Inside Mod Manager v12 Page Headings for more information on these functions.


jQuery Routines

Includes jQuery script at the bottom of the page to do the following:

  • Position the status (filter) bar tightly underneath the Mod Manager header if the $options['adjust_headers'] option is set
  • Position the listing tightly underneath the status (filter) bar if the $options['adjust_headers'] option is set
  • Toggle the mod status panel from other fields on the mod listing line
  • Toggle the mod status panel from the status bar
  • Open/close all mod lines at once
  • Handle the Select All and Clear All buttons on filtered mod listings
  • Handle confirmation for Delete button
  • Handle "Nothing selected" alert on filtered mod listings
  • When the "Lock" checkbox on the filter line is checked, send filter list containing currently displayed mods to ajax_filter.php to store in the session. When the "Lock" box is unchecked, send a code to ajax_filter.php to unset the session filter list. This allows the filtered mod listing to remember the filtered items after performing an operation on one of the mods when the "Lock" box is checked.

Inside Mod Manager v12 Directory

Chapters

Inside Mod Manager v12 (Home)

  1. Mod Manager and OOP
  2. Page Headings
  3. Main Script
  4. Class Modbase
  5. Class Modparser
  6. Class Modlister
  7. Class Modinstaller
  8. Class Modeditor
  9. Class Modremover
  10. Class Moddeleter
  11. Formulas
  12. Mod Options
  13. Mod Logging
  14. Tools
  15. Issues