Start page

Mykola Zharkikh (Kyiv)

Personal site

?

SmerecashPage object

The SmerecashPage object is designed to search previously generated (smerecashed) HTML code of Web pages and send data to the client. From this class is inherited Page class.

Fields

protected $PageSmerecasheable – value of logical type, which allows or denies smerecashing for this page. If smerecashing allowed, then Smereka tries to find pre-generated code in smerecash during processing the request, and write code of the page to smerecash after code generation. If smerecashing prohibited, Smereka always performs full cycle of HTML code of web pages generation.

protected function CanSmerecashe()

The method returns a Boolean value, which allows or denies smerecashing for this page. Typically smerecashing allowed if it allows by global variable $GLOBALS['UseSmerecashe'] and value of the PageSmerecasheable field. If object User is created in the PHP session (default), then additionally called its method AllowSmerecash().

Thus, smerecash management can be done at the global level, user-level and node class level. You need to override this method to provide specific mode of pages smerecashing.

protected function Compress(&$Data)

The method receives the HTML code of web page and compresses it with gzip algorithm to send the user a smaller amount of data. This compression is performed after postprocessing, each time page is sending to user (regardless was page smerecashed or not). Compression is performed by the simultaneous implementation of all the following conditions:

  • it is allowed by global variable CompressOutput;
  • client is ready to accept gzip-data;
  • MIME Type of page – HTML;
  • length of the incoming data exceeds 20 kb (one can save something on its compression).

The function returns a Boolean value – was compression applied or not.

public function Display($Id = NULL)

The main method of class. In this class, it does work with smerecash. If the optional parameter $Id specified, the function searches smerecashed page with the given node id and the current language version. If this parameter is omitted, the method PageURLInfo is called and smerecash is searched for address string, generated by this method.

If the smerecashed page found, it sent to the client by SendPage method and Smereka finished processing of request. If smerecashed page not found, the method returns False and the normal cycle of page generation continues.

protected function MIMEType()

The method returns a MIME Type for this page. By default, the method selects a value from a table smerecash. Descendants class can override this behavior.

public static function PageURLInfo()

The method analyzes the parameters of page request and generates the address string of those elements that define the page content.

protected function SendHeader($Size, $CanCache, $LastUpd)

Sends to the client HTTP-headers in accordance with the parameters $Size (data size), $CanCache (is HTTP-caching allowed), $LastUpd (date of last data modification).

protected function SendPage($R, $D)

The method receives data to be sent to the user ($R) and date of last modification ($D). If necessary, function performs postprocessing of the data obtained (typical task performed by postprocessing – insert the number of downloads of the page, which is performed by sending data to each client). After that attempt to compress data by Compress. If compression successful, the appropriate HTTP-headers sent to client. Then the data stream sent to client.