Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am jamesmcfadden on github.
* I am jamesmcfdn (https://keybase.io/jamesmcfdn) on keybase.
* I have a public key whose fingerprint is 5FF5 AA62 EEE1 B318 F0DB EB9C FE76 D65B 78A1 9EE3
To claim this, I am signing this object:
@mcfdn
mcfdn / PluralHelper.php
Created October 7, 2012 14:30
Manage Singular and Plural Words
<?php
/**
* @author James McFadden <james@jamesmcfadden.co.uk>
*/
final class PluralHelper
{
private static $irregularPluralForms = array(
'alumnus' => 'alumni',
'analysis' => 'analyses',
'appendix' => 'appendices',
@mcfdn
mcfdn / App_Validate_Xml.php
Created October 9, 2012 12:05
Validate XML With Zend_Form
<?php
class App_Validate_Xml extends Zend_Validate_Abstract
{
const ERROR_MESSAGE = 'error';
public $xmlError;
protected $_messageVariables = array(
'xmlError' => 'xmlError'
);
@mcfdn
mcfdn / view.phtml
Created October 23, 2012 16:08
Jquery File Upload Partial
<form id="<?php echo $this->escape($this->form->getAttrib('id')); ?>" action="<?php echo $this->escape($this->form->getAction()); ?>" method="<?php echo $this->form->getMethod(); ?>">
<div class="fileupload-buttonbar">
<span class="fileinput-button">
<span>Add files...</span>
<?php echo $this->form->Photo; ?>
</span>
<?php echo $this->form->Start; ?>
<?php echo $this->form->Cancel; ?>
<?php echo $this->form->Delete; ?>
<div class="fileupload-progress fade">
@mcfdn
mcfdn / Upload.php
Created October 23, 2012 16:10
Form_Jquery_File_Upload
<?php
/**
* This is aimed for use with jQueryFileUpload
*
* @link https://github.com/blueimp/jQuery-File-Upload
* @author James McFadden <james@jamesmcfadden.co.uk>
*/
class Form_Jquery_File_Upload extends Form_Upload
{
function init()
@mcfdn
mcfdn / action.php
Created October 23, 2012 16:11
jQuery File Upload Return Json
$jsonArray = array();
foreach($photos as $i => $photo) {
$jsonArray[$i]['name'] = $photo->getName();
$jsonArray[$i]['size'] = $photo->getSize();
$jsonArray[$i]['url'] = $photo->getUrl();
$jsonArray[$i]['thumbnail_url'] = $photo->getThumbnailUrl();
$jsonArray[$i]['delete_url'] = 'delete-photo.php?id=' . $photo->getId();
}
echo json_encode($jsonArray);
@mcfdn
mcfdn / RenderTable.php
Created November 6, 2012 20:01
Table View Helper
<?php
/**
* @author James McFadden <james@jamesmcfadden.co.uk>
*/
class App_View_Helper_RenderTable extends Zend_View_Helper_Abstract
{
/**
* Generate and return the table HTML
*
* @param array $headerDataMap
@mcfdn
mcfdn / infowindow.php
Last active December 10, 2015 13:58
LiteMap documentation example 4
<?php
$map = new LiteMap_Container();
$map->setCenter(51.500152, -0.126236);
$locations = array(
'51.500152' => '-0.126236',
'51.512249182894756' => '-0.15815299440919262',
'51.52325165255695' => '-0.11283439089356762',
'51.47238304492127' => '-0.15883963991700512',
'51.49077068938746' => '-0.07232230593263012'
@mcfdn
mcfdn / index.php
Created January 3, 2013 14:33
LiteMap documentation example 1
<?php
$map = new LiteMap_Container();
$map->setCenter(51.500152, -0.126236);
?>
<head>
<?php echo $map->getJs(); ?>
</head>
<body>
<?php echo $map->render(); ?>
</body>
@mcfdn
mcfdn / marker.php
Created January 3, 2013 14:35
LiteMap documentation example 2
<?php
$map = new LiteMap_Container();
$map->setCenter(51.500152, -0.126236);
$locations = array(
'51.500152' => '-0.126236',
'51.512249182894756' => '-0.15815299440919262',
'51.52325165255695' => '-0.11283439089356762',
'51.47238304492127' => '-0.15883963991700512',
'51.49077068938746' => '-0.07232230593263012'