/**
  * 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'];
     $pmData = FALSE;
     //-----------------------------------------
     // NORMAL
     //-----------------------------------------
     if ($this->_outputType == 'normal') {
         //-----------------------------------------
         // Do we have a PM show?
         //-----------------------------------------
         if (($this->memberData['msg_count_reset'] or $this->memberData['msg_show_notification']) and !$this->memberData['members_disable_pm']) {
             IPSMember::save($this->memberData['member_id'], array('core' => array('msg_show_notification' => 0)));
             if ($this->request['module'] != 'messaging' and (!$this->settings['board_offline'] or $this->memberData['g_access_offline'])) {
                 /* Grab PM Data. We init if we need to recount... */
                 require_once IPSLib::getAppDir("members") . '/sources/classes/messaging/messengerFunctions.php';
                 $messengerFunctions = new messengerFunctions($this->registry);
                 /* Only collect data if we have notifications to show */
                 if ($this->memberData['msg_show_notification']) {
                     $_data = $messengerFunctions->fetchUnreadNotifications($this->memberData['member_id']);
                     if (count($_data)) {
                         $pmData = array_shift($_data);
                     }
                 }
             }
         }
         //-----------------------------------------
         // Add identifier URL
         //-----------------------------------------
         $this->addMetaTag('identifier-url', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
         //-----------------------------------------
         // Add in task image?
         //-----------------------------------------
         $task = '';
         $system_vars_cache['task_next_run'] = isset($system_vars_cache['task_next_run']) ? $system_vars_cache['task_next_run'] : 0;
         if (time() >= $system_vars_cache['task_next_run']) {
             $_url = !$this->registry->getClass('output')->isHTTPS ? $this->settings['base_url'] : $this->settings['base_url_https'];
             $task = "<div><img src='" . $_url . "app=core&amp;module=task' alt='' style='border: 0px;height:1px;width:1px;' /></div>";
         }
         //-----------------------------------------
         // 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, 'pmData' => $pmData), array('time' => $this->registry->getClass('class_localization')->getDate(time(), 'SHORT', 1), 'lang_chooser' => $this->html_buildLanguageDropDown(), 'skin_chooser' => $this->html_fetchSetsDropDown(), '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(), 'task' => $task));
     } else {
         if ($this->_outputType == 'redirect') {
             $extraData['full'] = 1;
             # SEO?
             if ($extraData['seoTitle']) {
                 $extraData['url'] = $this->output->buildSEOUrl($extraData['url'], 'none', $extraData['seoTitle']);
             }
             $finalOutput = $this->output->getTemplate('global_other')->redirectTemplate($documentHeadItems, $this->_css, $jsLoaderItems, $extraData['text'], $extraData['url'], $extraData['full']);
         } else {
             if ($this->_outputType == 'popup') {
                 $finalOutput = $this->output->getTemplate('global_other')->displayPopUpWindow($documentHeadItems, $this->_css, $jsLoaderItems, $title, $output);
             }
         }
     }
     //-----------------------------------------
     // Return
     //-----------------------------------------
     //print IPSLib::sizeFormat( IPSLib::strlenToBytes( strlen( $finalOutput ) ) );
     return $this->parseIPSTags($finalOutput);
 }