Posted (Updated ) in Uncategorized

I’ve been frustrated for a while now at Chromes lack of a decent Amazon S3 extension. Firefox has S3Fox but the closest Chrome users come is S3 which only lets you browse and not modify the files in your buckets. Well that’s just changed!

Over the weekend I finally gathered up enough free time to add support for creation and deletion of files/buckets. While I was in there I made a few other modifications to improve performance and clean things up a bit.

Download the latest version (and the source: Github repo)

Adding a bucket
Adding a bucket
Deleting a bucket
Delete link when hovering over buckets
Adding files
Multi-select file browser for uploading files
Uploading Files
The uploading window
File delete
The confirmation you see when deleting files
Deleting a bucket with files in it
Error you see when attempting to delete a bucket with files in it

Read More »

Posted (Updated ) in PHP

In Kohana 2, html::script() and html::stylesheet() accepted an array or string as their first arguments. This allowed you to easily add multiple scripts and styles simultaneously without needing to write several lines of redundant code. Kohana 3 has removed this useful ability so I thought I’d write a very quick extension to add the feature back in. The following script adds HTML::scripts() and HTML::styles() (As Kohana 3 slightly renamed their functions to HTML::script() and HTML::style() respectively).

Simply add the following file html.php to your /classes directory:

<?php defined('SYSPATH') or die('No direct script access.');
 
class HTML extends Kohana_HTML {
	public static function scripts(array $scripts, $attributes=array(), $index = FALSE)
	{
		$response = '';
 
		//Data sanitisation
		$index = $index ? TRUE : false;
		if ( !is_array($attributes) ) $attributes = array();
 
		foreach ( $scripts as $script )
			$response .= html::script($script, $attributes, $index);
 
		return $response;
	}
 
	public static function styles(array $styles, $attributes=array(), $index = FALSE)
	{
		$response = '';
 
		//Data sanitisation
		$index = $index ? TRUE : false;
		if ( !is_array($attributes) ) $attributes = array();
 
		foreach ( $styles as $style )
			$response .= html::style($style, $attributes, $index);
 
		return $response;
	}
}

Download: html.php

Usage:

<?php
echo HTML::styles(array(
	'assets/css/reset',
	'assets/css/styles',
);
echo HTML::scripts(array(
	'assets/js/jquery',
	'assets/js/jquery.ui.all',
);
?>

Note: Both functions accept the latter 2 parameters available in Kohana 3 HTML::scripts() and HTML::styles(). If used, these arguments will be applied to every element in the first arguments array.

Read More »