In-Portal Developers Guide

This is a wiki-based Developers Guide for In-Portal Open Source CMS. The purpose of this guide is to provide advanced users, web developers and programmers with documentation on how to expand, customize and improve the functionality and the code the In-Portal software. Please consider contributing to our documentation writing effort.

K4:Constants

From In-Portal Developers Guide

Jump to: navigation, search
Current revision (18:26, 26 November 2010) (view source)
(Languages sidebox)
 
(9 intermediate revisions not shown.)
Line 1: Line 1:
{{toc | category = Структура приложения | sortkey = 003.001}}
{{toc | category = Структура приложения | sortkey = 003.001}}
-
В К4 константы делятся по смыслу исходя из места их определения на:
+
In K4, constants are separated based on their meaning into:
-
In K4, constants are separated based on their meaning, separated into:
+
* '''system''' - defined in "<code>core/kernel/startup.php</code>"
* '''system''' - defined in "<code>core/kernel/startup.php</code>"
-
* '''general use''' - defined in "<code>core/kernel/constants.php</code>"
+
* '''general application''' - defined in "<code>core/kernel/constants.php</code>"
* '''modular''' - defined in the not required file "<code><module_name>/constants.php</code>"
* '''modular''' - defined in the not required file "<code><module_name>/constants.php</code>"
Line 21: Line 20:
This constant is used only to correctly determine the value of the constant [[#BASE_PATH|BASE_PATH]]. If this constant isn't defined in time, then links built with the help of the method "<code>kApplicaton::HREF</code>" will be incorrect.
This constant is used only to correctly determine the value of the constant [[#BASE_PATH|BASE_PATH]]. If this constant isn't defined in time, then links built with the help of the method "<code>kApplicaton::HREF</code>" will be incorrect.
|-
|-
-
| {{ConfigProperty|SERVER_NAME}} || The name of the Virtual Host, which is running the site (the contents of the variable [http://lv.php.net/reserved.variables <nowiki>$_SERVER['SERVER_NAME']</nowiki>]).
+
| {{ConfigProperty|SERVER_NAME}} || Имя виртуального хоста (<code>VirtualHost</code>), под которым запущен данный сайт (содержание переменной [http://lv.php.net/reserved.variables <nowiki>$_SERVER['SERVER_NAME']</nowiki>]). В случае, если название виртуального хоста получить не удалось, то будет использован хост, указанный в константе [[#DOMAIN|DOMAIN]] (из файла "<code>config.php</code>"). Функциональность работающая в случае, когда не удалось получить имя виртуального хоста доступна начиная с [[K4:Core v 4.3.9|Core v 4.3.9]].
|-
|-
| {{ConfigProperty|WRITEABLE}} || The contents of the variables [[#FULL_PATH|FULL_PATH]] and [[#WRITEABLE_BASE|WRITEABLE_BASE]] together.
| {{ConfigProperty|WRITEABLE}} || The contents of the variables [[#FULL_PATH|FULL_PATH]] and [[#WRITEABLE_BASE|WRITEABLE_BASE]] together.
Line 30: Line 29:
{{ambox | type = refactoring | text = Constants [[#WRITEABLE|WRITEABLE]] and [[#WRITEBALE_BASE|WRITEBALE_BASE]] are incorrectly named (misspelled). In English obviously, the correct names would be <code>'''WRITABLE'''</code> and <code>'''WRITABLE_BASE'''</code> respectively.}}
{{ambox | type = refactoring | text = Constants [[#WRITEABLE|WRITEABLE]] and [[#WRITEBALE_BASE|WRITEBALE_BASE]] are incorrectly named (misspelled). In English obviously, the correct names would be <code>'''WRITABLE'''</code> and <code>'''WRITABLE_BASE'''</code> respectively.}}
-
Пример:
+
Example:
-
  http://alex.prod.intechnic.lv/test_project - путь в web browser
+
  http://alex.prod.intechnic.lv/test_project - path to the web browser
  FULL_PATH - "/home/sites/alex/web/test_project"
  FULL_PATH - "/home/sites/alex/web/test_project"
  BASE_PATH - "/test_project"
  BASE_PATH - "/test_project"
Line 38: Line 37:
  WRITEBALE - "/home/sites/alex/web/test_project/system"
  WRITEBALE - "/home/sites/alex/web/test_project/system"
-
== Константы общего применения ==
+
== General application constants ==
-
* распространённые типы записей (статусы) в базе данных:
+
* common types of records (statuses) in the database:
{| class="prettytable"
{| class="prettytable"
-
! название || описание || значение
+
! name || description || value
|-  
|-  
-
| {{ConfigProperty|STATUS_ACTIVE}} || Запись активна. || <center>1</center>
+
| {{ConfigProperty|STATUS_ACTIVE}} || Active record. || <center>1</center>
|-
|-
-
| {{ConfigProperty|STATUS_DISABLED}} || Запись не активна. || <center>0</center>
+
| {{ConfigProperty|STATUS_DISABLED}} || Inactive record. || <center>0</center>
|-
|-
-
| {{ConfigProperty|STATUS_PENDING}} || Запись требует подтверждения администратора. || <center>-2</center>
+
| {{ConfigProperty|STATUS_PENDING}} || Record is awaiting approval by the administrator. || <center>-2</center>
|}
|}
-
* статусы секций в дереве в административной консоли:
+
* status of sections in the navigation tree in the administrative console:
{| class="prettytable"
{| class="prettytable"
-
! название || описание
+
! name || description
|-
|-
-
| {{ConfigProperty|stTREE}} || Секция присутствует только в дереве (почти все секции).
+
| {{ConfigProperty|stTREE}} || Section is present only in the navigation tree (almost all sections).
|-
|-
-
| {{ConfigProperty|stTAB}} || Секция присутствует только как закладка (см. в [[In-Commerce:Discounts & Coupons]]).
+
| {{ConfigProperty|stTAB}} || Section is present only as a tab (see [[In-Commerce:Discounts & Coupons]]).  
|}
|}
-
* статусы завершения [[K4:Events|событий]] в K4:
+
* status of finished [[K4:Events|events]] in K4:
{| class="prettytable"
{| class="prettytable"
-
! название || описание
+
! name || description
|-
|-
-
| {{ConfigProperty|erSUCCESS}} || Событие успешно завершило своё выполнение. После выполнения события будет сделано перенаправление, выполняемое для того, чтобы пользователь перезагрузив страницу (F5) повторно не вызвал это событие.
+
| {{ConfigProperty|erSUCCESS}} || Event finished working successfully. Once the event finishes, there is an automatic redirect so that the event isn't called again in case the user refreshes the page (F5).
|-
|-
-
| {{ConfigProperty|erFAIL}} || Событие завершило свою работу, но не выполнило одну или более требуемых задач. Перенаправление происходить не будет.  
+
| {{ConfigProperty|erFAIL}} || Event finished working, but didn't accomplish one or more of the requested tasks. There won't be a redirect.
|-
|-
-
| {{ConfigProperty|erFATAL}} || Событие полностью не сделало свою работу ([[K4:Hooks|хуки]] не будут выполняться). Перенаправление происходить не будет.
+
| {{ConfigProperty|erFATAL}} || The event didn't accomplish any part of its task ([[K4:Hooks|hooks]] won't continue). There won't be a redirect.
|-
|-
-
| {{ConfigProperty|erPERM_FAIL}} || Проверка [[К4:Permissions|прав доступа]] не прошла успешно. Автоматически будет выполнено перенаправление на шаблон сообщающий пользователю об отсутствии у него прав на данное событие.
+
| {{ConfigProperty|erPERM_FAIL}} || Checking [[К4:Permissions|access permissions]] wasn't successful. There will be an automatic redirect to a template letting the user know that he doesn't have the required permissions for the event.
|-
|-
-
| {{ConfigProperty|erSTOP}} || Событие возвращает ответ в [[K4:Ajax|AJAX]] запрос. Шаблон не будет обработан после выполнения события, код отладчика тоже добавлен не будет.
+
| {{ConfigProperty|erSTOP}} || The event returns a response to an [[K4:Ajax|AJAX]] request. The template won't be parsed after running the event, debugger code won't be added either.  
|}
|}
-
* константы, использующиеся при редактировании содержания сайта через административную консоль.
+
* constants used when editing site content through the administrative console.
{| class="prettytable"
{| class="prettytable"
-
! название || описание
+
! name || description
|-
|-
-
| {{ConfigProperty|EDITING_MODE}} || Данная константа, начиная с [[K4:Core v 5.0.0|Core v 5.0.0]], заменяет собой методы <code>EditMode</code> в обработчике событий и тэгов префикса "<code>st</code>" и "<code>cms</code>". Значение этой константы может быть равно значению описанных ниже 3 констант или нулю, что будет означать, что пользователь не находиться в режиме редактирования содержания сайта. В независимости от режима редактирования содержания сайта оранжевые кнопки "<code>Edit</code>" будут появляться над теми фрагментами содержания страницы, которые можно изменить. Данная константа доступна начиная с [[K4:Core v 5.0.0|Core v 5.0.0]].
+
| {{ConfigProperty|EDITING_MODE}} || This constant, starting from [[K4:Core v 5.0.0|Core v 5.0.0]], replaces the methods <code>EditMode</code> in the event handler and tags of the prefixes "<code>st</code>" and "<code>cms</code>". The value of this constant may be the same as the value of the below 3 constant or equal to zero, which means that the user is currently not in the editing mode of the site. Regardless of the editing mode of the site, the orange "<code>Edit</code>" buttons will appear above the parts of the template that can be changed. This constant will be available starting with [[K4:Core v 5.0.0|Core v 5.0.0]].
|-
|-
-
| {{ConfigProperty|EDITING_MODE_CMS}} || Режим редактирования сайта, при котором изменяться может только содержание cms-блоков (это был единственный возможный режим редактирования сайта до [[K4:Core v 5.0.0|Core v 5.0.0]]). Данная константа доступна начиная с [[K4:Core v 5.0.0|Core v 5.0.0]].
+
| {{ConfigProperty|EDITING_MODE_CMS}} || Site editing mode, where the only things that can be changed are items contained in cms-blocks (this was the only possible site editing mode until [[K4:Core v 5.0.0|Core v 5.0.0]]). This constant will be available starting with [[K4:Core v 5.0.0|Core v 5.0.0]].
|-
|-
| {{ConfigProperty|EDITING_MODE_LAYOUT}}
| {{ConfigProperty|EDITING_MODE_LAYOUT}}
-
| Режим редактирования сайта, при котором изменяться может изменяться только содержание блоков, при подключении которых был передан параметр "<code>layout_view</code>":
+
| Site editing mode where only the content of blocks can be changed that were setup using the "<code> layout_view </code>" option:
<source lang="xml">
<source lang="xml">
<inp2:m_RenderElement name="block_name" layout_view="1"/>
<inp2:m_RenderElement name="block_name" layout_view="1"/>
</source>
</source>
-
В [[K4:Theme|теме]] "<code>default2007</code>" это блоки "<code>sidebar</code>" и "<code>content</code>" из текущего шаблона. Данная константа доступна начиная с [[K4:Core v 5.0.0|Core v 5.0.0]].
+
In the [[K4:Theme|theme]] "<code>default2007</code>" these are the "<code>sidebar</code>" and "<code>content</code>" blocks in the current template. This constant is available starting with [[K4:Core v 5.0.0|Core v 5.0.0]].
|-
|-
| {{ConfigProperty|EDITING_MODE_DESIGN}}
| {{ConfigProperty|EDITING_MODE_DESIGN}}
|
|
-
Режим редактирования сайта, при котором изменяться может только дизайн показываемых на шаблоне блоков, т.е. блоков, которые были указаны в параметре "<code>design</code>" (в примере это "<code>design_block_name</code>") при подключении других (в примере это "<code>element_name</code>") блоков. Например:
+
Site editing mode, where the design of the blocks can be changed, i.e. those blocks that were indicated in the parameter "<code>design</code>" (in the example that's "<code>design_block_name</code>") while setting up other (in the example that's "<code>element_name</code>") blocks. For example:
<source lang="xml">
<source lang="xml">
<inp2:m_RenderElement name="element_name" design="design_block_name"/>
<inp2:m_RenderElement name="element_name" design="design_block_name"/>
</source>
</source>
-
В [[K4:Theme|теме]] "<code>default2007</code>" это блоки "<code>blue_box</code>" и "<code>content_box</code>". Данная константа доступна начиная с [[K4:Core v 5.0.0|Core v 5.0.0]].
+
In the [[K4:Theme|theme]] "<code>default2007</code>" these are the "<code>blue_box</code>" and "<code>content_box</code>" blocks. This constant is available starting with [[K4:Core v 5.0.0|Core v 5.0.0]].
|}
|}
-
* разное:
+
* miscellaneous:
{| class="prettytable"
{| class="prettytable"
-
! название || описание || значение
+
! name || description || value
|-
|-
-
| {{ConfigProperty|ENV_VAR_NAME}} || Значение данной константы используется для определения названия [[K4:Переменная окружения|переменной окружения]] в запросе к серверу. || <center><code>env</code></center>
+
| {{ConfigProperty|ENV_VAR_NAME}} || The value of this constant is used to determine the name of the [[K4:Переменная окружения|environment variable]] in a request to the server. || <center><code>env</code></center>
|-
|-
-
| {{ConfigProperty|VALUE_LIST_SEPARATOR}} || Значение, которое будет использоваться для объединения [[K4:Formatters#options|возможных опций]] в полях <code>ValueList</code> (во всех таблицах, кроме таблицы [[K4:ConfigurationAdmin|ConfigurationAdmin]]). || <center><code><nowiki>||</nowiki></code></center>
+
| {{ConfigProperty|VALUE_LIST_SEPARATOR}} || The value that will be used for associating [[K4:Formatters#options|possible options]] in the <code>ValueList</code> fields (in all tables except the [[K4:ConfigurationAdmin|ConfigurationAdmin]] table). || <center><code><nowiki>||</nowiki></code></center>
|-
|-
| {{ConfigProperty|REGEX_EMAIL_USER}}
| {{ConfigProperty|REGEX_EMAIL_USER}}
-
| Регулярное выражение, которое проверяет части с именем пользователя в адресе электронной почты (<code>email</code>). Используя константы [[#REGEX_EMAIL_USER|REGEX_EMAIL_USER]] и [[#REGEX_EMAIL_DOMAIN|REGEX_EMAIL_DOMAIN]] можно составить регулярное выражение для проверки адреса электронной почты:
+
| Regular expression that checks the name part of an <code>email</code>. Using constants [[#REGEX_EMAIL_USER|REGEX_EMAIL_USER]] and [[#REGEX_EMAIL_DOMAIN|REGEX_EMAIL_DOMAIN]] it's possible to put together a regular expression that checks the email address:
<source lang="php">
<source lang="php">
$regexp = '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i';
$regexp = '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i';
</source>
</source>
-
Константа доступна начиная с [[K4:Core v 4.0.1|Core v 4.0.1]].
+
Constant available since [[K4:Core v 4.0.1|Core v 4.0.1]].
| <pre>[-a-zA-Z0-9!\#$%&*+\/=?^_`{|}~.]+</pre>
| <pre>[-a-zA-Z0-9!\#$%&*+\/=?^_`{|}~.]+</pre>
|-
|-
| {{ConfigProperty|REGEX_EMAIL_DOMAIN}}
| {{ConfigProperty|REGEX_EMAIL_DOMAIN}}
-
| Регулярное выражение, которое проверяет части с доменом (<code>domain</code>) в адресе электронной почты (<code>email</code>). Используя константы [[#REGEX_EMAIL_USER|REGEX_EMAIL_USER]] и [[#REGEX_EMAIL_DOMAIN|REGEX_EMAIL_DOMAIN]] можно составить регулярное выражение для проверки адреса электронной почты:
+
| Regular expression that checks the <code>domain</code> in an <code>email</code> address. Using constants [[#REGEX_EMAIL_USER|REGEX_EMAIL_USER]] and [[#REGEX_EMAIL_DOMAIN|REGEX_EMAIL_DOMAIN]] it's possible to put together a regular expression that checks the email address:
<source lang="php">
<source lang="php">
$regexp = '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i';
$regexp = '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i';
</source>
</source>
-
Константа доступна начиная с [[K4:Core v 4.0.1|Core v 4.0.1]].
+
Constant available since [[K4:Core v 4.0.1|Core v 4.0.1]].
| <pre>[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\.[a-zA-Z]{2,6}</pre>
| <pre>[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\.[a-zA-Z]{2,6}</pre>
 +
|-
 +
| {{ConfigProperty|ALLOW_DEFAULT_SETTINGS}}
 +
| Данная константа задумана для передачи в метод "<code>kApplication::RecallPersistentVar</code>" в качестве значения по умолчанию. Это подробнее показано на приведённом ниже примере.
 +
<source lang="php">
 +
$value = $this->Application->RecallPersistentVar('VarName', ALLOW_DEFAULT_SETTINGS);
 +
</source>
 +
Если требуемой переменной в таблице [[K4:PersistentSessionData|PersistentSessionData]] нету и используется эта константа, то будет возвращено значение этой переменной взятое у пользователя, указанного в конфигурационной переменной [[K4:Configuration#DefaultSettingsUserId|DefaultSettingsUserId]]. Данная константа доступна начиная с [[K4:Core v 4.2.2|Core v 4.2.2]].
 +
| <center><code>_USE_DEFAULT_USER_DATA_</code></center>
|}
|}
-
Константы это идентификаторы значений, которые не могут изменяться по ходу выполнения скрипта.
+
Constants are identifier values that can't change as the script runs.
-
== Константы из config.php ==
+
== config.php constants ==
-
В базовой директории проекта (той, что в [[#FULL_PATH|FULL_PATH]] константе) находиться файл <code>config.php</code>, который содержит настройки для подключения к базе данных и ряд других параметров, которые при инициализации K4 превращаются в константы. На данный файл '''нельзя''', не в коем случае, '''делать commit'''. По своему формату этот файл похож на обычный ini файл. Единственное отличие это расширение файла и защитная php конструкция в его начале.
+
In the root directory of the project (the one that's in the [[#FULL_PATH|FULL_PATH]] constant) there is a file <code>config.php</code> that contains settings for connecting to the database along with other parameters that by initializing K4 become constants. Into this file, a '''commit can never be made'''. By its format, this file looks similar to a regular ini file. The only difference is the file extension and the protected php design in the beginning of the file.
{| class="prettytable"
{| class="prettytable"
-
! название константы || название опции || описание
+
! constant name || option name || description
|-
|-
-
| {{ConfigProperty|SQL_TYPE}} || <code>DBType</code> || Тип сервера баз данных. Пока поддерживается только MySQL.
+
| {{ConfigProperty|SQL_TYPE}} || <code>DBType</code> || Database server type. Right now, only MySQL is supported.
|-
|-
-
| {{ConfigProperty|SQL_SERVER}} || <code>DBHost</code> || IP адрес или имя сервера баз данных.
+
| {{ConfigProperty|SQL_SERVER}} || <code>DBHost</code> || IP address or server name of the database.
|-
|-
-
| {{ConfigProperty|SQL_USER}} || <code>DBUser</code> || Имя пользователя, для подключения к базе данных.
+
| {{ConfigProperty|SQL_USER}} || <code>DBUser</code> || Username for connecting to the database.
|-
|-
-
| {{ConfigProperty|SQL_PASS}} || <code>DBUserPassword</code> || Пароль, для подключения к базе данных.
+
| {{ConfigProperty|SQL_PASS}} || <code>DBUserPassword</code> || Password for connecting to the database.
|-
|-
-
| {{ConfigProperty|SQL_DB}} || <code>DBName</code> || Название базы данных.
+
| {{ConfigProperty|SQL_DB}} || <code>DBName</code> || Database name.
|-
|-
-
| {{ConfigProperty|SQL_COLLATION}} || <code>DBCollation</code> || Тип сопоставления строк, используемый при работе базой данных (напр. "<code>utf8_general_ci</code>").
+
| {{ConfigProperty|SQL_COLLATION}} || <code>DBCollation</code> || Collation type used when working with the database (for example "<code>utf8_general_ci</code>").
|-
|-
-
| {{ConfigProperty|SQL_CHARSET}} || <code>DBCharset</code> || Кодировка данных, используемая при работе базой данных (напр. "<code>utf8</code>").
+
| {{ConfigProperty|SQL_CHARSET}} || <code>DBCharset</code> || Data encoding type used for working with the database (for example "<code>utf8</code>").
|-
|-
-
| {{ConfigProperty|TABLE_PREFIX}} || <code>TablePrefix</code> || Префикс таблиц проекта в базе данных.
+
| {{ConfigProperty|TABLE_PREFIX}} || <code>TablePrefix</code> || Prefix of database tables of the project in the database.
|-
|-
-
| {{ConfigProperty|DOMAIN}} || <code>Domain</code> || Домен, на котором сайт находиться. Используется для выхода из SSL-режима, а также для проверки лицензии в <code>In-Portal</code>.
+
| {{ConfigProperty|DOMAIN}} || <code>Domain</code> || Domain where the site is located. Used for leaving SSL-mode and for checking an <code>In-Portal</code> license.
|-
|-
-
| {{ConfigProperty|ADMIN_DIRECTORY}} || <code>AdminDirectory</code> || Расположение директории с административной консолью относительно [[#FULL_PATH|FULL_PATH]]. Доступна, начиная с [[K4:Core v 4.3.0|Core v 4.3.0]].
+
| {{ConfigProperty|ADMIN_DIRECTORY}} || <code>AdminDirectory</code> || Location of the administrative console directory relative to [[#FULL_PATH|FULL_PATH]]. Available starting with [[K4:Core v 4.3.0|Core v 4.3.0]].
|-
|-
-
| {{ConfigProperty|EDITOR_PATH}} || <code>EditorPath</code> || Расположение директории с <code>FCKEditor</code> относительно [[#FULL_PATH|FULL_PATH]] (обычно "<code>/core/editor/</code>"). Доступна, начиная с [[K4:Core v 4.3.2|Core v 4.3.2]].
+
| {{ConfigProperty|EDITOR_PATH}} || <code>EditorPath</code> || Location of the directory with the <code>FCKEditor</code>, relative to [[#FULL_PATH|FULL_PATH]] (usually "<code>/core/editor/</code>"). Available starting with [[K4:Core v 4.3.2|Core v 4.3.2]].
|-
|-
-
| {{ConfigProperty|WRITEABLE_BASE}} || <code>WriteablePath</code> || Директория, в которую имеет право писать сервер (обычно "<code>/system</code>").
+
| {{ConfigProperty|WRITEABLE_BASE}} || <code>WriteablePath</code> || Directory into which the server has permissions to write (usually "<code>/system</code>").
|-
|-
-
| {{ConfigProperty|APPLICATION_CLASS}} || <code>ApplicationClass</code> || Класс, который используется для создания объекта [[K4:Application|Application]], например "<code>EApplication</code>".
+
| {{ConfigProperty|APPLICATION_CLASS}} || <code>ApplicationClass</code> || Class that's used to create an [[K4:Application|Application]] object, for example "<code>EApplication</code>".
|-
|-
-
| {{ConfigProperty|APPLICATION_PATH}} || <code>ApplicationPath</code> || Расположение файла с классом, указанным в [[#APPLICATION_CLASS|APPLICATION_CLASS]] относительно корня сайта (с указанием "<code>/</code>" спереди), например. "<code>/custom/units/sections/e_application.php</code>".
+
| {{ConfigProperty|APPLICATION_PATH}} || <code>ApplicationPath</code> || Location of the file with the class indicated in [[#APPLICATION_CLASS|APPLICATION_CLASS]], relative to the root of the site (with the "<code>/</code>" character in front), for example "<code>/custom/units/sections/e_application.php</code>".
|}
|}
 +
 +
[[en:{{FULLPAGENAME}}]]
 +
[[ru:K4:Константы]]

Current revision

Структура приложения Структура приложения
Статьи в этой категории

In K4, constants are separated based on their meaning into:

  • system - defined in "core/kernel/startup.php"
  • general application - defined in "core/kernel/constants.php"
  • modular - defined in the not required file "<module_name>/constants.php"

System constants

name description
FULL_PATH Full path to the site in the file system of the server.
BASE_PATH Directory where the site is located (relative to $_SERVER['DOCUMENT_ROOT'])
REL_PATH Path from the root of the project to the PHP-file (usually that's "index.php"), that the site user enters. Defining this constant must be done before or right after defining the constant FULL_PATH in this PHP file. This constant must be defined in all cases, when the PHP-file is not in the root of the project or in its "admin" directory. Examples:
file: testing/folder/index.php - constant: "testing/folder"
file: sub_folder/index.php - constant "sub_folder"

This constant is used only to correctly determine the value of the constant BASE_PATH. If this constant isn't defined in time, then links built with the help of the method "kApplicaton::HREF" will be incorrect.

SERVER_NAME Имя виртуального хоста (VirtualHost), под которым запущен данный сайт (содержание переменной $_SERVER['SERVER_NAME']). В случае, если название виртуального хоста получить не удалось, то будет использован хост, указанный в константе DOMAIN (из файла "config.php"). Функциональность работающая в случае, когда не удалось получить имя виртуального хоста доступна начиная с Core v 4.3.9.
WRITEABLE The contents of the variables FULL_PATH and WRITEABLE_BASE together.
MAX_UPLOAD_SIZE The maximum size of the file that can be uploaded to the server (in bytes).

Example:

http://alex.prod.intechnic.lv/test_project - path to the web browser
FULL_PATH - "/home/sites/alex/web/test_project"
BASE_PATH - "/test_project"
SERVER_NAME - "alex.prod.intechnic.lv"
WRITEBALE_BASE - "/system"
WRITEBALE - "/home/sites/alex/web/test_project/system"

General application constants

  • common types of records (statuses) in the database:
name description value
STATUS_ACTIVE Active record.
1
STATUS_DISABLED Inactive record.
0
STATUS_PENDING Record is awaiting approval by the administrator.
-2
  • status of sections in the navigation tree in the administrative console:
name description
stTREE Section is present only in the navigation tree (almost all sections).
stTAB Section is present only as a tab (see In-Commerce:Discounts & Coupons).
  • status of finished events in K4:
name description
erSUCCESS Event finished working successfully. Once the event finishes, there is an automatic redirect so that the event isn't called again in case the user refreshes the page (F5).
erFAIL Event finished working, but didn't accomplish one or more of the requested tasks. There won't be a redirect.
erFATAL The event didn't accomplish any part of its task (hooks won't continue). There won't be a redirect.
erPERM_FAIL Checking access permissions wasn't successful. There will be an automatic redirect to a template letting the user know that he doesn't have the required permissions for the event.
erSTOP The event returns a response to an AJAX request. The template won't be parsed after running the event, debugger code won't be added either.
  • constants used when editing site content through the administrative console.
name description
EDITING_MODE This constant, starting from Core v 5.0.0, replaces the methods EditMode in the event handler and tags of the prefixes "st" and "cms". The value of this constant may be the same as the value of the below 3 constant or equal to zero, which means that the user is currently not in the editing mode of the site. Regardless of the editing mode of the site, the orange "Edit" buttons will appear above the parts of the template that can be changed. This constant will be available starting with Core v 5.0.0.
EDITING_MODE_CMS Site editing mode, where the only things that can be changed are items contained in cms-blocks (this was the only possible site editing mode until Core v 5.0.0). This constant will be available starting with Core v 5.0.0.
EDITING_MODE_LAYOUT Site editing mode where only the content of blocks can be changed that were setup using the " layout_view " option:
<inp2:m_RenderElement name="block_name" layout_view="1"/>

In the theme "default2007" these are the "sidebar" and "content" blocks in the current template. This constant is available starting with Core v 5.0.0.

EDITING_MODE_DESIGN

Site editing mode, where the design of the blocks can be changed, i.e. those blocks that were indicated in the parameter "design" (in the example that's "design_block_name") while setting up other (in the example that's "element_name") blocks. For example:

<inp2:m_RenderElement name="element_name" design="design_block_name"/>

In the theme "default2007" these are the "blue_box" and "content_box" blocks. This constant is available starting with Core v 5.0.0.

  • miscellaneous:
name description value
ENV_VAR_NAME The value of this constant is used to determine the name of the environment variable in a request to the server.
env
VALUE_LIST_SEPARATOR The value that will be used for associating possible options in the ValueList fields (in all tables except the ConfigurationAdmin table).
||
REGEX_EMAIL_USER Regular expression that checks the name part of an email. Using constants REGEX_EMAIL_USER and REGEX_EMAIL_DOMAIN it's possible to put together a regular expression that checks the email address:
$regexp = '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i';

Constant available since Core v 4.0.1.

[-a-zA-Z0-9!\#$%&*+\/=?^_`{|}~.]+
REGEX_EMAIL_DOMAIN Regular expression that checks the domain in an email address. Using constants REGEX_EMAIL_USER and REGEX_EMAIL_DOMAIN it's possible to put together a regular expression that checks the email address:
$regexp = '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i';

Constant available since Core v 4.0.1.

[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\.[a-zA-Z]{2,6}
ALLOW_DEFAULT_SETTINGS Данная константа задумана для передачи в метод "kApplication::RecallPersistentVar" в качестве значения по умолчанию. Это подробнее показано на приведённом ниже примере.
$value = $this->Application->RecallPersistentVar('VarName', ALLOW_DEFAULT_SETTINGS);

Если требуемой переменной в таблице PersistentSessionData нету и используется эта константа, то будет возвращено значение этой переменной взятое у пользователя, указанного в конфигурационной переменной DefaultSettingsUserId. Данная константа доступна начиная с Core v 4.2.2.

_USE_DEFAULT_USER_DATA_

Constants are identifier values that can't change as the script runs.

config.php constants

In the root directory of the project (the one that's in the FULL_PATH constant) there is a file config.php that contains settings for connecting to the database along with other parameters that by initializing K4 become constants. Into this file, a commit can never be made. By its format, this file looks similar to a regular ini file. The only difference is the file extension and the protected php design in the beginning of the file.

constant name option name description
SQL_TYPE DBType Database server type. Right now, only MySQL is supported.
SQL_SERVER DBHost IP address or server name of the database.
SQL_USER DBUser Username for connecting to the database.
SQL_PASS DBUserPassword Password for connecting to the database.
SQL_DB DBName Database name.
SQL_COLLATION DBCollation Collation type used when working with the database (for example "utf8_general_ci").
SQL_CHARSET DBCharset Data encoding type used for working with the database (for example "utf8").
TABLE_PREFIX TablePrefix Prefix of database tables of the project in the database.
DOMAIN Domain Domain where the site is located. Used for leaving SSL-mode and for checking an In-Portal license.
ADMIN_DIRECTORY AdminDirectory Location of the administrative console directory relative to FULL_PATH. Available starting with Core v 4.3.0.
EDITOR_PATH EditorPath Location of the directory with the FCKEditor, relative to FULL_PATH (usually "/core/editor/"). Available starting with Core v 4.3.2.
WRITEABLE_BASE WriteablePath Directory into which the server has permissions to write (usually "/system").
APPLICATION_CLASS ApplicationClass Class that's used to create an Application object, for example "EApplication".
APPLICATION_PATH ApplicationPath Location of the file with the class indicated in APPLICATION_CLASS, relative to the root of the site (with the "/" character in front), for example "/custom/units/sections/e_application.php".