<?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: Proposal for PEAR::Structures_DataGrid column formatter</title>
	<atom:link href="http://www.phpied.com/structures-datagrid-column-formatter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpied.com/structures-datagrid-column-formatter/</link>
	<description>Stoyan&#039;s blog about &#60;a href=&#34;/category/xhtml&#34; class=&#34;tag-minor&#34;&#62;(x)html(5)&#60;/a&#62;, &#60;a href=&#34;/category/ajax&#34; class=&#34;tag-major&#34;&#62;ajax&#60;/a&#62;, &#60;a href=&#34;/category/bookmarklets&#34; class=&#34;tag-major&#34;&#62;bookmarklets&#60;/a&#62;, &#60;a href=&#34;/category/browsers&#34; class=&#34;tag-minor&#34;&#62;browsers&#60;/a&#62;, &#60;a href=&#34;/category/css&#34; class=&#34;tag-normal&#34;&#62;css&#60;/a&#62;, &#60;a href=&#34;/category/firebug&#34; class=&#34;tag-minor&#34;&#62;firebug&#60;/a&#62;, &#60;a href=&#34;/category/javascript&#34; class=&#34;tag-numero-uno&#34;&#62;javascript&#60;/a&#62;, &#60;a href=&#34;/category/json&#34; class=&#34;tag-normal&#34;&#62;json&#60;/a&#62;, &#60;a href=&#34;/category/mdb2&#34; class=&#34;tag-minor&#34;&#62;mdb2&#60;/a&#62;, &#60;a href=&#34;/category/mysql&#34; class=&#34;tag-normal&#34;&#62;mysql&#60;/a&#62;, &#60;a href=&#34;/category/pear&#34; class=&#34;tag-numero-uno&#34;&#62;pear&#60;/a&#62;, &#60;a href=&#34;/category/performance&#34; class=&#34;tag-major&#34;&#62;performance&#60;/a&#62;, &#60;a href=&#34;/category/php&#34; class=&#34;tag-numero-uno&#34;&#62;php&#60;/a&#62;, &#60;a href=&#34;/category/phpbb&#34; class=&#34;tag-major&#34;&#62;phpbb&#60;/a&#62;, &#60;a href=&#34;/category/tools&#34; class=&#34;tag-normal&#34;&#62;tools&#60;/a&#62;, &#60;a href=&#34;/category/yslow&#34; class=&#34;tag-minor&#34;&#62;yslow&#60;/a&#62;, &#60;a href=&#34;/category/yui&#34; class=&#34;tag-normal&#34;&#62;yui&#60;/a&#62;, &#60;a href=&#34;/category/writing&#34; class=&#34;tag-minor&#34;&#62;writing&#60;/a&#62;, &#60;a href=&#34;/category/music&#34; class=&#34;tag-major&#34;&#62;music&#60;/a&#62;,... &#60;a href=&#34;/category/life-and-everything&#34; class=&#34;tag-normal&#34;&#62;life and everything&#60;/a&#62;.</description>
	<lastBuildDate>Sat, 11 Feb 2012 14:07:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: metapundit.net</title>
		<link>http://www.phpied.com/structures-datagrid-column-formatter/#comment-758</link>
		<dc:creator>metapundit.net</dc:creator>
		<pubDate>Mon, 13 Mar 2006 19:45:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/structures_datagrid-column-formatter/#comment-758</guid>
		<description>&lt;strong&gt;Improvements to Structures_Datagrid...&lt;/strong&gt;

One of the PEAR packages I have a love/hate relationship with is Structures_Datagrid....</description>
		<content:encoded><![CDATA[<p><strong>Improvements to Structures_Datagrid&#8230;</strong></p>
<p>One of the PEAR packages I have a love/hate relationship with is Structures_Datagrid&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stoyan</title>
		<link>http://www.phpied.com/structures-datagrid-column-formatter/#comment-186</link>
		<dc:creator>Stoyan</dc:creator>
		<pubDate>Mon, 10 Oct 2005 03:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/structures_datagrid-column-formatter/#comment-186</guid>
		<description>Thanks, Sjoerd, I&#039;ll try it out. I&#039;ll post a new bug in PEAR&#039;s bugtracker about this. I&#039;ve already commented on an older bug report, then wrote to the package developer and he asked me to file a new bug entry. Hopefully a new solution for the formatter callback will find its place in the next versions of the package.</description>
		<content:encoded><![CDATA[<p>Thanks, Sjoerd, I&#8217;ll try it out. I&#8217;ll post a new bug in PEAR&#8217;s bugtracker about this. I&#8217;ve already commented on an older bug report, then wrote to the package developer and he asked me to file a new bug entry. Hopefully a new solution for the formatter callback will find its place in the next versions of the package.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sjoerd</title>
		<link>http://www.phpied.com/structures-datagrid-column-formatter/#comment-165</link>
		<dc:creator>Sjoerd</dc:creator>
		<pubDate>Wed, 05 Oct 2005 12:26:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/structures_datagrid-column-formatter/#comment-165</guid>
		<description>Great code; tweaked it a bit more, so it supports call_user_func_array, which makes it possible to call normal functions:

This code allows for the usual array([objectname],[methodname]) calling structure of php. 
A second array can be supplied for arguments, to be supplied either as real arguments or an array of arguments

$myObj = new myobj;

$this-&gt;formatter = array(array($myObj,&#039;eat&#039;),array(&#039;banana&#039;,&#039;tomato&#039;));
will call: $myObj-&gt;eat(&#039;banana&#039;,&#039;apple&#039;)

$this-&gt;formatter = array(array($myObj,&#039;eat&#039;),array(&#039;fruit&#039;=&gt;&#039;banana&#039;,&#039;vegetable&#039;=&gt;&#039;tomato&#039;));
will call: $myObj-&gt;eat(array(&#039;fruit&#039;=&gt;&#039;banana&#039;,&#039;vegetable&#039;=&gt;&#039;tomato&#039;,&#039;record&#039;=&gt;...))

    function formatter($record)
    {
 
        if (empty($this-&gt;formatter[0])) {
            return false;
        }
 
        $parameters = false;
  $calluserfuncarray = false;
        if (empty($this-&gt;formatter[1])) {
            if (!empty($this-&gt;fieldName)){
                $parameters = $record[$this-&gt;fieldName];
            }
        } else {
            $parameters = array(&#039;record&#039; =&gt; $record);
            if (is_array($this-&gt;formatter[1])) {
    foreach ($this-&gt;formatter[1] as $key=&gt;$value){
     $calluserfuncarray &#124;= is_numeric($key);
     if ($calluserfuncarray) break;
    }
    if (!$calluserfuncarray)
     $parameters = array_merge(array(&#039;record&#039; =&gt; $record), $this-&gt;formatter[1]);
            }
        }
 
        // Call the formatter
        if (is_callable($this-&gt;formatter[0])) {
   if ($calluserfuncarray)
    return call_user_func_array($this-&gt;formatter[0], $this-&gt;formatter[1]);
   return call_user_func($this-&gt;formatter[0], $parameters);
        } else {
            //$result = new PEAR_Error(&#039;Unable to process formatter&#039;);
            $result = false;
            PEAR::raiseError(&#039;Unable to process formatter&#039;, &#039;1&#039;,
                             PEAR_ERROR_TRIGGER);
        }
    }
</description>
		<content:encoded><![CDATA[<p>Great code; tweaked it a bit more, so it supports call_user_func_array, which makes it possible to call normal functions:</p>
<p>This code allows for the usual array([objectname],[methodname]) calling structure of php.<br />
A second array can be supplied for arguments, to be supplied either as real arguments or an array of arguments</p>
<p>$myObj = new myobj;</p>
<p>$this-&gt;formatter = array(array($myObj,&#8217;eat&#8217;),array(&#8216;banana&#8217;,'tomato&#8217;));<br />
will call: $myObj-&gt;eat(&#8216;banana&#8217;,'apple&#8217;)</p>
<p>$this-&gt;formatter = array(array($myObj,&#8217;eat&#8217;),array(&#8216;fruit&#8217;=&gt;&#8217;banana&#8217;,'vegetable&#8217;=&gt;&#8217;tomato&#8217;));<br />
will call: $myObj-&gt;eat(array(&#8216;fruit&#8217;=&gt;&#8217;banana&#8217;,'vegetable&#8217;=&gt;&#8217;tomato&#8217;,'record&#8217;=&gt;&#8230;))</p>
<p>    function formatter($record)<br />
    {</p>
<p>        if (empty($this-&gt;formatter[0])) {<br />
            return false;<br />
        }</p>
<p>        $parameters = false;<br />
  $calluserfuncarray = false;<br />
        if (empty($this-&gt;formatter[1])) {<br />
            if (!empty($this-&gt;fieldName)){<br />
                $parameters = $record[$this-&gt;fieldName];<br />
            }<br />
        } else {<br />
            $parameters = array(&#8216;record&#8217; =&gt; $record);<br />
            if (is_array($this-&gt;formatter[1])) {<br />
    foreach ($this-&gt;formatter[1] as $key=&gt;$value){<br />
     $calluserfuncarray |= is_numeric($key);<br />
     if ($calluserfuncarray) break;<br />
    }<br />
    if (!$calluserfuncarray)<br />
     $parameters = array_merge(array(&#8216;record&#8217; =&gt; $record), $this-&gt;formatter[1]);<br />
            }<br />
        }</p>
<p>        // Call the formatter<br />
        if (is_callable($this-&gt;formatter[0])) {<br />
   if ($calluserfuncarray)<br />
    return call_user_func_array($this-&gt;formatter[0], $this-&gt;formatter[1]);<br />
   return call_user_func($this-&gt;formatter[0], $parameters);<br />
        } else {<br />
            //$result = new PEAR_Error(&#8216;Unable to process formatter&#8217;);<br />
            $result = false;<br />
            PEAR::raiseError(&#8216;Unable to process formatter&#8217;, &#8217;1&#8242;,<br />
                             PEAR_ERROR_TRIGGER);<br />
        }<br />
    }</p>
]]></content:encoded>
	</item>
</channel>
</rss>

