<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: JLoader PHP Class</title>
	<atom:link href="http://www.hazaah.com/programming/php/jloader-php-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hazaah.com/programming/php/jloader-php-class/</link>
	<description>buffle the world</description>
	<lastBuildDate>Fri, 12 Feb 2010 18:20:09 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Vladimir Cvetic</title>
		<link>http://www.hazaah.com/programming/php/jloader-php-class/comment-page-1/#comment-8665</link>
		<dc:creator>Vladimir Cvetic</dc:creator>
		<pubDate>Thu, 09 Oct 2008 05:17:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.hazaah.com/?p=98#comment-8665</guid>
		<description>&quot;It&#039;s a good practise&quot; because...?</description>
		<content:encoded><![CDATA[<p>&#8220;It&#8217;s a good practise&#8221; because&#8230;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian</title>
		<link>http://www.hazaah.com/programming/php/jloader-php-class/comment-page-1/#comment-8663</link>
		<dc:creator>Ian</dc:creator>
		<pubDate>Wed, 08 Oct 2008 19:53:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.hazaah.com/?p=98#comment-8663</guid>
		<description>The is_array() check prevents PHP from possibly throwing type mismatch warnings on the subsequent calls which are only meant for arrays.  The count() check only saves a few CPU cycles in this case, but it is a good best practice to use these two in tandem.

I suggest developing your code with logging enabled and your error_reporting set to either &quot;E_ALL&quot; or &quot;E_ALL &amp; ~E_NOTICE&quot;.  This will help you maintain best practices in your code.</description>
		<content:encoded><![CDATA[<p>The is_array() check prevents PHP from possibly throwing type mismatch warnings on the subsequent calls which are only meant for arrays.  The count() check only saves a few CPU cycles in this case, but it is a good best practice to use these two in tandem.</p>
<p>I suggest developing your code with logging enabled and your error_reporting set to either &#8220;E_ALL&#8221; or &#8220;E_ALL &amp; ~E_NOTICE&#8221;.  This will help you maintain best practices in your code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vladimir Cvetic</title>
		<link>http://www.hazaah.com/programming/php/jloader-php-class/comment-page-1/#comment-8656</link>
		<dc:creator>Vladimir Cvetic</dc:creator>
		<pubDate>Tue, 07 Oct 2008 20:03:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.hazaah.com/?p=98#comment-8656</guid>
		<description>I noticed that validation on: 
if ($src &amp;&amp; !file_exists($src) &amp;&amp; !file_exists($this-&gt;home_path.$src))

was not correct your will do better.

But I don&#039;t agree on the 
if (is_array($depends) &amp;&amp; count($depends))
it&#039;s just silly to check for size of array. Even if size is 0, foreach will not trigger.</description>
		<content:encoded><![CDATA[<p>I noticed that validation on:<br />
if ($src &amp;&amp; !file_exists($src) &amp;&amp; !file_exists($this-&gt;home_path.$src))</p>
<p>was not correct your will do better.</p>
<p>But I don&#8217;t agree on the<br />
if (is_array($depends) &amp;&amp; count($depends))<br />
it&#8217;s just silly to check for size of array. Even if size is 0, foreach will not trigger.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian</title>
		<link>http://www.hazaah.com/programming/php/jloader-php-class/comment-page-1/#comment-8655</link>
		<dc:creator>Ian</dc:creator>
		<pubDate>Tue, 07 Oct 2008 16:36:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.hazaah.com/?p=98#comment-8655</guid>
		<description>I was bored, so I rewrote your code:
&lt;?php
class JLoader{  
  
    public $loaded = array();  
    public $repository = &quot;/common/jloader&quot;;  
    public $home_path = &quot;/www/mysite&quot;;  

    /** 
     * 
     * @since 1.0.0 
     * 
     * @param string $handler Valid external file handler name. 
     * @param int&#124;bool $ver Optional. Script version number. Default is false. 
     * @param array&#124;bool $depends Array of valid handler dependencies. 
     * @return bool 
     */  
    public function load($handler, $ver = false, $src = false, $depends=false)  
    {  
        if (!$src)  
        {  
        		if($ver)
        		{
            	$src = $this-&gt;repository.&quot;/$handler/$handler.js?ver=$ver&quot;;
        		} else {
	            $src = $this-&gt;repository.&quot;/$handler/$handler.js&quot;;
        		}
        }  
  
        if ($src &amp;&amp; !file_exists($src) &amp;&amp; !file_exists($this-&gt;home_path.$src))
        {  
             trigger_error(&quot;ExtLoader::load($handler, $ver, $src) sad file &quot;.$src.&quot; doesn&#039;t exist in local or home path.&quot;);  
             return false;
        }  

        if (is_array($depends) &amp;&amp; count($depends))
        {  
            foreach($depends as $script)  
            {  
                $this-&gt;load($script);
            }  
        }  
        $this-&gt;loaded[$handler] = &#039;&lt;script type=&quot;text/javascript&quot; src=&quot;%27.$src.%27&quot;&gt;&lt;/script&gt;&#039;;  
  
        return true;  
    }  
  
    /** 
     * Print loaded Javascript files. 
     * 
     * @since 1.0.0 
     * 
     * @return unknown 
     */  
    function printjs()  
    {  
        foreach($this-&gt;loaded as $script)  
        {  
            echo $script.&quot;\n&quot;;  
        }  
    }  
}</description>
		<content:encoded><![CDATA[<p>I was bored, so I rewrote your code:<br />
&lt;?php<br />
class JLoader{  </p>
<p>    public $loaded = array();<br />
    public $repository = &#8220;/common/jloader&#8221;;<br />
    public $home_path = &#8220;/www/mysite&#8221;;  </p>
<p>    /**<br />
     *<br />
     * @since 1.0.0<br />
     *<br />
     * @param string $handler Valid external file handler name.<br />
     * @param int|bool $ver Optional. Script version number. Default is false.<br />
     * @param array|bool $depends Array of valid handler dependencies.<br />
     * @return bool<br />
     */<br />
    public function load($handler, $ver = false, $src = false, $depends=false)<br />
    {<br />
        if (!$src)<br />
        {<br />
        		if($ver)<br />
        		{<br />
            	$src = $this-&gt;repository.&#8221;/$handler/$handler.js?ver=$ver&#8221;;<br />
        		} else {<br />
	            $src = $this-&gt;repository.&#8221;/$handler/$handler.js&#8221;;<br />
        		}<br />
        }  </p>
<p>        if ($src &amp;&amp; !file_exists($src) &amp;&amp; !file_exists($this-&gt;home_path.$src))<br />
        {<br />
             trigger_error(&#8221;ExtLoader::load($handler, $ver, $src) sad file &#8220;.$src.&#8221; doesn&#8217;t exist in local or home path.&#8221;);<br />
             return false;<br />
        }  </p>
<p>        if (is_array($depends) &amp;&amp; count($depends))<br />
        {<br />
            foreach($depends as $script)<br />
            {<br />
                $this-&gt;load($script);<br />
            }<br />
        }<br />
        $this-&gt;loaded[$handler] = &#8216;&lt;script type=&#8221;text/javascript&#8221; src=&#8221;%27.$src.%27&#8243;&gt;&lt;/script&gt;&#8217;;  </p>
<p>        return true;<br />
    }  </p>
<p>    /**<br />
     * Print loaded Javascript files.<br />
     *<br />
     * @since 1.0.0<br />
     *<br />
     * @return unknown<br />
     */<br />
    function printjs()<br />
    {<br />
        foreach($this-&gt;loaded as $script)<br />
        {<br />
            echo $script.&#8221;\n&#8221;;<br />
        }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Nieuwoudt</title>
		<link>http://www.hazaah.com/programming/php/jloader-php-class/comment-page-1/#comment-8653</link>
		<dc:creator>Sean Nieuwoudt</dc:creator>
		<pubDate>Mon, 06 Oct 2008 22:28:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.hazaah.com/?p=98#comment-8653</guid>
		<description>Done something similar myself for some of my CodeIgniter apps.

Thanks!</description>
		<content:encoded><![CDATA[<p>Done something similar myself for some of my CodeIgniter apps.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
