Packagecom.thirdavedesign.drupalSite
Classpublic class DrupalSite
InheritanceDrupalSite Inheritance Amf
Implementsflash.events.IEventDispatcher

DrupalSite is an ActionScript 3 class for interfacing with the Drupal content management system.

DrupalSite provides high-level methods for invoking and retrieving data from Drupal services. This class requires the Amf connection class, which provides basic methods for establishing and handling the Amf connection with Drupal.

The DrupalSite class must be instantiated. After the class is instantiated and the gateway URL is provided, DrupalSite attempts to establish a connection and invoke the system.connect Drupal service method. If this is successful, the session ID is retrieved, the CONNECTED property is set to true, and the COMPLETE event is dispatched. Also, if the session is for an already authenticated user, then the USER and UID properties are set.

If the user is not yet authenticated, then the login method can be used for authenticating the current user via the user.login Drupal service method.

DrupalSite also provides the following methods for accessing Drupal services:

Drupal service methodDrupalSite method
taxonomy.getTreegetCategory
node.loadgetNode
view.getViewgetView
node.deletenodeDelete
node.savenodeSave
system.mailsendMail

These methods implement some basic measures to improve the reliability and speed of calling Drupal services. First, these methods use an internal blocking system for retrying delayed or broken connections. Second, three methods (getCategory, getNode, and getView) save the results to a cache so that some subsequent calls may not need to fetch duplicate data. These methods include an argument to ignore cached data.



Public Properties
 PropertyDefined by
 InheritedapiKey : String = ""
API key for Drupal services.
Amf
  CONNECTED : Boolean = false
Status variable for whether DrupalSite is currently connected.
DrupalSite
  Event_DATA : String = "Event_DATA"
[static] Event definition for new data.
DrupalSite
  Event_ERROR : String = "Event_ERROR"
[static] Event definition for error.
DrupalSite
  GATEWAY : String
URL to Drupal services AMFPHP gateway.
DrupalSite
 InheritedgatewayUrl : String = ""
URL to the Drupal services AMFPHP gateway.
Amf
  KEY : String
API key for Drupal services AMFPHP gateway.
DrupalSite
 InheritedsessionId : String = ""
Session ID from successful connection to Drupal services.
Amf
  UID : int = 0
Drupal user ID of authenticated user.
DrupalSite
  USER : Object
Drupal user object of authenticated user.
DrupalSite
  VERBOSE : Boolean = true
Determines whether debug printout is enabled.
DrupalSite
Public Methods
 MethodDefined by
  
DrupalSite(gatewayUrl:String = "", apiKey:String = "")
Creates a new DrupalSite instance.
DrupalSite
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
DrupalSite
  
amfConnect():void
Invokes Drupal system.connect service method using the blocking routines.
DrupalSite
 Inherited
connect(onSuccess:Function):void
Invoke Drupal system.connect service method to establish connection with Drupal services.
Amf
  
dispatchEvent(evt:Event):Boolean
DrupalSite
  
getCategory(vid:int, tid:int, callback:Function, data:Object = null, reload:Boolean = false):Boolean
Invokes the Drupal taxonomy.getTree service method for retrieving nodes associated with a category or term.
DrupalSite
  
getNode(nid:int, callback:Function, data:Object = null, reload:Boolean = false):Boolean
Invokes the Drupal node.load service method for retrieving a node.
DrupalSite
  
getView(viewname:String, callback:Function, data:Object = null, reload:Boolean = false):Boolean
Invokes the Drupal view.getView service method for retrieving nodes from a view.
DrupalSite
  
hasEventListener(type:String):Boolean
DrupalSite
  
login(username:String, password:String, callback:Function = null, data:Object = null):Boolean
Invokes the Drupal user.login service method to authenticate a user.
DrupalSite
  
nodeDelete(nid:int, callback:Function = null, data:Object = null):Boolean
Invokes the Drupal node.delete service method for deleting a node.
DrupalSite
  
nodeSave(node:Object, callback:Function = null, data:Object = null):Boolean
Invokes the Drupal node.save service method for saving a node.
DrupalSite
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
DrupalSite
  
sendMail(addrTo:String, subject:String, body:String, addrFrom:String = "", mailKey:String = "service-system-mail", headers:Array = null, callback:Function = null, data:Object = null):Boolean
Invokes the Drupal system.mail service method to send an e-mail.
DrupalSite
 Inherited
service(onSuccess:Function, onFault:Function, command:String, ... args):Boolean
Invoke Drupal services method.
Amf
  
willTrigger(type:String):Boolean
DrupalSite
Public Constants
 ConstantDefined by
  DATE : String = "8.27.2008"
[static] Engine version date.
DrupalSite
  LICENSE : String = "DrupalSite by Third Ave Design. Licensed under GPLv3."
[static] Engine license.
DrupalSite
  NAME : String = "DrupalSite"
[static] Engine name.
DrupalSite
  VERSION : String = "Alpha 0.5 - release/Public"
[static] Engine version.
DrupalSite
Property detail
CONNECTEDproperty
public var CONNECTED:Boolean = false

Status variable for whether DrupalSite is currently connected.

Event_DATAproperty 
public static var Event_DATA:String = "Event_DATA"

Event definition for new data.

Event_ERRORproperty 
public static var Event_ERROR:String = "Event_ERROR"

Event definition for error.

GATEWAYproperty 
public var GATEWAY:String

URL to Drupal services AMFPHP gateway.

KEYproperty 
public var KEY:String

API key for Drupal services AMFPHP gateway.

UIDproperty 
public var UID:int = 0

Drupal user ID of authenticated user.

USERproperty 
public var USER:Object

Drupal user object of authenticated user.

VERBOSEproperty 
public var VERBOSE:Boolean = true

Determines whether debug printout is enabled. It also prints version information at initialization.

Constructor detail
DrupalSite()constructor
public function DrupalSite(gatewayUrl:String = "", apiKey:String = "")

Creates a new DrupalSite instance. If the gatewayUrl is specified, DrupalSite tries immediately to establish a connection.

Parameters
gatewayUrl:String (default = "") — [Optional] URL to Drupal AMFPHP service gateway.
 
apiKey:String (default = "") — [Optional] API key for Drupal services.
Method detail
addEventListener()method
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)
amfConnect()method 
public function amfConnect():void

Invokes Drupal system.connect service method using the blocking routines. This validates the API key and retrieves a Drupal session. If the user is already authenticated, the UID and USER properties on DrupalSite will be set. Event.COMPLETE will be dispatched when the connection is made.

dispatchEvent()method 
public function dispatchEvent(evt:Event):Boolean

Parameters
evt:Event

Returns
Boolean
getCategory()method 
public function getCategory(vid:int, tid:int, callback:Function, data:Object = null, reload:Boolean = false):Boolean

Invokes the Drupal taxonomy.getTree service method for retrieving nodes associated with a category or term.

Parameters
vid:int — Drupal vocabulary ID
 
tid:int — Drupal term ID
 
callback:Function — Callback function on succcess.
 
data:Object (default = null) — [Optional] Data passed as argument to callback function.
 
reload:Boolean (default = false) — [Optional] If set to true, then any cached data for the category or term is ignored, and the nodes are reloaded from the Drupal site.

Returns
Boolean — Success (true) or failure (false) of blocking initiation.
getNode()method 
public function getNode(nid:int, callback:Function, data:Object = null, reload:Boolean = false):Boolean

Invokes the Drupal node.load service method for retrieving a node.

Parameters
nid:int — Drupal node ID.
 
callback:Function — Callback function on success.
 
data:Object (default = null) — [Optional] Data passed as argument to callback function.
 
reload:Boolean (default = false) — [Optional] If set to true, then any cached data for the node is ignored, and the node is reloaded from the Drupal site.

Returns
Boolean — Success (true) or failure (false) of blocking initiation.
getView()method 
public function getView(viewname:String, callback:Function, data:Object = null, reload:Boolean = false):Boolean

Invokes the Drupal view.getView service method for retrieving nodes from a view.

Parameters
viewname:String — Name of Drupal view to retrieve.
 
callback:Function — Callback function on success.
 
data:Object (default = null) — [Optional] Data passed as argument to callback function.
 
reload:Boolean (default = false) — [Optional] If set to true, then any cached data for the view is ignored, and the view is reloaded from the Drupal site.

Returns
Boolean — Success (true) or failure (false) of blocking initiation.
hasEventListener()method 
public function hasEventListener(type:String):Boolean

Parameters
type:String

Returns
Boolean
login()method 
public function login(username:String, password:String, callback:Function = null, data:Object = null):Boolean

Invokes the Drupal user.login service method to authenticate a user.

Parameters
username:String — Username for Drupal account
 
password:String — Password
 
callback:Function (default = null) — [Optional] Callback function on success.
 
data:Object (default = null) — [Optional] Data passed as argument to callback function.

Returns
Boolean
nodeDelete()method 
public function nodeDelete(nid:int, callback:Function = null, data:Object = null):Boolean

Invokes the Drupal node.delete service method for deleting a node.

Parameters
nid:int — Drupal node ID for node to delete.
 
callback:Function (default = null) — [Optional] Callback function on success.
 
data:Object (default = null) — [Optional] Data passed as argument to callback function.

Returns
Boolean
nodeSave()method 
public function nodeSave(node:Object, callback:Function = null, data:Object = null):Boolean

Invokes the Drupal node.save service method for saving a node.

Parameters
node:Object — Drupal node object to save. Node objects for new nodes must include the type property; otherwise, node objects must include the nid and changed properties.
 
callback:Function (default = null) — Callback function on success.
 
data:Object (default = null) — [Optional] Data passed as argument to callback function.

Returns
Boolean
removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
sendMail()method 
public function sendMail(addrTo:String, subject:String, body:String, addrFrom:String = "", mailKey:String = "service-system-mail", headers:Array = null, callback:Function = null, data:Object = null):Boolean

Invokes the Drupal system.mail service method to send an e-mail.

Parameters
addrTo:String — Recipient's address for e-mail.
 
subject:String — Subject for e-mail.
 
body:String — Body text of e-mail.
 
addrFrom:String (default = "") — [Optional] Sender's address for e-mail.
 
mailKey:String (default = "service-system-mail") — [Optional] Mail key used within Drupal for identifying/modifying mail message.
 
headers:Array (default = null) — [Optional] Array of other headers to include in e-mail.
 
callback:Function (default = null) — [Optional] Callback function on success.
 
data:Object (default = null) — [Optional] Data passed as argument to callback function.

Returns
Boolean
willTrigger()method 
public function willTrigger(type:String):Boolean

Parameters
type:String

Returns
Boolean
Constant detail
DATEconstant
public static const DATE:String = "8.27.2008"

Engine version date. Enables version date to be retrieved at runtime.

LICENSEconstant 
public static const LICENSE:String = "DrupalSite by Third Ave Design. Licensed under GPLv3."

Engine license. Enables license to be retrieved at runtime.

NAMEconstant 
public static const NAME:String = "DrupalSite"

Engine name. Enables engine name to be retrieved at runtime.

VERSIONconstant 
public static const VERSION:String = "Alpha 0.5 - release/Public"

Engine version. Enables version to be retrieved at runtime.