[go: up one dir, main page]

Skip to content

Commit

Permalink
fix bugs, re-organization article meta modles
Browse files Browse the repository at this point in the history
  • Loading branch information
liufee committed Jul 30, 2017
1 parent a4f3b5e commit 8c720f5
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/models/AdminRolePermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function assignPermission($roleId, $ids)
*/
public static function getPermissionsByRoleId($role_id)
{
return self::find()->leftJoin(Menu::tableName(), 'menu.id=' . self::tableName() . '.menu_id')->where(['role_id' => $role_id])->select('*')->asArray()->all();
return self::find()->leftJoin(Menu::tableName(), Menu::tableName() . '.id=' . self::tableName() . '.menu_id')->where(['role_id' => $role_id])->select('*')->asArray()->all();
}

/**
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Created at: 2017-03-15 21:16
*/

namespace common\models;
namespace common\models\meta;

class ArticleMetaLike extends ArticleMeta
class ArticleMetaLike extends \common\models\ArticleMeta
{

public $tag = "like";
Expand Down
4 changes: 2 additions & 2 deletions console/controllers/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function actionPublish()
$temp . 'console' . DIRECTORY_SEPARATOR . 'runtime',
$temp . 'install' . DIRECTORY_SEPARATOR . 'runtime',
$temp . 'frontend' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'assets',
$temp . 'frontend' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'cache',
$temp . 'frontend' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'uploads',
$temp . 'frontend' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'assets',
$temp . 'frontend' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'uploads',
Expand All @@ -119,7 +118,8 @@ public function actionPublish()
if($v == $temp . 'tests') continue;
FileHelper::createDirectory($v, 0777);
}
FileHelper::createDirectory($temp . 'common' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR .'conf', 0777);
FileHelper::createDirectory($publishDir . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR .'conf', 0777);
if( file_exists($publishDir . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR .'conf' . DIRECTORY_SEPARATOR . 'install.lock') ) unlink($publishDir . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR .'conf' . DIRECTORY_SEPARATOR . 'install.lock');
file_put_contents($temp . 'common' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'main-local.php', "<?php return [];?>" );
$this->stdout('Copy Success' . "\n", Console::FG_GREEN);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/controllers/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use common\models\Category;
use frontend\models\Comment;
use yii\data\ActiveDataProvider;
use common\models\ArticleMetaLike;
use common\models\meta\ArticleMetaLike;
use yii\web\NotFoundHttpException;
use yii\filters\HttpCache;

Expand Down
44 changes: 44 additions & 0 deletions frontend/controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,48 @@ public function actionLanguage()
$this->redirect(Yii::$app->getRequest()->headers['referer']);
}

/**
* http异常捕捉后处理
*
* @return string
*/
public function actionError()
{
if (($exception = Yii::$app->getErrorHandler()->exception) === null) {
// action has been invoked not from error handler, but by direct route, so we display '404 Not Found'
$exception = new HttpException(404, Yii::t('yii', 'Page not found.'));
}

if ($exception instanceof HttpException) {
$code = $exception->statusCode;
} else {
$code = $exception->getCode();
}
//if ($exception instanceof Exception) {
$name = $exception->getName();
//} else {
//$name = $this->defaultName ?: Yii::t('yii', 'Error');
//}
if ($code) {
$name .= " (#$code)";
}

//if ($exception instanceof UserException) {
$message = $exception->getMessage();
//} else {
//$message = $this->defaultMessage ?: Yii::t('yii', 'An internal server error occurred.');
//}
$statusCode = $exception->statusCode ? $exception->statusCode : 500;
if (Yii::$app->getRequest()->getIsAjax()) {
return "$name: $message";
} else {
return $this->render('error', [
'code' => $statusCode,
'name' => $name,
'message' => $message,
'exception' => $exception,
]);
}
}

}
9 changes: 5 additions & 4 deletions install/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'qxOH-LMMrJJ_unqJzWsPO1eL39JF0cnK',
'csrfParam' =>'_csrf_install',
],
'i18n' => [
'translations' => [
'install*' => [
'class' => 'yii\i18n\PhpMessageSource',
'class' => yii\i18n\PhpMessageSource::class,
'basePath' => '@install/messages',
'sourceLanguage' => 'en-US',
'fileMap' => [
'df' => 'installsdfsdfd.php',
'df' => 'install.php',
'app/error' => 'error.php',
],
],
Expand All @@ -43,12 +44,12 @@
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
'class' => yii\debug\Module::class,
];

$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'class' => yii\gii\Module::class,
];
}
return $config;

0 comments on commit 8c720f5

Please sign in to comment.