Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
47f038fb
Commit
47f038fb
authored
Oct 20, 2016
by
Robert Lyon
Committed by
Gerrit Code Review
Oct 20, 2016
Browse files
Merge "Bug 1626805: Allow the view constructor to fix missing layout info"
parents
febfcabb
e95ebc66
Changes
1
Show whitespace changes
Inline
Side-by-side
htdocs/lib/view.php
View file @
47f038fb
...
...
@@ -314,6 +314,48 @@ class View {
// set only for existing views - _create provides default value
if
(
empty
(
$this
->
columnsperrow
))
{
$this
->
columnsperrow
=
get_records_assoc
(
'view_rows_columns'
,
'view'
,
$this
->
get
(
'id'
),
'row'
,
'row, columns'
);
if
(
empty
(
$this
->
columnsperrow
))
{
// if we are missing the info for some reason we will give the page it's layout back
// this can happen in MySQL when many users are copying the same page
if
(
$this
->
layout
)
{
if
(
$rowscols
=
get_records_sql_array
(
"
SELECT vlrc.row, vlc.columns
FROM
{
view_layout_rows_columns
}
vlrc
JOIN
{
view_layout_columns
}
vlc ON vlc.id = vlrc.columns
WHERE viewlayout = ?"
,
array
(
$this
->
layout
)))
{
$default
=
array
();
foreach
(
$rowscols
as
$row
)
{
insert_record
(
'view_rows_columns'
,
(
object
)
array
(
'view'
=>
$this
->
get
(
'id'
),
'row'
=>
$row
->
row
,
'columns'
=>
$row
->
columns
));
$default
[
$row
->
row
]
=
$row
;
}
}
}
else
if
(
$rowscols
=
get_records_sql_array
(
"
SELECT vrc.row, vrc.columns
FROM
{
view
}
v
JOIN
{
view_rows_columns
}
vrc ON vrc.view = v.id
WHERE v.template = ?
AND v.type = ?"
,
array
(
self
::
SITE_TEMPLATE
,
$this
->
type
)))
{
// Layout not specified so use the view type default layout
$default
=
array
();
foreach
(
$rowscols
as
$row
)
{
insert_record
(
'view_rows_columns'
,
(
object
)
array
(
'view'
=>
$this
->
get
(
'id'
),
'row'
=>
$row
->
row
,
'columns'
=>
$row
->
columns
));
$default
[
$row
->
row
]
=
$row
;
}
}
else
{
// Layout not known so make it 1 row / 3 cols
insert_record
(
'view_rows_columns'
,
(
object
)
array
(
'view'
=>
$this
->
get
(
'id'
),
'row'
=>
1
,
'columns'
=>
3
));
$default
=
self
::
default_columnsperrow
();
}
$this
->
columnsperrow
=
$default
;
}
}
}
...
...
Write
Preview
Supports
Markdown
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