<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tudor Barbu&#039;s professional blog &#187; user interface</title>
	<atom:link href="http://blog.motane.lu/tag/user-interface/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.motane.lu</link>
	<description>Ramblings about software development</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:38:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>New theme</title>
		<link>http://blog.motane.lu/2010/02/01/new-theme/</link>
		<comments>http://blog.motane.lu/2010/02/01/new-theme/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 00:17:47 +0000</pubDate>
		<dc:creator>Tudor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://blog.motane.lu/?p=1304</guid>
		<description><![CDATA[Got myself a new blog theme. The old one was getting&#8230;well&#8230;old. The design was made by Andrei Chirea. It&#8217;s still in beta. Some things may work &#8220;funny&#8221;, other may not work at all. Should work in Internet Explorer. Suggestions are welcome!]]></description>
			<content:encoded><![CDATA[<p>Got myself a new blog theme. The old one was getting&#8230;well&#8230;old. The design was made by <a href="http://www.andreichirea.com/" title="Andrei Chirea's webpage" class="outgoing">Andrei Chirea</a>. It&#8217;s still in beta. Some things may work &#8220;funny&#8221;, other may not work at all. Should work in Internet Explorer.</p>
<p>Suggestions are welcome! </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.motane.lu/2010/02/01/new-theme/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Styling Zend_Form</title>
		<link>http://blog.motane.lu/2009/04/24/styling-zend_form/</link>
		<comments>http://blog.motane.lu/2009/04/24/styling-zend_form/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 05:46:24 +0000</pubDate>
		<dc:creator>Tudor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[decorators]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://blog.motane.lu/?p=366</guid>
		<description><![CDATA[As a Zend Framework user I use a lot the Zend_Form component to render my forms. I like it, it&#8217;s easy to use, pretty versatile and comes with lots of ready built filters and validators meant to make life easier. But the problems with Zend_Form begin when one tries to style it. Problem partially solved [...]]]></description>
			<content:encoded><![CDATA[<p>As a Zend Framework user I use a lot the Zend_Form component to render my forms. I like it, it&#8217;s easy to use, pretty versatile and comes with lots of ready built filters and validators meant to make life easier. But the problems with Zend_Form begin when one tries to style it. Problem partially solved by the developers of ZF with the use of the <a href="http://en.wikipedia.org/wiki/Decorator_pattern" title="Decorator pattern" class="outgoing">decorator pattern</a>. </p>
<p>Using decorators, the form&#8217;s elements can be wrapped in custom HTML tags and alter the way the form displays.</p>
<p>But in some cases, for example when you want each element of the form to have its custom markup, to have 3 elements on the first line and 2 on the second or you want to have all the errors grouped in a single area like in Drupal, the decorator pattern fails. Bad. What to do then? Stop using Zend_Form? Or hacking it? If the second choice sounds better, then keep reading <img src='http://blog.motane.lu/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> <span id="more-366"></span></p>
<h2><span>How to style a Zend_Form</span></h2>
<p>I did it this way: overrode the __toString() method to return HTML code from a view, passed the form object to this view and rendered it there &#8211; by hand, without any decorators. Sounds simple? It is! First of all, I&#8217;ve wrote a custom form class (pay attention to the __toString() method):</p>
<pre class="brush: php; title: ; notranslate">
/**
 * Example form
 *
 * @package Forms
 * @author Tudor Barbu &lt;miau@motane.lu&gt;
 */
class MyForm extends Zend_Form {
    /**
     * init the form
     *
     * @return void
     */
    public function init() {
        $this-&gt;setMethod('post');
        $translator = Zend_Registry::get('translator');

        $email = new Zend_Form_Element_Text('email');
        $email-&gt;setOptions(
            array(
                'label'          =&gt; $translator-&gt;translate('Email address'),
                'required'     =&gt; true,
                'filters'        =&gt; array('StringTrim','StripTags',),
            )
        );    

        $name = new Zend_Form_Element_Text('name');
        $name-&gt;setOptions(
            array(
                'label'          =&gt; $translator-&gt;translate('Name'),
                'required'     =&gt; true,
                'filters'        =&gt; array('StringTrim','StripTags',),
            )
        );    

        $message = new Zend_Form_Element_Textarea('message');
        $message-&gt;setOptions(
            array(
                'label'          =&gt; $translator-&gt;translate('Message'),
                'required'     =&gt; true,
                'filters'        =&gt; array('StringTrim','StripTags',),
            )
        );

        $submit = new Zend_Form_Element_Submit('submit');
        $submit-&gt;setOptions(
            array(
                'label' =&gt; $translator-&gt;translate('Submit'),
            )
        );

        $this-&gt;addElement($email);
        $this-&gt;addElement($name);
        $this-&gt;addElement($message);
        $this-&gt;addElement($submit);
    }

    /**
     * magic method __toString() implementation
     *
     * @return string
     */
    public function __toString() {
        // get the view
        $view = Zend_Layout::getMvcInstance()-&gt;getView();
        // use addScriptPath to tell the view where to look for this files
        // previous version used setScriptPath here, a bad practice
        // read  Iulian Ilea's comment for more details
        $view-&gt;addScriptPath( APPLICATION_PATH . '/views/forms/' );

        // pass the form the the view
        $view-&gt;form = $this;

        // render the form using myForm.phtml
        return $view-&gt;render( 'myForm.phtml' );
    }
}
</pre>
<p>Now, in the <strong>application/views folder</strong>, I&#8217;ve created a subfolder called <strong>forms</strong>, which holds this kind of views, meant to render forms. I usually name these files after the form they belong to, so if the form was saved in a file called MyForm.php, this view will be called <em>myForm.phtml</em>. </p>
<p>Pretty self explanatory. The content of <em>myForm.phtml</em> looks like this:</p>
<pre class="brush: php; title: ; notranslate">
/**
 * custom form renderer
 *
 * @package Forms
 * @author Tudor Barbu &lt;miau@motane.lu&gt;
 */

// get the form's elements as variables
foreach($this-&gt;form-&gt;getElements() as $element) {
    ${$element-&gt;getName()} = $this-&gt;splitElement($element);
}
?&gt;
&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;
            &lt;?php echo $email['label'];?&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;?php echo $name['label'];?&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;
            &lt;?php echo $email['body'];?&gt;
            &lt;?php if(!empty($email['messages'])):?&gt;
                &lt;ul&gt;
                    &lt;?php foreach($email['messages'] as $message):?&gt;
                    &lt;li&gt;&lt;?php echo $message;?&gt;
                    &lt;?php endforeach;?&gt;
                &lt;/ul&gt;
            &lt;?php endif;?&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;?php echo $name['body'];?&gt;
            &lt;?php if(!empty($body['messages'])):?&gt;
                &lt;ul&gt;
                    &lt;?php foreach($body['messages'] as $message):?&gt;
                    &lt;li&gt;&lt;?php echo $message;?&gt;
                    &lt;?php endforeach;?&gt;
                &lt;/ul&gt;
            &lt;?php endif;?&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td colspan=&quot;2&quot;&gt;
            &lt;div style=&quot;display:none&quot;&gt;
                &lt;!-- only for screen readers --&gt;
                &lt;?php echo $message['label'];?&gt;
            &lt;/div&gt;
            &lt;?php echo $message['body'];?&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;?php if(!empty($message['messages'])):?&gt;
    &lt;tr&gt;
        &lt;td colspan=&quot;2&quot;&gt;
            &lt;ul&gt;
                &lt;?php foreach($message['messages'] as $msg):?&gt;
                &lt;li&gt;&lt;?php echo $msg;?&gt;&lt;/li&gt;
                &lt;?php endforeach;?&gt;
            &lt;/ul&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;?php endif;?&gt;
    &lt;tr&gt;
        &lt;td colspan=&quot;2&quot;&gt;
            &lt;!-- use a button tag instead of a input type submit --&gt;
            &lt;button type=&quot;submit&quot;&gt;
                &lt;?php echo $submit['label'];?&gt;
            &lt;/button&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
</pre>
<p>I&#8217;ve wrote the SplitElement view helper to make things easier. It&#8217;s supposed to be pretty simple, but if you have a hard time understanding it, post a comment below. Here is its source code. </p>
<pre class="brush: php; title: ; notranslate">
/**
 * Returns an array containing the element's
 * body (html tag), label text and error messages
 *
 * Expect something like:
 *
 * array(
 *     'body'     =&gt; '&lt;input type=&quot;text&quot; id=&quot;name&quot; name=&quot;name&quot;&gt;',
 *     'label'    =&gt; 'Name',
 *     'messages' =&gt; array('validator 1 error', 'validator 2 error' )
 * )
 *
 * @package View Helpers
 * @author Tudor Barbu &lt;miau@motane.lu&gt;
 */

class MyLibrary_View_Helper_SplitElement {
    /**
     * returns an array containing the element's
     * body, label and error messages
     *
     * @param Zend_Form_Element $element
     * @return array
     */
    public function splitElement(Zend_Form_Element $element) {
        $result = array();
        $result['body'] = $element-&gt;getView()-&gt;{$element-&gt;helper}(
            $element-&gt;getName(),
            $element-&gt;getValue(),
            $element-&gt;getAttribs(),
            $element-&gt;options
        );

        $result['label'] = $element-&gt;getLabel();
        $result['messages'] = $element-&gt;getMessages();

        return $result;
    }
}
</pre>
<p>And now, in the controller:</p>
<pre class="brush: php; title: ; notranslate">
class TestController extends Zend_Controller_Action {
    public function exampleAction() {
         $this-&gt;view-&gt;form = new MyForm();
         // other controller logic
    }
}
</pre>
<p>and in the view (<strong>application/views/scripts/test/example.phtml</strong>):</p>
<pre class="brush: php; title: ; notranslate">
echo $this-&gt;form;
</pre>
<p>If you have other ideas on how to style Zend_Form objects, don&#8217;t be shy and post a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.motane.lu/2009/04/24/styling-zend_form/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>The future&#8230;from Microsoft</title>
		<link>http://blog.motane.lu/2009/03/03/the-futurefrom-microsoft/</link>
		<comments>http://blog.motane.lu/2009/03/03/the-futurefrom-microsoft/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 05:59:58 +0000</pubDate>
		<dc:creator>Tudor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[future technologies]]></category>
		<category><![CDATA[thoughts]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.motane.lu/?p=504</guid>
		<description><![CDATA[How will the future look? Here is Microsoft&#8217;s point of view: Video: Future Vision Montage I consider Microsoft&#8217;s point of view to be very optimistic. I&#8217;m not sure that in only 10 we&#8217;ll reach that level of technology, and even if we do, there will be a lot of people that will reject it, due [...]]]></description>
			<content:encoded><![CDATA[<p>How will the future look? Here is Microsoft&#8217;s point of view:</p>
<p><embed src="http://images.video.msn.com/flash/soapbox1_1.swf" width="432" height="364" id="n3gs2o5d" type="application/x-shockwave-flash" allowFullScreen="true" allowScriptAccess="always" pluginspage="http://macromedia.com/go/getflashplayer" flashvars="c=v&#038;v=a517b260-bb6b-48b9-87ac-8e2743a28ec5&#038;ifs=true&#038;fr=shared&#038;mkt=en-GB"></embed><noembed><a href="http://video.msn.com/?mkt=en-GB&#038;playlist=videoByUuids:uuids:a517b260-bb6b-48b9-87ac-8e2743a28ec5&#038;showPlaylist=true&#038;from=shared" target="_new" title="Future Vision Montage">Video: Future Vision Montage</a></noembed></p>
<p>I consider Microsoft&#8217;s point of view to be very optimistic. I&#8217;m not sure that in only 10 we&#8217;ll reach that level of technology, and even if we do, there will be a lot of <a href="http://www.youtube.com/watch?v=khhC5UkiNd4" title="Old people using computers on Youtube" class="outgoing">people</a> that will reject it, due to traditions, personal convictions that it &#8220;was better back in the days&#8221;, religious beliefs and so on. And, before developing that technology, we should figure out some new energy sources, to have enough juice to power it all. But the ideas expressed in the movie are impressive, not the less&#8230;</p>
<p>Credits for finding the movie go to <a href="http://readyroom.wordpress.com/" class="outgoing" title="The ready room">Radu</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.motane.lu/2009/03/03/the-futurefrom-microsoft/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>About the User Interface</title>
		<link>http://blog.motane.lu/2009/02/02/about-the-user-interface/</link>
		<comments>http://blog.motane.lu/2009/02/02/about-the-user-interface/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 19:53:42 +0000</pubDate>
		<dc:creator>Tudor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[accesibility]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.motane.lu/?p=312</guid>
		<description><![CDATA[Few days ago, I&#8217;ve watched a presentation on TED Talks about the computer&#8217;s user interface held by Anand Agarawala. It&#8217;s extremely interesting, so sacrifice 5 minutes of your lives and watch this video. It&#8217;s worth every second! Impressive, isn&#8217;t it? But the question that pops in my mind is would I really like that kind [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago, I&#8217;ve watched a presentation on TED Talks about the computer&#8217;s user interface held by <a href="http://www.honeybrown.ca/" title="" class="outgoing" title="Anand Agarawala's homepage">Anand Agarawala</a>. It&#8217;s extremely interesting, so sacrifice 5 minutes of your lives and watch this video. It&#8217;s worth every second!</p>
<p><object width="446" height="326"><param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"></param><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent"></param><param name="bgColor" value="#ffffff"></param><param name="flashvars" value="vu=http://video.ted.com/talks/embed/AnandAgarawala_2007-embed_high.flv&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/AnandAgarawala-2007.embed_thumbnail.jpg&#038;vw=432&#038;vh=240&#038;ap=0&#038;ti=131" /><embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="446" height="326" allowFullScreen="true" flashvars="vu=http://video.ted.com/talks/embed/AnandAgarawala_2007-embed_high.flv&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/AnandAgarawala-2007.embed_thumbnail.jpg&#038;vw=432&#038;vh=240&#038;ap=0&#038;ti=131"></embed></object></p>
<p>Impressive, isn&#8217;t it? But the question that pops in my mind is would I really like that kind of User Interface? I think not. Especially now, after I&#8217;ve gotten used to the point-and-click one. It&#8217;s like walking and driving a car, it&#8217;s natural and intuitively to walk but once I&#8217;ve learned to drive and interact with the car via its wheel, pedals and gear stick interface, any attempt to drive a car that was supposed to be handled with a revolutionary interface that would make driving similar to walking would quickly turn me in an even greater menace that I already am.</p>
<p>The interface is funny to use, but after a some time it gets boring. It could be more intuitive and help <a href="http://www.youtube.com/watch?v=khhC5UkiNd4" class="outgoing" title="Old people use a computer - The game show">old people use the computer</a>, but by the time this interface will be widely used, we will be the &#8220;old people&#8221;. I think it&#8217;s a very interesting experiment, just like <a href="http://www.dontclick.it/" title="don't click it" class="outgoing">dontclick.it</a> was 5 years ago, but I doubt that will ever hit the market.</p>
<p>I&#8217;m waiting for the vocal computer interface, just like they had in Star Trek.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.motane.lu/2009/02/02/about-the-user-interface/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

