/**
  * Decodes and prepare all config structures
  *
  */
 function prepare_config()
 {
     $this->sql = $this->config->query;
     // output from query
     $outputfields = explode(';', @$this->config->outputfields);
     $outputlabels = explode(';', @$this->config->fieldlabels);
     $outputformats = explode(';', @$this->config->outputformats);
     dashboard_normalize($outputfields, $outputlabels);
     // normalizes labels to keys
     dashboard_normalize($outputfields, $outputformats);
     // normalizes labels to keys
     $this->output = array_combine($outputfields, $outputlabels);
     $this->outputf = array_combine($outputfields, $outputformats);
     // filtering query
     $outputfilters = explode(';', @$this->config->filters);
     $outputfilterlabels = explode(';', @$this->config->filterlabels);
     dashboard_normalize($outputfilters, $outputfilterlabels);
     // normalizes labels to keys
     $this->filterfields = new StdClass();
     $this->filterfields->labels = array_combine($outputfilters, $outputfilterlabels);
     $outputfilterdefaults = explode(';', @$this->config->filterdefaults);
     dashboard_normalize($outputfilters, $outputfilterdefaults);
     // normalizes defaults to keys
     $this->filterfields->defaults = array_combine($outputfilters, $outputfilterdefaults);
     $outputfilteroptions = explode(';', @$this->config->filteroptions);
     dashboard_normalize($outputfilters, $outputfilteroptions);
     // normalizes options to keys
     $this->filterfields->options = array_combine($outputfilters, $outputfilteroptions);
     $outputfilterqueries = explode(';', @$this->config->filterqueries);
     dashboard_normalize($outputfilters, $outputfilterqueries);
     // normalizes options to keys
     $this->filterfields->queries = array_combine($outputfilters, $outputfilterqueries);
     // Detect translated
     $translatedfilters = array();
     $filterfields = array();
     foreach ($outputfilters as $f) {
         if (preg_match('/^(.*) as (.*)$/si', $f, $matches)) {
             $translatedfilters[$f] = $matches[2];
             $filterfields[$matches[2]] = $matches[1];
             $translatedfilters[$matches[2]] = $f;
         }
     }
     $this->filterfields->translations = $translatedfilters;
     $this->filterfields->filtercanonicalfield = $filterfields;
     // tabular params
     $vkeys = explode(";", @$this->config->verticalkeys);
     $vformats = explode(";", @$this->config->verticalformats);
     $vlabels = explode(";", @$this->config->verticallabels);
     dashboard_normalize($vkeys, $vformats);
     // normalizes formats to keys
     dashboard_normalize($vkeys, $vlabels);
     // normalizes labels to keys
     $this->vertkeys = new StdClass();
     $this->vertkeys->formats = array_combine($vkeys, $vformats);
     $this->vertkeys->labels = array_combine($vkeys, $vlabels);
     // treeview params
     $parentserie = @$this->config->parentserie;
     $treeoutputfields = explode(';', @$this->config->treeoutput);
     $treeoutputformats = explode(';', @$this->config->treeoutputformats);
     dashboard_normalize($treeoutputfields, $treeoutputformats);
     // normailzes labels to keys
     $this->treeoutput = array_combine($treeoutputfields, $treeoutputformats);
     // summators
     $numsums = explode(';', @$this->config->numsums);
     $numsumlabels = explode(';', @$this->config->numsumlabels);
     $numsumformats = explode(';', @$this->config->numsumformats);
     dashboard_normalize($numsums, $numsumlabels);
     // normailzes labels to keys
     dashboard_normalize($numsums, $numsumformats);
     // normailzes labels to keys
     $this->outputnumsums = array_combine($numsums, $numsumlabels);
     $this->numsumsf = array_combine($numsums, $numsumformats);
     // graph params
     $yseries = explode(';', @$this->config->yseries);
     $yseriesformats = explode(';', @$this->config->yseriesformats);
     dashboard_normalize($yseries, $yseriesformats);
     // normalizes labels to keys
     $this->yseriesf = array_combine($yseries, $yseriesformats);
     // coloring params
     $this->colourcoding = dashboard_prepare_colourcoding($this->config);
     // prepare user params definitions
     for ($i = 1; $i < 5; $i++) {
         $varkey = 'sqlparamvar' . $i;
         $labelkey = 'sqlparamlabel' . $i;
         $typekey = 'sqlparamtype' . $i;
         $valueskey = 'sqlparamvalues' . $i;
         if (!empty($this->config->{$varkey})) {
             $uparam = new StdClass();
             $uparam->key = $this->config->{$varkey};
             $uparam->label = $this->config->{$labelkey};
             $uparam->type = $this->config->{$typekey};
             $uparam->values = $this->config->{$valueskey};
             $uparam->ashaving = dashboard_guess_is_alias($this, $uparam->key);
             $this->params[$uparam->key] = $uparam;
         }
     }
 }
Ejemplo n.º 2
0
function dashboard_prepare_colourcoding(&$config)
{
    $colorcoding = array();
    if (!empty($config->colorfield)) {
        $colors = explode("\n", @$config->colors);
        $colorvalues = explode("\n", @$config->coloredvalues);
        dashboard_normalize($colorvalues, $colors);
        // normailzes options to keys
        $colorcoding = array_combine($colorvalues, $colors);
    }
    return $colorcoding;
}