Phonetic won!

development, php 4 Comments »

winner1.gif align=Yes, my class Phonetic won the first place of the PHPClasses Innovation Award.

Thanks to everyone voted for me!

Vote for Phonetic class

development, php No Comments »

My PHP class Phonetic is nominated on phpclasses.org Innovation Award.

Vote for it!

The class generates words that phonetically are equal to the given one, but are written differently.

Get Mozilla FireFox T-Shirt

FireFox, development 3 Comments »

FirefoxDo you want to get a Mozilla Add-ons Developer T-shirt?

Recently I have received an email from Mozilla:

If you are able to achieve Firefox 3 beta 3 compatibility by March 18th on addons.mozilla.org, you are eligible for a Mozilla Add-ons Developer T-shirt. If you have updated your add-on, and would like a shirt, please fill out the following form:

https://addons.mozilla.org/en-US/firefox/developers/tshirtrequest

Additionally, if your add-on is one of the top 50 most used add-ons by Firefox 3 users on the Firefox 3 release day, Mozilla will offer to sponsor (for an amount we will determine) a party for you and your friends. That is, Mozilla will chip in for you and your friends to celebrate your tools success! Mozilla will be in contact with the top add-ons shortly after the Firefox 3 release.

As for me, I have created a Get File Size plugin, and as soon as I did it, I have become eligible to fill a shipping form.

Here is a couple of links to help you on this way:

It is a good chance to make your cool plugin idea come true.

Get file size

FireFox 12 Comments »

I have created a ‘Get File Size’ plugin for FireFox. By the time I write this it’s in the SandBox of Mozilla’s Developers Zone, but I hope it will be available for the IT crowd soon.

Example screen

This simple plugin creates a HEAD request to the URL you clicked and alerts the size of the file - the value of ‘Content-Length’ header.

I’m here to delete code

development 1 Comment »

I have only made this letter longer
because I have not had the time to make it shorter

Blaise Pascal, Lettres provinciales.

What do you think you are supposed to do as developer? To create code? Nope. To delete it!

delete_eraser1.jpgHave you ever thought why it takes 5-15 minutes to get into the flow? From my point of view, that’s because you have to understand the root of a task, to load its code base into your operating memory - brain. So the less code you have to deal with, the more productive you are in juggling with it.

Alongside this fact consider these statements:

  • Less software is easier to manage.
  • Less software reduces your codebase and that means less maintenance busywork (and a happier staff).
  • Less software lowers your cost of change so you can adapt quickly. You can change your mind without having to change boatloads of code.
  • Less software results in fewer bugs.
  • Less software means less support.

( Getting Real :: Less Software chapter )

At the same time it’s funny how often I got more robust code by moving from 100 lines to 10…

In the next post I will describe the ways I use to achieve that goal.

Fusebox cheat sheet

Fusebox No Comments »

A wonderful list of Fusebox XML tags can be found at “Fusebox 4.1 XML Cheat Sheet“.

By the way, an astonishing variety of cool cheat sheets (Ajax, CSS, Regexp, Ruby, PHP and many others) can be found at Smashing Magazine.

Digg effect

site 3 Comments »

This blog is quite young, so not so many visits is obvious. This is what submitting to Digg and Reddit can do…

Digg effect

Hehe…

CRUD Class

php 5 Comments »

I have intention to complete my draft of a CRUD PHP-class. Don’t know what is it? Easy!

Imagine you have a site where users point some places at Google Maps framed at your page. As developer of this site you will have to create several admin pages:

  • a page to manage users: e.g. grant permissions to your friend or deactivate a gonzo user
  • another page to tune options of the map points: fix a typo or edit coordinates of points

Just two pages, but I bet you’d need at least 3-5 hours to make a small draft form to manage these entities. To make things worse, let me remind you of paging, client and server sides validation, date-picker dialogs or even data integrity checks.

So, to cut the long story short, CRUD class generates all this for you in a couple of lines of code. So you just define what database table you’d like to manage - drum-roll! - you get a ready-made interface! (I call it a Table Manager Class - it helps you to manage any table in your system)

By the way, CRUD stands for Create, Read, Update and Delete. So CRUD class allows to play with data you have.

As Petrovich said (a laboratory assistant in my university), “first check what others have done”.

So, I found a CRUD class and I remember about Symfony framework admin generator.

CRUD class

While the former is rather crude (it doesn’t work in some conditions, settings are embedded in PHP code), Symfony’s generator is quite nice: settings are separated from logic in a Yaml file and the code is being regenerated for you every time you make a change.The drawback of the latter is that you have to deal with huge Symfony framework to have this feature.

Symfony admin generator

So my idea is to prepare a stand-alone PHP class to make generation of admin inteface easier. I’m going to use an Ext.js JavaScript framework to beautify the interface.

Maybe someone has a better solution?

Andrisi suggests this to be like this:

A draft of CRUD

Automatical turn to AJAX with FuseBox

AJAX, Fusebox No Comments »

You as web developer might have thought about how to develop applications having both AJAX and HTML-only versions at the same time. Fusebox can make your life easier!

The solution has two simple steps:

  1. determine whether JavaScript is turned on in user’s browser;
  2. if JavaScript is turned on, the application loads HTML chunks via AJAX, otherwise PHP is used to load the same chunks while an HTML page is generated.

It may look confusing how the same snippets of HTML code could be load by both AJAX and PHP. It’s not a big deal if the snippets are HTML parts of code ready to be outputed to browser. To do this, let’s create an ‘ajax’ circuit in our fictitious application. In general, this circuit don’t have a header or footer - it’s used just to return pieces of HTML.

Let’s imagine our application must show a table of products. The fuseaction ‘list’ of ‘products’ circuit could be defined like this:

<circuit access="public">

  <fuseaction name="list">
    <if condition="1==${jsdisabled}">
      <true>
        <set name="some_var1" value="1"  />
        <set name="some_var2" value="2"  />
        <do action="ajax.GetProducts" contentvariable="ProductsList"/>
      </true>
    </if>
    <include template="dspList.php" />
  </fuseaction>

</circuit>

This means that if $jsdisabled variable equals to 1 (which tells us that JavaScript is turned off - we will see later how to determine this), we grab contents of fuseaction ‘ajax.GetProducts’ to get an HTML code of products list into a variable $ProductsList.

All the magic is in dspList.php template: it determines what must be called - AJAX or PHP:

<? if ( 0 == $jsdisabled )  {?>
  <script>
    new_AJAX_request('index.php?fa=ajax.GetProducts&some_var1=1&some_var2=2');
  </script>
<?
}
else
{
  echo $ProductsList;
}
?>

There are a couple of variables defined for both calls ( some_var1 and some_var2 ). Such variables are used to tune the output of ajax.GetProducts fuseaction, for example, if your table supports sorting by click on its header, you can define the hyperlinks locations for sorting: if AJAX is used, they probably will look like <a href="javascript: update_rows()">...</a>, otherwise usual page reloading links would be used.

It’s worth saying a couple of words about how your application could find out whether it can use AJAX or not, i.e. if JavaScript is turned on at client side. Let’s consider the way which is used by Google Maps: if you turn JavaScript off in your browser and reload the page, you will be automatically redirected to a Google Maps page created with help of hyperlinks and images only. The algorithm is simple - if JavaScript is turned off, SCRIPT tag doesn’t work, but the NOSCRIPT tag does, so we can put a redirection command into this block. Then, if you switch back to have JavaScript available (and SCRIPT tag would make sense again), the application must be informed about the fact, so we redirect to the same location, but with additional parameter, telling the application about the change. The current value of JavaScript state can be stored in session or cookies.

Here is a PHP snippet, showing this at work:

<html>
  <head>
    <? if ( 0 == $attributes['jsdisabled'] ) : ?>
      <noscript>
        <meta http-equiv="refresh" content="0; URL=http://<?=$_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI'] . (strpos($_SERVER['REQUEST_URI'], '?')!==false ? '&' : '?' ) ?>jsdisabled=1"/>
      </noscript>
    <? else : ?>
      <script>
        top.document.location.href='http://<?=$_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI'] . (strpos($_SERVER['REQUEST_URI'], '?')!==false ? '&' : '?' ) ?>jsdisabled=0';
      </script>
    <? endif; ?>

Mind-mapping in Fusebox

Fusebox, Mind-mapping 1 Comment »

In our fast-moving world visual designing tools become more and more popular, allowing to generate code snippets or whole projects from a graphical scretch. This article describes what a Fusebox developer can get from it.Circuits and fuses of a Fusebox project form a strict hierarchy, so we can draw the project schema as a tree. Is there any software to draw trees? Of course! There is an astonishing variety of tools to create mind-maps which we can adopt to our needs.

If you are not familiar with mind maps, let’s take a closer look on them:

A mind map is a diagram used to represent words, ideas, tasks or other items linked to and arranged radially around a central key word or idea. It is used to generate, visualize, structure and classify ideas, and as an aid in study, organization, problem solving, decision making, and writing [wikipedia].

Mind maps are a result of mind-mapping: a technique allowing to keep track of ideas generated while a brain-storm session (yes, it’s when people jot down as many ideas as they can and after that they “separate grains and tares” - choose the most brilliant ones). So, valuable thoughts are hierarchically organized as a tree. As any tree, mind map has nodes and leafs, i.e. nodes with no children.

mind map

Structural similarity between a mind map and a Fusebox project provides a basis for a conclusion that the former can be used to generate the latter (and vice versa). A glue between the two layers can be the XML format as most mind-mapping utilities can import from and export to it. A drawback of using XML is that almost every application has its own kind of the XML format our converter will have to deal with.

As long as mind-mapping utilities are concerned - there are a plenty of on-line tools and desktop applications (usually written in Java). We will decide in favour of Bubbl.us as the web site and FreeMind as example of a free desktop tool.

Bubbl.us is a web2.0 on-line application written in Flash, and it’s quite fun to work with it - for example, a deleting node can explode, so be aware! There is a feature of export to several graphical formats, so you can have a big glyph of your project on the wall. You can register if you want to save your masterpieces (so called ‘lazy registration’). Minus is that if you have too many items it could work a bit slower.

Preparing project structure at bubble.us. Export to XML feature is available in the right bottom

FreeMind is a Java tool so you can use it on many operating systems. It is not as fun as the previous one but it provides extensive export capabilities (XHTML format as well which allows a user to create a mapped image with links to a folding outline) and has some extra features - you can provide nodes with icons, lock nodes (protect with password) and search within a single branch.

Preparing a project structure in FreeMind. XML is available as .mm-file

Since Fusebox supports ColdFusion and PHP platforms, instruments for both platforms are available.

ColdFusion implementations can be found in the Tools part of the fusebox.org site. Among them are:

  • Fuseminder2 - Converts Mind Maps to Fusebox 3
  • Fuseminder - Generates a Fusebox 2.0 framework based on a mind mapping file
  • FuseminderPlus - Fuseminder for Fusebox 3
  • FuseminderFB4 - Fuseminder for Fusebox 4
  • MindFuser - Reads a Fusebox 2.0 application and generates an outline file

You can easily download them and give them a try.

There is not so many tools written in PHP. One of a kind is the Fusebox Manager supporting several XML formats. This package implements a code generator that takes project definition and generates PHP code to implement the Fusebox methodology. The generated code uses a run-time PHP framework also provided within the package to deploy projects using this methodology all in PHP. For now it works in only one direction - it generates a Fusebox application from a mind map, but it’s planned to add backward function, so that you could use it for existing Fusebox projects to manage them visually and then save back as a bunch of PHP files.

Fusebox Manager at work

All in all, the day when you would be able to create a whole project by several movements of your mouse is not as far as you may think.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login