How to get xForms on CMS 5 RC1 working with IE8

by roberto.vega 15. December 2009 10:51

To get xForms to work with IE8 compatible mode u need to change a function in xformedit.js.
U can find the file at /edit/ui/javascript/. Look then for this function:

function formPopulateForSubmit( oForm )
{
   fieldPropertiesHideAll();
   formContent.value = xFormControl.innerHTML;
   return true;
}

 

Replace it with this function instead:

function formPopulateForSubmit( oForm )
{
    fieldPropertiesHideAll();
    
    var cnt = xFormControl.innerHTML;
    var regExpInput = new RegExp(']+>');
    var inputTemp = regExpInput.exec(cnt);
    
    while (inputTemp != null) {
        var regExpType = new RegExp('type=text|type=radio|type=checkbox|type=submit');
        var typeTemp = regExpType.exec(inputTemp[0]);
        var type = (typeTemp != null && typeTemp.length > 0) ? typeTemp[0] : '';
        var str = inputTemp[0].replace(type, '');
      
        if (type == 'type=text') {
            type = '';
            var regExpGuid = new RegExp(' {[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}}');
            var guidTemp = regExpGuid.exec(str);
            if (guidTemp != null && guidTemp.length > 0)
                str = str.replace(guidTemp[0], '');
        } 
        else if (typeTemp == 'type=submit') {
            var regExpOnCLick = new RegExp('onclick=[^\f\n\r\t\v]+');
            var onCLickTemp = regExpOnCLick.exec(str);
            
            if (onCLickTemp != null && onCLickTemp.length > 0) {
                str = str.replace(onCLickTemp[0], '');
                type = onCLickTemp[0] + type;
            }
        }      
        
        str = str.replace('<INPUT', '<$MGL$ ' + type);
        cnt = cnt.replace(inputTemp[0], str);
        var inputTemp = regExpInput.exec(cnt);
    }
    
    while (cnt.indexOf('<$MGL$') != -1){
        cnt = cnt.replace('<$MGL$', '<INPUT');
    }
    
    formContent.value = cnt;
    return true;
}


 

Don't forget to empty IE8 cache and temporarily Internet files.

Tags: , , , ,

Development

Google Analytics API with Objective c, Part two

by roberto.vega 16. October 2009 15:45

Well it is time for part two. Part one was easy and the second part is easy as well.
Now that we got the authentication token we can get analtyics data.
The data we are getting is the accounts and profiles for analytics:

NSURL *urlAccount = [NSURL URLWithString:@"https://www.google.com/analytics/feeds/accounts/default"];

NSString* param = [NSString stringWithFormat:@"GoogleLogin auth=%@",authString]; 
NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:urlAccount];
[req setHTTPMethod:@"GET"];
[req addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[req setValue:param forHTTPHeaderField: @"Authorization"];
[req addValue:@"Authorization" forHTTPHeaderField:param];

NSHTTPURLResponse *res;
NSError *err;
NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&res error:&err];

[req release];
return data;

Finally u get a NSData. I personal use libxml2 for parsing the xml data and XPath queries. Check out http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html for more info :)

Tags: , ,

Development

Google Analytics API with Objective c, Part one

by roberto.vega 6. October 2009 13:37

Now that Google Analytics API is out and lot of people want to get access to the analytics data.
It is not to hard to retrieve the data. First thing that u need to do is access the Client Login and retrieve authentication token.
The easiest way to do this is:

NSString *post = [NSString stringWithFormat:@"accountType=GOOGLE&Email=%@&Passwd=%@&service=analytics&source=%@", email, password, source];

NSURL *url = [NSURL URLWithString:@"https://www.google.com/accounts/ClientLogin"];

NSMutableURLRequest *authRequest = [[NSMutableURLRequest alloc] initWithURL:url];
[authRequest setHTTPMethod:@"POST"];
[authRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[authRequest setHTTPBody:[post dataUsingEncoding:NSASCIIStringEncoding]];

NSHTTPURLResponse *authResponse;
NSError *authError;

NSData *receivedData = [NSURLConnection sendSynchronousRequest:authRequest returningResponse:&authResponse error:&authError];

NSString *authResponseData = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding];

NSArray *lines = [authResponseData componentsSeparatedByString:@"\n"];
NSMutableDictionary *token = [NSMutableDictionary dictionary];

for(NSString *s in lines)
{ 
   NSArray *kvpair = [s componentsSeparatedByString:@"="];
   if([kvpair count]>1)
      [token setObject:[kvpair objectAtIndex:1] forKey:[kvpair objectAtIndex:0]];
}

[authRequest release];
[authResponseData release];

return [token objectForKey:@"Auth"];

Well that's the first part. Part two is how to retrieve analytics data from Google Analytics API.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 2.5 Sweden License.


Welcome to the Dropit blog!

Here we, the people that work at Dropit, will write about stuff that interests us. For example web development, especially with .NET and EPiServer - but we'll also talk about other techniques that interest us, marketing on the web, social phenomenons, pop culture, games and software development in general.