Re: Re: Re: Structures_DataGrid HTML_Template_Flexy renderer

From: Date: Wed, 08 Jun 2005 07:11:31 +0000
Subject: Re: Re: Re: Structures_DataGrid HTML_Template_Flexy renderer
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19509@lists.php.net to get a copy of this message
On 08/06/2005, at 2:05 AM, Mark Wiesemann wrote: Ok i have made more tweaks to it, this time it returns the rendered flexy object, and then i send it as a variable to an outer shell template, in this outer shell template I call my custom getResults method and the renderers getPaging method and the pager selectbox www.electroteque.org/pear/DataGrid/ Excuse the formatting i have to email from a mac /** * Pager results called from the Flexy template */
    function getResults()
    {
    //echo yes;
    if ($this->dg->getRecordCount() > 1) {
    $page = $this->dg->getPageCount() > 1 ? 'pages' : 'page';
    return 'You have ' . $this->dg->getRecordCount() . ' results in '.
$this->dg->getPageCount() . ' '.$page;
    }
    }
/** * Global datagrid handler to display paginated lists * <br>Customer Pager settings are collected from the project settings file. * We append extra Pager settings for displaying image navigation. * <br>A Database object or an array is able to be supplied to the datagrid * to display, limit, sort and paginate the results. * * @parammixed$dothe dataobject object or an array as a * datasource * @paramstring$templatethe flexy template to supply as the list * @paramint$limitsend a row limit to the datagrid * @parammixed$objthe flexy object to send to the Flexy * datagrid renderer * @access public */ 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); $this->datagrid = $dg->renderer->render($obj); $dg->renderer->_flexy->compile('datagrid.html');
          return $dg->renderer->_flexy->output($this);
} 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); $this->datagrid = $dg->renderer->render($obj); $dg->renderer->_flexy->compile('datagrid.html');
          return $dg->renderer->_flexy->output($this);
} }

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