Jump to content
MediaWiki

راهنما:اعمال سیاهه به ویژه:سیاهه

From mediawiki.org
This page is a translated version of the page Manual:Logging to Special:Log and the translation is 57% complete.

این صفحه نحوه اعمال سیاهه به Special:Log را توضیح می دهد. (Logging to the application log is covered at Manual:Structured logging .)

مثال

This illustrates how you would code Special:Log entries for extensions. The log messages appear on the Special:Log page and can be filtered by, for example, the log name, user, title, or date range.

در پرونده راه اندازی افزونه شما

اين ها بايد در extension.json کار کنند:

{
"LogTypes":["foo"],
"LogNames":{
"foo":"foo-name"
},
"LogHeaders":{
"foo":"foo-header"
},
"LogActionsHandlers":{
"foo/*":"LogFormatter"
}
}

در پرونده i18n/en.json

{
"log-name-foo":"Foo log",
"log-description-foo":"These events track when Foo events happen in the system.",
"logentry-foo-bar":"1ドル {{GENDER:2ドル|did bar}} to page 3ドル"
}

مستندات پیام (qqq.json):

{
"log-name-foo":"The Special:Log log name that appears in the drop-down on the Special:Log page",
"log-description-foo":"The Special:Log description that appears on the Special:Log page when you filter logs on this specific log name",
"logentry-foo-bar":"The template of the log entry message"
}

در کد افزونه

// Anywhere in your code where you want to generate a log entry
$logEntry = new ManualLogEntry( 'foo', 'bar' ); // Log action 'bar' in the Special:Log for 'foo'
$logEntry->setPerformer( $user ); // User object, the user who performed this action
$logEntry->setTarget( $this ); // The page that this log entry affects, a Title object
$logEntry->setComment( $reason ); // Optional, user provided comment
// در صورت اختیاری، پارامترهای اضافی را برای استفاده در پیام i18n ورودی سیاهه
اضافه کنید.
// شماره گذاری باید از 4 شروع شود و می تواند در پیام به عنوان 4ドル، 5ドル و غیره استفاده شود.
//
// Indexes 1,ドル 2,ドル and 3ドル are reserved and provide the username and target page parameters for the messages.
// 1ドル is a reference to the user page and user talk page in the wiki
// 2ドル is used to determine the gender of the user for any gender specific messages
// 3ドル is a reference to the page on which the action took place
//
// If you want to store stuff that should not be available in messages, don’t prefix the array key with a number and don’t use the colons.
// 
// The format is index:formatspecifier:name.
// Format specifier is currently unused, but in future you could say for example
// that this param is a number, format it according to the user language.
// Name is just for giving identifier for the value, and helps to debug issues
// versus unindexed list of parameters.
$logEntry->setParameters( [
	'4::paramname' => 'customparam',
	'hiddenparam' => 'ugly stuff',
] );
// We're not done yet, we need to insert the log entry into the database.
// Insert adds it to the logging table and returns the id of that log entry.
$logid = $logEntry->insert();
// Optionally, publish the log entry in recent changes and the UDP feed of recent changes
// if we want. UDP feed is mainly used for echoing the recent change items into IRC.
// publish() takes second param with values 'rcandudp' (default), 'rc' and 'udp'.
$logEntry->publish( $logid );

افزودن پیوندها

To add a link to log entries, you should pass the page name etc. in the log parameters, and format that in your LogFormatter using makePageLink(). With other methods, non-html output (like UDP feed to IRC) will be broken.

See LogFormatter for an example LogFormatter with links.

جستارهای وابسته

راه اندازی
پیاده‌سازی
نقاط گسترش افزونه
عمومی
صفحات
محتوا
نشانه گذاری ویکی
اعتدال
احراز هویت
بهترین شیوه ها
ابزارها

AltStyle によって変換されたページ (->オリジナル) /