/**
  * Fetches the output
  *
  * @access	public
  * @param	string		Output gathered
  * @param	string		Title of the document
  * @param	array 		Navigation gathered
  * @param	array 		Array of document head items
  * @param	array 		Array of JS loader items
  * @param	array 		Array of extra data
  * @return	string		Output to be printed to the client
  */
 public function fetchOutput($output, $title, $navigation, $documentHeadItems, $jsLoaderItems, $extraData = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $system_vars_cache = $this->caches['systemvars'];
     $showPMBox = '';
     $currentCharSet = $this->settings['gb_char_set'];
     /* Force UTF-8 for the skin */
     $this->settings['gb_char_set'] = 'UTF-8';
     //-----------------------------------------
     // NORMAL
     //-----------------------------------------
     if ($this->_outputType == 'normal') {
         //-----------------------------------------
         // Grab output
         //-----------------------------------------
         $finalOutput = $this->output->getTemplate('global')->globalTemplate($output, $documentHeadItems, $this->_css, $jsLoaderItems, $this->_metaTags, array('title' => $title, 'applications' => $this->core_fetchApplicationData(), 'page' => $this->_current_page_title), array('navigation' => $navigation), array('time' => $this->registry->getClass('class_localization')->getDate(time(), 'SHORT', 1), 'lang_chooser' => $this->html_buildLanguageDropDown(), 'skin_chooser' => $this->html_fetchSetsDropDown(), 'stats' => $this->html_showDebugInfo(), 'copyright' => $this->html_fetchCopyright()), array('ex_time' => sprintf("%.4f", IPSDebug::endTimer()), 'gzip_status' => $this->settings['disable_gzip'] == 1 ? $this->lang->words['gzip_off'] : $this->lang->words['gzip_on'], 'server_load' => ipsRegistry::$server_load, 'queries' => $this->DB->getQueryCount()));
     } else {
         if ($this->_outputType == 'redirect') {
             # SEO?
             if ($extraData['seoTitle']) {
                 $extraData['url'] = $this->output->buildSEOUrl($extraData['url'], 'none', $extraData['seoTitle']);
                 $extraData['full'] = 1;
             }
             $finalOutput = $this->output->getTemplate('global')->redirectTemplate($documentHeadItems, $this->_css, $jsLoaderItems, $extraData['text'], $extraData['url'], $extraData['full']);
         } else {
             if ($this->_outputType == 'popup') {
                 $finalOutput = $this->output->getTemplate('global')->displayPopUpWindow($documentHeadItems, $this->_css, $jsLoaderItems, $title, $output);
             }
         }
     }
     //-----------------------------------------
     // Return
     //-----------------------------------------
     $finalOutput = $this->parseIPSTags($finalOutput);
     /* Attempt to clean HTML */
     return IPSText::stripNonUtf8(IPSText::convertCharsets($finalOutput, $currentCharSet, 'UTF-8'));
 }