Wednesday, June 1, 2011

How to add the Google Plus One Button to your Joomla 1.5 website

New update available, read below.

Introduction

I wrote a little Module for Joomla 1.5 that supports the new Google Plus One Button for your Joomla Website without working in the code or change anything in the template.

Download for Joomla 1.6

Here you can find the Download and Documentation for the Google +1 Button Module for Joomla 1.6.

Changelog/Latest Version

Joomla 1.5, Version 1.1, released June 10 2011

  • show total +1 counter ON/OFF beside the +1 Button
  • set a target URL for the +1 Button or keep the default (the page the button is embedded)

Joomla 1.5, Version 1.0, released June 02 2011

  • change size of the Google +1 Button, small, medium, standard, tall
  • add custom CSS with the +1 Button

Downloading the Extension

You can download it at the Link below.

Download v1.1 Joomla 1.5.x

Or check out the official Joomla Extension Website for more infos.

Example


Here is an example on how the Google Plus One Joomla Module looks in action:
Flopwatch.org

Installation

If you have never installed the Google Plus One module before go straight to "Install the new Version" otherwise make sure you uninstall the old version first.

Uninstall the old Version

1. Go to your Joomla Admin area.

2. Go to Extensions > Install/Uninstall.

3. Go to Modules.

4. Find and select the entry "mod_j_google_plus_one".

6. Click Uninstall.

7. Done.

Install the new Version

1. Download the Module from the Link above.

2. Go to your Joomla Admin area.

3. Go to Extensions > Install/Uninstall.

4. Go to Upload Package File and click "Choose File".

5. After selecting the mod_j_google_plus_one_1.0.zip from your harddrive, click "Upload File & Install".

6. Go into the Module under Extensions > Modules .

7. Enable the Module and disable the Title.

8. Select the position and size of the button.

9. Save and you are done.


More about the Google +1 Button in a Google Video






Wednesday, May 25, 2011

Checkout the all new Hattrick iPhone App - HT-SmartViewer

Earlier this year the Lite version was released and now there is Full version of the HT-SmartViewer. The App is written for iPhone it does work on iPad as well though.


The App is still free of charge and comes with tons of new stuff. Below are links to the articles that write about the features.

1. HT-SmartViewer The Home Screen/Social Media
2. HT-SmartViewer League Infos Feature
3. HT-SmartViewer Match Data Feature
4. HT-SmartViewer Match Stats Feature

The App Homepage is here: HT-SmartViewer Home. The App can be downloaded directly from the Apple AppStore here: HT-SmartViewer in the AppStore.




Based on user feedback and our own ideas the App will be extendend with new modules like conference, team and youth team infos, national team etc.

Tuesday, May 10, 2011

Objective C/Xcode 4: Check at runtime whether iOS device supports multitasking

Introduction


When I was recently in search for a code snippet that tells me whether the iOS device that the code is running does support Multitasking I quickly found some answers. All the answers seemed to be missing something though.

So below the solution I came up with, that satisfies all my requirements to check for multitasking of my iPhone/iPad/iPod device at runtime.

Difference between multitasking support of the SDK version and of the device version


Since version 4.0 iOS supports multitasking. Read more about it in this interesting article: Understanding iOS 4 Backgrounding and Delegate Messaging.

Even though you have iOS 4.x on your iPhone 3G it doesn't support multitasking. Multitasking is supported from iPhone 3GS and iPod touch G3 (both released in 2009) but not previous generations like iPhone 2G or 3G due to hardware limitations. Read more here: Apple announces multitasking for iPhone OS 4

The Code

//get the current device object
UIDevice* device = [UIDevice currentDevice];

//check if the currently running iOS knows the isMultitaskingSupport message (method)
if ([device respondsToSelector:@selector(isMultitaskingSupported)]){
        
        //check if the current device does actually support multitasking
        if ([device isMultitaskingSupported]) {
            //do some multitasking stuff

        } else {
            //deal with the lack of multitasking 

        }
        
    } else {
        //deal with the lack of multitasking 
    }

Wednesday, May 4, 2011

Bugzilla and Gmail: Send mail notifications/alerts via Gmail

Bugzilla is an Issue Tracking System that can send email notifications to its members. Most important Bugzilla sends an Email to the bug reporter or assignee of a bug. Bugzilla does support SMTP to send email notifications. That can be set when you are logged in as an administrator under Administration > Parameters > Email.

If you want to configure Bugzilla to use Gmail you have to consider that Gmail doesn't use standard SMTP, Gmail is using SMTP with TLS. I tried this tutorial BugZilla alerts using GMAIL, but I couldn't get it running and I found it somewhat confusing.

So I digged a little deeper and came up with my own more easy solution using Email::Send::Gmail rather than Email::Send::SMTP::TLS as described in the other tutorial. The steps are done with Bugzilla running on Apache2.2 Server with a Debian Linux OS. The instructions should be similar for other Linux distributions like Ubuntu, Fedora or RedHat Linux. Be awate if you run Bugzilla on a Windows Server especially the folder structure is different.

Install the Email-Send-Gmail package for Pearl


If you have Bugzilla installed and running then you have Pearl installed properly. Start the pearl command line.
# perl -MCPAN -e shell
Run the install package command for Email-Send-Gmail.
cpan[1]> install Email::Send::Gmail
Confirm all questions with 'yes'.
If everything is done leave the command line.
cpan[2]> quit

Optional Fix: Warning (usually harmless): 'YAML' not installed...


I fixed that by entering the below command in the regular command line:
# sudo apt-get install libnet-ldap-perl

Confirm Email-Send-Gmail was installed properly


Login as administrator into your Bugzilla and go to Administration > Parameters > Email.
You should be able to select an entry called "Gmail". Select it and save the changes for now.

Change Mailer.pm


Now we need to change the Bugzilla Mailer.pm to pass on the right parameters when sending emails via the new pearl package.

Go to your Bugzilla root folder on your server. For me that is /var/www/bugzilla.
# cd /var/www/bugzilla
In the subfolder of your Bugzilla root is another folder called Bugzilla. In this folder the Mailer.pm is located. Open it with the editor of your choice, e.g. vim or nano.

# nano Bugzilla/Mailer.pm

After the last line that starts with use enter:
use Email::Send::Gmail;
use Email::Simple::Creator;

The line that says:
if ($method eq "SMTP"){
change to:
if ($method eq "SMTP" || $method eq "Gmail") {
Save your settings and you are done here.

Configure Bugzilla's Email settings


Now again as an administrator go back to Administration > Parameters > Email in your Bugzilla.

mailfrom:
username@gmail.com or username@your_domain.com (if you use your own domain via Google Applications)

smtpserver:
smtp.gmail.com

smtp_username:
username@gmail.com or username@your_domain.com (if you use your own domain via Google Applications)

smtp_password:
your Gmail password

smtp_debug:
You might want to turn on debug to see if sending mails is working. if not you should get a debug message that should help you better narrowing the error down. When everything is working you can turn debug off.

Save your changes and you are good to go. Let me know if you run into problems.

Friday, April 29, 2011

Xcode4/CoraData: Using LIKE to search SQLite Table - "String starts with"

Problem


I recently had a task where a UITableView should suggest autocomplete for a word I started to type into a UISearchBar/Search Display Controller.

From the top of my head I came up with the SQL query that I wanted to use:

SELECT string FROM table WHERE string LIKE 'S%';

This query should return all the strings that start with capital S.

Solution


For a NSPredicate the query has to look like this:

NSString *query = [NSString stringWithFormat:@"String LIKE '%@%%'", startOfString];

Most important here is that the percent sign needs to be escaped with another percent sign (%%).

Friday, April 15, 2011

Xcode4: Set Company/Organization Name for specific Projects

Another thing that changed in Xcode 4 is how to tell Xcode to use a certain Organization name instead of the default "__MyCompanyName__" or the company name that is tight to your Mac user account.

Most prominent this value shows up in the comment copyright header when you create a new file in Xcode4.

1. Click on your project root in the Project Navigator on the left.


2. Enable your Utilities view on the right while the project root is marked.


3. Select the File Inspector. To make sure you are in the right location, the Identity should display your Project Name.


4. Under Project Document is a text field called Organization. Enter here the Organization name you want to show up for all your new files that get generated in this project.


That's it. Let me know if you have any problems or comments.

Sunday, April 10, 2011

Objective C: Adding an Enter/Search Button to Number Pad on iPhone Apps

In my Xcode projects where I needed a button on the Number Pad to initiate the intended action I used this tutorial: UIKeyboardTypeNumberPad and missing return key.

I also implemented the updates described in the Internet that make the hack compatible with either iOS version, below 3.2 and above, including iOS 4, iOS 4.1, iOS 4.2 and iOS 4.3.

Another improvement compared to the tutorial is that I put the image in the Background of the Button and use a Label in the foreground to be able to use any Label I want and make it localizable.




Below are the steps from the above website with my additions to accomplish the above features:

Create and Add the button images to your project


The button will be placed on the number pad in your iPhone or iPad App. To make it look good the button should look like the other number pad buttons when it gets clicked and when not. That means that the button has to states.

I modified a button from number pad to look like the other buttons. You can use them in your project if you want.



Call them buttonUp.png and buttonDown.png or whatever you want and copy them in your xcode project.

Prepare your ViewController Header (.h)


Make sure you have set your keyboard as the delegate for the UILabel that uses the Keyboard.

in ExampleViewController.h:
@interface ExampleViewController : UIViewController {
 UITextField *textField;
}
...
@property (nonatomic, retain) IBOutlet UITextField *textField;
...
- (void)addButtonToKeyboard;
- (void)keyboardWillShow:(NSNotification *)note;
- (void)keyboardDidShow:(NSNotification *)note;
- (void)buttonClicked:(id)sender;
@end

Prepare your ViewController (.m)


- (void)viewDidLoad {
    [super viewDidLoad];
...
// add observer for the respective notifications (depending on the os version)
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];     
    } else {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    }
...
}

- (void) viewWillDisappear:(BOOL)animated{
 [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)addButtonToKeyboard {  
    // create custom button
    UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeCustom];
    yourButton.frame = CGRectMake(0, 163, 105, 53);
    yourButton.adjustsImageWhenHighlighted = NO;
    //set font button size and type
    yourButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
    
    //set the label text of the button when its not pushed 
    [yourButton setTitle:@"SEARCH" forState:UIControlStateNormal];
    //set the color of the label text of the button when its not pushed
    [yourButton setTitleColor:[UIColor colorWithRed:0.302f green:0.33f blue:0.384f alpha:1.0f] forState:UIControlStateNormal];
    //set the background image of the button when its not pushed
    [yourButton setBackgroundImage:[UIImage imageNamed:@"buttonUp.png"] forState:UIControlStateNormal];

    //set the label text of the button when its pushed
    [yourButton setTitle:@"SEARCH" forState:UIControlStateHighlighted];
    //set the color of the label text of the button when its pushed
    [yourButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    //set the background image of the button when its pushed
    [yourButton setBackgroundImage:[UIImage imageNamed:@"buttonDown.png"] forState:UIControlStateHighlighted];
    
    [yourButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
 
    // locate keyboard view
    UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
    UIView* keyboard;
    for(int i=0; i<[tempWindow.subviews count]; i++) {
        keyboard = [tempWindow.subviews objectAtIndex:i];
        // keyboard found, add the button
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
            if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
                [keyboard addSubview:yourButton];
        } else {
            if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
                [keyboard addSubview:yourButton];
        }
    }
}

- (void)keyboardWillShow:(NSNotification *)note {
    // if clause is just an additional precaution, you could also dismiss it
    if ([[[UIDevice currentDevice] systemVersion] floatValue] < 3.2) {
        [self addButtonToKeyboard];
    }
}

- (void)keyboardDidShow:(NSNotification *)note {
    // if clause is just an additional precaution, you could also dismiss it
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
        [self addButtonToKeyboard];
    }
}

- (void)buttonClicked:(id)sender{
        //lets the number pad disappear after your clicked your custom button
 [self.textField resignFirstResponder];
 ...
        //do here what you want after the button was clicked
}


Troubleshooting

So far I came across only one problem and that was that my picture where not added properly to my project. Therefore clicking worked, but the buttons didn't show up. You can test this by adding a UIImage view manually to your NIB and see if the image shows in the list of images that you could set.

Let me know if you have more issues or suggestions.