Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mahara
mahara
Commits
78f1a5c6
Commit
78f1a5c6
authored
Aug 28, 2007
by
Penny Leach
Committed by
Nigel McNie
Oct 17, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more stuff to do with blocktypes...
parent
31ba0c7f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
114 additions
and
24 deletions
+114
-24
htdocs/admin/extensions/plugins.php
htdocs/admin/extensions/plugins.php
+35
-5
htdocs/artefact/file/lib.php
htdocs/artefact/file/lib.php
+1
-1
htdocs/lang/en.utf8/error.php
htdocs/lang/en.utf8/error.php
+1
-0
htdocs/lib/artefact.php
htdocs/lib/artefact.php
+5
-5
htdocs/lib/mahara.php
htdocs/lib/mahara.php
+9
-2
htdocs/lib/upgrade.php
htdocs/lib/upgrade.php
+63
-11
No files found.
htdocs/admin/extensions/plugins.php
View file @
78f1a5c6
...
...
@@ -37,9 +37,12 @@ require('upgrade.php');
$plugins
=
array
();
foreach
(
plugin_types
()
as
$plugin
)
{
// this has to happen first because of broken artefact/blocktype ordering
$plugins
[
$plugin
]
=
array
();
$plugins
[
$plugin
][
'installed'
]
=
array
();
$plugins
[
$plugin
][
'notinstalled'
]
=
array
();
}
foreach
(
plugin_types
()
as
$plugin
)
{
if
(
$installed
=
get_records_array
(
$plugin
.
'_installed'
))
{
foreach
(
$installed
as
$i
)
{
$plugins
[
$plugin
][
'installed'
][
$i
->
name
]
=
array
();
...
...
@@ -78,19 +81,46 @@ foreach (plugin_types() as $plugin) {
continue
;
}
if
(
array_key_exists
(
$dir
,
$plugins
[
$plugin
][
'installed'
]))
{
$installed
=
true
;
}
if
(
$plugin
!=
'artefact'
&&
empty
(
$installed
))
{
continue
;
}
$plugins
[
$plugin
][
'notinstalled'
][
$dir
]
=
array
();
require_once
(
'artefact.php'
);
$funname
=
$plugin
.
'_check_plugin_sanity'
;
if
(
function_exists
(
$funname
))
{
if
(
empty
(
$installed
))
{
$plugins
[
$plugin
][
'notinstalled'
][
$dir
]
=
array
();
try
{
$funname
(
$dir
);
validate_plugin
(
$plugin
,
$dir
);
}
catch
(
InstallationException
$e
)
{
$plugins
[
$plugin
][
'notinstalled'
][
$dir
][
'notinstallable'
]
=
$e
->
GetMessage
();
}
}
if
(
$plugin
==
'artefact'
)
{
// go check it for blocks as well
$btlocation
=
get_config
(
'docroot'
)
.
$plugin
.
'/'
.
$dir
.
'/blocktype'
;
if
(
!
is_dir
(
$btlocation
))
{
continue
;
}
$btdirhandle
=
opendir
(
$btlocation
);
while
(
false
!==
(
$btdir
=
readdir
(
$btdirhandle
)))
{
if
(
strpos
(
$btdir
,
'.'
)
===
0
)
{
continue
;
}
if
(
!
is_dir
(
get_config
(
'docroot'
)
.
$plugin
.
'/'
.
$dir
.
'/blocktype/'
.
$btdir
))
{
continue
;
}
if
(
!
array_key_exists
(
$btdir
,
$plugins
[
'blocktype'
][
'installed'
]))
{
try
{
validate_plugin
(
'blocktype'
,
$dir
.
'/'
.
$btdir
,
get_config
(
'docroot'
)
.
'artefact/'
.
$dir
.
'/blocktype/'
.
$btdir
);
$plugins
[
'blocktype'
][
'notinstalled'
][
$dir
.
'/'
.
$btdir
]
=
array
();
}
catch
(
InstallationException
$_e
)
{
$plugins
[
'blocktype'
][
'notinstalled'
][
$dir
.
'/'
.
$btdir
][
'notinstallable'
]
=
$_e
->
getMessage
();
}
}
}
}
}
}
...
...
htdocs/artefact/file/lib.php
View file @
78f1a5c6
...
...
@@ -37,7 +37,7 @@ class PluginArtefactFile extends PluginArtefact {
}
public
static
function
get_block_types
()
{
return
array
();
return
array
(
'image'
);
}
public
static
function
get_plugin_name
()
{
...
...
htdocs/lang/en.utf8/error.php
View file @
78f1a5c6
...
...
@@ -65,6 +65,7 @@ $string['artefactpluginmethodmissing'] = "Artefact plugin %s must implement %s
$string
[
'blocktypelibmissing'
]
=
'Missing lib.php for block %s in artefact plugin %s'
;
$string
[
'blocktypemissingconfigform'
]
=
'Block type %s must implement config_form'
;
$string
[
'blocktypemissingconfigsave'
]
=
'Block type %s must implement config_save'
;
$string
[
'versionphpmissing'
]
=
'Plugin %s %s is missing version.php!'
;
// if you change these next two , be sure to change them in libroot/errors.php
// as they are duplicated there, in the case that get_string was not available.
...
...
htdocs/lib/artefact.php
View file @
78f1a5c6
...
...
@@ -53,12 +53,12 @@ function artefact_check_plugin_sanity($pluginname) {
}
}
if
(
!
class_exists
(
$typeclassname
))
{
throw
new
InstallationException
(
get_string
(
'
plugin
classmissing'
,
'error'
,
$typeclassname
,
$type
,
$plugin
));
throw
new
InstallationException
(
get_string
(
'classmissing'
,
'error'
,
$typeclassname
,
$type
,
$plugin
));
}
}
$types
=
call_static_method
(
$classname
,
'get_block_types'
);
foreach
(
$types
as
$type
)
{
$
type
classname
=
generate_
blocktype_
class_name
(
$type
);
$
plugin
classname
=
generate_class_name
(
'blocktype'
,
'image'
);
if
(
get_config
(
'installed'
))
{
if
(
$taken
=
get_record_select
(
'blocktype_installed'
,
'name = ?'
,
array
(
$type
)))
{
throw
new
InstallationException
(
get_string
(
'blocktypenametaken'
,
'error'
,
$type
,
...
...
@@ -67,13 +67,13 @@ function artefact_check_plugin_sanity($pluginname) {
}
// go look for the lib file to include
try
{
safe_require
(
'blocktype'
,
$type
);
safe_require
(
'blocktype'
,
$pluginname
.
'/'
.
$type
);
}
catch
(
Exception
$_e
)
{
throw
new
InstallationException
(
get_string
(
'blocktypelibmissing'
,
'error'
,
$type
,
$pluginname
));
}
if
(
!
class_exists
(
$
type
classname
))
{
throw
new
InstallationException
(
get_string
(
'
plugin
classmissing'
,
'error'
,
$
type
classname
,
$type
,
$pluginname
));
if
(
!
class_exists
(
$
plugin
classname
))
{
throw
new
InstallationException
(
get_string
(
'classmissing'
,
'error'
,
$
plugin
classname
,
$type
,
$pluginname
));
}
}
}
...
...
htdocs/lib/mahara.php
View file @
78f1a5c6
...
...
@@ -291,9 +291,16 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
else
{
$extras
=
plugin_types
();
// more later..
foreach
(
$extras
as
$tocheck
)
{
if
(
strpos
(
$section
,
$tocheck
.
'.'
)
===
0
)
{
if
(
strpos
(
$section
,
$tocheck
.
'.'
)
===
0
)
{
$pluginname
=
substr
(
$section
,
strlen
(
$tocheck
)
+
1
);
$locations
[]
=
$docroot
.
$tocheck
.
'/'
.
$pluginname
.
'/lang/'
;
if
(
$tocheck
==
'blocktype'
&&
strpos
(
$pluginname
,
'/'
)
!==
false
)
{
// it belongs to an artefact plugin
$bits
=
explode
(
'/'
,
$pluginname
);
$locations
[]
=
$docroot
.
'artefact/ '
.
$bits
[
0
]
.
'/blocktype/'
.
$bits
[
1
]
.
'/'
.
'lang/'
;
}
else
{
$locations
[]
=
$docroot
.
$tocheck
.
'/'
.
$pluginname
.
'/lang/'
;
}
}
}
}
...
...
htdocs/lib/upgrade.php
View file @
78f1a5c6
...
...
@@ -93,7 +93,21 @@ function check_upgrades($name=null) {
$plugins
=
array
();
if
(
!
empty
(
$name
))
{
$plugins
[]
=
explode
(
'.'
,
$name
);
try
{
$bits
=
explode
(
'.'
,
$name
);
$pt
=
$bits
[
0
];
$pn
=
$bits
[
1
];
$pp
=
null
;
if
(
$pt
==
'blocktype'
&&
strpos
(
$pn
,
'/'
)
!==
false
)
{
$bits
=
explode
(
'/'
,
$name
);
$pp
=
get_config
(
'docroot'
)
.
'artefact/'
.
$bits
[
0
]
.
'/blocktype/'
.
$bits
[
1
];
}
validate_plugin
(
$pt
,
$pn
,
$pp
);
$plugins
[]
=
explode
(
'.'
,
$name
);
}
catch
(
InstallationException
$_e
)
{
log_warn
(
"Plugin
$plugin
$dir
is not installable: "
.
$e
->
GetMessage
());
}
}
else
{
foreach
(
$pluginstocheck
as
$plugin
)
{
...
...
@@ -105,18 +119,30 @@ function check_upgrades($name=null) {
if
(
!
is_dir
(
get_config
(
'docroot'
)
.
$plugin
.
'/'
.
$dir
))
{
continue
;
}
require_once
(
'artefact.php'
);
$funname
=
$plugin
.
'_check_plugin_sanity'
;
if
(
function_exists
(
$funname
))
{
try
{
$funname
(
$dir
);
}
catch
(
InstallationException
$e
)
{
log_warn
(
"Plugin
$plugin
$dir
is not installable: "
.
$e
->
GetMessage
());
try
{
validate_plugin
(
$plugin
,
$dir
);
$plugins
[]
=
array
(
$plugin
,
$dir
);
}
catch
(
InstallationException
$_e
)
{
log_warn
(
"Plugin
$plugin
$dir
is not installable: "
.
$e
->
GetMessage
());
}
if
(
$plugin
==
'artefact'
)
{
// go check it for blocks as well
$btlocation
=
get_config
(
'docroot'
)
.
$plugin
.
'/blocktype'
;
if
(
!
is_dir
(
$btlocation
))
{
continue
;
}
$btdirhandle
=
opendir
(
$btlocation
);
while
(
false
!==
(
$btdir
=
readdir
(
$btdirhandle
)))
{
if
(
strpos
(
$btdir
,
'.'
)
===
0
)
{
continue
;
}
if
(
!
is_dir
(
get_config
(
'docroot'
)
.
$plugin
.
'/blocktype/'
.
$btdir
))
{
continue
;
}
$plugins
[]
=
array
(
'blocktype'
,
$dir
.
'/'
.
$btdir
);
}
}
$plugins
[]
=
array
(
$plugin
,
$dir
);
}
}
}
...
...
@@ -127,7 +153,12 @@ function check_upgrades($name=null) {
$pluginpath
=
"
$plugin[0]/$plugin[1]
"
;
$pluginkey
=
"
$plugin[0].$plugin[1]
"
;
if
(
$plugintype
==
'blocktype'
&&
strpos
(
$pluginname
,
'/'
)
!==
false
)
{
// sigh.. we're a bit special...
$bits
=
explode
(
'/'
,
$pluginname
);
$pluginpath
=
'artefact/'
.
$bits
[
0
]
.
'/blocktype/'
.
$bits
[
1
];
}
// Don't try to get the plugin info if we are installing - it will
// definitely fail
$pluginversion
=
0
;
...
...
@@ -539,4 +570,25 @@ function local_xmldb_contents_sub(&$contents) {
$contents
=
str_replace
(
$searchstring
,
$tosub
,
$contents
);
}
/**
* validates a plugin for installation
* @throws InstallationException
*/
function
validate_plugin
(
$plugintype
,
$pluginname
,
$pluginpath
=
''
)
{
if
(
empty
(
$pluginpath
))
{
$pluginpath
=
get_config
(
'docroot'
)
.
$plugin
.
'/'
;
}
if
(
!
file_exists
(
$pluginpath
.
'/version.php'
))
{
throw
new
InstallationException
(
get_string
(
'versionphpmissing'
,
'error'
,
$plugintype
,
$pluginname
));
}
require_once
(
'artefact.php'
);
$funname
=
$plugintype
.
'_check_plugin_sanity'
;
if
(
function_exists
(
$funname
))
{
$funname
(
$pluginname
);
}
// @TODO more?
}
?>
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