Editor modules manager.
addBlock (moduleName:String, action:String, block:_ExportBlock, vars:Vars):Void
Outputs page block.
Parameters:
moduleName
Editor module name.
action
Action string.
block
Page block.
vars
Request variables.
addForm (form:_ExportBlock, vars:Vars):Void
Outputs a web form. Can use SQL query results to set input values. Module manager API is described in detail in Page Blocks article.
Usage cheatsheet:
manager.addForm({
type: BLOCK_FORM,
enctype: "multipart/form-data", // optional
width: 550, // optional
title: "Form Title",
action: "calendar.add",
query: "SELECT * FROM CalendarEvents WHERE ID = [id]", // optional
inputs: [
// form segments separator
{ title: "Group title", type: INPUT_HEADER },
// basic text field
{ title: "Amount", name: "amount" },
// basic text field with given value
{ title: "Amount", name: "amount", value: 10 },
// file upload
{ title: "File", name: "file", type: INPUT_FILE },
// int value taken from "params" JSON string field of SQL query result
// i.e., Params = "{"testParam":10}"
{ title: "Test Param", name: "testParam", isParam: true },
// float value taken from "params" JSON string field of SQL query result
// i.e., Params = "{"testParam":10.1}"
{ title: "Test Param", name: "testParam", type: "float", isParam: true },
// text area with default size
{ title: "Note", name: "note", type: INPUT_TEXTAREA },
// text area with number of rows and columns specified
{ title: "Note", name: "note", type: INPUT_TEXTAREA, rows: 10, cols: 50 },
// uneditable value
{ title: "Reg Date", name: "regdate", value: "10.04.2010", type: INPUT_VALUE },
// drop-down list from SQL query
{ title: "Item Slot", name: "slotid", type: INPUT_SELECT,
query: "SELECT ID AS Value, Name " +
"FROM ItemSlots ORDER BY Name" },
// drop-down list from an array of name, value pairs
{ title: "Item Group", name: "groupid", type: INPUT_SELECT,
values: [
{ name: "group name 1", value: 1 },
{ name: "group name 2", value: 2 }
]
},
// checkbox
{ title: "Bool var", name: "myboolvar", type: INPUT_CHECKBOX }
// hidden value
{ name: "hiddenVal", value: "15", type: INPUT_HIDDEN },
// date/time text and selector
{ title: "Start date (DD.MM.YYYY HH:MM)", name: "datestart",
type: INPUT_DATETIME },
],
}, vars);
Parameters:
form
Page block.
vars
Request variables.
addList (block:_ExportBlock, vars:Vars):Void
Outputs a list from SQL query results. Module manager API is described in detail in Page Blocks article.
Usage cheatsheet:
manager.addList({
type: BLOCK_LIST,
title: "Search",
pageRows: 50,
pageAction: "?a=user.search&name=[name]",
pageCount: "SELECT count(*) AS cnt FROM Users WHERE ID > [id] ORDER BY Name",
actionPre: "user.",
actions: [ "edit", "del" ],
actionPost: "&chainid=[id]&rowval=[row.value]",
query: "SELECT * FROM Users WHERE ID > [id] ORDER BY Name",
fields: [ "id", "name", "minLevel", "isDaily" ],
fieldsExt: [
{ name: "minLevel", func: this.minLevel },
{ name: "isDaily", param: "isDaily" }
]
}, vars);
// ...
function minLevel(listrow: Dynamic, vars: Vars, perms: String)
{
// ...
}
Parameters:
block
Page block.
vars
Request variables.
checkPermissions (type:String):Bool
Checks user permissions for this action.
Parameters:
type
Action type.
Returns:
True, if this action is permitted for this user. False otherwise.
doDelete (m:_ModuleExport, vars:Vars):Bool
Performs SQL DELETE query. Module manager API is described in detail in Editor Modules article.
Usage cheatsheet:
manager.doDelete({
table: "TableName",
delete: true
}, vars);
Parameters:
m
Editor module export.
vars
Request variables.
Returns:
True, if query was successful.
doInsert (m:_ModuleExport, vars:Vars):Bool
Performs SQL INSERT query. Module manager API is described in detail in Editor Modules article.
Usage cheatsheet:
manager.doInsert({
table: "TableName",
insert: [ "checkbox:col1", "col2", "col3", "datetime:date", "now:date" ],
insertParams: [ "minLevel", "float:minMoment", "checkbox:nitroDisabled",
"string:myString" ], // json-object params
}, vars);
Parameters:
m
Editor module export.
vars
Request variables.
Returns:
True, if query was successful.
doUpdate (m:_ModuleExport, vars:Vars, ?traceQuery:Bool):Bool
Performs SQL UPDATE query. Module manager API is described in detail in Editor Modules article.
Usage cheatsheet:
manager.doUpdate({
table: "TableName",
update: [ "checkbox:col1", "col2", "col3", "datetime:date", "now:date" ],
updateParams: [ "minLevel", "float:minMoment", "checkbox:nitroDisabled",
"string:myString" ], // json-object params
}, vars);
Parameters:
m
Editor module export.
vars
Request variables.
traceQuery
If set to true, will output the SQL query.
Returns:
True, if query was successful.
inline doUpload (m:_ModuleExport, vars:Vars):Bool
Performs file upload. Module manager API is described in detail in Editor Modules article.
Usage cheatsheet:
manager.doUpload({
action: "core/item.upload",
upload: "client/items/[id].swf",
}, vars);
Parameters:
m
Editor module export.
vars
Request variables.
Returns:
True, if file upload was successful.
getModule (name:String):Dynamic
Returns editor module by name.
Parameters:
name
Module name.
Returns:
Editor module.
getModuleExport (type:String):_ModuleExport
Returns module export by action name.
Parameters:
type
Module export name.
Returns:
Module export.
getParams (table:String, id:Int):Dynamic
Returns parsed "params" field from database row.
Parameters:
table
Database table name.
id
Database row ID.
Returns:
Parameters object.
getParamsAsArray (table:String, id:Int):Array<Dynamic>
Returns parsed "params" field as an array from database row.
Parameters:
table
Database table name.
id
Database row ID.
Returns:
Parameters array.
getSubscribedModules (tag:String):Null<List<ModuleEdit<EditServer>>>
Returns subscribed modules list for this event name.
Parameters:
tag
Event name.
Returns:
Editor modules list.
parse (tpl:String, vars:Vars, ?row:Dynamic):String
Inserts request variables and database row fields into template string. Example usage:
// request variables
// s = "core/calendar.edit&id=3&eventid=10";
var s = manager.parse("core/calendar.edit&id=[id]&eventid=[eventid]", vars);
// supplied database row fields
// s = "core/calendar.edit&id=3&eventval=10";
var s = manager.parse("core/calendar.edit&id=[id]&eventval=[row.value]", vars, row);
Parameters:
tpl
Template string.
vars
Request variables.
row
Database row.
Returns:
Resulting string.
registerActionPost (type:String, func:Vars ‑> Void):Void
Registers a function to run post-execution of module export.
Parameters:
type
Full module export name.
func
Function to execute. Has a single argument - HTTP request variables.
registerBlocks (type:String, blocks:Array<_ExportBlock>):Void
Registers additional blocks in module export.
Parameters:
type
Full module export name.
blocks
List of additional blocks. You can set the position of these blocks in the structures. If the block position is 0, the block will be added to the top. If the block position is not set explicitly, it will be added to the end.
replaceBlockByAction (type:String, action:String, block:_ExportBlock):Void
Replaces a block in module export by its action string.
Parameters:
type
Full module export name.
action
Block action string.
block
New block to replace the old one.
setParams (table:String, id:Int, params:Dynamic):Bool
Sets "params" field of a database row from a given object.
Parameters:
table
Database table name.
id
Database row ID.
params
Parameters object.
Returns:
True, if the operation was successful. False otherwise.
subscribeModule (tag:String, module:Dynamic):Void
Subscribes editor module to an event. Editor subscriptions are described in detail in Subscriptions article.
Parameters:
tag
Event name.
module
Editor module.