Skip to main content

Posts

Creating simple, extendible CRUD, using Zend Framework

The Form Creating a nice, easy to maintain form, starts with a form class. Creating your forms procedurally in your controller/actions is horrid. please don’t do it. To start with creating your form classes, you need your own namespace in your library. If you don’t have this, register one. This can be done by adding an _initAutoloading method to your Bootstrap. below is a short example. its not comprehensive (you can also do this in your ini i believe, but I use php configuration files similar to DASPRiD ‘s, and i’m not trying to show how to set up autoloading here.) class Bootstrap extends Zend_Application_Bootstrap { //... /** * Initilise autoloader and library namespaces */ public function _initAutoloading ( ) { $loader = Zend_Loader_Autoloader :: getInstance ( ) ; $loader -> registerNamespace ( 'My_' ) ; } //... } Your next task, create a form. This is pretty simple. I will demonstrate us...

jQuery webcam plugin

The jQuery webcam plugin is a transparent layer to communicate with a camera directly in JavaScript. Overview This plugin provides three different modes to access a webcam through a small API directly with JavaScript - or more precisely jQuery. Thus, it is possible to bring the image on a Canvas (callback mode), to store the image on the server (save mode) and to stream the live image of the Flash element on a Canvas (stream mode). If you just want to download the plugin, click here: Download the jQuery webcam plugin jQuery webcam example jQuery Take a picture after 3 seconds | Take a picture instantly Available Cameras HP Webcam [2 MP Fixed] (V4L2) If you activate the filter with the button on the right side of the picture, methods of my already published jQuery plugin xcolor will be used to distort the colors of the Canvas. General information about the interface The following snippet describes the interface of the webcam API: $ ( ...

Very useful HTML5 APIs

Element.classList The classList API provides the basic CSS controls our JavaScript libraries have been giving us for years: // Add a class to an element myElement. classList . add ( "newClass" ) ; // Remove a class to an element myElement. classList . remove ( "existingClass" ) ; // Check for existence myElement. classList . contains ( "oneClass" ) ; // Toggle a class myElement. classList . toggle ( "anotherClass" ) ; The epitome of a great API addition: simple and intelligent. ContextMenu API The new ContextMenu API is excellent:  instead of overriding the browser context menu, the new ContextMenu API allows you to simply add items to the browser's context menu: contextmenu = "mymenu" > type = "context" id = "mymenu" > label = "Refresh Post" onclick = "window.location.reload();" icon = "/images/refresh-icon.png" > label = ...

Read PDF and Word DOC Files Using PHP

Reading PDF Files To read PDF files, you will need to install the XPDF package , which includes "pdftotext." Once you have XPDF/pdftotext installed, you run the following PHP statement to get the PDF text: $content = shell_exec ( '/usr/local/bin/pdftotext ' . $filename . ' -' ) ; //dash at the end to output content Reading DOC Files Like the PDF example above, you'll need to download another package. This package is called Antiword . Here's the code to grab the Word DOC content: $content = shell_exec ( '/usr/local/bin/antiword ' . $filename ) ; The above code does NOT read DOCX files and does not (and purposely so) preserve formatting. There are other libraries that will preserve formatting but in our case, we just want to get at the text.