mirror of
				https://github.com/Icinga/icingaweb2.git
				synced 2025-10-31 11:24:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| class Zend_View_Helper_Customvar extends Zend_View_Helper_Abstract
 | |
| {
 | |
|     /**
 | |
|      * Create dispatch instance
 | |
|      *
 | |
|      * @return self
 | |
|      */
 | |
|     public function checkPerformance()
 | |
|     {
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     public function customvar($struct)
 | |
|     {
 | |
|         if (is_string($struct) || is_int($struct) || is_float($struct)) {
 | |
|             return $this->view->escape((string) $struct);
 | |
|         } elseif (is_array($struct)) {
 | |
|             return $this->renderArray($struct);
 | |
|         } elseif (is_object($struct)) {
 | |
|             return $this->renderObject($struct);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     protected function renderArray($array)
 | |
|     {
 | |
|         if (empty($array)) {
 | |
|             return '[]';
 | |
|         }
 | |
|         $out = "<ul>\n";
 | |
|         foreach ($array as $val) {
 | |
|             $out .= '<li>' . $this->customvar($val) . "</li>\n";
 | |
|         }
 | |
|         return $out . "</ul>\n";
 | |
|     }
 | |
| 
 | |
|     protected function renderObject($object)
 | |
|     {
 | |
|         if (empty($object)) {
 | |
|             return '{}';
 | |
|         }
 | |
|         $out = "{<ul>\n";
 | |
|         foreach ($object as $key => $val) {
 | |
|             $out .= '<li>'
 | |
|                   . $this->view->escape($key)
 | |
|                   . ' => '
 | |
|                   . $this->customvar($val)
 | |
|                   . "</li>\n";
 | |
|         }
 | |
|         return $out . "</ul>}";
 | |
|     }
 | |
| 
 | |
| }
 | |
| 
 |