Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

code-reformat-and-optimization -- done #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
692 changes: 692 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions assets/AppAsset.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
*/

namespace app\assets;
Expand All @@ -11,14 +11,15 @@

/**
* Main application asset bundle.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
* @since 2.0
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';

public $baseUrl = '@web';

public $css = [
'css/site.css',
];
Expand All @@ -29,6 +30,7 @@ class AppAsset extends AssetBundle
'fedemotta\datatables\DataTablesAsset',
'raoul2000\bootswatch\BootswatchAsset',
];

public $jsOptions = ['position' => \yii\web\View::POS_HEAD];
}

12 changes: 6 additions & 6 deletions commands/HelloController.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
*/

namespace app\commands;

use yii\console\Controller;
use yii\console\ExitCode;
use yii\console\Controller;

/**
* This command echoes the first argument that you have entered.
*
* This command is provided as an example for you to learn how to create console commands.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
* @since 2.0
*/
class HelloController extends Controller
{
/**
* This command echoes what you have entered as the message.
*
* @param string $message the message to be echoed.
*
* @return int Exit code
*/
public function actionIndex($message = 'hello world')
Expand Down
2 changes: 1 addition & 1 deletion common/messages/ru/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
'false' => 'Нет',

// models/ProjectsAll
'Xlogin' => 'Логин',
'Xlogin' => 'Логин',
'Final Mark' => 'Финальная оценка',
'Retry' => 'Попыток',
'Status' => 'Статус',
Expand Down
2 changes: 1 addition & 1 deletion components/ChangeThemeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function run()
{
if (ThemesHelper::isDefault()) {
ThemesHelper::setDark();
} else if (ThemesHelper::isDark()) {
} elseif (ThemesHelper::isDark()) {
ThemesHelper::setDefault();
}

Expand Down
2 changes: 1 addition & 1 deletion config/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'controllerNamespace' => 'app\commands',
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
'@npm' => '@vendor/npm-asset',
],
'components' => [
'cache' => [
Expand Down
8 changes: 7 additions & 1 deletion config/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=' . env('DB_HOST', 'mysql') . ';port=' . env('DB_PORT', '3306') .';dbname=' . env('DB_NAME', 'yii2') . ';',
'dsn' => 'mysql:host='
. env('DB_HOST', 'mysql')
. ';port='
. env('DB_PORT', '3306')
. ';dbname='
. env('DB_NAME', 'yii2')
. ';',
'username' => env('DB_USERNAME', 'yii2'),
'password' => env('DB_PASSWORD', 'yii2'),
'charset' => 'utf8',
Expand Down
2 changes: 1 addition & 1 deletion config/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'basePath' => dirname(__DIR__),
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
'@npm' => '@vendor/npm-asset',
],
'language' => 'en-US',
'components' => [
Expand Down
4 changes: 2 additions & 2 deletions config/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

$config = [
'id' => 'basic',
'name'=>'cheatera.pp.ua',
'name' => 'cheatera.pp.ua',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'sourceLanguage' => 'en', // использовать в качестве ключей переводов
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
'@npm' => '@vendor/npm-asset',
],
'modules' => [
'languages' => [
Expand Down
28 changes: 16 additions & 12 deletions controllers/CalculatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ class CalculatorController extends CommonController
/**
* actionIndex
*
* @param Object $model calculator's model
* @param Object $model calculator's model
*
* @return String which sends to the View
*/
public function actionIndex($model = null)
{
$title = Yii::t('app', 'Experience calculator');
$description = Yii::t('app', 'Want to know your level after project evaluation -- use our Experience calculator!');
$description =
Yii::t('app', 'Want to know your level after project evaluation -- use our Experience calculator!');
$this->setMeta($title, $description);

if ($model === null) {
Expand All @@ -35,37 +36,40 @@ public function actionIndex($model = null)
'model' => $model,
'breadcrumbs' => [
'name' => Yii::t('app', 'Calculator'),
'url' => 'calculator'
'url' => 'calculator',
],
]);
}

/**
* getMarkFromPost
*
* @param Object $model reference to Calculator's Model instance
* @param Array $post $post request array
* @param Object $model reference to Calculator's Model instance
* @param Array $post $post request array
*/
private function getMarkFromPost(&$model, $post)
{
if ($model && $post
&& $model->load($post) && $model->validate() ) {
&& $model->load($post)
&& $model->validate()
) {
foreach ($model->getTier() as $k => $v) {
if ( array_key_exists($k, $post) ) {
if (array_key_exists($k, $post)) {
$tier = $model->tier = $k;
}
}
if ( isset($tier)
&& !is_nan($tier)
&& $tier <= 7
&& $tier >= 0 ) {
if (isset($tier)
&& !is_nan($tier)
&& $tier <= 7
&& $tier >= 0
) {
$model->lvlstart = $model->getMark();
}
}
}

/**
* actionFormSubmission
*
* @return Float to be set into the 'Result' field on the View
*/
public function actionFormSubmission()
Expand Down
2 changes: 1 addition & 1 deletion controllers/CamsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function actionIndex()
'isAccessGaranted' => $isAccessGaranted,
'breadcrumbs' => [
'name' => Yii::t('app', 'Cams'),
'url' => 'cams'
'url' => 'cams',
],
]);
}
Expand Down
9 changes: 5 additions & 4 deletions controllers/CommonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public function behaviors()
'rules' => [
[
'allow' => true,
'roles' => ['@']
]
]
'roles' => ['@'],
],
],
],
];
}
Expand All @@ -29,7 +29,8 @@ public function behaviors()
* @param null $title
* @param null $description
*/
protected function setMeta($title = null, $description = null) {
protected function setMeta($title = null, $description = null)
{
$this->view->title = $title;
$this->view->registerMetaTag(['name' => 'description', 'content' => "$description"]);
}
Expand Down
8 changes: 5 additions & 3 deletions controllers/CorrectSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
namespace app\controllers;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\Correct;
use yii\data\ActiveDataProvider;

/**
* CorrectSearch represents the model behind the search form of `app\models\Correct`.
*/
class CorrectSearch extends Correct
{
public $dateStart = null;

public $dateEnd = null;

public function __construct($login, array $configs = [])
{
$this->xlogin = $login;
parent::__construct($configs);
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -63,8 +65,8 @@ public function search($params)
'query' => $query,
'sort' => [
'defaultOrder' => [
'date' => SORT_DESC
]
'date' => SORT_DESC,
],
],
'pagination' => [
'pageSize' => -1,
Expand Down
2 changes: 0 additions & 2 deletions controllers/CorrectionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace app\controllers;

use Yii;
use app\models\CorrectionLog;
use app\controllers\CorrectionsSearch;

/**
* CorrectionLogController implements the CRUD actions for CorrectionLog model.
Expand Down
8 changes: 5 additions & 3 deletions controllers/CorrectionsSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
namespace app\controllers;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\CorrectionLog;
use yii\data\ActiveDataProvider;

/**
* CorrectionLogSearch represents the model behind the search form of `app\models\CorrectionLog`.
*/
class CorrectionsSearch extends CorrectionLog
{
public $dateStart = null;

public $dateEnd = null;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -56,8 +58,8 @@ public function search($params)
'query' => $query,
'sort' => [
'defaultOrder' => [
'date' => SORT_DESC
]
'date' => SORT_DESC,
],
],
'pagination' => [
'pageSize' => -1,
Expand Down
9 changes: 7 additions & 2 deletions controllers/FriendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Yii;
use app\models\Friend;
use yii\web\Controller;
use yii\filters\VerbFilter;

/**
Expand Down Expand Up @@ -70,13 +69,16 @@ public function actionCreate($id, $course)
if ($model->save()) {
return $this->goBack();
}

return $this->redirect(['error']);
}

/**
* Deletes an existing Friend model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
* @param integer $id
*
* @return mixed
* @throws \Throwable
* @throws \yii\db\StaleObjectException
Expand All @@ -88,9 +90,12 @@ public function actionDelete($id)
$friend->status = 0;
$friend->save();
}
if (Friend::find()->where(['mylogin' => Yii::$app->user->identity->username, 'xlogin' => $id])->one()->delete() !== null) {
if (Friend::find()->where(['mylogin' => Yii::$app->user->identity->username, 'xlogin' => $id])->one()->delete()
!== null
) {
return $this->goBack();
}

return $this->redirect(['friend/index']);
}
}
Loading