$tmpl->view_name = $pgdata['base'];
if ($tmpl->get('template', $pgdata['template'])) {
if (strtotime($tmpl->updated) >= filemtime($flexy->resolvePath ($pgdata['template']))) {
+ if ($tmpl->is_deleted != 0 || $tmpl->filetype != 'html') {
+ $oo = clone($tmpl);
+ $tmpl->is_deleted = 0;
+ $tmpl->filetype = 'html';
+ $tmpl->update($oo);
+ }
+
+
+
return $tmpl;
}
}
$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; // already sent headers and everything.
+ }
+
+ putenv("LANGUAGE=$lang");
+ setlocale(LC_ALL, $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;
+ }
+ $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;
+ }
+ if (file_exists($fname) && strtotime($ts->updated) < filemtime($fname)) {
+ return; // 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;
+ $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;
+
+ 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
$this->applyFiltersTree($q,$roo);
}
- if(!empty($q['on_table']) && !is_numeric($q['template_id'])){
+ if(!empty($q['on_table']) && (empty($q['template_id']) || !is_numeric($q['template_id']))){
$this->template_id = 0;
+ $this->whereAdd(" join_src_id_id.txt != ''");
}
if (!empty($q['_search_txt'])) {
$str = $this->escape($q['_search_txt']);
switch(true) {
case ($q['node'] == 'transtree'):
+ case ($q['node'] == 'langlist'):
// DB_DataObject::debugLevel(1);
$x = DB_Dataobject::Factory($this->tableName());
$x->selectAdd();
$x->selectAdd('distinct(lang) as lang');
+
+ $x->selectAdd("i18n_translate('l', lang, 'en') as lang_name");
$x->whereAdd("lang != ''");
$ret= array();
- foreach( $x->fetchAll('lang') as $l) {
+ foreach( $x->fetchAll() as $l) {
$ret[] = array(
- 'text'=>$l,
- 'id' => 'lang:'.$l,
+ 'text'=>$l->lang_name,
+ 'id' => $q['node'] == 'langlist' ? $l->lang : 'lang:'.$l->lang ,
'language' => true
);
}
if (empty($ret)) {
$ret[] = array(
- 'text'=>'en',
+ 'text'=>'English',
'id' => 'lang:en',
'language' => true
);
$x->selectAdd();
$x->selectAdd('distinct(view_name) as view_name');
$x->lang = $lang;
+ $x->whereAdd('join_template_id_id.is_deleted = 0');
$x->orderBy('view_name DESC');
$x->find();
while($x->fetch()) {
'leaf' => false
);
}
+
+ $ff = HTML_FlexyFramework::get()->Pman_Core;
+
+ if(!empty($ff['DataObjects_Core_templatestr']['tables'])){
+ foreach($ff['DataObjects_Core_templatestr']['tables'] as $table=>$v){
+ $ret[] = array(
+ 'text'=> $table,
+ 'on_table' => $table,
+ 'id' => 'table:'. $lang .':'. $table,
+ 'leaf' => true
+ );
+ }
+ }
-
+
$roo->jdata($ret);
- break;
+ break;
case preg_match('/^view:/', $q['node']):
$bits= explode(":",preg_replace('/^view:/', '', $q['node']));
- $x = DB_DataObject::factory($this->tableName());
+ $x = DB_DataObject::factory($this->tableName());
$x->autoJoin();
$x->selectAdd();
$x->selectAdd('distinct(core_templatestr.template_id) as template_id');
$x->whereAdd("join_template_id_id.view_name = '{$x->escape($bits[1])}'");
+ $x->whereAdd('join_template_id_id.is_deleted = 0');
$x->lang = $bits[0];
$ids = $x->fetchAll('template_id');
$ret= array();
//add the table type lists
-
+ /*
$ff = HTML_FlexyFramework::get()->Pman_Core;
- if(!empty($ff['DataObjects_Core_templatestr']['tables'])){
- foreach($ff['DataObjects_Core_templatestr']['tables'] as $table=>$v){
- $ret[] = array(
- 'text'=> $table,
- 'on_table' => $table,
- 'id' => 0,
- 'leaf' => true
- );
- }
- }
// $x->orderBy('template ASC');
// $x->whereAdd("lang != ''");
-
+ */
//below are old code
$xx = DB_Dataobject::Factory('core_template');
$xx->whereAddIn('id', $ids, 'int');
function translateFlexyString($flexy, $string)
{
- //var_dump($string);
- $debug = false;;
+ $debug = false;;
//if (!empty($_REQUEST['_debug'])) { $debug= true; }
// using $flexy->currentTemplate -> find the template we are looking at..
$ff = HTML_FlexyFramework::get();
$view_name = isset($ff->Pman_Core['view_name']) ? $ff->Pman_Core['view_name'] : false;
+ if (empty($view_name)) {
+ $pg = HTML_FlexyFramework::get()->page;
+ if (isset($pg->templateViewName)) {
+ $view_name = $pg->templateViewName;
+ }
+
+ }
+
+
if ($debug) { var_dump(array('view_name'=> $view_name)); }
$tmpname = substr($flexy->currentTemplate, strlen($td) +1);
+
if (isset($cache[$tmpname]) && $cache[$tmpname] === false) {
if ($debug) { echo "from cache no match - $string\n"; }
return $string;
} else {
$tmpl = $cache[$tmpname] ;
}
-
+
+
- //get original template id
+ //get original template id
+ /*
$orig = DB_DataObject::factory($this->tableName());
$orig->lang = '';
$orig->template_id = $tmpl->id;
$orig->active = 1;
+
+ $cache[$tmpname]->words =
+
if(!$orig->get( 'mdsum' , md5(trim($string)))){
//var_dump('no text? '. $string);
if ($debug) { echo "no original string found tplid: {$tmpl->id}\n"; }
return false;
}
-
- //find out the text by language
- $x = DB_DataObject::factory($this->tableName());
- $x->lang = $flexy->options['locale'];
- $x->template_id = $tmpl->id;
- if(!$x->get('src_id', $orig->id)){
- //var_dump('no trans found' . $orig->id);
- if ($debug) { echo "no translation found\n"; }
- return false;
+ */
+
+ if (empty($cache[$tmpname]->translations)) {
+
+ //find out the text by language
+ //DB_DataObject::DebugLevel(1);
+ $x = DB_DataObject::factory($this->tableName());
+ $x->lang = $flexy->options['locale'];
+ $x->template_id = $tmpl->id;
+ $x->autoJoin();
+ $cache[$tmpname]->translations = $x->fetchAll('src_id_mdsum', 'txt');
+ if (empty($cache[$tmpname]->translations)) {
+ $cache[$tmpname]->translations = true;
+ }
+ //var_Dump($cache[$tmpname]->translations);
+ }
+
+
+ if ($cache[$tmpname]->translations === true) {
+ return $string;
}
- if ($debug) { echo "returning $x->txt\n"; }
- //var_Dump($x->txt);
- return empty($x->txt) ? $string : $x->txt;
+ //var_dump("Checking: " . md5(trim($string)));
+
+ if (!empty($cache[$tmpname]->translations [md5(trim($string))])){
+ // var_dump("RETURNING: ". $cache[$tmpname]->translations [md5(trim($string))]);
+ return $cache[$tmpname]->translations [md5(trim($string))];
+ }
+ return $string;
+
}
// determine if a complied template need recompling
if ($size < 0) {
$provider = preg_replace('#/Thumb$#', '', $provider);
- return $baseURL . $provider . "/{$this->id}/{$shorten_name}";
+ return $baseURL . $provider . "/{$this->id}/{$shorten_name}"; // -- this breaks the rss feed #image-{$this->id}";
}
//-- max?
//$size = max(100, (int) $size);
$fc->convert($mt, $size);
- return $baseURL . $provider . "/$size/{$this->id}/{$shorten_name}";
+ return $baseURL . $provider . "/$size/{$this->id}/{$shorten_name}"; // -- this breaks the rss feed #image-{$this->id}";
}
+ function getFromHashURL($url)
+ {
+ $id = false;
+ if (preg_match('/#image-([0-9]+)$/', $url, $matches)) {
+ $id = $matches[1];
+ } else if (preg_match('#Images/Thumb/[^/]+/([0-9]+)/#', $url, $matches)) {
+ $id = $matches[1];
+ } else if (preg_match('#Images/([0-9]+)/#', $url, $matches)) {
+ $id = $matches[1];
+ }
+
+ if ($id === false || $id < 1) {
+ return false;
+ }
+
+ $img = DB_DAtaObject::Factory('images');
+ if ($img->get($id)) {
+ return $img;
+ }
+ return false;
+ }
+
+
function shorten_name()
{
if(empty($this->filename)) {
if (empty($k)) {
return '??';
}
- $lang = !$au || empty($au->lang ) ? 'en' : (is_string($au) ? $au : $au->lang);
+ $fo = &PEAR::getStaticProperty('HTML_Template_Flexy','options');
+
+ $fallback_lang = empty($fo['locale']) ? 'en' : $fo['locale'];
+
+
+ $lang = empty($au ) ? $fallback_lang : (is_string($au) ? $au : $au->lang);
// does it need caching?
--- /dev/null
+
+DROP FUNCTION IF EXISTS core_translate_lookup;
+
+DELIMITER $$
+CREATE FUNCTION core_translate_lookup(
+ in_ontable VARCHAR(128),
+ in_onid INT(11),
+ in_col VARCHAR(128),
+ in_lang VARCHAR(8),
+ in_default TEXT
+)
+RETURNS TEXT NOT DETERMINISTIC READS SQL DATA
+ BEGIN
+
+ DECLARE v_ret TEXT;
+ DECLARE v_id INT(11);
+
+ SET v_id = 0;
+
+ SELECT
+ id , txt
+ INTO
+ v_id, v_ret
+ FROM
+ core_templatestr
+ WHERE
+ on_id = in_onid
+ AND
+ on_table = in_ontable
+ AND
+ on_col = in_col
+ AND
+ lang = in_lang
+ AND
+ active = 1
+ LIMIT 1;
+
+ IF v_id < 1 OR LENGTH(v_ret) < 1 THEN
+ RETURN in_default;
+ END IF;
+
+ RETURN v_ret;
+
+ END $$
+
+DELIMITER ;
\ No newline at end of file
);
ALTER TABLE core_template ADD COLUMN view_name varchar(32) NOT NULL default '';
+ALTER TABLE core_template ADD COLUMN filetype varchar(32) NOT NULL default '';
+ALTER TABLE core_template ADD COLUMN is_deleted INT(2) NOT NULL default 0;
+alter table core_template add index lookupa(view_name, template, lang, filetype, is_deleted);