Documentation

News extends ACP
in package
implements ActionInterface Uses BackwardCompatibility

This class manages... the news. :P

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Properties

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

Methods

adminLogin()  : mixed
Question the verity of the admin by asking for his or her password.
call()  : void
Convenience method to load() and execute() an instance of this class.
compose()  : void
Shows a form to edit a forum mailing and its recipients.
composeMailing()  : void
Backward compatibility wrapper for the mailingcompose sub-action.
edit()  : void
Let the administrator(s) edit the news items for the forum.
editNews()  : void
Backward compatibility wrapper for the edit sub-action.
emailAdmins()  : mixed
Send all the administrators a lovely email.
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 this admin area.
getFileVersions()  : array<string|int, mixed>
Search through source, theme, and language files to determine their version.
getServerVersions()  : array<string|int, mixed>
Get a list of versions that are currently installed on the server.
list_getNews()  : array<string|int, mixed>
Prepares an array of the forum news items for display in the template
list_getNewsCheckbox()  : string
Callback to prepare HTML for the checkboxes in the news editing form.
list_getNewsPreview()  : string
Callback to prepare HTML for the previews in the news editing form.
list_getNewsTextarea()  : string
Callback to prepare HTML for the input fields in the news editing form.
load()  : object
Static wrapper for constructor.
modifyNewsSettings()  : void|array<string|int, mixed>
Backward compatibility wrapper for the settings sub-action.
prepareDBSettingContext()  : void
Helper function, it sets up the context for database settings.
prepareMailingForPreview()  : void
Prepare subject and message of an email for the preview box Used in ComposeMailing and RetrievePreview (XmlHttp.php)
saveDBSettings()  : mixed
Helper function for saving database settings.
saveSettings()  : void
Helper function. Saves settings by putting them in Settings.php or saving them in the settings table.
selectMailingMembers()  : void
Backward compatibility wrapper for the mailingmembers sub-action.
selectMembers()  : void
Allows the user to select the membergroups to send their mailing to.
send()  : void
Handles the sending of the forum mailing in batches.
sendMailing()  : void
Backward compatibility wrapper for the mailingsend sub-action.
settings()  : void
Set general news and newsletter settings and permissions.
updateAdminPreferences()  : mixed
Saves the admin's current preferences to the database.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
adminLogin_outputPostVars()  : string
Used by the adminLogin() method.
construct_query_string()  : string
Properly urlencodes a string to be used in a query.
setAdminAreas()  : void
Sets any dynamic values in $this->admin_areas.
setDynamicStrings()  : void
Sets any dynamic string values in the passed array.
setListOptions()  : void
Sets dynamic values in $this->list_options.

Properties

$admin_areas

public array<string|int, mixed> $admin_areas = ['forum' => ['title' => 'admin_main', 'permission' => ['admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'], 'areas' => ['index' => ['label' => 'admin_center', 'function' => __NAMESPACE__ . '\\Home::call', 'icon' => 'administration'], 'credits' => ['label' => 'support_credits_title', 'function' => __NAMESPACE__ . '\\Home::call', 'icon' => 'support'], 'news' => ['label' => 'news_title', 'function' => __NAMESPACE__ . '\\News::call', 'icon' => 'news', 'permission' => ['edit_news', 'send_mail', 'admin_forum'], 'subsections' => ['editnews' => ['label' => 'admin_edit_news', 'permission' => 'edit_news'], 'mailingmembers' => ['label' => 'admin_newsletters', 'permission' => 'send_mail'], 'settings' => ['label' => 'settings', 'permission' => 'admin_forum']]], 'packages' => ['label' => 'package', 'function' => 'SMF\\PackageManager\\PackageManager::call', 'permission' => ['admin_forum'], 'icon' => 'packages', 'subsections' => ['browse' => ['label' => 'browse_packages'], 'packageget' => ['label' => 'download_packages', 'url' => '{scripturl}?action=admin;area=packages;sa=packageget;get'], 'perms' => ['label' => 'package_file_perms'], 'options' => ['label' => 'package_settings']]], 'search' => ['function' => __NAMESPACE__ . '\\Find::call', 'permission' => ['admin_forum'], 'select' => 'index'], 'adminlogoff' => ['label' => 'admin_logoff', 'function' => __NAMESPACE__ . '\\EndSession::call', 'enabled' => true, 'icon' => 'exit']]], 'config' => ['title' => 'admin_config', 'permission' => ['admin_forum'], 'areas' => ['featuresettings' => ['label' => 'modSettings_title', 'function' => __NAMESPACE__ . '\\Features::call', 'icon' => 'features', 'subsections' => ['basic' => ['label' => 'mods_cat_features'], 'bbc' => ['label' => 'manageposts_bbc_settings'], 'layout' => ['label' => 'mods_cat_layout'], 'sig' => ['label' => 'signature_settings_short'], 'profile' => ['label' => 'custom_profile_shorttitle'], 'likes' => ['label' => 'likes'], 'mentions' => ['label' => 'mentions'], 'alerts' => ['label' => 'notifications']]], 'antispam' => ['label' => 'antispam_title', 'function' => __NAMESPACE__ . '\\AntiSpam::call', 'icon' => 'security'], 'languages' => ['label' => 'language_configuration', 'function' => __NAMESPACE__ . '\\Languages::call', 'icon' => 'languages', 'subsections' => ['edit' => ['label' => 'language_edit'], 'add' => ['label' => 'language_add'], 'settings' => ['label' => 'language_settings']]], 'current_theme' => ['label' => 'theme_current_settings', 'function' => __NAMESPACE__ . '\\Themes::call', 'custom_url' => '{scripturl}?action=admin;area=theme;sa=list;th=%1$d', 'icon' => 'current_theme'], 'theme' => ['label' => 'theme_admin', 'function' => __NAMESPACE__ . '\\Themes::call', 'custom_url' => '{scripturl}?action=admin;area=theme', 'icon' => 'themes', 'subsections' => ['admin' => ['label' => 'themeadmin_admin_title'], 'list' => ['label' => 'themeadmin_list_title'], 'reset' => ['label' => 'themeadmin_reset_title'], 'edit' => ['label' => 'themeadmin_edit_title']]], 'modsettings' => ['label' => 'admin_modifications', 'function' => __NAMESPACE__ . '\\Mods::call', 'icon' => 'modifications', 'subsections' => [ // MOD AUTHORS: If your mod has just a few simple // settings and doesn't need its own settings page, you // can use the integrate_general_mod_settings hook to // add them to the 'general' page. 'general' => ['label' => 'mods_cat_modifications_misc'], ]]]], 'layout' => ['title' => 'layout_controls', 'permission' => ['manage_boards', 'admin_forum', 'manage_smileys', 'manage_attachments', 'moderate_forum'], 'areas' => ['manageboards' => ['label' => 'admin_boards', 'function' => __NAMESPACE__ . '\\Boards::call', 'icon' => 'boards', 'permission' => ['manage_boards'], 'subsections' => ['main' => ['label' => 'boards_edit'], 'newcat' => ['label' => 'mboards_new_cat'], 'settings' => ['label' => 'settings', 'admin_forum']]], 'postsettings' => ['label' => 'manageposts', 'function' => __NAMESPACE__ . '\\Posts::call', 'permission' => ['admin_forum'], 'icon' => 'posts', 'subsections' => ['posts' => ['label' => 'manageposts_settings'], 'censor' => ['label' => 'admin_censored_words'], 'topics' => ['label' => 'manageposts_topic_settings'], 'drafts' => ['label' => 'manage_drafts']]], 'managecalendar' => ['label' => 'manage_calendar', 'function' => __NAMESPACE__ . '\\Calendar::call', 'icon' => 'calendar', 'permission' => ['admin_forum'], 'inactive' => false, 'subsections' => ['holidays' => ['label' => 'manage_holidays', 'permission' => 'admin_forum'], 'settings' => ['label' => 'calendar_settings', 'permission' => 'admin_forum']]], 'managesearch' => ['label' => 'manage_search', 'function' => __NAMESPACE__ . '\\Search::call', 'icon' => 'search', 'permission' => ['admin_forum'], 'subsections' => ['weights' => ['label' => 'search_weights'], 'method' => ['label' => 'search_method'], 'settings' => ['label' => 'settings']]], 'smileys' => ['label' => 'smileys_manage', 'function' => __NAMESPACE__ . '\\Smileys::call', 'icon' => 'smiley', 'permission' => ['manage_smileys'], 'subsections' => ['editsets' => ['label' => 'smiley_sets'], 'addsmiley' => ['label' => 'smileys_add', 'enabled' => true], 'editsmileys' => ['label' => 'smileys_edit', 'enabled' => true], 'setorder' => ['label' => 'smileys_set_order', 'enabled' => true], 'editicons' => ['label' => 'icons_edit_message_icons', 'enabled' => true], 'settings' => ['label' => 'settings']]], 'manageattachments' => ['label' => 'attachments_avatars', 'function' => __NAMESPACE__ . '\\Attachments::call', 'icon' => 'attachment', 'permission' => ['manage_attachments'], 'subsections' => ['browse' => ['label' => 'attachment_manager_browse'], 'attachments' => ['label' => 'attachment_manager_settings'], 'avatars' => ['label' => 'attachment_manager_avatar_settings'], 'attachpaths' => ['label' => 'attach_directories'], 'maintenance' => ['label' => 'attachment_manager_maintenance']]], 'sengines' => ['label' => 'search_engines', 'inactive' => false, 'function' => __NAMESPACE__ . '\\SearchEngines::call', 'icon' => 'engines', 'permission' => 'admin_forum', 'subsections' => ['stats' => ['label' => 'spider_stats'], 'logs' => ['label' => 'spider_logs'], 'spiders' => ['label' => 'spiders'], 'settings' => ['label' => 'settings']]]]], 'members' => ['title' => 'admin_manage_members', 'permission' => ['moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum'], 'areas' => ['viewmembers' => ['label' => 'admin_users', 'function' => __NAMESPACE__ . '\\Members::call', 'icon' => 'members', 'permission' => ['moderate_forum'], 'subsections' => ['all' => ['label' => 'view_all_members'], 'search' => ['label' => 'mlist_search']]], 'membergroups' => ['label' => 'admin_groups', 'function' => __NAMESPACE__ . '\\Membergroups::call', 'icon' => 'membergroups', 'permission' => ['manage_membergroups'], 'subsections' => ['index' => ['label' => 'membergroups_edit_groups', 'permission' => 'manage_membergroups'], 'add' => ['label' => 'membergroups_new_group', 'permission' => 'manage_membergroups'], 'settings' => ['label' => 'settings', 'permission' => 'admin_forum']]], 'permissions' => ['label' => 'edit_permissions', 'function' => __NAMESPACE__ . '\\Permissions::call', 'icon' => 'permissions', 'permission' => ['manage_permissions'], 'subsections' => ['index' => ['label' => 'permissions_groups', 'permission' => 'manage_permissions'], 'board' => ['label' => 'permissions_boards', 'permission' => 'manage_permissions'], 'profiles' => ['label' => 'permissions_profiles', 'permission' => 'manage_permissions'], 'postmod' => ['label' => 'permissions_post_moderation', 'permission' => 'manage_permissions'], 'settings' => ['label' => 'settings', 'permission' => 'admin_forum']]], 'regcenter' => ['label' => 'registration_center', 'function' => __NAMESPACE__ . '\\Registration::call', 'icon' => 'regcenter', 'permission' => ['admin_forum', 'moderate_forum'], 'subsections' => ['register' => ['label' => 'admin_browse_register_new', 'permission' => 'moderate_forum'], 'agreement' => ['label' => 'registration_agreement', 'permission' => 'admin_forum'], 'policy' => ['label' => 'privacy_policy', 'permission' => 'admin_forum'], 'reservednames' => ['label' => 'admin_reserved_set', 'permission' => 'admin_forum'], 'settings' => ['label' => 'settings', 'permission' => 'admin_forum']]], 'warnings' => ['label' => 'warnings', 'function' => __NAMESPACE__ . '\\Warnings::call', 'icon' => 'warning', 'inactive' => false, 'permission' => ['admin_forum']], 'ban' => ['label' => 'ban_title', 'function' => __NAMESPACE__ . '\\Bans::call', 'icon' => 'ban', 'permission' => 'manage_bans', 'subsections' => ['list' => ['label' => 'ban_edit_list'], 'add' => ['label' => 'ban_add_new'], 'browse' => ['label' => 'ban_trigger_browse'], 'log' => ['label' => 'ban_log']]], 'paidsubscribe' => ['label' => 'paid_subscriptions', 'inactive' => false, 'function' => __NAMESPACE__ . '\\Subscriptions::call', 'icon' => 'paid', 'permission' => 'admin_forum', 'subsections' => ['view' => ['label' => 'paid_subs_view'], 'settings' => ['label' => 'settings']]]]], 'maintenance' => ['title' => 'admin_maintenance', 'permission' => ['admin_forum'], 'areas' => ['serversettings' => ['label' => 'admin_server_settings', 'function' => __NAMESPACE__ . '\\Server::call', 'icon' => 'server', 'subsections' => ['general' => ['label' => 'general_settings'], 'database' => ['label' => 'database_settings'], 'cookie' => ['label' => 'cookies_sessions_settings'], 'security' => ['label' => 'security_settings'], 'cache' => ['label' => 'caching_settings'], 'export' => ['label' => 'export_settings'], 'loads' => ['label' => 'load_balancing_settings'], 'phpinfo' => ['label' => 'phpinfo_settings']]], 'maintain' => ['label' => 'maintain_title', 'function' => __NAMESPACE__ . '\\Maintenance::call', 'icon' => 'maintain', 'subsections' => ['routine' => ['label' => 'maintain_sub_routine', 'permission' => 'admin_forum'], 'database' => ['label' => 'maintain_sub_database', 'permission' => 'admin_forum'], 'members' => ['label' => 'maintain_sub_members', 'permission' => 'admin_forum'], 'topics' => ['label' => 'maintain_sub_topics', 'permission' => 'admin_forum'], 'hooks' => ['label' => 'hooks_title_list', 'permission' => 'admin_forum']]], 'scheduledtasks' => ['label' => 'maintain_tasks', 'function' => __NAMESPACE__ . '\\Tasks::call', 'icon' => 'scheduled', 'subsections' => ['tasks' => ['label' => 'maintain_tasks', 'permission' => 'admin_forum'], 'tasklog' => ['label' => 'scheduled_log', 'permission' => 'admin_forum'], 'settings' => ['label' => 'scheduled_tasks_settings', 'permission' => 'admin_forum']]], 'mailqueue' => ['label' => 'mailqueue_title', 'function' => __NAMESPACE__ . '\\Mail::call', 'icon' => 'mail', 'subsections' => ['browse' => ['label' => 'mailqueue_browse', 'permission' => 'admin_forum'], 'settings' => ['label' => 'mailqueue_settings', 'permission' => 'admin_forum'], 'test' => ['label' => 'mailqueue_test', 'permission' => 'admin_forum']]], 'reports' => ['label' => 'generate_reports', 'function' => __NAMESPACE__ . '\\Reports::call', 'icon' => 'reports'], 'logs' => ['label' => 'logs', 'function' => __NAMESPACE__ . '\\Logs::call', 'icon' => 'logs', 'subsections' => ['errorlog' => ['label' => 'errorlog', 'permission' => 'admin_forum', 'enabled' => true, 'url' => '{scripturl}?action=admin;area=logs;sa=errorlog;desc'], 'adminlog' => ['label' => 'admin_log', 'permission' => 'admin_forum', 'enabled' => true], 'modlog' => ['label' => 'moderation_log', 'permission' => 'admin_forum', 'enabled' => true], 'banlog' => ['label' => 'ban_log', 'permission' => 'manage_bans'], 'spiderlog' => ['label' => 'spider_logs', 'permission' => 'admin_forum', 'enabled' => true], 'tasklog' => ['label' => 'scheduled_log', 'permission' => 'admin_forum'], 'settings' => ['label' => 'log_settings', 'permission' => 'admin_forum']]], 'repairboards' => ['label' => 'admin_repair', 'function' => __NAMESPACE__ . '\\RepairBoards::call', 'select' => 'maintain', 'hidden' => true]]]]

Defines the menu structure for the admin center. See Menu.php for details!

The values of all 'title' and 'label' elements are Lang::$txt keys, and will be replaced at runtime with the values of those Lang::$txt strings.

All occurrences of '{scripturl}' and '{boardurl}' in value strings will be replaced at runtime with the real values of Config::$scripturl and Config::$boardurl.

In this default definintion, all parts of the menu are set as enabled. At runtime, however, various parts may be turned on or off depending on the forum's saved settings.

MOD AUTHORS: If your mod has just a few simple settings and doesn't need its own settings page, you don't need to bother adding anything to this menu. Instead, just use the integrate_general_mod_settings hook to add your settings to the general mod settings page.

Alternatively, if you want to add a custom settings page for your mod, please use the integrate_admin_areas hook to add your settings page to $admin_areas['config']['areas']['modsettings']['subsections'].

$list_options

public array<string|int, mixed> $list_options = ['id' => 'news_lists', 'get_items' => ['function' => __CLASS__ . '::list_getNews'], 'columns' => ['news' => ['header' => ['value' => '{txt:admin_edit_news}', 'class' => 'half_table'], 'data' => ['function' => __CLASS__ . '::list_getNewsTextarea', 'class' => 'half_table']], 'preview' => ['header' => ['value' => '{txt:preview}', 'class' => 'half_table'], 'data' => ['function' => __CLASS__ . '::list_getNewsPreview', 'class' => 'half_table']], 'check' => ['header' => ['value' => '<input type="checkbox" onclick="invertAll(this, this.form);">', 'class' => 'centercol icon'], 'data' => ['function' => __CLASS__ . '::list_getNewsCheckbox', 'class' => 'centercol icon']]], 'form' => [ 'href' => '{scripturl}?action=admin;area=news;sa=editnews', // Will be populated at runtime with session_var => session_id 'hidden_fields' => [], ], 'additional_rows' => [['position' => 'bottom_of_list', 'value' => ' <span id="moreNewsItems_link" class="floatleft" style="display: none;"> <a class="button" href="javascript:void(0);" onclick="addNewsItem(); return false;">{txt:editnews_clickadd}</a> </span> <input type="submit" name="save_items" value="{txt:save}" class="button"> <input type="submit" name="delete_selection" value="{txt:editnews_remove_selected}" data-confirm="{txt:editnews_remove_confirm}" class="button you_sure">']], 'javascript' => ' document.getElementById(\'list_news_lists_last\').style.display = "none"; document.getElementById("moreNewsItems_link").style.display = ""; var last_preview = 0; $(document).ready(function () { $("div[id ^= \'preview_\']").each(function () { var preview_id = $(this).attr(\'id\').split(\'_\')[1]; if (last_preview < preview_id) last_preview = preview_id; make_preview_btn(preview_id); }); }); function make_preview_btn (preview_id) { $("#preview_" + preview_id).addClass("button"); $("#preview_" + preview_id).text(\'{txt:preview}\').click(function () { $.ajax({ type: "POST", headers: { "X-SMF-AJAX": 1 }, xhrFields: { withCredentials: typeof allow_xhjr_credentials !== "undefined" ? allow_xhjr_credentials : false }, url: "{scripturl}?action=xmlhttp;sa=previews;xml", data: {item: "newspreview", news: $("#data_" + preview_id).val()}, context: document.body, success: function(request){ if ($(request).find("error").text() == \'\') $(document).find("#box_preview_" + preview_id).html($(request).text()); else $(document).find("#box_preview_" + preview_id).text(\'{txt:news_error_no_news}\'); }, }); }); } function addNewsItem () { last_preview++; $("#list_news_lists_last").before(' . '{js_escape: <tr class="windowbg}' . ' + (last_preview % 2 == 0 ? \'\' : \'2\') + ' . '{js_escape:"> <td style="width: 50%;"> <textarea id="data_}' . ' + last_preview + ' . '{js_escape:" rows="3" cols="65" name="news[]" style="width: 95%;"></textarea> <br> <div class="floatleft" id="preview_}' . ' + last_preview + ' . '{js_escape:"></div> </td> <td style="width: 45%;"> <div id="box_preview_}' . ' + last_preview + ' . '{js_escape:" style="overflow: auto; width: 100%; height: 10ex;"></div> </td> <td></td> </tr>}' . '); make_preview_btn(last_preview); }']

List options for showing the news items.

All occurrences of '{scripturl}' and '{boardurl}' in value strings will be replaced at runtime with the real values of Config::$scripturl and Config::$boardurl.

All occurrences of '{txt:...}' in value strings will be replaced at runtime with Lang::$txt strings, using whatever appears between the colon and the closing brace as the key for Lang::$txt.

All occurrences of '{js_escape:...}' in value strings will be replaced at runtime with escaped versions of whatever appears between the colon and the closing brace. This escaping is done using Utils::JavaScriptEscape().

$subaction

public string $subaction = 'editnews'

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

$subactions

public static array<string|int, mixed> $subactions = ['editnews' => ['edit', 'edit_news'], 'mailingmembers' => ['selectMembers', 'send_mail'], 'mailingcompose' => ['compose', 'send_mail'], 'mailingsend' => ['send', 'send_mail'], 'settings' => ['settings', 'admin_forum']]

Available sub-actions.

Format: 'sub-action' => array('function', 'permission')

$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' => 'ManageNews', 'list_getNews' => 'list_getNews', 'list_getNewsTextarea' => 'list_getNewsTextarea', 'list_getNewsPreview' => 'list_getNewsPreview', 'list_getNewsCheckbox' => 'list_getNewsCheckbox', 'prepareMailingForPreview' => 'prepareMailingForPreview', 'editNews' => 'EditNews', 'selectMailingMembers' => 'SelectMailingMembers', 'composeMailing' => 'ComposeMailing', 'sendMailing' => 'SendMailing', 'modifyNewsSettings' => 'ModifyNewsSettings']]

BackwardCompatibility settings for this class.

Methods

adminLogin()

Question the verity of the admin by asking for his or her password.

public static adminLogin([string $type = 'admin' ]) : mixed
  • loads Login.template.php and uses the admin_login sub template.
  • sends data to template so the admin is sent on to the page they wanted if their password is correct, otherwise they can try again.
Parameters
$type : string = 'admin'

What login type is this - can be 'admin' or 'moderate'

call()

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

public static call() : void

compose()

Shows a form to edit a forum mailing and its recipients.

public compose() : void

Called by ?action=admin;area=news;sa=mailingcompose. Requires the send_mail permission. Form is submitted to ?action=admin;area=news;sa=mailingsend.

Tags
uses
template_email_members_compose()

composeMailing()

Backward compatibility wrapper for the mailingcompose sub-action.

public static composeMailing() : void

edit()

Let the administrator(s) edit the news items for the forum.

public edit() : void

It writes an entry into the moderation log. This function uses the edit_news administration area. Called by ?action=admin;area=news. Requires the edit_news permission. Can be accessed with ?action=admin;sa=editnews. Uses a standard list (@see SMF\ItemList())

editNews()

Backward compatibility wrapper for the edit sub-action.

public static editNews() : void

emailAdmins()

Send all the administrators a lovely email.

public static emailAdmins(string $template[, array<string|int, mixed> $replacements = [] ][, array<string|int, mixed> $additional_recipients = [] ]) : mixed
  • loads all users who are admins or have the admin forum permission.
  • uses the email template and replacements passed in the parameters.
  • sends them an email.
Parameters
$template : string

Which email template to use

$replacements : array<string|int, mixed> = []

An array of items to replace the variables in the template

$additional_recipients : array<string|int, mixed> = []

An array of arrays of info for additional recipients. Should have 'id', 'email' and 'name' for each.

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 this admin area.

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

$config_vars for the news area.

getFileVersions()

Search through source, theme, and language files to determine their version.

public static getFileVersions(array<string|int, mixed> &$versionOptions) : array<string|int, mixed>

Get detailed version information about the physical SMF files on the server.

  • the input parameter allows to set whether to include SSI.php and whether the results should be sorted.
  • returns an array containing information on source files, templates, and language files found in the default theme directory (grouped by language).
Parameters
$versionOptions : array<string|int, mixed>

An array of options. Can contain one or more of 'include_root', 'include_tasks' and 'sort_results'

Return values
array<string|int, mixed>

An array of file version info.

getServerVersions()

Get a list of versions that are currently installed on the server.

public static getServerVersions(array<string|int, mixed> $checkFor) : array<string|int, mixed>
Parameters
$checkFor : array<string|int, mixed>

An array of what to check versions for - can contain one or more of 'gd', 'imagemagick', 'db_server', 'phpa', 'memcache', 'php' or 'server'

Return values
array<string|int, mixed>

An array of versions (keys are same as what was in $checkFor, values are the versions)

list_getNews()

Prepares an array of the forum news items for display in the template

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

An array of information about the news items

list_getNewsCheckbox()

Callback to prepare HTML for the checkboxes in the news editing form.

public static list_getNewsCheckbox( $news) : string
Parameters
$news :

Info about a news item.

Return values
string

HTML string to show in the form.

list_getNewsPreview()

Callback to prepare HTML for the previews in the news editing form.

public static list_getNewsPreview( $news) : string
Parameters
$news :

Info about a news item.

Return values
string

HTML string to show in the form.

list_getNewsTextarea()

Callback to prepare HTML for the input fields in the news editing form.

public static list_getNewsTextarea( $news) : string
Parameters
$news :

Info about a news item.

Return values
string

HTML string to show in the form.

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

modifyNewsSettings()

Backward compatibility wrapper for the settings sub-action.

public static modifyNewsSettings([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.

prepareDBSettingContext()

Helper function, it sets up the context for database settings.

public static prepareDBSettingContext(array<string|int, mixed> &$config_vars) : void
Parameters
$config_vars : array<string|int, mixed>

An array of configuration variables

Tags
todo

see rev. 10406 from 2.1-requests

prepareMailingForPreview()

Prepare subject and message of an email for the preview box Used in ComposeMailing and RetrievePreview (XmlHttp.php)

public static prepareMailingForPreview() : void

saveDBSettings()

Helper function for saving database settings.

public static saveDBSettings(array<string|int, mixed> &$config_vars) : mixed
Parameters
$config_vars : array<string|int, mixed>

An array of configuration variables

Tags
todo

see rev. 10406 from 2.1-requests

saveSettings()

Helper function. Saves settings by putting them in Settings.php or saving them in the settings table.

public static saveSettings(array<string|int, mixed> &$config_vars) : void
  • Saves those settings set from ?action=admin;area=serversettings.
  • Requires the admin_forum permission.
  • Contains arrays of the types of data to save into Settings.php.
Parameters
$config_vars : array<string|int, mixed>

An array of configuration variables

selectMailingMembers()

Backward compatibility wrapper for the mailingmembers sub-action.

public static selectMailingMembers() : void

selectMembers()

Allows the user to select the membergroups to send their mailing to.

public selectMembers() : void

Called by ?action=admin;area=news;sa=mailingmembers. Requires the send_mail permission. Form is submitted to ?action=admin;area=news;mailingcompose.

Tags
uses
template_email_members()

send()

Handles the sending of the forum mailing in batches.

public send([bool $clean_only = false ]) : void

Called by ?action=admin;area=news;sa=mailingsend Requires the send_mail permission. Redirects to itself when more batches need to be sent. Redirects to ?action=admin;area=news;sa=mailingmembers after everything has been sent.

Parameters
$clean_only : bool = false

If set, it will only clean the variables, put them in context, then return.

Tags
uses
template_email_members_send()

sendMailing()

Backward compatibility wrapper for the mailingsend sub-action.

public static sendMailing() : void

settings()

Set general news and newsletter settings and permissions.

public settings() : void

Called by ?action=admin;area=news;sa=settings. Requires the forum_admin permission.

Tags
uses
template_show_settings()

updateAdminPreferences()

Saves the admin's current preferences to the database.

public static updateAdminPreferences() : mixed

__construct()

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

protected __construct() : mixed

adminLogin_outputPostVars()

Used by the adminLogin() method.

protected static adminLogin_outputPostVars(string $k, string $v) : string

If 'value' is an array, calls itself recursively.

Parameters
$k : string

The keys

$v : string

The values

Return values
string

'hidden' HTML form fields, containing key-value pairs

construct_query_string()

Properly urlencodes a string to be used in a query.

protected static construct_query_string(string $get) : string
Parameters
$get : string

A copy of $_GET.

Return values
string

Our query string.

setAdminAreas()

Sets any dynamic values in $this->admin_areas.

protected setAdminAreas() : void

setDynamicStrings()

Sets any dynamic string values in the passed array.

protected static setDynamicStrings(array<string|int, mixed> &$data) : void
Parameters
$data : array<string|int, mixed>

setListOptions()

Sets dynamic values in $this->list_options.

protected setListOptions() : void

        
On this page

Search results