文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>cpaint笔记

cpaint笔记

时间:2007-03-18  来源:lib


                                                                                                cpaint API
cpaintcpaint后台服务类有两个意图:
1. 通过cpaint的前端发送参数调用你的函数,
2. 要写函数来响应前端的请求
cpaint_node
cpaint_node为响应扮演一个容器或返回前端的响应的一部分.
cpaint_transformer
cpaint_transformer显性的被cpaint类调用,它提供方法来调整cpaint_node对象成为你所希望的正确的响应.
Backend: cpaint.register()
Frontend:1. cpaint.set_debug() 定义调试级别,用于查看前后台数据的传输
void set_debug ( mixed debuglevel )
    *-1 - no debugging at all
    * 0 - no debug messages, only errors.
    * 1 - debug most commonly needed information.
    * 2 - full debugging.
旧版本是:
  • false - equivalent to 0
  • true  - equivalent to 1
    当前也有效
2. cpaint.set_proxy_url()
void set_proxy_url ( string proxy_url )
      defines the URL of the proxy script,
      Assigns the URL to the CPAINT proxy script on your local server.
3. cpaint.set_transfer_mode() 设置http传递数据的类型(GET|POST)
void set_transfer_mode ( string transfer_mode )
4. cpaint.set_async() 是否使用异步传输,(true|false)
void set_async ( boolean asynchronous )
5. cpaint.set_response_type() 返回文件类型
void set_response_type ( string response_type )
  • E4X will return the XML from the backend as Javascript XML() object and thus allowing E4X notation. Supported by Firefox 1.5 only!
  • JSON
    will return the data structure from the backend as JSON dataset. Note
    that class methods will not be part of the response, only the data.
  • OBJECT
    will return XML as well but in this case CPAINT will generate a
    JavaScript object structure for you and return this to the callback
    function.
  • TEXT will return a plaintext response.
  • XML will return a JavaScript XMLHttpObject. This can be traversed via standard DOM functions.
6. cpaint.set_persistent_connection() 定义是否使用持久连接
void set_persistent_connection ( boolean persistance )
如果为真,则一个单独的持久连接对象将被CPAINT使用
7. cpaint.set_use_cpaint_api() 定义是否将CPAINT变量通过GET和POST到后台,以别的文件或框架.
void set_use_cpaint_api ( boolean cpaint_api )
8. cpaint.call() 触发后台运行CPAINT
void call ( string url, string remote_method, function callback_function [, mixed args [, mixed ...]] )
9.cpaint.capable 测定浏览器是否支持ajax
boolean capable
Class cpaint_result_object
      This is the basic prototype for a cpaint node object.
Description
If you have configured CPAINT with cpaint.set_response_type('object') - which is also the default configuration - then your callback function will receive an object of class cpaint_result_object as response.
For all other response types this object is irrelevant!
This object represents the parsed content of the response from the CPAINT backend. The original response was XML but has been parsed by cpaint_transformer.object_conversion.
Via the available methods the various subnodes and attributes can be retrieved.
Textdata contained in this node can be retrieved directly via object.data.
Subnodes of the same name can be traversed and accessed directly via array object.subnodename.
Attributes can not be retrieved directly to avoid naming collisions with subnodes. Use object.get_attribute() instead.
1. cpaint_result_object.find_item_by_type() 返回一个子节点和给定的类型和id
object find_item_by_type ( string type, string id )
string type  The type of the subnode. Equivalent to the XML tag name.
string id The id of the subnode. Equivalent to the XML tag names id attribute.
Description
   
      This method exists to be able to retrieve a single well-known item with a given id directly.
   
   
      Subnodes of identical type are always available as array object.type
      but we would have to iterate through this array and test subnode.get_attribute('id') until we find the
      correct subnode without this method.
2. cpaint_result_object.set_attribute() Assigns a new value to an attribute of a cpaint_result_object node.
void set_attribute ( string name, mixed value )
string name Name of the attribute where to set the value.
ixed value  Value to assign to the attribute. Note that the value must be a scalar.
Description
   
      This method exists merely for consistency reasons. We felt like you as developer should have the opportunity to
      change the values and attributes of a CPAINT response as your application sees fit, and thus eliminating the need
      for local variables which would only waste memory without an additional benefit.
   
3. cpaint_result_object.get_attribute() 返回给定属性的值
tring get_attribute ( string name )
string name Name of the attribute to retrieve the value for. Node attributes reflect XML tag attributes.
Description
With the freedom to assign arbitrary attributes to a result node via cpaint.set_attribute() in the backend it became necessary to provide a method in the frontend as well for reading the attributes.
This method will take care of proper unescaping automatically.
               
               
               
               
               
               
               
               
               
               
               
               
               
4.cpaint_result_object.data   响应节点的内容(Contains the text content of a response node.)
mixed data
Textual data of a response node that you have assigned in the backend via cpaint_node.set_data() can not be retrieved by get_attribute().
The property data is reserved for that.
               
               

相关阅读 更多 +
排行榜 更多 +
开心动动脑安卓版 v1.0 手机版

开心动动脑安卓版 v1.0 手机版

休闲益智 下载
不良人破局手游下载

不良人破局手游下载

角色扮演 下载
云海之下手游下载

云海之下手游下载

角色扮演 下载