• R/O
  • SSH
  • HTTPS

jeanscms: コミット


コミットメタ情報

リビジョン246 (tree)
日時2010-08-16 10:50:23
作者kmorimatsu

ログメッセージ

<%using%> tag implementation.

変更サマリ

差分

--- jeanscms/trunk/jeans/libs/error.php (revision 245)
+++ jeanscms/trunk/jeans/libs/error.php (revision 246)
@@ -35,7 +35,9 @@
3535 self::echo_html('<!--\'"-->'.$text,$data);
3636 $db=debug_backtrace();
3737 self::echo_html('<!--');
38+ ob_start();
3839 print_r($db);
40+ self::p(ob_get_clean());
3941 self::echo_html('-->');
4042 for ($i=0;$i<count($db);$i++) {
4143 if ($db[$i]['class']=='error') continue;
--- jeanscms/trunk/jeans/libs/jeans.php (revision 245)
+++ jeanscms/trunk/jeans/libs/jeans.php (revision 246)
@@ -571,7 +571,7 @@
571571 static public function log($desc,$by,$type='general'){
572572 $row=array(
573573 'ip'=>$_SERVER['REMOTE_ADDR'],
574- 'referer'=>$_SERVER['HTTP_REFERER'],
574+ 'referer'=>@$_SERVER['HTTP_REFERER'],
575575 'mid'=>(int)member::setting('id'),
576576 'time'=>_NOW,
577577 'uri'=>$_SERVER['REQUEST_URI'],
--- jeanscms/trunk/jeans/libs/view.php (revision 245)
+++ jeanscms/trunk/jeans/libs/view.php (revision 246)
@@ -136,6 +136,7 @@
136136 $replace=array('self','compile_cb');
137137 }
138138 // Actually, JIT compiler is just a preg_replace_callback.
139+ self::$compile_using=array();
139140 $compiled=preg_replace_callback($search,$replace,$source);
140141 if (!$lambda) return $compiled;
141142 // Create lambda
@@ -143,6 +144,7 @@
143144 if (!is_callable($code)) return error::compile_error($source,$compiled);
144145 return $code;
145146 }
147+ static private $compile_using;
146148 static private function compile_cb($matches){
147149 // Simple replacements
148150 if (count($matches)<=2) {
@@ -165,10 +167,11 @@
165167 // First argument for skin-var is always $data.
166168 array_unshift($args,'$data');
167169 $args=implode(',',$args);
168- if (preg_match('/^(if|ifnot|elseif|elseifnot)\.([a-zA-Z0-9\.]+)$/',$matches[2],$if)) {
170+ if (preg_match('/^(if|ifnot|elseif|elseifnot)(\.[a-zA-Z0-9\.]+)?$/',$matches[2],$if)) {
169171 // If-skinvars.
170- $method=self::compile_cb_method($if[2],'if_');
171- if ($method===false) error::quit('If-var not found: <%0%>',$if[2]);
172+ $iftag=isset($if[2]) ? substr($if[2],1):'';
173+ $method=self::compile_cb_method($iftag,'if_');
174+ if ($method===false) error::quit('If-var not found: <%0%>',$iftag);
172175 switch($if[1]){
173176 case 'ifnot':
174177 return "<?php $cr if (!( $method($args) )) { ?>";
@@ -183,6 +186,11 @@
183186 } else switch($matches[2]){
184187 // The other skinvars.
185188 // Note that the position of $cr is important. This makes the template (if/select) description simple.
189+ case 'using':
190+ foreach(explode(',',$matches[3]) as $namespace){
191+ self::$compile_using[]=$namespace;
192+ }
193+ return $cr;
186194 case 'return':
187195 return "$cr<?php return true; ?>";
188196 case 'exit':
@@ -226,7 +234,14 @@
226234 }
227235
228236 }
229- static private function compile_cb_method($text,$prefix='tag_'){
237+ static private function compile_cb_method($text,$prefix='tag_',$using=true){
238+ if (count(self::$compile_using) && $using) {
239+ foreach(self::$compile_using as $namespace){
240+ $tag=$text=='' ? $namespace:$namespace.'.'.$text;
241+ $method=self::compile_cb_method($tag,$prefix,false);
242+ if ($method) return $method;
243+ }
244+ }
230245 if (preg_match('/^jp\.([a-z0-9]+)$/i',$text,$m)) {
231246 $class='jp_'.$m[1];
232247 $method=$prefix.$m[1];
旧リポジトリブラウザで表示