projects
/
Pman.Core
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix #8131 - chinese translations
[Pman.Core]
/
JsTemplate.php
diff --git
a/JsTemplate.php
b/JsTemplate.php
index
81b2113
..
302b1c6
100644
(file)
--- a/
JsTemplate.php
+++ b/
JsTemplate.php
@@
-40,37
+40,47
@@
class Pman_Core_JsTemplate extends Pman {
}
}
- function get()
+ function get(
$v, $opts=array()
)
{
{
+
+ $this->sessionState(0);
// get the modules.
header('Content-type: text/javascript');
$ff = HTML_FlexyFramework::get();
$pr = $ff->project;
// get the modules.
header('Content-type: text/javascript');
$ff = HTML_FlexyFramework::get();
$pr = $ff->project;
- $ar = explode(PATH_SEPARATOR, $ff->HTML_Template_Flexy['templateDir']);
- $prefix = $pr == 'Pman' ? 'Pman.' : '';
+ $mods = $this->modulesList();
+ //print_r($mods);
+
+ //$ar = explode(PATH_SEPARATOR, $ff->HTML_Template_Flexy['templateDir']);
+ array_push($mods, $pr);
- foreach($ar as $mod) {
- $dir = dirname($mod) . '/jtemplates';
+ foreach($mods as $mod )
+ {
+ $prefix = $mod == $pr ? "" : "{$pr}.";
+ //var_dump($prefix);
+ $pdir = $mod == $pr ? '' : ($pr .'/') ;
+
+ $dir = $this->rootDir .'/'.$pdir . $mod . '/jtemplates';
if (!file_exists($dir)) {
if (!file_exists($dir)) {
- echo '// missing directory '. htmlspecialchars($dir) ."\n";
+
//
echo '// missing directory '. htmlspecialchars($dir) ."\n";
continue;
}
// got a directory..
continue;
}
// got a directory..
- $mn = basename(dirname($mod));
+
$ar = glob("$dir/*.html") ;
if (empty($ar)) {
echo '// no template is directory '. htmlspecialchars($dir) ."\n";
continue;
}
$ar = glob("$dir/*.html") ;
if (empty($ar)) {
echo '// no template is directory '. htmlspecialchars($dir) ."\n";
continue;
}
- echo "{$prefix}{$m
n} = {$prefix}{$mn
} || {};\n";
- echo "{$prefix}{$m
n}.template = {$prefix}{$mn
}.template || {};\n\n";
+ echo "{$prefix}{$m
od} = {$prefix}{$mod
} || {};\n";
+ echo "{$prefix}{$m
od}.template = {$prefix}{$mod
}.template || {};\n\n";
foreach(glob("$dir/*.html") as $fn) {
foreach(glob("$dir/*.html") as $fn) {
- $name = "{$prefix}{$m
n
}.template." . preg_replace('/\.html$/i', '', basename($fn));
+ $name = "{$prefix}{$m
od
}.template." . preg_replace('/\.html$/i', '', basename($fn));
echo $this->compile($fn, $name) . "\n";
echo $this->compile($fn, $name) . "\n";
@@
-103,52
+113,61
@@
class Pman_Core_JsTemplate extends Pman {
$out= array();
$out= array();
- $head = "$name = function(t)\n{\n var ret =
[]
;\n\n";
+ $head = "$name = function(t)\n{\n var ret =
''
;\n\n";
$funcs = array();
// do not allow nested functions..?
$fstart = -1;
$funcs = array();
// do not allow nested functions..?
$fstart = -1;
- $indent =
1
;
+ $indent =
2
;
$inscript = false;
$ret = &$out;
foreach($ar as $item) {
$in = str_repeat(" ", $indent);
$inscript = false;
$ret = &$out;
foreach($ar as $item) {
$in = str_repeat(" ", $indent);
-
+ $indent = max($indent , 1);
//var_Dump(substr($item,-3,2));
switch(true) {
case (!strlen($item)):
//var_Dump(substr($item,-3,2));
switch(true) {
case (!strlen($item)):
- continue;
+ continue
2
;
case ($inscript && ($item != '{end:}')):
case ($inscript && ($item != '{end:}')):
- $ret[
]
= $item;
- continue;
+ $ret[
count($ret)-1] .
= $item;
+ continue
2
;
case ($inscript && ($item == '{end:}')):
$inscript = false;
case ($inscript && ($item == '{end:}')):
$inscript = false;
- continue;
+ continue
2
;
case ($item[0] != '{'):
if (!strlen(trim($item))) {
case ($item[0] != '{'):
if (!strlen(trim($item))) {
- continue;
+ continue
2
;
}
$ret[] = $in . "ret += ". json_encode($item) . ";";
}
$ret[] = $in . "ret += ". json_encode($item) . ";";
- continue;
+ continue
2
;
case ($item == '{script:}'):
$inscript = true;
case ($item == '{script:}'):
$inscript = true;
- continue;
+ $ret[] = '';
+ continue 2;
case ($item[1] == '!'):
case ($item[1] == '!'):
- $ret[] = $in . substr($item,1,-1) .';';
- continue;
+ $ret[] = $in . substr($item,2,-1) .';';
+ continue 2;
+
case (substr($item,1,3) == 'if('):
$ret[] = $in . substr($item,1,-1) . ' {';
$indent++;
case (substr($item,1,3) == 'if('):
$ret[] = $in . substr($item,1,-1) . ' {';
$indent++;
- continue;
+ continue
2
;
+ case (substr($item,1,5) == 'else:'):
+ $indent--;
+ $in = str_repeat(" ", $indent);
+ $ret[] = $in . "} else { ";
+ $indent++;
+ continue 2;
+
case (substr($item,1,4) == 'end:'):
$indent--;
$in = str_repeat(" ", $indent);
case (substr($item,1,4) == 'end:'):
$indent--;
$in = str_repeat(" ", $indent);
@@
-157,11
+176,11
@@
class Pman_Core_JsTemplate extends Pman {
$fstart = -1;
$ret = &$out;
}
$fstart = -1;
$ret = &$out;
}
- continue;
+ continue
2
;
case (substr($item,1,7) == 'return:'):
$ret[] = $in . "return;";
case (substr($item,1,7) == 'return:'):
$ret[] = $in . "return;";
- continue;
+ continue
2
;
case (substr($item,1,9) == 'function:'):
$fstart = $indent;
case (substr($item,1,9) == 'function:'):
$fstart = $indent;
@@
-172,22
+191,26
@@
class Pman_Core_JsTemplate extends Pman {
$ret[] = $in . "var $name = function (" . $body . '{';
$ret[] = $in . "var $name = function (" . $body . '{';
- continue;
+ continue
2
;
default:
if (substr($item,-3,2) == ':h') {
$ret[] = $in . "ret += ". substr($item,1,-3) . ';';
default:
if (substr($item,-3,2) == ':h') {
$ret[] = $in . "ret += ". substr($item,1,-3) . ';';
- continue;
+ continue 2;
+ }
+ if (substr($item,-3,2) == ':b') {
+ $ret[] = $in . "ret += Roo.util.Format.htmlEncode(". substr($item,1,-3).').split("\n").join("<br/>\n");';
+ continue 2;
}
$ret[] = $in . "ret += Roo.util.Format.htmlEncode(". substr($item,1,-1).');';
}
$ret[] = $in . "ret += Roo.util.Format.htmlEncode(". substr($item,1,-1).');';
- continue;
+ continue
2
;
}
}
$in = str_repeat(" ", $indent);
}
}
$in = str_repeat(" ", $indent);
- $ret[] = $in . "return ret
.join('')
;\n}\n";
+ $ret[] = $in . "return ret;\n}\n";
return $head . implode("\n",$funcs) . "\n\n" .implode("\n",$out) ;
//echo '<PRE>' . htmlspecialchars(implode("\n",$ret));
return $head . implode("\n",$funcs) . "\n\n" .implode("\n",$out) ;
//echo '<PRE>' . htmlspecialchars(implode("\n",$ret));