[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - Online User manual * 4 * http://www.eGroupWare.org * 5 * Written and copyright (c) 2004-6 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.uimanual.inc.php 20990 2006-04-06 11:11:08Z ralfbecker $ */ 14 15 include_once (EGW_INCLUDE_ROOT.'/wiki/inc/class.uiwiki.inc.php'); 16 17 class uimanual extends uiwiki 18 { 19 var $public_functions = array( 20 'view' => True, 21 'search' => True, 22 ); 23 var $manual_config; 24 25 function uimanual() 26 { 27 $config =& CreateObject('phpgwapi.config','manual'); 28 $config->read_repository(); 29 if (!is_array($config->config_data) || !isset($config->config_data['manual_update_url'])) // empty never get's stored 30 { 31 foreach(array( 32 'manual_remote_egw_url' => 'http://manual.egroupware.org/egroupware', 33 'manual_update_url' => 'http://manual.egroupware.org/egroupware/wiki/index.php?page=Manual&action=xml', 34 'manual_wiki_id' => 1, 35 'manual_allow_anonymous' => '', // no 36 'manual_anonymous_user' => 'anonymous', 37 'manual_anonymous_password' => 'anonymous', 38 ) as $name => $default) 39 { 40 if (!isset($config->config_data[$name]) || 41 $name == 'manual_update_url' && $config->config_data[$name] == 'http://egroupware.org/egroupware/wiki/index.php?page=Manual&action=xml') 42 { 43 $config->config_data[$name] = $default; 44 $need_save = True; 45 } 46 } 47 if ($need_save) 48 { 49 $config->save_repository(); 50 } 51 } 52 $this->manual_config = $config->config_data; 53 unset($config); 54 $this->wiki_id = (int) $this->manual_config['manual_wiki_id']; 55 56 // set a language given in the URL as session preference 57 if ($this->manual_config['manual_allow_anonymous'] && isset($_REQUEST['lang']) && preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_REQUEST['lang']) && 58 $_REQUEST['lang'] != $GLOBALS['egw_info']['user']['preferences']['common']['lang']) 59 { 60 $GLOBALS['egw']->preferences->add('common','lang',$_REQUEST['lang'],'session'); 61 $GLOBALS['egw_info']['user']['preferences']['common']['lang']=$_REQUEST['lang']; 62 } 63 $this->lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; 64 65 $this->bowiki($this->wiki_id); 66 67 if (!is_object($GLOBALS['egw']->html)) 68 { 69 $GLOBALS['egw']->html =& CreateObject('phpgwapi.html'); 70 } 71 $this->html =& $GLOBALS['egw']->html; 72 } 73 74 /** 75 * reimplemented that the we stay inside the manual app 76 */ 77 function viewURL($page, $lang='', $version='', $full = '') 78 { 79 $args = array( 80 'menuaction' => 'manual.uimanual.view', 81 ); 82 if ($lang || @$page['lang']) 83 { 84 $args['lang'] = $lang ? $lang : @$page['lang']; 85 if ($args['lang'] == $GLOBALS['egw_info']['user']['prefereces']['common']['lang']) unset($args['lang']); 86 } 87 if ($version) 88 { 89 $args['version'] = $version; 90 } 91 if ($full) 92 { 93 $args['full'] = 1; 94 } 95 // 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 96 return $GLOBALS['egw']->link('/index.php',$args).'&page='.urlencode(is_array($page) ? $page['name'] : $page); 97 } 98 99 /** 100 * reimplemented to disallow editing 101 */ 102 function editURL($page, $lang='',$version = '') 103 { 104 return False; 105 } 106 107 /** 108 * Show the page-header for the manual 109 * 110 * @param object/boolean $page sowikipage object or false 111 * @param string $title title of the search 112 */ 113 function header($page=false,$title='') 114 { 115 $GLOBALS['egw']->common->egw_header(); 116 117 // let the (existing) window pop up 118 $html .= "<script language=\"JavaScript\">\n\twindow.focus();\n</script>\n"; 119 $html .= '<div id="divMain">'."\n"; 120 121 if ($page && ($app = preg_match('/^Manual([A-Z]{1}[a-z]+)[A-Z]+/',$page->name,$matches) ? $matches[1] : false)) 122 { 123 $app_page =& $this->page('Manual'.$app); 124 if ($app_page->read() === False) $app = false; 125 } 126 $html .= '<form action="'.$GLOBALS['egw']->link('/index.php',array('menuaction'=>'manual.uimanual.search')).'" method="POST">'. 127 (isset($_GET['referer']) ? $this->html->image('phpgwapi','left-grey',lang('Back')) : 128 $this->html->a_href($this->html->image('phpgwapi','left',lang('Back')),'','','onclick="history.back(); return false;"')).' | '. 129 '<a href="'.htmlspecialchars($this->viewURL('Manual')).'">'.lang('Index').'</a> | '. 130 ($app ? '<a href="'.htmlspecialchars($this->viewUrl('Manual'.$app)).'">'.lang($app).'</a> | ' : ''). 131 '<input name="search" value="'.$this->html->htmlspecialchars($_REQUEST['search']).'" /> '. 132 '<input type="submit" name="go" value="'.$this->html->htmlspecialchars(lang('Search')).'" /></form>'."\n"; 133 $html .= "<hr />\n"; 134 135 if ($title) $html .= '<p><b>'.$titel."</b></p>\n"; 136 137 return $html; 138 } 139 140 /** 141 * Show the page-footer for the manual 142 * 143 * @param object/boolean $page sowikipage object or false 144 */ 145 function footer($page=false) 146 { 147 return "\n</div>\n"; 148 } 149 150 /** 151 * view a manual page 152 */ 153 function view() 154 { 155 if ($this->manual_config['manual_remote_egw_url']) 156 { 157 if (isset($_GET['referer'])) 158 { 159 $_SERVER['HTTP_REFERER'] = $_GET['referer']; 160 } 161 $referer = $GLOBALS['egw']->common->get_referer(); 162 $url = $this->manual_config['manual_remote_egw_url'].'/manual/index.php?referer='. 163 urlencode($this->manual_config['manual_remote_egw_url'].$referer). 164 (isset($_GET['page']) ? '&page='.urlencode($_GET['page']): ''). 165 '&lang='.urlencode($GLOBALS['egw_info']['user']['preferences']['common']['lang']); 166 //echo htmlentities($url); exit; 167 $GLOBALS['egw']->redirect($url); 168 } 169 if (isset($_GET['page'])) 170 { 171 $pages[] = $_GET['page']; 172 } 173 if (isset($_GET['referer']) || !isset($_GET['page'])) 174 { 175 // use the referer 176 $referer = $GLOBALS['egw']->common->get_referer('',$_GET['referer']); 177 list($referer,$query) = explode('?',$referer,2); 178 parse_str($query,$query); 179 //echo "<p>_GET[referer]='$_GET[referer]', referer='$referer', query=".print_r($query,True)."</p>\n"; 180 181 if (isset($query['menuaction']) && $query['menuaction']) 182 { 183 list($app,$class,$function) = explode('.',$query['menuaction']); 184 // for acl-preferences use the app-name from the query and acl as function 185 if ($app == 'preferences' && $class == 'uiaclprefs') 186 { 187 $app = $query['acl_app'] ? $query['acl_app'] : $_GET['acl_app']; 188 $function = 'acl'; 189 } 190 elseif ($app == 'preferences' && $class == 'uisettings') 191 { 192 $pages[] = 'Manual'.ucfirst($query['appname'] ? $query['appname'] : $_GET['appname']).'Preferences'; 193 } 194 elseif ($app == 'admin' && $class == 'uiconfig') 195 { 196 $app = $query['appname'] ? $query['appname'] : $_GET['appname']; 197 } 198 $pages[] = 'Manual'.ucfirst($app).ucfirst($class).ucfirst($function); 199 $pages[] = 'Manual'.ucfirst($app).ucfirst($function); 200 $pages[] = 'Manual'.ucfirst($app).ucfirst($class); 201 } 202 else 203 { 204 $parts = explode('/',$referer); 205 unset($parts[0]); 206 $app = array_shift($parts); 207 $file = str_replace('.php','',array_pop($parts)); 208 if (empty($file)) $file = 'index'; 209 // for preferences use the app-name from the query 210 if ($app == 'preferences' && $file == 'preferences') 211 { 212 $app = $query['appname'] ? $query['appname'] : $_GET['appname']; 213 } 214 $pages[] = 'Manual'.ucfirst($app).ucfirst($file); 215 } 216 $pages[] = 'Manual'.ucfirst($app); 217 } 218 // show the first page-hit 219 foreach($pages as $name) 220 { 221 $page =& $this->page($name); 222 if ($page->read() !== False) 223 { 224 break; 225 } 226 $page = false; 227 } 228 //echo "<p>page='".(is_object($page) ? $page->name : $page)."' from ".implode(', ',$pages)."</p>\n"; 229 if (!$page) 230 { 231 $html = '<p><b>'.lang("Page(s) %1 not found !!!",'<i>'.implode(', ',$pages).'</i>')."</b></p>\n"; 232 // show the Manual startpage 233 $page =& $this->page('Manual'); 234 if ($page->read() === false) $page = false; 235 } 236 $html = $this->header($page).$html; 237 $html .= $this->get($page,'',$this->wiki_id); 238 $html .= $this->footer(); 239 240 echo $html; 241 } 242 }
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 |