Twitter over capacity

Posted: 23rd May 2011 by Grant Perry in Business, Industry, Infrastructure

Who would have thought a website with such significant infrastructure behind it could ever reach capacity… Something quite big must be happening somewhere in the world! Or maybe it’s just all of America talking about one of Operah’s final shows….


Finally easy Android UI prototyping…

Posted: 3rd February 2011 by Grant Perry in Android, Mobile
Tags: , , , , ,

For some time I’ve been looking for an easy tool to do some basic Android interface prototyping with. There are plenty of resources out there with PSD’s of ‘Androidie’ stuff… but nothing I found was quick and easy to use! Until now…

Some of you may have heard of Pencil if you use Firefox. It’s a neat little Add-On which does UI prototyping… But their site never had any stencils I found useful… However it seems someone been hard at work because there are some Android Pencil stencils available here….

Android Prototyping with Pencil


Android Market’s new website

Posted: 2nd February 2011 by Grant Perry in Uncategorized

Android Market now has it’s very own website for browsing applications. I still think Appbrain is a more useful site, but glad to see an official one finally!

One good feature though is after you’ve signed in you can access “My Market” which shows you a list of applications you’ve downloaded, or purchased. Great for if you’ve had to remove some purchased stuff to recover space at one point, or got a new phone!

Also once your phone is registered, and you’re logged in you can install applications from the site…

Android Market Site Screenshot


Googles Android Honeycomb Event Video (2 Feb 11)

Posted: 2nd February 2011 by Grant Perry in Android, Mobile



Earlier this year Google acquired BumpTop a 3D interactive touch user interface (I could have used more adjectives!).

Here’s hoping we see some of this in the Andriod 3 release rumoured to be in the 4th Quarter of 2010.

This UI alone would make me go out an buy an Andriod tablet. Who doesn’t love playing with cool toys? Even if you can’t justify your purchase…


New leader, but the same internet filter

Posted: 6th July 2010 by Grant Perry in Industry
Tags: , , ,

See Gillard backs internet filter

Thanks for wasting our money Gillard and Conroy… 705,000 results for a search “hack internet filter”… Why spend billions waving the Child Pornography flag when any police officer will tell you they’re not traded through websites but through technologies the Conroy’s filter can’t filter… Not to mention it’s easy to circumvent, and completely legal too according to Conroy from articles I’ve read.

Would you wast money on building a barbed-wire fence on 1 side of your property? Is it for looks? Is it suppose to gain votes? Maybe it would if you didn’t advertise you couldn’t fully fence the yard so people can walk around it. Or perhaps Conroy and Gillard take us for idiots? “Oh my children are safe now we have a filter, praise the lord, amen…”, “Luckily kids theses days aren’t smart enough to get around that…” (sarcasm)

Surely everyone else has noticed Conroy is looking after too conflicting projects too.. maybe he hasn’t yet? I mean the National Broadband Network (faster internet) and the Internet Filter (slower internet).. maybe after spending billions on both projects we might just come out the same as we started? Just a little be less money in the wallet to spend on more important things.


Apples denies iphone owners flash still

Posted: 1st April 2010 by Grant Perry in iPhone
Tags: , , ,

Adobe makes it quite clear Apple is not letting us iPhone owners choose what software we want to use.. So much for ownership when your limited by the company as to what they what you to do with the device you worked hard to buy! Imagine buying a car then being told where your allowed to drove it…



I’ll introduce this topic with a warning – This article doesn’t show you how to completely reorder your entire Navigation, it does however show you how you could populate a new container from an existing one and reorder it.

Zend Navigation currently doesn’t allow you to nominate a default Navigation Container class. So while we could extend the Zend_Navigation_Container creating our own customised one, you’d almost have to duplicate the code for the Zend Page and Zend Container classes to do a thorough job, as they both call each other – so won’t know to use your new one.

My goal was to achieve:

  • a container of all pages in my navigation configuration (ignoring hierarchy)
  • exclude pages that had sub pages (so I only had the leaves on the branch so to speak)
  • order these pages by a date set for each page in the nav configuration

Step 1 – Add dates to Navigation configuration

You can add new properties to Zend Navigation Pages without needing to do anything. See my “dateadded” in the example below on some pages.

                    <security>
                        <label>Security</label>
                        <module>computers</module>
                        <controller>security</controller>
                        <action>index</action>
                        <pages>
		                    <password>
		                        <label>Password generator</label>
		                        <module>computers</module>
		                        <controller>security</controller>
		                        <action>password-generator</action>
		                        <dateadded>01/08/2009</dateadded>
		                    </password>
                            <encrypt>
		                        <label>Hash generator</label>
		                        <title>Hash generator (string encryption)</title>
		                        <module>computers</module>
		                        <controller>security</controller>
		                        <action>encrypt</action>
		                        <dateadded>25/08/2009</dateadded>
		                    </encrypt>
		                </pages>
                    </security>

Step 2 – Create a custom container type

By creating a custom container extending Zend_Navigation_Container we can add our own sorting function. The trick of this is converting the dates to the linux time stamp i.e. number of seconds since 1 January 1970. This is also a logical place to but build a function to extract lowest level pages from another container. This one class services all three of my requirements.

class Utilitiesman_Navigation_Container_Utilities extends Zend_Navigation_Container
{
	public function addLowestPages($page) {
		$iterator = new RecursiveIteratorIterator($page,RecursiveIteratorIterator::SELF_FIRST);
		foreach ($iterator as $page) {
			// don't add page if it has children
			if(!$page->hasPages()) {
				$lowestPages[] = $page;
			}
		}
		$this->addPages($lowestPages);
	}
 
    public function sortByDate($property = 'dateadded')
    {
        $newIndex = array();
        $index = 0;
 
        foreach ($this->_pages as $hash => $page) {
            $pageDate = $page->get($property);
            if(Zend_Date::isDate($pageDate)) {
                $date = new Zend_Date($pageDate);
                $timestamp = $date->getTimestamp();
                $newIndex[$hash] = $timestamp;                
            } else {
                // there wasn't a valid date for this page, use an incremental number start at 0
                $newIndex[$hash] = $index;
                $index++;
            }
        }
 
        //sort the array using those timestamp versions of the dates
        arsort($newIndex);
        $this->_index = $newIndex;
        $this->_dirtyIndex = false; // flag index as clean - prevent default sort
    }
 
}

Step 3 – Call it and render the result

This is all done within the context of a view script (the layout in my case) I should mention:

$containerByDate = new Utilitiesman_Navigation_Container_Utilities();
$rootPage = current($this->navigation()->getContainer()->getPages());
$containerByDate->addLowestPages($rootPage);
$containerByDate->sortByDate();
echo $this->navigation()->menu()->render($containerByDate);

To see a cool example of this in action check out the calculator section of my utilities man website, or any section mind you.

utilities man - calculators

My implementation is a little more complex than this though, I’m using a partial view script for the menu and I’m also only displaying pages under the section your on.



Part 3: Implementing jsTree which uses jQuery (optional javascript expand/collapse)

This is a completely optional step in this series and really has nothing to do with Zend Framework because by this based on the client side we have all the HTML we need.

What we’ll be doing is setting up jsTree a jQuery tree component that can do much more than we’ll be using it for, it’s probably overkill but the best I came across when I was looking on this occasion.

You need jQuery:

$this->headScript()->appendFile($this->baseUrl . '/scripts/jquery-1.3.2.min.js', 'text/javascript');

Setup the jsTree javascript and css files if $nav2Container is set (see Part 2)

// append nav2 menu components if $activeContainer is set for the menu
if(isset($nav2Container)) {
    $this->headScript()->appendFile($this->baseUrl . '/scripts/jstree/css.js', 'text/javascript');
    $this->headScript()->appendFile($this->baseUrl . '/scripts/jstree/tree_component.min.js', 'text/javascript');
    $this->headLink()->appendStylesheet($this->baseUrl . '/scripts/jstree/tree_component.css', 'screen');
}

Render the Style and Script files we setup earlier:

        echo $this->headStyle() . "\n";
        echo $this->headScript() . "\n";

Some of this code below is a repeat from previous parts but its better to see this all in context. I’ve added a couple bit of JavaScript to achieve the following:

< ?php
        	// render nav2 container and menu if not on the homepage
        	if(isset($nav2Container)) {
        ?>
        <div id="nav2Container">
        	< ?php 
        		$this->navigation()->menu()->setMinDepth(null)->setMaxDepth(null);
        		echo $this->navigation()->menu()->renderMenu($nav2Container,array('ulClass' => 'nav2'));
        	?>
        	<script type="text/javascript">
        	$(function () {
        			// setup each active <li> with an id
        			var $active_li = $(".nav2 li.active");
        			var $active_li_id = new Array();
            		for( var i = 0, n = $active_li.length;  i < n;  ++i ) {
                		var $element = $active_li[i];
                		$active_li_id[i] = "nav2_active_" + i;
                		$($element).attr("id", $active_li_id[i]);
            		};
        			// configure and initialise 
        			$(".nav2").tree({
              			data  : {type : "predefined"},
            	  		opened : $active_li_id,
        	      		path : "<?php echo $this->baseUrl . '/scripts/jstree/'; ?>",
              			ui : {theme_name : "toolbox"},
        	      		rules : {   
                			metadata : "mdata",
                			use_inline : true
              			}
        			});
        		});
        	</li></script>
        </div>
        < ?php
        	}
        ?>

I’m using version 0.9.8 of jsTree but I’m looking forward to version 0.9.9 which will apparently alleviate some of my design/performance concerns, as the script loads this default theme and then the custom theme, rather than just the custom theme.

If I’ve missed anything and this doesn’t work, please let me know!



Part 2: Rendering the sub menus (relevant to the active tab).

This is where we employ another trick because the Zend_Navigation menu view helper does provide an option to render the active menu, but it is meant literally not the active branch of the menu like we’re trying to achieve.

In the layout we need to get the root level pages then we assume the 1st one is Home and root of all other navigation items. After this we loop through the pages below Home to find the active one and set this as the $nav2Container which we’ll use next.

layout.phtml

// find the active page/container under the rootPage (Home) for nav2 menu
$rootPage = current($this->navigation()->getContainer()->getPages());
$pages = $rootPage->getPages();
foreach($pages as $page) { 
	if($page->isActive(true)) { 
		$nav2Container = $page; 
	}
}

Now that we know what the root of this sub menu should be we can use the helpers to render it (this is also in your layout file).

if(isset($nav2Container)) {
    echo $this->navigation()->menu()->renderMenu($nav2Container,array('ulClass' => 'nav2'));
};