diff options
author | Kevin Chabowski <kevin@kch42.de> | 2011-12-23 01:43:53 +0100 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2011-12-23 01:43:53 +0100 |
commit | df0658f7e10d2bf87460195f792398d16eee811e (patch) | |
tree | 1f7720ecc6c3ca5e94e84022766121f6f677c88f /ratatoeskr/sys/pluginpackage.php | |
parent | 7d6a5eca4e0a38ae615634542859d29ab79c94e8 (diff) | |
download | ratatoeskr-cms-df0658f7e10d2bf87460195f792398d16eee811e.tar.gz ratatoeskr-cms-df0658f7e10d2bf87460195f792398d16eee811e.tar.bz2 ratatoeskr-cms-df0658f7e10d2bf87460195f792398d16eee811e.zip |
Added plugin management to bakend and fixed db models.
Diffstat (limited to 'ratatoeskr/sys/pluginpackage.php')
-rw-r--r-- | ratatoeskr/sys/pluginpackage.php | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/ratatoeskr/sys/pluginpackage.php b/ratatoeskr/sys/pluginpackage.php index 0200c79..d8ce170 100644 --- a/ratatoeskr/sys/pluginpackage.php +++ b/ratatoeskr/sys/pluginpackage.php @@ -39,6 +39,29 @@ function dir2array($dir) } /* + * Function: array2dir + * Unpack an array into a directory. + * + * Parameters: + * $a - Array to unpack. + * $dir - Directory to unpack to. + */ +function array2dir($a, $dir) +{ + if(!is_dir($dir)) + mkdir($dir); + + foreach($a as $k => $v) + { + $k = "$dir/$k"; + if(is_array($v)) + array2dir($v, $k); + else + file_put_contents($k, $v); + } +} + +/* * Class: InvalidPackage * An Exception that <PluginPackage>'s function can throw, if the package is invalid. */ @@ -99,7 +122,7 @@ class PluginPackage */ public function validate() { - function validate_url ($u) { return preg_match("/^http[s]{0,1}://.*$/", $u) != 0; } + function validate_url ($u) { return preg_match("/^http[s]{0,1}:\\/\\/.*$/", $u) != 0; } function validate_arraydir($a) { if(!is_array($a)) @@ -177,7 +200,7 @@ class PluginPackage throw new InvalidPackage("Wrong SHA1 hash"); $plugin = @unserialize($pluginser); - if(!($plugin instanceof this)) + if(!($plugin instanceof self)) throw new InvalidPackage("Not the correct class or not unserializeable."); $plugin->validate(); @@ -198,8 +221,8 @@ class PluginPackage public function save() { $this->validate(); - $ser = serialize($self); - return this::$magic . sha1($ser, True) . gzcompress($ser, 9); + $ser = serialize($this); + return self::$magic . sha1($ser, True) . gzcompress($ser, 9); } /* |