Documentation

Languages
in package
implements ActionInterface Uses BackwardCompatibility

This class handles the administration of languages tasks.

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Properties

$subaction  : string
$subactions  : array<string|int, mixed>
$obj  : object
$backcompat  : array<string|int, mixed>

Methods

add()  : void
Interface for adding a new language
addLanguage()  : void
Backward compatibility wrapper for the add sub-action.
call()  : void
Convenience method to load() and execute() an instance of this class.
download()  : void
Download a language file from the Simple Machines website.
downloadLanguage()  : void
Backward compatibility wrapper for the download sub-action.
editEntries()  : mixed
Edit a particular set of language entries.
editLanguages()  : mixed
This lists all the current languages and allows editing of them.
execute()  : void
Dispatcher to whichever sub-action method is necessary.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
getConfigVars()  : array<string|int, mixed>
Gets the configuration variables for the languages area.
list_getLanguages()  : array<string|int, mixed>
Fetch the actual language information.
list_getLanguagesList()  : array<string|int, mixed>
Gets a list of available languages from the mother ship Will return a subset if searching, otherwise all avaialble
list_getNumLanguages()  : int
How many languages? Callback for the list in editLanguages().
load()  : object
Static wrapper for constructor.
modifyLanguage()  : void
Backward compatibility wrapper for the editlang sub-action.
modifyLanguages()  : void
Backward compatibility wrapper for the edit sub-action.
modifyLanguageSettings()  : void|array<string|int, mixed>
Backward compatibility wrapper for the settings sub-action.
settings()  : void|array<string|int, mixed>
Edit language related settings.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
cleanLangString()  : string
This function cleans language entries to/from display.

Properties

$subaction

public string $subaction = 'edit'

The requested sub-action. This should be set by the constructor.

$subactions

public static array<string|int, mixed> $subactions = ['edit' => 'editLanguages', 'add' => 'add', 'settings' => 'settings', 'downloadlang' => 'download', 'editlang' => 'editEntries']

Available sub-actions.

$obj

protected static object $obj

An instance of this class. This is used by the load() method to prevent mulitple instantiations.

$backcompat

private static array<string|int, mixed> $backcompat = ['func_names' => ['call' => 'ManageLanguages', 'list_getLanguagesList' => 'list_getLanguagesList', 'list_getNumLanguages' => 'list_getNumLanguages', 'list_getLanguages' => 'list_getLanguages', 'modifyLanguages' => 'ModifyLanguages', 'addLanguage' => 'AddLanguage', 'modifyLanguageSettings' => 'ModifyLanguageSettings', 'downloadLanguage' => 'DownloadLanguage', 'modifyLanguage' => 'ModifyLanguage']]

BackwardCompatibility settings for this class.

Methods

add()

Interface for adding a new language

public add() : void
Tags
uses
template_add_language()

addLanguage()

Backward compatibility wrapper for the add sub-action.

public static addLanguage() : void

call()

Convenience method to load() and execute() an instance of this class.

public static call() : void

download()

Download a language file from the Simple Machines website.

public download() : void

Requires a valid download ID ("did") in the URL. Also handles installing language files. Attempts to chmod things as needed. Uses a standard list to display information about all the files and where they'll be put.

Tags
uses
template_download_language()

Uses a standard list for displaying languages (@see SMF\ItemList())

downloadLanguage()

Backward compatibility wrapper for the download sub-action.

public static downloadLanguage() : void

editEntries()

Edit a particular set of language entries.

public editEntries() : mixed

editLanguages()

This lists all the current languages and allows editing of them.

public editLanguages() : mixed

execute()

Dispatcher to whichever sub-action method is necessary.

public execute() : void

exportStatic()

Provides a way to export a class's public static properties and methods to global namespace.

public static exportStatic() : void

To do so:

  1. Use this trait in the class.
  2. At the END of the class's file, call its exportStatic() method.

Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.

Regarding the $backcompat items:

A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].

$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.

$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.

Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.

getConfigVars()

Gets the configuration variables for the languages area.

public static getConfigVars() : array<string|int, mixed>
Return values
array<string|int, mixed>

$config_vars for the languages area.

list_getLanguages()

Fetch the actual language information.

public static list_getLanguages() : array<string|int, mixed>

Callback for $listOptions['get_items']['function'] in editLanguages. Determines which languages are available by looking for the "index.{language}.php" file. Also figures out how many users are using a particular language.

Return values
array<string|int, mixed>

An array of information about currenty installed languages

list_getLanguagesList()

Gets a list of available languages from the mother ship Will return a subset if searching, otherwise all avaialble

public static list_getLanguagesList() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array containing information about each available language

list_getNumLanguages()

How many languages? Callback for the list in editLanguages().

public static list_getNumLanguages() : int
Return values
int

The number of available languages

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

modifyLanguage()

Backward compatibility wrapper for the editlang sub-action.

public static modifyLanguage() : void

modifyLanguages()

Backward compatibility wrapper for the edit sub-action.

public static modifyLanguages() : void

modifyLanguageSettings()

Backward compatibility wrapper for the settings sub-action.

public static modifyLanguageSettings([bool $return_config = false ]) : void|array<string|int, mixed>
Parameters
$return_config : bool = false

Whether to return the config_vars array.

Return values
void|array<string|int, mixed>

Returns nothing or returns the config_vars array.

settings()

Edit language related settings.

public settings([bool $return_config = false ]) : void|array<string|int, mixed>
Parameters
$return_config : bool = false

Whether to return the $config_vars array (used in admin search)

Return values
void|array<string|int, mixed>

Returns nothing or the $config_vars array if $return_config is true

__construct()

Constructor. Protected to force instantiation via self::load().

protected __construct() : mixed

cleanLangString()

This function cleans language entries to/from display.

protected cleanLangString(string $string[, bool $to_display = true ]) : string
Parameters
$string : string

The language string

$to_display : bool = true

Whether or not this is going to be displayed

Tags
todo

This function could be two functions?

Return values
string

The cleaned string


        
On this page

Search results