rel_path = $infos['path']; } elseif (!empty($infos['representative_ext'])) { $pi = pathinfo($infos['path']); $file_wo_ext = get_filename_wo_extension($pi['basename']); $this->rel_path = $pi['dirname'].'/pwg_representative/' .$file_wo_ext.'.'.$infos['representative_ext']; } else { $this->rel_path = get_themeconf('mime_icon_dir').strtolower($ext).'.png'; } $this->coi = @$infos['coi']; if (isset($infos['width']) && isset($infos['height'])) { $this->size = array($infos['width'], $infos['height']); } } function get_size() { if ($this->size == null) not_implemented(); // get size from file return $this->size; } } final class DerivativeImage { public $src_image; private $params; private $rel_path, $rel_url; function __construct($type, $infos) { $this->src_image = new SrcImage($infos); self::build($type, $src_image, $this->rel_path, $this->rel_url, $this->params); } static function thumb_url($infos) { $src_image = new SrcImage($infos); self::build(IMG_THUMB, $src_image, $rel_path, $rel_url); //die($rel_url); return get_root_url().$rel_url; } static function url($type, $infos) { $src_image = new SrcImage($infos); self::build($type, $src_image, $rel_path, $rel_url); return get_root_url().$rel_url; } private static function build($type, $src, &$rel_path, &$rel_url, &$params = null) { if (is_string($type)) { $params = ImageStdParams::get_by_type($type); } else { $type = IMG_CUSTOM; } // todo check if we should not downgrade to a different type because // original file is too small ... // we are using a mime type icon ... // etc... $tokens=array(); $tokens[] = substr($type,0,2); if (!empty($src->coi)) { $tokens[] = 'ci'.$src->coi; } if ($type==IMG_CUSTOM) { $params->add_url_tokens($tokens); } $loc = $src->rel_path; if (substr_compare($loc, '../', 0, 3)==0) { $loc = substr($loc, 3); } $loc = substr_replace($loc, '-'.implode('_', $tokens), strrpos($loc, '.'), 0 ); $rel_path = PWG_DERIVATIVE_DIR.$loc; global $conf; $url_style=$conf['derivative_url_style']; if (!$url_style) { $mtime = @filemtime(PHPWG_ROOT_PATH.$rel_path); if ($mtime===false) { $url_style = 2; } else { $url_style = 1; } } if ($url_style == 2) { $rel_url = 'i'; if ($conf['php_extension_in_urls']) $rel_url .= '.php'; if (!$conf['question_mark_in_urls']) $rel_url.= '?'; $rel_url .= $loc; } else { $rel_url = $rel_path; } } /* returns the size of the derivative image*/ function get_size() { return $this->params->compute_final_size($this->src_image->get_size(), $this->src_image->coi); } } ?>