2021-09-08 22:53:13 +00:00
|
|
|
<?php
|
2021-09-08 23:02:10 +00:00
|
|
|
/**
|
|
|
|
* @brief noodles, a for Dotclear 2
|
|
|
|
*
|
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage \u
|
|
|
|
*
|
|
|
|
* @author JC Denis
|
|
|
|
*
|
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-09-08 22:53:13 +00:00
|
|
|
|
|
|
|
class noodlesLibImagePath
|
|
|
|
{
|
2021-09-08 23:02:10 +00:00
|
|
|
public static $version = '1.1';
|
2021-09-08 22:53:13 +00:00
|
|
|
|
2021-09-08 23:02:10 +00:00
|
|
|
public static function getArray($core,$m='')
|
|
|
|
{
|
|
|
|
if (!$core->plugins->moduleExists($m)
|
|
|
|
|| !$core->url->getBase($m.'module')) {
|
|
|
|
return array(
|
|
|
|
'theme'=>array('dir'=>null,'url'=>null),
|
|
|
|
'public'=>array('dir'=>null,'url'=>null),
|
|
|
|
'module'=>array('dir'=>null,'url'=>null),
|
|
|
|
);
|
|
|
|
}
|
2021-09-08 22:53:13 +00:00
|
|
|
|
2021-09-08 23:02:10 +00:00
|
|
|
return array(
|
|
|
|
'theme' => array(
|
|
|
|
'dir' => $core->blog->themes_path.'/'.$core->blog->settings->system->theme.'/img/'.$m.'-default-image.png',
|
|
|
|
'url' => $core->blog->settings->system->themes_url.$core->blog->settings->system->theme.'/img/'.$m.'-default-image.png'
|
|
|
|
),
|
|
|
|
'public' => array(
|
|
|
|
'dir' => $core->blog->public_path.'/'.$m.'-default-image.png',
|
|
|
|
'url' => $core->blog->host.path::clean($core->blog->settings->system->public_url).'/'.$m.'-default-image.png'
|
|
|
|
),
|
|
|
|
'module' => array(
|
|
|
|
'dir' => $core->plugins->moduleRoot($m).'/default-templates/img/'.$m.'-default-image.png',
|
|
|
|
'url' => $core->blog->url.$core->url->getBase($m.'module').'/img/'.$m.'-default-image.png'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2021-09-08 22:53:13 +00:00
|
|
|
|
2021-09-08 23:02:10 +00:00
|
|
|
public static function getUrl($core,$m='')
|
|
|
|
{
|
|
|
|
$files = self::getArray($core,$m);
|
|
|
|
foreach($files as $k => $file) {
|
|
|
|
if (file_exists($files[$k]['dir']))
|
|
|
|
return $files[$k]['url'];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2021-09-08 22:53:13 +00:00
|
|
|
|
2021-09-08 23:02:10 +00:00
|
|
|
public static function getPath($core,$m='')
|
|
|
|
{
|
|
|
|
$files = self::getArray($core,$m);
|
|
|
|
foreach($files as $k => $file) {
|
|
|
|
if (file_exists($files[$k]['dir']))
|
|
|
|
return $files[$k]['dir'];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2021-09-08 22:53:13 +00:00
|
|
|
|
2021-09-08 23:02:10 +00:00
|
|
|
public static function getSize($core,$m='')
|
|
|
|
{
|
|
|
|
if (!($img = self::getPath($core,$m)))
|
|
|
|
return array('w'=>16,'h'=>16);
|
|
|
|
else {
|
|
|
|
$info = getimagesize($img);
|
|
|
|
return array('w'=>$info[0],'h'=>floor($info[1] /3));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|