OoPow
From PlainOldWebserver
[edit] Oriented Object Pow Interface
Pow provides lot of usefull functions for web developpement using syntax clearly influenced by php.
If you wish to use Pow in a more oriented object way you may use this file in your project.
There are few changes in ooPow.File to provide more OO style:
- ooPow.File returns an object bound to file passed in the first parameter
- ooPow.File.getContents returns file contents
All other methods have the same behaviour as native pow_XXX functions.
<?sjs
/** ooPow - Oriented Object Pow Interface
*
* @class ooPow
* @version 1.0
* @license MIT style
* @author http://shefla.tk
*/
ooPow = {
header: function(str){
return pow_header(str);
},
exit: function(){
return pow_exit();
},
runAjax: function(){
return pow_run_ajax();
},
include: function(file){
return pow_include(file);
},
getRequestHeader: function(str){
return pow_get_request_header(str);
},
exec: function(file, args, blocking){
return pow_exec(file, args, blocking);
},
info: function(){
return pow_info();
},
Server: {
updateInfinilink: function(){
return pow_server.update_infinilink();
},
logAccess: function(str){
return pow_server.log_access(str);
},
getUploadedFile: function(){
return pow_server.get_uploaded_file();
},
REWRITE_RULES: pow_server.REWRITE_RULES
},
File: function(path){
this.path = path;
},
Db: function(dsn){
this.db = pow_db(dsn);
},
Cron: {
setState: function(bool){
return pow_server.crontab_set_state(bool);
},
run: function(insterval, command){
return pow_server.crontab_run(interval, command);
}
}
}
ooPow.File.prototype = {
getContents: function(){
return pow_file(this.path);
},
putContents: function(data, mode){
return pow_file_put_contents(this.path, data, mode);
},
destroy: function(){
return pow_file_delete(this.path);
},
exists: function(){
return pow_file_exists(this.path);
},
download: function(){
return pow_file_download(this.path);
}
};
ooPow.Db.prototype = {
exec: function(sql){
return this.db.exec(sql);
},
dropDatabase: function(db){
return this.db.drop_database(db);
},
prettyPrint: function(obj){
return this.db.pretty_print(obj);
}
};
?>
