1 <?php
3 function smarty_block_render($params, $text, &$smarty)
4 {
5 $text = stripslashes($text);
6 $acl = "";
8 /* Skip closing tag </render> */
9 if(empty($text)) {
10 return("");
11 }
13 /* Get acl parameter */
14 if (isset($params['acl'])) {
15 $acl = $params['acl'];
16 unset($params['acl']);
17 }
19 echo "<font color='blue' size='2'>".$acl."</font>";
21 /* Read / Write*/
22 if(preg_match("/w/i",$acl)){
23 return ($text);
24 }
26 /* Disable objects, but keep those active that have mode=read_active */
27 if(!(isset($params['mode']) && $params['mode']=='readable')){
29 /* Disable options */
30 $from = array("/name=/i");
31 $to = array(" disabled name=");
32 $text = preg_replace($from,$to,$text);
34 /* Replace picture if object is disabled */
35 if(isset($params['disable_picture'])){
36 $syn = "/src=['\"][a-z0-9\/.]*['\"]/i";
37 $new = "src=\"".$params['disable_picture']."\"";
38 $text = preg_replace($syn,$new,$text);
39 }
40 }
42 /* Read only */
43 if(preg_match("/r/i",$acl)){
44 return($text);
45 }
47 /* No acls */
48 if(preg_match("/type['\"= ].*submit/",$text)){
49 $text = preg_replace("/submit/","button",$text);
50 }else{
51 $text = preg_replace("/value=['\" ].*['\" ]/","",$text);
52 }
54 /* Remove select options */
55 $from = array("#<option.*<\/option>#i");
56 $to = array(" ");
57 $text = preg_replace($from,$to,$text);
59 return $text;
60 }
62 ?>