Archived Help Wiki
Advertisement

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
intpage_id
arrayflags
intflags[]['flag_type_id'] An ID of a flag type

Optional parameters:

Parameters
intwiki_id You can overwrite the current city_id
arrayflags[]['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
intwiki_id
intflag_group One of the keys in flagGroups property of the FlagType model:

1 => 'spoiler',
2 => 'disambig',
3 => 'canon',
4 => 'stub',
5 => 'delete',
6 => 'improvements',
7 => 'status',

8 => 'other'
stringflag_name A name of the flag (not longer than 128 characters)
stringflag_view A title of a template used for rendering the flag
intflag_targeting A level of targeting:
0 => readers,
1 => contibutors,
2 => admins

Optional parameters:

Parameters
stringflagParamsNames 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
intwiki_id (optional) You can overwrite a default wiki_id with it
intpage_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
intwiki_id (optional) You can overwrite a default wiki_id with it
intpage_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
stringflag_view

Optional parameters:

Parameters
intwiki_id You can overwrite the current city_id
Returns
int|null



getFlagTypes[]

Get all flag types for given wiki

Optional parameters:

Parameters
intwiki_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
intpage_id Page ID
arrayflags_ids An array of IDs of flags to remove



removeFlagType[]

Removes a type of flags.

Required parameters:

Parameters
intflag_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
intpage_id
intflag_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": []
        }
    }
}
Advertisement