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
(System constants: дополнение)
(General application constants: дополнение)
Line 119: Line 119:
Constant available since [[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.
+
Constants are identifier values that can't change as the script runs.
== config.php constants ==
== config.php constants ==

Revision as of 17:10, 4 November 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 "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".