Welcome, Guest. Please Login or Register.
April 27, 2025, 03:44:47 PM
Home Help Search Log in Register
News: SMF is the next generation in forum software, almost completely re-written from the ground up, make sure you don't fall for cheap imitations that suffer from feature bloat!

YaBB SE Community  |  General Category  |  Feedback  |  Table class: no more html for tables « previous next »
Pages: [1] Reply Ignore Print
Author Topic: Table class: no more html for tables  (Read 837 times)
Shindou Hikaru
Honinbou
YaBB Crony
YaBB God
*****
Posts: 1358


ICQ - 152652980mephidmann@emulation-inc.com WWW
Table class: no more html for tables
« on: June 01, 2002, 08:22:57 PM »
Reply with quote

I created a very pretty table class I hope will be used for yabbse. Download it here. I posted the whole class below.

<?php

/*****************************************************************

Table Class Copyright 2002 Mephidmann <[email protected]

Dedicated to the worlds bestest opensource forum: YaBB SE

Look below for executing examples

********************************************************************/

class table_create
        
{
        function 
table($rows$parameters=array())
                {
                if(!
is_array($rows) OR (isset($parameters) AND !is_array($parameters)))
                        {
                        print(
$this->printError("Table rows and parameters must be inputed in an array"));
                        }
                unset(
$params);
                while(list(
$k$v) = each($parameters))
                        {
                        
$params .= " " $k "=\"" $v "\"";
                        }
                while(list(
$k$v) = each($rows))
                        {
                        
$parsedrows .= $this->tr($rows[$k][0], $rows[$k][1]);
                        }
                return(
"<table" $params ">\n" $parsedrows "</table>\n");
                }
        
        function 
tr($cells$parameters=array())
                {
                if(!
is_array($cells) OR (isset($parameters) AND !is_array($parameters)))
                        {
                        print(
$this->printError("Row cells and parameters must be inputed in an array"));
                        }
                unset(
$params);
                while(list(
$k$v) = each($parameters))
                        {
                        
$params .= " " $k "=\"" $v "\"";
                        }
                while(list(
$k$v) = each($cells))
                        {
                        
$parsedcells .= $this->td($cells[$k][0], $cells[$k][1]);
                        }
                return(
"<tr" $params ">\n" $parsedcells "</tr>\n");
                }
        
        function 
td($content$parameters=array())
                {
                unset(
$params);
                while(list(
$k$v) = each($parameters))
                        {
                        
$params .= " " $k "=\"" $v "\"";
                        }
                
$content stripslashes($content);
                return(
"<td" $params ">" $content "</td>\n");
                }
        
        function 
printError($error)
                {
                return die(
"<font color=red>" $error "</font>\n");
                }
        }
        
#Examples of use#
$table = new table_create;
$cell[0][0] = "Hello, how are you, this is the first cell I created today";
$cell[0][1] = array("align" => "center""bgcolor" => "red");
$cell[1][0] = "Cell number 2 in row #1";
$cell[1][1] = array("height" => 50"valign" => "top""bgcolor" => "blue");
$cell[2][0] = "Cell spanning whole column";
$cell[2][1] = array("bgcolor" => "orange""colspan" => 2"align" => "center");
$row[0][0] = array($cell[0], $cell[1]); 
$row[0][1] = array();
$row[1][0] = array($cell[2]);
$row[1][1] = array();
$params = array("border" => 1);
print(
$table->table($row$params));

/**************************************
More explaining:
$cell is an array, containing three values, each a different cell on the table.
Each of those cell values, is also an array, containing the cell contents and
parameters.

$row is also an array, one value for each row, those values again being arrays
with the first value being the row contents and the second being an array with
parameters

$params is an array with general table properties
*************************************/
?>


SCREENSHOT OF RESULT OF EXAMPLE:
Logged

Please do not message me for support, use the support boards
Amazon Wishlist | ThinkGeek Wishlist | My Blog
Jeff Lewis
Global Moderator
YaBB God
*****
Posts: 10149


I'm a llama!

WWW
Re:Table class: no more html for tables
« Reply #1 on: June 01, 2002, 09:07:25 PM »
Reply with quote

All that to create a table? :) Like I said, talk to Greg...
Logged

Shindou Hikaru
Honinbou
YaBB Crony
YaBB God
*****
Posts: 1358


ICQ - 152652980mephidmann@emulation-inc.com WWW
Re:Table class: no more html for tables
« Reply #2 on: June 01, 2002, 09:20:01 PM »
Reply with quote

really, i contacted him this time. The first time you asked i couldn't figure out his username so I had no clue who to IM. Now i figured it out.
Logged

Please do not message me for support, use the support boards
Amazon Wishlist | ThinkGeek Wishlist | My Blog
groundup
Disciple of Joe, Head Cleric
Mod Team
YaBB God
*****
Posts: 2983


Error 309: Please notify the administrator of this

WWW
Re:Table class: no more html for tables
« Reply #3 on: June 01, 2002, 09:28:27 PM »
Reply with quote

that is an awful lot to create a small table like that
Logged

http://www.fastfinancialfreedom.org - financial freedom is a myth
http://www.fastfinancialfreedom.org - financial freedom is a myth
http://www.fastfinancialfreedom.org - financial freedom is a myth
fastfinancialfreedom.org
Shindou Hikaru
Honinbou
YaBB Crony
YaBB God
*****
Posts: 1358


ICQ - 152652980mephidmann@emulation-inc.com WWW
Re:Table class: no more html for tables
« Reply #4 on: June 02, 2002, 07:56:08 AM »
Reply with quote

this is just one way to do it. There are many other ways. But if you think, if you replace all the hundreds of tables in yabbse, you'll save a lot of space on the long run.

Another plus about using this is that code is much easier to eversee and editing can be done on the fly.

A lot of parameters that I filled in in the example are optional btw.
Logged

Please do not message me for support, use the support boards
Amazon Wishlist | ThinkGeek Wishlist | My Blog
Jeff Lewis
Global Moderator
YaBB God
*****
Posts: 10149


I'm a llama!

WWW
Re:Table class: no more html for tables
« Reply #5 on: June 02, 2002, 01:46:14 PM »
Reply with quote

Quote from: mephidmann on June 01, 2002, 09:20:01 PMreally, i contacted him this time. The first time you asked i couldn't figure out his username so I had no clue who to IM. Now i figured it out.

Oops, sorry about that. He'll probably get in touch with you shortly.
Logged

Greg Robson
Training to be like Joseph
YaBB SE Developer
YaBB God
*****
Posts: 1459


Hello!

ICQ - 81390136 WWW
Re:Table class: no more html for tables
« Reply #6 on: June 04, 2002, 11:34:14 PM »
Reply with quote

aaahhhh, my wonderful TemplateParser! But hang on this is the feedback forum   :o :-X
Logged

You can't have everything... where would you put it? -- Steve Wright
Pages: [1] Reply Ignore Print 
YaBB SE Community  |  General Category  |  Feedback  |  Table class: no more html for tables « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 2.717 seconds with 18 queries.