Clean up code and fix some relative path
This commit is contained in:
parent
f40e9cf174
commit
bd6be92958
7 changed files with 45 additions and 26 deletions
12
_admin.php
12
_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)
|
||||
);
|
|
@ -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) {
|
||||
|
|
13
_public.php
13
_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';
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
@ -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]);
|
||||
|
|
|
@ -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'
|
||||
]
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue