fix 'Optional parameter declared before required parameter is implicitly treated...
[Pman.Cms] / UpdateDatabase.php
index dccc8a4..9c2cf1b 100644 (file)
@@ -15,11 +15,39 @@ require_once 'Pman.php';
 class Pman_Cms_UpdateDatabase extends Pman
 {
     
-    static $cli_desc = "Update SQL - Beta";
+    static $cli_desc = "Update Database (Cms)";
  
+    static $cli_opts = array(
+        'template' => array(
+            'desc' => 'Compile a specific template',
+            'default' => '',
+            'short' => 't',
+            'min' => 1,
+            'max' => 1,
+            
+        ),
+        'force-content-update' => array(
+            'desc' => 'Force updating of content from templates',
+            'default' => '',
+            'short' => 'f',
+            'min' => 1,
+            'max' => 1,
+            
+        ),
+        'debug' => array(
+            'desc' => 'Turn on debuggin',
+            'default' => '',
+            'short' => 'd',
+            'min' => 1,
+            'max' => 1,
+            
+        )
+    );
     
     var $cli = false;
+    
+    var $opts;
+    
     function getAuth() {
         
         
@@ -38,16 +66,35 @@ class Pman_Cms_UpdateDatabase extends Pman
         return true;
     }
      
-    function get()
+    function get($tbl, $opts= array())
     {
-        $this->updateData(); 
+        if (!empty($opts['debug'])) {
+            DB_DataObject::debugLevel(1);
+            
+        }
+        if (!empty($opts['template'])) {
+             $tp = DB_DataObject::factory('cms_template');
+             //$opts = HTML_FlexyFramework::get()->Pman_Cms;
+             $tp->syncTemplate($opts['template'], true, '');
+             die("done");
+            
+        }
+        $this->opts = $opts;
+        
+        
+        $this->updateData();
+        if (!empty($tbl)) {
+            $d = DB_DataObject::factory($tbl);
+            $d->initDatabase($this);
+        }
+        
     }
     
     function updateData()
     {
         $enum = DB_DataObject::Factory('core_enum');
         $enum->initEnums(
-            array( 
+            array(
                 array(
                     'etype' => '',
                     'name' => 'cms_page_type',
@@ -60,29 +107,82 @@ class Pman_Cms_UpdateDatabase extends Pman
                         array(
                             'name' => 'element',
                             'display_name' => 'Elements',
-                            
                         ),
                         array(
                             'name' => 'blog',
                             'display_name' => 'Blog Entries',
-                            
                         ),
                         array(
                             'name' => 'menu',
                             'display_name' => 'Menu Tree',
-                            
                         ),
                         array(
                             'name' => 'category',
                             'display_name' => 'Category',
-                            
                         ),
+                        array(
+                            'name' => 'disabled',
+                            'display_name' => 'Disabled element',
+                        ),
+                    )
+                ),
+                array(
+                    'etype' => '',
+                    'name' => 'Cms.Settings',
+                    'display_name' => 'Cms Settings',
+                    'cn' => array(
+                        
+                    )
+                ),
+                array(
+                    'etype' => '',
+                    'name' => 'cms_page_class',
+                    'display_name' =>  'Cms Page Class',
+                    'cn' => array(
+                        array(
+                            'name' => 'deep-blue',
+                            'display_name' => 'Deep Blue',
+                        ),
+                        array(
+                            'name' => 'deep-grey',
+                            'display_name' => 'Deep Grey',
+                        ),
+                        array(
+                            'name' => 'light-red',
+                            'display_name' => 'Light Red',
+                        ),
+                        array(
+                            'name' => 'deep-orange',
+                            'display_name' => 'Deep Orange',
+                        ),
+                        array(
+                            'name' => 'deep-green',
+                            'display_name' => 'Deep Green',
+                        )
                     )
-                )
+                ),
             )
         );
-        $page = DB_DataObject::factory('cms_page');
-        $page->initData();
+        /*
+        $p = DB_DataObject::Factory('cms_page');
+        $p->page_type_id = 0;
+        $all = $p->fetchAll();
+        foreach($all as $t) {
+            $t->convertOld();
+        }
+        $ff = $this->bootLoader;
+        $opts = isset($this->bootLoader->Pman_Cms) ? $this->bootLoader->Pman_Cms  : array();
+        echo "Calling syncTemplateDir from Cms/UpdateDatabase\n";
+        
+        
+        if (empty($this->opts['force-content-update'])) {
+            return;
+        }
+        */
+        echo "Template sync has been removed from here - call   Cms/UpdateTemplates\n";
+        
+        
+       
     }
     
 }
\ No newline at end of file