[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 3 require_once 'Horde/Browser.php'; 4 require_once 'Horde/Block/Collection.php'; 5 6 /** 7 * The Horde_Block_Layout_View class represents the user defined portal layout. 8 * 9 * $Horde: framework/Block/Block/Layout/View.php,v 1.4.2.3 2006/06/23 04:35:21 chuck Exp $ 10 * 11 * Copyright 2003-2006 Mike Cochrane <mike@graftonhall.co.nz> 12 * Copyright 2003-2006 Jan Schneider <jan@horde.org> 13 * 14 * See the enclosed file COPYING for license information (LGPL). If you 15 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 16 * 17 * @author Mike Cochrane <mike@graftonhall.co.nz> 18 * @author Jan Schneider <jan@horde.org> 19 * @since Horde 3.2 20 * @package Horde_Block 21 */ 22 class Horde_Block_Layout_View { 23 24 /** 25 * The current block layout. 26 * 27 * @var array 28 */ 29 var $_layout = array(); 30 31 /** 32 * All applications used in this layout. 33 * 34 * @var array 35 */ 36 var $_applications = array(); 37 38 /** 39 * CSS link tags pulled out of block content. 40 * 41 * @var array 42 */ 43 var $_linkTags = array(); 44 45 /** 46 * Constructor. 47 */ 48 function Horde_Block_Layout_View($layout = '') 49 { 50 $this->_layout = @unserialize($layout); 51 if (!$this->_layout) { 52 $this->_layout = array(); 53 } 54 } 55 56 /** 57 * Render the current layout as HTML. 58 * 59 * @return string HTML layout. 60 */ 61 function toHtml() 62 { 63 $browser = &Browser::singleton(); 64 $tplDir = $GLOBALS['registry']->get('templates', 'horde'); 65 $interval = $GLOBALS['prefs']->getValue('summary_refresh_time'); 66 67 $html = '<table class="nopadding" cellspacing="6" width="100%">'; 68 69 $covered = array(); 70 foreach ($this->_layout as $row_num => $row) { 71 $width = floor(100 / count($row)); 72 $html .= '<tr>'; 73 foreach ($row as $col_num => $item) { 74 if (isset($covered[$row_num]) && isset($covered[$row_num][$col_num])) { 75 continue; 76 } 77 if (is_array($item)) { 78 $this->_applications[$item['app']] = $item['app']; 79 $block = &Horde_Block_Collection::getBlock($item['app'], $item['params']['type'], $item['params']['params']); 80 $rowspan = $item['height']; 81 $colspan = $item['width']; 82 $width *= $colspan; 83 for ($i = 0; $i < $item['height']; $i++) { 84 if (!isset($covered[$row_num + $i])) { 85 $covered[$row_num + $i] = array(); 86 } 87 for ($j = 0; $j < $item['width']; $j++) { 88 $covered[$row_num + $i][$col_num + $j] = true; 89 } 90 } 91 if (is_a($block, 'PEAR_Error')) { 92 $header = _("Error"); 93 $content = $block->getMessage(); 94 ob_start(); 95 include $tplDir . '/portal/block.inc'; 96 $html .= ob_get_clean(); 97 } elseif (is_a($block, 'Horde_Block')) { 98 $header = $block->getTitle(); 99 $content = $block->getContent(); 100 ob_start(); 101 include $tplDir . '/portal/block.inc'; 102 $html .= ob_get_clean(); 103 } else { 104 $html .= '<td width="' . $width . '%"> </td>'; 105 } 106 } else { 107 $html .= '<td width="' . $width . '%"> </td>'; 108 } 109 } 110 $html .= '</tr>'; 111 } 112 $html .= '</table>'; 113 114 // Strip any CSS <link> tags out of the returned content so 115 // they can be handled seperately. 116 if (preg_match_all('/<link .*?rel="stylesheet".*?\/>/', $html, $links)) { 117 $html = str_replace($links[0], '', $html); 118 $this->_linkTags = $links[0]; 119 } 120 121 return $html; 122 } 123 124 /** 125 * Get any link tags found in the view. 126 */ 127 function getLinkTags() 128 { 129 return $this->_linkTags; 130 } 131 132 /** 133 * Return a list of all the applications used by blocks in this layout. 134 * 135 * @return array List of applications. 136 */ 137 function getApplications() 138 { 139 return array_keys($this->_applications); 140 } 141 142 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |