5 * This applies database files from
6 * a) OLD - {MODULE}/DataObjects/XXXX.{dbtype}.sql
8 * b) NEW - {MODULE}/sql/XXX.sql (SHARED or translable)
9 * and {MODULE}/{dbtype}/XXX.sql (SHARED or translable)
14 require_once 'Pman.php';
15 class Pman_Cms_UpdateDatabase extends Pman
18 static $cli_desc = "Update SQL - Beta";
20 static $cli_opts = array(
22 'desc' => 'Compile a specific template',
30 'desc' => 'Turn on debuggin',
43 $ff = HTML_FlexyFramework::get();
44 if (!empty($ff->cli)) {
49 parent::getAuth(); // load company!
50 $au = $this->getAuthUser();
51 if (!$au || $au->company()->comptype != 'OWNER') {
52 $this->jerr("Not authenticated", array('authFailure' => true));
54 $this->authUser = $au;
58 function get($tbl, $opts)
60 if (!empty($opts['debug'])) {
61 DB_DataObject::debugLevel(1);
64 if (!empty($opts['template'])) {
65 $tp = DB_DataObject::factory('cms_template');
66 //$opts = HTML_FlexyFramework::get()->Pman_Cms;
67 $tp->syncTemplate($opts['template'], true, '');
74 $d = DB_DataObject::factory($tbl);
75 $d->initDatabase($this);
82 $enum = DB_DataObject::Factory('core_enum');
87 'name' => 'cms_page_type',
88 'display_name' => 'Cms Page Type',
92 'display_name' => 'Pages',
96 'display_name' => 'Elements',
101 'display_name' => 'Blog Entries',
106 'display_name' => 'Menu Tree',
110 'name' => 'category',
111 'display_name' => 'Category',
119 $p = DB_DataObject::Factory('cms_page');
120 $p->page_type_id = 0;
121 $all = $p->fetchAll();
122 foreach($all as $t) {
126 $opts = HTML_FlexyFramework::get()->Pman_Cms;
128 $tp = DB_DataObject::factory('cms_template');
129 $tp->syncTemplateDir(false, '', true);
130 //if (isset($q['lang'])) {
131 // $this->syncLang($q['lang']);
134 $page = DB_DataObject::factory('cms_page');
138 // templates.. -- assume the above does the template syncing..
139 //DB_DataObject::DebugLevel(1);
140 echo "Sync the Languages template.....\n";
141 $x = DB_Dataobject::Factory('cms_templatestr');
143 $x->selectAdd('distinct(lang) as lang');
144 $x->whereAdd("lang != ''");
146 echo "Sync default Language.....\n";
147 $tps = DB_DataObject::factory('cms_templatestr');
148 $tps->syncLang('en'); /// this should be configured somewhere..
151 foreach( $x->fetchAll('lang') as $l) {
152 echo "Sync $l Language.....\n";
153 $tps = DB_DataObject::factory('cms_templatestr');
154 $tps->syncLang($l); /// this should be configured somewhere..
158 //sync the tables to cms_templatestr
159 if(isset($opts['trans_tables'])){