Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
bc21de98
Commit
bc21de98
authored
Aug 10, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the basic app.
parent
8ee92fdb
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
148 additions
and
85 deletions
+148
-85
web.php
apps/basic/config/web.php
+4
-2
SiteController.php
apps/basic/controllers/SiteController.php
+4
-1
about.php
apps/basic/views/site/about.php
+7
-6
contact.php
apps/basic/views/site/contact.php
+30
-24
error.php
apps/basic/views/site/error.php
+29
-0
index.php
apps/basic/views/site/index.php
+35
-33
login.php
apps/basic/views/site/login.php
+14
-12
index.php
apps/basic/web/index.php
+1
-1
YiiBase.php
framework/yii/YiiBase.php
+1
-1
error.php
framework/yii/views/errorHandler/error.php
+23
-5
No files found.
apps/basic/config/web.php
View file @
bc21de98
...
...
@@ -7,7 +7,7 @@ return array(
'modules'
=>
array
(
'debug'
=>
array
(
'class'
=>
'yii\debug\Module'
,
'enabled'
=>
YII_
DEBUG
&&
YII_
ENV_DEV
,
'enabled'
=>
YII_ENV_DEV
,
),
),
'components'
=>
array
(
...
...
@@ -15,9 +15,11 @@ return array(
'class'
=>
'yii\caching\FileCache'
,
),
'user'
=>
array
(
'class'
=>
'yii\web\User'
,
'identityClass'
=>
'app\models\User'
,
),
'errorHandler'
=>
array
(
'errorAction'
=>
'site/error'
,
),
'log'
=>
array
(
'traceLevel'
=>
YII_DEBUG
?
3
:
0
,
'targets'
=>
array
(
...
...
apps/basic/controllers/SiteController.php
View file @
bc21de98
...
...
@@ -12,9 +12,12 @@ class SiteController extends Controller
public
function
actions
()
{
return
array
(
'error'
=>
array
(
'class'
=>
'yii\web\ErrorAction'
,
),
'captcha'
=>
array
(
'class'
=>
'yii\captcha\CaptchaAction'
,
'fixedVerifyCode'
=>
YII_ENV_
DEV
?
'testme'
:
null
,
'fixedVerifyCode'
=>
YII_ENV_
TEST
?
'testme'
:
null
,
),
);
}
...
...
apps/basic/views/site/about.php
View file @
bc21de98
...
...
@@ -7,11 +7,12 @@ use yii\helpers\Html;
$this
->
title
=
'About'
;
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<h1>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</h1>
<div
class=
"site-about"
>
<h1>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</h1>
<p>
This is the About page. You may modify the following file to customize its content:
</p>
<code>
<?php
echo
__FILE__
;
?>
</code>
<p>
This is the About page. You may modify the following file to customize its content:
</p>
<code>
<?php
echo
__FILE__
;
?>
</code>
</div>
apps/basic/views/site/contact.php
View file @
bc21de98
...
...
@@ -11,32 +11,38 @@ use yii\captcha\Captcha;
$this
->
title
=
'Contact'
;
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<h1>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</h1>
<div
class=
"site-contact"
>
<h1>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</h1>
<?php
if
(
Yii
::
$app
->
session
->
hasFlash
(
'contactFormSubmitted'
))
:
?>
<div
class=
"alert alert-success"
>
Thank you for contacting us. We will respond to you as soon as possible.
</div>
<?php
return
;
endif
;
?
>
<?php
if
(
Yii
::
$app
->
session
->
hasFlash
(
'contactFormSubmitted'
))
:
?>
<div
class=
"alert alert-success"
>
Thank you for contacting us. We will respond to you as soon as possible.
</div
>
<p>
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
</p>
<?php
else
:
?>
<div
class=
"row"
>
<div
class=
"col-lg-5"
>
<?php
$form
=
ActiveForm
::
begin
(
array
(
'id'
=>
'contact-form'
));
?>
<?php
echo
$form
->
field
(
$model
,
'name'
)
->
textInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'email'
)
->
textInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'subject'
)
->
textInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'body'
)
->
textArea
(
array
(
'rows'
=>
6
));
?>
<?php
echo
$form
->
field
(
$model
,
'verifyCode'
)
->
widget
(
Captcha
::
className
(),
array
(
'options'
=>
array
(
'class'
=>
'form-control'
),
'template'
=>
'<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>'
,
));
?>
<div
class=
"form-actions"
>
<?php
echo
Html
::
submitButton
(
'Submit'
,
array
(
'class'
=>
'btn btn-primary'
));
?>
</div>
<?php
ActiveForm
::
end
();
?>
<p>
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
</p>
<div
class=
"row"
>
<div
class=
"col-lg-5"
>
<?php
$form
=
ActiveForm
::
begin
(
array
(
'id'
=>
'contact-form'
));
?>
<?php
echo
$form
->
field
(
$model
,
'name'
)
->
textInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'email'
)
->
textInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'subject'
)
->
textInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'body'
)
->
textArea
(
array
(
'rows'
=>
6
));
?>
<?php
echo
$form
->
field
(
$model
,
'verifyCode'
)
->
widget
(
Captcha
::
className
(),
array
(
'options'
=>
array
(
'class'
=>
'form-control'
),
'template'
=>
'<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>'
,
));
?>
<div
class=
"form-actions"
>
<?php
echo
Html
::
submitButton
(
'Submit'
,
array
(
'class'
=>
'btn btn-primary'
));
?>
</div>
<?php
ActiveForm
::
end
();
?>
</div>
</div>
<?php
endif
;
?>
</div>
apps/basic/views/site/error.php
0 → 100644
View file @
bc21de98
<?php
use
yii\helpers\Html
;
/**
* @var yii\base\View $this
* @var string $name
* @var string $message
* @var Exception $exception
*/
$this
->
title
=
$name
;
?>
<div
class=
"site-error"
>
<h1>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</h1>
<div
class=
"alert alert-danger"
>
<?php
echo
nl2br
(
Html
::
encode
(
$message
));
?>
</div>
<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
Please contact us if you think this is a server error. Thank you.
</p>
</div>
apps/basic/views/site/index.php
View file @
bc21de98
...
...
@@ -2,50 +2,52 @@
/**
* @var yii\base\View $this
*/
$this
->
title
=
'
Welcome
'
;
$this
->
title
=
'
My Yii Application
'
;
?>
<div
class=
"jumbotron"
>
<h1>
Congratulations!
</h1>
<div
class=
"site-index"
>
<p
class=
"lead"
>
You have successfully created your Yii-powered application.
</p>
<div
class=
"jumbotron"
>
<h1>
Congratulations!
</h1>
<p><a
class=
"btn btn-large btn-success"
href=
"http://www.yiiframework.com"
>
Get started with Yii
</a></p>
</div>
<p
class=
"lead"
>
You have successfully created your Yii-powered application.
</p>
<div
class=
"body-content"
>
<p><a
class=
"btn btn-large btn-success"
href=
"http://www.yiiframework.com"
>
Get started with Yii
</a></p>
</div>
<div
class=
"row"
>
<div
class=
"col-lg-4"
>
<h2>
Heading
</h2>
<div
class=
"body-content"
>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.
</p>
<div
class=
"row"
>
<div
class=
"col-lg-4"
>
<h2>
Heading
</h2>
<p><a
class=
"btn btn-default"
href=
"http://www.yiiframework.com/doc/"
>
Yii Documentation
»
</a></p>
</div>
<div
class=
"col-lg-4"
>
<h2>
Heading
</h2
>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.
</p
>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.
</p
>
<p><a
class=
"btn btn-default"
href=
"http://www.yiiframework.com/doc/"
>
Yii Documentation
»
</a></p>
</div>
<div
class=
"col-lg-4"
>
<h2>
Heading
</h2
>
<p><a
class=
"btn btn-default"
href=
"http://www.yiiframework.com/forum/"
>
Yii Forum
»
</a></p>
</div>
<div
class=
"col-lg-4"
>
<h2>
Heading
</h2
>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.
</p
>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.
</p
>
<p><a
class=
"btn btn-default"
href=
"http://www.yiiframework.com/forum/"
>
Yii Forum
»
</a></p>
</div>
<div
class=
"col-lg-4"
>
<h2>
Heading
</h2
>
<p><a
class=
"btn btn-default"
href=
"http://www.yiiframework.com/extensions/"
>
Yii Extensions
»
</a></p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.
</p>
<p><a
class=
"btn btn-default"
href=
"http://www.yiiframework.com/extensions/"
>
Yii Extensions
»
</a></p>
</div>
</div>
</div>
</div>
</div>
apps/basic/views/site/login.php
View file @
bc21de98
...
...
@@ -10,19 +10,21 @@ use yii\widgets\ActiveForm;
$this
->
title
=
'Login'
;
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<h1>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</h1>
<div
class=
"site-login"
>
<h1>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</h1>
<p>
Please fill out the following fields to login:
</p>
<p>
Please fill out the following fields to login:
</p>
<div
class=
"row"
>
<div
class=
"col-lg-3"
>
<?php
$form
=
ActiveForm
::
begin
(
array
(
'id'
=>
'login-form'
));
?>
<?php
echo
$form
->
field
(
$model
,
'username'
)
->
textInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'password'
)
->
passwordInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'rememberMe'
)
->
checkbox
();
?>
<div
class=
"form-actions"
>
<?php
echo
Html
::
submitButton
(
'Login'
,
array
(
'class'
=>
'btn btn-primary'
));
?>
</div>
<?php
ActiveForm
::
end
();
?>
<div
class=
"row"
>
<div
class=
"col-lg-3"
>
<?php
$form
=
ActiveForm
::
begin
(
array
(
'id'
=>
'login-form'
));
?>
<?php
echo
$form
->
field
(
$model
,
'username'
)
->
textInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'password'
)
->
passwordInput
();
?>
<?php
echo
$form
->
field
(
$model
,
'rememberMe'
)
->
checkbox
();
?>
<div
class=
"form-actions"
>
<?php
echo
Html
::
submitButton
(
'Login'
,
array
(
'class'
=>
'btn btn-primary'
));
?>
</div>
<?php
ActiveForm
::
end
();
?>
</div>
</div>
</div>
apps/basic/web/index.php
View file @
bc21de98
<?php
// comment out the following
line to disable debug mode
// 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'
);
...
...
framework/yii/YiiBase.php
View file @
bc21de98
...
...
@@ -567,7 +567,7 @@ class YiiBase
*/
public
static
function
powered
()
{
return
'Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a>
.
'
;
return
'Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a>'
;
}
/**
...
...
framework/yii/views/errorHandler/error.php
View file @
bc21de98
...
...
@@ -3,14 +3,32 @@
* @var \Exception $exception
* @var \yii\base\ErrorHandler $handler
*/
$title
=
$handler
->
htmlEncode
(
$exception
instanceof
\yii\base\Exception
?
$exception
->
getName
()
:
get_class
(
$exception
));
if
(
$exception
instanceof
\yii\web\HttpException
)
{
$code
=
$exception
->
statusCode
;
}
else
{
$code
=
$exception
->
getCode
();
}
if
(
$exception
instanceof
\yii\base\Exception
)
{
$name
=
$exception
->
getName
();
}
else
{
$name
=
'Error'
;
}
if
(
$code
)
{
$name
.=
" (#
$code
)"
;
}
if
(
$exception
instanceof
\yii\base\UserException
)
{
$message
=
$exception
->
getMessage
();
}
else
{
$message
=
'An internal server error occurred.'
;
}
?>
<?php
if
(
method_exists
(
$this
,
'beginPage'
))
$this
->
beginPage
();
?>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
/>
<title>
<?php
echo
$
title
?>
</title>
<title>
<?php
echo
$
handler
->
htmlEncode
(
$name
);
?>
</title>
<style>
body
{
...
...
@@ -51,8 +69,8 @@ $title = $handler->htmlEncode($exception instanceof \yii\base\Exception ? $excep
</head>
<body>
<h1>
<?php
echo
$
title
?>
</h1>
<h2>
<?php
echo
nl2br
(
$handler
->
htmlEncode
(
$
exception
->
getMessage
()))
?>
</h2>
<h1>
<?php
echo
$
handler
->
htmlEncode
(
$name
);
?>
</h1>
<h2>
<?php
echo
nl2br
(
$handler
->
htmlEncode
(
$
message
));
?>
</h2>
<p>
The above error occurred while the Web server was processing your request.
</p>
...
...
@@ -60,7 +78,7 @@ $title = $handler->htmlEncode($exception instanceof \yii\base\Exception ? $excep
Please contact us if you think this is a server error. Thank you.
</p>
<div
class=
"version"
>
<?php
echo
date
(
'Y-m-d H:i:s'
,
time
())
?>
<?php
echo
date
(
'Y-m-d H:i:s'
,
time
())
;
?>
</div>
<?php
if
(
method_exists
(
$this
,
'endBody'
))
$this
->
endBody
();
// to allow injecting code into body (mostly by Yii Debug Toolbar) ?>
</
body
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment