15
15
* You should have received a copy of the GNU General Public License
16
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
*
18
- * 2007 - 2020 , open3A GmbH - [email protected]
18
+ * 2007 - 2021 , open3A GmbH - [email protected]
19
19
*/
20
20
abstract class Collection {
21
21
protected $ A = null ;
@@ -118,8 +118,8 @@ function getCollectionOf(){
118
118
*/
119
119
function checkIfMyDBFileExists (){
120
120
#$p = $this->getClearClass();#
121
- $ p = str_replace ("GUI " ,"" ,get_class ($ this ));
122
- return file_exists (Util:: getRootPath (). $ _SESSION [ " CurrentAppPlugins " ]-> getAppFolderOfPlugin ( $ p ). " / " . $ _SESSION [ " CurrentAppPlugins " ]-> getFolderOfPlugin ( $ p ). " /CI.pfdb.php " );
121
+ # $p = str_replace("GUI","",get_class($this));
122
+ return file_exists ($ this -> getMyDBFileName () );
123
123
}
124
124
125
125
/**
@@ -130,7 +130,7 @@ function checkIfMyDBFileExists(){
130
130
function getMyDBFileName (){
131
131
#$p = $this->getClearClass();
132
132
$ p = str_replace ("GUI " ,"" ,get_class ($ this ));
133
- return Util::getRootPath ().$ _SESSION ["CurrentAppPlugins " ]->getAppFolderOfPlugin ($ p )."/ " .$ _SESSION ["CurrentAppPlugins " ]->getFolderOfPlugin ($ p )."/CI.pfdb.php " ;
133
+ return Util::getRootPath ().$ _SESSION ["CurrentAppPlugins " ]->getAppFolderOfPlugin ($ p )."/ " .$ _SESSION ["CurrentAppPlugins " ]->getFolderOfPlugin ($ p )."/mysql.sql " ;
134
134
}
135
135
136
136
/**
@@ -154,9 +154,23 @@ function getMyTablesInfos(){
154
154
$ this ->loadAdapter ();
155
155
156
156
if ($ this ->checkIfMyDBFileExists ()) {
157
- $ creates = new CIs ();
158
- $ creates ->setMyDBFolder ($ this ->getMyDBFolder ());
159
- $ creates ->lCV3 ();
157
+ $ data = file_get_contents ($ this ->getMyDBFileName ());
158
+ $ creates = new ArrayCollection ();
159
+ foreach (explode ("-- END " , $ data ) AS $ sql ){
160
+ if (trim ($ sql ) == "" )
161
+ continue ;
162
+
163
+ $ A = new stdClass ();
164
+ $ A ->MySQL = $ sql ;
165
+
166
+ $ P = new PersistentObject (-1 );
167
+ $ P ->setA ($ A );
168
+
169
+ $ creates ->add ($ P );
170
+ }
171
+ #$creates = new CIs();
172
+ #$creates->setMyDBFolder($this->getMyDBFolder());
173
+ #$creates->lCV3();
160
174
161
175
return $ creates ;
162
176
} else $ _SESSION ["messages " ]->addMessage ("Database-information file for plugin " .str_replace ("GUI " ,"" ,get_class ($ this ))." does not exist. " );
@@ -167,7 +181,7 @@ function getMyTablesInfos(){
167
181
* Creates a Database Table using the information of the associated database file.
168
182
*/
169
183
function createMyTable ($ quiet = false ) {
170
- $ _SESSION ["messages " ]->addMessage ("Creating table for " .get_class ($ this ).". Using file " .$ this ->getMyDBFolder ()."CI.pfdb.php ... " );
184
+ $ _SESSION ["messages " ]->addMessage ("Creating table for " .get_class ($ this ).". Using file " .$ this ->getMyDBFolder ()."mysql.sql ... " );
171
185
#if(!$this->checkIfMyTableExists()) {
172
186
173
187
$ creates = $ this ->getMyTablesInfos ();
@@ -182,8 +196,8 @@ function createMyTable($quiet = false) {
182
196
continue ;
183
197
}
184
198
185
- $ CIA ->MySQL = str_replace ("%%&ESCSLASH%%& " ,"\' " ,$ CIA ->MySQL );
186
- $ CIA ->MSSQL = str_replace ("%%&ESCSLASH%%& " ,"\' " ,$ CIA ->MSSQL );
199
+ # $CIA->MySQL = str_replace("%%&ESCSLASH%%&","\'",$CIA->MySQL);
200
+ # $CIA->MSSQL = str_replace("%%&ESCSLASH%%&","\'",$CIA->MSSQL);
187
201
$ message .= SqlFormatter::format (htmlentities ($ CIA ->MySQL ), false );
188
202
189
203
$ connection = $ this ->Adapter ->createMyTable ($ CIA );
@@ -223,23 +237,25 @@ function createMyTable($quiet = false) {
223
237
* and the data in the Database File.
224
238
*/
225
239
function checkMyTables ($ quiet = false ){
226
- $ _SESSION ["messages " ]->addMessage ("Checking tables of " .get_class ($ this ).". " );
240
+ # $_SESSION["messages"]->addMessage("Checking tables of ".get_class($this).".");
227
241
228
242
$ creates = $ this ->getMyTablesInfos ();
229
-
243
+
230
244
$ changes = 0 ;
231
245
232
- if (is_numeric ( $ creates) AND $ creates == -1 ) {
246
+ if ($ creates = == -1 ) {
233
247
echo -2 ;
234
248
return ;
235
249
}
250
+
236
251
try {
237
- while (( $ CI = $ creates ->getNextEntry () )){
238
- $ _SESSION ["messages " ]->addMessage ("checking entry " .$ CI ->getID ());
252
+ while ($ CI = $ creates ->n ( )){
253
+ # $_SESSION["messages"]->addMessage("checking entry ".$CI->getID());
239
254
#$CIA = $CI->getA();
240
255
$ c = $ this ->Adapter ->checkMyTable ($ CI ->getA ());
241
256
242
- if ($ c >= 0 ) $ changes +=$ c ;
257
+ if ($ c >= 0 )
258
+ $ changes += $ c ;
243
259
#else return -1;
244
260
}
245
261
} catch (TableDoesNotExistException $ e ){
@@ -507,9 +523,9 @@ function resetPointer(){
507
523
* @return String Classname
508
524
*/
509
525
function getClearClass (){
510
- if (isset ($ this ->collectionOf ) AND ( get_class ( $ this ) == " mGenericGUI " OR get_class ( $ this ) == " anyC " OR get_parent_class ( $ this ) == " anyC " ) )
526
+ if (isset ($ this ->collectionOf ) AND $ this instanceof anyC)
511
527
return "m " .$ this ->collectionOf ;
512
-
528
+
513
529
$ n = get_class ($ this );
514
530
if (strstr ($ n ,"GUI " ))
515
531
$ n = get_parent_class ($ this );
@@ -667,6 +683,9 @@ public function getTotalNum(){
667
683
* @return Integer Number of entries in Collector
668
684
*/
669
685
public function numLoaded (){
686
+ if ($ this ->collector === null )
687
+ return 0 ;
688
+
670
689
return count ($ this ->collector );
671
690
}
672
691
@@ -699,8 +718,8 @@ protected function filterCategories(){
699
718
$ F = $ this ->getCategoryFieldName ();
700
719
if ($ K != null AND $ K != "" ) {
701
720
$ Ks = explode ("; " ,$ K );
702
- foreach ($ Ks as $ k => $ v )
703
- $ this ->addAssocV3 (" $ F " , "= " ,$ v ,($ k == "0 " ? "AND " : "OR " ),"fCs " );
721
+ foreach ($ Ks AS $ k => $ v )
722
+ $ this ->addAssocV3 ($ F , "= " , $ v , ($ k == "0 " ? "AND " : "OR " ), "fCs " );
704
723
705
724
$ fC = true ;
706
725
}
@@ -797,7 +816,7 @@ public function asJSON($append = null){
797
816
#$this->lCV3();
798
817
799
818
$ array = array ();
800
- while ($ A = $ this ->getNextEntry ()){
819
+ while ($ A = $ this ->n ()){
801
820
$ subArray = array ();
802
821
foreach ($ A ->getA () as $ key => $ value )
803
822
$ subArray [$ key ] = $ value ;
0 commit comments