cvs: peardoc /en/package/structures/structures-datagrid example-simple.xml formatter.xml intro.xml
| From: | Mark Wiesemann | Date: | Sun, 23 Apr 2006 21:52:28 +0000 |
| Subject: | cvs: peardoc /en/package/structures/structures-datagrid example-simple.xml formatter.xml intro.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-7813@lists.php.net to get a copy of this message | ||
wiesemann Sun Apr 23 21:52:28 2006 UTC
Modified files:
/peardoc/en/package/structures/structures-datagrid
example-simple.xml
formatter.xml
intro.xml
Log:
- (minor) CS fix
- optimize example indentation
- don't specify Renderer type manually (it is automatically detected)
- check after bind() call for errors
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/structures/structures-datagrid/example-simple.xml?r1=1.12&r2=1.13&diff_format=u
Index: peardoc/en/package/structures/structures-datagrid/example-simple.xml
diff -u peardoc/en/package/structures/structures-datagrid/example-simple.xml:1.12
peardoc/en/package/structures/structures-datagrid/example-simple.xml:1.13
--- peardoc/en/package/structures/structures-datagrid/example-simple.xml:1.12 Wed Apr 19 19:25:47
2006
+++ peardoc/en/package/structures/structures-datagrid/example-simple.xml Sun Apr 23 21:52:27 2006
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.12 $ -->
+<!-- $Revision: 1.13 $ -->
<refentry id="package.structures.structures-datagrid.example-simple">
<refnamediv>
@@ -35,7 +35,7 @@
$options = array('dsn' => 'mysql://user:password@host/db_name');
// Bind a basic SQL statement as datasource
-$datagrid->bind("SELECT * FROM my_table",$options);
+$datagrid->bind('SELECT * FROM my_table', $options);
// Print the DataGrid with the default renderer (HTML Table)
$datagrid->render();
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/structures/structures-datagrid/formatter.xml?r1=1.4&r2=1.5&diff_format=u
Index: peardoc/en/package/structures/structures-datagrid/formatter.xml
diff -u peardoc/en/package/structures/structures-datagrid/formatter.xml:1.4
peardoc/en/package/structures/structures-datagrid/formatter.xml:1.5
--- peardoc/en/package/structures/structures-datagrid/formatter.xml:1.4 Sun Nov 20 18:54:52 2005
+++ peardoc/en/package/structures/structures-datagrid/formatter.xml Sun Apr 23 21:52:27 2006
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<refentry id="package.structures.structures-datagrid.formatter">
<refnamediv>
<refname>Column Formatter</refname>
@@ -19,33 +19,36 @@
<title>Using the column formatter</title>
<programlisting role="php">
<![CDATA[
- <?php
- require_once 'Structures/DataGrid.php';
+<?php
+require_once 'Structures/DataGrid.php';
- $dg =& new Structures_DataGrid();
- $dg->bind('http://pear.php.net/feeds/pkg_structures_datagrid.rss',
null, 'RSS');
-
- $dg->addColumn(new Structures_DataGrid_Column('Release', 'title',
'title', null, null, 'printLink()'));
- $dg->addColumn(new Structures_DataGrid_Column('Description',
'description', 'description', null, null, 'printDesc($length=150)'));
- $dg->addColumn(new Structures_DataGrid_Column('Date', 'dc:date',
'dc:date'));
- $dg->render();
-
- function printLink($params)
- {
- extract($params);
- return '<a href="' . $record['link'] . '">'
. $record['title'] . '</a>';
- }
-
- function printDesc($params)
- {
- extract ($params);
- if (strlen($record['description']) > $length) {
- return nl2br(substr($record['description'], 0, $length)) . '...';
- } else {
- return nl2br($record['description']);
- }
- }
- ?>
+$dg =& new Structures_DataGrid();
+$result = $dg->bind('http://pear.php.net/feeds/pkg_structures_datagrid.rss');
+if (PEAR::isError($result)) {
+ die('An error occured while fetching the RSS information.');
+}
+
+$dg->addColumn(new Structures_DataGrid_Column('Release', 'title',
'title', null, null, 'printLink()'));
+$dg->addColumn(new Structures_DataGrid_Column('Description', 'description',
'description', null, null, 'printDesc($length=150)'));
+$dg->addColumn(new Structures_DataGrid_Column('Date', 'dc:date',
'dc:date'));
+$dg->render();
+
+function printLink($params)
+{
+ extract($params);
+ return '<a href="' . $record['link'] . '">' .
$record['title'] . '</a>';
+}
+
+function printDesc($params)
+{
+ extract ($params);
+ if (strlen($record['description']) > $length) {
+ return nl2br(substr($record['description'], 0, $length)) . '...';
+ } else {
+ return nl2br($record['description']);
+ }
+}
+?>
]]>
</programlisting>
</example>
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/structures/structures-datagrid/intro.xml?r1=1.10&r2=1.11&diff_format=u
Index: peardoc/en/package/structures/structures-datagrid/intro.xml
diff -u peardoc/en/package/structures/structures-datagrid/intro.xml:1.10
peardoc/en/package/structures/structures-datagrid/intro.xml:1.11
--- peardoc/en/package/structures/structures-datagrid/intro.xml:1.10 Fri Jan 28 15:25:05 2005
+++ peardoc/en/package/structures/structures-datagrid/intro.xml Sun Apr 23 21:52:27 2006
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.10 $ -->
+<!-- $Revision: 1.11 $ -->
<refentry id="package.structures.structures-datagrid.intro">
<refnamediv>
<refname>Introduction</refname>
@@ -22,6 +22,7 @@
data can be sorted and paged, and each cell of the table can have a custom
look by using <acronym>CSS</acronym> for the HTML output.
</para>
+<!--
<note>
<title>Example data</title>
<para>
@@ -32,6 +33,7 @@
MySQL</ulink>; should work similar for other database systems.)
</para>
</note>
+-->
</refsect1>
<refsect1>
<title>Where to start</title>