Exemple #1
0
    function display($tpl = null)
    {
        JToolBarHelper::title(LAP_COMPONENT_NAME . ': ' . JText::_('COM_PLOTALOT_EDIT_CSS'), 'plotalot.png');
        JToolBarHelper::apply('apply_css');
        JToolBarHelper::save('save_css');
        JToolBarHelper::cancel('cancel', 'JTOOLBAR_CLOSE');
        $css_path = JPATH_COMPONENT_SITE . '/assets/plotalot.css';
        if (!file_exists($css_path)) {
            $app =& JFactory::getApplication();
            $app->redirect(LAP_COMPONENT_LINK . '&task=config', JText::_('COM_PLOTALOT_CSS_MISSING') . ' (' . $css_path . ')', 'error');
            return;
        }
        if (!is_readable($css_path)) {
            $app =& JFactory::getApplication();
            $app->redirect(LAP_COMPONENT_LINK . '&task=config', JText::_('COM_PLOTALOT_CSS_NOT_READABLE') . ' (' . $css_path . ')', 'error');
            return;
        }
        if (!is_writable($css_path)) {
            $app =& JFactory::getApplication();
            $app->redirect(LAP_COMPONENT_LINK . '&task=config', JText::_('COM_PLOTALOT_CSS_NOT_WRITEABLE') . ' (' . $css_path . ')', 'error');
            return;
        }
        $css_contents = @file_get_contents($css_path);
        ?>
	<form action="index.php" method="post" name="adminForm" id="adminForm" >
	<input type="hidden" name="option" value="<?php 
        echo LAP_COMPONENT;
        ?>
" />
	<input type="hidden" name="task" value="" />
	
	<?php 
        echo '<table><tr><td>';
        echo '<textarea name="css_contents" rows="25" cols="125">' . $css_contents . '</textarea>';
        echo '</td><td valign="top">';
        echo LAP_view::make_info('www.w3schools.com/css', 'http://www.w3schools.com/css/default.asp');
        echo '</td></tr></table>';
        ?>
	</form>
	<?php 
    }
Exemple #2
0
defined('_JEXEC') or die('Restricted Access');
// load the helpers
require_once JPATH_ADMINISTRATOR . '/components/com_plotalot/helpers/plotalot_helper.php';
require_once JPATH_ADMINISTRATOR . '/components/com_plotalot/helpers/db_helper.php';
require_once JPATH_ADMINISTRATOR . '/components/com_plotalot/helpers/plotalot.php';
require_once JPATH_ADMINISTRATOR . '/components/com_plotalot/helpers/view_helper.php';
require_once JPATH_ADMINISTRATOR . '/components/com_plotalot/models/chart.php';
// get parameters from the active menu item
$app = JFactory::getApplication('site');
$menu_params = $app->getParams();
if ($menu_params == null) {
    echo 'Menu item not found';
    return;
}
// load our css, if it exists
LAP_view::load_styles();
// load the Google jsapi
$document = JFactory::getDocument();
$document->addScript("https://www.google.com/jsapi");
// display the heading and top text
echo "\n<h2>" . $menu_params->get('page_hdr') . '</h2>';
echo "\n<div>" . $menu_params->get('top_text') . '</div>';
// get the model
jimport('joomla.application.component.model');
$model = new PlotalotModelChart();
// draw the charts
$chart_id_array = explode(",", $menu_params->get('chart_ids'));
if (count($chart_id_array) == 0) {
    echo "\n<div>No charts specified</div>";
    return;
}
Exemple #3
0
    function display($tpl = null)
    {
        global $chart_types;
        if ($this->chart_data->id == 0) {
            // creating a new record
            JToolBarHelper::title(LAP_COMPONENT_NAME . ': ' . JText::_('COM_PLOTALOT_NEW_ITEM'), 'plotalot.png');
        } else {
            JToolBarHelper::title(LAP_COMPONENT_NAME . ': ' . JText::_('COM_PLOTALOT_EDIT_ITEM') . ' ' . $this->chart_data->id, 'plotalot.png');
        }
        JToolBarHelper::apply();
        JToolBarHelper::save();
        if ($this->chart_data->id > 0) {
            JToolBarHelper::save2copy();
        }
        JToolBarHelper::cancel('cancel', 'JTOOLBAR_CLOSE');
        JToolBarHelper::preferences(LAP_COMPONENT, 350, 450);
        JToolBarHelper::custom('help', 'help.png', 'help_f2.png', 'JHELP', false);
        // load our front end css, if it exists
        LAP_view::load_styles();
        // get component parameters
        $params = JComponentHelper::getParams(LAP_COMPONENT);
        $this->tooltips = $params->get('tooltips', 1);
        if ($params->get('autocomplete', 1)) {
            $autocomplete = 'autocomplete="off"';
            if (empty($this->chart_data->db_user)) {
                // some browsers don't respect autocomplete="off"
                $this->chart_data->db_user = '******';
            }
            // the model will intercept this and remove it
        } else {
            $autocomplete = '';
        }
        ?>
	<form action="index.php" method="post" name="adminForm" id="adminForm" <?php 
        echo $autocomplete;
        ?>
 >

	<input type="hidden" name="option" value="<?php 
        echo LAP_COMPONENT;
        ?>
" />
	<input type="hidden" name="id" value="<?php 
        echo $this->chart_data->id;
        ?>
" />
	<input type="hidden" name="chart_type" value="<?php 
        echo $this->chart_data->chart_type;
        ?>
" />
	<input type="hidden" name="y_size" value="1" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="controller" value="" />
	<input type="hidden" name="plot_enable_0" value="1" />
	<?php 
        echo JHTML::_('form.token');
        ?>

	<table class="plot_table">
	<tr>
		<td class="pright">
			<?php 
        echo $this->make_prompt('COM_PLOTALOT_NAME', 'COM_PLOTALOT_TOOLTIP_CHART_NAME');
        ?>
		</td>
		<td>
			<?php 
        echo '<input type="text" class="p_short" name="chart_name" id="chart_name" size="80" 
			maxlength="250" value="' . htmlspecialchars($this->chart_data->chart_name) . '" />';
        ?>
		</td>
	</tr>

	<tr>
		<td class="pright">
			<?php 
        echo $this->make_prompt('COM_PLOTALOT_DATABASE', 'COM_PLOTALOT_TOOLTIP_DB_NAME');
        ?>
		</td>
		<td>
				<?php 
        echo '<input type="text" class="p_short" name="db_name" size="18" maxlength="250" value="' . htmlspecialchars($this->chart_data->db_name) . '" />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_HOST', 'COM_PLOTALOT_TOOLTIP_DB_HOST');
        echo '<input type="text" class="p_short" name="db_host" size="10" maxlength="250" value="' . htmlspecialchars($this->chart_data->db_host) . '" />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_USER', 'COM_PLOTALOT_TOOLTIP_DB_USER');
        echo '<input type="text" class="p_short" name="db_user" size="10" maxlength="250" value="' . htmlspecialchars($this->chart_data->db_user) . '" ' . $autocomplete . ' />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_PASSWORD', 'COM_PLOTALOT_TOOLTIP_DB_USER');
        echo '<input type="password" class="p_short" name="db_pass" size="9" maxlength="250" value="' . $this->chart_data->db_pass . '" ' . $autocomplete . ' />';
        ?>
		</td>
	</tr>

	<tr>
		<td class="pright" style="vertical-align: top;">
			<?php 
        echo $this->make_prompt('COM_PLOTALOT_QUERY', 'COM_PLOTALOT_TOOLTIP_TABLE_QUERY');
        ?>
		</td>
		<td>
			<?php 
        if (isset($this->chart_data->plot_array[0]['query'])) {
            $query = $this->chart_data->plot_array[0]['query'];
        } else {
            $query = '';
        }
        echo '<textarea class="p_short" name="query[0]" rows="6" cols="100">' . htmlspecialchars($query) . '</textarea>';
        ?>
		</td>
	</tr>
	</table>

	</form>
	<?php 
        // if new, don't try to draw the chart
        if ($this->chart_data->id == 0) {
            return;
        }
        // create the item text
        $plotalot = new Plotalot();
        if ($this->chart_data->db_user == '-') {
            $this->chart_data->db_user = '';
        }
        $chart_html = $plotalot->drawChart($this->chart_data);
        // Show any errors
        if ($plotalot->error != '') {
            echo '<div class="plotalot_error">' . JText::_('COM_PLOTALOT_ERROR') . ': ' . $plotalot->error . '</div>';
        }
        if ($plotalot->warning != '') {
            echo '<div class="plotalot_error">' . JText::_('COM_PLOTALOT_WARNING') . ': ' . $plotalot->warning . '</div>';
        }
        // Output the text
        echo '<div style="float:left; margin-left:35px; padding:5px; border:2px solid black; background-color: white;">' . $chart_html . '</div>';
    }
Exemple #4
0
    function display($tpl = null)
    {
        JToolBarHelper::title(LAP_COMPONENT_NAME, 'plotalot.png');
        JToolBarHelper::custom('new_chart', 'chart.png', 'chart_f2.png', 'COM_PLOTALOT_NEW_CHART', false);
        if (version_compare(JVERSION, "3.0.0", "<")) {
            JToolBarHelper::custom('new_table', 'table.png', 'table_f2.png', 'COM_PLOTALOT_NEW_TABLE', false);
            JToolBarHelper::custom('new_item', 'item.png', 'item_f2.png', 'COM_PLOTALOT_NEW_ITEM', false);
            JToolBarHelper::custom('edit_css', 'css.png', 'css_f2.png', 'COM_PLOTALOT_CSS', false);
            if ($this->cache_count > 0) {
                JToolBarHelper::custom('clear_cache', 'remove.png', 'remove_f2.png', 'JGLOBAL_SUBMENU_CLEAR_CACHE', false);
            }
        } else {
            JToolBarHelper::custom('new_table', 'list.png', 'list_f2.png', 'COM_PLOTALOT_NEW_TABLE', false);
            JToolBarHelper::custom('new_item', 'pencil-2.png', 'pencil-2_f2.png', 'COM_PLOTALOT_NEW_ITEM', false);
            JToolBarHelper::custom('edit_css', 'edit.png', 'edit_f2.png', 'COM_PLOTALOT_CSS', false);
            if ($this->cache_count > 0) {
                JToolBarHelper::custom('clear_cache', 'file-remove.png', 'file-remove_f2.png', 'JGLOBAL_SUBMENU_CLEAR_CACHE', false);
            }
        }
        JToolBarHelper::unpublishList();
        JToolBarHelper::publishList();
        JToolBarHelper::deleteList();
        JToolBarHelper::preferences(LAP_COMPONENT, 350, 450);
        JToolBarHelper::custom('help', 'help.png', 'help_f2.png', 'JHELP', false);
        // if the table structure is incorrect, don't go any further
        if (!$this->check_table) {
            $app = JFactory::getApplication();
            $app->enqueueMessage(JText::_('COM_PLOTALOT_BAD_TABLE_STRUCTURE'), 'error');
            return;
        }
        // if the mysql_ functions are not supported, don't go any further
        if (!function_exists('mysql_connect')) {
            $app = JFactory::getApplication();
            $app->enqueueMessage(JText::_('COM_PLOTALOT_MYSQL_NOT_SUPPORTED'), 'error');
            return;
        }
        // get the current filter
        $app = JFactory::getApplication();
        $filter_state = $app->getUserStateFromRequest(LAP_COMPONENT . '.filter_state', 'filter_state', '', 'word');
        $filter_chart_type = $app->getUserStateFromRequest(LAP_COMPONENT . '.filter_chart_type', 'filter_chart_type', CHART_TYPE_ANY, 'int');
        // Create the state filter html
        $lists['state'] = JHtml::_('grid.state', $filter_state);
        $plotutil = new Plotalot_Utility();
        $lists['chart_type'] = LAP_view::make_list('filter_chart_type', $filter_chart_type, $plotutil->chart_categories, CHART_TYPE_ANY, 'onchange="submitform( );"');
        // get the order states
        $filter_order = $app->getUserStateFromRequest(LAP_COMPONENT . '.filter_order', 'filter_order', 'chart_name');
        $filter_order_Dir = $app->getUserStateFromRequest(LAP_COMPONENT . '.filter_order_Dir', 'filter_order_Dir', 'asc');
        $lists['order_Dir'] = $filter_order_Dir;
        $lists['order'] = $filter_order;
        // get the current Joomla database name
        $app = JFactory::getApplication();
        $website_database = $app->getCfg('db');
        $numrows = count($this->items);
        $check_all = 'onclick="Joomla.checkAll(this);"';
        $plotutil = new Plotalot_Utility();
        ?>
	<form action="index.php" method="get" name="adminForm" id="adminForm">

	<input type="hidden" name="option" value="<?php 
        echo LAP_COMPONENT;
        ?>
" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="controller" value="" />
	<input type="hidden" name="filter_order" value="<?php 
        echo $lists['order'];
        ?>
" />
	<input type="hidden" name="filter_order_Dir" value="<?php 
        echo $lists['order_Dir'];
        ?>
" />

	<div style="text-align:right">
		<?php 
        echo $lists['chart_type'];
        echo '&nbsp;';
        echo $lists['state'];
        ?>
	</div>
	
	<div id="editcell">
		<table class="adminlist table table-striped">
		<thead>
			<tr>
				<th width="5"><?php 
        echo JHtml::_('grid.sort', 'COM_PLOTALOT_ID', 'id', $lists['order_Dir'], $lists['order']);
        ?>
</th>
				<th width="20"><input type="checkbox" name="toggle" value="" <?php 
        echo $check_all;
        ?>
 /></th>			
				<th width="5%" class="title" nowrap="nowrap" colspan="2"><?php 
        echo JText::_('JPUBLISHED');
        ?>
</th>
				<th><?php 
        echo JHtml::_('grid.sort', 'COM_PLOTALOT_NAME', 'chart_name', $lists['order_Dir'], $lists['order']);
        ?>
</th>
				<th><?php 
        echo JHtml::_('grid.sort', 'COM_PLOTALOT_TYPE', 'chart_type', $lists['order_Dir'], $lists['order']);
        ?>
</th>
				<th><?php 
        echo JText::_('COM_PLOTALOT_PLOTS');
        ?>
</th>
				<th><?php 
        echo JHtml::_('grid.sort', 'COM_PLOTALOT_DATABASE', 'db_name', $lists['order_Dir'], $lists['order']);
        ?>
</th>
				<th><?php 
        echo JHtml::_('grid.sort', 'COM_PLOTALOT_CREATED', 'date_created', $lists['order_Dir'], $lists['order']);
        ?>
</th>
				<th><?php 
        echo JHtml::_('grid.sort', 'COM_PLOTALOT_UPDATED', 'date_updated', $lists['order_Dir'], $lists['order']);
        ?>
</th>
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="9"><?php 
        echo $this->pagination->getListFooter();
        ?>
</td>
			</tr>
		</tfoot>
		<?php 
        if ($this->items == null) {
            echo '</table></div></form>';
            return;
        }
        $k = 0;
        $n = count($this->items);
        for ($i = 0; $i < $n; $i++) {
            $row =& $this->items[$i];
            $checked = JHtml::_('grid.id', $i, $row->id);
            $link = JRoute::_(LAP_COMPONENT_LINK . '&task=edit&cid[]=' . $row->id);
            $icon = '';
            if ($row->sample_id > 0) {
                $icon = 'yellow_spot_16.png';
                // old 2.xx samples
                $state = JText::_('COM_PLOTALOT_OLD_SAMPLE');
            }
            if ($row->sample_id > 5) {
                $icon = 'blue_spot_16.png';
                // 3.xx samples
                $state = JText::_('COM_PLOTALOT_SAMPLE');
            }
            if ($row->sample_id == 0 and $row->state == 1) {
                $icon = 'red_bullet_16.png';
                // upgraded from 2.xx and not yet saved in 4.xx
                $state = JText::_('COM_PLOTALOT_STATE_UPGRADED');
            }
            if ($icon == '') {
                $status_image = '';
            } else {
                $status_image = '<span title="' . $state . '" class="hasTip"><img src="' . LAP_ADMIN_ASSETS_URL . $icon . '" alt="" /></span>';
            }
            $published = JHtml::_('grid.published', $row, $i);
            switch ($row->chart_type) {
                case CHART_TYPE_PL_TABLE:
                    $icon = 'c_table.gif';
                    break;
                case CHART_TYPE_GV_TABLE:
                    $icon = 'c_gv_table.gif';
                    break;
                case CHART_TYPE_SINGLE_ITEM:
                    $icon = 'c_item.gif';
                    break;
                case CHART_TYPE_LINE:
                    $icon = 'c_line.gif';
                    break;
                case CHART_TYPE_AREA:
                    $icon = 'c_area.gif';
                    break;
                case CHART_TYPE_GAUGE:
                    $icon = 'c_gauge.gif';
                    break;
                case CHART_TYPE_SCATTER:
                    $icon = 'c_scatter.gif';
                    break;
                case CHART_TYPE_BAR_H_STACK:
                case CHART_TYPE_BAR_H_GROUP:
                    $icon = 'c_bar_h.gif';
                    break;
                case CHART_TYPE_BAR_V_STACK:
                case CHART_TYPE_BAR_V_GROUP:
                    $icon = 'c_bar_v.gif';
                    break;
                case CHART_TYPE_PIE_2D:
                case CHART_TYPE_PIE_2D_V:
                    $icon = 'c_pie_2d.gif';
                    break;
                case CHART_TYPE_PIE_3D:
                case CHART_TYPE_PIE_3D_V:
                    $icon = 'c_pie_3d.gif';
                    break;
                case CHART_TYPE_TIMELINE:
                    $icon = 'c_timeline.gif';
                    break;
                case CHART_TYPE_BUBBLE:
                    $icon = 'c_bubble.gif';
                    break;
                case CHART_TYPE_COMBO_STACK:
                case CHART_TYPE_COMBO_GROUP:
                    $icon = 'c_combo.gif';
                    break;
                default:
                    $icon = 'c_unknown.gif';
            }
            $image_html = '<img src="' . LAP_ADMIN_ASSETS_URL . $icon . '" alt="" />';
            echo '<tr class="row' . $k . '">';
            echo '<td>' . $row->id . '</td>';
            echo '<td>' . $checked . '</td>';
            echo '<td align="center">' . $published . '</td>';
            echo '<td>' . $status_image . '</td>';
            echo '<td><a href="' . $link . '">' . $row->chart_name . '</a></td>';
            echo '<td>' . $image_html . ' ' . $plotutil->chartTypeName($row->chart_type) . '</td>';
            echo '<td style="text-align: center;">' . $row->num_plots . '</td>';
            if ($row->db_name == '') {
                echo '<td>' . JText::_('JSITE') . ' (' . $website_database . ')</td>';
            } else {
                echo '<td>' . $row->db_name . '</td>';
            }
            echo '<td>' . $row->date_created . '</td>';
            echo '<td>' . $row->date_updated . '</td>';
            echo '</tr>';
            $k = 1 - $k;
        }
        ?>
		</table>
	</div>

	</form>
	<?php 
    }
Exemple #5
0
    function display($tpl = null)
    {
        // the controller has already populated the data into $this->chart_data
        if ($this->chart_data->id == 0) {
            // creating a new record
            JToolBarHelper::title(LAP_COMPONENT_NAME . ': ' . JText::_('COM_PLOTALOT_NEW_CHART'), 'plotalot.png');
        } else {
            JToolBarHelper::title(LAP_COMPONENT_NAME . ': ' . JText::_('COM_PLOTALOT_EDIT_CHART') . ' ' . $this->chart_data->id, 'plotalot.png');
        }
        JToolBarHelper::apply();
        JToolBarHelper::save();
        if ($this->chart_data->id > 0) {
            JToolBarHelper::save2copy();
        }
        JToolBarHelper::cancel('cancel', 'JTOOLBAR_CLOSE');
        JToolBarHelper::preferences(LAP_COMPONENT, 350, 450);
        JToolBarHelper::custom('help', 'help.png', 'help_f2.png', 'JHELP', false);
        // load our front end css, if it exists
        LAP_view::load_styles();
        // are we coming back with a validation failure?
        if (isset($this->stored) and $this->stored === false) {
            $validation_failed = true;
        } else {
            $validation_failed = false;
        }
        // if we came back here as a result of the extra save button, scroll down so we can see the chart
        // - unless it was a validation failure, in which case we should stay at the top
        $document = JFactory::getDocument();
        $jinput = JFactory::getApplication()->input;
        $task = $jinput->get('task', '', 'STRING');
        // 'save' or 'apply'
        if ($task == 'apply2' and !$validation_failed) {
            $js = "\n window.addEvent('domready', function() {document.getElementById('chart_area').scrollIntoView();});";
            $document->addScriptDeclaration($js);
        }
        // get component parameters
        $params = JComponentHelper::getParams(LAP_COMPONENT);
        $this->tooltips = $params->get('tooltips', 1);
        $background = $params->get('background', 'FFFFFF');
        if (strcasecmp($background, 'transparent') != 0 and $background[0] != '#') {
            $background = '#' . $background;
        }
        if ($params->get('autocomplete', 1)) {
            $autocomplete = 'autocomplete="off"';
            if (empty($this->chart_data->db_user)) {
                // some browsers don't respect autocomplete="off"
                $this->chart_data->db_user = '******';
            }
            // the model will intercept this and remove it
        } else {
            $autocomplete = '';
        }
        // load the Javascript that hides and enables the chart type dependent fields
        // it is called by the 'domready' function and the 'onchange' function of the chart type list selector
        $document->addScript(JURI::base(true) . '/components/com_plotalot/assets/chart_edit.js?2');
        $dom_ready = "\nwindow.addEvent('domready', function() {plotalot_fields(" . $this->chart_data->chart_type . ");});\n";
        $document->addScriptDeclaration($dom_ready);
        // make objects
        $plotalot = new Plotalot();
        $plotutil = new Plotalot_Utility();
        // make the chart type list
        $chart_type_list = LAP_view::make_list('chart_type', $this->chart_data->chart_type, $plotutil->chart_types, CHART_TYPE_LINE, 'onchange="plotalot_fields(this.value)"');
        // build the form
        ?>
	<form action="index.php" method="post" name="adminForm" id="adminForm" <?php 
        echo $autocomplete;
        ?>
 >

	<input type="hidden" name="option" value="<?php 
        echo LAP_COMPONENT;
        ?>
" />
	<input type="hidden" name="id" value="<?php 
        echo $this->chart_data->id;
        ?>
" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="controller" value="" />

	<table class="plot_table">
	<tr>
	<td width="50%" class="ptop">
		<fieldset class="adminform plotalot_form"><legend><?php 
        echo JText::_('COM_PLOTALOT_CHART');
        ?>
</legend>
		<table class="plot_table">
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_NAME', 'COM_PLOTALOT_TOOLTIP_CHART_NAME');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long" name="chart_name" maxlength="250" value="' . htmlspecialchars($this->chart_data->chart_name) . '" />';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_TYPE');
        ?>
			</td>
			<td>
				<?php 
        echo $chart_type_list;
        echo '<span class="pjh_all pjh_legend_type" >';
        echo ' ' . JText::_('COM_PLOTALOT_LEGEND');
        echo LAP_view::make_list('legend_type', $this->chart_data->legend_type, $plotutil->legendTypes);
        echo '</span>';
        echo '<span class="pjh_all pjh_chart_option_pie" >';
        echo ' ' . JText::_('COM_PLOTALOT_PIE_TEXT_TYPE');
        echo LAP_view::make_list('pie_chart_option', $this->chart_data->chart_option, $plotutil->pieTextTypes);
        echo '</span>';
        echo '<span class="pjh_all pjh_chart_option_bar" >';
        echo ' ' . LAP_view::make_checkbox('bar_chart_option', $this->chart_data->chart_option, JText::_('COM_PLOTALOT_ORDERED'));
        echo '</span>';
        ?>
			</td>
		</tr>
		
		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_SIZE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short" name="x_size" size="8" 
					value="' . $this->chart_data->x_size . '" />';
        echo ' x ';
        echo '<input type="text" class="p_short" name="y_size" size="8" 
					value="' . $this->chart_data->y_size . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_TITLE', 'COM_PLOTALOT_TOOLTIP_TITLE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short pjd_all pjd_chart_title" name="chart_title" size="60" maxlength="2000" value="';
        echo htmlspecialchars($this->chart_data->chart_title) . '" />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_COLOUR', 'COM_PLOTALOT_TOOLTIP_COLOUR') . ' ';
        echo '<input type="text" class="p_short pjd_all pjd_chart_title color {required:false}" name="chart_title_colour" size="6" value="' . $this->chart_data->chart_title_colour . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_BACKGROUND', 'COM_PLOTALOT_TOOLTIP_COLOUR');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short color {required:false}" name="back_colour" size="6" value="' . $this->chart_data->back_colour . '" />';
        echo '<span class="pjh_all pjh_show_grid" >';
        echo ' ' . LAP_view::make_checkbox('show_grid', $this->chart_data->show_grid, $this->make_prompt('COM_PLOTALOT_GRID', 'COM_PLOTALOT_TOOLTIP_GRID'));
        echo '</span>';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_DATABASE', 'COM_PLOTALOT_TOOLTIP_DB_NAME');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short" name="db_name" size="18" maxlength="250" value="' . htmlspecialchars($this->chart_data->db_name) . '" />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_HOST', 'COM_PLOTALOT_TOOLTIP_DB_HOST');
        echo '<input type="text" class="p_short" name="db_host" size="10" maxlength="250" value="' . htmlspecialchars($this->chart_data->db_host) . '" />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_USER', 'COM_PLOTALOT_TOOLTIP_DB_USER');
        echo '<input type="text" class="p_short" name="db_user" size="10" maxlength="250" value="' . htmlspecialchars($this->chart_data->db_user) . '" ' . $autocomplete . ' />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_PASSWORD', 'COM_PLOTALOT_TOOLTIP_DB_USER');
        echo '<input type="password" class="p_short" name="db_pass" size="9" maxlength="250" value="' . $this->chart_data->db_pass . '" ' . $autocomplete . ' />';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright ptop">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_EXTRA_PARAMS', 'COM_PLOTALOT_TOOLTIP_EXTRA_PARAMS');
        ?>
			</td>
			<td>
				<?php 
        echo '<textarea class="p_long" name="extra_parms" rows="1">' . htmlspecialchars($this->chart_data->extra_parms) . '</textarea>';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright ptop">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_EXTRA_COLUMNS', 'COM_PLOTALOT_TOOLTIP_EXTRA_COLUMNS');
        ?>
			</td>
			<td>
				<?php 
        echo '<textarea class="p_long" name="extra_columns" rows="1">' . htmlspecialchars($this->chart_data->extra_columns) . '</textarea>';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_NUM_PLOTS', 'COM_PLOTALOT_TOOLTIP_NUM_PLOTS');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short pjd_all pjd_num_plots" size="5" name="num_plots" value = "' . $this->chart_data->num_plots . '" />';
        echo ' ' . LAP_view::make_checkbox('sort_plots', false, $this->make_prompt('COM_PLOTALOT_SORT_PLOTS', 'COM_PLOTALOT_TOOLTIP_SORT_PLOTS'));
        echo ' ' . LAP_view::make_checkbox('show_raw_data', $this->chart_data->show_raw_data, $this->make_prompt('COM_PLOTALOT_SHOW_RAW', 'COM_PLOTALOT_TOOLTIP_SHOW_RAW'));
        echo ' ' . LAP_view::make_checkbox('show_script', $this->chart_data->show_script, $this->make_prompt('COM_PLOTALOT_SHOW_SCRIPT', 'COM_PLOTALOT_TOOLTIP_SHOW_SCRIPT'));
        ?>
			</td>
		</tr>
		</table>
		</fieldset>
	</td>
	<td width="50%" class="ptop">
		<fieldset class="adminform plotalot_form"><legend><?php 
        echo JText::_('COM_PLOTALOT_AXES');
        ?>
</legend>
		<table class="plot_table">
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_X_TITLE', 'COM_PLOTALOT_TOOLTIP_X_TITLE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long pjd_all pjd_xy_titles" name="x_title" maxlength="2000" value="';
        echo htmlspecialchars($this->chart_data->x_title) . '" />';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_X_START', 'COM_PLOTALOT_TOOLTIP_X_START');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long pjd_all pjd_x_params" name="x_start" maxlength="2000" value="';
        echo htmlspecialchars($this->chart_data->x_start) . '" />';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_X_END', 'COM_PLOTALOT_TOOLTIP_X_END');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long pjd_all pjd_x_params" name="x_end" maxlength="2000" value="';
        echo htmlspecialchars($this->chart_data->x_end) . '" />';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_X_NUM_LABELS', 'COM_PLOTALOT_TOOLTIP_X_NUM_LABELS');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short pjd_all pjd_x_params" size="5" name="x_labels" value = "' . $this->chart_data->x_labels . '" />';
        echo '<span class="pjh_all pjh_x_format" >';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_X_LABEL_FORMAT', 'COM_PLOTALOT_TOOLTIP_X_FORMAT') . ' ';
        echo LAP_view::make_list('x_format', $this->chart_data->x_format, $plotutil->xDataFormats, FORMAT_NONE);
        echo '</span>';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_Y_TITLE', 'COM_PLOTALOT_TOOLTIP_Y_TITLE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long pjd_all pjd_xy_titles" name="y_title" maxlength="2000" value="';
        echo htmlspecialchars($this->chart_data->y_title) . '" />';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_Y_START', 'COM_PLOTALOT_TOOLTIP_Y_START');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long pjd_all pjd_y_params" name="y_start" maxlength="2000" value="';
        echo htmlspecialchars($this->chart_data->y_start) . '" />';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_Y_END', 'COM_PLOTALOT_TOOLTIP_Y_END');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long pjd_all pjd_y_params" name="y_end" maxlength="2000" value="';
        echo htmlspecialchars($this->chart_data->y_end) . '" />';
        ?>
			</td>
		</tr>
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_Y_NUM_LABELS', 'COM_PLOTALOT_TOOLTIP_Y_NUM_LABELS');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short pjd_all pjd_y_labels" size="5" name="y_labels" value = "' . $this->chart_data->y_labels . '" />';
        echo '<span class="pjh_all pjh_y_format" >';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_Y_LABEL_FORMAT', 'COM_PLOTALOT_TOOLTIP_Y_FORMAT') . ' ';
        echo LAP_view::make_list('y_format', $this->chart_data->y_format, $plotutil->yDataFormats, FORMAT_NONE);
        echo '</span>';
        ?>
			</td>
		</tr>
		</table>
		</fieldset>
	</td>
	</tr>
	</table>

	<?php 
        // the plots array
        for ($i = 0; $i < $this->chart_data->num_plots; $i++) {
            if (!isset($this->chart_data->plot_array[$i]['legend'])) {
                $this->chart_data->plot_array[$i]['legend'] = '';
            }
            if (!isset($this->chart_data->plot_array[$i]['colour'])) {
                $this->chart_data->plot_array[$i]['colour'] = '';
            }
            if (!isset($this->chart_data->plot_array[$i]['style'])) {
                $this->chart_data->plot_array[$i]['style'] = 0;
            }
            $this->chart_data->plot_array[$i]['style'] = $plotalot->checkPlotStyle($this->chart_data->chart_type, $this->chart_data->plot_array[$i]['style']);
            if (!isset($this->chart_data->plot_array[$i]['query'])) {
                $this->chart_data->plot_array[$i]['query'] = '';
            }
            if (!isset($this->chart_data->plot_array[$i]['enable'])) {
                // if not present ..
                $this->chart_data->plot_array[$i]['enable'] = false;
            }
            // .. plot is disabled
            if ($this->chart_data->plot_array[$i]['legend'] == '' and $this->chart_data->plot_array[$i]['query'] == '') {
                $this->chart_data->plot_array[$i]['enable'] = true;
            }
            // make new plots enabled
            echo "\n\n" . '<div><fieldset class="adminform plotalot_form"><legend>' . JText::_('COM_PLOTALOT_PLOT') . ' ' . ($i + 1) . '</legend>';
            echo '<table width="100%"><tr>';
            echo '<td style="width:20%; vertical-align:top;">';
            echo "\n" . '<table>';
            echo "\n" . '<tr><td>' . $this->make_prompt('COM_PLOTALOT_NAME', 'COM_PLOTALOT_TOOLTIP_PLOT_NAME') . '</td>';
            echo '<td><input type="text" class="p_short" size="25" name="legend[' . $i . ']" value = "' . htmlspecialchars($this->chart_data->plot_array[$i]['legend']) . '" /></td>';
            echo '</tr>';
            echo "\n" . '<tr><td>' . $this->make_prompt('COM_PLOTALOT_COLOUR', 'COM_PLOTALOT_TOOLTIP_COLOUR') . '</td>';
            echo '<td><input type="text" class="p_short color {required:false}" name="colour[' . $i . ']" size="6" value="' . $this->chart_data->plot_array[$i]['colour'] . '" /></td>';
            echo '</tr>';
            echo "\n" . '<tr class="pjh_all pjh_plot_style_pie"><td>' . $this->make_prompt('COM_PLOTALOT_STYLE', 'COM_PLOTALOT_TOOLTIP_PLOT_STYLE') . '</td>';
            echo '<td>' . LAP_view::make_list("pie_style[{$i}]", $this->chart_data->plot_array[$i]['style'], $plotutil->lineStylesPie) . '</td>';
            echo '</tr>';
            echo "\n" . '<tr class="pjh_all pjh_plot_style_line"><td>' . $this->make_prompt('COM_PLOTALOT_STYLE', 'COM_PLOTALOT_TOOLTIP_PLOT_STYLE') . '</td>';
            echo '<td>' . LAP_view::make_list("line_style[{$i}]", $this->chart_data->plot_array[$i]['style'], $plotutil->lineStylesLine) . '</td>';
            echo '</tr>';
            echo "\n" . '<tr class="pjh_all pjh_plot_type"><td>' . JText::_('COM_PLOTALOT_TYPE') . '</td>';
            echo '<td>' . LAP_view::make_list("plot_type[{$i}]", $this->chart_data->plot_array[$i]['style'], $plotutil->comboPlotTypes) . '</td>';
            echo '</tr>';
            echo "\n" . '<tr><td>' . $this->make_prompt('COM_PLOTALOT_ENABLE', 'COM_PLOTALOT_TOOLTIP_PLOT_ENABLE') . '</td>';
            echo '<td>' . LAP_view::make_checkbox("enable[{$i}]", $this->chart_data->plot_array[$i]['enable']) . '</td>';
            echo '</tr>';
            echo "\n" . '</table>';
            echo '</td>';
            // width:20%
            echo "\n<td>";
            echo LAP_view::make_info(JText::_('COM_PLOTALOT_TOOLTIP_PLOT_QUERY'), '', 'style="float:left";');
            echo '<textarea class="p_long" name="query[' . $i . ']" rows="5" style="white-space:normal !important; word-wrap:normal !important;">' . htmlspecialchars($this->chart_data->plot_array[$i]['query']) . '</textarea>';
            echo '</td>';
            echo '</tr></table>';
            echo '</fieldset></div>';
        }
        ?>

	</form>
	<?php 
        // if new, don't try to draw the chart
        if ($this->chart_data->id == 0) {
            return;
        }
        // if validation failed in the model, don't try to draw the chart
        if ($validation_failed) {
            return;
        }
        // create the chart	script
        if ($this->chart_data->db_user == '-') {
            $this->chart_data->db_user = '';
        }
        $chart_script = $plotalot->drawChart($this->chart_data);
        // Show any errors
        echo '<div id="error_msg" class="plotalot_error" style="margin-bottom:5px;"></div>';
        // place for any Javascript errors
        if ($plotalot->error != '') {
            echo '<div class="plotalot_error">' . JText::_('COM_PLOTALOT_ERROR') . ': ' . $plotalot->error . '</div>';
        }
        if ($plotalot->warning != '') {
            echo '<div class="plotalot_error">' . JText::_('COM_PLOTALOT_WARNING') . ': ' . $plotalot->warning . '</div>';
        }
        // add an error handler to catch any Javascript errors
        $error_handler = "\n window.onerror = function(message, url, linenumber) {\n\t    setTimeout(function() {document.getElementById('error_msg').innerHTML = '" . JText::_('COM_PLOTALOT_JAVASCRIPT_ERROR') . "'+': '+message;}, 200); };";
        $document->addScriptDeclaration($error_handler);
        // put the chart script into the document header
        $document->addScript("https://www.google.com/jsapi");
        $document->addCustomTag($chart_script);
        // the place for the Google javascript to draw in, and an extra save button
        // if the chart is responsive, make the chart container an arbitrary 640 x 480
        // if not, let the chart define the size of the container
        if (empty($this->chart_data->x_size)) {
            $styles = 'width:500px; height:300px; ';
        } else {
            $styles = 'height:' . $this->chart_data->y_size . 'px; width:' . $this->chart_data->x_size . 'px; ';
        }
        echo "\n" . '<div>';
        echo "\n" . '<div id="chart_area" style="' . $styles . 'float:left; border:1px solid lightgray;">';
        $chart_id = $this->chart_data->id;
        echo '<span id="chart_' . $chart_id . '" style="' . $styles . 'float:left; background-color:' . $background . '"></span>';
        echo '</div>';
        echo self::save_button();
        echo '</div>';
        // if show raw data was selected, show each plot as a table of up to 20 rows
        if ($this->chart_data->show_raw_data) {
            echo '<div style="clear:left;"></div>';
            echo '<h3>' . JText::_('COM_PLOTALOT_SHOW_RAW') . '</h3>';
            $this->chart_data->chart_type = CHART_TYPE_PL_TABLE;
            $this->chart_data->chart_css_style = 'border="1" cellspacing="0" cellpadding="2"';
            $this->chart_data->y_labels = 20;
            for ($p = 0; $p < $this->chart_data->num_plots; $p++) {
                echo '<div style="float:left; margin:5px;">';
                if (empty($this->chart_data->plot_array[$p]['enable'])) {
                    continue;
                }
                if (!$this->chart_data->plot_array[$p]['enable']) {
                    // plot is disabled
                    continue;
                }
                if ($this->chart_data->plot_array[$p]['query'] == '') {
                    // no query
                    continue;
                }
                $this->chart_data->plot_array[0]['query'] = $this->chart_data->plot_array[$p]['query'];
                // table query is always plot zero
                $this->chart_data->chart_title = JText::_('COM_PLOTALOT_RAW_DATA') . ', ' . JText::_('COM_PLOTALOT_PLOT') . ' ' . ($p + 1) . " (" . $this->chart_data->plot_array[$p]['legend'] . ")";
                $chart_html = $plotalot->drawChart($this->chart_data, true);
                // draw table but do not overwrite chart trace
                echo $chart_html;
                echo '';
            }
        }
        // if show script was selected, show it
        if ($this->chart_data->show_script) {
            $viewable_script = str_replace("\n<script type=\"text/javascript\">\n", '', $chart_script);
            $viewable_script = str_replace('</script>', '', $viewable_script);
            echo '<div style="clear:left;"></div>';
            echo '<h3>' . JText::_('COM_PLOTALOT_SHOW_SCRIPT') . '</h3>';
            echo '<pre>';
            echo $viewable_script;
            echo '</pre>';
        }
    }
Exemple #6
0
    function display($tpl = null)
    {
        global $chart_types;
        if ($this->chart_data->id == 0) {
            // creating a new record
            JToolBarHelper::title(LAP_COMPONENT_NAME . ': ' . JText::_('COM_PLOTALOT_NEW_TABLE'), 'plotalot.png');
        } else {
            JToolBarHelper::title(LAP_COMPONENT_NAME . ': ' . JText::_('COM_PLOTALOT_EDIT_TABLE') . ' ' . $this->chart_data->id, 'plotalot.png');
        }
        JToolBarHelper::apply();
        JToolBarHelper::save();
        if ($this->chart_data->id > 0) {
            JToolBarHelper::save2copy();
        }
        JToolBarHelper::cancel('cancel', 'JTOOLBAR_CLOSE');
        JToolBarHelper::preferences(LAP_COMPONENT, 350, 450);
        JToolBarHelper::custom('help', 'help.png', 'help_f2.png', 'JHELP', false);
        // load our front end css, if it exists
        LAP_view::load_styles();
        // get component parameters
        $params = JComponentHelper::getParams(LAP_COMPONENT);
        $this->tooltips = $params->get('tooltips', 1);
        $background = $params->get('background', 'FFFFFF');
        if (strcasecmp($background, 'transparent') != 0 and $background[0] != '#') {
            $background = '#' . $background;
        }
        if ($params->get('autocomplete', 1)) {
            $autocomplete = 'autocomplete="off"';
            if (empty($this->chart_data->db_user)) {
                // some browsers don't respect autocomplete="off"
                $this->chart_data->db_user = '******';
            }
            // the model will intercept this and remove it
        } else {
            $autocomplete = '';
        }
        $this->default_styles();
        // make the Javascript that hides and enables the chart type dependent fields
        // it is called by the 'domready' function and the 'onchange' function of the chart type list selector
        $js = self::javascript();
        $document = JFactory::getDocument();
        $document->addScriptDeclaration($js);
        $dom_ready = "\nwindow.addEvent('domready', function() {plotalot_fields(" . $this->chart_data->chart_type . ");});\n";
        $document->addScriptDeclaration($dom_ready);
        // make the chart type list
        $plotutil = new Plotalot_Utility();
        $chart_type_list = LAP_view::make_list('chart_type', $this->chart_data->chart_type, $plotutil->table_types, 0, 'onchange="plotalot_fields(this.value)"');
        ?>
	<form action="index.php" method="post" name="adminForm" id="adminForm" <?php 
        echo $autocomplete;
        ?>
 >

	<input type="hidden" name="option" value="<?php 
        echo LAP_COMPONENT;
        ?>
" />
	<input type="hidden" name="id" value="<?php 
        echo $this->chart_data->id;
        ?>
" />
	<input type="hidden" name="chart_type" value="<?php 
        echo $this->chart_data->chart_type;
        ?>
" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="controller" value="" />
	<input type="hidden" name="plot_enable_0" value="1" />
	<?php 
        echo JHTML::_('form.token');
        ?>

	<table class="plot_table">
	<tr>
	<td width="50%" class="ptop">
		<fieldset class="adminform plotalot_form"><legend><?php 
        echo JText::_('COM_PLOTALOT_CHART_TYPE_TABLE');
        ?>
</legend>
		<table cellspacing="0" width="100%">
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_NAME', 'COM_PLOTALOT_TOOLTIP_CHART_NAME');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short" name="chart_name" size="40" 
					maxlength="250" value="' . htmlspecialchars($this->chart_data->chart_name) . '" />';
        echo ' ' . JText::_('COM_PLOTALOT_TYPE') . ' ';
        echo $chart_type_list;
        echo '<span id="pl_col_heads">';
        echo ' ';
        echo LAP_view::make_checkbox('legend_type', $this->chart_data->legend_type, $this->make_prompt('COM_PLOTALOT_COL_HEADINGS', 'COM_PLOTALOT_TOOLTIP_TABLE_HEADINGS'));
        echo '</span>';
        ?>
			</td>
		</tr>

		<tr id="gv_sizes">
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_SIZE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short" name="x_size" size="8" 
					value="' . $this->chart_data->x_size . '" />';
        echo ' x ';
        echo '<input type="text" class="p_short" name="y_size" size="8" 
					value="' . $this->chart_data->y_size . '" />';
        echo ' ';
        echo LAP_view::make_checkbox('chart_option', $this->chart_data->chart_option, JText::_('COM_PLOTALOT_ROW_NUMBERS'));
        ?>
			</td>
		</tr>

		<tr id="pl_title">
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_TITLE', 'COM_PLOTALOT_TOOLTIP_TITLE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long" name="chart_title" maxlength="2000" value="';
        echo htmlspecialchars($this->chart_data->chart_title) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_DATABASE', 'COM_PLOTALOT_TOOLTIP_DB_NAME');
        ?>
			</td>
			<td>
					<?php 
        echo '<input type="text" class="p_short" name="db_name" size="18" maxlength="250" value="' . htmlspecialchars($this->chart_data->db_name) . '" />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_HOST', 'COM_PLOTALOT_TOOLTIP_DB_HOST');
        echo '<input type="text" class="p_short" name="db_host" size="10" maxlength="250" value="' . htmlspecialchars($this->chart_data->db_host) . '" />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_USER', 'COM_PLOTALOT_TOOLTIP_DB_USER');
        echo '<input type="text" class="p_short" name="db_user" size="10" maxlength="250" value="' . htmlspecialchars($this->chart_data->db_user) . '" ' . $autocomplete . ' />';
        echo ' ' . $this->make_prompt('COM_PLOTALOT_PASSWORD', 'COM_PLOTALOT_TOOLTIP_DB_USER');
        echo '<input type="password" class="p_short" name="db_pass" size="9" maxlength="250" value="' . $this->chart_data->db_pass . '" ' . $autocomplete . ' />';
        ?>
			</td>
		</tr>
		
		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_MAX_ROWS', 'COM_PLOTALOT_TOOLTIP_TABLE_MAX_ROWS');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_short" name="y_labels" size="10" 
				maxlength="10" value="' . $this->chart_data->y_labels . '" />';
        ?>
			</td>
		</tr>
		
		<tr id="gv_extra_params">
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_EXTRA_PARAMS', 'COM_PLOTALOT_TOOLTIP_EXTRA_PARAMS');
        ?>
			</td>
			<td>
				<?php 
        echo '<textarea name="extra_parms" rows="1" style="width:97% !important;">' . htmlspecialchars($this->chart_data->extra_parms) . '</textarea>';
        ?>
			</td>
		</tr>

		</table>
		</fieldset>
	</td>
	<td width="50%" class="ptop">
		<fieldset class="adminform plotalot_form"><legend><?php 
        echo JText::_('COM_PLOTALOT_CLASSES');
        ?>
</legend>
		<table width="100%" id="pl_styles">

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_TABLE_STYLE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long" name="style_pl_table" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['pl_table']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_TITLE_ROW_STYLE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long" name="style_pl_title" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['pl_title']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_HEADING_ROW_STYLE');
        ?>
			</td>
			<td>
				<?php 
        echo ' <input type="text" class="p_long" name="style_pl_head" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['pl_head']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_TABLE_ODD_STYLE', 'COM_PLOTALOT_TOOLTIP_TABLE_ODD');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long" name="style_pl_odd" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['pl_odd']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo $this->make_prompt('COM_PLOTALOT_TABLE_EVEN_STYLE', 'COM_PLOTALOT_TOOLTIP_TABLE_EVEN');
        ?>
			</td>
			<td>
				<?php 
        echo ' <input type="text" class="p_long" name="style_pl_even" 
				maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['pl_even']) . '" />';
        ?>
			</td>
		</tr>

		</table>

		<table width="100%" id="gv_styles">

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_HEADING_ROW_STYLE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long" name="style_gv_head" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['gv_head']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_TABLE_ODD_STYLE');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long" name="style_gv_odd" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['gv_odd']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_TABLE_ROW');
        ?>
			</td>
			<td>
				<?php 
        echo ' <input type="text" class="p_long" name="style_gv_row" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['gv_row']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_SELECTED_ROW');
        ?>
			</td>
			<td>
				<?php 
        echo '<input type="text" class="p_long" name="style_gv_selected" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['gv_selected']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_HOVER_ROW');
        ?>
			</td>
			<td>
				<?php 
        echo ' <input type="text" class="p_long" name="style_gv_hover" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['gv_hover']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_HEADER_CELL');
        ?>
			</td>
			<td>
				<?php 
        echo ' <input type="text" class="p_long" name="style_gv_hcell" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['gv_hcell']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_TABLE_CELL');
        ?>
			</td>
			<td>
				<?php 
        echo ' <input type="text" class="p_long" name="style_gv_tcell" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['gv_tcell']) . '" />';
        ?>
			</td>
		</tr>

		<tr>
			<td class="pright">
				<?php 
        echo JText::_('COM_PLOTALOT_NUMBER_CELL');
        ?>
			</td>
			<td>
				<?php 
        echo ' <input type="text" class="p_long" name="style_gv_numcell" 
					maxlength="255" value="' . htmlspecialchars($this->chart_data->style_array['gv_numcell']) . '" />';
        ?>
			</td>
		</tr>

		</table>

		</fieldset>
	</td>
	</tr>
	</table>
	
	<div><fieldset class="adminform plotalot_form">
	<table cellspacing="0" width="100%">
	<tr>
		<td class="pright" style="vertical-align: top; width:8%;">
			<?php 
        echo $this->make_prompt('COM_PLOTALOT_QUERY', 'COM_PLOTALOT_TOOLTIP_TABLE_QUERY');
        ?>
		</td>
		<td>
			<?php 
        if (isset($this->chart_data->plot_array[0]['query'])) {
            $query = $this->chart_data->plot_array[0]['query'];
        } else {
            $query = '';
        }
        echo '<textarea name="query[0]" rows="8" style="width:97% !important;">' . htmlspecialchars($query) . '</textarea>';
        ?>
		</td>
	</tr>
	</table>
	</fieldset></div>

	
	<div class="clr"></div>

	</form>
	<?php 
        // if new, don't try to draw the chart
        if ($this->chart_data->id == 0) {
            return;
        }
        // create the table	script or html
        $plotalot = new Plotalot();
        if ($this->chart_data->db_user == '-') {
            $this->chart_data->db_user = '';
        }
        $chart_text = $plotalot->drawChart($this->chart_data);
        // Show any errors
        echo '<div id="error_msg" class="plotalot_error"></div>';
        // place for any Javascript errors
        if ($plotalot->error != '') {
            echo '<div class="plotalot_error">' . JText::_('COM_PLOTALOT_ERROR') . ': ' . $plotalot->error . '</div>';
        }
        if ($plotalot->warning != '') {
            echo '<div class="plotalot_error">' . JText::_('COM_PLOTALOT_WARNING') . ': ' . $plotalot->warning . '</div>';
        }
        // add an error handler to catch any Javascript errors
        $error_handler = "window.onerror = function(message, url, linenumber) {\n\t    setTimeout(function() {document.getElementById('error_msg').innerHTML = '" . JText::_('COM_PLOTALOT_JAVASCRIPT_ERROR') . "'+': '+message;}, 200); };";
        $document = JFactory::getDocument();
        $document->addScriptDeclaration($error_handler);
        // for Plotalot tables, draw the image html
        if ($this->chart_data->chart_type == CHART_TYPE_PL_TABLE) {
            echo '<div>';
            $chart_id = $this->chart_data->id;
            echo '<span style="float:left; background-color:' . $background . '">' . $chart_text . '</span>';
            echo '</div>';
            // echo '<div style="background-color:'.$background.'"></div>';
            return;
        }
        // for Google tables, load the scripts
        if ($this->chart_data->chart_type == CHART_TYPE_GV_TABLE) {
            $document = JFactory::getDocument();
            $document->addScript("https://www.google.com/jsapi");
            $document->addCustomTag($chart_text);
            $chart_id = $this->chart_data->id;
            echo '<div>';
            $chart_id = $this->chart_data->id;
            echo '<span id="chart_' . $chart_id . '" style="float:left; background-color:' . $background . '"></span>';
            echo '</div>';
        }
    }