function textFields($className, $name, $value, $yii_t_label) { if (is_array($value)) { $result = ''; foreach ($value as $key => $val) { $result .= textFields($className, $name . '[' . $key . ']', $val, $yii_t_label . '.' . $key); } } else { $id = $className . '_value'; $result = '<label for="' . $id . '">' . Module::t('settings', $yii_t_label) . ':' . Html::textInput($name, $value) . '</label>'; } return $result; }
echo Html::encode($this->title); ?> </title> <?php $this->head(); ?> </head> <body> <?php $this->beginBody(); ?> <div class="wrap"> <?php NavBar::begin(); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => Module::t('app', 'Home'), 'url' => Yii::$app->homeUrl], ['label' => Module::t('app', 'Settings'), 'url' => ['/settings']], $user->isGuest ? ['label' => Module::t('app', 'Login'), 'url' => ['site/login']] : ['label' => Module::t('app', 'Logout') . ' (' . $user->identity->username . ')', 'url' => ['site/logout']]]]); NavBar::end(); ?> <!-- Вывод flash-сообщений --> <?php foreach (Yii::$app->getSession()->getAllFlashes() as $key => $message) { echo '<div class="flash-' . $key . '">' . $message . "</div>\n"; } ?> <!-- Ошибки --> <div id="error"></div> <div class="container" style="margin: 20px;"> <?php
/** * Получает модель по заданным параметрам поиска. * * @param string $name имя перемаметра настройки: * @param boolean $throwException Бросать исключение, если запись не найдена. * @return mixed $model * @throws yii\web\HttpException 404 "Параметр настройки не найден!" */ public static function getModel($name, $throwException = true) { // Читаю файл настроек: settings.json $settings = self::getJsonSettings(); $model = __CLASS__; $model = new $model(); if (!isset($settings[$name])) { if ($throwException) { throw new \yii\web\HttpException('404', Module::t('app', 'Setting name not found!')); } return null; } $settings = $settings[$name]; $settings['name'] = $name; $model->attributes = $settings; return $model; }
}, sLoadingRecords: '<?php echo Module::t('app', 'Loading...'); ?> ', sProcessing: '<?php echo Module::t('app', 'Processing...'); ?> ', oAria: { sSortAscending: '<?php echo Module::t('app', ': enable sort by asc'); ?> ', sSortDescending: '<?php echo Module::t('app', ': enable sort by desc'); ?> ' } } }; $.fn.dataTable.ext.oPagination.iFullNumbersShowPages = 6; // Число страниц в пейджере dataTables[selector] = { selector: selector, options: options }; // Запуск DataTables if ($(selector).length != 0) { dataTables[selector]['dom'] = $(selector).dataTable(options);
</head> <body> <?php $this->beginBody(); ?> <div class="wrap"> <?php NavBar::begin(['options' => ['class' => 'user-menu']]); $items = []; $items[] = ['label' => Module::t('app', 'Home'), 'url' => Yii::$app->homeUrl]; if ($user->isGuest and Yii::$app->controller->module->is_password_required()) { $items[] = ['label' => Module::t('app', 'Login'), 'url' => ['site/login']]; } if (!$user->isGuest) { $items[] = ['label' => Module::t('app', 'Logout') . ' (' . $user->identity->username . ')', 'url' => ['site/logout'], 'linkOptions' => ['data-method' => 'post']]; } echo Nav::widget(['items' => $items]); NavBar::end(); ?> <!-- Вывод flash-сообщений --> <?php foreach (Yii::$app->getSession()->getAllFlashes() as $key => $message) { echo '<div class="flash-' . $key . '">' . $message . "</div>\n"; } ?> <!-- Ошибки --> <div id="error"></div>
<?php use alhimik1986\yii2_settings_module\Module; $pageTitle = Module::t('app', 'System settings'); $this->title = $pageTitle; // Заголовок страницы $this->params['breadcrumbs'] = array($pageTitle); // Хлебные крошки (навигация сайта) echo $this->render('_index_js'); // Подключаю java-скрипты echo $this->render('_index_DataTables'); // Подключаю java-скрипты $this->registerCss('#urv-form label {margin-top:5px; display:block;}'); ?> <?php // Таблица с списком настроек ?> <table id="urv-table" class="urv-table"> <thead> <tr> <th style="min-width:110px"><?php echo $model->getAttributeLabel('name'); ?> </th> <th style="min-width:200px"><?php echo $model->getAttributeLabel('label'); ?> </th> <th style="min-width:350px"><?php echo $model->getAttributeLabel('description');