This is an update to my earlier post announcing the launch of FTM. Source provided after the jump.
When trying to deal with custom forms with file upload fields, you may sometimes get a error regarding extensions:
The specified file “your file name here” could not be uploaded. Only files with the following extensions are allowed: “jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp”
To allow all extensions, you have to manually set the ‘file_validate_extensions’ validator to an empty array.
e.g.
$validators = array('file_validate_extensions' => array());
$file = file_save_upload('upload', $validators);
For more information, check out Drupal API’s documentation at http://api.drupal.org/api/drupal/includes–file.inc/function/file_save_upload/7
The bare requirements for a file upload form is the “multipart/form-data” enctype, a “file” field, and the standard “submit” button. An example of a basic structure:
$form ['upload'] = array (
'#type' => 'file',
'#title' => 'Choose file',
'#description' => 'Upload a file.' );
$form ['submit'] = array ('#type' => 'submit', '#value' => t ( 'Submit' ) );
$form ['#attributes'] = array ('enctype' => "multipart/form-data" );
Inspired by some minimalist posters, I attempted to create one for one of my favorite movies:

Unfortunately, its not as minimal as I would like it to be. I got distracted and started watching “To Live”, another masterpiece from the same director, Zhang Yimou.
It surprises me to find out that Microsoft has been offering a free photo stitching utility for quite some time. And though its quality cannot be matched by photoshop or auto stitch, it is free, and surprisingly fast. While it takes up to 30mins to merge 8 hi res photos from my 550D (5184×3456) in photoshop, it took less than a minute in Microsoft’s Image Composite Editor. Oh, and did I mention that its free? ![]()
Download the 64bit version at http://research.microsoft.com/en-us/downloads/69699e5a-5c91-4b01-898c-ef012cbb07f7/default.aspx
A quick way to check a .php file for syntax errors is to use the -l option of php.exe.
php -l /path/to/php/file.php
Creating a new node in drupal is trivial, but when the node includes custom cck fields, then a few things can trip you up. To save time and energy, here’s a quick guide and some tips to make your drupal life easier.
Creating a basic node:
global $user; //get current logged in user
$new_node = new stdClass();
$new_node->type = 'YOUR_NODE_TYPE_HERE';
$new_node->uid = $user->uid; //you can specify some other userID here if you want
$new_node->name = $user->name;
$new_node->title = $YOUR_NODE_TITLE;
$new_node->body = $YOUR_NODE_BODY;
$new_node->status = 1; // published
node_save($new_node);
The function node_save() does a few things behind the scene. It checks if the nid property is empty to determine if this is a new insert or an update, then calls the appropriate functions so that you would not have duplicates. Put simply, if you want to do an update, populate the nid, and leave it out otherwise.
Creatnig a node with CCK fields involves this additional line (for each field):
$new_node->field_your_field[0]['value'] = $YOUR_FIELD_DATA;
Point to note is the [0]['value'], because CCK treats each field as multiple-value fields even if you specified otherwise in the field settings. If you see the error Fatal error: Cannot unset string offsets in …/modules/cck/content.module on line 1248, you’re probably missing the [0]['value'] and setting the value directly into $new_node->field_your_field.
To create a node with location, we need to save the location first to get a location ID before saving it along with our node:
$location = array(
'street' => $address,
'postal_code' => $postal,
);
$locationID = location_save($location);
$new_node = new stdClass();
// ... the usual stuff ...
$new_node->locations[0]['lid'] = $newLocationId;
node_save($new_node);
There you go. Another method is to manually craft an array to simulate a $_POST from a drupal form. To do that you basically have to know the form structure, populate the require fields and pass the array on to the drupal_execute() call. Refer to the example here for more details.
Drupal references:
Node_save: drupal documentation
Recently while trying to capture a frame from my webcam in Adobe Air, I realize the captured image is always smaller than the height or videoHeight from the Video object. The BitmapData documentation revealed that the BitmapData.draw() operation does not respect any matrix transformation applied on the Camera or Video object, so we need to do the scaling ourselves. A quick and dirty way would be:
Just like you shouldn’t start building a project from scratch, you shouldn’t start crafting a wireframe out of a blank canvas as well. The place where you should start is here:
Great looking stencil kits for building everything from iPhone, browser, facebook, MacOS apps – even Blackberry. Preview the iPhone kit below
A fantastic snapshot of the current web design trends by Smashing Magazine:
http://www.smashingmagazine.com/2010/05/04/web-design-trends-2010/
A nice little brush set containing hand-drawn arrows for that sketchy feel in your design.
http://finner.deviantart.com/art/Sketchy-Arrow-Brushes-59096138
Also in the pack: Sketchy Marks and Sketchy Text
And the mother of them all: Hand-drawn-photoshop-brushes-collection
