1 <?php
3 function smarty_block_render($params, $text, &$smarty)
4 {
5 /* Skip closing tag </render> */
6 if(empty($text)) {
7 return("");
8 }
10 /* Get acl parameter */
11 if (isset($params['acl'])) {
12 $acl = $params['acl'];
13 unset($params['acl']);
14 }
16 echo "<font color='blue' size='2'> ".$acl."</font>";
18 /* Read / Write*/
19 if(preg_match("/w/i",$acl)){
20 return ($text);
21 }
23 /* Disable objects, but keep those active that have mode=read_active */
24 if(!(isset($params['mode']) && $params['mode']=='readable')){
26 /* Disable options && greyout divlists */
30 $from = array("/class=['\"]list1nohighlight['\"]/i",
31 "/class=['\"]list0['\"]/i",
32 "/class=['\"]list1['\"]/i");
33 $to = array("class='list1nohighlightdisabled'",
34 "class='list1nohighlightdisabled'",
35 "class='list1nohighlightdisabled'");
37 if(!preg_match("/ disabled /",$text)){
38 $from [] = "/name=/i" ;
39 $to [] = "disabled name=";
40 }
42 $text = preg_replace($from,$to,$text);
44 /* Replace picture if object is disabled */
45 if(isset($params['disable_picture'])){
46 $syn = "/src=['\"][^\"']*['\"]/i";
47 $new = "src=\"".$params['disable_picture']."\"";
48 $text = preg_replace($syn,$new,$text);
49 }
50 }
52 /* Read only */
53 if(preg_match("/r/i",$acl)){
54 return($text);
55 }
57 /* No acls */
58 if(preg_match("/type['\"= ].*submit/",$text)){
59 $text = preg_replace("/submit/","button",$text);
60 }else{
61 $text = preg_replace("/value=['\"][^\"']*['\"]/","",$text);
62 }
64 /* Remove select options */
65 $from = array("#<option.*<\/option>#i");
66 $to = array(" ");
67 $text = preg_replace($from,$to,$text);
69 return $text;
70 }
72 ?>