Esempio n. 1
0
 /**
   Check for input and display the page
 */
 function drawPage()
 {
     if (!$this->config instanceof FannieConfig) {
         $this->config = FannieConfig::factory();
     }
     if (!$this->checkAuth() && $this->must_authenticate) {
         $this->loginRedirect();
     } elseif ($this->preprocess()) {
         /** Use FanniePage::drawPage for the plain old html
                 version of the page
             */
         if ($this->content_function == 'form_content') {
             if (FormLib::get('json') !== '') {
                 $this->addOnloadCommand(FormLib::fieldJSONtoJavascript(base64_decode(FormLib::get('json'))));
             }
             return parent::drawPage();
         }
         /**
           Global setting overrides default behavior
           to force the menu to appear.
           Unlike normal pages, the override is only applied
           when the output format is HTML.
         */
         if (($this->config->get('WINDOW_DRESSING') || $this->new_tablesorter) && $this->report_format == 'html') {
             $this->window_dressing = true;
         }
         if ($this->window_dressing) {
             echo $this->getHeader();
         }
         if ($this->readinessCheck() !== false) {
             $func = $this->content_function;
             echo $this->{$func}();
         } else {
             echo $this->errorContent();
         }
         if ($this->window_dressing) {
             $footer = $this->getFooter();
             $footer = str_ireplace('</html>', '', $footer);
             $footer = str_ireplace('</body>', '', $footer);
             echo $footer;
         }
         if ($this->report_format == 'html') {
             foreach ($this->scripts as $s_url => $s_type) {
                 printf('<script type="%s" src="%s"></script>', $s_type, $s_url);
                 echo "\n";
             }
             $js_content = $this->javascriptContent();
             if (!empty($js_content) || !empty($this->onload_commands)) {
                 echo '<script type="text/javascript">';
                 echo $js_content;
                 echo "\n\$(document).ready(function(){\n";
                 foreach ($this->onload_commands as $oc) {
                     if (strstr($oc, 'standardFieldMarkup()')) {
                         continue;
                     }
                     echo $oc . "\n";
                 }
                 echo "});\n";
                 echo '</script>';
             }
             $page_css = $this->cssContent();
             if (!empty($page_css)) {
                 echo '<style type="text/css">';
                 echo $page_css;
                 echo '</style>';
             }
             echo array_reduce($this->css_files, function ($carry, $css_url) {
                 return $carry . sprintf('<link rel="stylesheet" type="text/css" href="%s">' . "\n", $css_url);
             }, '');
         }
         if ($this->window_dressing || $this->report_format == 'html') {
             echo '</body></html>';
         }
     }
     // drawPage()
 }