[ Index ] |
|
Code source de Dotclear 1.2.5 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2004 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 require_once dirname(__FILE__).'/class.filemanager.php'; 24 25 class imgmanager extends filemanager 26 { 27 var $p_url; 28 var $img_url; 29 30 function imgmanager($root_path,$base_path,$img_url,$p_url) 31 { 32 parent::filemanager($root_path,$base_path); 33 $this->p_url = $p_url; 34 $this->img_url = $img_url; 35 } 36 37 function getNavBar($link='<a href="%1$s">%2$s</a>') 38 { 39 40 $f = ''; 41 $res = '» '.sprintf($link,$this->p_url,__('images')); 42 43 if (file_exists($this->root.$this->base_path)) 44 { 45 $r = explode('/',$this->base_path); 46 for ($i=1; $i<count($r); $i++) { 47 $f .= '/'.$r[$i]; 48 $res .= '/'.sprintf($link,$this->p_url.'?p='.$f,$r[$i]); 49 } 50 } 51 return $res; 52 } 53 54 function listDir($k,$v,$link='<a href="%1$s">%2$s</a>') 55 { 56 if ($v['d'] && $v['jail'] && $v['r'] && $v['x'] && $k != '.' && $k != '..') { 57 return sprintf($link,$this->p_url.'?p='.$v['l'],$k); 58 } 59 } 60 61 function listImg($k,$v,$link='<a href="%1$s"><img src="%1$s" alt="%2$s" /></a>') 62 { 63 $type = $this->__getType($this->root.'/'.$this->base_path.'/'.$k); 64 $url = $this->__cleanPath($this->img_url.'/'.$this->base_path.'/'.$k); 65 66 if ($type == 'img' && $v['jail'] && $v['r']) { 67 return sprintf($link,$url,$k,$this->getThumb($k),addslashes($url)); 68 } 69 } 70 71 function getThumb($k=NULL,$absolute=false) 72 { 73 if ($k === NULL) { 74 $img = $this->base_path; 75 } else { 76 $img = $this->base_path.'/'.$k; 77 } 78 79 $root = !$absolute ? $this->img_url : $this->root; 80 81 $tn = $this->root.'/'.preg_replace('/^(.*)([.]\\w+)$/','$1.TN__$2',$img); 82 83 if (file_exists($tn)) { 84 return $this->__cleanPath($root.'/'.dirname($img).'/'.basename($tn)); 85 } else { 86 return false; 87 } 88 } 89 90 91 function isImg() 92 { 93 if ($this->getImgType() === false) { 94 return false; 95 } 96 97 return true; 98 } 99 100 function getImgType() 101 { 102 return images::type($this->root.$this->base_path); 103 } 104 } 105 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 21:40:15 2007 | par Balluche grâce à PHPXref 0.7 |