return true;
}
- function get($tbl, $opts=array())
+ function get($step, $opts=array())
{
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
$this->opts = $opts;
- $this->updateData();
+
+ switch($step) {
+ case 'scanProjectBJS':
+ case 'scanPmanBJS':
+ case 'scanPmanTemplates':
+ case 'scanTables':
+ case 'syncLanguage':
+ $this->{$step}();
+ $this->jok("DONE - " . $step);
+ default:
+ $this->jerr("invalid step");
+ }
+
+
}
- function updateData()
+ function updateData() // this does everything?? not used?
+
{
$this->scanProjectBJS();
$this->scanPmanBJS();
$this->scanTables();
$this->syncLanguage();
+ DB_DataObject::factory('core_template')->query(
+ "update core_template set is_deleted = 1 where filetype = ''"
+ );
+
$this->jok('OK');
}
- function scanProjectBJS()
+ function scanProjectBJS() // this is probably not used (replace by the CMS scanner)
{
$ff = HTML_FlexyFramework::get();
if($template->find(true)){
$o = clone ($template);
}
+ $template->filetype = 'bjs';
$template->updated = $template->sqlValue("NOW()");
function scanPmanBJS()
{
+ $ids = array();
foreach ($this->modules() as $m){
$view_name = "Pman.$m";
if(!$dh){
continue;
}
-
+
while (($fn = readdir($dh)) !== false) {
if(empty($fn) || $fn[0] == '.' || !preg_match('/\.bjs$/', $fn)){
$template->setFrom(array(
'template' => $fn,
'lang' => 'en',
- 'view_name' => $view_name
+ 'view_name' => $view_name,
+
));
+
+
$o = false;
if($template->find(true)){
$o = clone ($template);
}
+ $updated = empty($template->updated) ? '1970-01-01' : $template->updated ;
+
+ $template->is_deleted = 0;
+ $template->filetype = 'bjs';
$template->updated = $template->sqlValue("NOW()");
(empty($o)) ? $template->insert() : $template->update($o);
+ if (strtotime($updated) >= filemtime('Pman' . '/' . $m . '/' . $fn)) {
+ continue;
+ }
+
+ $ids[] = $template->id;
$data = json_decode(file_get_contents('Pman' . '/' . $m . '/' . $fn), true);
$template->words = empty($data['strings']) ? array() : $data['strings'];
}
}
+ $del = DB_DataObject::factory('core_template');
+ $del->whereAddIn('!id', $ids, 'int');
+ $del->whereAddIn('view_name', $this->modules(), 'string');
+ $del->filetype = 'bjs';
+ $delids = $del->fetchAll('id');
+ if ($delids) {
+ DB_DataObject::factory('core_template')->query(
+ 'update core_template set is_deleted = 1 where id in('. implode(',', $delids). ')'
+ );
+ }
+
+
+
+
+
}
function scanTables()
if($this->cli){
echo "Sync tables.....\n";
}
+
+ // deactivate all table translation
+ $t = DB_DataObject::factory('core_templatestr');
+ $t->query(
+ "UPDATE core_templatestr
+ SET active = 0
+ WHERE on_table != ''"
+ );
+ // activate the used table translation
foreach($ff->Pman_Core['DataObjects_Core_templatestr']['tables'] as $table=>$cols){
$t = DB_DataObject::factory($table);
foreach($t->fetchAll() as $d) {
if (empty($ff->Pman_Core)) {
$this->jerr("config[Pman_Core] is not set");
}
-
- $opt_lang = empty($ff->Pman_Core_I18n) ? array( 'l' => array()) : $ff->Pman_Core_I18n;
+ $ff = HTML_FlexyFramework::get();
+
+ $opt_lang = empty($ff->Pman_Admin['languages']) ? array( 'l' => array()) : $ff->Pman_Admin['languages'];
if($this->cli){
echo "Sync the Languages template.....\n";
}
- foreach($opt_lang['l'] as $l) {
+ foreach($opt_lang as $l) {
if($this->cli){
echo "Sync $l Language.....\n";
}
$tp = DB_DAtaObject::Factory('core_template');
foreach ($this->modules() as $m){
-
+ //var_dump($m);
// templates...
$ar = $this->scanDir(array(
'tdir' => "Pman/$m/templates",
'skipdir' => array('images','css','js'),
));
-
+ // print_r($ar);
foreach($ar as $pg) {
-
- $tp->syncTemplatePage(array(
+ $temp = $tp->syncTemplatePage(array(
'base' =>'Pman.'.$m,
'template_dir' => "Pman/$m/templates",
'template' => $pg
));
+ if ($temp) {
+ $ids[] = $temp->id;
+ }
}
// should clean up old templates..
// php files..
foreach($ar as $pg) {
- $tp->syncPhpGetText(array(
+ $temp = $tp->syncPhpGetText(array(
'base' =>'Pman.'.$m,
'template_dir' => "Pman/$m",
'template' => $pg
));
+ if ($temp) {
+ $ids[] = $temp->id;
+ }
+
}
//$tp->syncTemplatePage($pg);
}
-
+ $del = DB_DataObject::factory('core_template');
+ $del->whereAddIn('!id', $ids, 'int');
+ $del->whereAddIn('view_name', $this->modules(), 'string');
+ $del->whereAddIn('filetype' , array( 'php', 'html' ), 'string');
+ $delids = $del->fetchAll('id');
+ if ($delids) {
+ DB_DataObject::factory('core_template')->query(
+ 'update core_template set is_deleted = 1 where id in('. implode(',', $delids). ')'
+ );
+ }
}