Structures_DataGrid HTML_Template_Flexy renderer

From: Date: Tue, 07 Jun 2005 04:28:51 +0000
Subject: Structures_DataGrid HTML_Template_Flexy renderer
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19496@lists.php.net to get a copy of this message
I have been advised to tweak the renderer and gain acceptance via user testing. I have created a mix of the table and smarty renderer. It requires Core.php from CVS for the page results function which the template gets from the renderer. I had been advised to take this out, however I cant work out a way to get this function from outside the renderer to the template ?? It collects flexy options if you are creating a new object from a static property or sending the options to setTemplate, if you are not sending the object with setFlexyObj. I use image navigation, you will see in the paging i had to call the getlinks and then append first and last to the navigation. I made an attempt to get first and last added to links in cvs so I could just call $this->pager->links but was not accepted. You have to set the firstPagePre and firstPagePost to empty so it wont add brackets around the image pretty clunky. www.electroteque.org/pear/DataGrid/ Here is an example of how I use it function data_grid($do, $template, $limit = 10, $obj = null) { /** * Require the DataGrid and DataSource */ require_once 'Structures/DataGrid.php'; require_once 'Structures/DataGrid/DataSource.php'; /* * Collect the Pager options */ $paging_options = &PEAR::getStaticProperty('Pager','options'); $options = array( 'prevImg'=><img name=\Back$i\ src=\images/nav_back_off.gif\ border=\0\ alt=\Previous Page\ onmouseover=\this.src='images/nav_back_on.gif'\ onmouseout=\this.src='images/nav_back_off.gif'\>, 'nextImg'=><img name=\Forward$i\ src=\images/nav_forward_off.gif\ border=\0\ alt=\Next Page\ onmouseover=\this.src='images/nav_forward_on.gif'\ onmouseout=\this.src='images/nav_forward_off.gif'\>, 'firstPageText'=><img name=\First$i\ src=\images/nav_first_off.gif\ border=\0\ alt=\First Page\ onmouseover=\this.src='images/nav_first_on.gif'\ onmouseout=\this.src='images/nav_first_off.gif'\>, 'lastPageText'=><img name=\Last$i\ src=\images/nav_last_off.gif\ border=\0\ alt=\Last Page\ onmouseover=\this.src='images/nav_last_on.gif'\ onmouseout=\this.src='images/nav_last_off.gif'\>, 'firstPagePre'=>'', 'firstPagePost'=>'', 'lastPagePre'=> '', 'lastPagePost'=> '' ); if (is_array($this->settings['Pager'])) { $paging_options = array_merge($this->settings['Pager'],$options); } /* * Setup the DataGrid */ $dg =& new Structures_DataGrid($_GET['setPerPage'] ? $_GET['setPerPage'] : $limit,$_GET['page'] ? $_GET['page'] : 1,'Flexy'); $dg->sortRecordSet(isset($_GET['orderBy']) ? $_GET['orderBy'] : '', isset($_GET['direction']) ? $_GET['direction'] : 'ASC'); if (is_object($do)) { /* * Setup the DataObject as the DataSource */ $data = Structures_DataGrid_DataSource::create($do,false,'DataObject'); $dg->bindDataSource($data); $this->dg = $dg; /* * Send the flexy object to the flexy renderer */ $dg->renderer->setFlexyObj($this->tpl); /* * Send the template to the flexy renderer */ $dg->renderer->setTemplate($template); return $dg->renderer->render($obj); } elseif (is_array($do) && !empty($do)) { /* * Setup an array as the DataSource */ $data = Structures_DataGrid_DataSource::create($do); $dg->bindDataSource($data); $this->dg = $dg; $dg->renderer->setTemplate($template); return $dg->renderer->render($obj); }

« previous php.pear.general (#19496) next »