10 public static function register($cacheKey, array $params = array())
13 if ($options[
"WRITE_STATISTIC"] ===
"N")
18 if (!is_string($cacheKey) || mb_strlen($cacheKey) < 1)
23 $pageTitle = $params[
"TITLE"] ??
$GLOBALS[
"APPLICATION"]->GetTitle();
24 $pageTitle = mb_substr($pageTitle, 0, 250);
26 $pageHost = isset($params[
"HOST"]) && mb_strlen($params[
"HOST"]) ? $params[
"HOST"] :
Helper::getHttpHost();
27 $pageHost = mb_substr($pageHost, 0, 100);
29 $pageUri = isset($params[
"URI"]) && mb_strlen($params[
"URI"]) ? $params[
"URI"] :
Helper::getRequestUri();
30 $pageUri = mb_substr($pageUri, 0, 2000);
32 $pageSize = isset($params[
"SIZE"]) ? intval($params[
"SIZE"]) : 0;
35 "TITLE" => $pageTitle,
40 $GLOBALS[
"DB"]->StartUsingMasterOnly();
42 $page = static::getByCacheKey($cacheKey);
46 $data[
"LAST_VIEWED"] =
new DateTime();
47 $data[
"VIEWS"] = $page[
"VIEWS"] + 1;
49 if (isset($params[
"CHANGED"]) && $params[
"CHANGED"] ===
true)
52 $data[
"REWRITES"] = $page[
"REWRITES"] + 1;
53 $data[
"SIZE"] = $pageSize;
56 $result = PageTable::update($page[
"ID"], $data);
60 $data[
"SIZE"] = $pageSize;
61 $data[
"CACHE_KEY"] = $cacheKey;
62 $result = PageTable::add($data);
65 $GLOBALS[
"DB"]->StopUsingMasterOnly();
67 return $result !==
null ? $result->getId() :
null;