Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
8130f2da
Commit
8130f2da
authored
Aug 07, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring view class.
parent
ea3c59d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
27 deletions
+9
-27
system/view.php
+9
-27
No files found.
system/view.php
View file @
8130f2da
...
...
@@ -75,22 +75,28 @@ class View {
/**
* Create a new view instance from a view name.
*
* The view names for the active module will be searched first, followed by
* the view names for the application directory, followed by the view names
* for all other modules.
*
* @param string $name
* @param array $data
* @return View
*/
private
static
function
of
(
$name
,
$data
=
array
())
{
// Search the active module first, then the application module, then all other modules.
$modules
=
array_unique
(
array_merge
(
array
(
ACTIVE_MODULE
,
'application'
),
Config
::
get
(
'application.modules'
)));
foreach
(
$modules
as
$module
)
{
static
::
load_composers
(
$module
);
if
(
!
is_null
(
$view
=
static
::
find_view_for_name
(
$name
,
static
::
$composers
[
$module
]))
)
foreach
(
static
::
$composers
[
$module
]
as
$key
=>
$value
)
{
return
new
static
(
$view
,
$data
);
if
(
$name
===
$value
or
(
isset
(
$value
[
'name'
])
and
$name
===
$value
[
'name'
]))
{
return
new
static
(
$key
,
$data
);
}
}
}
...
...
@@ -98,28 +104,6 @@ class View {
}
/**
* Find the view for a given name in an array of composers.
*
* @param string $name
* @param array $composers
* @return string
*/
private
static
function
find_view_for_name
(
$name
,
$composers
)
{
foreach
(
$composers
as
$key
=>
$value
)
{
if
(
is_string
(
$value
)
and
$value
==
$name
)
{
return
$key
;
}
elseif
(
is_array
(
$value
)
and
isset
(
$value
[
'name'
])
and
$value
[
'name'
]
==
$name
)
{
return
$key
;
}
}
}
/**
* Parse a view identifier and get the module, path, and view name.
*
* @param string $view
...
...
@@ -127,8 +111,6 @@ class View {
*/
private
static
function
parse
(
$view
)
{
// Check for a module qualifier. If a module name is present, we need to extract it from
// the view name, otherwise, we will use "application" as the module.
$module
=
(
strpos
(
$view
,
'::'
)
!==
false
)
?
substr
(
$view
,
0
,
strpos
(
$view
,
':'
))
:
'application'
;
$path
=
(
$module
==
'application'
)
?
VIEW_PATH
:
MODULE_PATH
.
$module
.
'/views/'
;
...
...
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