Page 1 of 2

128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Fri Dec 14, 2007 10:29 pm
by thomasfedb
Hi ! I'm Thomas, 13 years old and have just learnt the ropes of php...  :D

Description of task: Implement all three of ApplestoOranges's CSS for Bar Graphs
implementations in a Joomla! v 1.5 plugin:

    # Basic CSS Bar Graph;
    # Complex CSS Bar Graph;
    # Vertical CSS Bar Graph.

So far this is the beginning of the code i am creating:

Code: Select all

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

$mainframe->registerEvent( 'onPrepareContent', 'plgProGraph' );

function plgProGraph( &$row, &$params, $page=0 ) {

	$plugin =& JPluginHelper::getPlugin('content', 'prograph');
	$pluginParams = new JParameter( $plugin->params );

	$gpattern = '/{graph="(.*)"}(.*){\/graph}/';        // Pattern for the graph syntax
	$bpattern = '/{bar="(.*)"}/';                       // Pattern for the individual bars
	
	// check whether plugin has been unpublished
	if ( PGIsEnabled($pluginParams) == 0 )
    {
        $disabletext = '' //Change to give option in bacckend for this message / formatting
		$row->text = preg_replace( $gpattern, $disabletext, $row->text );
	}
	
	// find all instances of plugin and put in $matches
	preg_match_all( $gpattern, $row->text, $plugins );

	// Number of plugins
	$pluginsnum = count( $plugins[0] );
	
	if ( !($pluginsnum == 0) )
	{
       for ( $loop=0; $loop < $pluginsnum; )
           $loop = $loop + 1;
           preg_match_all( $bpattern, $plugins[1][$loop], $bars );
           $barsnum = count( $bars[0] );
           if ( !($barsnum == 0))
           {
                $replace = PGSetupGrapg(
           
           


}

function PGIsEnabled( $params )
{
 if ( $params->get( 'enabled', 1 ) )
 {
    return 1;
 }
}

The php manual entries are very difficult for me to understand so it would be great if somebody would explain the output of this command:

Code: Select all

$gpattern = '/{graph="(.*)"}(.*){\/graph}/';        // Pattern for the graph syntax
preg_match_all( $gpattern, $row->text, $plugins );
The problem is that I'm asking it to return 2 values (one for the graph params & the bars...)
Would it give me a 3 dimensional array.

If nobody can answer this then i have thought out a way around it...


Also is there a way to place a logo in the module configuration panel?
Or put in tables or text formatting??

Thanks for any help
It's greatly appreciated

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Fri Dec 14, 2007 11:25 pm
by thomasfedb
This is my code to extract th params from the graph syntax:

Code: Select all

$gpattern[0] = 'type:(.*)\;';
     $gpattern[1] = 'borderc:(.*)\;';
     $gpattern[2] = 'borderw:(.*)\;';
     $gpattern[3] = 'backgroud:(.*)\;';
     $gpattern[4] = 'textsize:(.*)\;';
     $gpattern[5] = 'width:(.*)\;';
     
     // check to make sure we have a type
	preg_match_all( $gpattern[0], $params, $type );
	$havetype = count( $type[1] );
	if ( !($havetype == 1) )
	{
	return 0;
	} else {
	if ($type[1][0] == 1) { $graph[0] = 1; $graph[1] = $gparams['1borderc']; $graph[2] = $gparams['1borderw'];
     $graph[3] = $gparams['1background']; $grapg[4] = $gparams['1textsize']; $graph[5] = $gparams['1width']; }
    if ($type[1][0] == 2) { $graph[0] = 2; $graph[1] = $gparams['2borderc']; $graph[2] = $gparams['2borderw'];
     $graph[3] = $gparams['2background']; $grapg[4] = $gparams['2textsize']; $graph[5] = $gparams['2width']; }
    if ($type[1][0] == 3) { $graph[0] = 1; $graph[1] = $gparams['3borderc']; $graph[2] = $gparams['3borderw'];
     $graph[3] = $gparams['3background']; $grapg[4] = $gparams['3textsize']; $graph[5] = $gparams['3width']; }
    if ($type[1][0] == 0) { return 0; }
    for ( $loop=1; $loop <= 5; $loop++) {
    preg_match_all($gpattern[$loop],$params,$param);
    $isparam = count($param[1])
    if ($isparam == 1) {
    $graph[$loop] = $param[1][0];
    }

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Sat Dec 15, 2007 2:39 am
by thomasfedb
A bit of a problem with graph type 3...

The CSS at Applestoorranges dosn't actualy do what the picture shows.
This is because it uses images that i don't have..
Unfortuantly these images have text on them and i would hve to add them with html & css
There are a couple of options:
1) Make images but ommit text
2) Make images and mess arround with css to make the text apear..

I think i will go with option 2 but i won't do it untill i have coded the rest of my plugin. It will be quite low on the TODO...

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Sat Dec 15, 2007 4:41 am
by AmyStephen
Thomas -

You are blowing me away!  8)

Can you put this into a plugin and share the zip? Would love to see this in action! (Even as a work in progress.)

Thanks!
Amy :)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Sat Dec 15, 2007 11:32 pm
by thomasfedb
Dear Amy, of course i can make a zip with an XML install file right away (well not RIGHT now because i'm @ my grandparents house, they had to tear me away from my php editor ... lol) However it will do nothing, exept generate errors.. However since my first post i have completed most of my function 2 to go (I think...).

However i have some issues regarding graph type 3..
I have thought of a solution and that is that i will create a backround image.
I will probably not get text under the bars (just on) untill everything else is working.

Is there a way to put heading or images into the parameters page in the joomla backend?
In description can i just add: ?

Also, as a precaution against thick users, the images that are required for the graphs to work will be hard codoed at the top of the php file (so those tech savy can change if they must  :D)
Where should these images be placed in the joomla directories and how does my installer put them there?


Lastly, (i know what your thinking, "AT LAST!") i am using inline styles and am modifying the css code every so slightly to offer more options.. (the more the merrier!)

I'll try to have a working version done by the 19th as i'm going on holiday on the 22nd and can use the 'net at my beach house ('spose i put myself on a tight scedule lol!  :D)

JoomlaCode:
http://joomlacode.org/gf/project/prograph

Oh, BTW, i omly learnt php out of a book last month, so any bugs.. please forgive me!

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Sun Dec 16, 2007 5:14 am
by thomasfedb
Actually applestooranges DO provide the images...  And i made a logo, have a look:
Image

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Sun Dec 16, 2007 6:19 am
by AmyStephen
Love it!  :-*

Don't forget to talk to family, too!  ;)

See you later,
Amy :)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Sun Dec 16, 2007 8:07 am
by thomasfedb
Ah!
the hard bit is done! PHP Complete (well actually its not tested yet  :o)

I'm starting on the XML (and english language file)

I plan to do these langs:
French
German (my gran can check it)
Spanish (maby)
Italian

Please give me the codes: eg. English = en-GB ... etc

I will be using google / bablefish for this so they won't be the best (but i'll have them checked in that forum...)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Tue Dec 18, 2007 9:03 am
by thomasfedb
Weird things happening with the php, it will only detect 1 bar, and 1 graph.

Lucky my dad was a programmer, i'll get him to help me sort it out tonight...

Wondering if i will get time to do the languages, however if there not done for the comp they wil be released on the ProGraph JoomlaCode site after January!

Should have this done by, say, the 20th?

Please reply, i will ask for final review soon and a version (that almost works) will be avalable on Joomla code probably tonight and if anybody can tell me where i am going wrong, it would be great!

Thx

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Tue Dec 18, 2007 2:19 pm
by AmyStephen
Very much looking forward to seeing this!

French - fr-FR
Spanish - es-ES
Italian - it-IT

Thanks!
Amy :)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Tue Dec 18, 2007 11:35 pm
by thomasfedb
The alpha version is now avalable on JoomlaCode !!!

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Wed Dec 19, 2007 7:40 am
by AmyStephen
Thomas - that is some seriously impressive code!

I was not able to figure out the plugin syntax:


{graph}12,3{/graph}

{bar=12,5,8} or {bar 12,5,8}

Will you provide a few examples of how to power it on? I am dying to see these graphs in action!

Good stuff,
Amy :)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Wed Dec 19, 2007 10:18 pm
by thomasfedb
The syntax is a bit like css.e.g.:

{graph="type:1;"}{bar="barsize:25%;"}{bar="barsize:50%;"}{bar="barsize:75%;"}{bar="barsize:100%;"}{/graph}

you can change type to 2 and 3 also...

Please try the new version from joomlacode its much improved!

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Thu Dec 20, 2007 12:11 am
by thomasfedb
Final Review Please

All done!

Unfortuantly i don't have time to do the oter languages but my code is made so this is easy, all you need is language files!

The things is.. I'm going away on the morning of the 22nd so is it ok if either:
1) Final review can be done very fast
2)I can upload to google now?
3) Some nice person can post it on google on my behalf (i can post there saying that someone will do that) (Amy?)

Documentation: http://joomlacode.org/gf/project/progra ... dit&id=577

Things you *might* want to take into account during final review:
1) HEAPS of options!
2) JoomlaCode: http://joomlacode.org/gf/project/prograph (look for the documentation on making graphs)
3) No strings outside of language file.
4) Protection against stupid users (trust me you can be thick as a brick and still not make a mess of your home page, its got loads of error and idiot checking!)
5) Nicely indented code
6) The code itself (looks good, works good, it is good...)
7) I started learning php 1-2 months ago and this is my very first program.

Thx & please be quick!

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Fri Dec 21, 2007 1:01 am
by thomasfedb
Amy Please reply

Final Review Please

Read Above Post, if i get no reply by tonight i will upload on google! because thats my last opertunity to do so!

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Fri Dec 21, 2007 8:17 am
by thomasfedb
OK, I'm Sorry, but this is my last chance to get to the computer until the 2nd !!!

I'm ow going to upload my finished project at the GHOP Website and hope that all goes well with final review and updating my task as complete!

Sorry, truly sorry, for disobeying your very clear rules, but this is all i can do, i'v waited as long as i can...

However, even if this does not get passed, i will continue this project and later add more languages.
But i will still be VERY sad!  :'( :'( :'(

So please, oh please, pass my entry into the GHOP and forgive me if i do not answer any emails/posts/etc until the 2nd..
BTW: How will you get my details to post me a T-Shirt? (if e-mail, etc plz wait 'till 2nd !!)

Oh, and soz for writing this like an epic novel lol, and posting so much code that this page is about 10 feet long lolololol!!

I will *try* to check before the 2nd, but i will DEFIANTLY check after the 2nd

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Fri Dec 21, 2007 4:11 pm
by AmyStephen
Thomas -

I received both of your PMs and I see these comments. We have 77 open tasks. We are overwhelmed. We are trying to walk through as many as we can today. We will be and have been reasonable with contestants and the dates, provided people have shown effort. CLEARLY, you have shown effort and we certainly understand you have holiday plans. If you are not available, we will wait until you are. Please also understand, as volunteers, we too, have families and holiday plans, as well. Provided we are all respectful and considerate with one another, we will eventually get all of this done.

Happy Holidays. We will review and respond to your thread. We will await your response when you are able.

Amy :)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Fri Dec 21, 2007 10:18 pm
by thomasfedb
Sorry for not considering your workload.
I sneaked on... leaving in 20 min...

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Fri Dec 21, 2007 10:52 pm
by AmyStephen
Don't worry about it! This is a really amazing plugin and I understand your desire to get some feedback and get it finalized. We will be here when you get back. Have a great time with family!

Look for feedback soon.
Amy :)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Sat Dec 22, 2007 4:57 am
by AmyStephen
This is a very, very, very nice extension. It's a WOW extension, in fact.

Little things:

I am getting a few error messages:

Notice: Undefined offset: 4 in D:\VirtualWebsites\JoomlaPlace\JoomlaGHOP\plugins\content\prograph.php on line 233

Notice: Undefined variable: validbars in D:\VirtualWebsites\JoomlaPlace\JoomlaGHOP\plugins\content\prograph.php on line 280

Notice: Undefined offset: 4 in D:\VirtualWebsites\JoomlaPlace\JoomlaGHOP\plugins\content\prograph.php on line 207
The background parameter for a graph is misspelled (backgroud).

I wasn't able to figure out how to build Graph Type 3, very well. I'll hopefully find a bit more time to look at it, again, before you return. The more examples you provide - the better it will be.

This really is an awesome extension and one you should be very proud of! Congrats.

Amy :)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Sun Dec 30, 2007 7:13 am
by thomasfedb
You might want to try: {graph="type:3;"}{bar="barsize:25%;"}{bar="barsize:50%;"}{bar="barsize:75%;"}{bar="barsize:100%;"}{/graph}

I will fix those errors by lets say the 5th ?
and there is a bit of a bug with graph type 3 (it has white dots on it) but i now know to fix that!!!!

MERRY CHIRISMAS

HAPPY NEW YEAR

look @ : http://joomlacode.org/gf/download/docma ... torial.txt (if u havnt all ready!)

c u in the new year!

BTW: new time the GHOP is on (if i'm not in it...) i would like to vonenteer to be a helper with php & css.... (if i can)
also, how would i get about getting on a joomla team?

cya

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Mon Dec 31, 2007 6:11 am
by jonhurlock
Really liking the syntax :D
thomasfedb wrote: The syntax is a bit like css.e.g.:
{graph="type:1;"}{bar="barsize:25%;"}{bar="barsize:50%;"}{bar="barsize:75%;"}{bar="barsize:100%;"}{/graph}
This will help with non programer types, who will want to public nice little graphs on their site. Im sure businesses will love this extension. e.g. Excellent work :D

http://code.google.com/apis/chart/ is googles new Chart API, tbh i prefer your markup :D

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Tue Jan 01, 2008 9:52 am
by thomasfedb
jonhurlock wrote: Really liking the syntax :D
thomasfedb wrote: The syntax is a bit like css.e.g.:
{graph="type:1;"}{bar="barsize:25%;"}{bar="barsize:50%;"}{bar="barsize:75%;"}{bar="barsize:100%;"}{/graph}
This will help with non programer types, who will want to public nice little graphs on their site. Im sure businesses will love this extension. e.g. Excellent work :D

http://code.google.com/apis/chart/ is googles new Chart API, tbh i prefer your markup :D
Yeh...

Its been designed for idiots!
i couldn't make it work untill i realised that my syntax was wrong, if the syntax isn't just so it removes it.. (as little as i can safely...)
i.e. id you have a graph with 7 bars and 2 of them have wrong syntax then the graph will only display 5 bars....

Also that syntax makes it a LOT easyer to parse....

glad you like it!

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Wed Jan 02, 2008 11:42 pm
by thomasfedb
The latest version has now been released, it fixes those errors (thx amy) and improves graph type 3 !

HERE: http://joomlacode.org/gf/project/progra ... ge_id=3194

Hope you like it


btw , back from holidays, so will be arround more now

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Thu Jan 03, 2008 7:22 am
by AmyStephen
Thomas -

It is very, very, very fabulous.

I have one "problem" that would be great if you could fix.

This is what I have in my article (using No WYSIWYG editor)

Code: Select all

<h3>Type 1: Basic CSS Bar Graph</h3>

{graph="type:1;backgroud:black;"}{bar="barsize:25%;barcolor:red;text:rabbits;"}{bar="barsize:50%;barcolor:green;text:turtles;"}{bar="barsize:75%;barcolor:purple;textcolor:white;text:monsters;"}{bar="barsize:100%;barcolor:pink;text:pancakes;"}{/graph}

<h3>Type 2: Complex CSS Bar Graph</h3>

{graph="type:2;"}{bar="barsize:25%;barcolor:red;text:rabbits;"}{bar="barsize:50%;barcolor:green;text:turtles;"}{bar="barsize:75%;barcolor:purple;text:monsters;"}{bar="barsize:100%;barcolor:pink;text:pancakes;"}{/graph}

<h3>Type 3: Vertical CSS Bar Graph</h3>

{graph="type:3;textcolor:black;"}{bar="barsize:22%;barcolor:red;text:rabbits;"}{bar="barsize:4%;barcolor:green;text:turtles;"}{bar="barsize:60%;barcolor:purple;text:monsters;"}{bar="barsize:9%;barcolor:pink;text:pancakes;"}{/graph}
Image

How can you force a break so that these don't stack up oddly?

Beautiful code, too.
Amy :)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Thu Jan 03, 2008 1:01 pm
by thomasfedb
AmyStephen wrote: Thomas -

It is very, very, very fabulous.

I have one "problem" that would be great if you could fix.

This is what I have in my article (using No WYSIWYG editor)

Code: Select all

<h3>Type 1: Basic CSS Bar Graph</h3>

{graph="type:1;backgroud:black;"}{bar="barsize:25%;barcolor:red;text:rabbits;"}{bar="barsize:50%;barcolor:green;text:turtles;"}{bar="barsize:75%;barcolor:purple;textcolor:white;text:monsters;"}{bar="barsize:100%;barcolor:pink;text:pancakes;"}{/graph}

<h3>Type 2: Complex CSS Bar Graph</h3>

{graph="type:2;"}{bar="barsize:25%;barcolor:red;text:rabbits;"}{bar="barsize:50%;barcolor:green;text:turtles;"}{bar="barsize:75%;barcolor:purple;text:monsters;"}{bar="barsize:100%;barcolor:pink;text:pancakes;"}{/graph}

<h3>Type 3: Vertical CSS Bar Graph</h3>

{graph="type:3;textcolor:black;"}{bar="barsize:22%;barcolor:red;text:rabbits;"}{bar="barsize:4%;barcolor:green;text:turtles;"}{bar="barsize:60%;barcolor:purple;text:monsters;"}{bar="barsize:9%;barcolor:pink;text:pancakes;"}{/graph}
Image

How can you force a break so that these don't stack up oddly?

Beautiful code, too.
Amy :)
I have tried a break, that doesn't seem to work...
But having a look at the applestooranges site  it looks like it needs a clearer ie after each graph...
I can't add that now because i'm @ my grandparents  :), but try:

Code: Select all

<h3>Type 1: Basic CSS Bar Graph</h3>

{graph="type:1;backgroud:black;"}{bar="barsize:25%;barcolor:red;text:rabbits;"}{bar="barsize:50%;barcolor:green;text:turtles;"}{bar="barsize:75%;barcolor:purple;textcolor:white;text:monsters;"}{bar="barsize:100%;barcolor:pink;text:pancakes;"}{/graph}
<div style="clear: both; height: 1px; font-size: 1px;"/>
<h3>Type 2: Complex CSS Bar Graph</h3>

{graph="type:2;"}{bar="barsize:25%;barcolor:red;text:rabbits;"}{bar="barsize:50%;barcolor:green;text:turtles;"}{bar="barsize:75%;barcolor:purple;text:monsters;"}{bar="barsize:100%;barcolor:pink;text:pancakes;"}{/graph}
<div style="clear: both; height: 1px; font-size: 1px;"/>
<h3>Type 3: Vertical CSS Bar Graph</h3>

{graph="type:3;textcolor:black;"}{bar="barsize:22%;barcolor:red;text:rabbits;"}{bar="barsize:4%;barcolor:green;text:turtles;"}{bar="barsize:60%;barcolor:purple;text:monsters;"}{bar="barsize:9%;barcolor:pink;text:pancakes;"}{/graph}
<div style="clear: both; height: 1px; font-size: 1px;"/>
And tel me if that helps!

thx

if this works i will add it tomoro..

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Thu Jan 03, 2008 3:26 pm
by AmyStephen
Image

It's better, but now it runs into other parts of the site.

I don't know CSS very well. It would be nice to have an expert weigh on this.

See what you think. I'll think on this, too.

Amy :)

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Thu Jan 03, 2008 11:53 pm
by thomasfedb
amy, did you just download the new version, or that and use the spacer thing?...

Thinking... ???

What template are you using?

The thing is, and ill try to explain this with as little 'geek speak' as possible, that the graphs don't really exist (at least not type 3) they are just positioned bit of colored 'stuff'........... lol

It would help (a lot) if you could grab the source of what you are seeing, the lot (the entire page), and post it here so i can have a look.
View -> Source  / Page Source  and then copy it all
that would really help!
thx

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Thu Jan 03, 2008 11:56 pm
by thomasfedb
also, try replacing "clear:both;" with either "clear:right;" or "clear:left;"

Re: 128 - Create a Joomla! v 1.5 CSS for Bar Graphs Plugin

Posted: Fri Jan 04, 2008 1:55 am
by AmyStephen
I can handle a little geek speak, Thomas.  ;)

Downloaded from http://joomlacode.org/gf/project/progra ... ge_id=3194 yesterday night (late).

I am using the latest version of Joomla!. (SVN 9840) Although, it's been this way since the start.

Standard Milkyway template.

I shared the contents of the article with you because you should be able produce the same results if you put it into an article using an NO WYSIWYG editor. Have you tried that, yet?

I can also give you access to a server environment we can share, if you wish. I'll PM you an admin ID if you want.

Thanks!

Amy :)