[3594] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * ProjectManager - Adminstration |
---|
| 4 | * |
---|
| 5 | * @link http://www.egroupware.org |
---|
| 6 | * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
| 7 | * @package projectmanager |
---|
| 8 | * @copyright (c) 2005 by Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
| 9 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
---|
| 10 | * @version $Id: class.admin.inc.php 23852 2007-05-09 16:29:32Z lkneschke $ |
---|
| 11 | */ |
---|
| 12 | |
---|
| 13 | require_once(PHPGW_INCLUDE_ROOT.'/etemplate/inc/class.uietemplate.inc.php'); |
---|
| 14 | |
---|
| 15 | /** |
---|
| 16 | * ProjectManager: Administration |
---|
| 17 | */ |
---|
| 18 | class admin |
---|
| 19 | { |
---|
| 20 | /** |
---|
| 21 | * @var array $public_functions Functions to call via menuaction |
---|
| 22 | */ |
---|
| 23 | var $public_functions = array( |
---|
| 24 | 'config' => true, |
---|
| 25 | ); |
---|
| 26 | var $accounting_types; |
---|
| 27 | var $duration_units; |
---|
| 28 | var $fonts; |
---|
| 29 | |
---|
| 30 | /** |
---|
| 31 | * Constructor, calls the constructor of the extended class |
---|
| 32 | */ |
---|
| 33 | function admin() |
---|
| 34 | { |
---|
| 35 | if (!$GLOBALS['phpgw_info']['user']['apps']['admin']) |
---|
| 36 | { |
---|
| 37 | $GLOBALS['phpgw']->common->redirect_link('/index.php',array( |
---|
| 38 | 'menuaction' => 'projectmanager.uiprojectmanger.index', |
---|
| 39 | 'msg' => lang('Permission denied !!!'), |
---|
| 40 | )); |
---|
| 41 | } |
---|
| 42 | $this->config =& CreateObject('phpgwapi.config','projectmanager'); |
---|
| 43 | $this->config->read_repository(); |
---|
| 44 | |
---|
| 45 | $this->accounting_types = array( |
---|
| 46 | 'status' => lang('No accounting, only status'), |
---|
| 47 | 'times' => lang('No accounting, only times and status'), |
---|
| 48 | 'budget' => lang('Budget (no pricelist)'), |
---|
| 49 | 'pricelist' => lang('Budget and pricelist'), |
---|
| 50 | ); |
---|
| 51 | $this->duration_units = array( |
---|
| 52 | 'd' => 'days', |
---|
| 53 | 'h' => 'hours', |
---|
| 54 | ); |
---|
| 55 | $this->fonts = $this->get_fonts(); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | /** |
---|
| 59 | * Edit the site configuration |
---|
| 60 | * |
---|
| 61 | * @param array $content=null |
---|
| 62 | */ |
---|
| 63 | function config($content=null) |
---|
| 64 | { |
---|
| 65 | $tpl =& new etemplate('projectmanager.config'); |
---|
| 66 | |
---|
| 67 | if ($content['save'] || $content['apply']) |
---|
| 68 | { |
---|
| 69 | $content['GANTT_FONT_FILE'] = $this->get_font_file($content['GANTT_FONT'],$content['GANTT_STYLE']); |
---|
| 70 | foreach(array('duration_units','hours_per_workday','accounting_types','allow_change_workingtimes', |
---|
| 71 | 'GANTT_FONT','LANGUAGE_CHARSET','GANTT_STYLE','GANTT_CHAR_ENCODE','GANTT_FONT_FILE') as $name) |
---|
| 72 | { |
---|
| 73 | $this->config->config_data[$name] = $content[$name]; |
---|
| 74 | } |
---|
| 75 | $this->config->save_repository(); |
---|
| 76 | $msg = lang('Site configuration saved'); |
---|
| 77 | } |
---|
| 78 | if ($content['cancel'] || $content['save']) |
---|
| 79 | { |
---|
| 80 | $tpl->location(array( |
---|
| 81 | 'menuaction' => 'projectmanager.uiprojectmanager.index', |
---|
| 82 | 'msg' => $msg, |
---|
| 83 | )); |
---|
| 84 | } |
---|
| 85 | include_once(PHPGW_INCLUDE_ROOT.'/projectmanager/inc/class.ganttchart.inc.php'); |
---|
| 86 | |
---|
| 87 | $content = $this->config->config_data; |
---|
| 88 | if (!$content['duration_units']) $content['duration_units'] = array_keys($this->duration_units); |
---|
| 89 | if (!$content['hours_per_workday']) $content['hours_per_workday'] = 8; |
---|
| 90 | if (!$content['accounting_types']) $content['accounting_types'] = array_keys($this->accounting_types); |
---|
| 91 | |
---|
| 92 | // Ganttchart config |
---|
| 93 | $content['jpg_msg'] = ganttchart::msg_install_new_jpgraph(); |
---|
| 94 | if (!$content['GANTT_FONT']) $content['GANTT_FONT'] = GANTT_FONT; |
---|
| 95 | if (!$content['LANGUAGE_CHARSET']) $content['LANGUAGE_CHARSET'] = LANGUAGE_CHARSET; |
---|
| 96 | if (!$content['GANTT_STYLE']) $content['GANTT_STYLE'] = GANTT_STYLE; |
---|
| 97 | if (!isset($content['GANTT_CHAR_ENCODE'])) $content['GANTT_CHAR_ENCODE'] = GANTT_CHAR_ENCODE; |
---|
| 98 | if (is_readable(TTF_DIR.$content['GANTT_FONT_FILE'])) |
---|
| 99 | { |
---|
| 100 | $content['font_msg'] = TTF_DIR.$content['GANTT_FONT_FILE']; |
---|
| 101 | $content['font_msg_class'] = ''; |
---|
| 102 | } |
---|
| 103 | else |
---|
| 104 | { |
---|
| 105 | $content['font_msg'] = lang("Fontfile '%1' not found!!!",$content['GANTT_FONT_FILE']); |
---|
| 106 | $content['font_msg_class'] = 'redItalic'; |
---|
| 107 | } |
---|
| 108 | $content['msg'] = $msg; |
---|
| 109 | |
---|
| 110 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('projectmanager').' - '.lang('Site configuration'); |
---|
| 111 | $tpl->exec('projectmanager.admin.config',$content,array( |
---|
| 112 | 'duration_units' => $this->duration_units, |
---|
| 113 | 'accounting_types' => $this->accounting_types, |
---|
| 114 | 'allow_change_workingtimes' => array('no','yes'), |
---|
| 115 | 'GANTT_FONT' => $this->get_fonts(), |
---|
| 116 | 'GANTT_STYLE' => array( |
---|
| 117 | FS_NORMAL => lang('normal'), |
---|
| 118 | FS_BOLD => lang('bold'), |
---|
| 119 | FS_ITALIC => lang('italic'), |
---|
| 120 | FS_BOLDITALIC => lang('bold').' & '.lang('italic'), |
---|
| 121 | ), |
---|
| 122 | 'GANTT_CHAR_ENCODE' => array( |
---|
| 123 | 1 => 'yes', |
---|
| 124 | '' => 'No', |
---|
| 125 | ) |
---|
| 126 | )); |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | /** |
---|
| 130 | * Get font id - name pairs the installed jpgraph understands |
---|
| 131 | * |
---|
| 132 | * @return array |
---|
| 133 | */ |
---|
| 134 | function get_fonts() |
---|
| 135 | { |
---|
| 136 | $fonts = array(); |
---|
| 137 | foreach(array( |
---|
| 138 | // MS web iniative |
---|
| 139 | FF_ARIAL => 'Arial (MS)', |
---|
| 140 | FF_COMIC => 'Comic (MS)', |
---|
| 141 | FF_COURIER => 'Courier (MS)', |
---|
| 142 | FF_GEORGIA => 'Georgia (MS)', |
---|
| 143 | FF_TIMES => 'Times (MS)', |
---|
| 144 | FF_TREBUCHE => 'Trebuche (MS)', |
---|
| 145 | FF_VERDANA => 'Verdana (MS)', |
---|
| 146 | |
---|
| 147 | // Gnome Vera font |
---|
| 148 | // Available from http://www.gnome.org/fonts/ |
---|
| 149 | FF_VERA => 'Vera (Gnome)', |
---|
| 150 | FF_VERAMONO => 'Veramono (Gnome)', |
---|
| 151 | FF_VERASERIF => 'Veraserif (Gnome)', |
---|
| 152 | |
---|
| 153 | // Chinese font |
---|
| 154 | FF_SIMSUN => 'Simsun (Chinese)', |
---|
| 155 | FF_CHINESE => 'Chinese (Chinese)', |
---|
| 156 | FF_BIG5 => 'Big5 (Chinese)', |
---|
| 157 | |
---|
| 158 | // Japanese font |
---|
| 159 | FF_MINCHO => 'Mincho (Japanese)', |
---|
| 160 | FF_PMINCHO => 'PMincho (Japanese)', |
---|
| 161 | FF_GOTHIC => 'Gothic (Japanese)', |
---|
| 162 | FF_PGOTHIC => 'PGothic (Japanese)', |
---|
| 163 | |
---|
| 164 | // Hebrew fonts |
---|
| 165 | FF_DAVID => 'David (Hebrew)', |
---|
| 166 | FF_MIRIAM => 'Miriam (Hebrew)', |
---|
| 167 | FF_AHRON => 'Ahron (Hebrew)', |
---|
| 168 | |
---|
| 169 | // Extra fonts |
---|
| 170 | // Download fonts from |
---|
| 171 | // http://www.webfontlist.com |
---|
| 172 | // http://www.webpagepublicity.com/free-fonts.html |
---|
| 173 | |
---|
| 174 | FF_SPEEDO => 'Speedo', // This font is also known as Bauer (Used for gauge fascia) |
---|
| 175 | FF_DIGITAL => 'Digital', // Digital readout font |
---|
| 176 | FF_COMPUTER => 'Computer', // The classic computer font |
---|
| 177 | FF_CALCULATOR=> 'Calculator', // Triad font |
---|
| 178 | ) as $font => $label) |
---|
| 179 | { |
---|
| 180 | if (is_int($font)) |
---|
| 181 | { |
---|
| 182 | $fonts[$font] = $label; |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | return $fonts; |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | /** |
---|
| 189 | * Get the path of the given font or an error-message |
---|
| 190 | * |
---|
| 191 | * @param int $font |
---|
| 192 | * @param int $style |
---|
| 193 | * @return string |
---|
| 194 | */ |
---|
| 195 | function get_font_file($font,$style) |
---|
| 196 | { |
---|
| 197 | if(file_exists(PHPGW_SERVER_ROOT . '/../jpgraph/src/jpg-config.inc.php')) |
---|
| 198 | { |
---|
| 199 | //echo "including jpg-config.inc.php"; |
---|
| 200 | require_once(PHPGW_SERVER_ROOT . '/../jpgraph/src/jpg-config.inc.php'); |
---|
| 201 | if(file_exists(PHPGW_SERVER_ROOT . '/../jpgraph/src/jpgraph_ttf.inc.php')) |
---|
| 202 | { |
---|
| 203 | //echo "including jpgraph_ttf.inc.php"; |
---|
| 204 | require_once(PHPGW_SERVER_ROOT . '/../jpgraph/src/jpgraph_ttf.inc.php'); |
---|
| 205 | } |
---|
| 206 | } |
---|
| 207 | elseif(file_exists(PHPGW_SERVER_ROOT . '/../jpgraph/src/jpg-config.inc')) |
---|
| 208 | { |
---|
| 209 | //echo "including jpg-config.inc"; |
---|
| 210 | require_once(PHPGW_SERVER_ROOT . '/../jpgraph/src/jpg-config.inc'); |
---|
| 211 | } |
---|
| 212 | else |
---|
| 213 | { |
---|
| 214 | //echo "falling back to vera"; |
---|
| 215 | return 'Vera.ttf'; |
---|
| 216 | } |
---|
| 217 | if (!defined('FF_ARIAL')) |
---|
| 218 | { |
---|
| 219 | DEFINE("FF_COURIER",10); |
---|
| 220 | DEFINE("FF_VERDANA",11); |
---|
| 221 | DEFINE("FF_TIMES",12); |
---|
| 222 | DEFINE("FF_COMIC",14); |
---|
| 223 | DEFINE("FF_ARIAL",15); |
---|
| 224 | DEFINE("FF_GEORGIA",16); |
---|
| 225 | DEFINE("FF_TREBUCHE",17); |
---|
| 226 | |
---|
| 227 | // Gnome Vera font |
---|
| 228 | // Available from http://www.gnome.org/fonts/ |
---|
| 229 | DEFINE("FF_VERA",18); |
---|
| 230 | DEFINE("FF_VERAMONO",19); |
---|
| 231 | DEFINE("FF_VERASERIF",20); |
---|
| 232 | |
---|
| 233 | // Chinese font |
---|
| 234 | DEFINE("FF_SIMSUN",30); |
---|
| 235 | DEFINE("FF_CHINESE",31); |
---|
| 236 | DEFINE("FF_BIG5",31); |
---|
| 237 | |
---|
| 238 | // Japanese font |
---|
| 239 | DEFINE("FF_MINCHO",40); |
---|
| 240 | DEFINE("FF_PMINCHO",41); |
---|
| 241 | DEFINE("FF_GOTHIC",42); |
---|
| 242 | DEFINE("FF_PGOTHIC",43); |
---|
| 243 | |
---|
| 244 | // TTF Font styles |
---|
| 245 | DEFINE("FS_NORMAL",9001); |
---|
| 246 | DEFINE("FS_BOLD",9002); |
---|
| 247 | DEFINE("FS_ITALIC",9003); |
---|
| 248 | DEFINE("FS_BOLDIT",9004); |
---|
| 249 | DEFINE("FS_BOLDITALIC",9004); |
---|
| 250 | } |
---|
| 251 | // File names for available fonts from jpgraph_ttf |
---|
| 252 | $font_files=array( |
---|
| 253 | FF_COURIER => array(FS_NORMAL =>'cour.ttf', |
---|
| 254 | FS_BOLD =>'courbd.ttf', |
---|
| 255 | FS_ITALIC =>'couri.ttf', |
---|
| 256 | FS_BOLDITALIC =>'courbi.ttf' ), |
---|
| 257 | FF_GEORGIA => array(FS_NORMAL =>'georgia.ttf', |
---|
| 258 | FS_BOLD =>'georgiab.ttf', |
---|
| 259 | FS_ITALIC =>'georgiai.ttf', |
---|
| 260 | FS_BOLDITALIC =>'' ), |
---|
| 261 | FF_TREBUCHE =>array(FS_NORMAL =>'trebuc.ttf', |
---|
| 262 | FS_BOLD =>'trebucbd.ttf', |
---|
| 263 | FS_ITALIC =>'trebucit.ttf', |
---|
| 264 | FS_BOLDITALIC =>'trebucbi.ttf' ), |
---|
| 265 | FF_VERDANA => array(FS_NORMAL =>'verdana.ttf', |
---|
| 266 | FS_BOLD =>'verdanab.ttf', |
---|
| 267 | FS_ITALIC =>'verdanai.ttf', |
---|
| 268 | FS_BOLDITALIC =>'' ), |
---|
| 269 | FF_TIMES => array(FS_NORMAL =>'times.ttf', |
---|
| 270 | FS_BOLD =>'timesbd.ttf', |
---|
| 271 | FS_ITALIC =>'timesi.ttf', |
---|
| 272 | FS_BOLDITALIC =>'timesbi.ttf' ), |
---|
| 273 | FF_COMIC => array(FS_NORMAL =>'comic.ttf', |
---|
| 274 | FS_BOLD =>'comicbd.ttf', |
---|
| 275 | FS_ITALIC =>'', |
---|
| 276 | FS_BOLDITALIC =>'' ), |
---|
| 277 | FF_ARIAL => array(FS_NORMAL =>'arial.ttf', |
---|
| 278 | FS_BOLD =>'arialbd.ttf', |
---|
| 279 | FS_ITALIC =>'ariali.ttf', |
---|
| 280 | FS_BOLDITALIC =>'arialbi.ttf' ) , |
---|
| 281 | FF_VERA => array(FS_NORMAL =>'Vera.ttf', |
---|
| 282 | FS_BOLD =>'VeraBd.ttf', |
---|
| 283 | FS_ITALIC =>'VeraIt.ttf', |
---|
| 284 | FS_BOLDITALIC =>'VeraBI.ttf' ), |
---|
| 285 | FF_VERAMONO => array(FS_NORMAL =>'VeraMono.ttf', |
---|
| 286 | FS_BOLD =>'VeraMoBd.ttf', |
---|
| 287 | FS_ITALIC =>'VeraMoIt.ttf', |
---|
| 288 | FS_BOLDITALIC =>'VeraMoBI.ttf' ), |
---|
| 289 | FF_VERASERIF=> array(FS_NORMAL =>'VeraSe.ttf', |
---|
| 290 | FS_BOLD =>'VeraSeBd.ttf', |
---|
| 291 | FS_ITALIC =>'', |
---|
| 292 | FS_BOLDITALIC =>'' ) , |
---|
| 293 | |
---|
| 294 | /* Chinese fonts */ |
---|
| 295 | FF_SIMSUN => array(FS_NORMAL =>'simsun.ttc', |
---|
| 296 | FS_BOLD =>'simhei.ttf', |
---|
| 297 | FS_ITALIC =>'', |
---|
| 298 | FS_BOLDITALIC =>'' ), |
---|
| 299 | FF_CHINESE => array(FS_NORMAL =>CHINESE_TTF_FONT, |
---|
| 300 | FS_BOLD =>'', |
---|
| 301 | FS_ITALIC =>'', |
---|
| 302 | FS_BOLDITALIC =>'' ), |
---|
| 303 | |
---|
| 304 | /* Japanese fonts */ |
---|
| 305 | FF_MINCHO => array(FS_NORMAL =>MINCHO_TTF_FONT, |
---|
| 306 | FS_BOLD =>'', |
---|
| 307 | FS_ITALIC =>'', |
---|
| 308 | FS_BOLDITALIC =>'' ), |
---|
| 309 | FF_PMINCHO => array(FS_NORMAL =>PMINCHO_TTF_FONT, |
---|
| 310 | FS_BOLD =>'', |
---|
| 311 | FS_ITALIC =>'', |
---|
| 312 | FS_BOLDITALIC =>'' ), |
---|
| 313 | FF_GOTHIC => array(FS_NORMAL =>GOTHIC_TTF_FONT, |
---|
| 314 | FS_BOLD =>'', |
---|
| 315 | FS_ITALIC =>'', |
---|
| 316 | FS_BOLDITALIC =>'' ), |
---|
| 317 | FF_PGOTHIC => array(FS_NORMAL =>PGOTHIC_TTF_FONT, |
---|
| 318 | FS_BOLD =>'', |
---|
| 319 | FS_ITALIC =>'', |
---|
| 320 | FS_BOLDITALIC =>'' ), |
---|
| 321 | FF_MINCHO => array(FS_NORMAL =>PMINCHO_TTF_FONT, |
---|
| 322 | FS_BOLD =>'', |
---|
| 323 | FS_ITALIC =>'', |
---|
| 324 | FS_BOLDITALIC =>'' ), |
---|
| 325 | |
---|
| 326 | /* Hebrew fonts */ |
---|
| 327 | FF_DAVID => array(FS_NORMAL =>'DAVIDNEW.TTF', |
---|
| 328 | FS_BOLD =>'', |
---|
| 329 | FS_ITALIC =>'', |
---|
| 330 | FS_BOLDITALIC =>'' ), |
---|
| 331 | |
---|
| 332 | FF_MIRIAM => array(FS_NORMAL =>'MRIAMY.TTF', |
---|
| 333 | FS_BOLD =>'', |
---|
| 334 | FS_ITALIC =>'', |
---|
| 335 | FS_BOLDITALIC =>'' ), |
---|
| 336 | |
---|
| 337 | FF_AHRON => array(FS_NORMAL =>'ahronbd.ttf', |
---|
| 338 | FS_BOLD =>'', |
---|
| 339 | FS_ITALIC =>'', |
---|
| 340 | FS_BOLDITALIC =>'' ), |
---|
| 341 | |
---|
| 342 | /* Misc fonts */ |
---|
| 343 | FF_DIGITAL => array(FS_NORMAL =>'DIGIRU__.TTF', |
---|
| 344 | FS_BOLD =>'Digirtu_.ttf', |
---|
| 345 | FS_ITALIC =>'Digir___.ttf', |
---|
| 346 | FS_BOLDITALIC =>'DIGIRT__.TTF' ), |
---|
| 347 | FF_SPEEDO => array(FS_NORMAL =>'Speedo.ttf', |
---|
| 348 | FS_BOLD =>'', |
---|
| 349 | FS_ITALIC =>'', |
---|
| 350 | FS_BOLDITALIC =>'' ), |
---|
| 351 | FF_COMPUTER => array(FS_NORMAL =>'COMPUTER.TTF', |
---|
| 352 | FS_BOLD =>'', |
---|
| 353 | FS_ITALIC =>'', |
---|
| 354 | FS_BOLDITALIC =>'' ), |
---|
| 355 | FF_CALCULATOR => array(FS_NORMAL =>'Triad_xs.ttf', |
---|
| 356 | FS_BOLD =>'', |
---|
| 357 | FS_ITALIC =>'', |
---|
| 358 | FS_BOLDITALIC =>'' ), |
---|
| 359 | ); |
---|
| 360 | return $font_files[$font][$style]; |
---|
| 361 | } |
---|
| 362 | } |
---|