示例#1
1
 /**
  * print either html or xml content given oModule object
  * @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
  * @param ModuleObject $oModule the module object
  * @return void
  */
 function printContent(&$oModule)
 {
     // Check if the gzip encoding supported
     if (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1 && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE && function_exists('ob_gzhandler') && extension_loaded('zlib') && $oModule->gzhandler_enable) {
         $this->gz_enabled = TRUE;
     }
     // Extract contents to display by the request method
     if (Context::get('xeVirtualRequestMethod') == 'xml') {
         require_once _XE_PATH_ . "classes/display/VirtualXMLDisplayHandler.php";
         $handler = new VirtualXMLDisplayHandler();
     } else {
         if (Context::getRequestMethod() == 'XMLRPC') {
             require_once _XE_PATH_ . "classes/display/XMLDisplayHandler.php";
             $handler = new XMLDisplayHandler();
             if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
                 $this->gz_enabled = FALSE;
             }
         } else {
             if (Context::getRequestMethod() == 'JSON') {
                 require_once _XE_PATH_ . "classes/display/JSONDisplayHandler.php";
                 $handler = new JSONDisplayHandler();
             } else {
                 if (Context::getRequestMethod() == 'JS_CALLBACK') {
                     require_once _XE_PATH_ . "classes/display/JSCallbackDisplayHandler.php";
                     $handler = new JSCallbackDisplayHandler();
                 } else {
                     require_once _XE_PATH_ . "classes/display/HTMLDisplayHandler.php";
                     $handler = new HTMLDisplayHandler();
                 }
             }
         }
     }
     $output = $handler->toDoc($oModule);
     // call a trigger before display
     ModuleHandler::triggerCall('display', 'before', $output);
     // execute add-on
     $called_position = 'before_display_content';
     $oAddonController = getController('addon');
     $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
     if (file_exists($addon_file)) {
         include $addon_file;
     }
     if (method_exists($handler, "prepareToPrint")) {
         $handler->prepareToPrint($output);
     }
     // header output
     if ($this->gz_enabled) {
         header("Content-Encoding: gzip");
     }
     $httpStatusCode = $oModule->getHttpStatusCode();
     if ($httpStatusCode && $httpStatusCode != 200) {
         $this->_printHttpStatusCode($httpStatusCode);
     } else {
         if (Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') {
             $this->_printJSONHeader();
         } else {
             if (Context::getResponseMethod() != 'HTML') {
                 $this->_printXMLHeader();
             } else {
                 $this->_printHTMLHeader();
             }
         }
     }
     // debugOutput output
     $this->content_size = strlen($output);
     $output .= $this->_debugOutput();
     // results directly output
     if ($this->gz_enabled) {
         print ob_gzhandler($output, 5);
     } else {
         print $output;
     }
     // call a trigger after display
     ModuleHandler::triggerCall('display', 'after', $output);
 }
示例#2
0
 /**
  * Get content of real module
  *
  * @param string $module module name
  * @param string $mid module id
  * @param string $skin skin name
  * @param string $skinType PC(P) or mobile(M)
  * @return string content of real module
  */
 private function procRealModule($module, $mid, $skin, $skinType)
 {
     // if form site design and preview module, find target module
     if ($module && !$mid) {
         $args = new stdClass();
         $args->module = $module;
         $output = executeQuery('layout.getOneModuleInstanceByModuleName', $args);
         if (!$output->toBool()) {
             throw new Exception($output->getMessage());
         }
         // if there is no module instance, error...
         if (!$output->data) {
             throw new Exception(Context::getLang('msg_unabled_preview'));
         }
         $mid = current($output->data)->mid;
     } elseif (!$module && !$mid) {
         $oModuleModel = getModel('module');
         $columnList = array('modules.mid', 'sites.index_module_srl');
         $startModuleInfo = $oModuleModel->getSiteInfo(0, $columnList);
         $mid = $startModuleInfo->mid;
     }
     $oModuleHandler = new ModuleHandler('', '', $mid, '', '');
     // Adhoc...
     $oModuleHandler->act = '';
     $oModuleHandler->init();
     // Adhoc...
     $oModuleHandler->module_info->use_mobile = 'Y';
     $oModuleHandler->module_info->is_skin_fix = 'Y';
     $oModuleHandler->module_info->is_mskin_fix = 'Y';
     if ($skinType == 'M') {
         Mobile::setMobile(TRUE);
         $oModuleHandler->module_info->mskin = $skin;
     } else {
         Mobile::setMobile(FALSE);
         $oModuleHandler->module_info->skin = $skin;
     }
     // Proc module
     $oModule = $oModuleHandler->procModule();
     if (!$oModule->toBool()) {
         throw new Exception(Context::getLang('not_support_layout_preview'));
     }
     // get module html
     require_once _XE_PATH_ . "classes/display/HTMLDisplayHandler.php";
     $handler = new HTMLDisplayHandler();
     return $handler->toDoc($oModule);
 }
 /**
  * print either html or xml content given oModule object
  * @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
  * @param ModuleObject $oModule the module object
  * @return void
  */
 function printContent(&$oModule)
 {
     // Check if the gzip encoding supported
     if (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1 && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE && extension_loaded('zlib') && $oModule->gzhandler_enable) {
         $this->gz_enabled = TRUE;
     }
     // Extract contents to display by the request method
     if (Context::get('xeVirtualRequestMethod') == 'xml') {
         $handler = new VirtualXMLDisplayHandler();
     } else {
         if (Context::getRequestMethod() == 'XMLRPC') {
             $handler = new XMLDisplayHandler();
             if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
                 $this->gz_enabled = FALSE;
             }
         } else {
             if (Context::getRequestMethod() == 'JSON') {
                 $handler = new JSONDisplayHandler();
             } else {
                 if (Context::getRequestMethod() == 'JS_CALLBACK') {
                     $handler = new JSCallbackDisplayHandler();
                 } else {
                     $handler = new HTMLDisplayHandler();
                 }
             }
         }
     }
     $output = $handler->toDoc($oModule);
     // call a trigger before display
     ModuleHandler::triggerCall('display', 'before', $output);
     // execute add-on
     $called_position = 'before_display_content';
     $oAddonController = getController('addon');
     $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
     if (file_exists($addon_file)) {
         include $addon_file;
     }
     if (method_exists($handler, "prepareToPrint")) {
         $handler->prepareToPrint($output);
     }
     // Start the session if $_SESSION was touched
     Context::getInstance()->checkSessionStatus();
     // header output
     $httpStatusCode = $oModule->getHttpStatusCode();
     if ($httpStatusCode && $httpStatusCode != 200) {
         $this->_printHttpStatusCode($httpStatusCode);
     } else {
         if (Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') {
             $this->_printJSONHeader();
         } else {
             if (Context::getResponseMethod() != 'HTML') {
                 $this->_printXMLHeader();
             } else {
                 $this->_printHTMLHeader();
             }
         }
     }
     // debugOutput output
     $this->content_size = strlen($output);
     $output .= $this->_debugOutput();
     // disable gzip if output already exists
     ob_flush();
     if (headers_sent()) {
         $this->gz_enabled = FALSE;
     }
     // enable gzip using zlib extension
     if ($this->gz_enabled) {
         ini_set('zlib.output_compression', true);
     }
     // results directly output
     print $output;
     // call a trigger after display
     ModuleHandler::triggerCall('display', 'after', $output);
     flushSlowlog();
 }
示例#4
0
 /**
  * print either html or xml content given oModule object
  * @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
  * @param ModuleObject $oModule the module object
  * @return void
  */
 public function printContent(&$oModule)
 {
     // Check if the gzip encoding supported
     if (config('view.use_gzip') && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && extension_loaded('zlib') && $oModule->gzhandler_enable) {
         $this->gz_enabled = TRUE;
     }
     // Extract contents to display by the request method
     if (Context::get('xeVirtualRequestMethod') == 'xml') {
         $handler = new VirtualXMLDisplayHandler();
     } elseif (Context::getRequestMethod() == 'JSON' || isset($_POST['_rx_ajax_compat'])) {
         $handler = new JSONDisplayHandler();
     } elseif (Context::getRequestMethod() == 'JS_CALLBACK') {
         $handler = new JSCallbackDisplayHandler();
     } elseif (Context::getRequestMethod() == 'XMLRPC') {
         $handler = new XMLDisplayHandler();
         if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
             $this->gz_enabled = FALSE;
         }
     } else {
         $handler = new HTMLDisplayHandler();
     }
     $output = $handler->toDoc($oModule);
     // call a trigger before display
     ModuleHandler::triggerCall('display', 'before', $output);
     $original_output = $output;
     // execute add-on
     $called_position = 'before_display_content';
     $oAddonController = getController('addon');
     $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
     if (file_exists($addon_file)) {
         include $addon_file;
     }
     if ($output === false || $output === null || $output instanceof Object) {
         $output = $original_output;
     }
     if (method_exists($handler, "prepareToPrint")) {
         $handler->prepareToPrint($output);
     }
     // Start the session if $_SESSION was touched
     Context::checkSessionStatus();
     // header output
     $httpStatusCode = $oModule->getHttpStatusCode();
     if ($httpStatusCode !== 200 && !in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON', 'JS_CALLBACK'))) {
         self::_printHttpStatusCode($httpStatusCode);
     } else {
         if (Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') {
             if (strpos($_SERVER['HTTP_ACCEPT'], 'json') !== false) {
                 self::_printJSONHeader();
             }
         } else {
             if (Context::getResponseMethod() != 'HTML') {
                 self::_printXMLHeader();
             } else {
                 self::_printHTMLHeader();
             }
         }
     }
     // disable gzip if output already exists
     while (ob_get_level()) {
         ob_end_flush();
     }
     if (headers_sent()) {
         $this->gz_enabled = FALSE;
     }
     // enable gzip using zlib extension
     if ($this->gz_enabled) {
         ini_set('zlib.output_compression', true);
     }
     // call a trigger after display
     self::$response_size = $this->content_size = strlen($output);
     ModuleHandler::triggerCall('display', 'after', $output);
     // Output the page content and debug data.
     $debug = $this->getDebugInfo($output);
     print $output;
     print $debug;
 }