Saturday, August 4, 2012

The difference between PHP "include" and "require" statements?

Although I have been developing in PHP for years I did not realize what the difference between "require" and "include" statements were.  You see them used often and seem to be interchangeable. There is, however, one main difference. Include and require are identical, except upon failure:
  • require will produce a fatal error (E_COMPILE_ERROR) and stop the script
  • include will only produce a warning (E_WARNING) and the script will continue
So, if you want the execution to go on and show users the output, even if the include file is missing, use include. Otherwise, always use require to help avoid compromising your application's security and integrity.

Of course, I recommend to use the require_once and include_once statements when including code that may be loaded by multiple files.  This will prevent trying to load the same file twice.

Wednesday, July 25, 2012

Minify now supports conditionals

CSS can be a real pain since each browser seems to have it's own flavor of the W3C Standard.  For instance, if you want to rotate your text you would have to do something like the following:
.w_rotate_up {
    /*firefox*/
    -moz-transform: rotate(270deg);
    -moz-transform-origin: bottom left;
    /*safari*/
    -webkit-transform: rotate(270deg);
    /*opera*/
    -o-transform: rotate(270deg);
    /*msie*/
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    -ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";
}

Having to have separate tags in your CSS means that much of the CSS you are pushing just gets ignored by the browser anyway.  To solve this I have added CSS Conditionals into minify_css.php.  The supported conditional operators are: lt, gt, lte, gte, eq, not.  The supported browsers are firefix,msie,chrome,safari,opera.  To make a CSS line conditional simply put brackets around the contidion at the beginning of the css line.  For instance:
  • not msie: [not msie]
  •  to only show for msie: [msie]
  • to only show for msie 6 [msie eq 6]
  • to only show for msie greater than 6 [msie gt 6]
  • to ony show for msie less than or equal to 6 [msie lte 6]
Here is how the above code would look before it was processed by a Firefox browser:
.w_rotate_up {
    /*firefox*/
    [firefox]-moz-transform: rotate(270deg);
    [firefox]-moz-transform-origin: bottom left;
    /*safari*/
    [safari]-webkit-transform: rotate(270deg);
    /*opera*/
    [opera]-o-transform: rotate(270deg);
    /*msie*/
    [msie lt 8]filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    [msie gte 8]-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";
    }
and here is how it will look like to the Firefox browser
.w_rotate_up {
    -moz-transform: rotate(270deg);
    -moz-transform-origin: bottom left;
    }
 and in Internet Explorer:
.w_rotate_up {
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    -ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";
    }

Hope this helps! It has helped me.


Tuesday, May 22, 2012

Better tinyMCE integration!

WaSQL has been integrated with tinyMCE for a while.  That said, there have been issues when using tinyMCE within AJAX calls since tinyMCE does some fancy stuff to the DOM.  I believe that this update fixes any AJAX related problems when using tinyMCE.  The magic is to remove the tinyMCE instance before rewriting the div content. This required some fancy footwork on the WaSQL side also.

Look forward to hearing if this solved your problems!

Steve

Monday, May 14, 2012

WaSQL Updates

Morning fellow WaSQLers!
     I made a boatload of updates to WaSQL this weekend.  Here are a few of the changes:

MINIFY Changes:
    /php/minify_js.php and /php/minify_css.php got a major overall and now support a ton more stuff.  Read the readme.txt in the custom folders for details. They now support almost everything.

JS and CSS fields in _pages and _templates:
    as part of the minify changes the _pages and _templates tables now have two additonal fields - js and css.  javascript and css placed in these tables will automatically load with minify.  So you can now place your template or page specific javascript or css right into the template or page record.

From my testing it looks like these changes can speed up the page load time.

As always, update your staging areas first and test your site before updating your live area. 

Happy WaSQLing!