waSystemConfig

Класс для получения информации о конфигурации фреймворка

Contents...

To obtain an instance of this class, use method wa()->getConfig().

Methods

public function getAuth()

Returns authorization parameters of all websites. For each website, the method returns the authorization setting status and the ID of the app selected for managing website visitors’ login and signup. If the authorization option is not enabled in a website’s settings, then the method either does not include that website in its return value or returns an empty array for it.

Example

$auth_config = wa()->getConfig()->getAuth();

Result

array(
  'mydomain.com' => array(
    'auth' => true,
    'app' => 'site',
  ),
  'seconddomain.com' => array(
    'auth' => true,
    'app' => 'shop',
  ),
)

public function getBackendUrl ($with_root_url = false)

Returns relative URL of backend.

Parameters

Example

wa()->getConfig()->getBackendUrl();

Result

webasyst

Example

wa()->getConfig()->getBackendUrl(true);

Result

/webasyst/

public function getConfigFile ($file, $default = array())

Returns the contents of a system configuration file.

Parameters

Example

wa()->getConfig()->getConfigFile('config');

Result

array(
  'debug' => true,
  'backend_url' => 'admin',
  'mod_rewrite' => true,
)

public function getCurrentUrl()

Returns relative URL of current HTTP request.

Example

wa()->getConfig()->getCurrentUrl();

Result

/webasyst/blog/?plugin=test&action=settings

public function getDatabase()

Returns the configurations of all databases connected to the framework, from file wa-config/db.php.

Example

wa()->getConfig()->getDatabase();

Result

array(
  'default' => array(
    'type' => 'mysqli',
    'host' => 'localhost',
    'port' => '3306',
    'user' => 'admin',
    'password' => 'qL5UfHtoV4k8Xw7M',
    'database' => 'webasyst',
    'sql_mode' => 'TRADITIONAL',
  ),
)

public function getDomain()

Returns current HTTP request’s URL domain name.

Example

wa()->getConfig()->getDomain();

Result

mydomain.com

public function getHostUrl()

Returns the current HTTP request’s host URL without trailing slash.

Example

wa()->getConfig()->getHostUrl();

Result

https://mydomain.com

public function getLocales ($type = false)

Returns information of all locales enabled in framework’s configuration file wa-config/locale.php.

Parameters

Example

wa()->getConfig()->getLocales();

Result

array(
  0 => 'en_US',
  1 => 'ru_RU',
)

Example

wa()->getConfig()->getLocales(true);

Result

array(
  'en_US' => array(
    'iso3' => 'usa',
    'name' => 'English',
    'region' => 'USA',
    'english_name' => 'English',
    'english_region' => 'USA',
    'date_formats' => array(
      'humandate' => 'F j, Y',
      'date' => 'm/d/Y',
      'dtime' => 'd/m H:i',
      'datetime' => 'm/d/Y H:i',
      'fulldatetime' => 'm/d/Y H:i:s',
    ),
    'decimal_point' => '.',
    'frac_digits' => '2',
    'thousands_sep' => ',',
    'first_day' => 7,
    'amount_in_words' => array(
      'delim' => array(
        10 => '-',
        100 => ' and ',
      ),
    ),
    'currency' => 'USD',
  ),
  'ru_RU' => array(
    'iso3' => 'rus',
    'name' => 'Русский',
    'region' => 'Российская Федерация',
    'english_name' => 'Russian',
    'english_region' => 'Russian Federation',
    'date_formats' => array(
      'humandate' => 'j f Y',
      'date' => 'd.m.Y',
      'dtime' => 'd.m H:i',
      'datetime' => 'd.m.Y H:i',
      'fulldatetime' => 'd.m.Y H:i:s',
    ),
    'date_month_postfix' => 'я',
    'decimal_point' => ',',
    'frac_digits' => '2',
    'thousands_sep' => ' ',
    'first_day' => 1,
    'amount_in_words' => array(
      'plural' => array(
        1000 => 2,
      ),
    ),
    'translit_table' => array(
      'А' => 'A',
      'Б' => 'B',
      'В' => 'V',
      'Г' => 'G',
      'Д' => 'D',
      'Е' => 'Ye',
      'Ё' => 'Yo',
      'Ж' => 'Zh',
      'З' => 'Z',
      'И' => 'I',
      'Й' => 'Y',
      'К' => 'K',
      'Л' => 'L',
      'М' => 'M',
      'Н' => 'N',
      'О' => 'O',
      'П' => 'P',
      'Р' => 'R',
      'С' => 'S',
      'Т' => 'T',
      'У' => 'U',
      'Ф' => 'F',
      'Х' => 'Kh',
      'Ц' => 'Ts',
      'Ч' => 'Ch',
      'Ш' => 'Sh',
      'Щ' => 'Shch',
      'Ь' => '',
      'Ы' => 'Y',
      'Ъ' => '',
      'Э' => 'E',
      'Ю' => 'Yu',
      'Я' => 'Ya',
      'а' => 'a',
      'б' => 'b',
      'в' => 'v',
      'г' => 'g',
      'д' => 'd',
      'е' => 'e',
      'ё' => 'yo',
      'ж' => 'zh',
      'з' => 'z',
      'и' => 'i',
      'й' => 'y',
      'к' => 'k',
      'л' => 'l',
      'м' => 'm',
      'н' => 'n',
      'о' => 'o',
      'п' => 'p',
      'р' => 'r',
      'с' => 's',
      'т' => 't',
      'у' => 'u',
      'ф' => 'f',
      'х' => 'kh',
      'ц' => 'ts',
      'ч' => 'ch',
      'ш' => 'sh',
      'щ' => 'shch',
      'ь' => '',
      'ы' => 'y',
      'ъ' => '',
      'э' => 'e',
      'ю' => 'yu',
      'я' => 'ya',
    ),
    'currency' => 'RUB',
  ),
)

Example

wa()->getConfig()->getLocales('name');

Result

array(
  'en_US' => 'English',
  'ru_RU' => 'Русский',
)

Example

wa()->getConfig()->getLocales('name_region');

Result

array(
  'en_US' => 'English (USA)',
  'ru_RU' => 'Русский (Российская Федерация)',
)

public function getPath ($name, $file = null)

Returns the path to a framework’s directory or PHP file.

Parameters

Example

wa()->getConfig()->getPath('data');

Result

/var/www/mywebsite/wa-data

Example

wa()->getConfig()->getPath('data', 'public/shop/products/thumb');

Result

/var/www/mywebsite/wa-data/public/shop/products/thumb.php

public function getRequestUrl ($without_root = true, $without_params = false)

Returns current HTTP request URL.

Parameters

Example

wa()->getConfig()->getRequestUrl()

Result

webasyst/myapp/?action=save

Example

wa()->getConfig()->getRequestUrl(false)

Result

https://mydomain.com/webasyst/myapp/?action=save

Example

wa()->getConfig()->getRequestUrl(false, true)

Result

https://mydomain.com/webasyst/myapp/

public function getRootPath()

Returns the path to framework’s root directory.

Example

wa()->getConfig()->getRootPath()

Result

/var/www/mywebsite

public function getRootUrl ($absolute = false, $script = false)

Returns framework’s root URL.

Parameters

Example

wa()->getConfig()->getRootUrl()

Result

/

Example

wa()->getConfig()->getRootUrl(true)

Result

https://mydomain.com/

public static function isDebug()

Returns debug mode status.

Example

$debug_mode_enabled = waSystemConfig::isDebug();

public static function systemOption ($name)

Returns a system configuration parameter value.

Parameters

Example

$mod_rewrite_enabled = waSystemConfig::systemOption('mod_rewrite');