cvs: smarty / NEWS Smarty.class.php /docs designers.sgml
| From: | Monte Ohrt | Date: | Wed, 01 May 2002 15:40:46 +0000 |
| Subject: | cvs: smarty / NEWS Smarty.class.php /docs designers.sgml | ||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-79@lists.php.net to get a copy of this message | ||
mohrt Wed May 1 11:40:46 2002 EDT
Modified files:
/smarty NEWS Smarty.class.php
/smarty/docs designers.sgml
Log:
fixed bug with resource testing and include_path
Index: smarty/NEWS diff -u smarty/NEWS:1.193 smarty/NEWS:1.194 --- smarty/NEWS:1.193 Tue Apr 30 10:41:36 2002 +++ smarty/NEWS Wed May 1 11:40:44 2002 @@ -1,3 +1,5 @@ + - fixed bug with resource testing, and include_path (Monte) + Version 2.1.0 ------------- Index: smarty/Smarty.class.php diff -u smarty/Smarty.class.php:1.272 smarty/Smarty.class.php:1.273 --- smarty/Smarty.class.php:1.272 Tue Apr 30 10:41:36 2002 +++ smarty/Smarty.class.php Wed May 1 11:40:44 2002 @@ -804,13 +804,18 @@ if ($resource_type == 'file') { $readable = false; - $include_paths = preg_split('![:;]!', ini_get('include_path')); - foreach ($include_paths as $path) { - if (@is_file($path . DIRECTORY_SEPARATOR . $resource_name)) { - $readable = true; - break; - } - } + if(@is_file($resource_name)) { + $readable = true; + } else { + // test for file in include_path + $include_paths = preg_split('![:;]!', ini_get('include_path')); + foreach ($include_paths as $path) { + if (@is_file($path . DIRECTORY_SEPARATOR . $resource_name)) { + $readable = true; + break; + } + } + } } else if ($resource_type != 'file') { $readable = true; $resource_func = $this->_plugins['resource'][$resource_type][0][0]; Index: smarty/docs/designers.sgml diff -u smarty/docs/designers.sgml:1.23 smarty/docs/designers.sgml:1.24 --- smarty/docs/designers.sgml:1.23 Mon Apr 29 17:13:39 2002 +++ smarty/docs/designers.sgml Wed May 1 11:40:45 2002 @@ -1395,6 +1395,120 @@ </html></programlisting> </example> </sect1> + <sect1 id="language.function.foreach"> + <title>foreach,foreachelse</title> + <informaltable frame=all> + <tgroup cols=5> + <colspec colname=param align=center> + <colspec colname=type align=center> + <colspec colname=required align=center> + <colspec colname=default align=center> + <colspec colname=desc> + <thead> + <row> + <entry>Attribute Name</entry> + <entry>Type</entry> + <entry>Required</entry> + <entry>Default</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>from</entry> + <entry>string</entry> + <entry>Yes</entry> + <entry><emphasis>n/a</emphasis></entry> + <entry>The name of the array you are looping through</entry> + </row> + <row> + <entry>item</entry> + <entry>string</entry> + <entry>Yes</entry> + <entry><emphasis>n/a</emphasis></entry> + <entry>The name of the variable that is the current + element</entry> + </row> + <row> + <entry>key</entry> + <entry>string</entry> + <entry>No</entry> + <entry><emphasis>n/a</emphasis></entry> + <entry>The name of the variable that is the current key</entry> + </row> + <row> + <entry>name</entry> + <entry>string</entry> + <entry>No</entry> + <entry><emphasis>n/a</emphasis></entry> + <entry>The name of the foreach loop for accessing + foreach properties</entry> + </row> + </tbody> + </tgroup> + </informaltable> + <para> + <emphasis>foreach</emphasis> loops are an alternative to + <emphasis>section</emphasis> loops. <emphasis>foreach</emphasis> is + used to loop over a single associative array. The syntax for + <emphasis>foreach</emphasis> is much easier than + <emphasis>section</emphasis>, but as a tradeoff it can only be used + for a single array. <emphasis>foreach</emphasis> tags must be + paired with <emphasis>/foreach</emphasis> tags. Required parameters + are <emphasis>from</emphasis> and <emphasis>item</emphasis>. The + name of the foreach loop can be anything you like, made up of + letters, numbers and underscores. <emphasis>foreach</emphasis> + loops can be nested, and the nested foreach names must be unique + from each other. The <emphasis>from</emphasis> variable (usually an + array of values) determines the number of times + <emphasis>foreach</emphasis> will loop. + <emphasis>foreachelse</emphasis> is executed when there are no + values in the <emphasis>from</emphasis> variable. + </para> +<example> +<title>foreach</title> +<programlisting> + +{* this example will print out all the values of the $custid array *} +{foreach from=$custid item=curr_id} + id: {$curr_id}<br> +{/foreach} + +OUTPUT: + +id: 1000<br> +id: 1001<br> +id: 1002<br></programlisting> +</example> + +<example> +<title>foreach key</title> +<programlisting> +{* The key contains the key for each looped value + +assignment looks like this: + +$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), + array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))); + +*} + +{foreach name=outer item=contact from=$contacts} + {foreach key=key item=item from=$contact} + {$key}: {$item}<br> + {/foreach} +{/foreach} + +OUTPUT: + +phone: 1<br> +fax: 2<br> +cell: 3<br> +phone: 555-4444<br> +fax: 555-3333<br> +cell: 760-1234<br></programlisting> +</example> + </sect1> <sect1 id="language.function.include"> <title>include</title> <informaltable frame=all> @@ -2406,120 +2520,6 @@ </programlisting> </example> </sect2> - </sect1> - <sect1 id="language.function.foreach"> - <title>foreach,foreachelse</title> - <informaltable frame=all> - <tgroup cols=5> - <colspec colname=param align=center> - <colspec colname=type align=center> - <colspec colname=required align=center> - <colspec colname=default align=center> - <colspec colname=desc> - <thead> - <row> - <entry>Attribute Name</entry> - <entry>Type</entry> - <entry>Required</entry> - <entry>Default</entry> - <entry>Description</entry> - </row> - </thead> - <tbody> - <row> - <entry>from</entry> - <entry>string</entry> - <entry>Yes</entry> - <entry><emphasis>n/a</emphasis></entry> - <entry>The name of the array you are looping through</entry> - </row> - <row> - <entry>item</entry> - <entry>string</entry> - <entry>Yes</entry> - <entry><emphasis>n/a</emphasis></entry> - <entry>The name of the variable that is the current - element</entry> - </row> - <row> - <entry>key</entry> - <entry>string</entry> - <entry>No</entry> - <entry><emphasis>n/a</emphasis></entry> - <entry>The name of the variable that is the current key</entry> - </row> - <row> - <entry>name</entry> - <entry>string</entry> - <entry>No</entry> - <entry><emphasis>n/a</emphasis></entry> - <entry>The name of the foreach loop for accessing - foreach properties</entry> - </row> - </tbody> - </tgroup> - </informaltable> - <para> - <emphasis>foreach</emphasis> loops are an alternative to - <emphasis>section</emphasis> loops. <emphasis>foreach</emphasis> is - used to loop over a single associative array. The syntax for - <emphasis>foreach</emphasis> is much easier than - <emphasis>section</emphasis>, but as a tradeoff it can only be used - for a single array. <emphasis>foreach</emphasis> tags must be - paired with <emphasis>/foreach</emphasis> tags. Required parameters - are <emphasis>from</emphasis> and <emphasis>item</emphasis>. The - name of the foreach loop can be anything you like, made up of - letters, numbers and underscores. <emphasis>foreach</emphasis> - loops can be nested, and the nested foreach names must be unique - from each other. The <emphasis>from</emphasis> variable (usually an - array of values) determines the number of times - <emphasis>foreach</emphasis> will loop. - <emphasis>foreachelse</emphasis> is executed when there are no - values in the <emphasis>from</emphasis> variable. - </para> -<example> -<title>foreach</title> -<programlisting> - -{* this example will print out all the values of the $custid array *} -{foreach from=$custid item=curr_id} - id: {$curr_id}<br> -{/foreach} - -OUTPUT: - -id: 1000<br> -id: 1001<br> -id: 1002<br></programlisting> -</example> - -<example> -<title>foreach key</title> -<programlisting> -{* The key contains the key for each looped value - -assignment looks like this: - -$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), - array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))); - -*} - -{foreach name=outer item=contact from=$contacts} - {foreach key=key item=item from=$contact} - {$key}: {$item}<br> - {/foreach} -{/foreach} - -OUTPUT: - -phone: 1<br> -fax: 2<br> -cell: 3<br> -phone: 555-4444<br> -fax: 555-3333<br> -cell: 760-1234<br></programlisting> -</example> </sect1> <sect1 id="language.function.strip"> <title>strip</title>
Index: smarty/NEWS diff -u smarty/NEWS:1.193 smarty/NEWS:1.194 --- smarty/NEWS:1.193 Tue Apr 30 10:41:36 2002 +++ smarty/NEWS Wed May 1 11:40:44 2002 @@ -1,3 +1,5 @@ + - fixed bug with resource testing, and include_path (Monte) + Version 2.1.0 ------------- Index: smarty/Smarty.class.php diff -u smarty/Smarty.class.php:1.272 smarty/Smarty.class.php:1.273 --- smarty/Smarty.class.php:1.272 Tue Apr 30 10:41:36 2002 +++ smarty/Smarty.class.php Wed May 1 11:40:44 2002 @@ -804,13 +804,18 @@ if ($resource_type == 'file') { $readable = false; - $include_paths = preg_split('![:;]!', ini_get('include_path')); - foreach ($include_paths as $path) { - if (@is_file($path . DIRECTORY_SEPARATOR . $resource_name)) { - $readable = true; - break; - } - } + if(@is_file($resource_name)) { + $readable = true; + } else { + // test for file in include_path + $include_paths = preg_split('![:;]!', ini_get('include_path')); + foreach ($include_paths as $path) { + if (@is_file($path . DIRECTORY_SEPARATOR . $resource_name)) { + $readable = true; + break; + } + } + } } else if ($resource_type != 'file') { $readable = true; $resource_func = $this->_plugins['resource'][$resource_type][0][0]; Index: smarty/docs/designers.sgml diff -u smarty/docs/designers.sgml:1.23 smarty/docs/designers.sgml:1.24 --- smarty/docs/designers.sgml:1.23 Mon Apr 29 17:13:39 2002 +++ smarty/docs/designers.sgml Wed May 1 11:40:45 2002 @@ -1395,6 +1395,120 @@ </html></programlisting> </example> </sect1> + <sect1 id="language.function.foreach"> + <title>foreach,foreachelse</title> + <informaltable frame=all> + <tgroup cols=5> + <colspec colname=param align=center> + <colspec colname=type align=center> + <colspec colname=required align=center> + <colspec colname=default align=center> + <colspec colname=desc> + <thead> + <row> + <entry>Attribute Name</entry> + <entry>Type</entry> + <entry>Required</entry> + <entry>Default</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>from</entry> + <entry>string</entry> + <entry>Yes</entry> + <entry><emphasis>n/a</emphasis></entry> + <entry>The name of the array you are looping through</entry> + </row> + <row> + <entry>item</entry> + <entry>string</entry> + <entry>Yes</entry> + <entry><emphasis>n/a</emphasis></entry> + <entry>The name of the variable that is the current + element</entry> + </row> + <row> + <entry>key</entry> + <entry>string</entry> + <entry>No</entry> + <entry><emphasis>n/a</emphasis></entry> + <entry>The name of the variable that is the current key</entry> + </row> + <row> + <entry>name</entry> + <entry>string</entry> + <entry>No</entry> + <entry><emphasis>n/a</emphasis></entry> + <entry>The name of the foreach loop for accessing + foreach properties</entry> + </row> + </tbody> + </tgroup> + </informaltable> + <para> + <emphasis>foreach</emphasis> loops are an alternative to + <emphasis>section</emphasis> loops. <emphasis>foreach</emphasis> is + used to loop over a single associative array. The syntax for + <emphasis>foreach</emphasis> is much easier than + <emphasis>section</emphasis>, but as a tradeoff it can only be used + for a single array. <emphasis>foreach</emphasis> tags must be + paired with <emphasis>/foreach</emphasis> tags. Required parameters + are <emphasis>from</emphasis> and <emphasis>item</emphasis>. The + name of the foreach loop can be anything you like, made up of + letters, numbers and underscores. <emphasis>foreach</emphasis> + loops can be nested, and the nested foreach names must be unique + from each other. The <emphasis>from</emphasis> variable (usually an + array of values) determines the number of times + <emphasis>foreach</emphasis> will loop. + <emphasis>foreachelse</emphasis> is executed when there are no + values in the <emphasis>from</emphasis> variable. + </para> +<example> +<title>foreach</title> +<programlisting> + +{* this example will print out all the values of the $custid array *} +{foreach from=$custid item=curr_id} + id: {$curr_id}<br> +{/foreach} + +OUTPUT: + +id: 1000<br> +id: 1001<br> +id: 1002<br></programlisting> +</example> + +<example> +<title>foreach key</title> +<programlisting> +{* The key contains the key for each looped value + +assignment looks like this: + +$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), + array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))); + +*} + +{foreach name=outer item=contact from=$contacts} + {foreach key=key item=item from=$contact} + {$key}: {$item}<br> + {/foreach} +{/foreach} + +OUTPUT: + +phone: 1<br> +fax: 2<br> +cell: 3<br> +phone: 555-4444<br> +fax: 555-3333<br> +cell: 760-1234<br></programlisting> +</example> + </sect1> <sect1 id="language.function.include"> <title>include</title> <informaltable frame=all> @@ -2406,120 +2520,6 @@ </programlisting> </example> </sect2> - </sect1> - <sect1 id="language.function.foreach"> - <title>foreach,foreachelse</title> - <informaltable frame=all> - <tgroup cols=5> - <colspec colname=param align=center> - <colspec colname=type align=center> - <colspec colname=required align=center> - <colspec colname=default align=center> - <colspec colname=desc> - <thead> - <row> - <entry>Attribute Name</entry> - <entry>Type</entry> - <entry>Required</entry> - <entry>Default</entry> - <entry>Description</entry> - </row> - </thead> - <tbody> - <row> - <entry>from</entry> - <entry>string</entry> - <entry>Yes</entry> - <entry><emphasis>n/a</emphasis></entry> - <entry>The name of the array you are looping through</entry> - </row> - <row> - <entry>item</entry> - <entry>string</entry> - <entry>Yes</entry> - <entry><emphasis>n/a</emphasis></entry> - <entry>The name of the variable that is the current - element</entry> - </row> - <row> - <entry>key</entry> - <entry>string</entry> - <entry>No</entry> - <entry><emphasis>n/a</emphasis></entry> - <entry>The name of the variable that is the current key</entry> - </row> - <row> - <entry>name</entry> - <entry>string</entry> - <entry>No</entry> - <entry><emphasis>n/a</emphasis></entry> - <entry>The name of the foreach loop for accessing - foreach properties</entry> - </row> - </tbody> - </tgroup> - </informaltable> - <para> - <emphasis>foreach</emphasis> loops are an alternative to - <emphasis>section</emphasis> loops. <emphasis>foreach</emphasis> is - used to loop over a single associative array. The syntax for - <emphasis>foreach</emphasis> is much easier than - <emphasis>section</emphasis>, but as a tradeoff it can only be used - for a single array. <emphasis>foreach</emphasis> tags must be - paired with <emphasis>/foreach</emphasis> tags. Required parameters - are <emphasis>from</emphasis> and <emphasis>item</emphasis>. The - name of the foreach loop can be anything you like, made up of - letters, numbers and underscores. <emphasis>foreach</emphasis> - loops can be nested, and the nested foreach names must be unique - from each other. The <emphasis>from</emphasis> variable (usually an - array of values) determines the number of times - <emphasis>foreach</emphasis> will loop. - <emphasis>foreachelse</emphasis> is executed when there are no - values in the <emphasis>from</emphasis> variable. - </para> -<example> -<title>foreach</title> -<programlisting> - -{* this example will print out all the values of the $custid array *} -{foreach from=$custid item=curr_id} - id: {$curr_id}<br> -{/foreach} - -OUTPUT: - -id: 1000<br> -id: 1001<br> -id: 1002<br></programlisting> -</example> - -<example> -<title>foreach key</title> -<programlisting> -{* The key contains the key for each looped value - -assignment looks like this: - -$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), - array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))); - -*} - -{foreach name=outer item=contact from=$contacts} - {foreach key=key item=item from=$contact} - {$key}: {$item}<br> - {/foreach} -{/foreach} - -OUTPUT: - -phone: 1<br> -fax: 2<br> -cell: 3<br> -phone: 555-4444<br> -fax: 555-3333<br> -cell: 760-1234<br></programlisting> -</example> </sect1> <sect1 id="language.function.strip"> <title>strip</title>