diff --git a/_admin.php b/_admin.php index f45b7b4..f388a34 100644 --- a/_admin.php +++ b/_admin.php @@ -11,12 +11,14 @@ * @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; +} -# Admin menu $_menu['Plugins']->addItem( __('Noodles'), - 'plugin.php?p=noodles','index.php?pf=noodles/icon.png', - preg_match('/plugin.php\?p=noodles(&.*)?$/',$_SERVER['REQUEST_URI']), - $core->auth->check('admin',$core->blog->id) + $core->adminurl->get('admin.plugin.noodles'), + dcPage::getPF('noodles/icon.png'), + preg_match('/noodles(&.*)?$/', $_SERVER['REQUEST_URI']), + $core->auth->check('admin', $core->blog->id) ); \ No newline at end of file diff --git a/_install.php b/_install.php index 9f9b5f8..730d346 100644 --- a/_install.php +++ b/_install.php @@ -26,6 +26,12 @@ try { $core->blog->settings->noodles->put( 'noodles_active', false, 'boolean', 'Enable extension', false, true ); + $core->blog->settings->noodles->put( + 'noodles_image', '', 'string', 'Image filename', false, true + ); + $core->blog->settings->noodles->put( + 'noodles_object', '', 'string', 'Noodles behaviors', false, true + ); $core->setVersion('noodles', $new_version); return true; } catch (Exception $e) { diff --git a/_prepend.php b/_prepend.php index e70a441..537bd36 100644 --- a/_prepend.php +++ b/_prepend.php @@ -12,7 +12,7 @@ */ if (!defined('DC_RC_PATH')) { - return null; + return null; } $__autoload['noodlesImg'] = dirname(__FILE__) . '/inc/lib.noodles.img.php'; @@ -21,14 +21,14 @@ $__autoload['noodlesLibImagePath'] = dirname(__FILE__) . '/inc/lib.image.path.ph $core->blog->settings->addNamespace('noodles'); $core->url->register( - 'noodlesmodule', - 'noodles', - '^noodles/(.+)$', + 'noodlesmodule', + 'noodles', + '^noodles/(.+)$', ['urlNoodles', 'noodles'] ); $core->url->register( - 'noodlesservice', - 'noodle', - '^noodle/$', + 'noodlesservice', + 'noodle', + '^noodle/$', ['urlNoodles', 'service'] ); \ No newline at end of file diff --git a/_public.php b/_public.php index dc1a04e..af4e3d0 100644 --- a/_public.php +++ b/_public.php @@ -83,6 +83,8 @@ class publicNoodles class urlNoodles extends dcUrlHandlers { + public static $api_url = 'http://www.gravatar.com/avatar/%s?s=%s&r=%s&d=%s'; + public static function service($args) { global $core; @@ -127,9 +129,9 @@ class urlNoodles extends dcUrlHandlers return false; } - $m = $__noodles->{$i}->jsCallback($__noodles->{$i}, $c); - $s = $__noodles->{$i}->size; - $r = $__noodles->{$i}->rating; + $m = $__noodles->get($i)->jsCallback($__noodles->get($i), $c); + $s = $__noodles->get($i)->size; + $r = $__noodles->get($i)->rating; $d = $core->blog->settings->noodles->noodles_image ? urlencode(noodlesLibImagePath::getUrl($core, 'noodles')) : ''; @@ -143,11 +145,10 @@ class urlNoodles extends dcUrlHandlers $r = 'g'; } - $m = mb_strtolower($m); - $m = md5($m); + $m = md5(strtolower(trim( $m))); $im = new xmlTag('noodle'); $im->size = $s; - $im->src = 'http://www.gravatar.com/avatar/' . $m . '?s=' . $s . '&r=' . $r . '&d=' . $d; + $im->src = sprintf(self::$api_url, $m, $s, $r, $d); $rsp->insertNode($im); $rsp->status = 'ok'; diff --git a/default-templates/img/noodles-default-image.png b/default-templates/img/noodles-default-image.png index 1a53105..8e6c007 100644 Binary files a/default-templates/img/noodles-default-image.png and b/default-templates/img/noodles-default-image.png differ diff --git a/inc/class.noodles.php b/inc/class.noodles.php index 5391cb8..2bc43a7 100644 --- a/inc/class.noodles.php +++ b/inc/class.noodles.php @@ -22,7 +22,7 @@ class noodles public static function decode($s) { $o = @unserialize(base64_decode($s)); - if ($o instanceof self) { + if ($o instanceof noodles) { return $o; } return new self; @@ -39,16 +39,26 @@ class noodles return $this->noodles[$id]; } - public function __get($id) + public function get($id) { return isset($this->noodles[$id]) ? $this->noodles[$id] : null; } - public function __set($id, $noodle) + public function __get($id) + { + return $this->get($id); + } + + public function set($id, $module) { return $this->noodles[$id] = $noodle; } + public function __set($id, $noodle) + { + return $this->set($id, $noodle); + } + public function exists($id) { return isset($this->noodles[$id]); diff --git a/inc/lib.image.path.php b/inc/lib.image.path.php index d4cb727..0046923 100644 --- a/inc/lib.image.path.php +++ b/inc/lib.image.path.php @@ -25,23 +25,23 @@ class noodlesLibImagePath || !$core->url->getBase($m . 'module') ) { return [ - 'theme' => ['dir' = >null, 'url' = >null], + 'theme' => ['dir' => null, 'url' => null], 'public' => ['dir' => null, 'url' => null], 'module' => ['dir' => null, 'url' => null], - }; + ]; } return [ 'theme' => [ - 'dir' => $core->blog->themes_path . '/' . $core->blog->settings->system->theme . '/img/' . $m . '-default-image.png', + 'dir' => path::real($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' => [ - 'dir' => $core->blog->public_path . '/' . $m . '-default-image.png', + 'dir' => path::real($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' => [ - 'dir' => $core->plugins->moduleRoot($m) . '/default-templates/img/' . $m . '-default-image.png', + 'dir' => path::real($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' ] ];