Blog I've always got something to say...

Feeds

RSS Feed Twitter Feed




Photostream

I'm watching you... Mr. Robin Now we're cooking! Same shot as before but closer! Added logs not for effect but to really dry them out Hot hot hot!

PHP Twitter OAuth Library

September

Thursday

22

Anyone looking for a quick, easy and well documented Twitter OAuth Library, I have to recommend tmhOAuth by Matt Harris.

After creating an App at Twitter and successful authorisation, I was posting tweets within minutes.  The library requires CURL and hash_hmac, but your host should be providing this as standard.

Oh, and it's hosted at GitHub too.  Enough said!


Firefox 6 with 1Password

August

Wednesday

17

For those of you whose lives depend on the the great application 1Password, you may have noticed that if your primary browser is Firefox, and you upgraded to the latest recent version 6, then the 1Password extension stopped working.

Thankfully, the great folk at Agile have already released an update/replacement extension, and normal service has ben resumed!

Here's the link to the extension.


CodeIgniter Controller Names with Dashes

June

Friday

17

I prefer to use dashes with my CI2 controller names, so the below solves that problem.

Simply create a file called 'MY_Router.php' and place it in the '/application/core/' folder.

class MY_Router extends CI_Router
{
function _set_request($segments = array()) {
parent::_set_request(str_replace('-', '_', $segments));
}
}


CodeIgniter Message Library

April

Wednesday

27

The very useful and simple to use Message Library written by Adam Jackett, allowing you to show different types of messages in an application.


Usage:
$this->load->library('message');

Setting a Message:
// an error
$this->message->set('You forgot a required field.', 'error');

// a notice after a redirect
$this->message->set('Your account will expire in 5 days.', 'notice', TRUE);

// a success message after a redirect in a specific group
$this->message->set('Your subscription has been received.', 'success', TRUE, 'newsletter');

Retreiving Messages:
$this->message->display();

Library:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
* Message:: a library for giving feedback to the user
*
* @author  Adam Jackett
* @url http://www.darkhousemedia.com/
* @version 2.1
*/

class CI_Message {

var $CI;
var $messages = array();
var $wrapper = array('', '');

function CI_Message($config){    
$this->CI =& get_instance();        
$this->CI->load->library('session');

if($this->CI->session->flashdata('_messages')) $this->messages = $this->CI->session->flashdata('_messages');
if(isset($config['wrapper'])) $this->wrapper = $config['wrapper'];
}

function set($message, $type, $flash=FALSE, $group=FALSE){
if(!is_array($message)) $message = array($message);
foreach($message as $msg){
$obj = new stdClass();
$obj->message = $msg;
$obj->type = $type;
$obj->flash = $flash;
$obj->group = $group;
$this->messages[] = $obj;
}

$flash_messages = array();
foreach($this->messages as $msg){
if($msg->flash) $flash_messages[] = $msg;
}
if(count($flash_messages)) $this->CI->session->set_flashdata('_messages', $flash_messages);
}

function get($type=FALSE, $group=FALSE){
$output = array();
if(count($this->messages)){            
foreach($this->messages as $msg){
if($type !== FALSE){
$output[] = $msg->message;
} else {
if(!isset($output[$msg->type])) $output[$msg->type] = array();
$output[$msg->type][] = $msg->message;
}
}
}
return $output;
}

function display($group=FALSE, $wrapper=FALSE){
if(count($this->messages)){
$output = $this->get(FALSE, $group);
echo ($wrapper !== FALSE ? $wrapper[0] : $this->wrapper[0])."\r\n";
foreach($output as $type => $messages){
echo '<div class="message-'.$type.'">'."\r\n";
foreach($messages as $msg){
echo '<p>'.$msg.'</p>'."\r\n";
}
echo '</div>'."\r\n";
}
echo ($wrapper !== FALSE ? $wrapper[1] : $this->wrapper[1])."\r\n";
}        
}

}

 

 


Mozilla Firefox 4 Released

March

Wednesday

23

Mozilla's faster and more streamlined browser has arrived!

Due to the vast array of features available it was delay several times, but now, Mozilla has released it's fourth generation Firefox 4.

Firefox comes with several big changes and one of the most notable is the user interface giving it a streamlined feel, by moving the tabs to the top, removing the status bar at the bottom and now the URL preview appears just above the old status, much like [ahem] Google Chrome.

Firefox also offers huge speed improvements when it comes to rendering and JavaScript engine, apparently up to 6x times faster!

[update]: If anyone has trouble with 1Password (ie the button does nothing), just completely uninstall via 1Password, restart Firefox, and then install again.  Worked for me!