$this->scanTables();
$this->syncLanguage();
+ DB_DataObject::factory('core_template')->query(
+ "update core_template set is_deleted = 1 where filetype = ''"
+ );
+
$this->jok('OK');
}
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);
}
+ $template->is_deleted = 0;
+ $template->filetype = 'bjs';
$template->updated = $template->sqlValue("NOW()");
(empty($o)) ? $template->insert() : $template->update($o);
-
+ $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()
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). ')'
+ );
+ }
}