Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Anguz on October 27, 2004, 06:34:53 AM

Title: Table From CSV
Post by: Anguz on October 27, 2004, 06:34:53 AM
Link to Mod (http://mods.simplemachines.org/index.php?mod=40)

This mod adds a new tag that'll create a table from CSV text. This is, by far, the simplest way of creating table. Each line is a row (if there's more than one, the first will be the headers). Values are separated by the separator specified in the tag using this format [table=,] (no value [table=] will default to ","). The resulting table can be sorted by clicking on the column headers.

Copyright 2007 by Cristian Lavaque. http://anguz.net
sorttable.js copyright 2003 by Stuart Langridge. http://www.kryogenix.org
Title: Re: Table From CSV
Post by: Anguz on October 27, 2004, 02:33:53 PM
Here's a simple example:


[table=]Num,Name,City
456,John,N.Y.
123,Charles,L.A.
789,Peter,D.C.[/table]


Attachment 1 is how it it comes out and 2 after sorting it by Name clicking on the column header. ;)

Of course, you can style it in your CSS file, the class is .sortable.
Title: Re: Table From CSV
Post by: Tristan Perry on October 27, 2004, 04:38:29 PM
Nice job  :) It looks really helpful!
Title: Re: Table From CSV
Post by: Grudge on October 27, 2004, 05:09:25 PM
Yea, I think it's a very cool idea actually.
Title: Re: Table From CSV
Post by: Omar Bazavilvazo on October 27, 2004, 06:32:33 PM
I like it a lot: simple and useful!
Title: Re: Table From CSV
Post by: codenaught on October 27, 2004, 06:43:46 PM
Very nice mod! A simple mod that can be very handy! I really like it.  :)
Title: Re: Table From CSV
Post by: Ben_S on October 27, 2004, 07:41:28 PM
Will probably install this one :). Nice idea.
Title: Re: Table From CSV
Post by: Anguz on October 27, 2004, 07:58:53 PM
Hey all, thank you for the comments! I'm really glad you find it useful. :D

I'll probably add alternating backgrounds (optional of course, modifying the styles) tonight. Will also move it in parsecode and place it before the br tag, so you can use the latter in the values, that'll let you have multiple lines in a cell if so desired.

A clarification on the separators use. Anything between the = and ] will be used as the separator, that includes tabs (just tested to make sure), which is good for tab separated CSV files. You'll need to copy/paste the tab from a text editor though, cause hitting tab in the post form will move the focus to the next element in the form. If it's left blank, it'll default to a comma.

One more thing, it's a nice short-hand to create tables in messages and it's way faster than the current table parsing, even the one in FasterParsecode, so you may prefer to use it when possible.
Title: Re: Table From CSV
Post by: Anguz on October 28, 2004, 06:49:50 AM
Updated to 1.10

Didn't do the br tag thing because it gave some trouble and I didn't consider it that important to bother making it work. If you need multiple lines in a cell, just use the normal table tag. :)

The alternating row backgrounds are in there now. Thanks to [Unknown] for his help with JS. I'm attaching a new screenshot. ;)

I also added some simple styling, as you can see, which you can easily modify if you don't like.
Title: Re: Table From CSV
Post by: jacbier on October 31, 2004, 04:19:46 PM
Hello Anguz,

Thank you for this simple en useful mod. (http://www.hobbybrouwen.nl/yabbse/Smileys/classic/groots.gif)

Jacques
Title: Re: Table From CSV
Post by: Anguz on October 31, 2004, 04:35:55 PM
I'm glad you liked it! Thank you for writting! :D
Title: Re: Table From CSV
Post by: Oldiesmann on November 01, 2004, 11:41:53 AM
Nice :)
Title: Re: Table From CSV
Post by: codenaught on November 12, 2004, 07:52:04 PM
I am having a problem with this mod. When I add a link to a row, first the link won't auto wrap a [ url ] tag around it like the links do on this forum when just typing in a link. For example typing in http://www.google.com without the [ url ] tags will still make it clickable. And also when I do wrap the [ url ] [ /url ] tags around it the link will turn out all wrong.

So for example if I do this,


[table=]test,test,test
test,test,[url]http://www.google.com[/url][/table]


the page that shows up when clicking that link is:

http://www.myaddress.com/myforumdirectory/%5C%22http://www.google.com%5C%22

of course where myaddress and myforumdirectory were used instead of my real one.

any ideas how to fix it so you can use links in the tables?

PS: If it helps, when hovering the link at the bottom the link appears to be going to: http://www.myaddress.com/myforumdirectory/\"http://www.google.com\"
Title: Re: Table From CSV
Post by: Anguz on November 12, 2004, 07:57:27 PM
I haven't tried using tags in the CSV table. I'll try it out in my test server and see what I can find out.
Title: Re: Table From CSV
Post by: Anguz on November 12, 2004, 09:22:53 PM
I fixed it parsing the CVS table before the other tags. Links are working now, look at the status bar in the screenshot. I'll post an update in a moment.
Title: Re: Table From CSV
Post by: codenaught on November 12, 2004, 09:25:16 PM
Okay thanks. Great mod may I say again. It is a very nice simple way to arrange things in order. Keep up with the nice bbcodes.  ;D
Title: Re: Table From CSV
Post by: Anguz on November 12, 2004, 09:47:07 PM
Updated to 1.11

Title: Re: Table From CSV
Post by: Elijah Bliss on December 05, 2004, 07:18:28 AM
Do I have to add anything in order to make the tables sortable because their are no links showing up to sort them as shown in your screen capture.

Aside from that, great mod.
Title: Re: Table From CSV
Post by: Anguz on December 05, 2004, 06:20:46 PM
There's a javascript file added to your default theme dir during install. If you're using another theme, you need to make a copy of the file to that theme's dir as well.
Title: Re: Table From CSV
Post by: Elijah Bliss on December 05, 2004, 06:34:41 PM
Quote from: Anguz on December 05, 2004, 06:20:46 PM
There's a javascript file added to your default theme dir during install. If you're using another theme, you need to make a copy of the file to that theme's dir as well.

The "sorttable.js" is located in the theme I am using.

The problem I am encountering is this:
if I just have this for example:
[table=]Giants,Forty Niners,Bears[/table]

the sortable links show up in the headers, but as soon as I make a carriage return,
[table=]Giants,Forty Niners,Bears
Bonds,Young,Arrington[/table]

the links in the headers go dead.
Title: Re: Table From CSV
Post by: Elijah Bliss on December 05, 2004, 09:01:19 PM
Quote from: Elijah Bliss on December 05, 2004, 06:34:41 PM
Quote from: Anguz on December 05, 2004, 06:20:46 PM
There's a javascript file added to your default theme dir during install. If you're using another theme, you need to make a copy of the file to that theme's dir as well.

The "sorttable.js" is located in the theme I am using.

The problem I am encountering is this:
if I just have this for example:
[table=]Giants,Forty Niners,Bears[/table]

the sortable links show up in the headers, but as soon as I make a carriage return,
[table=]Giants,Forty Niners,Bears
Bonds,Young,Arrington[/table]

the links in the headers go dead.

I got it to work by changing this line of code from the mod:

From:
$arr1[] = '~\[table=(.*?)\](.*?<br />)?(.*?)\[/table\](?:\s|\xA0|<br />|&nbsp;)?~ie';

To:
$arr1[] = '~\[table=(.*?)\](.*?<br>)?(.*?)\[/table\](?:\s|\xA0|<br>|&nbsp;)?~ie';

I don't know why that made a difference, but nonetheless, great mod, and kudos designing mods that don't interfere with the mods from the other mod developers. Great work!
Title: Re: Table From CSV
Post by: Anguz on December 05, 2004, 10:34:18 PM
Thank you. Glad you find them useful. :)

On the modification you made, break tags will always be <br /> and not <br>.

I didn't fully understand what was the problem you were having. If you only have one row in the table, it should not have the links to sort it, if it has more than one, the first row will be the headers for the columns.
Title: Re: Table From CSV
Post by: Anguz on December 06, 2004, 03:44:28 AM
I rewrote the code, could you try this and tell me if it solves your problem?


// Table from CSV. [table=]cell1,cell2[/table]
if(isset($add['[table='])){
$arr1[] = '~\[table=(.*?)\](.*?)\[/table\](?:\s|\xA0|<br />|&nbsp;)?~ie';
$arr2[] = 'parse_table_csv(\'$1\', \'$2\')';
}



function parse_table_csv($comma, $table)
{
static $id = 1;
$comma = empty($comma) ? ',' : $comma;
$ths = $tds = '';
$table = trim(strtr($table, array('<br />' => "\n")));
if (strpos($table, "\n") !== false)
{
$table = explode("\n", $table);
$ths = '<tr><th>' . strtr(array_shift($table), array($comma => '</th><th>')) . '</th></tr>';
$table = implode('</td></tr><tr><td>', $table);
}
$tds = '<tr><td valign="top">' . strtr($table, array($comma => '</td><td valign="top">')) . '</td></tr>';
return '<table id="tbl' . $id++ . '"' . (!empty($ths) ? ' class="sortable"' : '') . '>' . $ths . $tds . '</table>';
}


It fixes a problem where it wouldn't parse right if there were two CSV tables in the same message and the first one consisted of only one line.
Title: Re: Table From CSV
Post by: Elijah Bliss on December 06, 2004, 03:51:35 AM
Quote from: Anguz on December 06, 2004, 03:44:28 AM
I rewrote the code, could you try this and tell me if it solves your problem?


// Table from CSV. [table=]cell1,cell2[/table]
if(isset($add['[table='])){
$arr1[] = '~\[table=(.*?)\](.*?)\[/table\](?:\s|\xA0|<br />| )?~ie';
$arr2[] = 'parse_table_csv(\'$1\', \'$2\')';
}



function parse_table_csv($comma, $table)
{
static $id = 1;
$comma = empty($comma) ? ',' : $comma;
$ths = $tds = '';
$table = trim(strtr($table, array('<br />' => "\n")));
if (strpos($table, "\n") !== false)
{
$table = explode("\n", $table);
$ths = '<tr><th>' . strtr(array_shift($table), array($comma => '</th><th>')) . '</th></tr>';
$table = implode('</td></tr><tr><td>', $table);
}
$tds = '<tr><td valign="top">' . strtr($table, array($comma => '</td><td valign="top">')) . '</td></tr>';
return '<table id="tbl' . $id++ . '"' . (!empty($ths) ? ' class="sortable"' : '') . '>' . $ths . $tds . '</table>';
}


It fixes a problem where it wouldn't parse right if there were two CSV tables in the same message and the first one consisted of only one line.

Do I add this code before, after or replace?
Title: Re: Table From CSV
Post by: Anguz on December 06, 2004, 05:11:51 AM
QuoteDo I add this code before, after or replace?

Replace. It won't be hard to find what they replace, look for the comment in the first block and for the function name in the second one.
Title: Re: Table From CSV
Post by: Elijah Bliss on December 06, 2004, 05:24:08 AM
Quote from: Anguz on December 06, 2004, 05:11:51 AM
QuoteDo I add this code before, after or replace?

Replace. It won't be hard to find what they replace, look for the comment in the first block and for the function name in the second one.

After replacing the code I get a blank white screen when I try to go to the message index.
Title: Re: Table From CSV
Post by: Anguz on December 06, 2004, 02:24:15 PM
Odd, it's working okay for me, you probably missed something in the replace? Anyway, the update for SMF 1.0 will be out soon, when that version gets released. In the meantime you can use what you had working. :)
Title: Re: Table From CSV
Post by: 1948Pal on December 13, 2004, 04:10:13 PM
Hi.
Does each of these versions complement the previous one, as in the faster parse code, or each version should replace its predecessor?
Title: Re: Table From CSV
Post by: Anguz on December 14, 2004, 01:08:06 AM
Quote from: 1948Pal on December 13, 2004, 04:10:13 PM
Hi.
Does each of these versions complement the previous one, as in the faster parse code, or each version should replace its predecessor?

The 1.11 version is complete, it doesn't go on top of the previous one. If you have an earlier one installed, uninstall it first and then install 1.11. :)
Title: Re: Table From CSV
Post by: Anguz on January 29, 2005, 09:19:42 AM
1.12

Title: Re: Table From CSV
Post by: johnm on January 30, 2005, 12:40:16 PM
does this only sort the first colum?

cause if i try to sort the second/third/etc colum i get an error on the page and it does nothing?
Title: Re: Table From CSV
Post by: Anguz on January 30, 2005, 08:13:48 PM
It should work with every column. Could you post a little example of a table that does that for you?
Title: Re: Table From CSV
Post by: Tony Reid on February 01, 2005, 04:28:23 AM
Thanks for this anguz,

We use tables on our site and this will be a great help :)

Title: Re: Table From CSV
Post by: Anguz on February 01, 2005, 04:31:44 AM
Quote from: Tony on February 01, 2005, 04:28:23 AM
Thanks for this anguz,

We use tables on our site and this will be a great help :)

You're welcome. I'm really glad you find it useful. ;)
Title: Re: Table From CSV
Post by: Tony Reid on February 01, 2005, 06:09:52 AM
I would like to expand the columns, as its a little cramped - and I dont think CSS will do it quite like I would like.

Could you tell me how to increase the column width by say.... 5 spaces?

Thanks,
Tony.

Title: Re: Table From CSV
Post by: Anguz on February 01, 2005, 08:25:21 AM
Did you try adding five spaces to one of the values in that column?
Title: Re: Table From CSV
Post by: Tony Reid on February 01, 2005, 08:34:13 AM
Oops.... my fault :( all fixed ;D

Thanks again,
Tony
Title: Re: Table From CSV
Post by: FaSan on February 01, 2005, 08:59:07 AM
Quote from: John on January 30, 2005, 12:40:16 PM
does this only sort the first colum?

cause if i try to sort the second/third/etc colum i get an error on the page and it does nothing?


I've the same problem ..
Title: Re: Table From CSV
Post by: Anguz on February 01, 2005, 09:21:33 AM
Quote from: Anguz on January 30, 2005, 08:13:48 PM
It should work with every column. Could you post a little example of a table that does that for you?
Title: Re: Table From CSV
Post by: FaSan on February 01, 2005, 03:25:24 PM
this is an example :

[table=]Numero,Nome,Città
000.1234567,PokeMone,Bologna
987.7654321,Longinus,Firenze
<br>,<br>,<br>
01234567890, Fear°, Roma
<br>, <br>, <br>[/table]




FaSan
Title: Re: Table From CSV
Post by: Tony Reid on February 01, 2005, 05:41:28 PM
I just tested Fasans example on my site and its working fine (smf 1.01)
Title: Re: Table From CSV
Post by: johnm on February 01, 2005, 05:45:41 PM
mmm ive just tested that above and it worked this is what i had in the table (it was to test it)


[table=,]aaaa,aaaa,aaaa,aaaa
bbbb,bbbb,bbbb,bbbb
cccc,cccc,cccc,cccc
[/table]
Title: Re: Table From CSV
Post by: Anguz on February 02, 2005, 04:18:14 AM
Hmm.. funny, I just tried your table and it worked fine for me, it let me do the sorting with all three columns. Were you able to reproduce the problem again?
Title: Re: Table From CSV
Post by: johnm on February 02, 2005, 03:45:25 PM
yes i can still produce the same problem

bit of a daft question but are you meant to upload .js files in binary or ASCII
Title: Re: Table From CSV
Post by: Tony Reid on February 02, 2005, 04:59:40 PM
In ASCII john :)
Title: Re: Table From CSV
Post by: Anguz on February 03, 2005, 08:46:54 AM
Updated to 1.20


Quote from: John on February 02, 2005, 03:45:25 PM
yes i can still produce the same problem

This version should fix it, could you tell me if it did?
Title: Re: Table From CSV
Post by: FaSan on February 03, 2005, 01:39:14 PM
Work fine for me.

Little problem... if i have a number value with comma, the table not work correctly es :

"0,01"



FaSan
Title: Re: Table From CSV
Post by: Anguz on February 03, 2005, 03:52:23 PM
Quote from: FaSan on February 03, 2005, 01:39:14 PM
Work fine for me.

Good. :)

Quote
Little problem... if i have a number value with comma, the table not work correctly

Then you use a different separator that's not used in the values, just put it after the equal sign, even a tab will work:


[table= ]
col1 col2 col3
val1 val2 val3
[/table]


;)
Title: Re: Table From CSV
Post by: FaSan on February 03, 2005, 04:05:56 PM
Great ! Thank you ;)
Title: Re: Table From CSV
Post by: johnm on February 05, 2005, 05:06:02 AM
ill try this when i get home :)
Title: Re: Table From CSV
Post by: johnm on February 21, 2005, 09:52:40 AM
does v1.20 work with smf1.0.2 as when i try to install it vi package manager

i get

Install Actions for archive TableFromCsv12011.tar.gz:
The package you are trying to download or install is either corrupt or not compatible with this version of SMF. 
Title: Re: Table From CSV
Post by: Kindred on February 21, 2005, 11:26:26 AM
yes and no...

The Table from CSV requires the faster Parsecode...

Faster Parsecode has not yet been updated for 1.0.2...  because 1.0.2 actually changed a section of the code in subs.php that FPC removes...

If you updated to 1.0.2 by using the package manager, thewn all your mods should be pretty much intact... if you did it by FTP, then you'll have to modify each of the mod files to install under 1.0.2 in the installation instructions that checks the version before installing...
Title: Re: Table From CSV
Post by: johnm on February 21, 2005, 11:51:46 AM
thats what i did and its working now.

thanks
Title: Re: Table From CSV
Post by: Anguz on February 21, 2005, 05:56:52 PM
Faster Parsecode is updated for SMF 1.0.2 already. Table From CSV will work fine with it, it's just that I haven't yet modified the package-info.xml file in it to allow the install in 1.0.2. If you open that file and look for the bit that says for="1.0.1" and change that for 1.0.2, it'll work fine with the latest Faster Parsecode mod installed. Same with the other bbcode tags that work with Faster Parsecode. I'll be doing these version updates myself today or tomorrow, though, so if you can wait that much, it'll be done for you.
Title: Re: Table From CSV
Post by: Anguz on February 22, 2005, 09:35:53 PM
1.21

Title: Re: Table From CSV
Post by: johnm on February 23, 2005, 06:52:23 PM
Quote from: Anguz on February 21, 2005, 05:56:52 PM
Faster Parsecode is updated for SMF 1.0.2 already. Table From CSV will work fine with it, it's just that I haven't yet modified the package-info.xml file in it to allow the install in 1.0.2. If you open that file and look for the bit that says for="1.0.1" and change that for 1.0.2, it'll work fine with the latest Faster Parsecode mod installed. Same with the other bbcode tags that work with Faster Parsecode. I'll be doing these version updates myself today or tomorrow, though, so if you can wait that much, it'll be done for you.

i didnt think of that i just followed the actions in the xml file this mod is so handy its well worth it!
Title: Re: Table From CSV
Post by: Anguz on February 23, 2005, 09:26:47 PM
Glad you like it. :D
Title: Re: Table From CSV
Post by: Anguz on April 19, 2005, 11:41:16 PM
1.22

Title: Re: Table From CSV
Post by: agridoc on May 22, 2005, 09:20:10 AM
Excellent mod Anguz.

I installed version 1.22 for SMF 1.03. I had to do it manually as my server runs in safe mode. Excellent results.

Altough the SMF editor has the possibility of adding a table while most others don' t, it' s not so easy if the table is large.

I usually added one by obtaining a "clean"(without formatting, font styles etc.) HTML code first. Then I did a global replace of "<" and ">" with "[" and "]" and copied the code for rows between a new table code in the editor.

This is not so easy for everyone and I had to do all the tables myself.

It' s much easier now. I think that now, with your mod installed, it will be easy for everybody to add a table.

The sorting script is useful in some cases too.

The new possibility, with full HTML power for the administrator, in version 1.1 is more flexible but is not available to everyone.

Your mod makes also editing data easier as all those cell tags are a headache in a large table with numbers.

Thank you very much for writing such a useful mod.

I hope it will be available for 1.1 too when it will be released as a stable version. I run it as a test now.
Title: Re: Table From CSV
Post by: Anguz on May 22, 2005, 05:19:10 PM
agridoc, it made me very happy to read your message. :D

Of course I plan to release it for 1.1 when it reaches a stable point. I'm really glad you found it so useful. I wrote it exactly for the reasons you mention.

Thank you again for taking the time to write this. :)

Edit: I searched your forum and found your tests (http://www.aeromodelling.gr/ForumS/index.php/topic,44.msg565.html#msg565), it's great to see it in use. Those tables really do look nice, don't they? ;P
Title: Re: Table From CSV
Post by: agridoc on May 22, 2005, 07:37:14 PM
Thank you for your time to surf in my forum. Yes Anguz they look nice. But this mod is not only for looks, it is it's functionality that counts above all.

Most of the best Greek aeromodellers meet in this forum (we are gradually gathering in the new forum from an older in Yahoo!, active since May 2000) and they are amazed by SMF' s possibilities.

As we have events and often have to post programs, results etc. table formation is needed. A few days ago the top R/C helicopter pilots were presenting their equipment and they were struggling to obtain a proper presentation. It will be now very easy with your mod (and good looking of course). ;)

I think it's a must for forums where tables are often needed.
Title: Re: Table From CSV
Post by: tattooedpierre on June 29, 2005, 03:24:26 PM
I've only just migrated from phpBB and am in the process of that conversion, however, this mod is a god-send for what I was searching for ages to do with phpBB!

One question I have though. Daily I have a CSV file I download for a certain website and I save this to my own site. Now is it possible for me to parse this file through the mod rather than copying the data and pasting it? I was thinking something like:

[table=http://mydomain.com/data.csv]

Many thanks,
Peter
Title: Re: Table From CSV
Post by: Anguz on June 30, 2005, 02:38:57 AM
The mod doesn't do that, but it shouldn't be too much trouble copy/pasting it, right? You still need to create the post, right? Please wait for me to update it to 1.0.5 first, though, okay? You can post your CSV tables in the messages with the format for now, but it'll only be displayed as CSV for now, then when you install the mod, they'll show as tables. Would that work for you? I really can't work on my mods at the moment.
Title: Re: Table From CSV
Post by: tattooedpierre on June 30, 2005, 04:11:14 AM
Quote from: Anguz on June 30, 2005, 02:38:57 AM
The mod doesn't do that, but it shouldn't be too much trouble copy/pasting it, right? You still need to create the post, right? Please wait for me to update it to 1.0.5 first, though, okay? You can post your CSV tables in the messages with the format for now, but it'll only be displayed as CSV for now, then when you install the mod, they'll show as tables. Would that work for you? I really can't work on my mods at the moment.

Oh it's perfectly workable the way it is just now.. I just wasnt sure if it was possible to pull from a file. No problems, thanks for the reply.

PS: Yes, I'm probably being extremely lazy!
Title: Re: Table From CSV
Post by: Anguz on July 03, 2005, 06:59:51 AM
1.23

Title: Re: Table From CSV
Post by: agridoc on July 03, 2005, 12:44:12 PM
Thank you very much Anguz.

I think you should consider looking at version 1.1 too. It is still beta but feedback is very positive and it is public now. Is it in your recent plans?

As my server is running in safe mode I have to upgrade and install all mods manually. It is cleaner of course but time consuming.

I think that SMF should consider Table From CSV as a feature. It is a very strong and useful mod.

Thanks again for this excellent mod.

P.S. It' s time also for us, the Greek members to consider making a Greek translation for 1.1.
Title: Re: Table From CSV
Post by: Anguz on July 03, 2005, 06:09:52 PM
agridoc, thank you for your nice feedback again.

If you want, please post the txt strings in Greek as a reply to this topic so others can use it, I could even package it.

Regarding applying mods by hand, it may be less trouble for you to have a local server in your machine, do the installs with the package manager and then upload the modified files to your webhost.

I don't think I'll update my mods for 1.1x soon, though, unless I get very motivated to do it. My work is keeping me very busy lately, and I wouldn't be able to keep up with the new versions right away, as beta's code can change drastically, so I'd rather wait for at least a RC or final.
Title: Re: Table From CSV
Post by: Phoenixoverlord on July 09, 2005, 10:47:53 AM
Hi Anguz!

For some reason, the table's header isn't clickable and so I can't sort it. Any idea what might be wrong?

Oh yes, we have SMF 1.0.5 of course (as you can see below)

We have these mods installed:

1.     Donations_Mod      1.1       [ Uninstall ]  [ List Files ]  [ Delete ]
2.    SMF 1.0.4 Update Package    1.0.4    [ List Files ] [ Delete ]
3.    SMF 1.0.5 Update Package    1.0.5    [ List Files ] [ Delete ]
4.    Faster Parsecode    1.09    [ Uninstall ] [ List Files ] [ Delete ]
5.    Spoiler Tag    1.04    [ Uninstall ] [ List Files ] [ Delete ]
6.    Table From CSV    1.23
Title: Re: Table From CSV
Post by: Anguz on July 09, 2005, 02:42:23 PM
You seem to be missing the JavaScript file in your theme. Does it not work in the default theme either?
Title: Re: Table From CSV
Post by: Phoenixoverlord on July 09, 2005, 04:28:37 PM
I did place the .js in each theme but I also had to modify index.template.php in each theme dir and the css there. It works now! :D

This is truly one of the best mods out there.
Title: Re: Table From CSV
Post by: Anguz on July 09, 2005, 11:19:02 PM
Glad you like it. :D
Title: Re: Table From CSV
Post by: oSa on September 01, 2005, 07:48:21 PM
Hi, I'm using smf 1.0.5 (default theme) and i've already installed the fasterparse code. But i can't install this mod (i'm trying the latest version which is updated for 1.0.5). There is a problem with the subs.php. Any ideas about what's wrong?
Title: Re: Table From CSV
Post by: Anguz on September 01, 2005, 10:08:31 PM
No, I don't know. Did get any errors when installing the FasterParsecode mod? Did you install any other mod after it? Could you post your parsecode function from Subs.php inside code tags?
Title: Re: Table From CSV
Post by: oSa on September 02, 2005, 11:07:38 AM
I don't remember having problems installing the fasterparsecode. I've also tried your other mods (spoiler tag, sort tag, anchor tag and language tag) and they all give errors while the hide tag (which is written by another mod writer works normally; i don't know if it makes sense? ). Currently installed mods:

1.     SMF 1.0.3 Update Package      1.0.3      
2.    SMF 1.0.4 Update Package    1.0.4    
3.    SMF 1.0.5 Update Package    1.0.5    
4.    PHP 4.4.0 Compatibility Update    1.0    
5.    Merge Double Posts    0.99    
6.    Picture forum view par MkC    3.0    
7.    Buddy List    1.21    
8.    Topic Ratings    1.02    
9.    Membergroup Colors In Posts    1.1    
10.    Member Color Link    1.81    
11.    Enhanced Quick Reply    1.0    
12.    Faster Parsecode    1.09    
13.    Show Multiple Badges (Aka Stars)    0.3    
14.    Additional Avatar Permissions    1.01    
15.    Board Notes    1.0.2    
16.    Gmail Field    1.1    
17.    Message Icon Manager (Quick Reply)    1.2    
18.    BBC edit tag    1.0    
19.    Group Moderators    1.0c    
20.    Simple ImageShack


And here is my parsecode function in subs.php:

// Parses the code in message, using the normal syntax used by some many forums...
function parsecode(&$message)
{
global $modSettings, $scripturl, $txt, $settings, $context;
static $codefromcache = array(), $codetocache = array();

// If it wasn't already set, set it.
if (empty($codefromcache))
{
// If any tags are disabled then we won't add them.
if (!empty($modSettings['disabledBBC']))
{
$disabled = array_flip(explode(',', $modSettings['disabledBBC']));

foreach ($disabled as $tag => $dummy)
$disabled[trim($tag)] = true;
}

$code_to_from = array(
                        // Edit tag
'~\[edit\](.+?)\[/edit\]~i' => isset($disabled['edit']) ? '$1' : '<br /><br /><span style="font-size: xx-small; font-style:italic ">Edit: $1</span>',
// A named email address. [[email protected]]me[/email]  And, you can't have []s in your email, I should know.
'~\[email=(.+?)\](.+?)\[/email\]~ie' => isset($disabled['email']) ? '"$2 ($1)"' : '"<a href=\"mailto:" . strtr("$1", array("\"" => "&quot;", "]" => "", "[" => "")) . "\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"',
// An image.  Width and height can be are optional.
'~\[img(\s+width=([\d]+))?(\s+height=([\d]+))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/img\]~ie' => isset($disabled['img']) ? 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$5", array("@" => "&#64;")))' : '"<img src=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$5", array("@" => "&#64;", "\"" => "&quot;"))) . "\" alt=\"\"" . ("$2" != "" ? " width=\"$2\"" : "") . ("$4" != "" ? " height=\"$4\"" : "") . " border=\"0\" />"',
// Find an inside link. (named?) ie. [iurl]www.simplemachines.org[/iurl]
'~\[iurl=(.+?)\](.+?)\[/iurl\]~ie' => isset($disabled['iurl']) ? (!isset($disabled['url']) ? '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"' : 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", "$2") . " ($1)"') : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"',
'~\[iurl\](.+?)\[/iurl\]~ie' => isset($disabled['iurl']) ? (!isset($disabled['url']) ? '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">$1</a>"' : '"$1"') : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\">$1</a>"',
// FTP link.  Named...?  [ftp=upload.sourceforge.net]Sourceforge[/ftp]
'~\[ftp\](.+?)\[/ftp\]~ie' => isset($disabled['ftp']) ? 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", "$1")' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array("@" => "&#64;"))) . "</a>"',
'~\[ftp=(.+?)\](.+?)\[/ftp\]~ie' => isset($disabled['ftp']) ? 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", "$2") . " ($1)"' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"',
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
'~\[url=([^:\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie' => isset($disabled['url']) ? 'preg_replace("~(\[url.*?\]|\[/url\])~i", "", "$2") . " ($1)"' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . preg_replace("~(\[url.*?\]|\[/url\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"',
'~\[url=(.+?)\](.+?)\[/url\]~ie' => isset($disabled['url']) ? '"$2 ($1)"' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . strtr("$2", array("@" => "&#64;")) . "</a>"',
'~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~ie' => isset($disabled['url']) ? '"$1"' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">$1</a>"',
// Bold, italics, underline, strikeout.
'~\[b\](.+?)\[/b\]~i' => isset($disabled['b']) ? '$1' : '<b>$1</b>',
'~\[i\](.+?)\[/i\]~i' => isset($disabled['i']) ? '$1' : '<i>$1</i>',
'~\[u\](.+?)\[/u\]~i' => isset($disabled['u']) ? '$1' : '<span style="text-decoration: underline;">$1</span>',
'~\[s\](.+?)\[/s\]~i' => isset($disabled['s']) ? '$1' : '<del>$1</del>',
// A quote.  May or may not specify an author and/or link and date.
'~\[quote(?: author)?=&quot;(.{1,80}?)&quot;\](?:<br />)?~i' => isset($disabled['quote']) ? '<div>' : '<div class="quoteheader">' . $txt['smf239'] . ': $1</div><div class="quote">',
'~\[quote author=(.{1,80}?) link=(?:board=\d+;)?((?:topic|threadid)=[\dmsg#\./]{1,40}(?:;start=[\dmsg#\./]{1,40})?) date=(\d+)\](?:<br />)?~ei' => isset($disabled['quote']) ? '\'<div>\'' : '\'<div class="quoteheader"><a href="' . $scripturl . '?$2">' . $txt['smf239'] . ': $1 ' . $txt[176] . ' \' . timeformat(\'$3\') . \'</a></div><div class="quote">\'',
'~\[quote author=(.{1,80}?)\](?:<br />)?~i' => isset($disabled['quote']) ? '<div>' : '<div class="quoteheader">' . $txt['smf239'] . ': $1</div><div class="quote">',
'~\[quote\](?:<br />)?~i' => isset($disabled['quote']) ? '<div>' : '<div class="quoteheader">' . $txt['smf240'] . '</div><div class="quote">',
'~\[/quote\](?:<br />)?~i' => isset($disabled['quote']) ? '</div>' : '</div>',
// Size the font.  [size=large]HELLO![/size]
'~\[size=([\d]{1,2}p[xt]|(?:x-)?small(?:er)?|(?:x-)?large[r]?)\](.+?)\[/size\]~i' => isset($disabled['size']) ? '$2' : '<span style="font-size: $1;">$2</span>',
'~\[size=([\d])\](.+?)\[/size\]~i' => isset($disabled['size']) ? '$2' : '<font size="$1">$2</font>',
// Performat/justify text.  [center]Justifying is good.[/center]
'~\[pre\](.+?)\[/pre\]~i' => isset($disabled['pre']) ? '$1' : '<pre>$1</pre>',
'~\[left\](.+?)\[/left\]~i' => isset($disabled['left']) ? '$1' : '<div align="left">$1</div>',
'~\[right\](.+?)\[/right\]~i' => isset($disabled['right']) ? '$1' : '<div align="right">$1</div>',
'~\[center\](.+?)\[/center\]~i' => isset($disabled['center']) ? '$1' : '<div align="center">$1</div>',
// Teletyped text.  Monospace, in other words.
'~\[tt\](.+?)\[/tt\]~i' => isset($disabled['tt']) ? '$1' : '<tt>$1</tt>',
// Subscript and superscript.  6[sup]2[/sup] = 36.
'~\[sub\](.+?)\[/sub\]~i' => isset($disabled['sub']) ? '$1' : '<sub>$1</sub>',
'~\[sup\](.+?)\[/sup\]~i' => isset($disabled['sup']) ? '$1' : '<sup>$1</sup>',
// An email address. [email][email protected][/email]
'~\[email\](?:<br />)*(.+?)(?:<br />)*\[/email\]~ie' => isset($disabled['email']) ? '"$1"' : '"<a href=\"mailto:" . strtr("$1", array(":" => "&#58;", "\"" => "&quot;", "[" => "", "]" => "")) . "\">$1</a>"',
// Specify a specific font.  [font=Comic Sans]Blah![/font]
'~\[font=([\w,\-\s]+?)\](.+?)\[/font\]~i' => isset($disabled['font']) ? '$2' : '<span style="font-family: $1;">$2</span>',
// Colors.... [red]See?[/red]
'~\[color=(#[\da-fA-F]{3}|#[\da-fA-F]{6}|[\w]{1,12})\](.*?)\[/color\]~i' => isset($disabled['color']) ? '$2' : '<span style="color: $1;">$2</span>',
'~\[(black|white|red|green|blue)\](.+?)\[/\1\]~i' => isset($disabled['color']) ? '$2' : '<span style="color: $1;">$2</span>',
'~\[(chr|k)issy\](.+?)\[/\1issy\]~i' => isset($disabled['color']) ? '$2' : '<span style="color: #CC0099;">$2 :-*</span>',
// Lists... [list][*]First, ...[o]Second![li]THIRD!!![/li][/list]
'~\[list\](?:<br />)?~i' => isset($disabled['list']) || isset($disabled['li']) ? '' : '<ul style="margin-top: 0; margin-bottom: 0;">',
'~\[/list\](?:<br />)?~i' => isset($disabled['list']) || isset($disabled['li']) ? '' : '</ul>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => isset($disabled['list']) || isset($disabled['li']) ? '<br />$1<br />' : '<li>$1</li>',
// Horizontal rule. [hr] => ------------------.
'~\[hr(?:\s*/)?\]~i' => isset($disabled['hr']) ? '' : '<hr />',
// A break.  [br] or [br /]. (it makes no sense to disable this one :P.)
'~\[br(?:\s*/)?\]~i' => '<br />',
// Right-to-left and left-to-right strings.
'~\[(ltr|rtl)\](.+?)\[/\1\]~i' => isset($disabled['ltr']) || isset($disabled['rtl']) ? '$2' : '<div dir="$1">$2</div>',
// Acronyms and abbreviations... [acronym=Bulletin Board Code]BBC[/acronym]
'~\[abbr=((?:&quot;)?)(.+?)\\1\](.+?)\[/abbr\]~ie' => isset($disabled['abbr']) ? '"$3 ($2)"' : '"<abbr title=\"" . strtr("$2", array("\"" => "&quot;")) . "\">$3</abbr>"',
'~\[acronym=((?:&quot;)?)(.+?)\\1\](.+?)\[/acronym\]~ie' => isset($disabled['acronym']) ? '"$3 ($2)"' : '"<acronym title=\"" . strtr("$2", array("\"" => "&quot;")) . "\">$3</acronym>"',
// [me=Comment]does something[/me]
'~\[me=((?:&quot;)?)(.{1,80}?)\\1\](.+?)\[/me\](?:<br />)?~i' => isset($disabled['ftp']) ? '/me $3<br />' : '<div class="meaction">* $2 $3</div>',
// An email address they just typed in.  Don't match if there's already a mailto: or = before it.
'~(?<=[\?\s\xA0[\]()*\\\;>]|^)([\w\-\.]{1,80}@[\w\-]+\.[\w\-\.]+[\w\-])(?=[?,\s\xA0\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|&#039;|\.(?:\.|&nbsp;|\s|$|<br />))~i' => '<a href="mailto:$1">$1</a>',
'~(?<=<br />)([\w\-\.]{1,80}@[\w\-]+\.[\w\-\.]+[\w\-])(?=[?\.,\s\xA0\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|&#039;)~i' => '<a href="mailto:$1">$1</a>',
// This last one fixes spaces at the beginning of lines.
'~<br /> ~' => '<br />&nbsp;',
// Match a table... hopefully with everything in the right place.
'~\[table\](?:\s|\xA0|<br />|&nbsp;)*((?:\[tr\](?:\s|\xA0|<br />|&nbsp;)*\[td\]).*?(?:(?:\s|\xA0|<br />|&nbsp;)*\[/td\]\[/tr\])*)(?:\s|\xA0|<br />|&nbsp;)*\[/table\](?:\s|\xA0|<br />|&nbsp;)?~i' => '<table>$1</table>',
);

$codefromcache = array_keys($code_to_from);
$codetocache = array_values($code_to_from);

// GLOWING or /shadowed/ text.
$codefromcache[] = '~\[glow=([#\w]{3,12}),([012]\d{1,2}|\d{1,2})(,[^]]+)?\](.+?)\[/glow\]~i';
$codetocache[] = isset($disabled['glow']) ? '$4' : '<table border="0" cellpadding="0" cellspacing="0" style="display: inline; vertical-align: middle; font: inherit;"><tr><td style="filter: Glow(color=$1, strength=$2); font: inherit;">$4</td></tr></table> ';
$codefromcache[] = '~\[shadow=([#\w]{3,12}),(left|right|top|bottom|[0123]\d{0,2})\](.+?)\[/shadow\]~ei';
$codetocache[] = isset($disabled['shadow']) ? 'strtr(\'$3\', array(\'\\"\' => \'"\'))' : '\'<table border="0" cellpadding="0" cellspacing="0" style="display: inline; vertical-align: middle; font: inherit;"><tr><td style="filter: Shadow(color=$1, direction=\' . (isset($shadow_directions[\'$2\']) ? $shadow_directions[\'$2\'] : (int) \'$2\') . \'); font: inherit;">\' . strtr(\'$3\', array(\'\\"\' => \'"\')) . \'</td></tr></table> \'';

// Moving text... [move]stuff[/move]
$codefromcache[] = '~\[move\](.+?)\[/move\]~i';
$codetocache[] = isset($disabled['move']) ? '$1' : '<marquee>$1</marquee>';

// Handle flash.
$codefromcache[] = '~\[flash=(\d+),(\d+)\](?:<br />)*([^<>]+?)(?:<br />)*\[/flash\]~ie';
if (empty($modSettings['enableEmbeddedFlash']) || isset($disabled['flash']))
$codetocache[] = isset($disabled['url']) ? '"$3"' : '"<a href=\"" . strtr("$3", array("\"" => "&quot;")) . "\" target=\"_blank\">$3</a>"';
// Internet Explorer for Windows.
elseif ($context['browser']['is_ie'] && !$context['browser']['is_mac_ie'])
$codetocache[] = '"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"$1\" height=\"$2\"><param name=\"movie\" value=\"" . strtr("$3", array("\"" => "&quot;")) . "\" /><param name=\"play\" value=\"true\" /><param name=\"loop\" value=\"true\" /><param name=\"quality\" value=\"high\" /><param name=\"AllowScriptAccess\" value=\"never\" /><embed src=\"" . strtr("$3", array("\"" => "&quot;")) . "\" width=\"$1\" height=\"$2\" play=\"true\" loop=\"true\" quality=\"high\" AllowScriptAccess=\"never\" /><noembed><a href=\"" . strtr("$3", array("\"" => "&quot;")) . "\" target=\"_blank\">$3</a></noembed></object>"';
// Anything else.
else
$codetocache[] = '"<embed type=\"application/x-shockwave-flash\" src=\"" . strtr("$3", array("\"" => "&quot;")) . "\" width=\"$1\" height=\"$2\" play=\"true\" loop=\"true\" quality=\"high\" AllowScriptAccess=\"never\" /><noembed><a href=\"" . strtr("$3", array("\"" => "&quot;")) . "\" target=\"_blank\">$3</a></noembed>"';
}

// Nothing to parse... ?
if (!strstr($message, '[') && !strstr($message, '://') && !strstr($message, '@') && !strstr($message, '/me') && !strstr($message, '&lt;'))
return;

$message = strtr($message, array('$' => '&#036;'));
// Replace <a href="something">somewhere</a> with HTML.
if (!empty($modSettings['enablePostHTML']) && strstr($message, '&lt;'))
{
$message = preg_replace('~&lt;a\s+href=(?:&quot;)?(?:\[url\])?((?:http://|ftp:/\|https://|ftps://|mailto:).+?)(?:\[/url\])?(?:&quot;)?&gt;(.+?)&lt;/a&gt;~ie', '\'<a href="$1">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \'</a>\'', $message);

// Do <img ... /> - with security... action= -> action-.
preg_match_all('~&lt;img\s+src=(?:&quot;)?(?:\[url\])?((?:http://|ftp://|https://|ftps://).+?)(?:\[/url\])?(?:&quot;)?(?:\s+alt=(?:&quot;)?(.*?)(?:&quot;)?)?(?:\s?/)?&gt;~i', $message, $matches, PREG_PATTERN_ORDER);
if (!empty($matches[0]))
{
$replaces = array();
foreach ($matches[1] as $match => $imgtag)
{
// No alt?
if (!isset($matches[2][$match]))
$matches[2][$match] = '';

// Remove action= from the URL - no funny business, now.
if ($imgtag != preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $imgtag))
$replaces[$matches[0][$match]] = '<img src="' . preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $imgtag) . '" alt="' . $matches[2][$match] . '" border="0" />';

// Check if the image is larger than allowed.
if (!empty($modSettings['maxwidth']) && !empty($modSettings['maxheight']))
{
list ($width, $height) = url_image_size($imgtag);

if ($width > $modSettings['maxwidth'] || $height > $modSettings['maxheight'])
{
if ($width > $modSettings['maxwidth'] && !empty($modSettings['maxwidth']))
{
$height = floor($modSettings['maxwidth'] / $width * $height);
$width = $modSettings['maxwidth'];
if ($height > $modSettings['maxheight'] && !empty($modSettings['maxheight']))
{
$width = floor($modSettings['maxheight'] / $height * $width);
$height = $modSettings['maxheight'];
}
}
else
{
if ($height > $modSettings['maxheight'] && !empty($modSettings['maxheight']))
{
$width = floor($modSettings['maxheight'] / $height * $width);
$height = $modSettings['maxheight'];
}
}
}

// Set the new image tag.
$replaces[$matches[0][$match]] = '<img src="' . preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $imgtag) . '" width="' . $width . '" height="' . $height . '" alt="' . $matches[2][$match] . '" border="0" />';
}
elseif (strpos($matches[0][$match], '[url]') !== false || substr($matches[0][$match], 0, 4) == '&lt;')
$replaces[$matches[0][$match]] = '<img src="' . preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $imgtag) . '" alt="' . $matches[2][$match] . '" border="0" />';
}

$message = strtr($message, $replaces);
}
}

// Do the code if necessary.
if (strstr($message, '[') || strstr($message, '://') || strstr($message, '@') || strstr($message, '/me'))
{
$shadow_directions = array('left' => '270', 'right' => '90', 'top' => '0', 'bottom' => '180');

$message = preg_replace($codefromcache, $codetocache, $message);

// Tables need to be done twice or they won't work properly.
if (strpos($message, '<table>') !== false)
{
for ($i = 0; $i < 2; $i++)
$message = preg_replace(
array(
'~((?:<table>|</tr>|\[/tr\])(?:\s|\xA0|<br />|&nbsp;)*(?:<tr>|\[tr\])|</td>|\[/td\])(?:\s|\xA0|<br />|&nbsp;)*\[td\](?:\s|\xA0|<br />|&nbsp;)*(.*?)(?:\s|\xA0|<br />|&nbsp;)*\[/td\](?:\s|\xA0|<br />|&nbsp;)*((?:</tr>|\[/tr\])(?:\s|\xA0|<br />|&nbsp;)*(?:<tr>|\[tr\]|</table>)|<td(?: valign="top")?>|\[td\])~i',
'~(<table>|</tr>|\[/tr\])(?:\s|\xA0|<br />|&nbsp;)*\[tr\](?:\s|\xA0|<br />|&nbsp;)*(.*?)(?:\s|\xA0|<br />|&nbsp;)*\[/tr\](?:\s|\xA0|<br />|&nbsp;)*(</table>|<tr>|\[tr\])~i'
),
array(
'$1<td valign="top">$2</td>$3',
'$1<tr>$2</tr>$3'
), $message
);
}
}

// Enable Basic HTML?
if (!empty($modSettings['enablePostHTML']) && strstr($message, '&lt;'))
{
// b, u, i, s, pre... basic tags.
$closable_tags = array('b', 'u', 'i', 's', 'pre', 'blockquote');
foreach ($closable_tags as $tag)
{
$opens = substr_count($message, '&lt;' . $tag . '&gt;');
$closes = substr_count($message, '&lt;/' . $tag . '&gt;');
$message = str_replace(array('&lt;' . $tag . '&gt;', '&lt;/' . $tag . '&gt;'), array('<' . $tag . '>', '</' . $tag . '>'), $message);

if ($closes < $opens)
$message .= str_repeat('</' . $tag . '>', $opens - $closes);
}

// <br /> should be empty.
$empty_tags = array('br');
foreach ($empty_tags as $tag)
$message = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . ' />', $message);
}
}

// Parse smileys in the passed message.
function parsesmileys(&$message)
{
global $modSettings, $db_prefix, $txt, $user_info;
static $smileyfromcache = array(), $smileytocache = array();

// If the smiley array hasn't been set, do it now.
if (empty($smileyfromcache) && $user_info['smiley_set'] != 'none')
{
// Use the default smileys if it is disabled. (better for "portability" of smileys.)
if (empty($modSettings['smiley_enable']))
{
$smileysfrom = array('>:D', ':D', '::)', '>:(', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
$smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
$smileysdescs = array('', $txt[289], $txt[450], $txt[288], $txt[287], $txt[292], $txt[293], $txt[291], $txt[294], $txt[295], $txt[451], $txt[296], $txt[526], $txt[527], $txt[529], $txt[530], $txt[528], '', '', '', '');
}
else
{
// Load the smileys in reverse order by length so they don't get parsed wrong.
$result = db_query("
SELECT code, filename, description
FROM {$db_prefix}smileys
ORDER BY LENGTH(code) DESC", __FILE__, __LINE__);
$smileysfrom = array();
$smileysto = array();
$smileysdescs = array();
while ($row = mysql_fetch_assoc($result))
{
$smileysfrom[] = $row['code'];
$smileysto[] = $row['filename'];
$smileysdescs[] = $row['description'];
}
mysql_free_result($result);
}

// This smiley regex makes sure it doesn't parse smileys within code tags (so [url=mailto:[email protected]] doesn't parse the :D smiley)
for ($i = 0, $n = count($smileysfrom); $i < $n; $i++)
{
$smileyfromcache[] = '/(?<=[>:\?\.\s\xA0[\]()*\\\;])(' . preg_quote($smileysfrom[$i], '/') . '|' . preg_quote(htmlspecialchars($smileysfrom[$i], ENT_QUOTES), '/') . ')(?=[^[:alpha:]0-9]|$)/';
$smileytocache[] = '<img src="' . $modSettings['smileys_url'] . '/' . $user_info['smiley_set'] . '/' . $smileysto[$i] . '" alt="' . htmlspecialchars($smileysdescs[$i]) . '" border="0" />';
}
}

// Replace away! (do it twice just in case.)
$message = preg_replace($smileyfromcache, $smileytocache, $message);
}

// Highlight any code...
function highlight_php_code($code)
{
global $context;

// Remove special characters.
$code = un_htmlspecialchars(strtr($code, array('<br />' => "\n", "\t" => 'SMF_TAB();')));

$oldlevel = error_reporting(0);

// It's easier in 4.2.x+.
if ((float) PHP_VERSION < 4.2)
{
ob_start();
@highlight_string($code);
$buffer = str_replace(array("\n", "\r"), '', ob_get_contents());
ob_end_clean();
}
else
$buffer = str_replace(array("\n", "\r"), '', @highlight_string($code, true));

error_reporting($oldlevel);

// Yes, I know this is kludging it, but this is the best way to preserve tabs from PHP :P.
$buffer = preg_replace('~SMF_TAB(</(font|span)><(font color|span style)="[^"]*?">)?\(\);~', "<pre style=\"display: inline;\">\t</pre>", $buffer);

return strtr($buffer, array('\'' => '&#039;', '<code>' => '', '</code>' => ''));
}

// Put this user in the online log.
function writeLog($force = false)
{
global $db_prefix, $ID_MEMBER, $user_info, $sc, $modSettings;

// Don't mark them as online more than every so often.
if (empty($_SESSION['log_time']) || $_SESSION['log_time'] < (time() - 8) || $force)
$_SESSION['log_time'] = time();
else
return;

if (!empty($modSettings['who_enabled']))
{
$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
unset($serialized['sesc']);
$serialized = addslashes(serialize($serialized));
}
else
$serialized = '';

// Guests use 0, members use their session ID.
$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();

db_query("
DELETE FROM {$db_prefix}log_online
WHERE logTime < NOW() - INTERVAL " . ($modSettings['lastActive'] * 60) . " SECOND
OR session = '$session_id'" . (empty($ID_MEMBER) ? '' : " OR ID_MEMBER = $ID_MEMBER"), __FILE__, __LINE__);
db_query("
INSERT IGNORE INTO {$db_prefix}log_online
(session, ID_MEMBER, ip, url)
VALUES ('$session_id', $ID_MEMBER, IFNULL(INET_ATON('$user_info[ip]'), 0), '$serialized')", __FILE__, __LINE__);

// Well, they are online now.
if (empty($_SESSION['timeOnlineUpdated']))
$_SESSION['timeOnlineUpdated'] = time();

// Set their login time, if not already done within the last minute.
if (!empty($user_info['last_login']) && $user_info['last_login'] < time() - 60)
{
// Don't count longer than 15 minutes.
if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
$_SESSION['timeOnlineUpdated'] = time();

updateMemberData($ID_MEMBER, array('lastLogin' => time(), 'memberIP' => '\'' . $user_info['ip'] . '\'', 'totalTimeLoggedIn' => 'totalTimeLoggedIn + ' . (time() - $_SESSION['timeOnlineUpdated'])));

$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
$_SESSION['timeOnlineUpdated'] = time();
}
}

/* Make sure the browser doesn't come back and repost the form data.
Should be used whenever anything is posted. */
function redirectexit($setLocation = '', $add = true, $refresh = false)
{
global $scripturl, $modSettings;

// Add the scripturl on if needed.
if (WIRELESS)
{
if ($add)
$setLocation = $scripturl . '?' . $setLocation;

$char = strpos($setLocation, '?') === false ? '?' : ';';

if (strpos($setLocation, '#') ==! false)
$setLocation = strtr($setLocation, array('#' => $char . WIRELESS_PROTOCOL . '#'));
else
$setLocation .= $char . WIRELESS_PROTOCOL;
}
elseif ($add)
$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');

// Put the session ID in.
if (defined('SID') && SID != '')
$setLocation = preg_replace('/' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')(\?)?/', $scripturl . '?' . SID . '&', $setLocation);

// Send the header only.
if (empty($modSettings['redirectMetaRefresh']))
{
// We send a Refresh header only in special cases because Location looks better. (and is quicker...)
if ($refresh)
header('Refresh: 0; URL=' . strtr($setLocation, array(' ' => '%20', ';' => '%3b')));
else
header('Location: ' . str_replace(' ', '%20', $setLocation));
}
else
{
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="refresh" content="0;URL=', strtr($setLocation, array(' ' => '%20', ';' => '%3b')), '" />
</head>
<body style="font-family: Georgia, serif; font-size: 1.3em; margin-top: 20%; text-align: center; background-color: white;">
<a href="', str_replace(' ', '%20', $setLocation), '" style="color: black;">', $setLocation, '</a>
</body>
</html>';
}

obExit(false);
}

// Ends execution.  Takes care of template loading and remembering the previous URL.
Title: Re: Table From CSV
Post by: Anguz on September 02, 2005, 11:59:37 AM
I see now. The FasterParsecode mod didn't install, you have the original parsecode function there. You probably didn't notice the failure notice when installing and hit proceed. "uninstall" the FasterParsecode mod and install again until it says "success" in the preview, then install this mod. HIH.
Title: Re: Table From CSV
Post by: oSa on September 02, 2005, 04:16:48 PM
Thanks, I've solved the problem. FasterParsecode wouldn't  install from the package manager so i c/p the  code manually. Now it doesn't show that the fpc is installed, but all the tag mods (except the sort tag) work perfectly :). 

If i install custom bbcode mod now (after textarea mod offcourse ;)), does it cause any problems?
Title: Re: Table From CSV
Post by: Anguz on September 02, 2005, 05:22:02 PM
Don't see why it would. Glad you solved it. To get the uninstall option for the FasterParsecode mod, you could try installing it, it'll say it fails, but proceed anyway, you already have the code there, but now you'll also have the package manager know it's there and you'll be able to manage the mod with it.
Title: Re: Table From CSV
Post by: oSa on September 03, 2005, 07:51:51 AM
Once again thanks for the tip ;)
Title: Re: Table From CSV
Post by: Anguz on September 03, 2005, 02:25:32 PM
NP.
Title: Re: Table From CSV
Post by: Rasyr on November 30, 2005, 09:50:42 PM
Is there a version that will work with 1.1 RC1?

I work for a table-top game company, and our users like working with lots of spreadsheets and tables and such, and something like this would be a HUGE benefit for them....


Title: Re: Table From CSV
Post by: white1 on December 01, 2005, 06:31:04 AM
Is there an alternative to this for 1.1?
Title: Re: Table From CSV
Post by: Anguz on December 01, 2005, 06:15:15 PM
Not yet, sorry. The code parser changed a lot in 1.1 and it's still subject to changes until we reach final, so I may not be releasing this mod for a while. I can be motivated to do so, though, lol. Sorry, been pretty busy lately and releasing my mods for 1.0 before final caused me to have to release several updates.
Title: Re: Table From CSV
Post by: agridoc on December 01, 2005, 07:56:12 PM
Anguz for some forums who use tables your mod will be nececcary for ugrade. Tables will not be wiewed as tables without your mod.

Of course you know better but will it be necessary for a Faster Parsecode mod also with 1.1?

On the other hand it is true that making modifications again and again is annoying. I recently had worked making Greek buttons for some of Bloc' s themes with hiw Button Generators and I installed them in my forum for test display in Greek. I had to modify the files for each of them to work with Table from CSV and it will be quite some work to do that again and again. It is not difficult but it needs time. Also the dark themes needed a little play with table background colors in the CSS file.
Title: Re: Table From CSV
Post by: Anguz on December 01, 2005, 10:26:24 PM
I will try to make it work with the current parser in 1.1 for a couple of reasons: 1) writting a new Faster Parsecode would be like making less the default one again, and it's been just written; 2) I could probably improve the current one with a lot of work, but that'd be with a lot of work, which I can't put in such a mod at the time. On the other hand, since I haven't studied the new parser, I can't guarantee that I can make this mod work in it. One way or another, I'll do my best to accomplish it when I start working on it.

I know that your forum requires it, and if it wasn't for the fact that there's nothing wrong with SMF 1.0.5, I'd be upgrading the mod to 1.1 already, but 1.0.5 is good enough for now to wait until 1.1 final, IMO.

P.S.: If someone really can't wait to get an upgrade for this mod, bribe me via PM :D.
Title: Re: Table From CSV
Post by: agridoc on December 02, 2005, 01:33:39 AM
Thank you Anguz, I see you enough motivated for the mod  ;)
Title: Re: Table From CSV
Post by: Anguz on December 02, 2005, 01:55:03 AM
:)
Title: Re: Table From CSV
Post by: Rasyr on December 02, 2005, 08:17:23 AM
Yes, thank you very very much!!! My users will rejoice if I can install this mod for them...

:)

They like large tables, and being able to use csv and/or tab-delimited to import into a table would make them very, very happy!! You will be their hero.   ;D
Title: Re: Table From CSV
Post by: agridoc on December 02, 2005, 09:22:22 AM
If you have not seen this mod working with large tables Rasyr take a look at http://www.aeromodelling.gr/ForumS/index.php/topic,250.0.html

It' s in Greek but the tables are daily results from the 2005 R/C model helicopters World championship, category F.A.I. F3C, in Jamora, Spain.

The tables can be copied and pasted as tables in other programs. The delimiter is configurable.

Anguz made this possible.
Title: Re: Table From CSV
Post by: Rasyr on December 02, 2005, 09:59:18 AM
Very nice!! That is exactly what would be needed by my users. They would just LOVE this!!

:D



Title: Re: Table From CSV
Post by: Rasyr on December 07, 2005, 04:03:07 PM
anguz - do we need to beg?   :'(
Title: Re: Table From CSV
Post by: Rasyr on December 10, 2005, 07:20:24 AM
Any progress? My users are really anxious for me to install this mod.   :D

They all think it would be very  8)
Title: Re: Table From CSV
Post by: Anguz on December 10, 2005, 02:56:47 PM
Like I said, I won't update my mods for 1.1 until it reaches final. Now, what you can do if you don't want to wait, is use 1.0.5, but that'd mean you don't get the cool things in 1.1 in the meantime.

The other option, is to replace the parsecode function in 1.1 with the one in my Faster Parsecode mod, although I don't know if this would break something, but I doubt it. After changing that function, you can apply the mods that require it, including this one.

Hope that helps.
Title: Re: Table From CSV
Post by: Rasyr on December 10, 2005, 03:04:14 PM
Would 1.1 apply the mods, or would I have to do that manually? Figured it couldn't hurt to ask.  :D
Title: Re: Table From CSV
Post by: Anguz on December 10, 2005, 05:13:20 PM
FasterParsecode will have to be manual, unless you modify the package to accept the SMF version you're using and also modify the .mod file to search for the code in your version instead of the 1.0.5 one. The other mods would only need the SMF version check removed or changed to the one you have.
Title: Re: Table From CSV
Post by: Rasyr on December 10, 2005, 08:05:18 PM
Cool!

I will download and take a look through the Faster Parsecode mod and compare it to what is already there (if the function it searches for is still the same as in 1.05, then it should not be an issue replacing it with the mod code).

And then I can add in the CSV stuff (and then make a button for it so my users don't freak out over having to type in the tags by hand... heheh)

Thanks lots!!

Title: Re: Table From CSV
Post by: Anguz on December 11, 2005, 01:03:22 AM
Sure.

BTW, you won't find the same code, but you will find the function by its name in Subs.php. Copy it and paste it instead of the current one in the "search for" part of the .mod file in Faster Parsecode.

Regarding the buttons for the Table From CSV mod, maybe Agridoc would be willing to share here with you what he did to make your job that much simpler.

Also, whatever you do, I recommend you do with with packages, so that future upgrades are less trouble.
Title: Re: Table From CSV
Post by: Rasyr on December 11, 2005, 10:44:33 AM
Oh well, I guess that they are not going to get this Mod anytime soon....

I went ot install it manually, and sources/subs.php contains no function called parsecode(). In fact, none of the files in the sources directory contain that function. I use Homesite which allows me to search all the files in the directory, and I searched for the string "parsecode" and it came up empty.

From the looks of things, 1.1 RC1 breaks the single parsecode function into a number of smaller functions.

Title: Re: Table From CSV
Post by: agridoc on December 11, 2005, 11:07:52 AM
I don't use any extra button neither I think it is needed. I have posted in my forum a message with instructions and an example.


In the editor press the button "Insert Table" (http://www.simplemachines.org/community/Themes/simple/images/bbc/table.gif). You get the code:
[table][/table]
Add an equal sign =
[table=][/table]
Now add between the tags your CSV (Comma Separated Values) table and you are ready i.e.
[table=]Name,Points, Rank
George, 860,1
Phil,845,2
Teddy, 807,3[/table]


--- Here the table is shown, not possible here. ---

If we want to use commas inside the table another separator must be used . The table has to be made using a separator not included in the contents. A good selection is the character "|". In this case the character "|" is given as a parameter "=|". If no parameter is given it defaults to comma ",".
[table=|][/table]


You may take this example, if you like my English 8) (the original is in Greek) and modify it as you like. I don' t think the difference of the equal sign is worth the effort to modify the editor 's code for adding an extra button. In some countries the semicolon takes the place of comma.
Title: Re: Table From CSV
Post by: agridoc on December 11, 2005, 11:42:49 AM
Quote from: Rasyr on December 11, 2005, 10:44:33 AM
I went ot install it manually, and sources/subs.php contains no function called parsecode(). In fact, none of the files in the sources directory contain that function. I use Homesite which allows me to search all the files in the directory, and I searched for the string "parsecode" and it came up empty.

Well a quick glance found "parsecode" (part of "preparsecode") in the files in subdirectory sources (1.1 RC1)
ManageNews.php
MoveTopic.php
PersonalMessage.php
Post.php
Profile.php
Subs-Post.php

subdirectory sources (1.05 for comparison)
Admin.php
InstantMessage.php
MoveTopic.php
Post.php
Profile.php
Subs-Post.php
Subs.php

Maybe Homesite doesn't search inside PHP files. Also I am not sure I will have the time for more.
Title: Re: Table From CSV
Post by: Anguz on December 11, 2005, 01:50:13 PM
Thank you, agridoc.

Rasyr, I did a quick search in Subs.php and the function is now named parse_bbc, shows how much I've worked with 1.1 so far ::).

Make a backup before trying this, I don't know how much the function changed besides the parsing code. I don't know if it's supposed to do other stuff, too, for exampe, or if some variables used outside now have other names.

When you modify the .mod file, not only will you change the function searched for, now, but will also change the function name in the replace part, so that it uses the new one.
Title: Re: Table From CSV
Post by: ianus on January 06, 2006, 10:09:32 AM
Long Hello!
A year ago, I decided to bring up my own board with some information about RPG and movie stuff. I decided to use the SMF because I noticed the Table From CSV –mod.
There is not much conted at the moment, but some tables are available.

So I like to send a honest ,,Tanks you". I greatly appreciated your work.

I like to give a single link, especially for SMF users who like to see this mod working.
It´s an german speaking site, but this should not circumvent the impression.

You will notice, even the spoiler mod is working, even inside of the table.

The link is
http://www.firopolis.de/forum/index.php/topic,5.0.html
or
http://www.firopolis.de/forum/index.php/topic,219.msg292.html#msg292
or ...

Thanks again and best regards.
Title: Re: Table From CSV
Post by: Anguz on January 06, 2006, 03:54:22 PM
ianus, thank you very much for your message! This kind of feedback always makes me very happy. :D
Title: Re: Table From CSV
Post by: takeliner on January 18, 2006, 11:10:02 AM
Let me thank you first for this mod! It's great, but
I'm experiencing a little error in my Table:

If I have a url in my Table like this
[url=http://www.google.de/imghp?hl=de&tab=wi&q=]Link]/url]
and send it. There will be this link generated:
http://www.google.de/imghp?hl=de&%3C/td%3E%3Ctd%20valign=%22top%22%3Etab=wi&%3C/td%3E%3Ctd%20valign=%22top%22%3Eq=

If I wrote this [url=http://www.google.de/imghp?hl=de&tab=wi&q=]Link]/url] outside of the table it works great, but not in the CSV Table.

I hope anyone can help me fixing this little glitch.

PS: Sorry for my bad english, i'm only a lazy german ;-)

CyA Takeliner
Title: Re: Table From CSV
Post by: Anguz on January 18, 2006, 02:31:16 PM
Hmm... that sounds like a problem that the mod had in an earlier version. Did you install the latest one? BTW, a bracket for the closing URL tag is wrong, is it like that in your test?
Title: Re: Table From CSV
Post by: agridoc on January 18, 2006, 02:57:43 PM
There is a small error in brackets (Link]/url). The right code is
[url=http://www.google.de/imghp?hl=de&tab=wi&q=]Link[/url]

I tried it in my forum (SMF 1.03) and works OK in a CSV table.
Title: Re: Table From CSV
Post by: Anguz on January 18, 2006, 04:22:52 PM
Thanks, agridoc.
Title: Re: Table From CSV
Post by: takeliner on January 20, 2006, 06:59:29 AM
Oh-Oh

At first I had an error in my post with the bracket, in testing there is one. But I guess i found the problem, we're using the 1.0.5 version of smf...

I forgot, that the co-admin told me he updatet a few days ago,(my organization is very messy and stressed up at the moment).

I'm sorry I forgot about the version. So I guess that Problem is cause of the yet uncompatible version of my SMF.(Ohoh, hard with my school english  :'( )

So i've to wait I guess.... although it works, only without an url Tag in a table...(It makes the table much less wide, so there's no horizontal scrolling *G*)

CyA Takeliner
Title: Re: Table From CSV
Post by: agridoc on January 20, 2006, 08:17:57 AM
takeliner there are Table From CSV versions up to SMF 1.05 http://mods.simplemachines.org/index.php?mod=40

I have a SMF 1.05 test forum with Table From CSV Mod and your link, as well as others, work perfectly in a table. You must update the FasterParsecode Mod, then theTable From CSV Mod with the versions for SMF 1.05.

There is no version for 1.1 yet, I hope Anguz will make one  when the right time  comes ;)
Title: Re: Table From CSV
Post by: takeliner on January 20, 2006, 12:46:21 PM
Oops, then I have the latest Versions:

SMF: 1.05
Parsecode: 1.09
TableCSV: 1.23

No other Mods installed, everything works except the Url Tag in the table.

I tried a bit and have these state of progress:

There seems to be a mistake/error with the Url that has special Chars in it:

If I put this:
[table=;]A;B;
[url=http://www.google.de/imghp?hl=de&tab=wi&q=]Link[/url];[url=http://www.google.de]Link[/url]
[/table]


The First Url under the A(the one with ...imghp?... )
makes this link:(http://www.takeliner.de/Bilder/smf/urltag.jpg)
The "B" Url (the normal google.de) makes this link:
http://www.google.de/

Because it works by other users, maybe it's only a mistake in the code?

Thanks for your help!
CyA Takeliner
Title: Re: Table From CSV
Post by: Anguz on January 20, 2006, 01:51:12 PM
The problem seems to be given by the amp symbol. I'll look into it.
Title: Re: Table From CSV
Post by: Anguz on January 20, 2006, 02:03:46 PM
I haven't tested it yet, can't right now, but I believe the problem comes from the & being converted to &amp; somewhere, and since you're using ; as the separator, you get extra td tags. Try using a different separator, please, and let me know how it goes. I'll try to fix the problem, though.
Title: Re: Table From CSV
Post by: Anguz on January 20, 2006, 02:10:14 PM
Quote from: agridoc on January 20, 2006, 08:17:57 AM
There is no version for 1.1 yet, I hope Anguz will make one  when the right time  comes ;)

Yeah, you'll get it soon :). Looking at the mod's code again today, I saw a couple of places it could be improved a bit. Not radically, though, it's already too good ;D.
Title: Re: Table From CSV
Post by: takeliner on January 20, 2006, 04:39:42 PM
Excellent it works!

I'm using the  ~ as the seperator now. 'Cause i found no chance in Excel to say it which seperator he should use as a seperator. I wrote a small php code in which I format the exported *.CSV automatically with Boardcode and now with the replace of the seperator.

Thanks alot!

CyA Takeliner
Title: Re: Table From CSV
Post by: Anguz on January 20, 2006, 05:27:09 PM
Cool :).
Title: Re: Table From CSV
Post by: agridoc on January 20, 2006, 05:37:04 PM
Yes I get an error too in links mith semicolon ";" as separator. I did my tests with comma "," although I usually use a  "|".

A table also can be copied and pasted to Word, then use it' s options to select a separator from table to text screen.
Title: Re: Table From CSV
Post by: takeliner on January 21, 2006, 03:13:18 PM
Word..., I should have thought about it.
But with my .php its possible to write predefined text just before and directly after a column automatically,
(e.g. the second column contains URLS, so I write only the http..link in the table and afterwards
I put it on the server, open the edit.php once and get a done.csv with the replaced seperators and the code wrapped around the Columns.
If anybody is Interested in the phpcode I will give ya the code....

CyA Takeliner
Title: Re: Table From CSV
Post by: Anguz on January 22, 2006, 03:36:01 PM
Oh, I'm sure there'll be many who'd be happy to have it. If you're so kind, please post it here between code tags, unless you prefer people contacting you via PM and giving it privately. Thanks!
Title: Re: Table From CSV
Post by: takeliner on January 23, 2006, 03:01:37 AM
Yeah, I've already got PMs. But I was the weekend away from everything that's like a computer! *G*

Here comes the PHP-Code, it does:
-Wrapping Code around each column
-Deleting the enclosure "
-Replacing the ; to an ~ not to get the error I had a few posts ago(the ; with an ? can make problemes)
so to have an ~ as an seperator

<?php
error_reporting
(E_ALL); 
//Configuration
//input.csv
$inputdata 'input.csv';
$editeddata 'done.csv';
$seperator ';';
$newseperator '~';
$enclosure '"';
$newenclosure '';
//Wrapping the Code around the columns
//X-ColumnNumber-a <--Code at BEGINNUNG of a column
//X-ColumnNumber-e <--Code at END of a column
//Currently supports 8 Columns, but easily to make up to infinite *G*
$X1a '[color=green]';
$X1e '[/color]';
$X2a '';
$X2e '';
$X3a '[color=orange]';
$X3e '[/color]';
$X4a '[color=red]';
$X4e '[/color]';
$X5a '[color=blue]';
$X5e '[/color]';
$X6a '[url=';
$X6e ']Link[/url]';
$X7a '';
$X7e '';
$X8a '[color=red]';
$X8e '[/color]';
//Reading input.csv
$fh fopen($inputdata'r');
//Wraps Code around the Columns
while (($line fgetcsv($fh1000';')) !== FALSE ) {
    
$line[0] = $X1a.$line[0].$X1e;
$line[1] = $X2a.$line[1].$X2e;
$line[2] = $X3a.$line[2].$X3e;
    
$line[3] = $X4a.$line[3].$X4e;
$line[4] = $X5a.$line[4].$X5e;
$line[5] = $X6a.$line[5].$X6e;
$line[6] = $X7a.$line[6].$X7e;
$line[7] = $X8a.$line[7].$X8e;
$file[] = $line;
}
fclose($fh);
$fh fopen($editeddata'w');
foreach (
$file as $line) {
    
fputcsv($fh$line';') or die('Fehler beim schreiben der fertig.csv(Chmod?)!');
}
fclose($fh);
//Deleting Enclosure
$fh fopen($editeddata'r');
$gelesen fread($fh,10000000);
fclose($fh);
$ersetzt str_replace($enclosure,$newenclosure,$gelesen);
$fh fopen($editeddata'w');
fwrite($fh$ersetzt);
fclose($fh);
echo(
'Fertig!!!');
//Deleting Seperator
$fh fopen($editeddata'r');
$gelesen fread($fh,10000000);
fclose($fh);
$ersetzt str_replace($seperator,$newseperator,$gelesen);
$fh fopen($editeddata'w');
fwrite($fh$ersetzt);
fclose($fh);
echo(
'Fertig!!!');
?>


CyA Takeliner
Title: Re: Table From CSV
Post by: Prasad007 on January 23, 2006, 06:28:30 AM
thank you! gr8 mod!! :) :)
Title: Re: Table From CSV
Post by: Anguz on January 23, 2006, 02:19:25 PM
takeliner, thx for the code. I'd suggest using a separator that's very unlikely to happen in the table content, like |, cause ~ happens in many URLs.

Prasad007, glad you like it. :)
Title: Re: Table From CSV
Post by: takeliner on January 27, 2006, 06:25:05 AM
Everybody can use a seperator he wants, but I Chose the ~ because all my links are from one site with always the same urls except two numbers at the end.

Just now i've an idea to make the table shorter in my case *G*

CyA takeliner
Title: Re: Table From CSV
Post by: Anguz on January 31, 2006, 04:37:07 PM
1.24
Title: Re: Table From CSV
Post by: agridoc on January 31, 2006, 06:22:05 PM
It works OK, thank you Anguz  :)

There is a difference however, I don' t get the different rows color and the monospace font, the display is like SMF' s tables, I think that there was a modification in the css file for doing this. I will look at it tomorrow.
Title: Re: Table From CSV
Post by: Anguz on January 31, 2006, 08:26:27 PM
The same happened in my test. Try ctrl+F5 to refresh the cached CSS.
Title: Re: Table From CSV
Post by: agridoc on February 01, 2006, 12:59:59 AM
Yes, the display is as it should be today. I was quite tired last night  ::). Thank you Anguz.

Any news on a 1.1 vesion?
Title: Re: Table From CSV
Post by: Anguz on February 01, 2006, 04:20:51 AM
Glad it's working.

No, nothing for 1.1 yet.
Title: Re: Table From CSV
Post by: navjotjsingh on July 12, 2006, 01:51:13 AM
So when it will be updated for 1.1RC2?
Title: Re: Table From CSV
Post by: djshank on September 29, 2006, 08:20:39 PM
Will we see a version for 1.1 RC3 any time soon?
Title: Re: Table From CSV
Post by: agridoc on December 02, 2006, 11:30:13 PM
Hello Anguz

SMF 1.1 final is released.  ;)

Should a compatible Table From CSV mod be expected now?
Title: Re: Table From CSV
Post by: ianus on December 03, 2006, 06:58:25 AM
Greetings!

I hope so. This is the only mod my board is dependent on.
Quick reminder:
Re: Table From CSV (http://www.simplemachines.org/community/index.php?topic=18917.msg445827#msg445827)

Well, I´m full of hope
Quote from: Anguz on December 02, 2006, 11:16:58 AM
Awesome! Great job!

I'll have to start working on updating my mods now. :P


But if you don´t upgrade this remarkable mod, I will not upgrade to 1.1, can spare my time and stop to rewrite and convert my personal changes (mainly the stylesheets and some own php code).

So, the only thing I like to know is: Will you update this mod?
I´m not (really) interested in a "when", don´t beg for a "please soon", my only point is "whether or not?"

Have a lot of fun and successes with everything you do.
ianus

Title: Re: Table From CSV
Post by: Anguz on December 07, 2006, 11:26:07 PM
agridoc, ianus,

Thanks for your messages. As promised, this mod will be rewritten for 1.1 Final, I haven't forgotten about it, just give me a little time.

I still haven't even browsed the 1.1 code and the last months of my life have seen an immense amount of change and activity, leaving me little free time.

I'll let you all know about the release when I upload the new mod. :)
Title: Re: Table From CSV
Post by: agridoc on December 08, 2006, 12:40:19 AM
Thank you Anguz.  :)

I believe that, if the SMF parsecode is used, not many changes will be needed. If you want someone to test, please send me PM.  ;)
Title: Re: Table From CSV
Post by: ianus on December 08, 2006, 04:43:33 AM
Greetings!

Quote from: Anguz on December 07, 2006, 11:26:07 PM
the last months of my life have seen an immense amount of change and activity

That's something nice to read about. I hope everything proceeds to your perfect satisfaction.

If it´s necessary, I can test your code @localhost. My online presence is mirrored there (1.06), a new install (1.1) and an upgrade (1.06-1.1) are running also.
I only have limited space online and only one database, but if its nesessary, I can set up a new board.

But mainly, enjoy your life and have a lot of fun and success with everything you do.
Title: Re: Table From CSV
Post by: ianus on January 06, 2007, 08:13:50 AM
Greetings!

Ok, I give it a try.

The basics:
In index.template.php

<search for>

<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/script.js"></script>
</search for>

<add after>
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/sorttable.js"></script>



;-)

And more basics
In style.css

<search for>

/*The AJAX notifier */


<add before>

/* Table From CSV. */
.sortable td, .sortable th
{
font-family: monospace;
}
.sortarrow
{
font-family: serif;
}
.sortbg1 td
{
background-color: lime;
}
.sortbg2 td, .sortable th
{
background-color: pink;
}


:-!

Now the part that makes things happen. Mmh? No it don't.
It won't ruin the board, only displays a little error message and, mmh, well, noting happens.
No, I'm not surprised.

In subs.php
<search for>

);
// This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line.


<add before>

array(
'tag' => 'sorttable',
'before' => '<table=\'>',
'after' => '</table>',
'content' => '<$parse_table_csv',
'validate' => create_function('&$tag, &$data, $disabled', '
if(isset($add[\'[table=\']))
$arr1[] = \'~\[table=(.*?)\](.*?)\[/table\](?:\s|\xA0|<br />|&nbsp;)?~ie\';
$arr2[] = \'parse_table_csv(\'$1\', \'$2\')\';'),

'block_level' => true,
),



Same file:
<search for>

// This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line.
if ($message === false)
return $codes;


<add after>

function parse_table_csv($comma, $table)
{
static $id = 1;
$ths = $tds = '';
$comma = empty($comma) ? ',' : $comma;
$table = trim(strtr($table, array('<br />' => "\n")));
if (strpos($table, "\n") !== false)
{
$table = explode("\n", $table);
$ths = '<tr><th>' . strtr($table[0], array($comma => '</th><th>')) . '</th></tr>';
unset($table[0]);
$table = implode('</td></tr><tr><td>', $table);
}
$tds = '<tr><td valign="top">' . strtr($table, array($comma => '</td><td valign="top">')) . '</td></tr>';
return '<table id="tbl' . $id++ . '"' . (!empty($ths) ? ' class="sortable"' : '') . '>' . $ths . $tds . '</table>';
}



#-/


This is the best I can do and it's not enough, by far.
Title: Re: Table From CSV
Post by: agridoc on January 06, 2007, 09:09:11 AM
ianus the changes in index.template.php and style.css are only for display and sort add-ons.

Table from CSV works in 1.0x even with a theme without these changes. The table will be dispayed just plain. The javascript will act after the BBC tag is parsed.

The parse code in 1.1 is quite different from 1.0x.
Title: Re: Table From CSV
Post by: ianus on January 06, 2007, 11:50:36 AM
,,the changes in index.template.php and style.css are only for display and sort add-ons."

.sortbg1 td
{background-color: lime;}
.sortbg2 td, .sortable th
{background-color: pink;}

Are you really sure? Lime and Pink for the tables? I don't know. Have to ask my optician first.
;-)

,,The parse code in 1.1 is quite different from 1.0x."
Understatement, but true.
Title: Re: Table From CSV
Post by: agridoc on January 06, 2007, 01:12:33 PM
QuoteAre you really sure? Lime and Pink for the tables? I don't know. Have to ask my optician first.
;-)

If you have a 1.0x working, with Tables from CSV installed, use a theme without changes or use the original index.template.php and style.css and you will see it's true.
Title: Re: Table From CSV
Post by: ianus on February 05, 2007, 06:04:13 PM
February 6th:
:'(
March 6th:
:'(
Title: Re: Table From CSV
Post by: jrmc on March 10, 2007, 02:18:59 PM
hello
still nothing to 1.1.2??
Title: Re: Table From CSV
Post by: ianus on April 06, 2007, 07:57:13 AM
Greetings!

First I planned to edit my post above. Imho it's more polite.
But between January 06 and today this page was viewed ~2634 times. (screen)
So I assume that people still looking for this outstanding feature.

I like to submit a link to my board. Not a lot of English threads there and German speaking in general – so no advertising but a demonstration of the usefullness of this mod, a demonstration of the imperative necessity for my project.
NwN2: Crafting Recipes (http://www.firopolis.de/forum/index.php?topic=1288.0)

Remember, all you need is a simple [.table=]some|thing[./table]
and not a [table][tr][td][/td][td][/td][/tr][/table] construction or something like
[tabular type=4 caption="[b]Table 1:[/b] My budget this month (in dollars)"]
[row] [head]Type[/head] [head]In[/head] [head]Out[/head] [head]Sum[/head] [/row]
[/tabular]

(Example from the Tabular (http://www.simplemachines.org/community/index.php?topic=52436.0) mod. Great work and nice look but complicated to type all the code.)

So for this month.
April 6th:
:'(


Title: Re: Table From CSV
Post by: Bill.Ramby on April 07, 2007, 09:45:18 PM
I too would appreciate this mod working for 1.1.2. Thanks.
Title: Re: Table From CSV
Post by: Bill.Ramby on May 20, 2007, 09:23:14 AM
Bump.

Please.
Title: Re: Table From CSV
Post by: Lew Cipher on May 20, 2007, 05:38:45 PM
Bump.
Title: Re: Table From CSV
Post by: Kindred on May 20, 2007, 06:04:41 PM
Since this mod depends on other mods, which I do not believe have been updated for 1.1.2, and it's been requested a number of times with no repsonse, I believe that the answer is:

Sorry, no one is interested at this time....
Title: Re: Table From CSV
Post by: Bill.Ramby on May 20, 2007, 06:37:21 PM
I've got many tables that used the mod. I'll admit, I'm lazy and don't want to go back and put in all the td's, tr's, etc. It's a lot of work that would be automagically fixed by an updated mod. :'( :'( :'(
Title: Re: Table From CSV
Post by: ianus on May 21, 2007, 02:42:22 PM
Greetings!


Sorry, no one is interested at this time....
Well, I don´t think so.
This "feature" is unique. There is no other board-software which offer this quick and easy way to include tables - not to mention the sortable kind. I´m astonished about the missing support.

So. Soon - bear with me.

Spam und Fake und Gejammer & CSV code (http://www.simplemachines.org/community/index.php?topic=165715.msg1058151#msg1058151)
Preview: http://www.firopolis.de/forum/index.php/topic,835.0.html



I have to figure out how to set the divider [ | ] dynamically.
This line:
$fields   = explode("|",$curline);
Anybody?

and how to chance the table-color with some code like this:
$result .= "<tr class=\" $message [\'alternate\'] == 0 ? \'windowbg3\' : \'windowbg2\'\">";

Anybody?
Title: Re: Table From CSV
Post by: Anguz on August 21, 2007, 02:26:48 AM
Updated to version 1.30 for SMF 1.1.3.

Sorry for making you guys wait so long. Enjoy the feature. :)
Title: Re: Table From CSV
Post by: Tony Reid on August 21, 2007, 05:08:08 AM
Hey Thanks :)

Glad to have this back.
Title: Re: Table From CSV
Post by: Bill.Ramby on August 21, 2007, 07:12:24 AM
Thank you very much!
Title: Re: Table From CSV
Post by: agridoc on August 21, 2007, 07:28:19 AM
Thank you Anguz  :)

It's an excellent mod, I missed it for quite a while.
Title: Re: Table From CSV
Post by: ianus on August 21, 2007, 11:15:56 AM
Greetings

First, thanks for the update. This mod is still one of the best improvements for SMF.
New user will enjoy it.

I put this message into code-tag after the reply of agridoc. So everybody could see what we talking about, but because my message based on a wrong assumption, it´s not  newsworthy anymore.
I´m not happy with it but it is obvious that some of my own code cause the problems.   

Some problems.
Firefox:
If I load the page with the table:
Table head color and color of the first row differs and the color of the second row is the same like the head.
Until this point, everything is correct.

The first klick (at a headline) activates the sortfunktion, as it should, but the second klick only change the colors (in a strange way) and not the contend.
The "strange change" happens, if some rows have the same contend.
Third click starts sorting content with correct colors for each line.

A minor problem is, that a "Tabstop" is not accepted as divider.

IE6:
Mod is not working with my IE. Maybe somebody can approve or decline it.

Opera:
Three klicks to start sorting, but colors behave correct.


[hr]
The benefit of your code is the free choice of the "divider" and the definition of the rowcolors in the css file.
The main benefits are,
[list]
[li]that it isn't necessary to write the closing tab directly after the last word of the table [/li]
[li]and that a closing bbcode is possible in the last line except of the strange color behaviour.[/li]
[/list]



[hr]
You can find [b]examples[/b] for this at
http://www.firopolis.de/forum/index.php/topic,835.msg3386.html#msg3386

Example 1 shows the problems with the activation of the sort function and if you klick to sort the last line (the x one), you will see the strange color sort.

Example 2 & 3 will show that bbcode in the last row will break the table while using my code.

[b]Guest can try it[/b] in the same thread.
Code example is given in example 1

[hr]
Please don't get me wrong. I love your work and – as mentioned before – I choose SMF because of your mod.
All this is to improve the mod and not to blame you!

[hr]
Imho it would be wonderful if the benefits of both codes could be merged.



BTW. What´s about SMF 2?  :-X
Title: Re: Table From CSV
Post by: agridoc on August 21, 2007, 03:46:11 PM
ianus I see in the code of your page

<script language="JavaScript" type="text/javascript" src="http://www.firopolis.de/forum/Themes/default/ownsorttable.js"></script>

I don't know where this comes from, maybe interfering with sorttable.js?

You can see a big table working example in
http://www.aeromodelling.gr/ForumS/index.php?topic=986.msg7253#msg7253

You can try the mod as a guest in http://www.aeromodelling.gr/ForumS/index.php?language=english&topic=44.0
Add reply.
Title: Re: Table From CSV
Post by: ianus on August 22, 2007, 05:07:19 AM
Greetings!

Thanks for your answer!

I have a bookmark to
http://www.aeromodelling.gr/ForumS/index.php/topic,250.0.html
One of the best examples for this mod in use imho.

After I noticed the problems with the new Version the first way lead me to your board and after that I have a sleepless night.

The js you have found in my source offers the same like the one from anguz, but the code is different. But you are right, this could cause the problem – but unfortunately not.
(I deleted the code and the file to be sure.)

I installed a second SMF to do some experiments and there the mod is working flawlessly.
So I think I have some flawed code elsewhere and I search for faults already.

Thanks for your attention.


To make my position clear again. I never ever noticed problems with Anguz mods before and the examples in the aeromodelling – board are a perfect demonstration for the function.
Title: Re: Table From CSV
Post by: agridoc on August 22, 2007, 01:27:59 PM
ianus, Anguz wants to know possible bugs or, more probably, possible conflicts with other mods.

There are quite a few mods for SMF, adding many of them may produce conflicts in code, making them or SMF not working properly.

More experienced users may add some extra code, themes vary in code, so wide use might  show some problems, in specific cases, that may be overcomed with a change of code in the mod or in combination with other mods.

P.S. Thank you for your comments on my board, it's true that, because of the nature of the interest, makes sometimes an extensive use of Table From CSV mod.

It also works perfectly in combination with Tiny Portal (http://www.tinyportal.net/) in blocks and articles.
Title: Re: Table From CSV
Post by: agridoc on September 15, 2007, 03:12:34 AM
Good news for this excellent mod by Anguz, the code is compatible with SMF 2.0 beta 1   8)

Package install of the current version for SMF 1.1.3 will inform you that the installation failed for index.template.php. I proceeded and did the code add in index.template.php manually. It works perfectly.

The install code for 1.1.3 in TableFromCsv1-30.mod is
Quote<edit file>
$themedir/index.template.php
</edit file>

<search for>
   <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/script.js?fin11"></script>
</search for>

<add after>
   <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/sorttable.js"></script>
</add after>

this for SMF 2.0 Beta 1 should change to
Quote<edit file>
$themedir/index.template.php
</edit file>

<search for>
   <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?rc2p"></script>
</search for>

<add after>
   <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/sorttable.js"></script>
</add after>

SMF 2.0 Beta 1 is available now only for Charter members. Anguz will decide when he will release a new version of Table from CSV.

Until then, Charter members that have access to SMF 2.0 Beta 1 and want a test can either install the existing version and add the changes to index.template.php manually or unzip the mod, edit TableFromCsv1-30.mod, rezip and install from the modified mod file.

Don't do this unless you know what you are doing and use it at your own risk.

I don't use the Beta in any working SMF site but it's good to know about this compatibility.

Many thanks again to Anguz for this excellent mod.  ;)
Title: Re: Table From CSV
Post by: rjscott on September 28, 2007, 08:15:05 AM
I just "found" this fantastic mod and it will really be useful on my forum.
Quick questions-
1. Should there be an icon in the editor for this or does the user use the default table button and then add the = into the tag?
2. I added csv (MS-DOS) content between the tags and the resulting data line up properly however there are no background colors visible. Any ideas for me to start investigating?
3. On one csv the sorting works, on another, only the first 2 column headers will sort and clicking on the others simply reloads the page. My first guess is that something in the csv is odd but I don't know where to start looking. Any suggestions?
Title: Re: Table From CSV
Post by: agridoc on September 28, 2007, 09:21:25 AM
1. There is no special icon, as said, use the table icon and add the =(optional separator).

2 and 3. I have large tables in my site and they work OK. If you use another theme check the changes you might have done manually. Background colors and sorting need changes in index.template.php and style.css of the theme.

Title: Re: Table From CSV
Post by: rjscott on September 28, 2007, 10:02:32 AM
Quote from: agridoc on September 28, 2007, 09:21:25 AM
1. There is no special icon, as said, use the table icon and add the =(optional separator).

2 and 3. I have large tables in my site and they work OK. If you use another theme check the changes you might have done manually. Background colors and sorting need changes in index.template.php and style.css of the theme.
Agridoc- thanks for the information. I had a feeling that is due to template settings. I'm also using the JSMF bridge and picking up styles from the web site it's integrated with so who knows what's going on. ;-)
Title: Re: Table From CSV
Post by: Anguz on October 02, 2007, 01:42:30 AM
rjscott, would you provide a link to examples of tables where you're having trouble? Or have you fixed them already? Sorry for not noticing your post before.

agridoc, thank you for the help you provide to others with this mod. I really appreciate it.
Title: Re: Table From CSV
Post by: rjscott on October 02, 2007, 05:26:44 AM
Quote from: Anguz on October 02, 2007, 01:42:30 AM
rjscott, would you provide a link to examples of tables where you're having trouble? Or have you fixed them already? Sorry for not noticing your post before.

agridoc, thank you for the help you provide to others with this mod. I really appreciate it.
Oddly enough, it seems to have started working, all by itself... :quizical look:
I'm PM'in you with login information so you can take a look around because there is some "odd" behavior.
Title: Re: Table From CSV
Post by: agridoc on October 02, 2007, 08:12:29 AM
Thank you Anguz, it's the least I can do.  :)

I have used and tested the mod for quite some time, with many themes and SMF versions, so it's easy to test, I have many ready examples.
Title: Re: Table From CSV
Post by: Anguz on October 02, 2007, 09:53:19 PM
Quote from: rjscott on October 02, 2007, 05:26:44 AMOddly enough, it seems to have started working, all by itself... :quizical look:
I'm PM'in you with login information so you can take a look around because there is some "odd" behavior.

Got the login data. Sorry for replying by PM, I didn't check this topic first.

I don't see the tag parsed in the example you showed me. Did you uninstall the mod?
Title: Re: Table From CSV
Post by: Anguz on October 02, 2007, 09:53:32 PM
Quote from: agridoc on October 02, 2007, 08:12:29 AM
Thank you Anguz, it's the least I can do.  :)

I have used and tested the mod for quite some time, with many themes and SMF versions, so it's easy to test, I have many ready examples.

:)
Title: Re: Table From CSV
Post by: rjscott on October 03, 2007, 05:04:06 AM
Quote from: Anguz on October 02, 2007, 09:53:19 PM
Quote from: rjscott on October 02, 2007, 05:26:44 AMOddly enough, it seems to have started working, all by itself... :quizical look:
I'm PM'in you with login information so you can take a look around because there is some "odd" behavior.

Got the login data. Sorry for replying by PM, I didn't check this topic first.

I don't see the tag parsed in the example you showed me. Did you uninstall the mod?
Wow now really weird things are happening. My forum is now somehow at version 1.1.2 and all of my mods are "broken" too. What the heck could be going on?! It looks like at least on file is showing up when I try to uninstall any mods as not good: ./Sources/Subs.php
Title: Re: Table From CSV
Post by: Anguz on October 03, 2007, 07:58:12 AM
No idea... weird. Maybe something to do with Joomla?
Title: Re: Table From CSV
Post by: rjscott on October 03, 2007, 08:00:46 AM
Quote from: Anguz on October 03, 2007, 07:58:12 AM
No idea... weird. Maybe something to do with Joomla?
Possibly. I've got a post in the general board here. I backed up my entire /forums and then tried to reapply the SMF upgrade patch but received a bunch of "Test failed" errors...
Title: Re: Table From CSV
Post by: rjscott on October 03, 2007, 08:05:18 AM
Quote from: rjscott on October 03, 2007, 08:00:46 AM
Quote from: Anguz on October 03, 2007, 07:58:12 AM
No idea... weird. Maybe something to do with Joomla?
Possibly. I've got a post in the general board here. I backed up my entire /forums and then tried to reapply the SMF upgrade patch but received a bunch of "Test failed" errors...
Getting back on topic... Here are the results when I try to uninstall the csv mod:

Uninstall Actions "Table From CSV":
Installing this package will perform the following actions:
   Type    Action    Description
1.    Execute Modification    ./Sources/Subs.php    Test failed
2.    Execute Modification    ./Themes/default/index.template.php    Test successful
3.    Execute Modification    ./Themes/default/style.css    Test successful
4.    Delete File    ./Themes/default/sorttable.js

That ./Sources?subs.php test failure shows up in all the broken mods. I rolled this file back to my backup file from a few days ago and now all the mods are working again but the SMF version is still wrong. I'll continue this saga over at http://www.simplemachines.org/community/index.php?topic=198373.msg1261174#msg1261174
Title: Re: Table From CSV
Post by: Iomega0318 on October 04, 2007, 01:27:15 AM
wow after reading through all of this I am surprised I did not find an answer to the question I am about to ask lol..

I can't post smilies!
When trying to put a smiley into the table cell it just shows up as the text for the smiley instead of the picture does anyone know why? If so how can I get it to work because I would really like to add them in..
Title: Re: Table From CSV
Post by: agridoc on October 04, 2007, 02:09:09 AM
Smilies are properly parsed and displayed by the mod Iomega0318, except headers (first row).

But some smilies use the semicolon ;, so the mod parses it as separator.

You can use another separator, I use |. So the code should be
[table=|]
[/table]


And the contents separated by |.

You can see a working example of a CSV table with smilies here (http://www.aeromodelling.gr/ForumS/index.php?topic=44.msg34555#msg34555).
Title: Re: Table From CSV
Post by: Iomega0318 on October 04, 2007, 02:11:30 AM
Hmm well they aren't in the header but they do use colons, ex. :smiley:

**EDIT**
Tried changing the separator and it still wouldn't work..
Title: Re: Table From CSV
Post by: agridoc on October 04, 2007, 03:51:59 AM
Have you tried | as separator?
Title: Re: Table From CSV
Post by: Iomega0318 on October 04, 2007, 05:25:41 AM
Yes that is what I tried as the separator and it still wouldn't show the smilies..
Title: Re: Table From CSV
Post by: agridoc on October 04, 2007, 05:49:06 AM
Could you try this code with copy paste and see if smilies appear in second row?
[table=|]
1|2|3
:)| ;)| :D
[/table]


Are you using UTF-8? I don't think it matters and I believe that I have tested the mod with UTF-8, not with smilies however.
Title: Re: Table From CSV
Post by: Iomega0318 on October 04, 2007, 04:51:28 PM
Yes that worked fine and yes my board uses UTF-8

I just got them to work though, with regular smilies ex :) you do not need a space after it, apparently with my smilies ex :smiley: there needs to be a space.. ex. :smiley: blah, old ex. :smiley:blah (see the difference? no space) so all is good now, thank you for your help though..
Title: Re: Table From CSV
Post by: agridoc on October 04, 2007, 05:06:58 PM
Good, I expected that UTF-8 was not a problem  ;)
Title: Re: Table From CSV
Post by: agridoc on October 07, 2007, 02:27:15 AM
Quote from: rjscott on September 28, 2007, 08:15:05 AM3. On one csv the sorting works, on another, only the first 2 column headers will sort and clicking on the others simply reloads the page. My first guess is that something in the csv is odd but I don't know where to start looking. Any suggestions?

I had a message in my forum with 54 thumbnails and links from Photobucket in a very looong message, so I arranged them in a CSV table.

Sorting is not needed in such a table but I clicked on the header of the last column and ... the browser went on page top. That reminded me of rjscott' s message.

The answer was simple. I had two empty cells in the last row. After adding two separators, column sorting was OK. It's not necessary to have some content, just the separator declaring that there is a cell after.

Sorting will not work if the column has empty cells.

I don't know if Anguz will have the will and time to make and add an error trapping routine for empty cells in the sorting script. The mod is quite useful and functional as it is. Options to use or not headers and sorting would be more beneficial for the mod, if added.
Title: Re: Table From CSV
Post by: Anguz on October 08, 2007, 10:34:17 PM
Thanks for the feedback, agridoc.

I won't change the javascript, I don't know the language and didn't write the script in this mod.

I have thought of making the headers and sorting optional, but couldn't think of a tag format for those variables that wouldn't be more complicated, like:

[table headers=no separator=|]

If I keep using the current format, anything placed after the = is the separator, and before it is the tag name, so there's no way of adding more variables. Unless I picked certain symbols that won't be parsed as separators, but as modifiers, like * meaning no headers, or something of the sort:

[table=*|]

Sorting could be left if headers are used and is not there if headers aren't, so that wouldn't need to be specified.

Thoughts?
Title: Re: Table From CSV
Post by: SONSiVRi on November 21, 2007, 12:50:32 PM
I have installed on 1.1.4 and it works without problem.
But theme is a little bit tricky, default directories didnt work on me.
For "Dilber Multicolor" I used this configuration:

/Sources/Subs.php (same)
/Themes/dilbermc-rc3/index.template.php
/Themes/dilbermc-rc3/style.css
/Themes/default/sorttable.js (same)
Title: Re: Table From CSV
Post by: Garry on April 07, 2008, 07:03:05 PM
Anguz

Thanks for your Mod  I hope you are set up to get emails when someone posts to this thread

I installed your mod in version 1.14 and it works fine

Then I went to the new ver 1 TP where you can now use BBC and I copied the code into an article and it worked ok as for building the Table

But the sorting feature doesn't work

which really doesn't surprise me

-------------------------------------------------------------------

I am just curious as to whether  you would be interested in seeing if you could bet it to work in the articles as that would be a tremendous function if you could sort in and article.


Its a great function as it is in an article   but sorting word make it greater

Title: Re: Table From CSV
Post by: agridoc on April 08, 2008, 10:07:08 AM
Hello Gary

I use Anguz's Table from CSV mod and I am TP Language Team member.

Table From CSV works well in SMF 1.1.x and I have tested with SMF 2.0 beta 1 too http://www.simplemachines.org/community/index.php?topic=18917.msg1241133#msg1241133

TinyPortal v1.0.5 beta (http://www.tinyportal.net/index.php?topic=23014.0) 1 was just announced 3 days ago as the first public beta version and as Bloc wrote
QuoteNote that it is still beta software and as such are bound to have some errors yet.

I can't say it's a TP bug but BBC articles is a new feature and as such it's more probable to have some small bugs.

You can report in TP or wait a more stable TP 1.0.x release to check with.

ADDITION: Tested OK
Quote from: agridoc on April 09, 2008, 05:19:19 AM
I tried Table From CSV in TP BBC articles with simple amd complex tables. Both display and sorting work OK.
Title: Re: Table From CSV
Post by: Garry on April 08, 2008, 10:52:18 AM
Thanks for the come back agridoc

I recognize that Bloc just released it and that is why I worded my post the way I did

QuoteI am just curious as to whether  you would be interested in seeing if you could bet it to work in the articles as that would be a tremendous function if you could sort in and article.

It actully works in TP as a BBC function to create the Table

Its the Javascript portion that isnt working there which is totally understandable

The new TP has unleashed a temendous range of posibilities especilly with the abillity for the average user to use BBC and make a pretty page with out having to know any HTML

I am just playing at the moment and finding out which BBC mods work in the TP BBC area

so far the user_name function works  but it doesnt show the button for it  but if you use the bbc it works fine

and the csv to table works  but the sorting area doesnt


so once again  thanks for the come back

Ill keep playing to see what works and what doesnt

so far I have tried those two mods  and they are at least trying to work 




Title: Re: Table From CSV
Post by: agridoc on April 09, 2008, 05:19:19 AM
I did a test install with SMF 1.1.4 and TinyPortal v1.0.5 beta  (http://www.tinyportal.net/index.php?topic=23014.0).

I tried Table From CSV in TP BBC articles with simple amd complex tables. Both display and sorting work OK.

If you used the version that was given with the April fool (not checked with this subversion) announcement, uninstall it and use the latest.
Title: Re: Table From CSV
Post by: ianus on April 09, 2008, 05:21:25 AM
Greetings!

I can confirm that. I have installed SMF1.1.4 and TP v1.0.5 beta 1 – just for testing.
This is not my live-site and the link will not stay forever. Also, what you see is absolute unperfect and some own scrips causes errors.

But the (brilliant!) table mod will work with the new TP Version and the tables are sortable inside an bbc-article.
Have a look at

example deleted - sorry for that, but it was a testing enviroment only




Title: Re: Table From CSV
Post by: agridoc on April 09, 2008, 05:35:42 AM
Thank you ianus  ;)

I can't give a link but my test included a "copy paste" code from my working forum for a table with 9 columns (with either text or numbers) and 42 rows.
Title: Re: Table From CSV
Post by: Butcher on September 10, 2008, 01:12:51 PM
Very nice mod Anguz thanks,

I have some prob with the table on how it looks like

what should i change so the fonts, bgcolor etc of the table don't have styles from: body, a:hover, but only from the .sortarrow, .csvtable td, .sortbg1 td, .sortbg2 td, .sortable th ?
Title: Re: Table From CSV
Post by: ianus on September 10, 2008, 07:01:05 PM
Greetings!

It seems that you have found the correct entries in the style.css already.
So I don't understand your problem exactly.

Imho you can add all definitions which fit your needs.
A small example..

.sortbg1 td
{
color: green;
background-color: #FFF;
}


I you use a custom theme, you have to add the sortable definitions to the style.css of your theme.
Title: Re: Table From CSV
Post by: Butcher on September 11, 2008, 12:44:47 PM
ok, let me put it this way. as u can u see i found what to change but it doesn't work.

background-color: some_color; don't work
background: url(some_image.gif); work

color: some_color; work but when the scripts loads the font colors are as the a:link, a:hover option.

Title: Re: Table From CSV
Post by: ianus on September 12, 2008, 05:37:45 AM
Greetings!

Well, it seems that CSS could be black magic.


background: url(some_image.gif); work
The url definition is working, because there is no other url definiton for "background".
(Try to set an url background for the main table.
Find: /* By default (td, body..) use verdana in black.*/
Add:  background: url(images/ some_image.gif);
The image of the .sortable should behave like the background-color, it will be overwritten.

background-color: some_color; don't work
This isn't working, because there is (at least) one other definition.

Question:
Why the extra ".sorttable" is ignored and the other td definition shows up instead?

Answers (maybe, maybe not):
1.: If you have a second css file.
(I use to have a custom script running, which comes with it's own .css.
Both, the smf.css and the script.css are called in the index.template.php.
Originally the script.css use .script a{} but it was overwritten by the smf.css, even with the extra .script.)
- If you have a second css with td definitions, try to disable it temporary.

2.: First don't come first.
- Make sure the .sortable td is at the very last position in your style.css


This is the css part.
I'm very sure that it is possible to change the style of the sorttables.
I have just set up a new SMF with the tables mod and changed some colors.
This is only for testing and I will delete it again. But till then you can have a look at the colorful tables:
http://www.firopolis.de/smf/index.php?topic=3.0


The php/html part could cause this behavior also.
I this case, it is nearly impossible to give an answer.
Maybe there is a missing </td>, maybe there is a missing </div>, maybe ...


If you like, you can attach your style.css.
I'm not at home this weekend, but I can spend some time the next week.
Title: Re: Table From CSV
Post by: Abadd0n on January 05, 2009, 08:39:15 AM
Original 1.3 isn't comportable with SMF 2.0 beta 4, and looks like author doesn't support this mod anymore, so this is modified version. Works with 2.0, probably with 1.x, but not tested.

Changes:
tag now is [ctable=] because tag [ table ] already exist
default separator is ; because it is more common for csv (just IMO)

http://custom.simplemachines.org/mods/index.php?mod=1583
Title: Re: Table From CSV
Post by: TerryMullins on January 05, 2009, 12:14:35 PM
Abadd0n,

I tried to download this using the link that you provided.
When I clicked on the link, I got a message that the file isn't ready for download.

I think that it could be helpful with the problem that I am working on...
http://www.simplemachines.org/community/index.php?topic=284090.msg1864951#msg1864951

Thank you,
Terry Mullins
Title: Re: Table From CSV
Post by: Anguz on January 06, 2009, 03:58:33 PM
Quote from: Abadd0n on January 05, 2009, 08:39:15 AM
Original 1.3 isn't comportable with SMF 2.0 beta 4, and looks like author doesn't support this mod anymore, so this is modified version. Works with 2.0, probably with 1.x, but not tested.

Changes:
tag now is [ctable=] because tag [ table ] already exist
default separator is ; because it is more common for csv (just IMO)

http://custom.simplemachines.org/mods/index.php?mod=1583

You're quite bad mannered. I didn't give you permission to use my code, much less to claim it yours. If you want to write your own mod, then go ahead, don't use mine. Don't assume that I don't support it, I just haven't seen the need for support for this mod lately. When a problem arised, usually the same or other users found the solution before I had to do it. An update to the latest SMF version is planned when it reaches Final, not Betas, as was the case before. I would consider writing an update for an earlier release if I see many asking politely, but I didn't expect to have someone do what you did. Others have, with other mods, offered to update the code to a version of SMF they were using, but asked for permission first. Please remove your post from here and the Mod Site.
Title: Re: Table From CSV
Post by: ianus on January 06, 2009, 04:56:05 PM
Greetings!

Thanks a lot for your reply!
I have written nearly the same some hours ago, but I was sure that you will answer.
After my experience with the last big SMF update, I never lost the trust that you will be here at the right time.
So I decided to wait a little bit to let you take the lead and completely agree with your post.

In addition, this mod works perfect with the SMF2b4. My board depend on this beautiful mod in large parts and I tried to use it in a test environment. Only a small change is necessary to make the magic happen.

Sounds like I am a fan-boy? Well yes!
Title: Re: Table From CSV
Post by: Anguz on January 06, 2009, 05:55:09 PM
Quote from: ianus on January 06, 2009, 04:56:05 PM
Greetings!

Thanks a lot for your reply!
I have written nearly the same some hours ago, but I was sure that you will answer.
After my experience with the last big SMF update, I never lost the trust that you will be here at the right time.
So I decided to wait a little bit to let you take the lead and completely agree with your post.

In addition, this mod works perfect with the SMF2b4. My board depend on this beautiful mod in large parts and I tried to use it in a test environment. Only a small change is necessary to make the magic happen.

Sounds like I am a fan-boy? Well yes!


Thanks a lot. I really appreciate the support. It's messages like this one that make me want to keep working on  these things. I'm really glad you find this mod so useful, that was my whole intention when I coded it. Hopefully SMF 2 Final will come soon. :)
Title: Re: Table From CSV
Post by: agridoc on January 06, 2009, 06:42:39 PM
As I had tested with early versions (http://www.simplemachines.org/community/index.php?topic=18917.msg1241133#msg1241133), I thought that  Table From CSV 1.30 worked with SMF 2.0.

After the last messages I did a test, as Ianus reported, it works somehow but needs a little work.

Speaking of mod upgrades, an upgrade should keep working with old posts depending on the mod.

I also waited for Anguz's response, he is just idling, he will open the throttle when needed  ;D
Title: Re: Table From CSV
Post by: sheryltoo on January 06, 2009, 08:54:41 PM
I tried to install this mod on 1.1.7 yesterday but I don't think it's working. Do I need to make any changes to make it work in 1.1.7 or should I have not installed it?
Thanks for any help on this.
Sheryl
Title: Re: Table From CSV
Post by: agridoc on January 07, 2009, 12:31:46 AM
sheryltoo version 1.30 installs and works properly in 1.1.7.

Try this in your forum.
[table=|]A|B|C
1|2|3
4|5|6[/table]


If you use another theme as default, some manual adding of code will be necessary for display and sorting. Main code will work.
Title: Re: Table From CSV
Post by: ianus on January 07, 2009, 03:35:16 AM
Greetings!

Welcome agridoc! Always a pleasure to read your posts.

@sheryltoo
As Agridoc stated, this mod will work in a SMF1.1.7 and you can use it without a doubt.
His code example is perfect to run a test.
But I you need further help, please explain your problems a little bit more detailed. I'm sure we will find a solution.

Quote
Speaking of mod upgrades, an upgrade should keep working with old posts depending on the mod.
I use an own tag to show the tables since the mod is compatible for 1.1.x. So I only change the original "table" to "csv" and I'm done. It seems to me, that the new parser won't accept the "table" anymore, but my knowledge of writing code is awfully bad.
Title: Re: Table From CSV
Post by: sheryltoo on January 07, 2009, 08:31:21 AM
I copied that code into a message at my site and it displayed a table only how do I insert those tags using my forum's task bar?
The only table icon brings up the standard table with tr and td.
How do I get that straight line after table=
I don't see any way to use a table other then the standard way which is why I was thinking it's not working right.
Maybe I'm missing something.
Also, in reading over all the messages in this thread, am I to understand that you could put a background image using an url, inside a table in a message?
If so, how would you code that?
Sheryl
Title: Re: Table From CSV
Post by: agridoc on January 07, 2009, 01:31:04 PM
sheryltoo I used | as separator.

CSV (Comma Separated Values) is a form for storing data. Ususally comma , is used as separator for American systems, semicolon ; for european.

The tag in Table from CSV is simple

[table=][table]

If no other separator is added after table= the separator defaults to comma. Example with a table

[table=]A,B,C
1,2,3
4,5,6[/table]


Table From CSV is of little use for small tables.

It's value shows with big tables (results, catalogs etc.)

In these cases data is exported to a CSV file and the contents are added between the tags.
Title: Re: Table From CSV
Post by: ianus on January 08, 2009, 03:04:09 AM
agridoc is right. Credits for this useful clarification.

After using this mod for years now, I quit to build a own button for it. But at the very beginning, I like to have one and I have written a small how-to on the german support board.
Now, this is the quick translation - for SMF 1.1.x

First, you have to create an image for the button. Look at /themes/default/images/bbc for exampels to get the neccessary heigt and weight of the image. Your own image has to go there also.

Next:
(Backup first!)
In Themes/default/post.template.php
Search:
$context['bbc_tags'] = array();

Add: (where the button should appear)
'table' => array('code' => 'table', 'before' => '[table=]', 'after' => '[/table]', 'description' => $txt['table']),

Example:
array(),
'table' => array('code' => 'table', 'before' => '[table=]', 'after' => '[/table]', 'description' => $txt['table']),
'table' => array('code' => 'table', 'before' => '[table]', 'after' => '[/table]', 'description' => $txt[436]),
'tr' => array('code' => 'td', 'before' => '[tr]', 'after' => '[/tr]', 'description' => $txt[449]),
'td' => array('code' => 'td', 'before' => '[td]', 'after' => '[/td]', 'description' => $txt[437]),
array(),


You have to edit each custom theme which has its own post.template.php

If you want to have the hover text also.
Open modifications.english.php
and add
$txt['table'] = 'CSV Table';

You can change the hover text of course and If you used to have another language installed, you have to edit the coresponding language file also.

A button is attached. I made it years ago and you can use it if you like.

Notes:
The given code will not include an separator automatically. Can be done, but maybe your user want to use different separators.
You have to edit the SMF source.
Because of this, I recommend to follow agridoc's hint and use the existing table button and add a = and the separator while posting.

For the background images.
You can edit your style.css to add things like this. But I do not recommend to add an image.
It will slow down things if you include a big table and use an image for each field.
Use a color definition and you will be fine.
Of course you can insert an image as a table data, or include spoiler-code, list-code, whatever.
But it is recommended to fill out every table-field. If you have noting to show, use a . or – or something.

Example:
(bad code, Number 6 is missing and field is empty)
[table=|]A|B|C
1|2|3
4|5|
(good code, Number 6 is missing but – is used instead)
[table=|]A|B|C
1|2|3
4|5|-
Table in action:
(With images)
http://www.firopolis.de/forum/index.php/topic,2394.0.html (http://www.firopolis.de/forum/index.php/topic,2394.0.html)
(With some lists)
http://www.firopolis.de/forum/index.php/topic,1372.0.html (http://www.firopolis.de/forum/index.php/topic,1372.0.html)[/hr]
Title: Re: Table From CSV
Post by: sheryltoo on January 08, 2009, 08:07:51 AM
I think this all might be over my head but I appreciate you both trying to help me out.
I belonged to a group that allowed you to use tables to make bordered backgrounds using images and then post text inside the backgrounds.
It was a way to dress up a message but it doesn't sound as if this table code works that same way. Nor does it sound like I should use a feature that lets you do this since it can slow things down.
At the moment I don't really have any need to set up some type of a table with various data but if I do, where do I find that straight line separator?
I don't see it on my keyboard.
Sheryl
Title: Re: Table From CSV
Post by: agridoc on January 08, 2009, 08:38:54 AM
You will find it in your keyboard not exactly as a straight line but as two small lines with a little space in the middle. But this is a separator I used in an example.

The separator can be any character, provided that it is not used in data. Comma is not a proper choice for my language,  Greek, as it is used in decimals, i.e. 4,25, not 4.25. Semicolon ; is usually OK.

You can alter the Table from CSV part in style.css to customize display. I don't believe that some small graphic for background will slow down SMF but I don;t think it will make big difference.

SMF is very strong in table creation. It has it's own capabilities, Table from CSV and, of course, HTML for administrators.
Title: Re: Table From CSV
Post by: sheryltoo on January 08, 2009, 09:55:04 AM
I think I finally found that separator key.  | Thanks for tell me what to look for and thanks for telling me about customizing style.css.
I probably won't do that since I'm not good at style sheets or html. I usually need a book in front of me when I'm trying to use css or html and then don't always understand what I'm looking at or have to do.
Sheryl
Title: Re: Table From CSV
Post by: Anguz on January 10, 2009, 02:06:31 AM
Thank you very, very much for your help with the mod's support, guys. I'm really sorry I can't be around all the time nowadays, but I feel better knowing you're here.

sheryltoo, I'm glad you could sort it out with their help.

When I realease the next update of the mod, I may include a button for the mod, which should make it simpler for some.
Title: Re: Table From CSV
Post by: jayc7176 on January 10, 2009, 07:20:32 AM
Very Nice Mod! - Thanks Mate !
Title: Re: Table From CSV
Post by: Abadd0n on January 10, 2009, 12:01:32 PM
Quote from: Anguz on January 06, 2009, 03:58:33 PMYou're quite bad mannered. I didn't give you permission to use my code, much less to claim it yours. If you want to write your own mod, then go ahead, don't use mine. Don't assume that I don't support it, I just haven't seen the need for support for this mod lately. When a problem arised, usually the same or other users found the solution before I had to do it. An update to the latest SMF version is planned when it reaches Final, not Betas, as was the case before. I would consider writing an update for an earlier release if I see many asking politely, but I didn't expect to have someone do what you did. Others have, with other mods, offered to update the code to a version of SMF they were using, but asked for permission first. Please remove your post from here and the Mod Site.
As you wish.
Title: Re: Table From CSV
Post by: Biker666 on January 17, 2009, 10:04:59 PM
A big (http://users.telenet.be/bikerben/smileys/smiley17.gif) from me.
If you where a girl, i kissed you for this mod. Before i spend hours to fix tables for our forum.
Now it's done in minutes.

I still got 1 question. Is it possible to have colors in the header of table?
In the normale table, it was allowed to use  the color= code.

i use SMF 1.1.7. installed it with the manager. it didn't worked for me.
So i edited Index.template.php - ./default/style.css in my theme and copied the sorttable.js into my theme.
And it works.
Title: Re: Table From CSV
Post by: ianus on January 18, 2009, 02:48:54 PM
Greetings!

It's possible to edit the general settings of the table-header with custom entries inside the style.css.

The original code:
.sortbg2 td, .sortable th
{
background-color: #E1E1E1;
}


Delete this:
, .sortable th

And make a new entry, example:
.sortable th
{
color:#000;
background-color: #fff;
}


It's not possible to edit the header in a post directly. You can use bb-code for the table data, but not for the headlines.
Title: Re: Table From CSV
Post by: JackWise on March 08, 2009, 08:23:20 PM
Hi,
I installed this mod in SMF1.1.8 and it's fine.

I had to install manually index.template.php in default theme and current theme.
I also had to copy the *.js to current theme.

Now it´s everything fine.

Many thanks.

JW
Title: Re: Table From CSV
Post by: drav on August 31, 2009, 12:28:06 PM
Hi

Does anyone know if this mod will be made compatible with 2.0RC1.2?
Title: Re: Table From CSV
Post by: Kindred on August 31, 2009, 08:25:02 PM
most definitely not...
Title: Re: Table From CSV
Post by: agridoc on September 01, 2009, 12:17:19 AM
I would say most definitely yes and it really deserves it. Anguz will probably be interested when 2.0 is near first final version. There are also quite a few users that love this mod and will help with upgrading.
Title: Re: Table From CSV
Post by: ianus on September 01, 2009, 01:10:16 AM
I'm with agridoc

See:
Quote from: Anguz on January 06, 2009, 03:58:33 PM
Don't assume that I don't support it, I just haven't seen the need for support for this mod lately. When a problem arised, usually the same or other users found the solution before I had to do it. An update to the latest SMF version is planned when it reaches Final, not Betas, as was the case before. I would consider writing an update for an earlier release if I see many asking politely, but I didn't expect to have someone do what you did.

I have also managed to use this mod with SMF2RC1. Only some minor changes are necessary.
I don't know how much have changed meanwhile or will be changed for the SMF2final. But as far as I can see, the basic source for bb-code seem to have the same structure in v.1 and v.2. The rest is done by a fine js file and so I'm quite sure, that this mod will work with upcoming SMF versions.
Title: Re: Table From CSV
Post by: zushiba on December 17, 2009, 03:37:59 AM
Quote from: ianus on September 01, 2009, 01:10:16 AM
I'm with agridoc

See:
Quote from: Anguz on January 06, 2009, 03:58:33 PM
Don't assume that I don't support it, I just haven't seen the need for support for this mod lately. When a problem arised, usually the same or other users found the solution before I had to do it. An update to the latest SMF version is planned when it reaches Final, not Betas, as was the case before. I would consider writing an update for an earlier release if I see many asking politely, but I didn't expect to have someone do what you did.

I have also managed to use this mod with SMF2RC1. Only some minor changes are necessary.
I don't know how much have changed meanwhile or will be changed for the SMF2final. But as far as I can see, the basic source for bb-code seem to have the same structure in v.1 and v.2. The rest is done by a fine js file and so I'm quite sure, that this mod will work with upcoming SMF versions.


Care to share what you have for making this function with 2.0? I'd love to update this. I'll mess around with it tomorrow but if you've got any code to share that would speed up the process it'd be very welcome.
Title: Re: Table From CSV
Post by: ianus on December 19, 2009, 11:34:53 AM
Greetings!

Of course, and it's easy. But first I must mention, that this is not an replacement for the mod or the work of Anguz. I only use his code and put it manually into the propper places.

You can just open the parser for this mod and you will see how to manually install it for 1.1.3

In SMF2rc Subs.php you will find // This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line. also.
Just add the code above this line just after the );

In index.template.php find <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?rc2"></script>
Add the mod-code after that line.

The style.css is now called index.css
Add the mod code whereever you like.

Now you have to download and extract the mod. Copy the sorttable.js and past it into your webfolder.

Well done, enjoy.




Edit:

Personally I have edited the tag itself. Now I create the sorttables with [csv=|] and not with table. Imho my tag is more unique.

You have to change in Subs.php:
// Table From CSV
$codes[] = array(
'tag' => 'table',

to
// Table From CSV
$codes[] = array(
'tag' => 'csv',


With this in mind... add a button in SMF2

First: Create an image for the button. (Name it csv.gif)
Feel free to use the one linked here: Re: Table From CSV (http://www.simplemachines.org/community/index.php?topic=18917.msg1869861#msg1869861)

Second: Copy the image to
/Themes/default/images/bbc
or
/Themes/your custom Theme/images/bbc

Third: Edit Source

Don't forget to Backup!!

Open: Sources/Subs-Editor.php
Find: // The below array makes it dead easy to add images to this control. Add it to the array and everything else is done for you!

Choose where your button should appear and add
array(
'image' => 'csv',
'code' => 'csv',
'before' => '[csv=|]\n\n',
'after' => '[/csv]',
),




It should be obvious, but I have to mention it again.
This mod from Anguz is one of the most usefull mods ever!
Title: Re: Table From CSV
Post by: Rasyr on February 21, 2010, 10:10:19 AM
Has anybody take the suggestions for this mod (for using it with SMF 2 RC2) and made it into a specific package for easy installing??

I know several people on my forums who would love it!!

Title: Re: Table From CSV
Post by: kangkenyot on April 21, 2010, 11:37:42 AM
I have same question :)

Quote from: Rasyr on February 21, 2010, 10:10:19 AM
Has anybody take the suggestions for this mod (for using it with SMF 2 RC2) and made it into a specific package for easy installing??

Title: Re: Table From CSV
Post by: wintermoon on June 14, 2011, 11:21:14 PM
i third this :(

please make a easy to install/uninstall package <33
Title: Re: Table From CSV
Post by: agridoc on June 15, 2011, 12:45:01 AM
The package is like others and works OK.

What is awaited is a version for SMF 2.0.
Title: Re: Table From CSV
Post by: wintermoon on June 15, 2011, 02:52:10 AM
yah that's what i mean :)
Title: Re: Table From CSV
Post by: LeYoyo on January 10, 2012, 08:42:22 AM
Still no SMF v2.0 version available ?
Title: Re: Table From CSV
Post by: abraamz on April 08, 2012, 05:19:17 AM
I have manually added this mod to smf 2.0.2 succesfully with the instructions in the message linked below
http://www.simplemachines.org/community/index.php?topic=18917.msg2412038#msg2412038
It is located in the previous page.

I had to search in the index.template.php for this code
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?fin20"></script>
and add the mods code below that line like this:
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sorttable.js"></script>
you have to upload the sorttable.js file to Themes/default/scripts

edit***
i found some errors. you have to add a description for the new button if you choose to make one to use with [csv=|]
Quote from: ianus on December 19, 2009, 11:34:53 AM

Open: Sources/Subs-Editor.php
Find: // The below array makes it dead easy to add images to this control. Add it to the array and everything else is done for you!

Choose where your button should appear and add
array(
'image' => 'csv',
'code' => 'csv',
'before' => '[csv=|]\n\n',
'after' => '[/csv]',
),




the above code should be
array(
'image' => 'csv',
'code' => 'csv',
'before' => '[csv=|]\n\n',
'after' => '[/csv]',
                                'description' => $txt['csv']
),


and you should add a text entry into file Post.English.php
find this
$txt['table'] = 'Insert Table';

add below this

$txt['csv'] = 'Insert Table from csv';
Title: Re: Table From CSV
Post by: danielwmoore on December 01, 2013, 03:41:42 PM
This is a mod that has been a HUGE headache saver for me. I frequently do tables, and this makes it easier than any other way I've ever done it.

However, it is a pain to implement on SMF 2 with all the changes and all. I have, therefore, recreated this same mod for SMF 2.0. It's not my code, but I have used the original mod, made the appropriate changes as noted on the last 3 pages of this thread, and placed it into a new XML package for SMF 2.0.

I have installed it on SMF 2.0.6, and it worked flawlessly.

I even added the "button" to insert the CSV table automatically with the posts. I also renamed the tag from 'table' to 'csv', as per ianus's suggestion. Thought that was a good idea.

That means the tag is CSV, not TABLE!

I included both PNG and GIF images for the button, since most people seem to use GIF, but many also have converted to PNG as I have. PNG is much smoother, but in this case it is just a "copy" of the GIF in order for it to work as a PNG on your setup. You can remove whichever one you don't use.

One thing I also did was remove all the CSS changes, as I didn't really see the need of setting up a whole new CSS that really only works with the SMF 1 default theme. The bright backgrounds really clashed on my dark themes on my forum. So instead, it borrows the colors from the standard 'table' bbc tag. All formatting will be like you used the 'table' tags, however your theme displays it.
Title: Re: Table From CSV
Post by: Arantor on December 01, 2013, 03:46:08 PM
Unfortunately, we can't let you distribute it without permission from the author - it's not given an open source licence and one cannot just be assumed. Sucks but for everyone's safety that's what we have to do :(
Title: Re: Table From CSV
Post by: danielwmoore on December 01, 2013, 08:47:09 PM
Thanks for the quick reply on that, even if it isn't the news I wanted to hear. Always best to keep it straight.

I have obtained the original author's email address, and will send him an email attaching the mod. Perhaps he will be willing to return and publish it himself. I would have sent a PM, but I'm not sure if he still checks the forums.

If he doesn't return, then the community will have to do without. It certainly is a shame, though, as I think this mod would be ideally suited to be part of the core of SMF itself. It just makes tables too easy.
Title: Re: Table From CSV
Post by: Arantor on December 01, 2013, 08:54:26 PM
If the original author gets in touch here, or send a PM to the 1 (http://www.simplemachines.org/community/index.php?action=profile;u=221071) account, we can take it further.

The problem with using a CSV entry is what happens if you want to have a table cell with a , in it. I know the times I've used tables, this has been an issue for me.

If it were core, it would likely get rewritten anyway and the licence problem would go away - I know a better form of table code in the core would be advantageous, especially if it means we can come up with a less insane way of handling the sanitisation aspect (but don't forget, we still have to deal with people upgrading who have the old style tables)
Title: Re: Table From CSV
Post by: danielwmoore on December 02, 2013, 05:07:31 AM
Quote from: Arantor Beeblebrox the First on December 01, 2013, 08:54:26 PM
The problem with using a CSV entry is what happens if you want to have a table cell with a , in it. I know the times I've used tables, this has been an issue for me.

That's what was so great about this mod. By using [CSV=|], it would use "|" as the delimiter. You can use whatever you want as a delimiter. Of course, a real CSV file would put quotes around an entry that contains a comma, and just not display the quotes. It's a way of allowing commas without a comma being a delimiter. This can't handle quoted entries. Real CSV handling, though, would be a much more complex code base, which would slow things down too much. However, it would enable a user to create a table using Excel or some other spreadsheet, save it as CSV, then paste it into a post. Just a thought, but perhaps I think too much sometimes. :)

It would be nice for it to be smart enough to handle "empty" cells, like:
1,2,3
4,,6
7,8,
10,11,12

But it doesn't. You have to supply something, even if it's just a dash or dot.

Since the tag is CSV=, old style tables can still be used as well. Not a replacement of the core really, but an addition to the core.
Title: Re: Table From CSV
Post by: tfs on December 02, 2013, 02:39:32 PM
Just an FYI re semantics of separators and delimiters.

CSV = Comma SEPARATED values.  The comma is the separator and the quotes are the delimiters.

Title: Re: Table From CSV
Post by: danielwmoore on December 02, 2013, 03:07:45 PM
@tfs: I stand corrected. You are right.

Having a rough week, with my 1 year old having bronchitis and on a breathing machine 4 times a day, I haven't slept in days. My brain is more feeble than usual. ;)
Title: Re: Table From CSV
Post by: tfs on December 03, 2013, 09:30:55 AM
Prayers up for your tyke.  It's very hard to watch a small child suffer through medical troubles.  Best wishes for a full and speedy recovery.