phpBMS

root/trunk/phpbms/install/install_include.php

Revision 679, 3.9 KB (checked in by nate, 2 years ago)
  • Installing modules no longer requires a createtables.sql file to exist in the module's install folder.
  • Added install.php and version.php to mailchimp module.
Line 
1<?php
2        class installer{
3
4                var $db;
5
6                function installer($db){
7
8                        $this->db = $db;
9
10                }//end function init
11
12
13                function processSQLfile($sqlfile){
14
15                        $return = "";
16
17                        $fileReturn = $this->db->processSQLFile($sqlfile);
18
19                        if(count($fileReturn->errors)){
20
21                                foreach($fileReturn->errors as $error)
22                                        $return .= "\n\n".$error;
23
24                                $return = substr($return, 2);
25
26                                return $return;
27
28                        } else
29                                return true;
30
31                }//end function processSQLfile
32
33        }//end class
34
35
36
37        class modules{
38
39                var $list = array();
40
41                // this loads the modules in to an array
42                // type looks for either update, to make sure the
43                // module folder has an install folder, and inside the install
44                // folder is an install.php or update .php (depending on type)
45                // and that it has a version.php file;
46                function modules($type = "install"){
47
48                        $currdirectory = @getcwd();
49
50                        $thedir= @ opendir("../modules/");
51
52                        $modules = array();
53
54                        //this helps build the modules array
55                        // each included modules version.php should add to the
56                        // array
57                        while($entry = readdir($thedir)){
58
59                                if($entry != "." && $entry != ".." && $entry != "base" && $entry != "sample" && is_dir("../modules/".$entry)){
60
61                                        if(file_exists("../modules/".$entry."/install/".$type.".php") && file_exists("../modules/".$entry."/version.php")){
62
63                                                include("../modules/".$entry."/version.php");
64
65                                        }//endif
66
67                                }//endif
68
69                        }//end if
70
71                        @ chdir ($currdirectory);
72
73                        $this->list = $modules;
74
75                }//end function init
76
77
78                function displpayJS(){
79
80                        echo 'modules = Array();'."\n";
81
82                        foreach($this->list as $name=>$module)
83                                if(is_array($module) && $name != "base"){
84
85                                        echo 'modules["'.$name.'"] = Array()'."\n";
86
87                                        foreach($module as $key=>$value)
88                                                if($key!="requirements")
89                                                        echo 'modules["'.$name.'"]["'.$key.'"] = "'.$value.'";'."\n";
90                                }//endif
91
92
93                }//end function displayJS
94
95
96                function displayInstallTable(){
97
98                        ?>
99                        <table id="moduleTable" cellpadding="0" cellspacing="0" border="0">
100                                <thead>
101                                        <tr>
102                                                <th>module</th>
103                                                <th>version</th>
104                                                <th>&nbsp;</th>
105                                        </tr>
106                                </thead>
107                                <tbody>
108                        <?php
109
110                        ksort($this->list);
111
112                        if(isset($this->list["bms"]))
113                                $this->_displayModuleLine("bms", $this->list["bms"], "bmsModule");
114
115                        foreach($this->list as $key=>$module)
116                                if($key != "base" && $key != "bms")
117                                        $this->_displayModuleLine($key, $module);
118
119
120                        ?></tbody></table><?php
121
122                }//end function displayInstallTable
123
124
125                function _displayModuleLine($name, $module, $class = null){
126
127                        ?>
128                        <tr <?php if($class)  echo 'class="'.$class.'"';?>>
129                                <td>
130                                        <h3><strong><?php echo $module["name"]?></strong></h3>
131                                        <p><?php echo $module["description"]?></p>
132                                        <p class="notes"><strong>Requirements:</strong> <?php echo $module["requirements"]?></p>
133                                </td>
134                                <td><?php echo $module["version"] ?></td>
135                                <td class="moduleInstall">
136                                        <button class="Buttons moduleButtons" id="moduleButton<?php echo $name ?>">Install Module</button>
137                                        <p><span class="" id="Results<?php echo $name?>"></span></p>
138                                </td>
139                        </tr>
140                        <?php
141
142                }//end
143
144        }//end class
145
146
147
148        class installUpdateBase{
149
150                var $db;
151                var $phpbmsSession;
152
153                function returnJSON($success, $details, $extras = null){
154
155                        $thereturn["success"] = $success;
156                        $thereturn["details"] = $details;
157
158                        if($extras)
159                                $thereturn["extras"] = $extras;
160
161                        return json_encode($thereturn);
162
163                }//endfunction returnJSON
164
165        }//end class installUpdateBase
166
167
168?>
Note: See TracBrowser for help on using the browser.
Scanned by Orvant Copyright © 2010 Kreotek, LLC. All Rights reserved.