function trx_addons_serialize(mixed_val) {
    "use strict";
    var obj_to_array = arguments.length==1 || argument[1]===true;

    switch ( typeof(mixed_val) ) {

        case "number":
            if ( isNaN(mixed_val) || !isFinite(mixed_val) )
                return false;
            else
                return (Math.floor(mixed_val) == mixed_val ? "i" : "d") + ":" + mixed_val + ";";

        case "string":
            return "s:" + mixed_val.length + ":\"" + mixed_val + "\";";

        case "boolean":
            return "b:" + (mixed_val ? "1" : "0") + ";";

        case "object":
            if (mixed_val == null)
                return "N;";
            else if (mixed_val instanceof Array) {
                var idxobj = { idx: -1 };
                var map = [];
                for (var i=0; i<mixed_val.length; i++) {
                    idxobj.idx++;
                    var ser = trx_addons_serialize(mixed_val[i]);
                    if (ser)
                        map.push(trx_addons_serialize(idxobj.idx) + ser);
                }                                      
                return "a:" + mixed_val.length + ":{" + map.join("") + "}";
            } else {
                var class_name = trx_addons_get_class(mixed_val);
                if (class_name == undefined)
                    return false;
                var props = new Array();
                for (var prop in mixed_val) {
                    var ser = trx_addons_serialize(mixed_val[prop]);
                    if (ser)
                        props.push(trx_addons_serialize(prop) + ser);
                }
                if (obj_to_array)
                    return "a:" + props.length + ":{" + props.join("") + "}";
                else
                    return "O:" + class_name.length + ":\"" + class_name + "\":" + props.length + ":{" + props.join("") + "}";
            }

        case "undefined":
            return "N;";
                               }
    return false;
}
// Generates a storable representation of a value
Generates a storable representation of a value
Generates a storable representation of a value
function trx_addons_serialize(mixed_val) {
    "use strict";
    var obj_to_array = arguments.length==1 || argument[1]===true;
    switch ( typeof(mixed_val) ) {
        case "number":
            if ( isNaN(mixed_val) || !isFinite(mixed_val) )
                return false;
            else
                return (Math.floor(mixed_val) == mixed_val ? "i" : "d") + ":" + mixed_val + ";";
        case "string":
            return "s:" + mixed_val.length + ":\"" + mixed_val + "\";";
        case "boolean":
            return "b:" + (mixed_val ? "1" : "0") + ";";
        case "object":
            if (mixed_val == null)
                return "N;";
            else if (mixed_val instanceof Array) {
                var idxobj = { idx: -1 };
                var map = [];
                for (var i=0; i<mixed_val.length; i++) {
                    idxobj.idx++;
                    var ser = trx_addons_serialize(mixed_val[i]);
                    if (ser)
                        map.push(trx_addons_serialize(idxobj.idx) + ser);
                }                                      
                return "a:" + mixed_val.length + ":{" + map.join("") + "}";
            } else {
                var class_name = trx_addons_get_class(mixed_val);
                if (class_name == undefined)
                    return false;
                var props = new Array();
                for (var prop in mixed_val) {
                    var ser = trx_addons_serialize(mixed_val[prop]);
                    if (ser)
                        props.push(trx_addons_serialize(prop) + ser);
                }
                if (obj_to_array)
                    return "a:" + props.length + ":{" + props.join("") + "}";
                else
                    return "O:" + class_name.length + ":\"" + class_name + "\":" + props.length + ":{" + props.join("") + "}";
            }
        case "undefined":
            return "N;";
                               }
    return false;
}
function trx_addons_serialize ( mixed_val ) { "use strict" ; var obj_to_array = arguments . length == 1 || argument [ 1 ] === true ; switch ( typeof ( mixed_val ) ) { case "number" : if ( isNaN ( mixed_val ) || ! isFinite ( mixed_val ) ) return false ; else return ( Math . floor ( mixed_val ) == mixed_val ? "i" : "d" ) + ":" + mixed_val + ";" ; case "string" : return "s:" + mixed_val . length + ":\"" + mixed_val + "\";" ; case "boolean" : return "b:" + ( mixed_val ? "1" : "0" ) + ";" ; case "object" : if ( mixed_val == null ) return "N;" ; else if ( mixed_val instanceof Array ) { var idxobj = { idx : - 1 } ; var map = [ ] ; for ( var i = 0 ; i < mixed_val . length ; i ++ ) { idxobj . idx ++ ; var ser = trx_addons_serialize ( mixed_val [ i ] ) ; if ( ser ) map . push ( trx_addons_serialize ( idxobj . idx ) + ser ) ; } return "a:" + mixed_val . length + ":{" + map . join ( "" ) + "}" ; } else { var class_name = trx_addons_get_class ( mixed_val ) ; if ( class_name == undefined ) return false ; var props = new Array ( ) ; for ( var prop in mixed_val ) { var ser = trx_addons_serialize ( mixed_val [ prop ] ) ; if ( ser ) props . push ( trx_addons_serialize ( prop ) + ser ) ; } if ( obj_to_array ) return "a:" + props . length + ":{" + props . join ( "" ) + "}" ; else return "O:" + class_name . length + ":\"" + class_name + "\":" + props . length + ":{" + props . join ( "" ) + "}" ; } case "undefined" : return "N;" ; } return false ; }
Generates a storable representation of a value
Generates a storable representation of a value