| Server IP : 87.98.154.146 / Your IP : 216.73.216.101 Web Server : Apache System : Linux webm005.cluster126.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : bsiadvisil ( 110003) PHP Version : 7.3.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/bsiadvisil/old/plugins/content/rgraph/ |
Upload File : |
<?php
/**
* @package rgraph Joomla! Plugin
* @version Version 1.2.3
* @author Joachim Schmidt - joachim.schmidt@jschmidt-systemberatung.de
* @copyright (C) 2016 Joachim Schmidt. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*
* change activity:
* 01.10.2018: changed to namespaced classes (Joomla 3.x.API)
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\String\StringHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
$lib = dirname(__FILE__) . '/lib/rgraph_chart.php';
require_once ($lib);
class plgContentrgraph extends CMSPlugin
{
var $params;
function __construct (&$subject, $params)
{
parent::__construct($subject, $params);
$this->_plugin = PluginHelper::getPlugin('content', 'rgraph');
}
function onContentPrepare ($context, &$row, &$params, $page = 0)
{
if (StringHelper::strpos($row->text, '{rgraph') === false)
return true;
else
{
$matches = array();
$regex = "#{rgraph\\s*(.*?)}(.*?){/rgraph}#s";
preg_match_all($regex, $row->text, $matches);
$count = count($matches[0]);
if ($count)
{
include_once 'helper.php';
$this->helper = new plgContentrgraphHelper();
$this->replaceContent($row, $matches, $count, $regex, $this->params);
return true;
}
else
{
return true;
}
}
}
function replaceContent (&$row, $matches, $count, $regex, $params)
{
$error_string = null;
$lang = Factory::getLanguage();
// $lang_subtag = explode("-", $lang->getTag());
$rc = $lang->load('plg_content_rgraph', JPATH_ADMINISTRATOR, null, true, true);
if (! $rc)
{
$lang->load('plg_content_rgraph', JPATH_ADMINISTRATOR, "en-GB");
//$lang_subtag[0] = "en";
}
$plugin_parms = $params->toString();
$plugin_parms = json_decode($plugin_parms, true);
//$rgraph_rgraph = $this->helper->getParam($plugin_parms, 'rgraph_rgraph', '1');
for ($i = 0; $i < $count; $i ++)
{
$replace = "";
$param_line = $this->helper->convert2Array($matches[0][$i]);
$id = trim($matches[2][$i]);
$result = $this->helper->getChartProperties($id, $plugin_parms, $param_line, $row);
$error_string = $result['error'];
if (strlen($error_string) != null)
{
if ($result['debug'])
$replace = $matches[0][$i] . "<br />" . Text::_('INVALID_MSG') . $error_string;
else
$replace = "<br />" . Text::_('INVALID_MSG') . $error_string;
}
else
{
$chart = $result['chart'];
$options = $result['options'];
$chart->set_options($options);
$id = $chart->get_id();
//$type = $chart->get_chartType();
$width = $result['width'];
$height = $result['height'];
if (isset($result['draw_option']))
$draw_option = $result['draw_option'];
else
$draw_option = ".draw();";
if (isset($result['chart_alignment']))
$canvas_style = $result['chart_alignment'];
if (isset($result['chart_script']))
$chart_script = $result['chart_script'];
if (isset($result['event_script']))
$event_script = $result['event_script'];
if (isset($result['canvas_class']))
$canvas_class = $result['canvas_class'];
$url_base = URI::base() . 'plugins/content/rgraph/js/';
$url_css = URI::base() . 'plugins/content/rgraph/css';
if (isset($result['modal']))
$options->set_option("gutterRight", $options->gutterLeft);
if ($result['debug'])
$rgraph_json = $chart->toPrettyString();
else
$rgraph_json = $chart->toString();
if ($rgraph_json == "")
$error_string = Text::_('ERROR_NO_JSON');
if (! isset($canvas_class))
$canvas_class = "";
if (! isset($result['chart_name']))
$chart_name = "chart" . $id;
else
$chart_name = $result['chart_name'];
if (! isset($event_script))
$event_script = "";
if (! isset($chart_script))
$chart_script = "";
$id = $chart->get_id();
$chart_type = $chart->get_chartType();
$document = Factory::getDocument();
$document->addStyleSheet($url_css . '/rgraph.css');
$document->addScript($url_base . "php-rgraph.common.js");
$document->addScript($url_base . $chart->getScript($chart_type));
if ($result['drill_chart'] == "")
$canvas = "$error_string<canvas id='" . $id . "' width='" . $width . "' height='" . $height . "' style='" . $canvas_style . "' class='" . $canvas_class . "'>[No canvas support]></canvas>";
$replace = "";
$bracket = "});";
if ($result['combine_chart'] == false)
{
if (isset($result['modal']))
{
if (! isset($result['title']))
$result['title'] = "modal chart";
$canvas = "<canvas id='" . $id . "' width='" . $width . "' height='" . $height . "' class='" . $canvas_class . "'>[No canvas support]></canvas>";
$replace = $this->helper->buildModalhtml($id, $canvas, $result['modal'][0], $result['title'], $result['modal'][1], $width);
}
elseif ($result['drill_chart'] == "")
$replace = $canvas;
}
if ($result['combine_chart'] == true)
{
if (! isset($result['chart_name']))
$chart_name = "combined" . $id;
}
if ($result['drill_chart'])
{
$draw = $draw_option;
$draw_option = "";
$rgraph_script = "function " . $result['drill_chart'] . "(draw) { if (draw != false) { RGraph.reset('" . $id . "'); RGraph.redraw(); } ";
$bracket = " if (draw == false) return $chart_name; else { " . $chart_name . $draw . " } }";
}
elseif ($result['drill_charts'])
{
$rgraph_script = "function " . $id . "_main() { RGraph.reset('" . $id . "'); RGraph.redraw(); ";
$bracket = " }";
$rgraph_main = "jQuery(document).ready(function() { ";
$rgraph_main .= $id . "_main (); }); \n";
$document->addScriptDeclaration($rgraph_main);
}
else
$rgraph_script = "jQuery(document).ready(function() { ";
if ($chart_type == "Bubble")
{
$rgraph_script .= $event_script . "\n var " . $chart_name . " = new RGraph.Scatter" . "( " . $rgraph_json . " );" . $chart_script . "\nvar bubble" . $id . " = new RGraph.Scatter.Bubble (" . $chart_name . "," . $result['min'] . "," . $result['max'] . "," . $result['max_size'] .
"," . "[" . implode(',', $result['bubble_data']) . "]);";
$rgraph_script .= "\nbubble" . $id . "" . $draw_option . "\n})\n";
}
else
{
if (! empty($result['drill_tips']))
$chart_script .= " ". $chart_name .
".ontooltip = function (obj) { tips = obj.get('drill_tips'); var tooltip = RGraph.Registry.Get('chart.tooltip'); var index=tooltip.__index__; if (tips[index] != undefined && typeof window[ tips[index] ] == 'function') window[ tips[index] ](false).draw(); else RGraph.hideTooltip(); }";
if (! empty($result['drill_charts']))
$chart_script .= " " . $chart_name . ".onclick = function (e, shape) { var obj = e.target.__object__; charts = " . $chart_name .
".Get('drill_charts'); var index=shape.index; if (charts[index] != undefined && typeof window[ charts[index] ] == 'function') { RGraph.reset('" . $id . "'); window[ charts[index] ](); } }\n "
. $chart_name . ".onmousemove = function (e, shape) { e.target.style.cursor = 'pointer'; return true; }";
$rgraph_script .= $event_script . "\n var " . $chart_name . " = new RGraph." . $chart_type . "( " . $rgraph_json . " )" . $draw_option . "\n" . $chart_script . " " . $bracket . "\n";
}
$document->addScriptDeclaration($rgraph_script);
}
$row->text = str_replace($matches[0][$i], $replace, $row->text);
$chart_script = "";
$event_script = "";
$result = array();
$error_string = null;
}
return true;
}
}