I would like to start by saying, i like 2.4 series the more i code in it, you can do everything for once.. My favorite is the enumerator support. Enumerator are even faster than integers in database design. XOOPS 2.4 series has support for Enumerator, Decimal, Floating Point, and Unicode handling now (check /kernel/object.php). The unicode handling is very import for IDN's - Internationalised Domain Names that is domains written in greek, arabic, chinese, spanish and other languages can be handled by XOBJ_DTYPE_UNICODE_URL. It is really good I am witting and application for Peak Backup LLC at the moment for XOOPS that utilises JQuery for form and form checking and calculationg (Using JSON). ie code like:
<script type="text/javascript" language="javascript">
function doJSONCheckUsername() {
var params = new Array();
var ram_name = document.getElementById('ram_name').value;
var ram_name_disabled = document.getElementById('ram_name').disabled;
var ram_password = document.getElementById('ram_password').value;
var ram_password_confirm = document.getElementById('ram_password_confirm').value;
var ram_email = document.getElementById('ram_email').value;
var ram_alias = document.getElementById('ram_alias').value;
$.getJSON("<{$xoops_url}>/modules/acctmgr/dojsonuser.php?ram_name=" + ram_name + "&ram_name_disabled=" +ram_name_disabled + "&ram_password=" + ram_password + "&ram_password_confirm=" + ram_password_confirm + "&ram_email=" + ram_email + "&ram_alias=" + ram_alias, params,refreshformdesc);
}
function refreshformdesc(data){
$.each(data, function(i, n){
switch(i){
case 'innerhtml':
$.each(n, function(y, k){
document.getElementById(y).innerHTML = k;
});
break;
case 'disable':
$.each(n, function(y, k){
document.getElementById(y).disabled = k;
});
break;
case 'checked':
$.each(n, function(y, k){
document.getElementById(y).checked = k;
});
break;
}
});
}
script><body onLoad="javascript:doJSONCheckUsername();" />
This Javascript allows me with a JSON PHP file to set any form elements in as much as I want from outputting an array based on the function I want it to perform in the java script: ie.
$values['innerhtml']['span_id'] = '';
When this object is passed back to the application interface it will set a span with the ID of
span_id with an image.. Incorporating this form is the method in XOOPS of using JQuery with forms
if ($user_id>0)
$sform = new XoopsThemeForm(_ATM_FRM_EDITACCOUNT, 'account', $_SERVER['REQUEST_URI'], 'post');
else
$sform = new XoopsThemeForm(_ATM_FRM_NEWACCOUNT, 'account', $_SERVER['REQUEST_URI'], 'post');
$formobj = array();
$eletray = array();
if ($user_id==0) {
$formobj[0] = new XoopsFormText(_ATM_MF_ACCOUNT_USERNAME, 'ram_name', 65, 255, isset($_REQUEST['ram_name'])?$_REQUEST['ram_name']:$account->getVar('ram_name')); $formobj[0]->setExtra('onChange="javascript:doJSONCheckUsername();"');
} else {
$formobj[0] = new XoopsFormHidden('ram_name', isset($_REQUEST['ram_name'])?$_REQUEST['ram_name']:$account->getVar('ram_name'));
}
$formobj[1] = new XoopsFormPassword(_ATM_MF_ACCOUNT_PASSWORD, 'ram_password', 65, 255, isset($_REQUEST['ram_password'])?$_REQUEST['ram_password']:$account->getVar('ram_password'));
$formobj[1]->setExtra('onChange="javascript:doJSONCheckUsername();"');
$formobj[2] = new XoopsFormPassword(_ATM_MF_ACCOUNT_PASSWORD_CONFIRM, 'ram_password_confirm', 65, 255, isset($_REQUEST['ram_password_confirm'])?$_REQUEST['ram_password_confirm']:$account->getVar('ram_password'));
$formobj[2]->setExtra('onChange="javascript:doJSONCheckUsername();"');
$formobj[3] = new XoopsFormText(_ATM_MF_ACCOUNT_ALIAS, 'ram_alias', 65, 255, isset($_REQUEST['ram_alias'])?$_REQUEST['ram_alias']:$account->getVar('ram_alias'));
$formobj[3]->setExtra('onChange="javascript:doJSONCheckUsername();"');
$formobj[4] = new XoopsFormText(_ATM_MF_ACCOUNT_EMAIL, 'ram_email', 65, 255, isset($_REQUEST['ram_email'])?$_REQUEST['ram_email']:$account->getVar('ram_email'));
$formobj[4]->setExtra('onChange="javascript:doJSONCheckUsername();"');
$formobj[5] = new AcctmgrFormSelectServer(_ATM_MF_ACCOUNT_SERVER, 'ram_server_id', isset($_REQUEST['ram_server_id'])?$_REQUEST['ram_server_id']:$account->getVar('ram_server_id'),1 , false, false);
$formobj[5]->setExtra('onChange="javascript:doJSONCheckUsername();"');
// Needs to contain for ajax
$formobj[0]->setDescription(_ATM_MF_ACCOUNT_USERNAME_DESC);
$formobj[1]->setDescription(_ATM_MF_ACCOUNT_PASSWORD_DESC);
$formobj[2]->setDescription(_ATM_MF_ACCOUNT_PASSWORD_CONFIRM_DESC);
$formobj[3]->setDescription(_ATM_MF_ACCOUNT_ALIAS_DESC);
$formobj[4]->setDescription(_ATM_MF_ACCOUNT_EMAIL_DESC);
$formobj[5]->setDescription(_ATM_MF_ACCOUNT_SERVER_DESC);
The JSON I am using the pear class to generate, it should be xoopified in 2.5.0 but there are no extra systems at the moment.. the code looks like so for dojsonuser.php
include('../../mainfile.php');
include $GLOBALS['xoops']->path('/modules/acctmgr/include/JSON.php');
$json = new services_JSON();
$values = array();
$values['disable']['user_submit'] = '';
if (strlen($_REQUEST['ram_alias'])>0 && strpos($_REQUEST['ram_alias'],' ')>0) {
$values['innerhtml']['alias_desc'] = ' ';
if (strlen($values['disable']['user_submit'])==0) $values['disable']['user_submit'] = '';
} else {
$values['innerhtml']['alias_desc'] = '.XOOPS_URL.'/modules/acctmgr/images/invalidname.png" />';
$values['disable']['user_submit'] = 'disabled';
}
if (strlen($_REQUEST['ram_password'])>0 && $_REQUEST['ram_password']==$_REQUEST['ram_password_confirm'] ) {
$values['innerhtml']['password_desc'] = '.XOOPS_URL.'/modules/acctmgr/images/validpassword.png" />';
$values['innerhtml']['passconfirm_desc'] = '.XOOPS_URL.'/modules/acctmgr/images/validpassword.png" />';
if (strlen($values['disable']['user_submit'])==0) $values['disable']['user_submit'] = '';
} else {
$values['innerhtml']['password_desc'] = '.XOOPS_URL.'/modules/acctmgr/images/invalidpassword.png" />';
$values['innerhtml']['passconfirm_desc'] = '.XOOPS_URL.'/modules/acctmgr/images/invalidpassword.png" />';
$values['disable']['user_submit'] = 'disabled';
}
if (strlen($_REQUEST['ram_email'])>0 && (strpos($_REQUEST['ram_email'],'@')>0 && strpos($_REQUEST['ram_email'],'.',strpos($_REQUEST['ram_email'],'@')+1)>0)) {
$values['innerhtml']['email_desc'] = ' ';
if (strlen($values['disable']['user_submit'])==0) $values['disable']['user_submit'] = '';
} else {
$values['innerhtml']['email_desc'] = '.XOOPS_URL.'/modules/acctmgr/images/invalidemail.png" />';
$values['disable']['user_submit'] = 'disabled';
}
if (strlen($_REQUEST['ram_name_disabled'])>0)
{
$values['innerhtml']['username_desc'] = 'Uneditable';
if (strlen($values['disable']['user_submit'])==0) $values['disable']['user_submit'] = '';
} elseif (strlen($_REQUEST['ram_name'])>0) {
$account_handler =& xoops_getmodulehandler('account_master', 'acctmgr');
$criteria = new Criteria('ram_name', $_REQUEST['ram_name'], 'LIKE');
if ($account_handler->getCount($criteria))
{
$values['innerhtml']['username_desc'] = '.XOOPS_URL.'/modules/acctmgr/images/usernametaken.png" />';
$values['disable']['user_submit'] = 'disabled';
} else {
$values['innerhtml']['username_desc'] = '.XOOPS_URL.'/modules/acctmgr/images/availableusername.png" />';
if (strlen($values['disable']['user_submit'])==0) $values['disable']['user_submit'] = '';
}
} else {
$values['innerhtml']['username_desc'] = '.XOOPS_URL.'/modules/acctmgr/images/usernametaken.png" />';
$values['disable']['user_submit'] = 'disabled';
}
print $json->encode($values);
This application will only be commercially available it is for managing and billing with whmcs. Give the forms a go:
http://wishcraft.thruhere.net/peakbackup/modules/acctmgr/