<?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>Monday By Noon &#187; PHP</title>
	<atom:link href="http://mondaybynoon.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://mondaybynoon.com</link>
	<description>A resource for Web designers and developers to read about and discuss their craft.</description>
	<lastBuildDate>Mon, 05 Jul 2010 13:48:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Improving Your Process: Establishing Style Guides</title>
		<link>http://mondaybynoon.com/2010/03/29/establishing-style-guides/</link>
		<comments>http://mondaybynoon.com/2010/03/29/establishing-style-guides/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 13:04:29 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Improving Process]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[style guide]]></category>
		<category><![CDATA[team]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/?p=1034</guid>
		<description><![CDATA[I'm becoming increasingly comfortable with the idea that at least some form of style guide, whether on a team or individually, is an extremely important part of the process. It helps with everything from readability to quality control and especially helps a team become that much more cohesive.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been <strong>huge</strong> on <a href="http://mondaybynoon.com/tag/process/">process</a> for a long time now. In fact, I&#8217;d say that I consistently spend a significant amount of my workweek analyzing how <a href="http://overit.com" title="Overit Media - Web and Brand in Albany, NY">our</a> process is working for us. Things change in an instant, <em>especially</em> in our industry. Things that worked for our process last year have become hardly applicable, and new ways of thinking are constantly required.</p>
<p>I like the business end of Web design. I&#8217;ve come to the conclusion that one of the reasons I like it so much is due to my enjoyment of problem solving. <strong>Web design as a business is a problem</strong>, plain and simple. Everyone has their own way of doing things, we&#8217;re working in a medium that many of our clients don&#8217;t fully understand, and it&#8217;s sometimes very difficult to completely resolve the final terms of an agreement and be fully confident you&#8217;ve covered all your bases. This is something I like thinking about, something I like dealing with. If you&#8217;re not in the same boat, I hope you don&#8217;t plan on freelancing being a walk in the park. The business end is <em>just as big of a deal</em> as the design/development end. You want to get paid.</p>
<h2>Style guides? For code?</h2>
<p>A <a href="http://en.wikipedia.org/wiki/Programming_style">style guide</a> is a straight and to the point document that outlines how you should be formatting your code. It covers indentation, alignment, spacing, tabs, naming, and just about every other aspect of writing code apart from the logic itself.</p>
<p>Whether you&#8217;re writing a script, some markup, or programming, you have a way of doing it. You put your brackets in a certain place because either it looks better to you, or your teacher told you to write it that way. The same goes for the spaces you include in your arguments list, your <code>array</code> declarations, and so on. These are important details to consider, especially when you&#8217;re <em>looking at someone else&#8217;s code</em>.</p>
<p>Even if you didn&#8217;t realize you did it yourself, looking at someone else&#8217;s code can just come off as&#8230; unorganized. At first you can&#8217;t quite put your finger on it but you&#8217;ll find yourself asking &#8220;how the heck does this even work?&#8221; If you&#8217;ve ever had one of those moments, you&#8217;ll appreciate a good style guide in your workflow.</p>
<h3>Structuring your style guide</h3>
<p>There isn&#8217;t a real set of rules to writing your style guide(s); they will probably undergo a long series of revision as you realize the little details you&#8217;ve forgotten over time. I think coming up with a style guide is really good team based exercise, something I plan to finalize with my team over the coming weeks.</p>
<p>At my company, we&#8217;ll need four style guides to cover our workflow:</p>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
<li>PHP</li>
</ul>
<p>Currently these style guides are a work in progress, but <em>as small snippets</em> look something like this:</p>
<h4>HTML</h4>
<p>Our HTML style guide will cover things you&#8217;d expect to find in other code style guides, but certain aspects of formatting will be included in nearly every example. Things like the &#8216;closing&#8217; comment for block level elements based on their <code>class</code> or <code>id</code>.</p>
<dl>
<dt>Block element with class</dt>
<dd>
<pre class="sh_html"><code>&lt;div class=&quot;group&quot;&gt;

&lt;/div&gt;
&lt;!-- /group --&gt;</code></pre>
</dd>
<dt>Block element with ID</dt>
<dd>
<pre class="sh_html"><code>&lt;div id=&quot;address&quot;&gt;

&lt;/div&gt;
&lt;!-- /address --&gt;</code></pre>
</dd>
<dt>Block element with class and ID</dt>
<dd>
<pre class="sh_html"><code>&lt;div class=&quot;group&quot; id=&quot;services&quot;&gt;

&lt;/div&gt;
&lt;!-- /services --&gt;</code></pre>
</dd>
</dl>
<h4>CSS</h4>
<p>Probably the biggest rule to cover in a CSS style guide would be whether you&#8217;re going for single line or multi line, a debate that will carry us through the end of time. Front enders seem to be very passionate about their decision to go with one or the other, so we&#8217;re lucky to have a number of tools that will convert from one format to the other on the fly.</p>
<dl>
<dt>Comment Basics</dt>
<dd>
<pre class="sh_css"><code>/* ================ */
/* = MAIN SECTION = */
/* ================ */

.main { width:100%; }

	/* Child section */
	.child { border:1px solid #f00; }</code></pre>
</dd>
<dt>Selector property value formatting</dt>
<dd>
<pre class="sh_css"><code>.section { width:200px; height:200px; }
.section #child { border:2px solid #f00; }
.section p { margin-bottom:1.2em; }
.section ul { list-style:disc; }
.section ul li { margin-bottom:0.6em; font-size:1.1em; }</code></pre>
</dd>
</dl>
<h4>JavaScript</h4>
<p>We&#8217;re a <a href="http://jquery.com">jQuery</a> house, so a significant portion of our JavaScript style guide will include jQuery-specific notes. Along those lines, more generic JavaScript instructions will be needed as well.</p>
<dl>
<dt>Conditionals</dt>
<dd>
<pre class="sh_javascript"><code>if( $('#address').height() &lt; 100 ) {
	do_this();
} else {
	do_that();
}</code></pre>
</dd>
<dt>Chaining</dt>
<dd>
<pre class="sh_javascript"><code>$('.group')
	.find('> p')
	.removeClass('someclass')
	.addClass('newclass')
	.find('ul')
		.addClass('targetclass')
	.end()
.end()
.slideDown();</code></pre>
</dd>
</dl>
<h4>PHP</h4>
<p>I&#8217;ve always liked the way <a href="http://codeigniter.com/user_guide/general/styleguide.html">CodeIgniter writes PHP</a>. Their guide is extremely in depth and I&#8217;d simply like to use that as our style guide as well. One of the best things about CodeIgniter&#8217;s style guide is that both correct <strong>and</strong> incorrect usage is outlined.</p>
<dl>
<dt>Bracket and Parenthetic Spacing</dt>
<dd>
<pre class="sh_php"><code>// INCORRECT:
$arr[ $foo ] = 'foo';

// CORRECT:
$arr[$foo] = 'foo'; // no spaces around array keys</code></pre>
</dd>
</dl>
<h3>Do you use style guides?</h3>
<p>I&#8217;m becoming increasingly comfortable with the idea that at least some form of style guide, whether on a team or individually, is an <strong>extremely important</strong> part of the process. It helps with everything from readability to quality control and especially helps a team become that much more cohesive. Are you/is your team using style guides? Have you found them to be helpful, hurtful, or ineffective?</p>
]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/2010/03/29/establishing-style-guides/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Avoiding IFRAMES via PHP and cURL</title>
		<link>http://mondaybynoon.com/2009/11/23/avoiding-iframes-via-php-and-curl/</link>
		<comments>http://mondaybynoon.com/2009/11/23/avoiding-iframes-via-php-and-curl/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 20:01:29 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[IFRAME]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/?p=632</guid>
		<description><![CDATA[With IFRAMES being so outdated, there is an alternative using PHP and cURL]]></description>
			<content:encoded><![CDATA[<p>A current project requires integration with a certain third party that provides a &#8220;Web service&#8221; to allow data integration into member websites. Unfortunately for me, this service revolves around plopping an <code>IFRAME</code> into your page where you&#8217;d like the data to appear. Not great.</p>
<p>In an ideal world, we&#8217;d be able to pull said content via (the real) <abbr title="Asynchronous JavaScript and XML">AJAX</abbr> but due to security (particularly cross domain) issues, that&#8217;s not a possibility. All is not lost, however. Enter <a href="http://php.net/manual/en/book.curl.php">cURL</a>.</p>
<h2>A brief introduction to cURL</h2>
<p><a href="http://php.net/manual/en/book.curl.php">cURL</a> is defined as:</p>
<blockquote cite="http://www.php.net/manual/en/intro.curl.php">
<p>PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP&#8217;s ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.</p>
<p>These functions have been added in PHP 4.0.2.</p>
</blockquote>
<p>In summary, cURL allows you to have PHP fetch a page for you to do with what you will.</p>
<h3>Setting up cURL</h3>
<p>There&#8217;s a bit of a learning curve when using cURL, so you&#8217;ll want to review the manual. If you&#8217;re looking to set something up quick and dirty, the function I&#8217;ve come to use is (<a href="http://www.php.net/manual/en/ref.curl.php#93163">via</a>):</p>
<pre class="sh_php"><code>function get_url( $url,  $javascript_loop = 0, $timeout = 5 )
{
    $url = str_replace( "&amp;", "&#038;", urldecode(trim($url)) );

    $cookie = tempnam ("/tmp", "CURLCOOKIE");
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
    curl_setopt( $ch, CURLOPT_URL, $url );
    curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie );
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
    curl_setopt( $ch, CURLOPT_ENCODING, "" );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );    # required for https urls
    curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
    curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
    curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
    $content = curl_exec( $ch );
    $response = curl_getinfo( $ch );
    curl_close ( $ch );

    if ($response['http_code'] == 301 || $response['http_code'] == 302)
    {
        ini_set("user_agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1");

        if ( $headers = get_headers($response['url']) )
        {
            foreach( $headers as $value )
            {
                if ( substr( strtolower($value), 0, 9 ) == "location:" )
                    return get_url( trim( substr( $value, 9, strlen($value) ) ) );
            }
        }
    }

    if (    ( preg_match("/>[[:space:]]+window\.location\.replace\('(.*)'\)/i", $content, $value) || preg_match("/>[[:space:]]+window\.location\=\"(.*)\"/i", $content, $value) ) &#038;&#038;
            $javascript_loop < 5
    )
    {
        return get_url( $value[1], $javascript_loop+1 );
    }
    else
    {
        return array( $content, $response );
    }
}</code></pre>
<p>This function allows me to pass a URL and have it be returned as the first index in an array. The second index contains another array of response headers as well.</p>
<h2>Replacing an IFRAME with cURL</h2>
<p>The particular service I'm working with uses <code>GET</code> variables to filter the data presented. I can literally use the same URL string in my cURL function and work with the data straight away. For example:</p>
<pre class="sh_php"><code>$service_url  = $service_base_url;
$service_url .= &quot;&amp;var1=X&quot;;
$service_url .= &quot;&amp;var2=Y&quot;;
$service_url .= &quot;&amp;api_key=&quot; . $service_api_key;

$request_results = get_url($service_url);

preg_match(&quot;/&lt;body.*\/body&gt;/s&quot;, $request_results[0], $pagecontent);

$pagecontent = $pagecontent[0];

$pagecontent = str_replace(&#x27;&lt;body&gt;&#x27;, &#x27;&#x27;, $pagecontent);
$pagecontent = str_replace(&#x27;&lt;/body&gt;&#x27;, &#x27;&#x27;, $pagecontent);

// I'd like to resize the images...
$pattern = &#x27;/\&lt; *[img][^\&gt;]*[src] *= *[\&quot;\&#x27;]{0,1}([^\&quot;\&#x27;\ &gt;]*)/i&#x27;;
$replacement = &#x27;&lt;img src=&quot;&#x27; . $imgpath . &#x27;/phpthumb/phpThumb.php?src=&#x27; . &#x27;$1&#x27; . &#x27;&amp;w=160&amp;h=110&amp;zc=1&#x27;;
$pagecontent = preg_replace($pattern, $replacement, $pagecontent);

echo $pagecontent;</code></pre>
<p>What's happening there is I'm first building the request URL (as the <code>GET</code> variables will change based on a few things) and then firing my <code>get_url()</code> function and passing the final URL. That's a great start, but of course the cURL request is going to return a full HTML document (including the <code>head</code>) which we don't need. A quick <code>preg_match</code> will pull out everything included within the <code>body</code> of the document, and we'll finally strip that out as well.</p>
<p>That leaves you with the remote page as would have been included in the <code>IFRAME</code> itself. You can write applicable CSS and do what you will with the markup. You can even go a step further and continue to refine the markup returned. In my case, I'd like to resize the images returned to fit the design I'm trying to implement. I've come to use <a href="http://phpthumb.sourceforge.net/">phpThumb</a> for all of my resizing needs and a quick <code>preg_replace</code> lets you reformat the <code>img src</code> to better match your design.</p>
<h3>Keep in mind the terms of service</h3>
<p>I'm currently waiting to hear back from the third party in an effort of following their terms of service. With the official documentation revolving around the inclusion of an <code>IFRAME</code> I'd like to make sure that this alternative method is acceptable before I put the remaining hours into customizing the output.</p>
]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/2009/11/23/avoiding-iframes-via-php-and-curl/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Crop and Resize Images with GD or ImageMagick (v1.1)</title>
		<link>http://mondaybynoon.com/2007/12/17/crop-and-resize-images-with-gd-or-imagemagick-v11/</link>
		<comments>http://mondaybynoon.com/2007/12/17/crop-and-resize-images-with-gd-or-imagemagick-v11/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 08:12:20 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Favorites]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[crop]]></category>
		<category><![CDATA[Cropper UI]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[GD]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/2007/12/17/crop-and-resize-images-with-gd-or-imagemagick-v11/</guid>
		<description><![CDATA[A new GD version has been released to complement the ImageMagick crop and resize with JavaScript and PHP. Crop and resize images from within your browser.]]></description>
			<content:encoded><![CDATA[<p>Over the past couple weeks, <a href="http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comments">conversation has picked up quite a bit</a> surrounding the <a href="http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comments">Crop &amp; Resize with JavaScript, PHP, and ImageMagick</a> demo I put together nearly a year ago. There were quite a few requests made in the comments, and there were even some developers beginning to offer their very own code. I&#8217;ve always meant to revisit the example and beef up the feature set a bit, and I&#8217;ve finally been able to do just that.</p>
<h2>Crop and Resize with GD</h2>
<p>Above all, the most asked question was &#8220;<a href="http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comment-7477">why only ImageMagick</a>&#8220;? I really don&#8217;t have a solid answer for that, other than the project itself was a way for me to get into using <a href="http://www.imagemagick.org/">ImageMagick</a> in a bit more detail than I ever had. I&#8217;m very happy to say that this version (as well as any future versions) now has equivalent ImageMagick <em>and GD</em> installations. You can choose one or the other in both the demo and download sections.</p>
<p><a class="demo" href="http://mondaybynoon.com/examples/crop-resize/1.1/gd/">Demo: GD Crop and Resize v1.1</a></p>
<p><a class="demo" href="http://mondaybynoon.com/examples/crop-resize/1.1/imagemagick/">Demo: ImageMagick Crop and Resize v1.1</a></p>
<p class="update">The demos and downloads have been removed temporarily due to a security issue. Replacements will be linked as soon as possible. Thank you for your patience. Please discontinue use as soon as possible until a revision has been posted.</p>
<p>Converting to <a href="http://www.boutell.com/gd/">GD</a> wasn&#8217;t a major undertaking thanks to the helpful comments on version 1.0. It did take some time getting the slider to properly convey dimensions that would result in an accurate recreation of the image. One thing I have noticed is that the GD version seems to result in lower quality output when compared directly to ImageMagick. If you&#8217;ve got a server with both GD and ImageMagick installed, take a minute to use the same image in both demos to see what the differences are. I plan on looking into this much further, but if you&#8217;re a bit more knowledgeable on the subject, I&#8217;d love to hear what you have to say. Could the answer be that ImageMagick is simply a superior piece of software? I noticed that GD gives you the option to control the quality of images when using certain functions, so I left image output at 90% for the time being (the default is 75%).</p>
<p>If you have any positive or negative experiences with the new GD version, please feel free to post your findings either below, or in an email to me. I&#8217;d be greatly appreciative of any data that comes through.</p>
<h3>Updates to the server side</h3>
<p>There were a number of fixes that needed to be done to the server side of things straight away. First and foremost was Linux dependency. I must admit, a Windows server didn&#8217;t cross my mind when I was working on version 1.0, so I tried to polish things up a bit in that regard. The <code>mv</code> lines have been replaced, as well as an update or two elsewhere. There could very well be some more Windows-specific issues to be dealt with, unfortunately I don&#8217;t have any Windows servers at my disposal to test with. Feedback in this area will be particularly helpful.</p>
<p>A small series of updates I made was to the file upload process itself. The example now only accepts files with a MIME type of <code>image/jpeg</code>. Future versions will allow for more image formats, but I&#8217;d like to do some more research before including it. There are also some checks on the filenames themselves, as there were some issues with particular circumstances in version 1.0.</p>
<p>There was some logic repair regarding the <code>$maxWidth</code> and <code>$maxHeight</code> variables you can set in the first step. As per request, <code>$minWidth</code> and <code>$minHeight</code> have also been added. This should allow you to really narrow down what image dimensions will result using these variables in conjunction with the <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">Cropper UI</a>. One issue that has not been included yet is taking the minimum and maximum values set in the first step into account when users have reached the resize stage of version 1.1. This will be handled in a future release.</p>
<p>Finally, the last noticeable feature to be added server side was the inclusion of <a href="http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comment-25838">image rotation</a>. When the final image is presented, image rotations of 90, 180, and 270 degrees will be available as well. You&#8217;re able to pull apart the code to retrieve which image you&#8217;d like to use, and can also include auto-generation using a form whenever you&#8217;d like. This was a larger hill to climb when it came to GD as none of the servers I have access to had PHP compiled with GD bundled, therefore giving me no access to <a href="http://www.php.net/imagerotate"><code>imagerotate()</code></a>. As reflected in the source, <a title="Alternative PHP function for imagerotate()" href="http://www.php.net/manual/en/function.imagerotate.php#73446">a function was written as an alternative</a>, and appears to work just fine. It checks to see if <code>imagerotate()</code> is available before taking the extra <abbr title="Central Processing Unit">CPU</abbr> cycles doing it &#8216;by hand&#8217;.</p>
<p><span id="more-113"></span></p>
<h3>Updates to the <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">Cropper UI</a></h3>
<p>I can&#8217;t credit <a href="http://www.defusion.org.uk/">Dave Spurr</a> enough for his <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">Cropper UI</a> that powers the entire front end of the cropping mechanism this installation provides. He had made a number of updates after my version 1.0 release, so first things first I went ahead and upgraded to his most recent version.</p>
<p>The second most asked for feature was a specific alteration to the Cropper UI itself. Whether it be minimum dimensions, maximum dimensions, or something else, it seemed like many people would like to use the script, but the openness of the Cropper UI was in fact a limitation. I made an effort to indicate that Dave Spurr included many of the requested features right out the box and documented them well on his website. To help with the version 1.1 demo, I&#8217;ve included a few Cropper UI instances to demonstrate its robustness. When you check out the demo, you&#8217;ll see a new option to choose the crop type you&#8217;d like to use. I&#8217;ve included the following by default:</p>
<dl>
<dt>Basic crop</dt>
<dd>Includes the most basic version of the Cropper UI. Unrestricted as far as crop dimension is concerned.</dd>
<dt>Ratio (16:9)</dt>
<dd>A 16:9 ratio will be applied to the Cropper UI. There are no restrictions for width or height.</dd>
<dt>Minimum Dimensions (200&#215;200)</dt>
<dd>The Cropper UI will require a minimum 200px by 200px crop area and will not allow anything less.</dd>
<dt>Minimum Dimensions (200&#215;200) with Ratio (1:1)</dt>
<dd>The Cropper UI will require a minimum 200px by 200px crop area and will not allow anything less. It will also apply a 1 to 1 ratio when adjusting the crop area.</dd>
<dt>Maximum Dimensions (200&#215;200)</dt>
<dd>The Cropper UI will require a maximum 200px by 200px crop area and will not allow anything less.</dd>
<dt>Maximum Dimensions (200&#215;200) with Ratio (1:1)</dt>
<dd>The Cropper UI will require a maximum 200px by 200px crop area and will not allow anything less. It will also apply a 1 to 1 ratio when adjusting the crop area.</dd>
<dt>Fixed Dimensions (200&#215;200)</dt>
<dd>You&#8217;re provided with a crop area at a fixed size of 200px by 200px. The drag handles are also removed as an added convenience.</dd>
<dt>Minimum Dimensions (100&#215;100) &amp; Maximum Dimensions (200&#215;200)</dt>
<dd>With this option, you&#8217;re limited to a crop area range scaling from 100px by 100px to 200px by 200px.</dd>
</dl>
<p>The Cropper UI is quite impressive in and of itself as you can see by the number of options you can apply by changing some values. For example, one thing I didn&#8217;t include in the demo is a Cropper UI that is limited to minimum and maximum dimensions as well as an aspect ratio of 1:1. You can easily invoke a Cropper UI with these attributes by creating a new file (<code>lib/init_cropper/min_max_ratio.js</code> for example) and inserting the following:</p>
<pre class="sh_javascript"><code>function onEndCrop(coords, dimensions) {
	$('cropX').value = coords.x1;
	$('cropY').value = coords.y1;
	$('cropWidth').value = dimensions.width;
	$('cropHeight').value = dimensions.height;
}

Event.observe( window, 'load', function() {
	new Cropper.Img(
		'cropImage', {
			ratioDim: { x: 1, y: 1 },
			minWidth: 200,
			minHeight: 200,
			maxWidth: 300,
			maxHeight: 300,
			onEndCrop: onEndCrop
		}
	);
});</code></pre>
<p>Swapping in this JavaScript would invoke a new Cropper UI for your image with a minimum dimension of 200px by 200px, a maximum dimension of 300px by 300px, as well as an aspect ratio of 1:1. Going further, you&#8217;re also able to specify a minimum or maximum for a height or width alone. This will result in a Cropper UI with handles only on the top and bottom if you wish. I would definitely suggest checking out the official website for <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">Dave Spurr&#8217;s Cropper UI</a> for more details</p>
<h3>Download &amp; installation instructions</h3>
<p>Installation is very straightforward. Download links to follow.</p>
<ol>
<li>Download the GD or ImageMagick version</li>
<li>Extract</li>
<li>Upload to your webserver</li>
<li><em>Give write permissions</em> to the <code>working</code> folder and subfolders</li>
<li>Begin using the demo</li>
</ol>
<p><a class="zipDownload" href="http://mondaybynoon.com/examples/crop-resize/1.1/download/crop-resize-gd-1.1.zip">Download GD Crop and Resize v1.1 (.zip)</a></p>
<p><a class="zipDownload" href="http://mondaybynoon.com/examples/crop-resize/1.1/download/crop-resize-imagemagick-1.1.zip">Download ImageMagick Crop and Resize v1.1 (.zip)</a></p>
<p class="update">The demos and downloads have been removed temporarily due to a security issue. Replacements will be linked as soon as possible. Thank you for your patience. Please discontinue use as soon as possible until a revision has been posted.</p>
<p>Many times, if you&#8217;re experiencing odd behavior such as pages turning up blank, there is an issue with write permissions on your server. The demo will need write access to the directory in which it is stored as well as the <code>working</code> folder and all folders within it. Errors with the code itself will more than likely be output to the screen. If that happens, please feel free to post your errors at your earliest convenience.</p>
<h3>What about AJAX?</h3>
<p>Another request that popped up more than once was a request for an AJAX version, something that didn&#8217;t require the page to reload. I thought about working out something such as that but quickly dismissed it, at least for now. My intention with this project was to provide something which would be used by the widest audience possible. Too many times have I seen examples too far into their own development to prevent me from writing something from scratch. In my opinion, an AJAX version of this example would prevent easy adoption and inclusion for many developers. AJAX may be a possibility for a future version, but I&#8217;d like to seriously consider as many angles as possible. This directly relates to the (lack of) design when looking at the demonstration. I wanted to keep things minimal in order to create the least work for anyone who wants to try incorporating this into something they&#8217;ve written.</p>
<p>I hope at the very least, the GD version presents itself as useful to at least a few people over the coming months. I do plan continuing work on future version, I simply hope it doesn&#8217;t take as long as this revision has. Please provide any comments you&#8217;d like, especially bug reports, and enjoy the demo!</p>
]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/2007/12/17/crop-and-resize-images-with-gd-or-imagemagick-v11/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>PHP, MySQL, and Contact Management: Contacts 0.1</title>
		<link>http://mondaybynoon.com/2007/10/22/php-mysql-and-contact-management-contacts-01/</link>
		<comments>http://mondaybynoon.com/2007/10/22/php-mysql-and-contact-management-contacts-01/#comments</comments>
		<pubDate>Mon, 22 Oct 2007 15:13:01 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[Favorites]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[contact]]></category>
		<category><![CDATA[FOSS]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/2007/10/22/php-mysql-and-contact-management-contacts-01/</guid>
		<description><![CDATA[Contacts is a free and open source (FOSS) contact management Web application running on PHP and MySQL]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been a bit obsessed with keeping an up-to-date list of contacts. I think it goes hand in hand with the <abbr title="Obsessive Compulsive Disorder">OCD</abbr> I&#8217;ve diagnosed myself with when it comes to computers and my using them. One thing that seems to constantly come up in the office is a lack of client contact information. Different people have different ways of storing such information. Some have a physical address book, some keep everything on their computers, and others are able to remember everything they need.</p>
<p>I thought this little problem of mine would be a good reason to whip up a really simple address book we could run on our in-house server. The idea would be to keep an up to date listing of basic contact information for any clients we&#8217;ve ever done business with. It wouldn&#8217;t be anything spectacular, just an easy way to enter in basic contact information for people, and group them by their company. This past weekend, I fired up <a href="http://www.panic.com/coda">Coda</a> and got to work.</p>
<h2>Contacts. <abbr title="Free and Open Source">FOSS</abbr> contact management.</h2>
<p><img src="http://mondaybynoon.com/images/contacts01.jpg" alt="Screenshot of Contacts 0.1" /></p>
<p>Contacts is a really simple application modeled after many desktop address books. When you bring it up, you&#8217;re given a list of entered contacts, as well as a list of companies that have been entered. Clicking a company name will limit the contacts list to only those contacts which are part of the selected company. Clicking a contact name will take you to a details page which contains information about the selected contact. This details page is (partially) equipped with <a href="http://microformats.org/wiki/hcard">hCard</a>. At the bottom of the details page, you&#8217;re able to edit or delete the active contact.</p>
<p>I told you it was basic.</p>
<p>Contacts uses some icons from the famous <a href="http://www.famfamfam.com/lab/icons/silk/">Silk</a> icon set, as well as an icon from the <a href="http://tango.freedesktop.org/Tango_Icon_Gallery">Tango</a> icon set.</p>
<h3>Getting on to the demonstration</h3>
<p>The demonstration is the best part. You can check out the <a href="http://mondaybynoon.com/examples/contacts/0.1/">Contacts 0.1 Demo</a> and see what it&#8217;s all about. The demo does have some restrictions you should know about. First and foremost, when you hit the demo, you&#8217;ll be asked for your name. This is used to ensure that any data you add/remove/edit will be seen only by you. Obviously this is a very simple solution, and there is a chance that two people could enter the same name. Please keep this in mind before entering any sensitive data. Also, the database will be purged on a regular basis to control table size. If your data goes missing while you&#8217;re checking out the demonstration, (hopefully) it&#8217;s just the clean-up process.</p>
<p class="update">The live demo has been temporarily disabled due to a recent server change.</p>
<p>I can&#8217;t stress enough that this version is very early in development, so if you do happen to come across any bugs or awkward behavior, please take a few minutes to <a href="http://mondaybynoon.com/contact">send me an email</a>.</p>
<h3>Contacts is definitely a work in progress</h3>
<p>The 0.1 release of Contacts is <em>definitely a work in progress</em>. As <a href="http://cdevroe.com">Colin Devroe</a> reminded me; &#8220;<abbr title="Free and Open Source">FOSS</abbr> is always release early, release often&#8221;. I&#8217;m going to keep this in mind and mark this project as &#8216;live development&#8217;. In much of the same style as a live redesign, this project will [ideally] be updated often, and I&#8217;m going to chronicle the changes as I go along.</p>
<p><a class="zipDownload" href="http://mondaybynoon.com/examples/contacts/0.1/contacts0.1.zip">Download Contacts 0.1</a></p>
<p>To install Contacts 0.1, you&#8217;ll need a server running PHP and MySQL. You can then follow these steps:</p>
<ol>
<li>Create a MySQL database and user with appropriate privileges</li>
<li>Extract the archive and copy the contents into an empty folder</li>
<li>Edit <code>config.php</code> and enter the correct <code>DB_NAME</code>, <code>DB_USER</code>, and <code>DB_PASSWORD</code></li>
<li>Hit <code>install.php</code> in your browser (sets up table)</li>
<li>Delete <code>install.php</code></li>
</ol>
<h3>Feature Requests</h3>
<p>As I was working on Contacts, there were a number of things that came to mind that I&#8217;d like to include as features go. My main goal with this project was to end up with a <strong>simple and lightweight</strong> contact management Web app, so I don&#8217;t want to bloat things with completely superfluous features. Some of the things I plan on adding:</p>
<ul>
<li>Better hCard support</li>
<li>Multiple phone numbers</li>
<li>Phone number types (i.e. work, home, mobile, etc)</li>
<li>Multiple email addresses</li>
<li>Mobile version</li>
<li>Better search functionality (currently only works with single words)</li>
<li>Progressive enhancement via JavaScript</li>
<li>Optimized database structure</li>
</ul>
<p>My list goes on, and I hope to implement these features as soon as possible. What other features would you like to see in Contacts? Is it something that&#8217;s of any use to anyone besides me?</p>
]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/2007/10/22/php-mysql-and-contact-management-contacts-01/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Are Inline Styles Sometimes Okay? When? Why?</title>
		<link>http://mondaybynoon.com/2007/06/25/are-inline-styles-sometimes-okay-when-why/</link>
		<comments>http://mondaybynoon.com/2007/06/25/are-inline-styles-sometimes-okay-when-why/#comments</comments>
		<pubDate>Mon, 25 Jun 2007 12:32:52 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Semantics]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[inline]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/2007/06/25/are-inline-styles-sometimes-okay-when-why/</guid>
		<description><![CDATA[Limitations range greatly from one CMS to another, some have embraced Web standards and produce semantically rich and valid markup, while others have put standards on the back burner.  One issue I&#8217;ve had some reoccurring trouble with in the past is the combination of a CMS with managed images that are part of the design as opposed to having informational value.]]></description>
			<content:encoded><![CDATA[<p>Nearly each and every project I work on professionally is heavily integrated with a custom Content Management System that has been developed by programmers on the team for many years.  What&#8217;s great about having a custom built <acronym title="Content Management System">CMS</acronym> is that I can personally talk to the developers regarding a feature request, and that feature can be added within the next few days, or even by that afternoon.  Content Management Systems are a great thing in my opinion, but like everything, they&#8217;ve got their limits.</p>
<p>Limitations range greatly from one CMS to another, some have embraced Web standards and produce semantically rich and valid markup, while others have put standards on the back burner.  One issue I&#8217;ve had some reoccurring trouble with in the past is the combination of a CMS with managed images that are part of the design as opposed to having informational value.  To be more clear, sometimes a client will request to have control over a piece of stock imagery represented on any number of pages.  This becomes an issue because traditionally, when images are uploaded in context, they&#8217;re treated as having informational value and included using an <code>img</code> tag with a descriptive <code>alt</code> attribute.</p>
<h2>So what&#8217;s the problem with inline images?</h2>
<p>There&#8217;s nothing at all wrong with inline images &#8212; as long as it is applicable that they be represented in the markup as an inline image.  When images are included in the markup, they <a href="http://mondaybynoon.com/2006/03/20/semantic-image-use/">should have informational value</a>.  Images with the sole purpose of adding to the design can be better included via your style sheet as to preserve the separation of style and content.</p>
<p>Inline images definitely have their place on the Web, but it is a far different position than images used for the site design purposes only.  Those images should be included via the associated style sheets, defined either by hand, or through the theme management of the CMS. Keeping that in mind, there can be a time when images that should be defined using CSS are instead included via the CMS front end.</p>
<h3>What can be done about the situation?</h3>
<p>The trouble with trying to give a client control over design-oriented images is when it comes to referencing the dynamic content.  With inline images, it&#8217;s easy in that the image URL can be pulled from the back end and used in any way you please.  It becomes a bit harder when a style sheet needs to be updated with a change in URL. I&#8217;ve read an article or two about using PHP (or any other server side language) to generate style sheets on the fly, but including PHP <code>echo</code>s in CSS doesn&#8217;t sit well with me.  It also restricts that style sheet to the language in which it has been written, therefore forcing an otherwise unnecessary update should the style sheet be written strictly in CSS.</p>
<p>Another way to go about things would be to have the CMS handle a number of style sheets the can be, as was an original intention, cascaded upon one another.  These files could be generated, taking into consideration any images that are managed via the CMS, and then included with the site CSS.</p>
<p>A more abstract method that could be possible is using a static URL in your style sheet that references the dynamic image, but instead of updating the URL, the CMS will update the image file itself.  Effectively the URL remains the same, but the target image itself can be updated by the client via the CMS.</p>
<h4>What&#8217;s this got to do with inline styles?</h4>
<p>While any of the above can be considered a solution, not everybody has open access to the inner workings of their CMS.  Sometimes you&#8217;re literally stuck with an image URL and that&#8217;s all you get.  At this point, is it better to include the image as a <code>background-image</code> via inline CSS?  Is it acceptable to ignore document semantics and include the image inline?</p>
<p>In my personal opinion, I think I&#8217;d opt to go with using inline CSS and a <code>background-image</code> as opposed to sacrificing semantics.  While inline CSS is considered difficult to manage, in this case the CMS is doing the management for you. While the end result isn&#8217;t completely ideal, I have to consider it more appropriate than using an inline image.</p>
<p>Is this an issue you&#8217;ve ever had to worry about before?  Do you really consider it an issue at all?</p>
]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/2007/06/25/are-inline-styles-sometimes-okay-when-why/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Crop &amp; Resize with JavaScript, PHP, and ImageMagick</title>
		<link>http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/</link>
		<comments>http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comments</comments>
		<pubDate>Mon, 22 Jan 2007 11:32:24 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[crop]]></category>
		<category><![CDATA[GD]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/</guid>
		<description><![CDATA[This demo was put together in an effort to make very basic image editing easier for less technically inclined users.  The main intention is to provided it as a component to include in a variety of applications including custom content management systems or Web applications.]]></description>
			<content:encoded><![CDATA[<p class="update"><strong>Update:</strong> <a href="http://mondaybynoon.com/2007/12/17/crop-and-resize-images-with-gd-or-imagemagick-v11/">A new version</a> of this example and demonstration has been released. Version 1.1 includes a <strong>GD</strong> version of the script as well as a number of functional improvements worth checking out.</p>
<p class="update"><strong>Update:</strong> There has been significant discussion in the comments regarding a GD version of this script. I have re-released v1.0 of this example as a GD version as well as an ImageMagick version. <del>You can find both downloads below</del> <ins>The download has been removed in preparation of version 1.1 due for release on December 17, 2007</ins>. They behave function exactly the same as one another. Thanks for all the contributions (<a href="http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comment-39674">Stefan Leever</a> and others) and requests!</p>
<p>Image management is often a big part of a comprehensive <abbr title="Content Management System">CMS</abbr>, and in my personal experience, has been one of the more difficult areas to make really easy for people to use.  Those that are technically inclined are often able to successfully format an image to their liking if given proper instruction.  On the other hand there are many who find image editing to be difficult, intimidating, and/or confusing.</p>
<p><a class="viewDemo" href="http://mondaybynoon.com/examples/image_crop_resize/">View JavaScript Crop &amp; Resize Demo</a></p>
<p class="update">The demos and downloads have been removed temporarily due to a security issue. Replacements will be linked as soon as possible. Thank you for your patience. Please discontinue use as soon as possible until a revision has been posted.</p>
<p>In an effort to better the situation, I put together a demo which gives the end user the ability to upload, crop, and resize their image from within their Web browser.  The intention, on my end, would be to use it for server-side image pre-processing before the image is used by a client in their <abbr title="Content Management System">CMS</abbr> for their website.</p>
<h2>What powers JavaScript cropping &amp; resizing</h2>
<p>This demo wouldn&#8217;t be possible without a number of scripts that can not go without mention.  First and foremost, the entire client side process is based on the <a href="http://prototypejs.org/">Prototype JavaScript Library</a>.  Prototype has just been updated to version 1.5.0 and it acts as the foundation for both the crop and resize stages of the demo.</p>
<p>Another essential piece of this demo is <a href="http://script.aculo.us/">script.aculo.us</a>, a collection of effects addons for Prototype.  It provides some really excellent <abbr title="User Interface">UI</abbr> tools to work with as well as various animation effects.  Both the crop and resize stages use script.aculo.us features.</p>
<h4>JavaScript Image Cropper UI by Dave Spurr</h4>
<p>In my opinion, the most comprehensive aspect of this JavaScript image crop and resize demo is the cropping stage.  The <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript Image Cropper UI</a> by Dave Spurr is a script that deserves the spotlight in the demo.  It was written using both <a href="http://prototypejs.org/">Prototype</a> and <a href="http://script.aculo.us/">script.aculo.us</a> and it is the one piece that really brings the demo together.</p>
<p>Dave&#8217;s JavaScript Image Cropper UI has many more capabilities than the basic version included in the demo.  If you check out his documentation he includes cropper user interfaces that can inherit various options such as retaining an aspect ratio, min/max width/height, and also display a crop preview if desired.  The <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript Image Cropper UI</a> by Dave Spurr is a feat in and of itself and should be given proper recognition.</p>
<h2>Server requirements</h2>
<p>The provided demo was written for a Linux based Web server running <a href="http://www.php.net/">PHP</a> and having <a href="http://www.imagemagick.org/">ImageMagick</a> installed.  It should run on a Windows based server with minimal adjustments, such as including the path to your ImageMagick install for each command.</p>
<p><a href="http://www.imagemagick.org/">ImageMagick</a> is a powerful command line image editor which performs all of the actual image transformations server-side.  Installation is usually quite easy after following directions written for your Web server configuration.</p>
<p><span id="more-61"></span></p>
<h4>Installation notes</h4>
<p>After you&#8217;ve downloaded the demo, extract the files to a common directory and upload that folder to your server.  After uploading, the directory will need to be given write permissions.  Failing to do so will destroy the functionality of the demo as uploads won&#8217;t be saved and there would be no way to create the adjusted images.</p>
<p><a class="zipDownload" href="http://mondaybynoon.com/examples/image_crop_resize/download/mbn_crop_resize_v1.0.zip">Download ImageMagick Crop &amp; Resize (.zip)</a></p>
<p class="update">The demos and downloads have been removed temporarily due to a security issue. Replacements will be linked as soon as possible. Thank you for your patience. Please discontinue use as soon as possible until a revision has been posted.</p>
<h5>Closing thoughts about cropping and resizing with JavaScript</h5>
<p>This demo was put together in an effort to make very basic image editing easier for less technically inclined users.  The main intention is to provide it as a component to include in a variety of applications including custom content management systems or Web applications.</p>
<p>I hope the demo proves to be useful, but I absolutely welcome any comments and criticisms readers may have.  Please take a minute to post your thoughts below so that the demo can be in constant revision to ensure it&#8217;s effectiveness.</p>
]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/feed/</wfw:commentRss>
		<slash:comments>104</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using xcache (user agent is rejected)
Database Caching using xcache

Served from: mondaybynoon.com @ 2010-07-30 22:11:32 -->