Dotclear

source: plugins/rateIt/inc/lib.image.path.php @ 1865

Revision 1865, 2.1 KB checked in by JcDenis, 13 years ago (diff)

rateIt 0.9.7:

  • Added entryFirstImage to wigdet
  • Fixed bug with date sorting on widget
  • Fixed bug with plugin ativityReport
  • Removed about tabs and fixed typo
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of rateIt, a plugin for Dotclear 2.
4#
5# Copyright (c) 2009 JC Denis and contributors
6# jcdenis@gdwd.com
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11# -- END LICENSE BLOCK ------------------------------------
12
13class libImagePath
14{
15     public static $version = '1.0';
16
17     public static function getArray($core,$m='')
18     {
19          if (!$core->plugins->moduleExists($m)
20           || !$core->url->getBase($m.'module')) {
21               return array(
22                    'theme'=>array('dir'=>null,'url'=>null),
23                    'public'=>array('dir'=>null,'url'=>null),
24                    'module'=>array('dir'=>null,'url'=>null),
25               );
26          }
27
28          return array(
29               'theme' => array(
30                    'dir' => $core->blog->themes_path.'/'.$core->blog->settings->theme.'/img/'.$m.'-default-image.png',
31                    'url' => $core->blog->settings->themes_url.$core->blog->settings->theme.'/img/'.$m.'-default-image.png'
32               ),
33               'public' => array(
34                    'dir' => $core->blog->public_path.'/'.$m.'-default-image.png',
35                    'url' => $core->blog->host.path::clean($core->blog->settings->public_url).'/'.$m.'-default-image.png'
36               ),
37               'module' => array(
38                    'dir' => $core->plugins->moduleRoot($m).'/default-templates/img/'.$m.'-default-image.png',
39                    'url' => $core->blog->url.$core->url->getBase($m.'module').'/img/'.$m.'-default-image.png'
40               )
41          );
42     }
43
44     public static function getUrl($core,$m='')
45     {
46          $files = self::getArray($core,$m);
47          foreach($files as $k => $file) {
48               if (file_exists($files[$k]['dir']))
49                    return $files[$k]['url'];
50          }
51          return null;
52     }
53
54     public static function getPath($core,$m='')
55     {
56          $files = self::getArray($core,$m);
57          foreach($files as $k => $file) {
58               if (file_exists($files[$k]['dir']))
59                    return $files[$k]['dir'];
60          }
61          return null;
62     }
63
64     public static function getSize($core,$m='')
65     {
66          if (!($img = self::getPath($core,$m)))
67               return array('w'=>16,'h'=>16);
68          else {
69               $info = getimagesize($img);
70               return array('w'=>$info[0],'h'=>floor($info[1] /3));
71          }
72     }
73}
74?>
Note: See TracBrowser for help on using the repository browser.

Sites map