Web Development

Widont for the Zend Framework - automatically remedies text widows

When I came across Shaun Inman’s clever Widon’t wordpress plug-in this morning, I thought to myself “What the heck is an unwanted browser window?”, as I read on I realized it said
“widow”. If you have never heard of a widow, you’ve likely never worked in the print industry. On the web, most of us have gotten rather sloppy when it comes to good typography, but in our defense, our medium doesn’t really lend itself to good practices. A widow is a lone word on the end of a header or paragraph. The header of this post would have had a widow, had I not used Shaun’s plugin (for a better explanation of a widow, refer to this article).

Since I’ve been using the Zend Framework so much lately, I figured why not add this functionality into it? Here’s a view helper to do just that. Enjoy!

class Zend_View_Helper_Widont {
 
    public $view;
 
    public function widont($str = '', $escape = false) {
 
        if ($escape) $str = $this->view->escape($str);
        return preg_replace( '|([^\s])\s+([^\s]+)\s*$|', '$1 $2', $str);
 
    }
 
    public function setView($view) {
 
        $this->view = $view;
 
    }
 
}

Refer to the Zend Framework’s view helper documentation if you don’t know how to install view helpers.

To use this helper, call $this->widont($str) from inside of a view. If you pass a true value as the second argument, the string will be escaped before being output.

PHP Csv Utilities - new version coming soon!

It has been months since there was any kind of update on PHP Csv Utilities (or even the blog for that matter). I released the last version (0.2) prematurely, which resulted in a poor release and a lot of bugs. I’d like to let anybody interested in the library know that I am working on version 0.3 right now as well as a much improved build / release process. If there are any bugs or issues you have with the library please leave a comment or shoot me an email and I’ll do my best to make sure it’s addressed.

Detecting if user is logged in with Miva Store Morph

As I was working on a Miva Merchant store today, I needed to show the user a link, but only if they were currently logged in. I know I have done this before, but I couldn’t find the code for the life of me. So I went to trusty ol’ Google and typed in “Miva Merchant detect if user logged in” and several other terms only to come up with nothing. So I dug through several other Merchant sites to find the code. I finally found it and have decided to post it here in case somebody else has the same problem.

UPDATE: Apparently you need to check that g.Basket:CUST_ID is not equal to zero. At first my solution only checked that it wasn’t null which was flawed.

<mvt:if expr="NOT ISNULL g.Basket:CUST_ID AND g.Basket:CUST_ID NE 0">
    Welcome back, &mvte:global:customer:login;!
<mvt:else>
    Hello anonymous user!
</mvt:if>

Zend Framework version 1.5 officially released

The Zend Framework has always been my favorite PHP framework. The thing I love about this framework is that its components are loosely coupled. That is to say that its components have well-defined, and well-thought out dependencies. If you don’t like certain components, you don’t have to use them. Other frameworks boast this kind of modularity, but honestly I haven’t seen any that really back it up. For our last two or three PHP projects, we gave CakePHP a try. At first I was really happy with cake because of how quickly I was able to wire frame an application, but the more I use it the more I realize that the components in cake are far too coupled and there is just too damn much “auto-magic” going on in cake. I really prefer explicit to implicit code.

The reason we decided to leave Zend and go to CakePHP was because it lacked two main components that made it very difficult to wire frame applications quickly and easily. Those components are a layout system, and a form manager. I am happy to announce that Zend has tackled both of these problems in this release, and has actually done a decent job on them. Neither of them are 100% yet (at least not in my opinion), but both are very usable and helpful at the very least. Go grab a copy of the new release and give it a go. I think you’ll be quite happy with it!

For a full list of the new features, check out the official release page on zend developer zone.0

UPDATE! - Zend Developer Zone has published a webinar on Zend_View and Zend_Layout by Ralph Schindler. Go check it out!

Butte Business Resources

Butte Business Resources

Website: www.buttebusinessresources.com
Formula:

Debut: March, 2008

Chabin Concepts and MC2 Design are proud to announce the release of Butte County’s new regional economic development and business resource site: ButteBusinessResources.com. Designed and developed by MC2, the site is geared to be a central location for businesses in Butte County to find resources in business development, funding, marketing, business expansion, human resources, and consulting.

PHP CSV Utilities v0.2 released - now able to detect the format of a csv file

Download PHP CSV Utililties v0.2
Read Documentation for PHP CSV Utilities

I have just wrapped up version 0.2 of our csv library. It includes several new features. The most exciting of which is the new Csv_Sniffer class.

(more…)

Cut down on temporary variables in PHP with Fluidics

Ollie Saunders, a colleague of mine and a regular at the DevNetwork forums has put together a very slick little set of functions he has collectively termed “PHP Fluidics”. If there is one thing that really sucks about PHP, it’s how often you have to use temporary variables to get to methods or array elements you need. Fluidics makes this process (and several others) much easier. We use this library in just about everything we code these days and I’d like to point out a few reasons why.

(more…)

Overland Equipment

Overland Equipment

Website: www.overlandequipment.com
Formula:

Debut: February, 2008

MC2 Design is pleased to announce Overland Equipment’s web site launch for the 2008 product year. We have been fortunate to work with Overland Equipment since 2001, designing and developing their corporate website. Overland Equipment is a designer and manufacturer of quality bags since 1981.

PHP CSV Utilities - a PHP library similar to python’s standard CSV module

Download PHP Csv Utilities

PHP Csv Utilities Documentation (PhpDocumentor)

Since I began doing web development five years ago, I have been exclusively a PHP developer. Recently though, I have taken quite a liking to python. In fact many times while I’m writing PHP I find myself thinking, “It sure would be nice if I could do this the python way”. It’s not that I don’t love PHP, it’s just that python is such an absolute joy to work with. Many features of PHP feel sort of tacked-on as an afterthought. For instance, many standard features available for object-oriented languages are rudimentary or missing completely. Although to PHP’s credit, PHP5 and the new Zend engine 2 have improved the situation considerably.

Several of the recent projects I’ve been working on have required an “import from / export to CSV” feature. PHP comes with a few functions for reading and writing csv files right out of the box: fgetcsv and fputcsv. While these are good functions and they get the job done I find they just aren’t enough in many cases. It would be nice if PHP had an interface like python’s csv module. Enter PHP CSV Utilities. The library is still in its infancy and nothing about the interface is concrete yet, but here are some of the things that are already possible with the library:

(more…)

Lead developer for jQuery UI hired to work on it full-time

jQuery has long been our favorite javascript library for things such as simple effects, ajax, and other behavior-related tasks. There is one place I’ve always thought jQuery could use improvement, and that is their UI elements. Well I’m pleased to announce that is all about to change.

jQuery UI is growing, and I’m already seeing quite a few sites using it exclusively to support their interface. As a matter of fact, it’s growing so well, that a LA-based open-source company decided to hire a person to exclusively work on jQuery UI full-time.

More