Public Member Functions[]
addFlagsToPage () | |
addFlagType () | |
getFlagsForPage () | |
getFlagsForPageForEdit () | |
getFlagTypeIdByTemplate () | |
getFlagTypes () | |
removeFlagsFromPage () | |
removeFlagType () | |
updateFlagsForPage () |
Member Function Documentation[]
addFlagsToPage[]
Adds flags to the given page. It accepts only POST requests with a valid User edit token.
Required parameters:
- Parameters
-
int page_id
array flags
int flags[]['flag_type_id']
An ID of a flag type
Optional parameters:
- Parameters
-
int wiki_id
You can overwrite the current city_idarray flags[]['params']
An array of params structured like: [ 'paramName1' => 'paramValue1', 'paramName2' => 'paramValue2', ]
addFlagType[]
Flag type level API Adds a new type of flags.
Required parameters:
- Parameters
-
int wiki_id
int flag_group
One of the keys in flagGroups property of the FlagType model:
1 => 'spoiler',
8 => 'other'
2 => 'disambig',
3 => 'canon',
4 => 'stub',
5 => 'delete',
6 => 'improvements',
7 => 'status',
string flag_name
A name of the flag (not longer than 128 characters)string flag_view
A title of a template used for rendering the flagint flag_targeting
A level of targeting:
0 => readers,
1 => contibutors,
2 => admins
Optional parameters:
- Parameters
-
string flagParamsNames
A JSON-encoded array of names of parameters It's used for rendering inputs in the "Add a flag" form.
getFlagsForPage[]
Article level API Retrieves all data for flags assigned to the given page with an intent of rendering them. To get all types of flags:
- See also
- getFlagsForPageForEdit()
- Parameters
-
int wiki_id
(optional) You can overwrite a default wiki_id with itint page_id
- Returns
- Array A list of flags with flag_type_id values as indexes. One item contains the following fields: int flag_id int flag_type_id int wiki_id int page_id int flag_group string flag_name string flag_view int flag_targeting string|null flag_params_names
getFlagsForPageForEdit[]
Retrieves all data for all flag types available on the given wikia with an intent of rendering a modal with an edit form. It returns the types with instances on the page first and then all other types sorted alphabetically. To retrieve only types with instances on the given page:
- See also
- getFlagsForPage()
- Parameters
-
int wiki_id
(optional) You can overwrite a default wiki_id with itint page_id
- Returns
- Array A list of flags with flag_type_id values as indexes. One item contains the following fields:
getFlagTypeIdByTemplate[]
Get flag type id by template (view) name
Required parameter:
- Parameters
-
string flag_view
Optional parameters:
- Parameters
-
int wiki_id
You can overwrite the current city_id
- Returns
- int|null
getFlagTypes[]
Get all flag types for given wiki
Optional parameters:
- Parameters
-
int wiki_id
You can overwrite the current city_id
- Returns
- Array all flag types
removeFlagsFromPage[]
Removes flags from the given page. It accepts only POST requests with a valid User edit token.
Required parameters:
- Parameters
-
int page_id
Page IDarray flags_ids
An array of IDs of flags to remove
removeFlagType[]
Removes a type of flags.
Required parameters:
- Parameters
-
int flag_type_id
IMPORTANT! When using this method be aware that it removes ALL instances of this type of flags with ALL of their parameters per the database's configuration.
updateFlagsForPage[]
Updates flags on the given page using a flags
array passed as a request parameter.
Required parameters:
- Parameters
-
int page_id
int flag_id
- Returns
- bool
Example[]
To get all flags on given page, you should send a request, similar to:
http://[wiki_name].wikia.com/wikia.php?controller=FlagsApi&method=getFlagsForPage&page_id=[page_id]
and the response should consist of two fields: status
and data
, i.e.:
{ "status": true, "data": { "191": { "flag_id": "23723", "wiki_id": "1174825", "page_id": "446440", "flag_type_id": "191", "flag_group": "6", "flag_name": "Cleanup", "flag_view": "Cleanup", "flag_targeting": "2", "flag_params_names": "{\"1\":\"Reason (optional)\"}", "flag_view_url": "http:\/\/[wiki_name].wikia.com\/wiki\/Template:Cleanup", "params": { "1": "Param value" } }, "187": { "flag_id": "23725", "wiki_id": "1174825", "page_id": "446440", "flag_type_id": "187", "flag_group": "8", "flag_name": "Antique update", "flag_view": "Antique update", "flag_targeting": "1", "flag_params_names": "{\"date\":\"Date\"}", "flag_view_url": "http:\/\/[wiki_name].wikia.com\/wiki\/Template:Antique_update", "params": { "date": "" } }, "189": { "flag_id": "23726", "wiki_id": "1174825", "page_id": "446440", "flag_type_id": "189", "flag_group": "8", "flag_name": "Beta content", "flag_view": "Beta content", "flag_targeting": "1", "flag_params_names": null, "flag_view_url": "http:\/\/[wiki_name].wikia.com\/wiki\/Template:Beta_content", "params": [] } } }