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)
 
(6 intermediate revisions not shown.)
Line 20: 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 65: Line 65:
| {{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.
|-
|-
-
| {{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|hooks]] won't continue). There won't be a redirect.
|-
|-
| {{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|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.
Line 81: Line 81:
|-
|-
| {{ConfigProperty|EDITING_MODE_LAYOUT}}
| {{ConfigProperty|EDITING_MODE_LAYOUT}}
-
| Site editing mode where only the content of blocks can be changed that were setup using the "<code> layout_view </ code>" option:
+
| 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"/>
Line 96: Line 96:
|}
|}
-
* разное:
+
* 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".