Code

Added smarty base classes
[gosa.git] / include / smarty / plugins / block.render.php
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         if (isset($_SESSION['DEBUGLEVEL']) && $_SESSION['DEBUGLEVEL'] & DEBUG_ACL ){
17                 echo "<font color='blue' size='2'>&nbsp;".$acl."</font>";
18         }
20         /* Read / Write*/
21         if(preg_match("/w/i",$acl)){
22                 return ($text);
23         }
25         $text = preg_replace ("/\n/","GOSA_LINE_BREAK",$text);
27         /* Disable objects, but keep those active that have mode=read_active */
28         if(!(isset($params['mode']) && $params['mode']=='read_active')){
30                 /* Disable options && greyout divlists */
31                 $from   = array("/class=['\"]list1nohighlight['\"]/i",
32                                 "/class=['\"]list0['\"]/i",
33                                 "/class=['\"]list1['\"]/i");
34                 $to     = array("class='list1nohighlightdisabled'",
35                                 "class='list1nohighlightdisabled'",
36                                 "class='list1nohighlightdisabled'");
37                                 
38                 if(!preg_match("/ disabled /",$text)){
39                         $from [] = "/name=/i" ;
40                         $to   [] = "disabled name=";
41                 }
43                 $text   = preg_replace($from,$to,$text);
45                 /* Replace picture if object is disabled */
46                 if(isset($params['disable_picture'])){
47                         $syn = "/src=['\"][^\"']*['\"]/i";
48                         $new = "src=\"".$params['disable_picture']."\"";
49                         $text = preg_replace($syn,$new,$text);
50                 }
51         }               
53         /* Read only */
54         if(preg_match("/r/i",$acl)){
55                 return(preg_replace("/GOSA_LINE_BREAK/","\n",$text));   
56         }
58         /* No acls */   
59         if(preg_match("/type['\"= ].*submit/",$text)){
60                 $text = preg_replace("/submit/","button",$text);
61         }else{
62                 $text = preg_replace("/value=['\"][^\"']*['\"]/","",$text);
63         }
65         /* Remove select options */
66         $from   = array("#<option.*<\/option>#i",
67                         "/(<textarea.*>).*(<\/textarea>)/i",
68                         "/^(.*<input.*)checked(.*>.*)$/i");
70         $to     = array(" ",
71                         "\\1\\2",
72                         "\\1 \\2");
73         $text   = preg_replace($from,$to,$text);
74         $text = preg_replace("/GOSA_LINE_BREAK/","\n",$text);
76         return $text;
77 }
79 ?>