<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Dell Sala – Web Development</title>
	
	<link>http://dellsala.com</link>
	<description>Freelance Web Developer</description>
	<lastBuildDate>Wed, 12 Oct 2011 23:36:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/dellsala" /><feedburner:info uri="dellsala" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Trouble suppressing PHP E_STRICT errors with error_reporting?</title>
		<link>http://feedproxy.google.com/~r/dellsala/~3/rLzuSfoaPsU/</link>
		<comments>http://dellsala.com/284/trouble-suppressing-php-e-strict/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 21:02:43 +0000</pubDate>
		<dc:creator>Dell Sala</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://dellsala.com/?p=284</guid>
		<description><![CDATA[I was working with a PEAR package in a PHP 5.2 environment. Naturally, I was getting some E_STRICT errors. I like to have all my code strict compliant, so I always develop with E_STRICT turned on. I wasn&#8217;t about to start changing the PEAR code, so I thought I&#8217;d just use error_reporting and disable E_STRICT [...]]]></description>
			<content:encoded><![CDATA[<p>I was working with a PEAR package in a PHP 5.2 environment. Naturally, I was getting some E_STRICT errors. I like to have all my code strict compliant, so I always develop with E_STRICT turned on. I wasn&#8217;t about to start changing the PEAR code, so I thought I&#8217;d just use error_reporting and disable E_STRICT reporting right before using the offending code &#8212; then I&#8217;d restore the original error_reporting value.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$oldErrorReportingValue</span> <span style="color: #339933;">=</span> <span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$oldErrorReportingValue</span> ^ <span style="color: #009900; font-weight: bold;">E_STRICT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// call offending PEAR code…</span>
<span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$oldErrorReportingValue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This didn&#8217;t work. No matter what I set error_reporting to, the E_STRICT errors would keep showing up in my logs. I found others with the same problem, but I was led on a wild goose chase:</p>
<ul>
<li><a href="http://pear.php.net/bugs/bug.php?id=9950">http://pear.php.net/bugs/bug.php?id=9950</a></li>
<li><a href="http://pear.php.net/bugs/bug.php?id=9950">https://bugs.php.net/bug.php?id=40244</a></li>
<li><a href="http://www.php.net/manual/en/function.error-reporting.php">http://www.php.net/manual/en/function.error-reporting.php</a></li>
</ul>
<p>One of the causes was PEAR running the non-strict code during a registered shutdown handler. Another cause was the strict errors getting thrown at compile time. But neither of these applied to my case.</p>
<p>After messing around for quite a while I discovered the answer in the <a href="http://php.net/manual/en/function.set-error-handler.php">set_error_handler documentation</a>. My custom error handler was the cause…</p>
<blockquote><p><em>&#8220;It is important to remember that the standard PHP error handler is completely  bypassed [...] unless the callback function returns FALSE.   error_reporting() settings will have no effect and your  error handler will be called regardless &#8211; however you are still able to read the current value of  error_reporting and act  appropriately.&#8221;</em></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://dellsala.com/284/trouble-suppressing-php-e-strict/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dellsala.com/284/trouble-suppressing-php-e-strict/</feedburner:origLink></item>
		<item>
		<title>Combo Box Input Element (jQuery Plugin)</title>
		<link>http://feedproxy.google.com/~r/dellsala/~3/EEpWmStDTbM/</link>
		<comments>http://dellsala.com/269/combo-box-input-element-jquery-plugin/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 19:30:15 +0000</pubDate>
		<dc:creator>Dell Sala</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ui design]]></category>

		<guid isPermaLink="false">http://dellsala.com/?p=269</guid>
		<description><![CDATA[The other day I needed a text input control that allowed free-form text input in combination with a select control for choosing a value from a predefined list &#8212; a combo box. I spent quite a while looking for a decent combo box plugin for jQuery. I did find this one (jQuery Editable Combobox), but [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-276" title="Combo Box Example" src="http://dellsala.com/wp-content/uploads/combo-box-example.png" alt="Combo Box Example" width="192" height="92" />The other day I needed a text input control that allowed free-form text input in combination with a select control for choosing a value from a predefined list &#8212; a <a href="http://en.wikipedia.org/wiki/Combo_box">combo box</a>. I spent quite a while looking for a decent combo box plugin for jQuery. I did find this one (<a href="http://code.google.com/p/jquery-jec/">jQuery Editable Combobox</a>), but the behavior and appearance seemed a bit odd to me. So here&#8217;s <a href="http://source.dellsala.com/jquery-combobox/">my combo box jquery plugin</a>.</p>
<ul>
<li><a href="http://source.dellsala.com/jquery-combobox/demo">Demo</a></li>
<li><a href="http://source.dellsala.com/jquery-combobox/">Download</a></li>
<li><a href="https://github.com/dellsala/Combo-Box-jQuery-Plugin">Github</a></li>
</ul>
<p>The &#8220;dropdown&#8221; button style can be customized with css. Here&#8217;s a quick example.</p>
<p>The Markup:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;combobox1&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fruit&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>And the Javascript:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#combobox1'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">combobox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>
        <span style="color: #3366CC;">'Apples'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'Oranges'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'Bananas'</span>
    <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I intend to add support for more flexible custom styling. The plugin is listed on jquery.com</p>
]]></content:encoded>
			<wfw:commentRss>http://dellsala.com/269/combo-box-input-element-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		<feedburner:origLink>http://dellsala.com/269/combo-box-input-element-jquery-plugin/</feedburner:origLink></item>
		<item>
		<title>Variable Collisions in WordPress activate_plugin “Sandbox”</title>
		<link>http://feedproxy.google.com/~r/dellsala/~3/OYRXf9cjTzE/</link>
		<comments>http://dellsala.com/243/variable-collisions-in-wordpress-activate_plugin-%e2%80%9csandbox%e2%80%9d/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 05:56:35 +0000</pubDate>
		<dc:creator>Dell Sala</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dellsala.com/?p=243</guid>
		<description><![CDATA[There is a bug in WordPress’s plugin activation related to variable collisions. When WordPress activates the plugins it executes them within the scope of the activate_plugin function. The problem is that this scope is full of other variables that can collide with your plugin’s top scope.]]></description>
			<content:encoded><![CDATA[<p>A heads up to all WordPress plugin developers: There is a bug in WordPress’s plugin activation related to variable collisions. Here&#8217;s a plugin that will reproduce the error:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
Plugin Name: Broken Plugin
*/</span>
&nbsp;
<span style="color: #000088;">$plugin</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;oops!&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Looks innocent enough. But try to activate this plugin and you&#8217;ll get an admin error notification: </p>
<p><strong>The plugin &#8220;oops!&#8221; has been deactivated due to an error: Plugin file does not exist.</strong></p>
<p>The reason for this is that when WordPress activates the plugin it <code>include</code>s your plugin file into the scope of the <code>activate_plugin</code> function. It does this in order to do a “Sandboxed” execution of your plugin to catch any errors, or premature output that could mess with the WordPress headers. The problem is that the “Sandbox” scope is full of other variables that are used in the process of registering the plugin. One of those variables is… you guessed it… <code>$plugin</code>.</p>
<p>Here&#8217;s a simplified version of what’s happening in <code>activate_plugin</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> activate_plugin <span style="color: #009900;">&#40;</span><span style="color: #000088;">$plugin</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">/* other stuff */</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>WP_PLUGIN_DIR <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$plugin</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #666666; font-style: italic;">// OOPS! NOW $plugin HAS AN UNINTENDED VALUE</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #666666; font-style: italic;">/* NO ERRORS */</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$installedPlugins</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'active_plugins'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$installedPlugins</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$plugin</span><span style="color: #339933;">;</span>   
      update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'active_plugins'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$installedPlugins</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>What made this bug a giant PITA for me was that I happened to assign an object to <code>$plugin</code>. So, not only did my plugin not install, but it riddled my WP install with cryptic errors about incomplete objects.</p>
<p><strong>The Solution…</strong></p>
<p>The simple work around to this is to not use <code>$plugin</code>, or any other variable name that happens to be used in the body of <code>activate_plugin</code>. The better solution is to eliminate variable declarations and code execution from the top scope of your plugin altogether. This can be achieved easily by wrapping any code in a bootstrap function:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> my_plugin_bootstrap <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$plugin</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyPlugin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$plugin</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
my_plugin_bootstrap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>There is <a href=" http://codex.wordpress.org/Function_Reference/register_activation_hook#A_Note_on_Variable_Scope">a note in the WordPress documentation about scoping in plugins</a> that is related to this issue. Personally, I think this is a bug &#8212; If I get a change to file it, I&#8217;ll link to the ticket and followup here.</p>
]]></content:encoded>
			<wfw:commentRss>http://dellsala.com/243/variable-collisions-in-wordpress-activate_plugin-%e2%80%9csandbox%e2%80%9d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dellsala.com/243/variable-collisions-in-wordpress-activate_plugin-%e2%80%9csandbox%e2%80%9d/</feedburner:origLink></item>
		<item>
		<title>Google Sites Equals Instant Wiki</title>
		<link>http://feedproxy.google.com/~r/dellsala/~3/tYxykMXQ8NA/</link>
		<comments>http://dellsala.com/140/google-sites-equals-instant-wiki/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 04:09:45 +0000</pubDate>
		<dc:creator>Dell Sala</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[google sites]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://dellsala/?p=140</guid>
		<description><![CDATA[I just discovered Google Sites while (for the umpteenth time) looking for a simple tool for writing documentation. In the past I had always fallen back on using Google Docs, Basecamp, or just passing around text files. These got the job done, but always felt a little clunky. I knew what I wanted was probably [...]]]></description>
			<content:encoded><![CDATA[<p>I just discovered <a title="Google Sites" href="https://sites.google.com/">Google Sites</a> while (for the umpteenth time) looking for a simple tool for writing documentation. In the past I had always fallen back on using Google Docs, Basecamp, or just passing around text files. These got the job done, but always felt a little clunky. I knew what I wanted was probably going to be a wiki, but the idea of installing and experimenting with a bunch of open source wiki software was not appealing.</p>
<p>Randomly, it popped into my head. “Doesn&#8217;t Google have a service for building basic websites? I wonder if its any good?” A few minutes later I had a multi-page documentation site with embedded media, configurable tables and list, file attachments, and comment support. It also supports private sites with the ability to control viewing and editing privileges.</p>
<p><object width="500" height="306"><param name="movie" value="http://www.youtube.com/e/tkTGrOcFiz0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/e/tkTGrOcFiz0" type="application/x-shockwave-flash" width="500" height="306" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Here are some of the highlights…<strong></strong></p>
<p><strong>No-nonsense Rich Text Editing</strong><br />
No fluff. The controls are paired down which makes maintaining consistent formatting easy.</p>
<p><strong>Great Navigation Controls</strong><br />
You can either create your own custom navigation, or have sites generate the nav for you automatically. You can also drop in Table of Contents blocks on individual pages that render automatically by detecting the heading structure of your document.</p>
<p><strong>Decent Layout Control</strong><br />
You can configure the layout of each page (x columns, headers, footers). Seem to give you just about every standard configuration you could want.</p>
<p>I won’t be using Google Sites to build my next client’s site any time soon. A friend of the superstar css tweaker it is not. But for something that needs to be functional, consistent, and organized this is a great tool.</p>
]]></content:encoded>
			<wfw:commentRss>http://dellsala.com/140/google-sites-equals-instant-wiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dellsala.com/140/google-sites-equals-instant-wiki/</feedburner:origLink></item>
		<item>
		<title>API for Flexible Image Resizing</title>
		<link>http://feedproxy.google.com/~r/dellsala/~3/29u2YAlIfQY/</link>
		<comments>http://dellsala.com/157/api-for-flexible-image-resizing/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 05:30:05 +0000</pubDate>
		<dc:creator>Dell Sala</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[api design]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://dellsala/?p=157</guid>
		<description><![CDATA[The Problem It&#8217;s a common one. You have a project that requires uploaded images. These images need to be displayed in different layouts at different sizes based on the context (ex: large on a detail page, thumbnail on the list page, etc…) In the past I would have encapsulated these sizes in an image class [...]]]></description>
			<content:encoded><![CDATA[<h2>The Problem</h2>
<p>It&#8217;s a common one. You have a project that requires uploaded images. These images need to be displayed in different layouts at different sizes based on the context (ex: large on a detail page, thumbnail on the list page, etc…) In the past I would have encapsulated these sizes in an image class and implemented the resizing to happen at upload time.</p>
<p>The problem pops up when the layout changes. You (or someone else) decides that the thumbnail need to be bigger. You go into your code – say it’s in a class called <strong>Image</strong>. Your image class has methods like, <strong>resizeAndInstallThumbnail()</strong>, <strong>getThumbnailUrl()</strong>, etc… Like a good little OO programmer you&#8217;ve hidden the actual dimensions of the thumbnail in the class. So you change those and you&#8217;re all set.</p>
<p>Well… sort of. You forget that you used <strong>getThumbnailUrl()</strong> in another layout, and that one wasn&#8217;t supposed  to change. After breaking the other layout severely you fix the problem by adding a method like <strong>getSearchResultThumbnailUrl()</strong>. Annoying, but not so bad. But, wait. You forgot this site is in production, with hundreds of uploaded images that all need to be resized. If your app has been storing the original uploaded files then you can write a one-off script to regenerate the resized images. If not, it&#8217;s time to re-upload all your images.</p>
<h2>The Solution</h2>
<p>The real problem here is that the rate of change in the presentation layer is high. And we&#8217;ve coupled some lower-level infrastructure to that presentation by designing our api around it with method names like <strong>getThumbnailUrl()</strong>. “Thumbnail” is a presentation word. Why does the object responsible for uploads and resizing need to know what a “SearchResultThumbnail” is? Why not have the presentation layer talk to the image infrastructure layer in a more generic way… Like pixel dimensions? Here&#8217;s what you end up with:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrlByHeight</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">55</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;
    alt=&quot;Product Thumbnail&quot;/&gt;</pre></div></div>

<p>The benefit here is that the hard-coded pixel values now appear in the presentation layer, where they belong. In addition, you can easily resize the images on demand. If you add new sizes to your layout, all you have to do is specify the new dimensions and any new images files will be generated as needed.</p>
<p>My brother Jay came up with this idea. I’m sure others out there are  using similar techniques, but there was something about the simplicity  of his solution that really appealed to me.</p>
]]></content:encoded>
			<wfw:commentRss>http://dellsala.com/157/api-for-flexible-image-resizing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://dellsala.com/157/api-for-flexible-image-resizing/</feedburner:origLink></item>
	</channel>
</rss>

