Menu

Wiki Plugin Mod

vger612004
2010-10-07
2012-09-07
  • vger612004

    vger612004 - 2010-10-07

    I have been successful at using phplot to display graphs embedded in Wiki
    pages as an inline image only. I have NOT had any luck getting it work as a
    "wiki plugin" as indicated on TikiWiki's doc page (http://doc.tiki.org/Mod+ph
    plot&structure=Documentation).

    I am beginning to wonder if this is because the doc is somewhat dated and that
    I am running pretty much the latest stable versions of all essential packages?
    Anyhow, what happens is that attempts to call a Wiki plugin php file from a
    Wiki page result in the image/graph taking over the entire browser display,
    not embedding. It appears that once the Drawgraph() function is called, the
    remaining code from calling php file is ignored, not returning control to the
    calling Wiki page. Does anyone know of where some current examples of Wiki
    plugins using phplot are?

    TIA!

    Running: PHPLOT 5.1.3 / PHP 5.2.6 / TikiWiki 5.1 / Debian 5

     
  • lbayuk

    lbayuk - 2010-10-07

    I'm not familiar with TikiWiki, but that documentation page you linked to
    doesn't look like it is maintained. The links and images are broken. (They
    point to phplot.com which is Afan's domain and he apparently set that to
    redirect all URLs to sourceforge.net/projects/phplot back in 2007.) Also on
    that page I see attempts to demonstrate the module which aren't working and
    are showing the code instead (which I assume means doc.tiki.org doesn't have
    the plugin, or it doesn't work).

    Where did you get the "mod" script described on that page? All I could find
    was wikiplugin_phplot.php in the SVN repository on sourceforge. Is that what
    you are using, or did I miss a 'download mods and plugins' link somewhere? For
    the one I found, it doesn't seem possible that it works at all. It looks to me
    as if it refererences a script that used to be on phplot.com for the image,
    not using a local PHPlot at all. I must be missing something, since you said
    you are getting a full page graph.

     
  • vger612004

    vger612004 - 2010-10-16

    Ibayuk,

    Thanks for the response and sorry for the delay on my end, I have been working
    on this whenever I find the time and I think I have come up with some answers.
    To first answer your Q, the "mod script" actually is embedded in the
    wikiplugin_phplot.php you found on the SVN repository. It's commented out and
    is intended to be a guide for both entering code in a Wiki page plus getting
    you started with your own php scripts that manipulate the graphing process. I
    believe the way it all works is that (1) the Wiki calls phplot via the
    wikiplugin_phplot (2) wikiplugin_phplot then calls another php script
    (create_chart.php in this case) which uses parameters sent from the wiki to
    create the graph (3) the create_chart script finally calls phplot.php where
    the drawgraph directive is executed (4) the resulting graph is then returned
    via the plugin and embedded in the Wiki page.

    In going thru this exercise, I discovered that installing the phplot wiki
    plugin was not exactly straightforward. The (nearly)current version of the
    Wiki handles plugins differently than the older versions I have worked with.
    The main difference is that they have added a security feature that
    incorporates a plugin registration process to prevent just any old plugin from
    being installed and manipulating unsuspecting Wiki's. The dated version of
    wikiplugin_phplot.php available does not include the necessary function to
    work with the registration/enable process. I have since added the function
    code to the plugin and it now shows up like the other plugins where it can be
    registered and enbaled. So I'm gonna start coding some test graphs with this
    method and see what happens. I'll try to post my progress/results here.

     
  • lbayuk

    lbayuk - 2010-10-16

    I'm still puzzled. I found the wikiplugin_phplot.php in SVN here:

    http://tikiwiki.svn.sourceforge.net/viewvc/tikiwiki/mods/trunk/wiki-plugins/p
    hplot/

    That one assumes a script called create_chart.php exists somewhere, and you
    have to change $PHPLOT_URL to point to it (in SVN, it points to phplot.com
    which won't work). I don't see create_chart.php anywhere on their site. There
    used to be a create_chart.php in PHPlot (it can still be found in CVS under
    examples/Attic) but I don't think that is the right one.

    While looking around, I also saw that apparently PHPlot support was removed
    some time ago from TikiWiki due to PHPlot's dual licensing. But we changed to
    LGPL in June 2009. Somebody noticed that and added a note in May 2010 to wiki-
    plugins/phplot/README that says "PHPlot was changed to LGPL in 2009, thus,
    this plugin could become part of Tiki core." But it doesn't look like there
    was anything further done on it.

    Did you get wikiplugin_phplot.php from the same location I found?

    Where did you get create_chart.php?

     
  • vger612004

    vger612004 - 2010-10-18

    Yes, correct about the URL. It's been awhile, but I think the create_chart.php
    came down with the wiki plugin for phplot I got some time ago. In any event, I
    thought I would include the code FYI:

    Cheers!

    This file is intended to be called from format_chart.php, the example-o-matic.". "Please click here to try it.

    "; exit; } */ extract ($_GET, EXTR_OVERWRITE); extract ($_POST, EXTR_OVERWRITE); //Sample functions // data-data as a function if ($which_data_type == 'function') { //Put function here $dx = ".3"; $max = 6.4; $maxi = $max/$dx; for ($i=0; $i<$maxi; $i++) { $a = 4; $x = $dx*$i; $data = array("", $x, $a*sin($x),$a*cos($x),$a*cos($x+1)); } $which_data_type = "data-data"; } // data-data-error as a random function else if ($which_data_type == 'randfunction') { srand ((double) microtime() * 1000000); $a = 9.62; $label = "October"; $label = "Day 5"; $label = "Day 10"; $label = "Day 15"; $label = "Day 20"; $label = "Day 25"; for ($i = 0; $i <= 30; $i++) { $a += rand(-1, 2); $b = rand(0,1); $c = rand(0,1); $data = @ array($label,$i+1,$a,$b,$c); } $which_data_type = 'data-data-error'; } // MBD, this is for data_sample3.php, $num_data_rows is set there else if ($which_data_type == 'data-data-error') { for ($i = 0; $i < $num_data_rows; $i++) { eval ("\$data = \$data_row$i; "); } } else { foreach($data_row0 as $key=>$val) { $data = array($data_row0,$data_row1,$data_row2,$data_row3,$data_row4); } } //////////////////////////////////////////////// //Required Settings // MichelV # include("../../xarincludes/phplot.php"); # include 'phplot.php'; $graph = new PHPlot($xsize_in, $ysize_in); $graph->SetDataType($which_data_type); // Must be first thing $graph->SetDataValues($data); //Optional Settings (Don't need them) // $graph->SetTitle("This is a\n\rmultiple line title\n\rspanning three lines."); $graph->SetTitle($title); $graph->SetXTitle($xlbl, $which_xtitle_pos); $graph->SetYTitle($ylbl, $which_ytitle_pos); $graph->SetLegend(array("2000","2001","2002","2003")); $graph->SetFileFormat($which_fileformat); $graph->SetPlotType($which_plot_type); $graph->SetUseTTF($which_use_ttf); $graph->SetYTickIncrement($which_yti); $graph->SetXTickIncrement($which_xti); $graph->SetXTickLength($which_xtl); $graph->SetYTickLength($which_ytl); $graph->SetXTickCrossing($which_xtc); $graph->SetYTickCrossing($which_ytc); $graph->SetXTickPos($which_xtick_pos); $graph->SetYTickPos($which_ytick_pos); $graph->SetShading($which_shading); $graph->SetLineWidth($which_line_width); $graph->SetErrorBarLineWidth($which_errorbar_line_width); $graph->SetDrawDashedGrid($which_dashed_grid); switch($which_draw_grid) { case 'x': $graph->SetDrawXGrid(TRUE); $graph->SetDrawYGrid(FALSE); break; case 'y': $graph->SetDrawXGrid(FALSE); $graph->SetDrawYGrid(TRUE); break; case 'both': $graph->SetDrawXGrid(TRUE); $graph->SetDrawYGrid(TRUE); break; case 'none': $graph->SetDrawXGrid(FALSE); $graph->SetDrawYGrid(FALSE); } $graph->SetXTickLabelPos($which_xtick_label_pos); $graph->SetYTickLabelPos($which_ytick_label_pos); $graph->SetXDataLabelPos($which_xdata_label_pos); $graph->SetYDataLabelPos($which_ydata_label_pos); // Please remember that angles other than 90 are taken as 0 when working fith fixed fonts. $graph->SetXLabelAngle($which_xlabel_angle); $graph->SetYLabelAngle($which_ylabel_angle); // Tests... //$graph->SetLineStyles(array("dashed","dashed","solid","solid")); //$graph->SetPointShapes(array("plus", "circle", "trianglemid", "diamond")); //$graph->SetPointSizes(array(15,10)); $graph->SetPointShapes($which_point); $graph->SetPointSizes($which_point_size); $graph->SetDrawBrokenLines($which_broken); // Some forms in format_chart.php don't set this variable, suppress errors. @ $graph->SetErrorBarShape($which_error_type); $graph->SetXAxisPosition($which_xap); $graph->SetYAxisPosition($which_yap); $graph->SetPlotBorderType($which_btype); if ($maxy_in) { if ($which_data_type = "text-data") { $graph->SetPlotAreaWorld(0,$miny_in,count($data),$maxy_in); } } /* //Even more settings $graph->SetPlotAreaWorld(0,100,5.5,1000); $graph->SetPlotAreaWorld(0,-10,6,35); $graph->SetPlotAreaPixels(150,50,600,400); $graph->SetDataColors( array("blue","green","yellow","red"), //Data Colors array("black") //Border Colors ); $graph->SetPlotBgColor(array(222,222,222)); $graph->SetBackgroundColor(array(200,222,222)); //can use rgb values or "name" values $graph->SetTextColor("black"); $graph->SetGridColor("black"); $graph->SetLightGridColor(array(175,175,175)); $graph->SetTickColor("black"); $graph->SetTitleColor(array(0,0,0)); // Can be array or name */ // $graph->SetPrintImage(false); $graph->DrawGraph(); // xdebug_dump_function_profile(XDEBUG_PROFILER_FS_SUM); ?>
     
  • lbayuk

    lbayuk - 2010-10-19

    Uh oh, zombie script. I killed that off 3 years ago, but it won't die...
    Seriously, I wouldn't use that script on a web site. First, it is using the
    equivalent of register_globals=On. Next, it is hard to read with all the
    commented out blocks and lines. No documentation describing what it is
    supposed to do, so how would anyone test it? (And what's with the echo Hello
    World at the top? That isn't in the original.) In short, I think it is a bad
    idea, badly implemented.

    Sorry I can't be of more help. Someone who knows tikiwiki really well would
    have to figure out if this is worth doing and how to do it better. (One way is
    to have the main script generate the plot image, store it in a temporary file,
    and include the URL to the temporary file in an IMG tag it returns to the
    browser. This requires a server-side caching system or something like that,
    which can generate unique name and clean up the files appropriately. Another
    way is to pass the parameters and data to the image-generating script using
    session variables. The third way is using URL parameters, but that requires
    care in defining and using those parameters.)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.