Main editor class.

Fields

actionsNoAuth:Array<String>

List of editor actions that can be executed without authentication. Should be set by the child class.

read only cache:Cache

Editor in-memory cache.

read only config:Config

Editor configuration variables.

read only coreAssetModule:AssetEditCore

Core assets module.

read only coreCalendarModule:CalendarEditCore

Core calendar events module.

read only coreChainsModule:ChainsEditCore

Core quest chains module.

read only coreItemModule:ItemsEditCore

Core items module.

read only coreLocaleModule:LocaleEditCore

Core localization module.

read only coreMainModule:MainEditCore

Core main page module.

read only coreProfilerModule:ProfilerEditCore

Core profiler module.

read only coreQuestsModule:QuestsEditCore

Core quests module.

read only coreStatsModule:StatsEditCore

Core stats module.

read only coreTableModule:TableEditCore

Core static tables module.

read only coreUserAttributeTypesModule:UserAttributeTypesEditCore

Core user attribute types module.

read only coreUserModule:UserEditCore

Core user module.

read only coreVarsModule:GameVarsEditCore

Core game variables module.

read only currentUser:_EditorUser

Current editor user. Set on each request.

defaultAction:String

Default editor action. Also used when module export for action name given in the request does not exist. Should be set by the child class.

defaultActionNoAuth:String

Default editor action when user is not authenticated. Should be set by the child class.

read only isProduction:Bool

If enabled, the server is in production mode. This is a shortcut to the configuration variable.

read only localeManager:LocaleManager

Editor localization manager.

moduleClasses:Array<Dynamic>

List of module classes to load. Should be set by the child class.

read only moduleManager:ModuleManager

Editor module manager.

Methods

inline add (type:String, params:Dynamic):Dynamic

Sends add notification to cache server. Cache server editor API is described in detail in Notifications article.

Parameters:

type

Request type.

params

Request parameters.

dynamic checkUserAuth ():_EditorUser

Checks for user authentication. Default implementation is based on HTTP basic access authentication and EditorUsers database table. Override if necessary.

Returns:

Editor user structure if authentication is successful, null otherwise.

copy (t:String, id:Int, ?replaceObj:Dynamic):Int

Copies database table row into new one and returns new row ID. Adds "COPY" words around name and note fields.

Parameters:

t

Database table name.

id

Database row ID.

replaceObj

Will replace any row fields with the ones in this object.

Returns:

New row ID.

inline del (type:String, params:Dynamic):Dynamic

Sends delete notification to cache server. Cache server editor API is described in detail in Notifications article.

Parameters:

type

Request type.

params

Request parameters.

entry ():Void

HTTP request module entry. This is made public because it has to be called once by hand at the end of main() function to handle the initial HTTP request.

inline get (type:String, params:Dynamic):Dynamic

Returns requested data from cache server. Cache server editor API is described in detail in Notifications article.

Parameters:

type

Request type.

params

Request parameters.

getBlock (type:String, id:Int):Map<String, Dynamic>

Returns cache data block from cache server as a key-value map. Does not lock it.

Parameters:

type

Data block type.

id

Data block ID.

Returns:

Key-value map with block contents.

getCount (q:String):Int

Executes a counting query and returns its result as a number.

For example, running getCount("SELECT count(*) AS cnt FROM Users") will return the number of user records in database.

Parameters:

q

Query string.

Returns:

Records amount.

inline getMedian (q:String):Float

Returns the median value for values returned by query. The query must use "val" field and be ordered from min to max, for example "SELECT ID AS Val FROM Users ORDER BY Time".

Parameters:

q

Query string.

Returns:

Median value.

getUID (name:String):Int

Returns user ID by his or her name.

Parameters:

name

User name.

Returns:

User ID, if such user exists in database. 0 otherwise.

getUIDbyNetworkID (networkType:String, networkID:String):Int

Returns user ID by his or her SNS ID and type (NetworkID, NetworkType database fields).

Parameters:

networkType

User SNS type.

networkID

User SNS ID.

Returns:

User ID, if such user exists in database. 0 otherwise.

init ():Void

Initializes editor internals and modules. Should be called once after instancing the editor.

lastID (t:String):Int

Returns last used row ID from sequence for given database table.

Parameters:

t

Database table name.

Returns:

Last used row ID.

log (s:String, ?printLog:Bool):Void

Adds a message to editor log.

Parameters:

s

Log message.

nextID (t:String):Int

Returns next available row ID from sequence for given database table.

Parameters:

t

Database table name.

Returns:

Next available row ID.

inline notify (type:String, params:Dynamic):Void

Sends notification to cache server. Will automatically close socket connection after sending the message without waiting for response.

Parameters:

type

Request type.

params

Request parameters.

inline query (q:String):PostgresResultSet

Executes SQL query in database.

Parameters:

q

Query string.

Returns:

Result set.

inline queryCache (q:String):List<Dynamic>

Executes SELECT SQL query, adds result into in-memory cache and returns it as list.

Note: If query result has params column, it will decode JSON encoded string that is contained inside.

Parameters:

q

Query string.

Returns:

Query result as a list.

inline queryTrace (q:String):PostgresResultSet

Executes SQL query in database, displaying it in web page for debugging purposes.

Parameters:

q

Query string.

Returns:

Result set.

inline quote (s:String):String

Escapes a string for using in SQL query as a row field.

Parameters:

s

String.

Returns:

Escaped string.

inline reload (type:String, params:Dynamic):Void

Sends reload notification to cache server. Cache server editor API is described in detail in Notifications article.

Parameters:

type

Request type.

params

Request parameters.

inline request (type:String, params:Dynamic, ?autoClose:Bool):Dynamic

Sends request to the cache server.

Parameters:

type

Request type.

params

Request parameters.

autoClose

If true, will close socket connection immediately after sending the request and return null. Otherwise, will wait for the response.

Returns:

Response object, if autoClose is false. Returns null otherwise. Also returns null if no connection could be established to cache server.

inline requestSlave (host:String, port:Int, type:String, params:Dynamic, ?autoClose:Bool):Dynamic

Sends request to a given slave server.

Parameters:

host

Server host.

port

Server port.

type

Request type.

params

Request parameters.

autoClose

If true, will close socket connection immediately after sending the request and return null. Otherwise, will wait for the response.

Returns:

Response object, if autoClose is false. Returns null otherwise. Also returns null if no connection could be established to the server.

row (table:String, id:Int):Dynamic

Returns database row for a given table and ID.

Parameters:

table

Database table name.

id

Database row ID.

Returns:

Row object.

dynamic sendFooters ():Void

Calls sendFootersProject() and displays page.footer template for all pages that have one. Override if necessary.

dynamic sendFootersProject ():Void

Sends project-specific footers. Empty by default. Override if necessary.

dynamic sendHeaders (pageTitle:String, user:String, flagSimpleForms:Bool):Void

Sends HTML headers for all pages that use one and displays page.header template. Override if necessary.

Parameters:

pageTitle

Page title.

user

User name to display in header.

flagSimpleForms

If enabled, displays simpler forms without using jQuery.

dynamic sendHeadersProject ():Void

Sends project-specific headers. Empty by default. Override if necessary.

showLog (name:String, ?noBR:Bool):Void

Displays the contents of a text log file.

Parameters:

name

File name.

noBR

Do not output HTML BR tag after each line.

template (name:String, ?params:Dynamic):String

Parses compiled-in page block template and returns the resulting page block string.

If the "page.fileTemplatesEnabled" editor configuration variable is enabled, the block templates will be read from external files located in "tpl/" directory.

Parameters:

name

Template name.

params

Template parameters.

Returns:

Page block string.

inline translate (s:String):String

Translates editor string. Editor localization is described in detail in Localization article.

Parameters:

s

Editor string.

Returns:

Localized editor string.

inline update (type:String, params:Dynamic):Dynamic

Sends update notification to cache server. Cache server editor API is described in detail in Notifications article.

Parameters:

type

Request type.

params

Request parameters.

inline updateBlock (type:String, id:Int, params:Dynamic):Unknown

Updates cache data block on cache server.

Note: Use with caution. Data block is not locked beforehand and the changes are not propagated to slave servers. If the block is currently locked by a slave server, no changes will be made.

Parameters:

type

Data block type.

id

Data block ID.

params

Anonymous object with data block changes.

Returns:

"ok", if operation was successful. "blockLocked" if the block is currently locked.

inline updateUser (id:Int, group:String, attr:String, value:Dynamic):Void

Updates a single user block attribute to a given value. This method does not have the limitations of updateBlock(). If the user is currently logged in to one of slave servers, his block will be updated on that server without any issues.

The group, attr, value arguments are the same as in snipe.slave.Block.set() call.

Parameters:

id

User ID.

group

Attribute group.

attr

Attribute name.

value

Attribute value.