Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
yiifans committed May 22, 2015
1 parent b5549ad commit d8e2a13
Show file tree
Hide file tree
Showing 3,400 changed files with 527,552 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory" : "vendor/bower"
}
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# phpstorm project files
.idea

# netbeans project files
nbproject

# zend studio for eclipse project files
.buildpath
.project
.settings

# windows thumbnail cache
Thumbs.db

# composer vendor dir


# composer itself is not needed
composer.phar

# Mac DS_Store Files
.DS_Store

# phpunit itself is not needed
phpunit.phar
# local phpunit config
/phpunit.xml

/runtime
/backend/runtime
/frontend/runtime
/static/assets
16 changes: 16 additions & 0 deletions admin-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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_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');

$config = require(__DIR__ . '/../tests/codeception/config/acceptance.php');

(new yii\web\Application($config))->run();
27 changes: 27 additions & 0 deletions admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use source\core\back\BaseBackApplication;
use source\LuLu;


// comment out the following two lines when deployed to production
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__ . '/source/config/bootstrap.php');
require (__DIR__ . '/backend/config/bootstrap.php');


$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/source/config/main.php'),
require(__DIR__ . '/source/config/main-local.php'),
require(__DIR__ . '/backend/config/main.php'),
require(__DIR__ . '/backend/config/main-local.php')
);

$app = new BaseBackApplication($config);
$app->run();

1 change: 1 addition & 0 deletions backend/config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
21 changes: 21 additions & 0 deletions backend/config/main-local.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '41SCN-vryMrrUOuOzXXcGo0GP4zBgMhr',
],
],
];

if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';

$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = 'yii\gii\Module';
}

return $config;
64 changes: 64 additions & 0 deletions backend/config/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
$params = array_merge(
require(__DIR__ . '/../../source/config/params.php'),
require(__DIR__ . '/../../source/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);

return [
'id' => 'app-backend',
'language' => 'zh-CN',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'],
'modules' => [],
'components' => [
'user' => [
'identityClass' => 'source\models\User',
'enableAutoLogin' => true,
'loginUrl' => ['admin/login'],
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'admin/error',
],
'view' => [
'class' => 'source\core\back\BaseBackView',
],


],
'modules' => [
// 'comment' => [
// 'class' => 'source\modules\comment\AdminModule',
// ],
// 'post' => [
// 'class' => 'source\modules\post\AdminModule',
// ],
// 'page' => [
// 'class' => 'source\modules\page\AdminModule',
// ],
// 'takonomy' => [
// 'class' => 'source\modules\takonomy\AdminModule',
// ],
'menu' => [
'class' => 'source\modules\menu\AdminModule',
],
'system' => [
'class' => 'source\modules\system\AdminModule',
],
'modularity' => [
'class' => 'source\modules\modularity\AdminModule',
],
],
'params' => $params,
];
3 changes: 3 additions & 0 deletions backend/config/params-local.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
return [
];
4 changes: 4 additions & 0 deletions backend/config/params.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
return [
'adminEmail' => 'admin@example.com',
];
135 changes: 135 additions & 0 deletions backend/controllers/BaseContentController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?php
namespace backend\controllers;

use Yii;
use source\models\Content;
use source\models\search\ContentSearch;
use source\core\back\BaseBackController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use source\libs\Common;
use source\helpers\StringHelper;

abstract class BaseContentController extends BaseBackController
{

protected $content_type;

protected $bodyModel;

public function actionIndex()
{
$searchModel = new ContentSearch();
$dataProvider = $searchModel->search([]);
$dataProvider->query->andWhere([
'content_type' => $this->content_type
]);
$dataProvider->query->orderBy('created_at desc');

return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider
]);
}

public function saveContent($model, $bodyModel)
{
$postDatas = Yii::$app->request->post();

if ($model->load($postDatas) && $bodyModel->load($postDatas) && $model->validate() && $bodyModel->validate())
{
if ($model->summary === null || $model->summary === '')
{
if ($bodyModel->hasAttribute('body'))
{
$content = strip_tags($bodyModel->body);
$pattern = '/\s/'; // 去除空白
$content = preg_replace($pattern, '', $content);
$model->summary = StringHelper::subStr($content, 250);
}
}
if ($model->save())
{
$bodyModel->content_id = $model->id;
$bodyModel->save();

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

public function actionCreate()
{
$model = new Content();
$model->user_id = 1;
$model->content_type = $this->content_type;
$model->loadDefaultValues();

$bodyModel = $this->findBodyModel();
$bodyModel->loadDefaultValues();

if (($r = $this->saveContent($model, $bodyModel)) !== false)
{
return $r;
}

return $this->render('create', [
'model' => $model,
'bodyModel' => $bodyModel
]);
}

public function actionUpdate($id)
{
$model = $this->findModel($id);
$bodyModel = $this->findBodyModel($id);

if (($r = $this->saveContent($model, $bodyModel)) !== false)
{
return $r;
}
return $this->render('update', [
'model' => $model,
'bodyModel' => $bodyModel
]);
}

public function actionDelete($id)
{
$this->findModel($id)->delete();

$this->deleteBodyModel($id);

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

protected function findModel($id)
{
if (($model = Content::findOne($id)) !== null)
{
return $model;
}
else
{
throw new NotFoundHttpException('The requested page does not exist.');
}
}

public function findBodyModel($contentId = null)
{
}

public function deleteBodyModel($contentId)
{
$bodyModel = $this->findBodyModel($contentId);
if ($bodyModel != null)
{
$bodyModel->delete();
}
}
}
38 changes: 38 additions & 0 deletions backend/controllers/BaseSettingController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
namespace backend\controllers;

use Yii;
use source\models\Config;
use source\models\search\ConfigSearch;
use source\core\back\BaseBackController;
use yii\base\InvalidParamException;
use source\models\ConfigForm;

abstract class BaseSettingController extends BaseBackController
{

public function doConfig($model, $view = null)
{
if (! ($model instanceof ConfigForm))
{
throw new InvalidParamException('model must be instance of ConfigForm');
}

if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post()) && $model->saveAll())
{
return $this->refresh();
}
else
{
if ($view === null)
{
$view = $this->action->id;
}

$model->initAll();
return $this->render($view, [
'model' => $model
]);
}
}
}
19 changes: 19 additions & 0 deletions backend/controllers/SiteController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
namespace backend\controllers;

use yii\web\Controller;

class SiteController extends Controller
{

public function actionIndex()
{
$this->layout = 'container';
return $this->render('index');
}

public function actionWelcome()
{
return $this->render('welcome');
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/attachment/20150424/20150424140031_35735.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/attachment/20150424/20150424162206_46279.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d8e2a13

Please sign in to comment.