XPressME Integration Kit

Trac

source: branches/Ver3.0/xpressme_integration_kit/module_icon.php @ 753

Last change on this file since 753 was 742, checked in by toemon, 13 years ago

モジュールアイコン変更

File size: 1.7 KB
Line 
1<?php
2$xoopsOption['nocommon'] = true ;
3require '../../mainfile.php' ;
4$mydirpath = dirname(__FILE__);
5$mydirname = basename(dirname(__FILE__));
6$icon_cache_limit = 3600 ; // default 3600sec == 1hour
7
8session_cache_limiter('public');
9header("Expires: ".date('r',intval(time()/$icon_cache_limit)*$icon_cache_limit+$icon_cache_limit));
10header("Cache-Control: public, max-age=$icon_cache_limit");
11header("Last-Modified: ".date('r',intval(time()/$icon_cache_limit)*$icon_cache_limit));
12header("Content-type: image/png");
13
14// file name
15if( ! empty( $_GET['file'] ) ) {
16        $file_base = preg_replace( '/[^0-9a-z_]/' , '' , $_GET['file'] ) ;
17} else {
18        $file_base = 'module_icon' ;
19}
20
21// branches by cores
22if( defined( 'ICMS_TRUST_PATH' ) ) {
23        $draw_dirname = false ;
24        $file_base .= '_icms' ;
25} else if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
26        $draw_dirname = true ;
27        $file_base .= '_xcl' ;
28        $title = '('.$mydirname.')';
29        $px = ( 112 - 6 * strlen( $title ) ) ;
30        $py = 14;
31        $font = 3;
32
33} else {
34        $draw_dirname = true ;
35        $title = $mydirname;
36        $px = ( 92 - 6 * strlen( $title ) ) / 2 ;
37        $py = 34;
38        $font = 3;
39}
40
41// icon files must be PNG
42$file = $file_base . '.png' ;
43
44// custom icon
45if( file_exists( $mydirpath.'/'.$file ) ) {
46        $draw_dirname = false ;
47        $icon_fullpath = $mydirpath.'/module_icon.png' ;
48} else {
49        $icon_fullpath = dirname(__FILE__).'/images/'.$file ;
50}
51
52if( $draw_dirname && function_exists( 'imagecreatefrompng' ) && function_exists( 'imagecolorallocate' ) && function_exists( 'imagestring' ) && function_exists( 'imagepng' ) ) {
53
54        $im = imagecreatefrompng( $icon_fullpath ) ;
55
56        $color = imagecolorallocate( $im , 0 , 0 , 0 ) ; // black
57        imagestring( $im , $font , $px , $py , $title , $color ) ;
58        imagepng( $im ) ;
59        imagedestroy( $im ) ;
60
61} else {
62
63        readfile( $icon_fullpath ) ;
64
65}
66
67?>
Note: See TracBrowser for help on using the repository browser.