1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category module
|
5
|
* @package droplet
|
6
|
* @author Ruud Eisinga (Ruud) John (PCWacht)
|
7
|
* @author WebsiteBaker Project
|
8
|
* @copyright 2004-2009, Ryan Djurovich
|
9
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
10
|
* @link http://www.websitebaker2.org/
|
11
|
* @license http://www.gnu.org/licenses/gpl.html
|
12
|
* @platform WebsiteBaker 2.8.x
|
13
|
* @requirements PHP 5.2.2 and higher
|
14
|
* @version $Id: install.php 1420 2011-01-26 17:43:56Z Luisehahne $
|
15
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/droplets/install.php $
|
16
|
* @lastmodified $Date: 2011-01-26 18:43:56 +0100 (Wed, 26 Jan 2011) $
|
17
|
*
|
18
|
*/
|
19
|
// Must include code to stop this file being access directly
|
20
|
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
|
21
|
|
22
|
global $admin;
|
23
|
|
24
|
$table = TABLE_PREFIX .'mod_droplets';
|
25
|
$database->query("DROP TABLE IF EXISTS `$table`");
|
26
|
|
27
|
$database->query("CREATE TABLE `$table` (
|
28
|
`id` INT NOT NULL auto_increment,
|
29
|
`name` VARCHAR(32) NOT NULL,
|
30
|
`code` LONGTEXT NOT NULL ,
|
31
|
`description` TEXT NOT NULL,
|
32
|
`modified_when` INT NOT NULL default '0',
|
33
|
`modified_by` INT NOT NULL default '0',
|
34
|
`active` INT NOT NULL default '0',
|
35
|
`admin_edit` INT NOT NULL default '0',
|
36
|
`admin_view` INT NOT NULL default '0',
|
37
|
`show_wysiwyg` INT NOT NULL default '0',
|
38
|
`comments` TEXT NOT NULL,
|
39
|
PRIMARY KEY ( `id` )
|
40
|
)"
|
41
|
);
|
42
|
|
43
|
//add all droplets from the droplet subdirectory
|
44
|
$folder=opendir(WB_PATH.'/modules/droplets/example/.');
|
45
|
$names = array();
|
46
|
while ($file = readdir($folder)) {
|
47
|
$ext=strtolower(substr($file,-4));
|
48
|
if ($ext==".php"){
|
49
|
if ($file<>"index.php" ) {
|
50
|
$names[count($names)] = $file;
|
51
|
}
|
52
|
}
|
53
|
}
|
54
|
closedir($folder);
|
55
|
|
56
|
foreach ($names as $dropfile) {
|
57
|
$droplet = addslashes(getDropletCodeFromFile($dropfile));
|
58
|
if ($droplet != "") {
|
59
|
$description = "Example Droplet";
|
60
|
$comments = "Example Droplet";
|
61
|
$cArray = explode("\n",$droplet);
|
62
|
if (substr($cArray[0],0,3) == "//:") {
|
63
|
$description = trim(substr($cArray[0],3));
|
64
|
array_shift ( $cArray );
|
65
|
}
|
66
|
if (substr($cArray[0],0,3) == "//:") {
|
67
|
$comments = trim(substr($cArray[0],3));
|
68
|
array_shift ( $cArray );
|
69
|
}
|
70
|
$droplet = implode ( "\n", $cArray );
|
71
|
$name = substr($dropfile,0,-4);
|
72
|
$modified_when = time();
|
73
|
$modified_by = method_exists($admin, 'get_user_id') ? $admin->get_user_id() : 1;
|
74
|
$database->query("INSERT INTO `$table`
|
75
|
(name, code, description, comments, active, modified_when, modified_by)
|
76
|
VALUES
|
77
|
('$name', '$droplet', '$description', '$comments', '1', '$modified_when', '$modified_by')");
|
78
|
|
79
|
// do not output anything if this script is called during fresh installation
|
80
|
if (method_exists($admin, 'get_user_id')) echo "Droplet import: $name<br/>";
|
81
|
}
|
82
|
}
|
83
|
|
84
|
function getDropletCodeFromFile ( $dropletfile ) {
|
85
|
$data = "";
|
86
|
$filename = WB_PATH."/modules/droplets/example/".$dropletfile;
|
87
|
if (file_exists($filename)) {
|
88
|
$filehandle = fopen ($filename, "r");
|
89
|
$data = fread ($filehandle, filesize ($filename));
|
90
|
fclose($filehandle);
|
91
|
// unlink($filename); doesnt work in unix
|
92
|
}
|
93
|
return $data;
|
94
|
}
|
95
|
?>
|