/** * @param string $description ---> enter the title or entry of model * @param object $model ---> enter lastest saved model * @param object $user ---> creater of the notification record (mostly current user model) * @param string $type ---> current controller name or a manualy hard coded string for comments (comment,journal,mood,event,photo,activity) * @param string $shared_with ---> shared_with values if latest saved model has a column named shared_with, else need to enter customized values */ public function notify($description, $model, $user, $type, $shared_with = null) { //create notification record - DTR $sharedWith = array(); if ($shared_with != null) { if ($shared_with == '*') { $sharedWith = yii\helpers\ArrayHelper::getColumn($user->others, 'id'); } else { $sharedWith = explode(',', $shared_with); } } else { $sharedWith = yii\helpers\ArrayHelper::getColumn($user->findParents()->all(), 'id'); } foreach ($sharedWith as $shared_id) { $notify = new Notification(); $notify->date = date("Y-m-d h:i:s"); $notify->shared_id = (int) $shared_id; $notify->type_id = $model->id; $notify->description = $description; $notify->type = $type; $notify->user_id = $user->id; $notify->status = 0; $notify->save(); } //end of notification record entry }
protected static function getYii() { $env = self::$runtimeEnviroment; if (in_array($env, ['dev'])) { defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); error_reporting(E_ALL); } else { if (in_array($env, ['test'])) { defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'test'); } else { if (in_array($env, ['live', 'prod'])) { defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_ENV') or define('YII_ENV', 'prod'); } } } require __DIR__ . '/../../vendor/autoload.php'; require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'; require __DIR__ . '/../../common/config/bootstrap.php'; require __DIR__ . '/../config/bootstrap.php'; $config = yii\helpers\ArrayHelper::merge(require __DIR__ . '/../../common/config/main.php', require __DIR__ . '/../../common/config/main-local.php', require __DIR__ . '/../config/main.php', require __DIR__ . '/../config/main-local.php'); $envFile = __DIR__ . "/../../common/config/{$env}.php"; if (is_file($envFile)) { $config = yii\helpers\ArrayHelper::merge($config, require $envFile, require __DIR__ . '/../../common/config/swoole.php'); } self::$yii = new yii\web\Application($config); }
public function getSharedWith($withoutWrapper = false) { $shared_users = User::find()->where(['id' => explode(",", $this->shared_with)])->all(); if ($withoutWrapper) { return implode(', ', yii\helpers\ArrayHelper::getColumn($shared_users, 'fullname')); } else { return "<span class='label label-success'>" . implode('</span> <span class="label label-success">', yii\helpers\ArrayHelper::getColumn($shared_users, 'fullname')) . "</span>"; } }
/** * the array of report ids reported by the current user in mentioned $month of the $year * where the keys(key+1) of the array represent the working day numbers of the user * @param type $year int * @param type $month int * @return type array */ public function listOfReportsIDbyCurrentUser($year, $month) { if ($month <= 9) { $month = '0' . $month; } $userID = Yii::$app->user->identity->id; $arrayID = yii\helpers\ArrayHelper::map(Reports::find()->where(['like', 'date', $year . "-" . $month])->andFilterWhere(['user_id' => $userID])->all(), 'id', 'id'); return array_values($arrayID); }
<?php // set correct script paths $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE; $_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL; return yii\helpers\ArrayHelper::merge(require __DIR__ . '/../../config/web.php', require __DIR__ . '/../_config.php', ['components' => ['db' => ['dsn' => 'mysql:host=localhost;dbname=dotplant2_functional']]]);
<?php $_SERVER['SCRIPT_FILENAME'] = YII_TEST_BACKEND_ENTRY_FILE; $_SERVER['SCRIPT_NAME'] = YII_BACKEND_TEST_ENTRY_URL; /** * Application configuration for backend functional tests */ return yii\helpers\ArrayHelper::merge(require YII_APP_BASE_PATH . '/common/config/main.php', require YII_APP_BASE_PATH . '/common/config/main-local.php', require YII_APP_BASE_PATH . '/backend/config/main.php', require YII_APP_BASE_PATH . '/backend/config/main-local.php', require dirname(__DIR__) . '/config.php', require dirname(__DIR__) . '/functional.php', require __DIR__ . '/config.php', []);
<?php if ($showColorNumberSelection) { echo Html::beginForm(['default/showupdatecolorsizeimage', 'item_id' => $itemData['item_id']], 'post'); echo Html::activeDropDownList($itemModel, 'numberOfColors', $colorNumbers, ['onchange' => 'this.form.submit()', 'prompt' => '--Choose Number of Colors--']); echo Html::endForm(); ?> <br/> <?php if ($showColorSizeImageSelection) { $form = ActiveForm::begin(['method' => 'post', 'action' => 'index.php?r=item/default/insetitem&sub_cat_it=' . $itemModel->item_sub_category_id . '&item_name=' . $itemModel->item_name . '&item_mirrVal=' . $itemModel->item_mirrorval . '&item_no_of_colors=' . $itemModel->numberOfColors . '&item_id=' . $itemModel->item_id . '&item_hash=' . $itemModel->item_hashTag, 'options' => ['enctype' => 'multipart/form-data']]); for ($i = 0; $i < $colorNumbers[$itemModel->numberOfColors]; $i++) { echo '<label class="control-label">Enter Details of Item ' . ($i + 1) . '</label>'; ?> <br/> <?php echo Html::activeDropDownList($itemModel, 'itemColors[' . $i . ']', yii\helpers\ArrayHelper::map($colors, 'color_name', 'color_name'), ['prompt' => '--Choose color--']); ?> <table> <tr> <td> <?php echo $form->field($itemModel, 'itemImgFront[' . $i . ']')->fileInput(['accept' => 'image/*', 'style' => 'padding:0px;']); ?> </td> <td> <?php echo $form->field($itemModel, 'itemImgBack[' . $i . ']')->fileInput(['accept' => 'image/*']); ?> </td> <td>
<?php /** * Application configuration for app unit tests */ return yii\helpers\ArrayHelper::merge(require YII_APP_BASE_PATH . '/common/config/main.php', require YII_APP_BASE_PATH . '/common/config/main-local.php', require YII_APP_BASE_PATH . '/app/config/main.php', require YII_APP_BASE_PATH . '/app/config/main-local.php', \common\helpers\ConfigHelper::getModulesConfigs($params["enabledModules"]), require dirname(__DIR__) . '/config.php', require dirname(__DIR__) . '/unit.php', require __DIR__ . '/config.php', []);
<?php defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(dirname(__DIR__))))); /** * Application configuration for frontend acceptance tests */ return yii\helpers\ArrayHelper::merge(require YII_APP_BASE_PATH . '/common/config/main.php', require YII_APP_BASE_PATH . '/common/config/main-local.php', require YII_APP_BASE_PATH . '/frontend/config/main.php', require YII_APP_BASE_PATH . '/frontend/config/main-local.php', require dirname(__DIR__) . '/config.php', require dirname(__DIR__) . '/acceptance.php', require __DIR__ . '/config.php', []);
/** * @return all batches */ public static function getStuBatches() { $dataTmp = Batches::find()->where(['is_status' => 0])->orderBy('batch_name')->all(); $result = yii\helpers\ArrayHelper::map($dataTmp, 'batch_id', 'batch_name'); return $result; }
<?php // NOTE: Make sure this file is not accessible when deployed to production if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) { die('You are not allowed to access this file.'); } defined('YII_ENV') or define('YII_ENV', 'test'); require dirname(__DIR__) . '/vendor/autoload.php'; require dirname(__DIR__) . '/vendor/yiisoft/yii2/Yii.php'; $config = yii\helpers\ArrayHelper::merge(require dirname(__DIR__) . '/app/config/common.php', require dirname(__DIR__) . '/app/tests/codeception/config/acceptance.php'); (new yii\web\Application($config))->run();
<?php $_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE; $_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL; /** * Application configuration for functional tests */ return yii\helpers\ArrayHelper::merge(require __DIR__ . '/../../../config/web.php', require __DIR__ . '/config.php', ['components' => ['request' => ['enableCsrfValidation' => false]]]);
<?php // comment out the following two lines when deployed to production defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_ENV') or define('YII_ENV', 'prod'); require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php'; $config = yii\helpers\ArrayHelper::merge(require __DIR__ . '/../config/common.php', require __DIR__ . '/../config/common-local.php', require __DIR__ . '/../config/web.php', require __DIR__ . '/../config/web-local.php'); (new yii\web\Application($config))->run();
<?php defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); require __DIR__ . '/../../vendor/autoload.php'; require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'; require __DIR__ . '/../../common/config/bootstrap.php'; require __DIR__ . '/../config/bootstrap.php'; $config = yii\helpers\ArrayHelper::merge(require __DIR__ . '/../../common/config/main.php', getParamsFromFile(__DIR__ . '/../../common/config/main-local.php', []), require __DIR__ . '/../config/main.php', getParamsFromFile(__DIR__ . '/../config/main-local.php', [])); $application = new yii\web\Application($config); $application->run();
<?php /** * Скрипт принимает и обрабатывает уведомления от PayQR */ defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php'; require __DIR__ . '/../common/config/bootstrap.php'; require __DIR__ . '/../console/config/bootstrap.php'; $config = yii\helpers\ArrayHelper::merge(require __DIR__ . '/../common/config/main.php', require __DIR__ . '/../common/config/main-local.php', require __DIR__ . '/../console/config/main.php', require __DIR__ . '/../console/config/main-local.php'); $application = new yii\console\Application($config); $exitCode = $application->run(); require_once __DIR__ . "/PayqrConfig.php"; // подключаем основной класс //инициализируем данными нашу библиотеку if (PayqrConfig::init()) { exit("Error init PayQR market!"); } try { $receiver = new PayqrReceiver(); $receiver->handle(); } catch (PayqrExeption $e) { echo $e->response; } exit($exitCode);
/** * Merge array from files * @param array $files files list * @param array $result base array for merge * @return array */ public function mergeFiles($files, $result = []) { foreach ($files as $file) { $filename = $this->getFilename($file); if (file_exists($filename)) { $result = yii\helpers\ArrayHelper::merge($result, require $filename); } } return $result; }
<?php defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); //prod,dev define('APP_PATH', './app'); //应用名字 define('APP_NAME', 'backend'); define('SITE_ROOT', str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT'])); //站点根目录 require './vendor/autoload.php'; require './vendor/yiisoft/yii2/Yii.php'; require APP_PATH . '/common/config/bootstrap.php'; require APP_PATH . '/' . APP_NAME . '/config/bootstrap.php'; $config = yii\helpers\ArrayHelper::merge(require APP_PATH . '/common/config/main.php', require APP_PATH . '/common/config/main-local.php', require APP_PATH . '/' . APP_NAME . '/config/main.php', require APP_PATH . '/' . APP_NAME . '/config/main-local.php'); $application = new yii\web\Application($config); $application->run();
<?php /** * Configuration file for the "backend" (web/admin.php) web application */ return yii\helpers\ArrayHelper::merge(require __DIR__ . '/web.php', ['controllerNamespace' => 'app\\controllers\\backend', 'viewPath' => '@app/views/backend', 'components' => ['session' => ['name' => 'MyProjectAdminSession'], 'user' => ['identityClass' => 'app\\models\\db\\Admin', 'idParam' => '__adminId', 'identityCookie' => ['name' => 'MyProjectAdminIdentity', 'httpOnly' => true], 'enableAutoLogin' => false], 'urlManager' => require __DIR__ . '/backend-url-manager.php', 'frontendUrlManager' => require __DIR__ . '/frontend-url-manager.php']]);
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use kartik\select2\Select2; use kartik\widgets\FileInput; // /* @var $this yii\web\View */ /* @var $model lukisongroup\models\hrd\organisasi */ /* @var $form yii\widgets\ActiveForm */ $array = lukisongroup\hrd\models\Organisasi::find()->distinct()->all(); $dataparent = yii\helpers\ArrayHelper::map($array, 'id', 'title'); $datastatik = ["1" => "a", "2" => "b", "3" => "c"]; // $drop = ArrayHelper::map(Corp::find()->all(), 'CORP_ID', 'CORP_NM'); ?> <div class="organisasi-form"> <?php $form = ActiveForm::begin(['id' => 'creupdt', 'enableClientValidation' => true, 'options' => ['enctype' => 'multipart/form-data']]); ?> <!--$form->field($model, 'id')->textInput(['maxlength' => true]) ?>--> <?php echo $form->field($model, 'parent')->widget(Select2::classname(), ['data' => $dataparent, 'options' => ['placeholder' => 'pilih ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php
<?php /** * Application configuration for acceptance tests */ return yii\helpers\ArrayHelper::merge(require PATH_CONF . 'web.php', require PATH_CONF . 'dev.php', require __DIR__ . '/config.php', []);
<?php defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); defined('REALM') or define('REALM', 'TmCt'); error_reporting(E_ALL & ~E_NOTICE); require __DIR__ . '/../../vendor/autoload.php'; require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'; require __DIR__ . '/../../common/config/aliases.php'; $config = yii\helpers\ArrayHelper::merge(require Yii::getAlias('@common') . '/config/main.php', require Yii::getAlias('@common') . '/config/main-local.php', require Yii::getAlias('@api') . '/config/main.php', require Yii::getAlias('@api') . '/config/main-local.php'); /* echo '<pre>'; print_r($config); echo '</pre>'; ///*/ $application = new yii\web\Application($config); $application->run();
/** * @return all Section */ public static function getStuSection() { $dataTmp = Section::find()->where(['is_status' => 0])->orderBy('section_name')->all(); $result = yii\helpers\ArrayHelper::map($dataTmp, 'section_id', 'section_name'); return $result; }
<?php // set correct script paths $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE; $_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL; return yii\helpers\ArrayHelper::merge(require __DIR__ . '/../../config/main.php', require __DIR__ . '/../../config/main-local.php', require __DIR__ . '/../../../common/config/main.php', require __DIR__ . '/../../../common/config/main-local.php', require __DIR__ . '/../_config.php', ['components' => ['db' => ['dsn' => 'mysql:host=localhost;dbname=yii2_advanced_functional']]]);
<?php defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'test'); require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../common/config/bootstrap.php'); require(__DIR__ . '/../config/bootstrap.php'); $config = yii\helpers\ArrayHelper::merge( require(__DIR__ . '/../../common/config/main.php'), require(__DIR__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/'.RG_ENV.'.php') ); $application = new yii\web\Application($config); $application->run();
<?php $config = ['id' => 'yii2-demo', 'name' => 'yii2-demo', 'vendorPath' => VENDOR_PATH, 'timeZone' => 'Asia/Shanghai', 'runtimePath' => WEB_ROOT . '../runtime', 'bootstrap' => ['log'], 'language' => 'zh-CN', 'modules' => ['site' => ['class' => 'modules\\site\\Module']], 'components' => ['i18n' => ['class' => 'modules\\components\\i18n\\I18N'], 'urlManager' => ['class' => 'yii\\web\\UrlManager', 'showScriptName' => false, 'enablePrettyUrl' => true, 'rules' => ['<_m>/<_c>/<_a>' => '<_m>/<_c>/<_a>', '<_m>/<_c>/<_a>.json' => '<_m>/<_c>/<_a>', '<_m>/<_ver>/<_c>/<_a>.json' => '<_m>/<_ver>/<_c>/<_a>']], 'assetManager' => ['linkAssets' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning', 'trace', 'info'], 'logFile' => '@runtime/logs/' . date('Ymd') . '.log', 'maxFileSize' => 10240]]]], 'params' => require __DIR__ . '/params.php']; if (YII_ENV_DEV) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = ['class' => 'yii\\debug\\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.*']]; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = ['class' => 'yii\\gii\\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.*']]; } $config['components'] = yii\helpers\ArrayHelper::merge($config['components'], require __DIR__ . '/env/db.' . YII_ENV . '.php'); $config['components'] = yii\helpers\ArrayHelper::merge($config['components'], require __DIR__ . '/env/cache.' . YII_ENV . '.php'); return $config;
<?php return yii\helpers\ArrayHelper::merge(require __DIR__ . '/../../config/console.php', require __DIR__ . '/../_config.php', ['components' => ['db' => ['class' => '\\yii\\db\\Connection', 'dsn' => 'sqlite:' . dirname(__FILE__) . '/../../data/blog.acceptance.sqlite', 'charset' => 'utf8', 'tablePrefix' => 'yii2_']]]);
<!-- Country --> <?php $listDataCountry = yii\helpers\ArrayHelper::map(common\models\Country::find()->where(['is_status' => 1])->all(), 'id', 'country'); ?> <?php echo $form->field($model, 'country_id', ['inputOptions' => ['class' => 'form-control']])->dropDownList($listDataCountry, ['prompt' => Yii::t('app', '-- Select Country --'), 'onchange' => ' $.get("' . yii\helpers\Url::toRoute(['dependent/getregion']) . '", { id: $(this).val() }) .done(function(data){ $("#' . Html::getInputId($model, 'region_id') . '").html( data ); });']); ?> <!-- Region --> <?php $listDataRegion = yii\helpers\ArrayHelper::map(common\models\Region::find()->all(), 'id', 'region'); ?> <?php echo $form->field($model, 'region_id')->dropDownList($listDataRegion, ['prompt' => '-- Select Region --', 'onchange' => ' $.get("' . yii\helpers\Url::toRoute(['dependent/getcity']) . '", { id: $(this).val() }) .done(function(data){ $("#' . Html::getInputId($model, 'city_id') . '").html( data ); });']); ?> <!-- City --> <?php $listDataCity = \yii\helpers\ArrayHelper::map(\common\models\City::find()->all(), 'id', 'city');
<?php $params = yii\helpers\ArrayHelper::merge(require dirname(dirname(__DIR__)) . '/common/config/params.php', require __DIR__ . '/params.php'); return ['id' => 'app-admin', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'admin\\controllers', 'defaultRoute' => 'cmgcore/site/index', 'bootstrap' => ['log', 'cmgCore'], 'modules' => ['cmgcore' => ['class' => 'cmsgears\\core\\admin\\Module'], 'cmgforms' => ['class' => 'cmsgears\\forms\\admin\\Module'], 'cmgcms' => ['class' => 'cmsgears\\cms\\admin\\Module']], 'components' => ['view' => ['theme' => 'themes\\admin\\Theme'], 'urlManager' => ['rules' => ['apix/<module:\\w+>/<controller:\\w+>/<action:[\\w\\-]+>' => '<module>/apix/<controller>/<action>', 'apix/<controller:\\w+>/<action:[\\w\\-]+>' => 'cmgcore/apix/<controller>/<action>', '<module:\\w+>/<controller:\\w+>/<action:[\\w\\-]+>' => '<module>/<controller>/<action>', '<action:(login|logout|dashboard|forgot-password|reset-password|activate-account)>' => 'cmgcore/site/<action>']], 'cmgCore' => ['loginRedirectPage' => '/dashboard', 'logoutRedirectPage' => '/login'], 'sidebar' => ['class' => 'cmsgears\\core\\admin\\components\\Sidebar', 'modules' => ['cmgcms', 'cmgcore']], 'dashboard' => ['class' => 'cmsgears\\core\\admin\\components\\Dashboard', 'modules' => ['cmgcms', 'cmgcore']]], 'params' => $params];
<?php return yii\helpers\ArrayHelper::merge(require __DIR__ . '/../../../../../config/web.php', require __DIR__ . '/../_config.php', ['components' => []]);
<?php use yii\grid\GridView; use yii\helpers\Html; use app\components\GridViewReservation; $roomsFilterData = yii\helpers\ArrayHelper::map(app\models\Room::find()->all(), 'id', function ($model, $defaultValue) { return sprintf('Floor: %d - Number: %d', $model->floor, $model->room_number); }); $sumPc = 0; $avgPc = 0; if (sizeof($dataProvider->getModels()) > 0) { foreach ($dataProvider->getModels() as $m) { $sumPc += $m->price_per_day; } $avgPc = $sumPc / sizeof($dataProvider->getModels()); } ?> <h2>Reservations</h2> <?php echo GridViewReservation::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'showFooter' => true, 'columns' => ['id', ['header' => 'Room', 'filter' => Html::activeDropDownList($searchModel, 'room_id', $roomsFilterData, ['prompt' => '--- all']), 'content' => function ($model) { return $model->room->floor; }], ['header' => 'Customer', 'attribute' => 'customer.surname'], ['attribute' => 'price_per_day', 'footer' => Yii::$app->formatter->asCurrency($allAvgPc, 'CNY')], 'date_from', 'date_to']]);