[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare SiteMgr - Web Content Management * 4 * http://www.egroupware.org * 5 * Written and (c) by RalfBecker@outdoor-training.de * 6 * -------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \**************************************************************************/ 12 13 /* $Id: class.module_template.inc.php 20295 2006-02-15 12:31:25Z $ */ 14 15 class module_template extends Module 16 { 17 function module_template() 18 { 19 $this->arguments = array(); 20 $this->title = lang('Choose template'); 21 $this->themes = $GLOBALS['Common_BO']->theme->getAvailableThemes(); 22 $this->arguments = array( 23 'only_allowed' => array( 24 'type' => 'checkbox', 25 'label' => lang('Show only (in the next field) selected templates'), 26 ), 27 'allowed' => array( 28 'type' => 'select', 29 'multiple' => True, 30 'label' => lang('Select the templates the user is allowed to see'), 31 'options' => $this->themes, 32 'default' => array_keys($this->themes), // all 33 ), 34 'show' => array( 35 'type' => 'select', 36 'label' => lang('Show a template-gallery (thumbnail and informations)'), 37 'options' => array( 38 1 => lang('No, chooser only (for side-areas)'), 39 8 => lang('No, chooser with preview'), 40 3 => lang('Gallery plus chooser'), 41 7 => lang('Gallery plus chooser and download'), 42 2 => lang('Only gallery'), 43 6 => lang('Gallery plus download'), 44 ), 45 ), 46 'zip' => array( 47 'type' => 'textfield', 48 'label' => lang('Path to zip binary if not in path of the webserver'), 49 'default' => 'zip', 50 ), 51 ); 52 $this->description = lang('This module lets the users choose a template or shows a template gallery'); 53 } 54 55 function get_content(&$arguments,$properties) 56 { 57 $show = $arguments['show'] ? $arguments['show'] : 1; 58 $download = @$_GET['download']; 59 60 if (($show & 4) && $download && ($arguments['only_allowed'] && in_array($download,$arguments['allowed'])) || 61 (!$arguments['only_allowed'] && isset($this->themes[$download]))) 62 { 63 $zip = @$arguments['zip'] ? $arguments['zip'] : 'zip'; 64 ob_end_clean(); // discard all previous output 65 $browser =& CreateObject('phpgwapi.browser'); 66 $browser->content_header($download.'.zip','application/zip'); 67 passthru('cd '.$GLOBALS['sitemgr_info']['site_dir'].'/templates; '.$zip.' -qr - '.$download); 68 exit; 69 } 70 if (count($arguments['only_allowed'] ? $arguments['allowed'] : $this->themes) > 1) 71 { 72 if ($show == 1 || $show == 8) // only chooser or chooser with preview 73 { 74 $link = $this->link(); 75 $link .= (strchr($link,'?') ? '&' : '?') . 'themesel='; 76 $content .= '<form name="themeselect" method="post">'."\n"; 77 if ($show == 8) 78 { 79 $content .= '<img width="140" height="110" name="preview" src="'.$this->themes[$GLOBALS['sitemgr_info']['themesel']]['thumbnail'].'"><br />'."\n"; 80 $content .= '<select onChange="document.images.preview.src=\'templates/\'+this.value+\'/template_thumbnail.png\'" name="themesel">'."\n"; 81 } 82 else 83 { 84 $content .= '<select onChange="location.href=\''.$link.'\'+this.value" name="themesel">'."\n"; 85 } 86 foreach ($this->themes as $name => $info) 87 { 88 if ($arguments['only_allowed'] && !in_array($name,$arguments['allowed'])) 89 { 90 continue; 91 } 92 $title = $info['title'] ? ' title="'.$info['title'].'"' : ''; 93 $content .= '<option ' . ($name == $GLOBALS['sitemgr_info']['themesel'] ? 'selected="1" ' : '') . 94 'value="' . $name . '"'. 95 ($info['title'] ? ' title="'.$info['title'].'"' : '').'>'. $info['name'] . '</option>'."\n"; 96 } 97 $content .= '</select>'."\n"; 98 if ($show == 8) 99 { 100 $content .= '<br ><input type="submit" value="'.lang('Select').'" onclick="location.href=\''.$link.'\'+this.form.themesel.value; return false;">'."\n"; 101 } 102 $content .= '</form>'."\n"; 103 } 104 if ($show & 2) // gallery 105 { 106 $t =& CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir('sitemgr')); 107 $t->set_file('theme_info','theme_info.tpl'); 108 $t->set_block('theme_info','info_block'); 109 $content .= '<table>'."\n"; 110 foreach ($this->themes as $name => $info) 111 { 112 //if ($name == 'realss' || $name == 'peeklime') echo "$name=<pre>".print_r($info,true)."</pre>\n"; 113 if ($arguments['only_allowed'] && !in_array($name,$arguments['allowed'])) 114 { 115 continue; 116 } 117 if ($further) $content .= '<tr><td colspan="2"><hr style="width: 30%" /></td></tr>'."\n"; 118 $further = True; 119 120 $info['thumbnail'] = $info['thumbnail'] ? '<img src="'.$info['thumbnail'].'" border="0" hspace="5"/>' : 121 '<div style="text-align:center; font-weight:bold; border:2px ridge black; background-color:white; padding-top:60px; padding-bottom:60px; width:200px;">'.lang('No thumbnail availible').'</div>'; 122 if ($show & 1) // chooser 123 { 124 $info['thumbnail'] = '<a href="'.sitemgr_link(array('themesel'=>$name)+$_GET).'" title="'. 125 lang('View template on this site').'">'.$info['thumbnail'].'</a>'; 126 } 127 128 if ($show & 4) // download 129 { 130 $info['copyright'] .= '<p style="font-size: 10pt;"><a href="'. 131 sitemgr_link(array('download'=>$name)+$_GET).'">'.'<img src="images/zip.gif" border="0" /> '. 132 lang('download as ZIP-archiv').'</a></p>'."\n"; 133 } 134 $t->set_var($info); 135 $t->set_var(array( 136 'lang_author' => lang('Author'), 137 'lang_copyright' => lang('Copyright'), 138 )); 139 $content .= $t->parse('out','info_block'); 140 } 141 $content .= '</table>'."\n"; 142 } 143 return $content; 144 } 145 return lang('No templates found.'); 146 } 147 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |