K4:Константы
From In-Portal Developers Guide
Line 1: | Line 1: | ||
{{toc | category = Структура приложения | sortkey = 003.001}} | {{toc | category = Структура приложения | sortkey = 003.001}} | ||
- | + | In K4, constants are separated based on their meaning into: | |
- | In K4, constants are separated based on their meaning | + | |
* '''system''' - defined in "<code>core/kernel/startup.php</code>" | * '''system''' - defined in "<code>core/kernel/startup.php</code>" | ||
* '''general application''' - defined in "<code>core/kernel/constants.php</code>" | * '''general application''' - defined in "<code>core/kernel/constants.php</code>" | ||
Line 62: | Line 61: | ||
! name || description | ! name || description | ||
|- | |- | ||
- | | {{ConfigProperty|erSUCCESS}} || Event finished working successfully | + | | {{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}} || Event finished working, but didn't accomplish one or more of the requested tasks. There won't be a redirect. | | {{ConfigProperty|erFAIL}} || Event finished working, but didn't accomplish one or more of the requested tasks. There won't be a redirect. | ||
Line 68: | Line 67: | ||
| {{ConfigProperty|erFATAL}} || The event didn't accomplish any part of its task ([[K4:Hooks|хуки]] won't continue). There won't be a redirect. | | {{ConfigProperty|erFATAL}} || The event didn't accomplish any part of its task ([[K4:Hooks|хуки]] won't continue). There won't be a redirect. | ||
|- | |- | ||
- | | {{ConfigProperty|erPERM_FAIL}} || Checking [[К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}} || 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. | | {{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. |
Revision as of 00:48, 29 March 2009
| ||
---|---|---|
Статьи в этой категории | ||
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 " |
SERVER_NAME | The name of the Virtual Host, which is running the site (the contents of the variable $_SERVER['SERVER_NAME']). |
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). |
Исходный код требует реорганизации (refactoring ).Constants WRITEABLE and WRITEBALE_BASE are incorrectly named (misspelled). In English obviously, the correct names would be WRITABLE and WRITABLE_BASE respectively. |
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. | |
STATUS_DISABLED | Inactive record. | |
STATUS_PENDING | Record is awaiting approval by the administrator. | |
- 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 (хуки 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 </ code>" option:
" 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 " <inp2:m_RenderElement name="element_name" design="design_block_name"/> In the theme " |
- разное:
название | описание | значение |
---|---|---|
ENV_VAR_NAME | Значение данной константы используется для определения названия переменной окружения в запросе к серверу. | env |
VALUE_LIST_SEPARATOR | Значение, которое будет использоваться для объединения возможных опций в полях ValueList (во всех таблицах, кроме таблицы ConfigurationAdmin). | || |
REGEX_EMAIL_USER
| Регулярное выражение, которое проверяет части с именем пользователя в адресе электронной почты (email ). Используя константы REGEX_EMAIL_USER и REGEX_EMAIL_DOMAIN можно составить регулярное выражение для проверки адреса электронной почты:
$regexp = '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i'; Константа доступна начиная с Core v 4.0.1. | [-a-zA-Z0-9!\#$%&*+\/=?^_`{|}~.]+ |
REGEX_EMAIL_DOMAIN
| Регулярное выражение, которое проверяет части с доменом (domain ) в адресе электронной почты (email ). Используя константы REGEX_EMAIL_USER и REGEX_EMAIL_DOMAIN можно составить регулярное выражение для проверки адреса электронной почты:
$regexp = '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i'; Константа доступна начиная с Core v 4.0.1. | [a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\.[a-zA-Z]{2,6} |
Константы это идентификаторы значений, которые не могут изменяться по ходу выполнения скрипта.
Константы из config.php
В базовой директории проекта (той, что в FULL_PATH константе) находиться файл config.php
, который содержит настройки для подключения к базе данных и ряд других параметров, которые при инициализации K4 превращаются в константы. На данный файл нельзя, не в коем случае, делать commit. По своему формату этот файл похож на обычный ini файл. Единственное отличие это расширение файла и защитная php конструкция в его начале.
название константы | название опции | описание |
---|---|---|
SQL_TYPE | DBType | Тип сервера баз данных. Пока поддерживается только MySQL. |
SQL_SERVER | DBHost | IP адрес или имя сервера баз данных. |
SQL_USER | DBUser | Имя пользователя, для подключения к базе данных. |
SQL_PASS | DBUserPassword | Пароль, для подключения к базе данных. |
SQL_DB | DBName | Название базы данных. |
SQL_COLLATION | DBCollation | Тип сопоставления строк, используемый при работе базой данных (напр. "utf8_general_ci ").
|
SQL_CHARSET | DBCharset | Кодировка данных, используемая при работе базой данных (напр. "utf8 ").
|
TABLE_PREFIX | TablePrefix | Префикс таблиц проекта в базе данных. |
DOMAIN | Domain | Домен, на котором сайт находиться. Используется для выхода из SSL-режима, а также для проверки лицензии в In-Portal .
|
ADMIN_DIRECTORY | AdminDirectory | Расположение директории с административной консолью относительно FULL_PATH. Доступна, начиная с Core v 4.3.0. |
EDITOR_PATH | EditorPath | Расположение директории с FCKEditor относительно FULL_PATH (обычно "/core/editor/ "). Доступна, начиная с Core v 4.3.2.
|
WRITEABLE_BASE | WriteablePath | Директория, в которую имеет право писать сервер (обычно "/system ").
|
APPLICATION_CLASS | ApplicationClass | Класс, который используется для создания объекта Application, например "EApplication ".
|
APPLICATION_PATH | ApplicationPath | Расположение файла с классом, указанным в APPLICATION_CLASS относительно корня сайта (с указанием "/ " спереди), например. "/custom/units/sections/e_application.php ".
|