Skip to content
GitLab
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
5f2083a9
Commit
5f2083a9
authored
Dec 07, 2006
by
Penny Leach
Browse files
fixed the web based installer to not break on templates and report
errors properly
parent
330cb1d9
Changes
6
Hide whitespace changes
Inline
Side-by-side
htdocs/admin/upgrade.json.php
View file @
5f2083a9
...
...
@@ -36,21 +36,22 @@ if (!$install) {
}
if
(
$install
)
{
$message
=
''
;
if
(
!
get_config
(
'installed'
))
{
try
{
core_install_defaults
();
}
catch
(
SQLException
$e
)
{
echo
json_encode
(
array
(
'success'
=>
0
,
'errormessage'
=>
$e
->
getMessage
()
));
exit
;
json_reply
(
true
,
$e
->
getMessage
());
}
catch
(
TemplateParserException
$e
)
{
// these ones are non fatal...
$message
=
$e
->
getMessage
()
.
' '
.
'<a href="'
.
get_config
(
'wwwroot'
)
.
'admin/templates.php">'
.
get_string
(
'fixtemplatescontinue'
,
'admin'
)
.
'</a>'
;
}
}
echo
json_encode
(
array
(
'success'
=>
1
));
exit
;
json_reply
(
false
,
$message
);
}
$upgrade
=
check_upgrades
(
$name
);
...
...
htdocs/admin/upgrade.php
View file @
5f2083a9
...
...
@@ -59,15 +59,18 @@ if (!empty($upgrades['core']->install)) {
$
(
'coredata'
)
.
innerHTML
=
'<img src="{$loadingicon}" alt="{$loadingstring}" />'
;
d
.
addCallbacks
(
function
(
data
)
{
if
(
data
.
success
)
{
if
(
!
data
.
error
)
{
var
message
=
'{$coresuccess}'
;
if
(
data
.
message
)
{
message
+=
' ('
+
data
.
message
+
')'
;
}
$
(
'coredata'
)
.
innerHTML
=
'<img src="{$successicon}" alt=":)" /> '
+
message
;
$
(
'finished'
)
.
style
.
visibility
=
'visible'
;
}
else
{
var
message
=
''
;
if
(
data
.
error
message
)
{
message
=
data
.
error
message
;
if
(
data
.
message
)
{
message
=
data
.
message
;
}
else
{
message
=
'{$failurestring}'
;
...
...
@@ -99,7 +102,7 @@ $js .= <<< EOJS
$
(
element
)
.
innerHTML
=
'<img src="{$loadingicon}" alt="{$loadingstring}" />'
;
d
.
addCallbacks
(
function
(
data
)
{
if
(
data
.
success
)
{
if
(
!
data
.
error
)
{
var
message
;
if
(
data
.
install
)
{
message
=
'{$installsuccessstring}'
;
...
...
@@ -112,8 +115,8 @@ $js .= <<< EOJS
}
else
{
var
message
=
''
;
if
(
data
.
error
message
)
{
message
=
data
.
error
message
;
if
(
data
.
message
)
{
message
=
data
.
message
;
}
else
{
message
=
'{$failurestring}'
;
...
...
htdocs/lang/en.utf8/admin.php
View file @
5f2083a9
...
...
@@ -42,6 +42,7 @@ $string['upgradeloading'] = 'Loading...';
$string
[
'upgradesuccess'
]
=
'Successfully upgraded to version '
;
$string
[
'upgradefailure'
]
=
'Failed to upgrade!'
;
$string
[
'noupgrades'
]
=
'Nothing to upgrade! You are fully up to date!'
;
$string
[
'fixtemplatescontinue'
]
=
'Try fixing this and continuing here (templates were not installed)'
;
// Admin navigation menu
$string
[
'usermanagement'
]
=
'Manage users'
;
...
...
@@ -164,4 +165,5 @@ $string['institutionupdatedsuccessfully'] = 'Institution updated successfully';
$string
[
'registrationallowed'
]
=
'Registration allowed?'
;
$string
[
'registrationalloweddescription'
]
=
'Whether users can register for the system with this institution'
;
?>
htdocs/lib/errors.php
View file @
5f2083a9
...
...
@@ -473,4 +473,9 @@ class ArtefactNotFoundException extends Exception {}
* Exception - view not found
*/
class
ViewNotFoundException
extends
Exception
{}
/**
* Exception - anything to do with template parsing
*/
class
TemplateParserException
extends
Exception
{}
?>
htdocs/lib/template.php
View file @
5f2083a9
...
...
@@ -57,7 +57,7 @@ function template_parse($templatename) {
if
(
count
(
$blockids
)
!=
count
(
array_unique
(
$blockids
)))
{
$dups
=
array_unique
(
array_diff_assoc
(
$blockids
,
array_unique
(
$blockids
)));
throw
new
InvalidArgument
Exception
(
"This template (
$templatename
) has duplicate block ids: "
.
implode
(
', '
,
$dups
));
throw
new
TemplateParser
Exception
(
"This template (
$templatename
) has duplicate block ids: "
.
implode
(
', '
,
$dups
));
}
$temp
=
array
(
'type'
=>
'html'
,
...
...
@@ -76,7 +76,7 @@ function template_parse_block($blockstr) {
// the first bit should be 'block'
if
(
$bits
[
0
]
!=
'block'
)
{
throw
new
InvalidArgument
Exception
(
"Invalid block section
$blockstr
"
);
throw
new
TemplateParser
Exception
(
"Invalid block section
$blockstr
"
);
}
array_shift
(
$bits
);
...
...
@@ -86,16 +86,16 @@ function template_parse_block($blockstr) {
}
if
(
!
isset
(
$data
[
'id'
])
||
empty
(
$data
[
'id'
])
||
strpos
(
$data
[
'id'
],
'tpl_'
)
!==
0
)
{
throw
new
InvalidArgument
Exception
(
"Invalid block section
$blockstr
- must have an id beginning with tpl_"
);
throw
new
TemplateParser
Exception
(
"Invalid block section
$blockstr
- must have an id beginning with tpl_"
);
}
if
(
!
isset
(
$data
[
'type'
])
||
empty
(
$data
[
'type'
]))
{
throw
new
InvalidArgument
Exception
(
"Invalid block section
$blockstr
- must have a type"
);
throw
new
TemplateParser
Exception
(
"Invalid block section
$blockstr
- must have a type"
);
}
$types
=
array
(
'artefact'
,
'label'
,
'title'
,
'author'
,
'description'
);
if
(
!
in_array
(
$data
[
'type'
],
$types
)){
throw
new
InvalidArgument
Exception
(
"Invalid block section
$blockstr
(type "
.
$data
[
'type'
]
throw
new
TemplateParser
Exception
(
"Invalid block section
$blockstr
(type "
.
$data
[
'type'
]
.
" not one of "
.
implode
(
', '
,
$types
));
}
...
...
@@ -110,14 +110,14 @@ function template_parse_block($blockstr) {
if
(
isset
(
$data
[
'artefacttype'
]))
{
if
(
!
$plugin
=
get_field
(
'artefact_installed_type'
,
'plugin'
,
'name'
,
$data
[
'artefacttype'
]))
{
throw
new
InvalidArgument
Exception
(
"artefacttype "
.
$data
[
'artefacttype'
]
.
" is not installed"
);
throw
new
TemplateParser
Exception
(
"artefacttype "
.
$data
[
'artefacttype'
]
.
" is not installed"
);
}
if
(
isset
(
$data
[
'format'
]))
{
// check the artefacttype can render to this format.
safe_require
(
'artefact'
,
$plugin
);
if
(
!
artefact_can_render_to
(
$data
[
'artefacttype'
],
$data
[
'format'
]))
{
throw
new
InvalidArgument
Exception
(
"Artefacttype "
.
$data
[
'artefacttype'
]
.
" can't render to format "
throw
new
TemplateParser
Exception
(
"Artefacttype "
.
$data
[
'artefacttype'
]
.
" can't render to format "
.
$format
[
'format'
]);
}
}
...
...
@@ -129,23 +129,23 @@ function template_parse_block($blockstr) {
safe_require
(
'artefact'
,
$data
[
'plugintype'
]);
}
catch
(
Exception
$e
)
{
throw
new
InvalidArgument
Exception
(
"Couldn't find plugin type "
.
$data
[
'plugintype'
]);
throw
new
TemplateParser
Exception
(
"Couldn't find plugin type "
.
$data
[
'plugintype'
]);
}
}
if
(
isset
(
$data
[
'defaultartefacttype'
]))
{
if
(
isset
(
$data
[
'artefacttype'
])
&&
$data
[
'artefacttype'
]
!=
$data
[
'defaultartefacttype'
])
{
throw
new
InvalidArgument
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
throw
new
TemplateParser
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
.
" doesn't make sense given artefact type "
.
$data
[
'artefacttype'
]);
}
else
if
(
isset
(
$data
[
'plugintype'
])
&&
!
in_array
(
$data
[
'defaultartefacttype'
],
call_static_method
(
generate_class_name
(
$data
[
'plugintype'
]),
'get_artefact_types'
)))
{
throw
new
InvalidArgument
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
throw
new
TemplateParser
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
.
" doesn't make sense given plugin type "
.
$data
[
'plugintype'
]);
}
if
(
!
$plugin
=
get_field
(
'artefact_installed_type'
,
'plugin'
,
'name'
,
$data
[
'defaultartefacttype'
]))
{
throw
new
InvalidArgument
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
throw
new
TemplateParser
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
.
" is not installed"
);
}
// look for a default format...
...
...
@@ -154,7 +154,7 @@ function template_parse_block($blockstr) {
$data
[
'defaultformat'
]
=
$data
[
'format'
];
}
else
{
throw
new
InvalidArgument
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
throw
new
TemplateParser
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
.
" specified but with no format method (couldn't find in either "
.
" default format, or fallback format field"
);
}
...
...
@@ -162,13 +162,13 @@ function template_parse_block($blockstr) {
// check the default artefact type can render to the given default format
safe_require
(
'artefact'
,
$plugin
);
if
(
!
artefact_can_render_to
(
$data
[
'defaultartefacttype'
],
$data
[
'defaultformat'
]))
{
throw
new
InvalidArgument
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
throw
new
TemplateParser
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
.
" can't render to defaultformat "
.
$format
[
'defaultformat'
]);
}
// check this default artefact is a 0 or 1 artefact
if
(
!
call_static_method
(
generate_artefact_class_name
(
$data
[
'defaultartefacttype'
]),
'is_0_or_1'
))
{
throw
new
InvalidArgument
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
throw
new
TemplateParser
Exception
(
"Default artefact type "
.
$data
[
'defaultartefacttype'
]
.
" is not a 0 or 1 type artefact"
);
}
}
...
...
@@ -232,7 +232,7 @@ function template_locate($templatename, $fetchdb=true) {
return
$template
;
}
throw
new
InvalidArgument
Exception
(
"Invalid template name
$templatename
, couldn't find"
);
throw
new
TemplateParser
Exception
(
"Invalid template name
$templatename
, couldn't find"
);
}
/**
...
...
htdocs/lib/upgrade.php
View file @
5f2083a9
...
...
@@ -438,7 +438,7 @@ function upgrade_templates() {
foreach
(
$dbtemplates
as
$name
=>
$guff
)
{
if
(
!
is_readable
(
$guff
[
'location'
]
.
'config.php'
))
{
throw
new
InvalidArgument
Exception
(
"missing config.php for template
$name
"
);
throw
new
TemplateParser
Exception
(
"missing config.php for template
$name
"
);
}
require_once
(
$guff
[
'location'
]
.
'config.php'
);
$fordb
=
new
StdClass
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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