本文整理汇总了PHP中HSetting::setConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP HSetting::setConfiguration方法的具体用法?PHP HSetting::setConfiguration怎么用?PHP HSetting::setConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HSetting
的用法示例。
在下文中一共展示了HSetting::setConfiguration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setInstalled
/**
* Sets application in installed state (disables installer)
*/
public function setInstalled()
{
$config = HSetting::getConfiguration();
$config['params']['installed'] = true;
HSetting::setConfiguration($config);
}
示例2: rewriteConfiguration
/**
* Rewrites the configuration file
*/
public static function rewriteConfiguration()
{
// Get Current Configuration
$config = HSetting::getConfiguration();
// Add Application Name to Configuration
$config['name'] = HSetting::Get('name');
// Add Default language
$defaultLanguage = HSetting::Get('defaultLanguage');
if ($defaultLanguage !== null && $defaultLanguage != "") {
$config['language'] = HSetting::Get('defaultLanguage');
} else {
$config['language'] = Yii::app()->getLanguage();
}
// Add Caching
$cacheClass = HSetting::Get('type', 'cache');
if (!$cacheClass) {
$cacheClass = "CDummyCache";
}
$config['components']['cache'] = array('class' => $cacheClass);
// Add User settings
$config['components']['user'] = array();
if (HSetting::Get('defaultUserIdleTimeoutSec', 'authentication_internal')) {
$config['components']['user']['authTimeout'] = HSetting::Get('defaultUserIdleTimeoutSec', 'authentication_internal');
}
// Install Mail Component
$mail = array('class' => 'ext.yii-mail.YiiMail', 'transportType' => HSetting::Get('transportType', 'mailing'), 'viewPath' => 'application.views.mail', 'logging' => true, 'dryRun' => false);
if (HSetting::Get('transportType', 'mailing') == 'smtp') {
$mail['transportOptions'] = array();
if (HSetting::Get('hostname', 'mailing')) {
$mail['transportOptions']['host'] = HSetting::Get('hostname', 'mailing');
}
if (HSetting::Get('username', 'mailing')) {
$mail['transportOptions']['username'] = HSetting::Get('username', 'mailing');
}
if (HSetting::Get('password', 'mailing')) {
$mail['transportOptions']['password'] = HSetting::Get('password', 'mailing');
}
if (HSetting::Get('encryption', 'mailing')) {
$mail['transportOptions']['encryption'] = HSetting::Get('encryption', 'mailing');
}
if (HSetting::Get('port', 'mailing')) {
$mail['transportOptions']['port'] = HSetting::Get('port', 'mailing');
}
if (HSetting::Get('allowSelfSignedCerts', 'mailing')) {
$mail['transportOptions']['options']['ssl']['allow_self_signed'] = true;
$mail['transportOptions']['options']['ssl']['verify_peer'] = false;
}
}
$config['components']['mail'] = $mail;
// Add Theme
$theme = HSetting::Get('theme');
if ($theme && $theme != "") {
$config['theme'] = $theme;
} else {
unset($config['theme']);
}
HSetting::setConfiguration($config);
}
示例3: rewriteConfiguration
/**
* Rewrites the configuration file
*/
public static function rewriteConfiguration()
{
// Get Current Configuration
$config = HSetting::getConfiguration();
// Add Application Name to Configuration
$config['name'] = HSetting::Get('name');
// Add Default language
$config['language'] = HSetting::Get('defaultLanguage');
// Add Caching
$cacheClass = HSetting::Get('type', 'cache');
if (!$cacheClass) {
$cacheClass = "CDummyCache";
}
$config['components']['cache'] = array('class' => $cacheClass);
// Install Mail Component
$mail = array('class' => 'ext.yii-mail.YiiMail', 'transportType' => HSetting::Get('transportType', 'mailing'), 'viewPath' => 'application.views.mail', 'logging' => true, 'dryRun' => false);
if (HSetting::Get('transportType', 'mailing') == 'smtp') {
$mail['transportOptions'] = array();
if (HSetting::Get('hostname', 'mailing')) {
$mail['transportOptions']['host'] = HSetting::Get('hostname', 'mailing');
}
if (HSetting::Get('username', 'mailing')) {
$mail['transportOptions']['username'] = HSetting::Get('username', 'mailing');
}
if (HSetting::Get('password', 'mailing')) {
$mail['transportOptions']['password'] = HSetting::Get('password', 'mailing');
}
if (HSetting::Get('encryption', 'mailing')) {
$mail['transportOptions']['encryption'] = HSetting::Get('encryption', 'mailing');
}
if (HSetting::Get('port', 'mailing')) {
$mail['transportOptions']['port'] = HSetting::Get('port', 'mailing');
}
}
$config['components']['mail'] = $mail;
// Add Theme
$theme = HSetting::Get('theme');
if ($theme && $theme != "") {
$config['theme'] = $theme;
} else {
unset($config['theme']);
}
HSetting::setConfiguration($config);
}
示例4: actionDatabase
/**
* Database action is responsible for all database related stuff.
* Checking given database settings, writing them into a config file.
*
* (Step 3)
*/
public function actionDatabase()
{
Yii::import('installer.forms.*');
$success = false;
$errorMessage = "";
$config = HSetting::getConfiguration();
$form = new DatabaseForm();
if (isset($_POST['ajax']) && $_POST['ajax'] === 'database-form') {
echo CActiveForm::validate($form);
Yii::app()->end();
}
if (isset($_POST['DatabaseForm'])) {
$_POST['DatabaseForm'] = Yii::app()->input->stripClean($_POST['DatabaseForm']);
$form->attributes = $_POST['DatabaseForm'];
if ($form->validate()) {
$connectionString = "mysql:host=" . $form->hostname . ";dbname=" . $form->database;
$password = $form->password;
if ($password == self::PASSWORD_PLACEHOLDER) {
$password = $config['components']['db']['password'];
}
// Create Test DB Connection
Yii::app()->setComponent('db', array('connectionString' => $connectionString, 'username' => $form->username, 'password' => $password, 'class' => 'CDbConnection', 'charset' => 'utf8'));
try {
// Check DB Connection
Yii::app()->db->getServerVersion();
// Write Config
$config['components']['db']['connectionString'] = $connectionString;
$config['params']['installer']['db']['installer_hostname'] = $form->hostname;
$config['params']['installer']['db']['installer_database'] = $form->database;
$config['components']['db']['username'] = $form->username;
if ($form->password != self::PASSWORD_PLACEHOLDER) {
$config['components']['db']['password'] = $form->password;
}
HSetting::setConfiguration($config);
$success = true;
$this->redirect(array('init'));
} catch (Exception $e) {
$errorMessage = $e->getMessage();
}
}
} else {
if (isset($config['params']['installer']['db']['installer_hostname'])) {
$form->hostname = $config['params']['installer']['db']['installer_hostname'];
}
if (isset($config['params']['installer']['db']['installer_database'])) {
$form->database = $config['params']['installer']['db']['installer_database'];
}
if (isset($config['components']['db']['username'])) {
$form->username = $config['components']['db']['username'];
}
if (isset($config['components']['db']['password'])) {
$form->password = self::PASSWORD_PLACEHOLDER;
}
}
// Render Template
$this->render('database', array('model' => $form, 'success' => $success, 'submitted' => isset($_POST['DatabaseForm']), 'errorMessage' => $errorMessage));
}