Assembly line workers/Params

From Apibot
Jump to: navigation, search

The Params workers are modifying in different ways the parameters (metadata) of the signals that carry the data between the line objects.

All are situated in the directory interfaces/line/workers/params.

Parameter group changing

These objects work on an entire parameters group.

All of them have the public property $group, which must contain the name of the parameters group to work on.

All parameter group workers are situated in the subdirectory group.

Class name Task Creation params Public properties Notes
Worker_Paramgroup_Copy Copies a parameters group under a new name Apibot core $new_group If a parameter group with the new name already exists, it will be overwritten
Worker_Paramgroup_Rename Renames a parameter group Apibot core $new_group If a parameter group with the new name already exists, it will be overwritten
Worker_Paramgroup_Set Sets an array representing a parameter group to the name in $group Apibot core $group_array (an array that is parameter group) If a parameter group with this name already exists, it will be overwritten
Worker_Paramgroup_Swap Swaps a parameter group with another one Apibot core $group2 (the name of the other group) If one of the parameter groups does not exist, the other will be effectively renamed
Worker_Paramgroup_Unset Unsets (deletes) the parameter group with the name in $group Apibot core

Parameter changing

These objects work on a signal parameter.

All of them have the following public properties:

  • $group - the name of the parameters group to work in
  • $name - the name of the parameter within that group to work on

All parameter workers are situated in the subdirectory param.

General parameter changing

These workers perform standard general operations on parameters.

All of them are situated in the subdirectory param/general.

Class name Task Creation params Public properties Notes
Worker_Param_Copy Copies a parameter under a new name Apibot core $source_group, $source_name If a parameter with this group and name already exists, it will be overwritten
Worker_Param_Rename Renames a parameter Apibot core $new_group, $new_name If a parameter with the new group and name already exists, it will be overwritten
Worker_Param_Set Sets a value to the parameter in $group with $name Apibot core $value If a parameter with this group and name already exists, it will be overwritten
Worker_Param_Swap Swaps a parameter with another one Apibot core $group2, $name2 If one of the parameters does not exist, the other will be effectively renamed
Worker_Param_Unset Unsets (deletes) the parameter in $group with $name Apibot core

Setting parameters from data

These workers set parameters from data values.

All of them are situated in the subdirectory param/set/from_data.

General

Class name Task Creation params Public properties Notes
Worker_SetParam_FromDataValue Copies a parameter from the signal default data element or its subelement Apibot core $from_sublevels If a parameter with this group and name already exists, it will be overwritten

The property $from_sublevels allows setting to a parameter not the entire data element, but its subelement. Assign to it the name of the sublevel, or an array with the names of the consecutive sublevels. Only arrays and objects can have subelements (members and properties respectively).

Some examples:

  • The data element is a page, and you want to get its timestamp - set $from_sublevels to "timestamp", or to array ( "timestamp" ).
  • The data element is array, which has under the key "object5" an object, which has a property $users. To this property is assigned an array, which has under key "2" some value that you want to get. In this case, set $from_sublevels to array ( "object5", "users", "2" ).

Wikivalues

These workers set parameters from standard wikivalues (title, pageid, user, blockid...) from the signal default data element.

All of them are situated in the subdirectory param/set/from_data/wikivalues.

The signal default data element must be of a type that can produce the wikivalue specified, or NULL will be returned (and set to the parameter) instead.

Class name Task Creation params Notes
Worker_SetParam_FromBlockid Sets the parameter to the Blockid value from the default data element. Apibot core
Worker_SetParam_FromByUser Sets the parameter to the By_User value from the default data element. Apibot core
Worker_SetParam_FromExpiry Sets the parameter to the Expiry value from the default data element. Apibot core
Worker_SetParam_FromExtlink Sets the parameter to the Extlink value from the default data element. Apibot core
Worker_SetParam_FromLogid Sets the parameter to the Logid value from the default data element. Apibot core
Worker_SetParam_FromNsid Sets the parameter to the Nsid value from the default data element. Apibot core
Worker_SetParam_FromPageid Sets the parameter to the Pageid value from the default data element. Apibot core
Worker_SetParam_FromRcid Sets the parameter to the Rcid value from the default data element. Apibot core
Worker_SetParam_FromRevid Sets the parameter to the Revid value from the default data element. Apibot core
Worker_SetParam_FromSize Sets the parameter to the Size value from the default data element. Apibot core
Worker_SetParam_FromTimestamp Sets the parameter to the Timestamp value from the default data element. Apibot core
Worker_SetParam_FromTitle Sets the parameter to the Title value from the default data element. Apibot core
Worker_SetParam_FromUser Sets the parameter to the User value from the default data element. Apibot core
Worker_SetParam_FromUserid Sets the parameter to the Userid value from the default data element. Apibot core

Setting parameters from parameters

Checksums

These create different checksums of the parameter value.

All need string type of data. If they get a wrong kind of data, that will stop the processing of the signal.

Class name Task Creation params Public properties Notes
Worker_SetParam_CRC32 Produces a CRC32 checksum of the parameter value (must be string). Apibot core
Worker_SetParam_MD5 Produces an MD5 checksum of the parameter value (must be string). Apibot core
Worker_SetParam_SHA1 Produces a SHA1 checksum of the parameter value (must be string). Apibot core

Math

These work on numeric data. Non-numeric data will cause the processing of the signal to stop there.

Class name Task Creation params Public properties Notes
Worker_SetParam_Math_Add Adds a specified value to the parameter value it copies. Apibot core $add
Worker_SetParam_Math_Subtract Subtracts a specified value from the parameter value it copies. Apibot core $subtract
Worker_SetParam_Math_SubtractFrom Subtracts the parameter value it copies from a specified value. Apibot core $subtract_from
Worker_SetParam_Math_Multiply Multiplies the parameter value it copies by a specified value. Apibot core $multiply
Worker_SetParam_Math_Divide Divides the parameter value it copies by a specified value. Apibot core $divide
Worker_SetParam_Math_Round Rounds the parameter value it copies. Apibot core $precision, $mode Works through the PHP round() function
Worker_SetParam_Math_Ceil Rounds up the parameter value it copies. Apibot core Works through the PHP ceil() function
Worker_SetParam_Math_Floor Rounds down the parameter value it copies. Apibot core Works through the PHP floor() function
Worker_SetParam_Math_Frac Returns the fractional part of the parameter value it copies Apibot core
Worker_SetParam_Math_Min Returns the smaller of the copied parameter value and a given value Apibot core $min
Worker_SetParam_Math_Max Returns the larger of the copied parameter value and a given value Apibot core $max
Worker_SetParam_Math_Random Returns a random number between $min and $max Apibot core $min, $max Does not use a source parameter value

String

These work on string data. Non-string data will cause the processing of the signal to stop there.

Class name Task Creation params Public properties Notes
Worker_SetParam_String_Extend Prepends and/or appends a string to the source parameter value Apibot core $prepend, $append
Worker_SetParam_String_Pad Pads the source parameter value with a string to a length, from left, right or both sides Apibot core $length, $with, $type = STR_PAD_RIGHT
Worker_SetParam_String_Repeat Repeats the source parameter value a given number of times Apibot core $count
Worker_SetParam_String_Trim Trims the leading and trailing spaces from the source parameter value Apibot core
Worker_SetParam_String_LTrim Trims the leading spaces from the source parameter value Apibot core
Worker_SetParam_String_RTrim Trims the trailing spaces from the source parameter value Apibot core
Worker_SetParam_String_Pos Returns the zero-based position of a given string within the source parameter value Apibot core $search (the string that must be found)
Worker_SetParam_String_Length Returns the length of the source parameter value, in characters. Apibot core $mb = true, $encoding Multibyte by default; set $mb = false to switch that off. Specify $encoding to force a multibyte encoding.
Worker_SetParam_String_Substr Returns a substring of the source parameter value, by start and length. Apibot core $start = 0, $length, $mb = true Multibyte by default; set $mb = false to switch that off. Leave $length unset to take from $start to the end of the parameter value.
Worker_SetParam_String_Replace Replaces in the source parameter value a given value or regex with another given value, up to a count of times Apibot core $match, $with, $count If $match starts with '/', it is treated as a PHP regex, otherwise as a string.
Worker_SetParam_String_ReplaceInto Replaces a given value into another given value with the source parameter value, up to a count of times Apibot core $match, $into, $count If $match starts with '/', it is treated as a PHP regex, otherwise as a string.
Worker_SetParam_String_ToLower Lowercases the source parameter value Apibot core $mb = true Multibyte by default; set $mb = false to switch that off.
Worker_SetParam_String_ToUpper Uppercases the source parameter value Apibot core $mb = true Multibyte by default; set $mb = false to switch that off.
Worker_SetParam_String_UCFirst Uppercases the first letter of the source parameter value Apibot core $mb = true Multibyte by default; set $mb = false to switch that off.
Worker_SetParam_String_UCWords Uppercases the first letter of every word in the source parameter value Apibot core $mb = true Multibyte by default; set $mb = false to switch that off.

See also