| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare Wiki - SiteMgr module * 4 * http://www.egroupware.org * 5 * ------------------------------------------------- * 6 * Copyright (c) 2004-6 by RalfBecker@outdoor-training.de * 7 * -------------------------------------------- * 8 * This program is free software; you can redistribute it and/or modify it * 9 * under the terms of the GNU General Public License as published by the * 10 * Free Software Foundation; either version 2 of the License, or (at your * 11 * option) any later version. * 12 \**************************************************************************/ 13 14 /* $Id: class.module_wiki.inc.php 20988 2006-04-06 11:09:19Z ralfbecker $ */ 15 16 include_once (EGW_INCLUDE_ROOT.'/wiki/inc/class.uiwiki.inc.php'); 17 18 /** 19 * extends the wiki user-interface for sitemgr 20 * 21 * As php cant do multiple inheritance, we have to use two classes 22 */ 23 class sitemgr_wiki extends uiwiki 24 { 25 var $wikipage_param = 'wikipage'; // name of the get-param used to transport the wiki-page-names 26 var $wikilang_param = 'wikilang'; // name of the get-param used to transport the wiki-lang 27 var $search_tag = '--s-e-a-r-c-h--'; // used to mark queries 28 var $arguments; 29 30 function sitemgr_wiki($arguments) 31 { 32 $this->arguments = $arguments; 33 34 // calling the constructor of the extended class 35 $this->uiwiki(); 36 } 37 38 /** 39 * reimplemented that the we stay in SiteMgr and dont loose the actual SiteMgr page 40 */ 41 function viewURL($page, $lang='', $version='', $full = '') 42 { 43 $url = $_SERVER['PHP_SELF'].'?'; 44 foreach($_GET as $name => $val) 45 { 46 if (!in_array($name,array('search',$this->wikipage_param,$this->wikilang_param))) 47 { 48 $url .= $name.'='.urlencode($val).'&'; 49 } 50 } 51 foreach(array('lang','version','full') as $name) 52 { 53 if ($$name || is_array($page) && $page[$name]) 54 { 55 if (!$$name && !($$name = $page[$name])) continue; 56 57 if ($name != 'lang') 58 { 59 $url .= $name.'='.urlencode($$name).'&'; 60 } 61 elseif($lang != $GLOBALS['egw_info']['user']['prefereces']['common']['lang']) 62 { 63 $url .= $this->wikilang_param.'='.urlencode($$name).'&'; 64 } 65 } 66 } 67 $url .= $this->wikipage_param.'='.urlencode(is_array($page) ? $page['name'] : $page); 68 69 // the page-parameter has to be the last one, as the old wiki code only calls it once with empty page and appends the pages later 70 return $url; 71 } 72 73 /** 74 * reimplemented to disallow editing 75 */ 76 function editURL($page, $lang='',$version = '') 77 { 78 return False; 79 } 80 81 /** 82 * Show the page-header for the sitemgr module 83 * 84 * @param object/boolean $page sowikipage object or false 85 * @param string $title title of the search 86 */ 87 function header($page=false,$title='') 88 { 89 $html = '<table class="wiki-title"><tr>'; 90 if ($page && ($this->arguments['title'] == 2 || $this->arguments['title'] == 1 && $page->name == $this->arguments['startpage'])) 91 { 92 $title = $this->html->htmlspecialchars($page->title); 93 } 94 if ($this->arguments['search']) 95 { 96 $search = '<form class="wiki-search" action="'.htmlspecialchars($this->viewURL($this->search_tag)).'" method="POST">'. 97 '<input name="search" value="'.$this->html->htmlspecialchars($_REQUEST['search']).'" /> '. 98 '<input type="submit" value="'.$this->html->htmlspecialchars(lang('Search')).'" /></form>'."\n"; 99 } 100 if ($title && $search || $search && $this->arguments['title'] == 1) 101 { 102 return '<table class="wiki-title" cellpadding="0" cellspacing="0"><tr><td><div class="wiki-title">'.$title. 103 '</div></td><td align="right" class="wiki-search">'.$search."</td></tr></table>\n"; 104 } 105 elseif ($title) 106 { 107 return '<div class="wiki-title">'.$title."</div>\n"; 108 } 109 else 110 { 111 return '<div class="wiki-search">'.$search."</div>\n"; 112 } 113 return ''; 114 } 115 116 /** 117 * Show the page-footer for the sitemgr module 118 * 119 * @param object/boolean $page sowikipage object or false 120 */ 121 function footer($page=false) 122 { 123 return ''; 124 } 125 126 /** 127 * view a manual page 128 */ 129 function view() 130 { 131 $wikipage = isset($_GET[$this->wikipage_param]) ? stripslashes(urldecode($_GET['wikipage'])) : 132 (empty($this->arguments['startpage']) ? $this->config['wikihome'] : $this->arguments['startpage']); 133 134 if ($wikipage == $this->search_tag) return $this->search(true); 135 136 $parts = explode(':',$wikipage); 137 if (count($parts) > 1) 138 { 139 $lang = array_pop($parts); 140 if (strlen($lang) == 2 || strlen($lang) == 5 && $lang[2] == '-') 141 { 142 $wikipage = implode(':',$parts); 143 } 144 else 145 { 146 $lang = $_GET[$this->wikilang_param]; 147 } 148 } 149 $page =& $this->page($wikipage,$lang); 150 if ($page->read() === False) $page = false; 151 152 $html = $this->header($page); 153 154 if (!$page) $html .= '<p><b>'.lang("Page '%1' not found !!!",'<i>'.$wikipage.($lang ? ':'.$lang : '').'</i>')."</b></p>\n"; 155 156 $html .= '<div class="wiki-content">' . $this->get($page) . "</div>\n"; 157 $html .= $this->footer($page); 158 159 return $html; 160 } 161 } 162 163 /** 164 * extends SiteMgr's Module class and instanciates the sitemgr_wiki class to display pages 165 */ 166 class module_wiki extends Module 167 { 168 function module_wiki() 169 { 170 $GLOBALS['egw']->translation->add_app('wiki'); 171 172 $this->arguments = array( 173 'startpage' => array( 174 'type' => 'textfield', 175 'label' => lang('Wiki startpage') 176 ), 177 'title' => array( 178 'type' => 'select', 179 'label' => lang('Show the title of the wiki page'), 180 'options' => array( 181 0 => lang('never'), 182 1 => lang('only on the first page'), 183 2 => lang('on all pages'), 184 ) 185 ), 186 'search' => array( 187 'type' => 'checkbox', 188 'label' => lang('Show a search'), 189 ), 190 ); 191 $this->properties = array(); 192 $this->title = lang('Wiki'); 193 $this->description = lang('Use this module for displaying wiki-pages'); 194 } 195 196 function get_content(&$arguments,$properties) 197 { 198 if (!@$GLOBALS['egw_info']['user']['apps']['wiki']) 199 { 200 return lang('You have no rights to view wiki content !!!'); 201 } 202 $wiki =& new sitemgr_wiki($arguments); 203 204 return $wiki->view(); 205 } 206 }
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 |