clean up code

This commit is contained in:
Jean-Christian Denis 2021-09-09 09:12:31 +02:00
parent 7b63f7f111
commit e78f1507a8
10 changed files with 344 additions and 296 deletions

View file

@ -11,30 +11,24 @@
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')){return;}
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
$new_version = $core->plugins->moduleInfo('noodles', 'version');
$old_version = $core->getVersion('noodles');
if (version_compare($old_version,$new_version,'>=')) return;
try
{
if (version_compare(DC_VERSION,'2.2-beta','<'))
{
throw new Exception('noodles requires Dotclear 2.2');
if (version_compare($old_version, $new_version, '>=')) {
return null;
}
try {
$core->blog->settings->addNamespace('noodles');
$core->blog->settings->noodles->put('noodles_active',false,'boolean','Enable extension',false,true);
$core->blog->settings->noodles->put(
'noodles_active', false, 'boolean', 'Enable extension', false, true
);
$core->setVersion('noodles', $new_version);
return true;
}
catch (Exception $e)
{
} catch (Exception $e) {
$core->error->add($e->getMessage());
}
return false;

View file

@ -11,16 +11,24 @@
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')){return;}
global $__autoload, $core;
if (!defined('DC_RC_PATH')) {
return null;
}
$__autoload['noodlesImg'] = dirname(__FILE__) . '/inc/lib.noodles.img.php';
$__autoload['noodlesLibImagePath'] = dirname(__FILE__) . '/inc/lib.image.path.php';
$core->blog->settings->addNamespace('noodles');
$core->url->register('noodlesmodule','noodles','^noodles/(.+)$',
array('urlNoodles','noodles'));
$core->url->register('noodlesservice','noodle','^noodle/$',
array('urlNoodles','service'));
$core->url->register(
'noodlesmodule',
'noodles',
'^noodles/(.+)$',
['urlNoodles', 'noodles']
);
$core->url->register(
'noodlesservice',
'noodle',
'^noodle/$',
['urlNoodles', 'service']
);

View file

@ -11,30 +11,35 @@
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')){return;}
if (!defined('DC_RC_PATH')) {
return null;
}
if (!$core->blog->settings->noodles->noodles_active) return;
if (!$core->blog->settings->noodles->noodles_active) {
return null;
}
include dirname(__FILE__) . '/inc/_default_noodles.php';
require_once dirname(__FILE__) . '/inc/_noodles_functions.php';
$core->addBehavior('publicHeadContent',
array('publicNoodles','publicHeadContent'));
$core->addBehavior('publicHeadContent', ['publicNoodles', 'publicHeadContent']);
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__) . '/default-templates');
global $__noodles;
$__noodles = noodles::decode($core->blog->settings->noodles->noodles_object);
if ($__noodles->isEmpty())
if ($__noodles->isEmpty()) {
$__noodles = $__default_noodles;
}
//$GLOBALS['__noodles'] =& $__noodles;
foreach($__noodles->noodles() AS $noodle) {
if ($noodle->active && $noodle->hasPhpCallback())
if ($noodle->active && $noodle->hasPhpCallback()) {
$noodle->phpCallback($core);
}
}
class publicNoodles
{
@ -45,26 +50,25 @@ class publicNoodles
$css = "\n";
$targets = array();
foreach($__noodles->noodles() AS $noodle) {
if (!$noodle->active || !$noodle->hasJsCallback()) continue;
if (!$noodle->active || !$noodle->hasJsCallback()) {
continue;
}
$css .= '.noodles-' . $noodle->id() . '{' . $noodle->css . '}' . "\n";
$targets[] =
' $(\'' . html::escapeJS($noodle->target) . '\').noodles({' .
'imgId:\'' . html::escapeJS($noodle->id()) . '\',' .
'imgPlace:\'' . html::escapeJS($noodle->place) . '\'' .
'});';
}
if (empty($targets)) return;
if (empty($targets)) {
return null;
}
echo
"\n<!-- CSS for noodles --> \n" .
'<style type="text/css">' . html::escapeHTML($css) . '</style>' .
"\n<!-- JS for noodles --> \n" .
"<script type=\"text/javascript\" src=\"".
$core->blog->url.$core->url->getBase('noodlesmodule')."/js/jquery.noodles.js\"></script> \n".
dcUtils::jsLoad($core->blog->url . $core->url->getBase('noodlesmodule') . "/js/jquery.noodles.js") .
"<script type=\"text/javascript\"> \n" .
"//<![CDATA[\n" .
" \$(function(){if(!document.getElementById){return;} \n" .
@ -90,41 +94,33 @@ class urlNoodles extends dcUrlHandlers
$i = !empty($_POST['noodleId']) ? $_POST['noodleId'] : null;
$c = !empty($_POST['noodleContent']) ? $_POST['noodleContent'] : null;
if (!$core->blog->settings->noodles->noodles_active)
{
if (!$core->blog->settings->noodles->noodles_active) {
$rsp->status = 'failed';
$rsp->message(__('noodles is disabled on this blog'));
echo $rsp->toXML(1);
return false;
}
if ($i === null || $c === null)
{
if ($i === null || $c === null) {
$rsp->status = 'failed';
$rsp->message(__('noodles failed because of missing informations'));
echo $rsp->toXML(1);
return false;
}
try
{
try {
$__noodles = noodles::decode($core->blog->settings->noodles->noodles_object);
if ($__noodles->isEmpty())
{
if ($__noodles->isEmpty()) {
$__noodles = $GLOBALS['__default_noodles'];
}
}
catch(Excetpion $e)
{
} catch(Excetpion $e) {
$rsp->status = 'failed';
$rsp->message(__('Failed to load default noodles'));
echo $rsp->toXML(1);
return false;
}
if (!$__noodles->exists($i))
{
if (!$__noodles->exists($i)) {
$rsp->status = 'failed';
$rsp->message(__('Failed to load noodle'));
echo $rsp->toXML(1);
@ -132,19 +128,23 @@ class urlNoodles extends dcUrlHandlers
}
$m = $__noodles->{$i}->jsCallback($__noodles->{$i}, $c);
$s = $__noodles->{$i}->size;
$r = $__noodles->{$i}->rating;
$d = $core->blog->settings->noodles->noodles_image ?
urlencode(noodlesLibImagePath::getUrl($core, 'noodles')) : '';
if (!$m) $m = 'nobody@nowhere.tld';
if (!$s) $s = 32;
if (!$r) $r = 'g';
if (!$m) {
$m = 'nobody@nowhere.tld';
}
if (!$s) {
$s = 32;
}
if (!$r) {
$r = 'g';
}
$m = mb_strtolower($m);
$m = md5($m);
$im = new xmlTag('noodle');
$im->size = $s;
$im->src = 'http://www.gravatar.com/avatar/' . $m . '?s=' . $s . '&amp;r=' . $r . '&amp;d=' . $d;
@ -159,29 +159,25 @@ class urlNoodles extends dcUrlHandlers
{
global $core;
if (!$core->blog->settings->noodles->noodles_active)
{
if (!$core->blog->settings->noodles->noodles_active) {
self::p404();
return;
}
if (!preg_match('#^(.*?)$#',$args,$m))
{
if (!preg_match('#^(.*?)$#', $args, $m)) {
self::p404();
return;
}
$f = $m[1];
if (!($f = self::searchTplFiles($f)))
{
if (!($f = self::searchTplFiles($f))) {
self::p404();
return;
}
$allowed_types = array('png','jpg','jpeg','gif','css','js','swf');
if (!in_array(files::getExtension($f),$allowed_types))
{
$allowed_types = ['png', 'jpg', 'jpeg', 'gif', 'css', 'js', 'swf'];
if (!in_array(files::getExtension($f), $allowed_types)) {
self::p404();
return;
}
@ -190,13 +186,14 @@ class urlNoodles extends dcUrlHandlers
header('Content-Type: ' . $type . '; charset=UTF-8');
header('Content-Length: ' . filesize($f));
if ($type != "text/css" || $core->blog->settings->system->url_scan == 'path_info')
{
if ($type != "text/css" || $core->blog->settings->system->url_scan == 'path_info') {
readfile($f);
}
else
{
echo preg_replace('#url\((?!(http:)|/)#','url('.$core->blog->url.$core->url->getBase('noodlesmodule').'/',file_get_contents($f));
} else {
echo preg_replace(
'#url\((?!(http:)|/)#',
'url(' . $core->blog->url . $core->url->getBase('noodlesmodule') . '/',
file_get_contents($f)
);
}
exit;
}
@ -204,20 +201,16 @@ class urlNoodles extends dcUrlHandlers
# Search noodles files like JS, CSS in default-templates subdirectories
private static function searchTplFiles($file)
{
if (strstr($file,"..") !== false)
{
if (strstr($file,"..") !== false) {
return false;
}
$paths = $GLOBALS['core']->tpl->getPath();
foreach($paths as $path)
{
if (preg_match('/tpl(\/|)$/',$path))
{
foreach($paths as $path) {
if (preg_match('/tpl(\/|)$/',$path)) {
$path = path::real($path . '/..');
}
if (file_exists($path.'/'.$file))
{
if (file_exists($path . '/' . $file)) {
return $path . '/' . $file;
}
}

View file

@ -11,7 +11,9 @@
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')){return;}
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
$this->addUserAction(
/* type */ 'settings',

12
dcstore.xml Normal file
View file

@ -0,0 +1,12 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="noodles">
<name>Noodles</name>
<version>0.6.1</version>
<author>Jean-Christian Denis and contributors</author>
<desc>Add users gravatars everywhere</desc>
<file>https://github.com/JcDenis/noodles/releases/download/v0.6.1/plugin-noodles.zip</file>
<da:dcmin>2.19</da:dcmin>
<da:details>http://plugins.dotaddict.org/dc2/details/noodles</da:details>
<da:support>https://github.com/JcDenis/noodles</da:support>
</module>
</modules>

View file

@ -1,14 +1,3 @@
/* -- BEGIN LICENSE BLOCK ----------------------------------
* This file is part of noodles, a plugin for Dotclear 2.
*
* Copyright (c) 2009 JC Denis and contributors
* jcdenis@gdwd.com
*
* Licensed under the GPL version 2.0 license.
* A copy of this license is available in LICENSE file or at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* -- END LICENSE BLOCK ------------------------------------*/
;if(window.jQuery) (function($) {
$.fn.noodles = function(options) {

View file

@ -11,84 +11,95 @@
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')){return;}
if (!defined('DC_RC_PATH')) {
return null;
}
require dirname(__FILE__) . '/class.noodles.php';
global $__default_noodles;
$__default_noodles = new noodles();
$__default_noodles = new noodles;
# Posts (by public behavior)
$__default_noodles->add('posts',__('Entries'),'',array('othersNoodles','publicPosts'));
$__default_noodles->posts->size = 48;
$__default_noodles->posts->css = 'float:right;margin:4px;';
$__default_noodles
->add('posts', __('Entries'), '', ['othersNoodles', 'publicPosts'])
->size(48)
->css('float:right;margin:4px;');
# Comments (by public behavior)
$__default_noodles->add('comments',__('Comments'),'',array('othersNoodles','publicComments'));
$__default_noodles->comments->active = true;
$__default_noodles->comments->size = 48;
$__default_noodles->comments->css = 'float:left;margin:4px;';
$__default_noodles
->add('comments', __('Comments'), '', ['othersNoodles', 'publicComments'])
->active(true)
->size(48)
->css('float:left;margin:4px;');
# Block with post title link (like homepage posts)
$__default_noodles->add('titlesposts',__('Entries titles'),array('genericNoodles','postURL'));
$__default_noodles->titlesposts->target = '.post-title a';
$__default_noodles->titlesposts->css = 'margin-right:2px;';
$__default_noodles
->add('titlesposts', __('Entries titles'), ['genericNoodles', 'postURL'])
->target('.post-title a')
->css('margin-right:2px;');
if ($core->plugins->moduleExists('widgets')) {
# Widget Selected entries
$__default_noodles->add('bestof',__('Selected entries'),array('genericNoodles','postURL'));
$__default_noodles->bestof->target = '.selected li a';
$__default_noodles->bestof->css = 'margin-right:2px;';
$__default_noodles
->add('bestof', __('Selected entries'), ['genericNoodles', 'postURL'])
->target('.selected li a')
->css('margin-right:2px;');
# Widget Last entries
$__default_noodles->add('lastposts',__('Last entries'),array('genericNoodles','postURL'));
$__default_noodles->lastposts->target = '.lastposts li a';
$__default_noodles->lastposts->css = 'margin-right:2px;';
$__default_noodles
->add('lastposts', __('Last entries'), ['genericNoodles', 'postURL'])
->target('.lastposts li a')
->css('margin-right:2px;');
# Widget Last comments
$__default_noodles->add('lastcomments',__('Last comments'),array('widgetsNoodles','lastcomments'));
$__default_noodles->lastcomments->active = true;
$__default_noodles->lastcomments->target = '.lastcomments li a';
$__default_noodles->lastcomments->css = 'margin-right:2px;';
$__default_noodles
->add('lastcomments', __('Last comments'), ['widgetsNoodles', 'lastcomments'])
->active(true)
->target('.lastcomments li a')
->css('margin-right:2px;');
}
# Plugin auhtorMode
if ($core->plugins->moduleExists('authorMode')
&& $core->blog->settings->authormode->authormode_active) {
&& $core->blog->settings->authormode->authormode_active
) {
$__default_noodles
->add('authorswidget', __('Authors widget'), ['authormodeNoodles', 'authors'])
->target('#authors ul li a')
->css('margin-right:2px;');
$__default_noodles->add('authorswidget',__('Authors widget'),array('authormodeNoodles','authors'));
$__default_noodles->authorswidget->target = '#authors ul li a';
$__default_noodles->authorswidget->css = 'margin-right:2px;';
$__default_noodles
->add('author', __('Author'), '', ['authormodeNoodles', 'author'])
->active(true)
->size(48)
->target('.dc-author #content-info h2')
->css('clear:left; float:left;margin-right:2px;');
$__default_noodles->add('author',__('Author'),'',array('authormodeNoodles','author'));
$__default_noodles->author->active = true;
$__default_noodles->author->size = 48;
$__default_noodles->author->target = '.dc-author #content-info h2';
$__default_noodles->author->css = 'clear:left; float:left;margin-right:2px;';
$__default_noodles->add('authors',__('Authors'),array('authormodeNoodles','authors'));
$__default_noodles->authors->active = true;
$__default_noodles->authors->size = 32;
$__default_noodles->authors->target = '.dc-authors .author-info h2 a';
$__default_noodles->authors->css = 'clear:left; float:left; margin:4px;';
$__default_noodles
->add('authors', __('Authors'), ['authormodeNoodles', 'authors'])
->active(true)
->size(32)
->target('.dc-authors .author-info h2 a')
->css('clear:left; float:left; margin:4px;');
}
# Plugin rateIt
if ($core->plugins->moduleExists('rateIt')
&& $core->blog->settings->rateit->rateit_active) {
$__default_noodles->add('rateitpostsrank',__('Top rated entries'),array('genericNoodles','postURL'));
$__default_noodles->rateitpostsrank->target = '.rateitpostsrank.rateittypepost ul li a'; // Only "post" type
$__default_noodles->rateitpostsrank->css = 'margin-right:2px;';
&& $core->blog->settings->rateit->rateit_active
) {
$__default_noodles
->add('rateitpostsrank', __('Top rated entries'), ['genericNoodles', 'postURL'])
->target('.rateitpostsrank.rateittypepost ul li a') // Only "post" type
->css('margin-right:2px;');
}
# Plugin lastpostsExtend
if ($core->plugins->moduleExists('lastpostsExtend')) {
$__default_noodles->add('lastpostsextend',__('Last entries (extend)'),array('genericNoodles','postURL'));
$__default_noodles->lastpostsextend->target = '.lastpostsextend ul li a';
$__default_noodles->lastpostsextend->css = 'margin-right:2px;';
$__default_noodles
->add('lastpostsextend', __('Last entries (extend)'), ['genericNoodles', 'postURL'])
->target('.lastpostsextend ul li a')
->css('margin-right:2px;');
}
# --BEHAVIOR-- initDefaultNoodles

View file

@ -11,7 +11,9 @@
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')){return;}
if (!defined('DC_RC_PATH')) {
return null;
}
class genericNoodles
{
@ -20,19 +22,15 @@ class genericNoodles
global $core;
$types = $core->getPostTypes();
$reg = '@^'.str_replace('%s','(.*?)',
preg_quote($core->blog->url.$types['post']['public_url'])).'$@';
$reg = '@^' . str_replace('%s', '(.*?)', preg_quote($core->blog->url . $types['post']['public_url'])) . '$@';
$ok = preg_match($reg, $content, $m);
if (!$ok || !$m[1]) return '';
$rs = $core->blog->getPosts(
array('no_content'=>1,'post_url'=>urldecode($m[1]),'limit'=>1)
);
if ($rs->isEmpty()) return '';
if (!$ok || !$m[1]){
return '';
}
$rs = $core->blog->getPosts(['no_content' => 1, 'post_url' => urldecode($m[1]), 'limit' => 1]);
if ($rs->isEmpty()) {
return '';
}
return $rs->user_email;
}
}
@ -42,12 +40,13 @@ class othersNoodles
{
public static function publicPosts($core, $noodle)
{
if (!$noodle->active) return;
if (!$noodle->active) {
return null;
}
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
'publicEntryBeforeContent' : 'publicEntryAfterContent';
$core->addBehavior($bhv,array('othersNoodles','publicEntryContent'));
$core->addBehavior($bhv, ['othersNoodles', 'publicEntryContent']);
}
public static function publicEntryContent()
@ -69,12 +68,14 @@ class othersNoodles
public static function publicComments($core, $noodle)
{
if (!$noodle->active) return;
if (!$noodle->active) {
return null;
}
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
'publicCommentBeforeContent' : 'publicCommentAfterContent';
$core->addBehavior($bhv,array('othersNoodles','publicCommentContent'));
$core->addBehavior($bhv, ['othersNoodles', 'publicCommentContent']);
}
public static function publicCommentContent()
@ -103,15 +104,13 @@ class widgetsNoodles
global $core;
$ok = preg_match('@\#c([0-9]+)$@', urldecode($content), $m);
if (!$ok || !$m[1]) return '';
$rs = $core->blog->getComments(
array('no_content'=>1,'comment_id'=>$m[1],'limit'=>1)
);
if (!$rs->isEmpty()) return $rs->comment_email;
if (!$ok || !$m[1]) {
return '' null;
}
$rs = $core->blog->getComments(['no_content' => 1, 'comment_id' => $m[1], 'limit' => 1]);
if (!$rs->isEmpty()) {
return $rs->comment_email;
}
return '';
}
}
@ -122,23 +121,22 @@ class authormodeNoodles
public static function authors($noodle, $content = '')
{
global $core;
$ok = preg_match('@\/([^\/]*?)$@', $content, $m);
if (!$ok || !$m[1]) return '';
if (!$ok || !$m[1]) {
return '';
}
$rs = $core->getUser($m[1]);
if ($rs->isEmpty()) return '';
if ($rs->isEmpty()) {
return '';
}
return $rs->user_email;
}
public static function author($core, $noodle)
{
if ($noodle->active)
{
$core->addBehavior('publicHeadContent',
array('authormodeNoodles','publicHeadContent'));
if ($noodle->active) {
$core->addBehavior('publicHeadContent', ['authormodeNoodles', 'publicHeadContent']);
}
}
@ -146,7 +144,9 @@ class authormodeNoodles
{
global $core, $_ctx, $__noodles;
if ($_ctx->current_tpl != 'author.html') return;
if ($_ctx->current_tpl != 'author.html') {
return null;
}
$id = $_ctx->users->user_id;
$u = $core->getUser($id);

View file

@ -11,16 +11,20 @@
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')){return;}
if (!defined('DC_RC_PATH')) {
return null;
}
class noodles
{
private $noodles = array();
private $noodles = [];
public static function decode($s)
{
$o = @unserialize(base64_decode($s));
if ($o instanceof self) return $o;
if ($o instanceof self) {
return $o;
}
return new self;
}
@ -32,6 +36,7 @@ class noodles
public function add($id, $name, $js_callback, $php_callback = null)
{
$this->noodles[$id] = new noodle($id, $name, $js_callback, $php_callback);
return $this->noodles[$id];
}
public function __get($id)
@ -66,13 +71,13 @@ class noodle
private $name;
private $js_callback;
private $php_callback;
private $settings = array(
private $settings = [
'active' => 0,
'rating' => 'g',
'size' => 16,
'target' => '',
'place' => 'prepend'
);
];
public function __construct($id, $name, $js_callback, $php_callback = null)
{
@ -94,7 +99,9 @@ class noodle
public function jsCallback($g, $content = '')
{
if (!is_callable($this->js_callback)) return null;
if (!is_callable($this->js_callback)) {
return null;
}
return call_user_func($this->js_callback, $g, $content);
}
@ -105,7 +112,9 @@ class noodle
public function phpCallback($core)
{
if (!is_callable($this->php_callback)) return null;
if (!is_callable($this->php_callback)) {
return null;
}
return call_user_func($this->php_callback, $core, $this);
}
@ -116,21 +125,17 @@ class noodle
public function set($type, $value)
{
switch ($type)
{
switch ($type) {
case 'active':
$this->settings['active'] = abs((integer) $value);
break;
case 'rating':
$this->settings['rating'] = in_array($value,array('g','pg','r','x')) ?
$value : 'g';
$this->settings['rating'] = in_array($value, ['g', 'pg', 'r', 'x']) ? $value : 'g';
break;
case 'size':
$this->settings['size'] =
in_array($value,array(16,24,32,48,56,64,92,128,256)) ?
$value : 16;
$this->settings['size'] = in_array($value, [16, 24, 32, 48, 56, 64, 92, 128, 256]) ? $value : 16;
break;
case 'css':
@ -142,11 +147,40 @@ class noodle
break;
case 'place':
$this->settings['place'] =
in_array($value,array('append','prepend','before','after')) ?
$value : 'prepend';
$this->settings['place'] = in_array($value, ['append', 'prepend', 'before', 'after']) ? $value : 'prepend';
break;
}
return $this;
}
public function active($value)
{
return $this->set('active', $value);
}
public function rating($value)
{
return $this->set('rating', $value);
}
public function size($value)
{
return $this->set('size', $value);
}
public function css($value)
{
return $this->set('css', $value);
}
public function target($value)
{
return $this->set('target', $value);
}
public function place($value)
{
return $this->set('place', $value);
}
public function __set($type, $value)

View file

@ -11,6 +11,10 @@
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
class noodlesLibImagePath
{
public static $version = '1.1';
@ -18,28 +22,29 @@ class noodlesLibImagePath
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),
);
|| !$core->url->getBase($m . 'module')
) {
return [
'theme' => ['dir' = >null, 'url' = >null],
'public' => ['dir' => null, 'url' => null],
'module' => ['dir' => null, 'url' => null],
};
}
return array(
'theme' => array(
return [
'theme' => [
'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(
],
'public' => [
'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(
],
'module' => [
'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'
)
);
]
];
}
public static function getUrl($core, $m = '')
@ -65,10 +70,10 @@ class noodlesLibImagePath
public static function getSize($core, $m = '')
{
if (!($img = self::getPath($core, $m)))
return array('w'=>16,'h'=>16);
return ['w' => 16, 'h' => 16];
else {
$info = getimagesize($img);
return array('w'=>$info[0],'h'=>floor($info[1] /3));
return ['w' => $info[0], 'h' => floor($info[1] /3)];
}
}
}