News
in package
implements
ActionInterface
uses
ActionTrait, BackwardCompatibility
This class manages... the news. :P
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $list_options : array<string|int, mixed>
- $subaction : string
- $subactions : array<string|int, mixed>
- $obj : static
Methods
- call() : void
- Convenience method to load() and execute() an instance of this class.
- canBeLogged() : bool
- Determines whether this action can be logged in the online log.
- canShowDebuggingInfo() : bool
- Determines whether debugging info should be shown.
- canShowInMaintenanceMode() : bool
- Determines whether this action allows access in maintenance mode.
- compose() : void
- Shows a form to edit a forum mailing and its recipients.
- edit() : void
- Let the administrator(s) edit the news items for the forum.
- execute() : void
- Dispatcher to whichever sub-action method is necessary.
- getConfigVars() : array<string|int, mixed>
- Gets the configuration variables for this admin area.
- getOutputType() : OutputTypeInterface
- Gets the output type for this action.
- isAgreementAction() : bool
- Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
- isRestrictedGuestAccessAllowed() : bool
- Determines whether this action allows access if guest access is restricted.
- isSimpleAction() : bool
- Determines whether this is a simple action.
- 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() : static
- Static wrapper for constructor.
- prepareMailingForPreview() : void
- Prepare subject and message of an email for the preview box Used in ComposeMailing and RetrievePreview (XmlHttp.php)
- 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.
- settings() : void
- Set general news and newsletter settings and permissions.
- subActionProvider() : null|array<string|int, mixed>
- Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- setDynamicStrings() : void
- Sets any dynamic string values in the passed array.
- setListOptions() : void
- Sets dynamic values in $this->list_options.
Properties
$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%; min-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::escapeJavaScript().
$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 static
$obj
An instance of this class. This is used by the load() method to prevent multiple instantiations.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
canBeLogged()
Determines whether this action can be logged in the online log.
public
canBeLogged() : bool
Return values
boolcanShowDebuggingInfo()
Determines whether debugging info should be shown.
public
canShowDebuggingInfo() : bool
Return values
boolcanShowInMaintenanceMode()
Determines whether this action allows access in maintenance mode.
public
canShowInMaintenanceMode() : bool
Return values
bool —True if access is allowed, false otherwise.
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
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())
execute()
Dispatcher to whichever sub-action method is necessary.
public
execute() : void
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.
getOutputType()
Gets the output type for this action.
public
getOutputType() : OutputTypeInterface
Return values
OutputTypeInterfaceisAgreementAction()
Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
public
isAgreementAction() : bool
Return values
boolisRestrictedGuestAccessAllowed()
Determines whether this action allows access if guest access is restricted.
public
isRestrictedGuestAccessAllowed() : bool
Return values
bool —True if access is allowed, false otherwise.
isSimpleAction()
Determines whether this is a simple action.
public
isSimpleAction() : bool
Return values
boollist_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(array<string|int, mixed> $news) : string
Parameters
- $news : array<string|int, mixed>
-
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(array<string|int, mixed> $news) : string
Parameters
- $news : array<string|int, mixed>
-
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(array<string|int, mixed> $news) : string
Parameters
- $news : array<string|int, mixed>
-
Info about a news item.
Return values
string —HTML string to show in the form.
load()
Static wrapper for constructor.
public
static load() : static
Return values
static —An instance of this class.
prepareMailingForPreview()
Prepare subject and message of an email for the preview box Used in ComposeMailing and RetrievePreview (XmlHttp.php)
public
static prepareMailingForPreview() : 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
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
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
subActionProvider()
Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods
public
static subActionProvider([null|string $sa = null ][, bool $return_config = false ][, string|null $activity = null ]) : null|array<string|int, mixed>
Parameters
- $sa : null|string = null
- $return_config : bool = false
- $activity : string|null = null
Return values
null|array<string|int, mixed>__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
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