Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
yii2bootstrap
Project
Project
Details
Activity
Releases
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
夏彬
yii2bootstrap
Commits
122376a8
Commit
122376a8
authored
Apr 22, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a basic app.
parent
e132ed8d
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
134 additions
and
4 deletions
+134
-4
.gitignore
app/assets/.gitignore
+1
-0
index.php
app/index.php
+9
-0
main.php
app/protected/config/main.php
+15
-0
SiteController.php
app/protected/controllers/SiteController.php
+22
-0
User.php
app/protected/models/User.php
+43
-0
.gitignore
app/protected/runtime/.gitignore
+1
-0
main.php
app/protected/views/layouts/main.php
+22
-0
index.php
app/protected/views/site/index.php
+17
-0
UrlManager.php
framework/web/UrlManager.php
+4
-4
No files found.
app/assets/.gitignore
0 → 100644
View file @
122376a8
*
app/index.php
0 → 100644
View file @
122376a8
<?php
defined
(
'YII_DEBUG'
)
or
define
(
'YII_DEBUG'
,
true
);
require
(
__DIR__
.
'/../framework/yii.php'
);
$config
=
require
(
__DIR__
.
'/protected/config/main.php'
);
$application
=
new
yii\web\Application
(
$config
);
$application
->
run
();
app/protected/config/main.php
0 → 100644
View file @
122376a8
<?php
return
array
(
'id'
=>
'hello'
,
'basePath'
=>
dirname
(
__DIR__
),
'components'
=>
array
(
'cache'
=>
array
(
'class'
=>
'yii\caching\FileCache'
,
),
'user'
=>
array
(
'class'
=>
'yii\web\User'
,
'identityClass'
=>
'app\models\User'
,
)
),
);
\ No newline at end of file
app/protected/controllers/SiteController.php
0 → 100644
View file @
122376a8
<?php
class
SiteController
extends
\yii\web\Controller
{
public
function
actionIndex
()
{
echo
$this
->
render
(
'index'
);
}
public
function
actionLogin
()
{
$user
=
app\models\User
::
findIdentity
(
100
);
Yii
::
$app
->
getUser
()
->
login
(
$user
);
Yii
::
$app
->
getResponse
()
->
redirect
(
array
(
'site/index'
));
}
public
function
actionLogout
()
{
Yii
::
$app
->
getUser
()
->
logout
();
Yii
::
$app
->
getResponse
()
->
redirect
(
array
(
'site/index'
));
}
}
\ No newline at end of file
app/protected/models/User.php
0 → 100644
View file @
122376a8
<?php
namespace
app\models
;
class
User
extends
\yii\base\Object
implements
\yii\web\Identity
{
public
$id
;
public
$name
;
public
$authKey
;
private
static
$users
=
array
(
'100'
=>
array
(
'id'
=>
'100'
,
'authKey'
=>
'test100key'
,
'name'
=>
'admin'
,
),
'101'
=>
array
(
'id'
=>
'101'
,
'authKey'
=>
'test101key'
,
'name'
=>
'demo'
,
),
);
public
static
function
findIdentity
(
$id
)
{
return
isset
(
self
::
$users
[
$id
])
?
new
self
(
self
::
$users
[
$id
])
:
null
;
}
public
function
getId
()
{
return
$this
->
id
;
}
public
function
getAuthKey
()
{
return
$this
->
authKey
;
}
public
function
validateAuthKey
(
$authKey
)
{
return
$this
->
authKey
===
$authKey
;
}
}
\ No newline at end of file
app/protected/runtime/.gitignore
0 → 100644
View file @
122376a8
*
app/protected/views/layouts/main.php
0 → 100644
View file @
122376a8
<?php
/**
* @var $this \yii\base\View
* @var $content string
*/
use
yii\helpers\Html
;
?>
<!DOCTYPE html>
<html>
<?php
$this
->
beginPage
();
?>
<head>
<title>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</title>
<?php
$this
->
head
();
?>
</head>
<body>
<h1>
Welcome
</h1>
<?php
$this
->
beginBody
();
?>
<?php
echo
$content
;
?>
<?php
$this
->
endBody
();
?>
</body>
<?php
$this
->
endPage
();
?>
</html>
app/protected/views/site/index.php
0 → 100644
View file @
122376a8
<?php
/** @var $this \yii\base\View */
use
yii\helpers\Html
;
$this
->
title
=
'Hello World'
;
$user
=
Yii
::
$app
->
getUser
();
if
(
$user
->
isGuest
)
{
echo
Html
::
a
(
'login'
,
array
(
'login'
));
}
else
{
echo
"You are logged in as "
.
$user
->
identity
->
name
.
"<br/>"
;
echo
Html
::
a
(
'logout'
,
array
(
'logout'
));
}
?>
framework/web/UrlManager.php
View file @
122376a8
...
@@ -74,9 +74,6 @@ class UrlManager extends Component
...
@@ -74,9 +74,6 @@ class UrlManager extends Component
public
function
init
()
public
function
init
()
{
{
parent
::
init
();
parent
::
init
();
if
(
is_string
(
$this
->
cache
))
{
$this
->
cache
=
Yii
::
$app
->
getComponent
(
$this
->
cache
);
}
$this
->
compileRules
();
$this
->
compileRules
();
}
}
...
@@ -88,6 +85,9 @@ class UrlManager extends Component
...
@@ -88,6 +85,9 @@ class UrlManager extends Component
if
(
!
$this
->
enablePrettyUrl
||
$this
->
rules
===
array
())
{
if
(
!
$this
->
enablePrettyUrl
||
$this
->
rules
===
array
())
{
return
;
return
;
}
}
if
(
is_string
(
$this
->
cache
))
{
$this
->
cache
=
Yii
::
$app
->
getComponent
(
$this
->
cache
);
}
if
(
$this
->
cache
instanceof
Cache
)
{
if
(
$this
->
cache
instanceof
Cache
)
{
$key
=
$this
->
cache
->
buildKey
(
__CLASS__
);
$key
=
$this
->
cache
->
buildKey
(
__CLASS__
);
$hash
=
md5
(
json_encode
(
$this
->
rules
));
$hash
=
md5
(
json_encode
(
$this
->
rules
));
...
@@ -104,7 +104,7 @@ class UrlManager extends Component
...
@@ -104,7 +104,7 @@ class UrlManager extends Component
$this
->
rules
[
$i
]
=
Yii
::
createObject
(
$rule
);
$this
->
rules
[
$i
]
=
Yii
::
createObject
(
$rule
);
}
}
if
(
$this
->
cache
instanceof
Cache
)
{
if
(
isset
(
$key
,
$hash
)
)
{
$this
->
cache
->
set
(
$key
,
array
(
$this
->
rules
,
$hash
));
$this
->
cache
->
set
(
$key
,
array
(
$this
->
rules
,
$hash
));
}
}
}
}
...
...
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