}
+ function beforeUpdate($old, $q, $roo)
+ {
+ if (!empty($q['_rescan'])){
+ if ($this->filetype != 'html') {
+ $roo->jerr("can not update a php source file currently - TDOD");
+ }
+ $pg = HTML_FlexyFramework::get()->page;
+
+ $this->syncTemplatePage(array(
+ 'template_dir' => $pg->rootDir . '/'. str_replace('.', '/', $this->view_name). '/templates',
+ 'template' => $this->template,
+ 'base' => $this->view_name,
+ 'force' => true
+ ));
+ // update the different langage versions of this page.
+ $x = DB_Dataobject::Factory('core_templatestr');
+ $x->selectAdd();
+ $x->selectAdd('distinct(lang) as lang');
+ $x->whereAdd("lang != ''");
+ $langs = $x->fetchAll('lang');
+ foreach($langs as $l) {
+ $x = DB_Dataobject::Factory('core_templatestr');
+ $x->syncLang($l, $this->id);
+ }
+
+
+ $roo->jok("updated -" . $this->template);
+ }
+ }
+
+
+
+
/*
* @param base (should be full path to template directory)
* @param subdir = empty for top or subpath.
* @param template_dir << the path to the template dir ... Pman/XXX/template ...
* @param template << name of template used by name field)
* @param base << view name (module ? + templates?)
+ * @param force << optional - forces even if database is newer.
*
*
*/
ini_set('memory_limit', '512M');
//var_dump($n);
- $n= $pgdata['template']; // remove trailing slash..
+ $n = $pgdata['template']; // remove trailing slash..
$fopts = HTML_FlexyFramework::get()->HTML_Template_Flexy;
$opts = HTML_FlexyFramework::get()->Pman_Core;
$tmpl->view_name = $pgdata['base'];
if ($tmpl->get('template', $pgdata['template'])) {
if (strtotime($tmpl->updated) >= filemtime($flexy->resolvePath ($pgdata['template']))) {
- return $tmpl;
+ if ($tmpl->is_deleted != 0 || $tmpl->filetype != 'html') {
+ $oo = clone($tmpl);
+ $tmpl->is_deleted = 0;
+ $tmpl->filetype = 'html';
+ $tmpl->update($oo);
+ }
+ if (empty($pgdata['force'])) {
+ return $tmpl;
+ }
}
}
-
+ //die("got here");
try {
$r = $flexy->compile($pgdata['template']);
+
+
} catch(Exception $e) {
$old = clone($tmpl);
$tmpl->updated = date('Y-m-d H:i:s',filemtime($flexy->resolvePath ($pgdata['template'])));
if ($tmpl->id) {
+ $tmpl->is_deleted = 0;
+ $tmpl->filetype = 'html';
$tmpl->update($tmpl);
} else {
+ $tmpl->is_deleted = 0;
+ $tmpl->filetype = 'html';
$tmpl->lang = 'en';
$tmpl->insert();
}
if (!$tmpl->get('template', $pgdata['template'])) {
-
+ $tmpl->is_deleted = 0;
+ $tmpl->filetype = 'html';
$tmpl->template = $pgdata['template'];
$tmpl->lang = 'en'; /// ??? hard coded??
$tmpl->updated = date('Y-m-d H:i:s', filemtime($flexy->currentTemplate));
//echo "FIX LANG?";exit;
$tmpl->lang = 'en'; /// ??? hard coded??
}
-
+ $tmpl->filetype = 'html';
+ $tmpl->is_deleted = 0;
$tmpl->updated = date('Y-m-d H:i:s', filemtime($flexy->currentTemplate));
$tmpl->update($xx);
}
if ($tmpl->get('template', $pgdata['template'])) {
if (strtotime($tmpl->updated) >= filemtime( $tmpl->currentTemplate )) {
+ if ($tmpl->is_deleted != 0 || $tmpl->filetype != 'html') {
+ $oo = clone($tmpl);
+ $tmpl->is_deleted = 0;
+ $tmpl->filetype = 'php';
+ $tmpl->update($oo);
+ }
return $tmpl;
}
}
$tmpl->template = $pgdata['template'];
$tmpl->lang = 'en'; /// ??? hard coded??
+ $tmpl->filetype = 'php';
+ $tmpl->is_deleted = 0;
$tmpl->updated = date('Y-m-d H:i:s', filemtime($tmpl->currentTemplate));
$tmpl->insert();
} else {
$xx =clone($tmpl);
-
+ $tmpl->filetype = 'php';
+ $tmpl->is_deleted = 0;
$tmpl->lang = 'en'; /// ??? hard coded??
$tmpl->updated = date('Y-m-d H:i:s', filemtime($tmpl->currentTemplate));
$tmpl->update($xx);
+ }
+ /*
+ SELECT LOWER(
+CONCAT(
+REPLACE(view_name, '.','_'),
+'_',
+REPLACE(template,'/','_')
+)
+)
+FROM core_template
+
+WHERE (
+ = 'release_pressrelease_distributionreportnew_journalistdistribution.php'
+)
+*/
+
+
+ function genGetText($clsname, $lang=false)
+ {
+ static $done = false;
+ $clsname = strtolower($clsname);
+
+ textdomain($clsname);
+
+
+ $ff = HTML_FlexyFramework::get();
+ $lang = $lang ? $lang : (isset($ff->locale) ? $ff->locale : 'en');
+
+
+ if (!empty($done[$clsname.':'.$lang])) {
+ return true; // already sent headers and everything.
+ }
+
+ putenv("LANGUAGE=$lang");
+ if ($lang != 'en') {
+ if (!setlocale(LC_ALL, $lang.'.UTF-8')) {
+ $ff->page->jerr("Language is not available {$lang}");
+ }
+ }
+
+
+ $d = DB_DataObject::factory($this->tableName());
+ $d->whereAdd("
+ LOWER(
+ CONCAT(
+ REPLACE(view_name, '.','_'),
+ '_',
+ REPLACE(template,'/','_')
+ )
+ ) = '{$clsname}.php'
+ ");
+ $d->filetype = 'php';
+ if (! $d->find(true) ){
+ $done[$clsname.':'.$lang] = true;
+ return false;
+ }
+ $user = 'www-data'; // ?? do we need other ones
+ $compileDir = ini_get('session.save_path') .'/' .
+ $user . '_gettext_' . $ff->project;
+
+ if ($ff->appNameShort) {
+ $compileDir .= '_' . $ff->appNameShort;
+ }
+ if ($ff->version) {
+ $compileDir .= '.' . $ff->version;
+ }
+ $lang = $lang ? $lang : $ff->locale;
+ $fdir = "{$compileDir}/{$lang}/LC_MESSAGES";
+ $fname = "{$fdir}/{$clsname}.mo";
+
+
+ //exit;
+ bindtextdomain($clsname, $compileDir) ;
+ bind_textdomain_codeset($clsname, 'UTF-8');
+
+ textdomain($clsname);
+
+
+ //textdomain($clsname);
+
+ $done[$clsname.':'.$lang] = 1;
+
+ // do we need to compile the file..
+ $ts = DB_DataObject::Factory('core_templatestr');
+ $ts->selectAdd('MAX(updated) as updated');
+ $ts->lang = $lang;
+ $ts->template_id = $d->id;
+ if (!$ts->find(true)) {
+ // then in theory there are no translations
+ return false;
+ }
+ if (file_exists($fname) && strtotime($ts->updated) < filemtime($fname)) {
+ return $fname; // file exists and is newer than our updated line.
+ }
+ //DB_DataObject::debugLevel(1);
+
+ $ts = DB_DataObject::Factory('core_templatestr');
+ $ts->autoJoin();
+ $ts->selectAdd('join_src_id_id.txt as src_id_txt, core_templatestr.txt as txt');
+ $ts->lang = $lang;
+ $ts->template_id = $d->id;
+ $ts->whereAdd("LENGTH(join_src_id_id.txt) > 0 AND LENGTH(core_templatestr.txt) > 0");
+ $words = $ts->fetchAll('src_id_txt', 'txt' );
+
+ if (!file_exists($fdir)) {
+ //var_dump($fdir);
+ mkdir($fdir, 0700, true);
+ }
+
+ require_once 'File/Gettext.php';
+ $gt = File_Gettext::factory('PO', preg_replace('/\.mo$/', '.po', $fname));
+ $gt->fromArray(
+
+ array(
+ 'meta' => array(
+ "Language" => $lang,
+ 'Content-Type' => 'text/plain; charset=UTF-8',
+ 'Content-Transfer-Encoding' => ' 8bit',
+ 'PO-Revision-Date' => date('Y-m-d H:iO'),
+ ),
+ 'strings' => $words
+ )
+
+ );
+ $gt->save();
+
+ // mo DOESNT WORK!!
+ require_once 'System.php';
+ $poname = preg_replace('/\.mo$/', '.po', $fname);
+ $msgfmt = System::which('msgfmt');
+ $cmd = "{$msgfmt} {$poname} -o {$fname}";
+ //echo $cmd;
+
+ `$cmd`;
+
+
+
+
+ return $fname;
+
+ require_once 'File/Gettext.php';
+ $gt = File_Gettext::factory('MO', $fname);
+ $gt->fromArray(
+
+ array(
+ 'meta' => array(
+ "Language" => $lang,
+ 'Content-Type' => 'text/plain; charset=UTF-8',
+ 'Content-Transfer-Encoding' => ' 8bit',
+ 'PO-Revision-Date' => date('Y-m-d H:iO'),
+ ),
+ 'strings' => $words
+ )
+
+ );
+ $gt->save();
+
}
}
\ No newline at end of file