From 557a5db1dba0c85ed12856e448cbe78e22a8228d Mon Sep 17 00:00:00 2001
From: Jean-Christian Denis
Date: Thu, 9 Sep 2021 01:02:10 +0200
Subject: [PATCH] update license and fix new lines, tabs, etc...
---
_admin.php | 32 +--
_define.php | 36 ++--
_install.php | 50 ++---
_prepend.php | 27 ++-
_public.php | 372 ++++++++++++++++----------------
_uninstall.php | 60 +++---
inc/_default_noodles.php | 89 ++++----
inc/_noodles_functions.php | 300 +++++++++++++-------------
inc/class.noodles.php | 312 +++++++++++++--------------
inc/lib.image.path.php | 130 ++++++------
index.php | 424 ++++++++++++++++++-------------------
locales/fr/main.lang.php | 4 +-
12 files changed, 915 insertions(+), 921 deletions(-)
diff --git a/_admin.php b/_admin.php
index 871fbdf..691b6c8 100644
--- a/_admin.php
+++ b/_admin.php
@@ -1,22 +1,22 @@
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)
-);
-?>
\ No newline at end of file
+ __('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)
+);
\ No newline at end of file
diff --git a/_define.php b/_define.php
index 220e10d..5d3b8b7 100644
--- a/_define.php
+++ b/_define.php
@@ -1,24 +1,24 @@
registerModule(
- /* Name */ "Noodles",
- /* Description*/ "Add users gravatars everywhere",
- /* Author */ "JC Denis",
- /* Version */ '0.6.1',
- /* Permissions */ 'admin'
- //* Priority */ 10000000
+ /* Name */ "Noodles",
+ /* Description*/ "Add users gravatars everywhere",
+ /* Author */ "JC Denis",
+ /* Version */ '0.6.1',
+ /* Permissions */ 'admin'
+ //* Priority */ 10000000
);
- /* date */ #20100705
-?>
\ No newline at end of file
+ /* date */ #20100705
\ No newline at end of file
diff --git a/_install.php b/_install.php
index 93433d3..a340d6a 100644
--- a/_install.php
+++ b/_install.php
@@ -1,14 +1,15 @@
=')) return;
try
{
- if (version_compare(DC_VERSION,'2.2-beta','<'))
- {
- throw new Exception('noodles requires Dotclear 2.2');
- }
-
- $core->blog->settings->addNamespace('noodles');
-
- $core->blog->settings->noodles->put('noodles_active',false,'boolean','Enable extension',false,true);
-
- $core->setVersion('noodles',$new_version);
-
- return true;
+ if (version_compare(DC_VERSION,'2.2-beta','<'))
+ {
+ throw new Exception('noodles requires Dotclear 2.2');
+ }
+
+ $core->blog->settings->addNamespace('noodles');
+
+ $core->blog->settings->noodles->put('noodles_active',false,'boolean','Enable extension',false,true);
+
+ $core->setVersion('noodles',$new_version);
+
+ return true;
}
catch (Exception $e)
{
- $core->error->add($e->getMessage());
+ $core->error->add($e->getMessage());
}
-return false;
-?>
\ No newline at end of file
+return false;
\ No newline at end of file
diff --git a/_prepend.php b/_prepend.php
index 71345e1..945791d 100644
--- a/_prepend.php
+++ b/_prepend.php
@@ -1,14 +1,15 @@
blog->settings->addNamespace('noodles');
$core->url->register('noodlesmodule','noodles','^noodles/(.+)$',
- array('urlNoodles','noodles'));
+ array('urlNoodles','noodles'));
$core->url->register('noodlesservice','noodle','^noodle/$',
- array('urlNoodles','service'));
-
-?>
\ No newline at end of file
+ array('urlNoodles','service'));
\ No newline at end of file
diff --git a/_public.php b/_public.php
index 83ecc11..a7410ff 100644
--- a/_public.php
+++ b/_public.php
@@ -1,14 +1,15 @@
addBehavior('publicHeadContent',
- array('publicNoodles','publicHeadContent'));
+ array('publicNoodles','publicHeadContent'));
$core->tpl->setPath($core->tpl->getPath(),dirname(__FILE__).'/default-templates');
@@ -26,201 +27,200 @@ global $__noodles;
$__noodles = noodles::decode($core->blog->settings->noodles->noodles_object);
if ($__noodles->isEmpty())
- $__noodles = $__default_noodles;
+ $__noodles = $__default_noodles;
//$GLOBALS['__noodles'] =& $__noodles;
foreach($__noodles->noodles() AS $noodle) {
- if ($noodle->active && $noodle->hasPhpCallback())
- $noodle->phpCallback($core);
+ if ($noodle->active && $noodle->hasPhpCallback())
+ $noodle->phpCallback($core);
}
class publicNoodles
{
- public static function publicHeadContent($core)
- {
- $__noodles =& $GLOBALS['__noodles'];
+ public static function publicHeadContent($core)
+ {
+ $__noodles =& $GLOBALS['__noodles'];
- $css = "\n";
- $targets = array();
- foreach($__noodles->noodles() AS $noodle) {
+ $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";
+ $css .= '.noodles-'.$noodle->id().'{'.$noodle->css.'}'."\n";
- $targets[] =
- ' $(\''.html::escapeJS($noodle->target).'\').noodles({'.
- 'imgId:\''.html::escapeJS($noodle->id()).'\','.
- 'imgPlace:\''.html::escapeJS($noodle->place).'\''.
- '});';
- }
+ $targets[] =
+ ' $(\''.html::escapeJS($noodle->target).'\').noodles({'.
+ 'imgId:\''.html::escapeJS($noodle->id()).'\','.
+ 'imgPlace:\''.html::escapeJS($noodle->place).'\''.
+ '});';
+ }
- if (empty($targets)) return;
+ if (empty($targets)) return;
- echo
- "\n \n".
- ''.
- "\n \n".
- " \n".
- "\n";
- }
+ echo
+ "\n \n".
+ ''.
+ "\n \n".
+ " \n".
+ "\n";
+ }
}
class urlNoodles extends dcUrlHandlers
{
- public static function service($args)
- {
- global $core;
-
- header('Content-Type: text/xml; charset=UTF-8');
-
- $rsp = new xmlTag('rsp');
+ public static function service($args)
+ {
+ global $core;
- $i = !empty($_POST['noodleId']) ? $_POST['noodleId'] : null;
- $c = !empty($_POST['noodleContent']) ? $_POST['noodleContent'] : null;
-
- 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)
- {
- $rsp->status = 'failed';
- $rsp->message(__('noodles failed because of missing informations'));
- echo $rsp->toXML(1);
- return false;
- }
-
- try
- {
- $__noodles = noodles::decode($core->blog->settings->noodles->noodles_object);
-
- if ($__noodles->isEmpty())
- {
- $__noodles = $GLOBALS['__default_noodles'];
- }
- }
- catch(Excetpion $e)
- {
- $rsp->status = 'failed';
- $rsp->message(__('Failed to load default noodles'));
- echo $rsp->toXML(1);
- return false;
- }
-
- if (!$__noodles->exists($i))
- {
- $rsp->status = 'failed';
- $rsp->message(__('Failed to load noodle'));
- echo $rsp->toXML(1);
- return false;
- }
-
- $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';
-
- $m = mb_strtolower($m);
- $m = md5($m);
-
- $im = new xmlTag('noodle');
- $im->size = $s;
- $im->src = 'http://www.gravatar.com/avatar/'.$m.'?s='.$s.'&r='.$r.'&d='.$d;
- $rsp->insertNode($im);
-
- $rsp->status = 'ok';
- echo $rsp->toXML(1);
- exit;
- }
+ header('Content-Type: text/xml; charset=UTF-8');
- public static function noodles($args)
- {
- global $core;
+ $rsp = new xmlTag('rsp');
- if (!$core->blog->settings->noodles->noodles_active)
- {
- self::p404();
- return;
- }
+ $i = !empty($_POST['noodleId']) ? $_POST['noodleId'] : null;
+ $c = !empty($_POST['noodleContent']) ? $_POST['noodleContent'] : null;
- if (!preg_match('#^(.*?)$#',$args,$m))
- {
- self::p404();
- return;
- }
+ if (!$core->blog->settings->noodles->noodles_active)
+ {
+ $rsp->status = 'failed';
+ $rsp->message(__('noodles is disabled on this blog'));
+ echo $rsp->toXML(1);
+ return false;
+ }
- $f = $m[1];
-
- 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))
- {
- self::p404();
- return;
- }
- $type = files::getMimeType($f);
-
- header('Content-Type: '.$type.'; charset=UTF-8');
- header('Content-Length: '.filesize($f));
-
- 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));
- }
- exit;
- }
-
- # Search noodles files like JS, CSS in default-templates subdirectories
- private static function searchTplFiles($file)
- {
- if (strstr($file,"..") !== false)
- {
- return false;
- }
- $paths = $GLOBALS['core']->tpl->getPath();
-
- foreach($paths as $path)
- {
- if (preg_match('/tpl(\/|)$/',$path))
- {
- $path = path::real($path.'/..');
- }
- if (file_exists($path.'/'.$file))
- {
- return $path.'/'.$file;
- }
- }
- return false;
- }
-}
-?>
\ No newline at end of file
+ if ($i === null || $c === null)
+ {
+ $rsp->status = 'failed';
+ $rsp->message(__('noodles failed because of missing informations'));
+ echo $rsp->toXML(1);
+ return false;
+ }
+
+ try
+ {
+ $__noodles = noodles::decode($core->blog->settings->noodles->noodles_object);
+
+ if ($__noodles->isEmpty())
+ {
+ $__noodles = $GLOBALS['__default_noodles'];
+ }
+ }
+ catch(Excetpion $e)
+ {
+ $rsp->status = 'failed';
+ $rsp->message(__('Failed to load default noodles'));
+ echo $rsp->toXML(1);
+ return false;
+ }
+
+ if (!$__noodles->exists($i))
+ {
+ $rsp->status = 'failed';
+ $rsp->message(__('Failed to load noodle'));
+ echo $rsp->toXML(1);
+ return false;
+ }
+
+ $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';
+
+ $m = mb_strtolower($m);
+ $m = md5($m);
+
+ $im = new xmlTag('noodle');
+ $im->size = $s;
+ $im->src = 'http://www.gravatar.com/avatar/'.$m.'?s='.$s.'&r='.$r.'&d='.$d;
+ $rsp->insertNode($im);
+
+ $rsp->status = 'ok';
+ echo $rsp->toXML(1);
+ exit;
+ }
+
+ public static function noodles($args)
+ {
+ global $core;
+
+ if (!$core->blog->settings->noodles->noodles_active)
+ {
+ self::p404();
+ return;
+ }
+
+ if (!preg_match('#^(.*?)$#',$args,$m))
+ {
+ self::p404();
+ return;
+ }
+
+ $f = $m[1];
+
+ 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))
+ {
+ self::p404();
+ return;
+ }
+ $type = files::getMimeType($f);
+
+ header('Content-Type: '.$type.'; charset=UTF-8');
+ header('Content-Length: '.filesize($f));
+
+ 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));
+ }
+ exit;
+ }
+
+ # Search noodles files like JS, CSS in default-templates subdirectories
+ private static function searchTplFiles($file)
+ {
+ if (strstr($file,"..") !== false)
+ {
+ return false;
+ }
+ $paths = $GLOBALS['core']->tpl->getPath();
+
+ foreach($paths as $path)
+ {
+ if (preg_match('/tpl(\/|)$/',$path))
+ {
+ $path = path::real($path.'/..');
+ }
+ if (file_exists($path.'/'.$file))
+ {
+ return $path.'/'.$file;
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/_uninstall.php b/_uninstall.php
index e836551..8549fbf 100644
--- a/_uninstall.php
+++ b/_uninstall.php
@@ -1,44 +1,42 @@
addUserAction(
- /* type */ 'settings',
- /* action */ 'delete_all',
- /* ns */ 'noodles',
- /* description */ __('delete all settings')
+ /* type */ 'settings',
+ /* action */ 'delete_all',
+ /* ns */ 'noodles',
+ /* description */ __('delete all settings')
);
$this->addUserAction(
- /* type */ 'plugins',
- /* action */ 'delete',
- /* ns */ 'noodles',
- /* description */ __('delete plugin files')
-);
-
-
-$this->addDirectAction(
- /* type */ 'settings',
- /* action */ 'delete_all',
- /* ns */ 'noodles',
- /* description */ sprintf(__('delete all %s settings'),'noodles')
+ /* type */ 'plugins',
+ /* action */ 'delete',
+ /* ns */ 'noodles',
+ /* description */ __('delete plugin files')
);
$this->addDirectAction(
- /* type */ 'plugins',
- /* action */ 'delete',
- /* ns */ 'noodles',
- /* description */ sprintf(__('delete %s plugin files'),'noodles')
+ /* type */ 'settings',
+ /* action */ 'delete_all',
+ /* ns */ 'noodles',
+ /* description */ sprintf(__('delete all %s settings'),'noodles')
);
-?>
\ No newline at end of file
+$this->addDirectAction(
+ /* type */ 'plugins',
+ /* action */ 'delete',
+ /* ns */ 'noodles',
+ /* description */ sprintf(__('delete %s plugin files'),'noodles')
+);
\ No newline at end of file
diff --git a/inc/_default_noodles.php b/inc/_default_noodles.php
index fafb625..63372d0 100644
--- a/inc/_default_noodles.php
+++ b/inc/_default_noodles.php
@@ -1,14 +1,15 @@
titlesposts->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;';
+ # 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;';
- # 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;';
+ # 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;';
- # 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;';
+ # 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;';
}
# Plugin auhtorMode
if ($core->plugins->moduleExists('authorMode')
&& $core->blog->settings->authormode->authormode_active) {
- $__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('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'),'',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('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'),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;';
}
# 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;';
+ $__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;';
}
# 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)'),array('genericNoodles','postURL'));
+ $__default_noodles->lastpostsextend->target = '.lastpostsextend ul li a';
+ $__default_noodles->lastpostsextend->css = 'margin-right:2px;';
}
# --BEHAVIOR-- initDefaultNoodles
-$core->callBehavior('initDefaultNoodles',$__default_noodles);
-
-?>
\ No newline at end of file
+$core->callBehavior('initDefaultNoodles',$__default_noodles);
\ No newline at end of file
diff --git a/inc/_noodles_functions.php b/inc/_noodles_functions.php
index 8db492e..50aecfa 100644
--- a/inc/_noodles_functions.php
+++ b/inc/_noodles_functions.php
@@ -1,172 +1,172 @@
getPostTypes();
- $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 '';
-
- return $rs->user_email;
- }
+ public static function postURL($noodle,$content='')
+ {
+ global $core;
+
+ $types = $core->getPostTypes();
+ $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 '';
+
+ return $rs->user_email;
+ }
}
# Miscellaneous
class othersNoodles
{
- public static function publicPosts($core,$noodle)
- {
- if (!$noodle->active) return;
-
- $bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
- 'publicEntryBeforeContent' : 'publicEntryAfterContent';
-
- $core->addBehavior($bhv,array('othersNoodles','publicEntryContent'));
- }
-
- public static function publicEntryContent()
- {
- global $core,$_ctx,$__noodles;
-
- $m = $_ctx->posts->getAuthorEmail(false);
- $c = $__noodles->posts->css;
- $s = $__noodles->posts->size;
- $r = $__noodles->posts->rating;
- $d = $core->blog->settings->noodles->noodles_image ?
- urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
-
- echo
- '';
- }
+ public static function publicPosts($core,$noodle)
+ {
+ if (!$noodle->active) return;
- public static function publicComments($core,$noodle)
- {
- if (!$noodle->active) return;
-
- $bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
- 'publicCommentBeforeContent' : 'publicCommentAfterContent';
-
- $core->addBehavior($bhv,array('othersNoodles','publicCommentContent'));
- }
-
- public static function publicCommentContent()
- {
- global $core,$_ctx,$__noodles;
-
- $m = $_ctx->comments->getEmail(false);
- $c = $__noodles->comments->css;
- $s = $__noodles->comments->size;
- $r = $__noodles->comments->rating;
- $d = $core->blog->settings->noodles->noodles_image ?
- urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
-
- echo
- '';
- }
+ $bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
+ 'publicEntryBeforeContent' : 'publicEntryAfterContent';
+
+ $core->addBehavior($bhv,array('othersNoodles','publicEntryContent'));
+ }
+
+ public static function publicEntryContent()
+ {
+ global $core,$_ctx,$__noodles;
+
+ $m = $_ctx->posts->getAuthorEmail(false);
+ $c = $__noodles->posts->css;
+ $s = $__noodles->posts->size;
+ $r = $__noodles->posts->rating;
+ $d = $core->blog->settings->noodles->noodles_image ?
+ urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
+
+ echo
+ '';
+ }
+
+ public static function publicComments($core,$noodle)
+ {
+ if (!$noodle->active) return;
+
+ $bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
+ 'publicCommentBeforeContent' : 'publicCommentAfterContent';
+
+ $core->addBehavior($bhv,array('othersNoodles','publicCommentContent'));
+ }
+
+ public static function publicCommentContent()
+ {
+ global $core,$_ctx,$__noodles;
+
+ $m = $_ctx->comments->getEmail(false);
+ $c = $__noodles->comments->css;
+ $s = $__noodles->comments->size;
+ $r = $__noodles->comments->rating;
+ $d = $core->blog->settings->noodles->noodles_image ?
+ urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
+
+ echo
+ '';
+ }
}
# Plugin Widgets
class widgetsNoodles
{
- public static function lastcomments($noodle,$content='')
- {
- 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;
-
- return '';
- }
+ public static function lastcomments($noodle,$content='')
+ {
+ 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;
+
+ return '';
+ }
}
# Plugin authorMode
class authormodeNoodles
{
- public static function authors($noodle,$content='')
- {
- global $core;
- $ok = preg_match('@\/([^\/]*?)$@',$content,$m);
-
- if (!$ok || !$m[1]) return '';
-
- $rs = $core->getUser($m[1]);
-
- if ($rs->isEmpty()) return '';
-
- return $rs->user_email;
- }
-
- public static function author($core,$noodle)
- {
- if ($noodle->active)
- {
- $core->addBehavior('publicHeadContent',
- array('authormodeNoodles','publicHeadContent'));
- }
- }
-
- public static function publicHeadContent()
- {
- global $core,$_ctx,$__noodles;
-
- if ($_ctx->current_tpl != 'author.html') return;
-
- $id = $_ctx->users->user_id;
- $u = $core->getUser($id);
- $m = $u->user_email;
- $c = $__noodles->author->css;
- $s = $__noodles->author->size;
- $r = $__noodles->author->rating;
- $d = $core->blog->settings->noodles->noodles_image ?
- urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
-
- echo
- '\n";
- }
-}
-?>
\ No newline at end of file
+ public static function authors($noodle,$content='')
+ {
+ global $core;
+ $ok = preg_match('@\/([^\/]*?)$@',$content,$m);
+
+ if (!$ok || !$m[1]) return '';
+
+ $rs = $core->getUser($m[1]);
+
+ if ($rs->isEmpty()) return '';
+
+ return $rs->user_email;
+ }
+
+ public static function author($core,$noodle)
+ {
+ if ($noodle->active)
+ {
+ $core->addBehavior('publicHeadContent',
+ array('authormodeNoodles','publicHeadContent'));
+ }
+ }
+
+ public static function publicHeadContent()
+ {
+ global $core,$_ctx,$__noodles;
+
+ if ($_ctx->current_tpl != 'author.html') return;
+
+ $id = $_ctx->users->user_id;
+ $u = $core->getUser($id);
+ $m = $u->user_email;
+ $c = $__noodles->author->css;
+ $s = $__noodles->author->size;
+ $r = $__noodles->author->rating;
+ $d = $core->blog->settings->noodles->noodles_image ?
+ urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
+
+ echo
+ '\n";
+ }
+}
\ No newline at end of file
diff --git a/inc/class.noodles.php b/inc/class.noodles.php
index 3838e08..81123f5 100644
--- a/inc/class.noodles.php
+++ b/inc/class.noodles.php
@@ -1,166 +1,166 @@
noodles[$id] = new noodle($id,$name,$js_callback,$php_callback);
- }
-
- public function __get($id)
- {
- return isset($this->noodles[$id]) ? $this->noodles[$id] : null;
- }
-
- public function __set($id,$noodle)
- {
- return $this->noodles[$id] = $noodle;
- }
-
- public function exists($id)
- {
- return isset($this->noodles[$id]);
- }
-
- public function isEmpty()
- {
- return !count($this->noodles);
- }
-
- public function noodles()
- {
- return $this->noodles;
- }
+ private $noodles = array();
+
+ public static function decode($s)
+ {
+ $o = @unserialize(base64_decode($s));
+ if ($o instanceof self) return $o;
+ return new self;
+ }
+
+ public function encode()
+ {
+ return base64_encode(serialize($this));
+ }
+
+ public function add($id,$name,$js_callback,$php_callback=null)
+ {
+ $this->noodles[$id] = new noodle($id,$name,$js_callback,$php_callback);
+ }
+
+ public function __get($id)
+ {
+ return isset($this->noodles[$id]) ? $this->noodles[$id] : null;
+ }
+
+ public function __set($id,$noodle)
+ {
+ return $this->noodles[$id] = $noodle;
+ }
+
+ public function exists($id)
+ {
+ return isset($this->noodles[$id]);
+ }
+
+ public function isEmpty()
+ {
+ return !count($this->noodles);
+ }
+
+ public function noodles()
+ {
+ return $this->noodles;
+ }
}
class noodle
{
- private $id;
- private $name;
- private $js_callback;
- private $php_callback;
- private $settings = array(
- 'active' => 0,
- 'rating' => 'g',
- 'size' => 16,
- 'target' => '',
- 'place' => 'prepend'
- );
-
- public function __construct($id,$name,$js_callback,$php_callback=null)
- {
- $this->id = $id;
- $this->name = $name;
- $this->js_callback = $js_callback;
- $this->php_callback = $php_callback;
- }
-
- public function id()
- {
- return $this->id;
- }
-
- public function name()
- {
- return $this->name;
- }
-
- public function jsCallback($g,$content='')
- {
- if (!is_callable($this->js_callback)) return null;
- return call_user_func($this->js_callback,$g,$content);
- }
-
- public function hasJsCallback()
- {
- return !empty($this->js_callback);
- }
-
- public function phpCallback($core)
- {
- if (!is_callable($this->php_callback)) return null;
- return call_user_func($this->php_callback,$core,$this);
- }
-
- public function hasPhpCallback()
- {
- return !empty($this->php_callback);
- }
-
- public function set($type,$value)
- {
- 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';
- break;
-
- case 'size':
- $this->settings['size'] =
- in_array($value,array(16,24,32,48,56,64,92,128,256)) ?
- $value : 16;
- break;
-
- case 'css':
- $this->settings['css'] = (string) $value;
- break;
-
- case 'target':
- $this->settings['target'] = (string) $value;
- break;
-
- case 'place':
- $this->settings['place'] =
- in_array($value,array('append','prepend','before','after')) ?
- $value : 'prepend';
- break;
- }
- }
-
- public function __set($type,$value)
- {
- $this->set($type,$value);
- }
-
- public function get($type)
- {
- return isset($this->settings[$type]) ? $this->settings[$type] : null;
- }
-
- public function __get($type)
- {
- return $this->get($type);
- }
-}
-?>
\ No newline at end of file
+ private $id;
+ private $name;
+ private $js_callback;
+ private $php_callback;
+ private $settings = array(
+ 'active' => 0,
+ 'rating' => 'g',
+ 'size' => 16,
+ 'target' => '',
+ 'place' => 'prepend'
+ );
+
+ public function __construct($id,$name,$js_callback,$php_callback=null)
+ {
+ $this->id = $id;
+ $this->name = $name;
+ $this->js_callback = $js_callback;
+ $this->php_callback = $php_callback;
+ }
+
+ public function id()
+ {
+ return $this->id;
+ }
+
+ public function name()
+ {
+ return $this->name;
+ }
+
+ public function jsCallback($g,$content='')
+ {
+ if (!is_callable($this->js_callback)) return null;
+ return call_user_func($this->js_callback,$g,$content);
+ }
+
+ public function hasJsCallback()
+ {
+ return !empty($this->js_callback);
+ }
+
+ public function phpCallback($core)
+ {
+ if (!is_callable($this->php_callback)) return null;
+ return call_user_func($this->php_callback,$core,$this);
+ }
+
+ public function hasPhpCallback()
+ {
+ return !empty($this->php_callback);
+ }
+
+ public function set($type,$value)
+ {
+ 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';
+ break;
+
+ case 'size':
+ $this->settings['size'] =
+ in_array($value,array(16,24,32,48,56,64,92,128,256)) ?
+ $value : 16;
+ break;
+
+ case 'css':
+ $this->settings['css'] = (string) $value;
+ break;
+
+ case 'target':
+ $this->settings['target'] = (string) $value;
+ break;
+
+ case 'place':
+ $this->settings['place'] =
+ in_array($value,array('append','prepend','before','after')) ?
+ $value : 'prepend';
+ break;
+ }
+ }
+
+ public function __set($type,$value)
+ {
+ $this->set($type,$value);
+ }
+
+ public function get($type)
+ {
+ return isset($this->settings[$type]) ? $this->settings[$type] : null;
+ }
+
+ public function __get($type)
+ {
+ return $this->get($type);
+ }
+}
\ No newline at end of file
diff --git a/inc/lib.image.path.php b/inc/lib.image.path.php
index 615a736..aef2e5d 100644
--- a/inc/lib.image.path.php
+++ b/inc/lib.image.path.php
@@ -1,74 +1,74 @@
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),
- );
- }
+ 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),
+ );
+ }
- 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'
- )
- );
- }
+ 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'
+ )
+ );
+ }
- 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;
- }
+ 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;
+ }
- 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;
- }
+ 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;
+ }
- 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));
- }
- }
-}
-?>
\ No newline at end of file
+ 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));
+ }
+ }
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index a54fe56..1f9c673 100644
--- a/index.php
+++ b/index.php
@@ -1,14 +1,15 @@
noodles_object);
if ($__noodles->isEmpty())
{
- $__noodles = $__default_noodles;
+ $__noodles = $__default_noodles;
}
else
{
- $default_noodles_array = $__default_noodles->noodles();
- foreach($default_noodles_array AS $id => $noodle)
- {
- if ($__noodles->exists($id)) continue;
- $__noodles->{$id} = $noodle;
- }
+ $default_noodles_array = $__default_noodles->noodles();
+ foreach($default_noodles_array AS $id => $noodle)
+ {
+ if ($__noodles->exists($id)) continue;
+ $__noodles->{$id} = $noodle;
+ }
}
if (!$s->noodles_active)
{
- $tab = 'settings';
+ $tab = 'settings';
}
$default_avatars_images = files::scandir(dirname(__FILE__).'/default-templates/img/');
$avatar_paths = noodlesLibImagePath::getArray($core,'noodles');
$combo_active = array(
- __('no') => 0,
- __('yes') => 1
+ __('no') => 0,
+ __('yes') => 1
);
$combo_place = array(
- __('Begin') => 'prepend',
- __('End') => 'append',
- __('Before') => 'before',
- __('After') => 'after'
+ __('Begin') => 'prepend',
+ __('End') => 'append',
+ __('Before') => 'before',
+ __('After') => 'after'
);
$combo_rating = array(
- 'G'=>'g',
- 'PG'=>'pg',
- 'R'=>'r',
- 'X'=>'x'
+ 'G'=>'g',
+ 'PG'=>'pg',
+ 'R'=>'r',
+ 'X'=>'x'
);
$combo_size = array(
- '16px'=>16,
- '24px'=>24,
- '32px'=>32,
- '48px'=>48,
- '56px'=>56,
- '64px'=>64,
- '92px'=>92,
- '128px'=>128,
- '256px'=>256
+ '16px'=>16,
+ '24px'=>24,
+ '32px'=>32,
+ '48px'=>48,
+ '56px'=>56,
+ '64px'=>64,
+ '92px'=>92,
+ '128px'=>128,
+ '256px'=>256
);
if (!empty($_POST['save']) && $tab == 'settings')
{
- try
- {
- $s->put('noodles_active',$_POST['noodles_active'],'boolean');
+ try
+ {
+ $s->put('noodles_active',$_POST['noodles_active'],'boolean');
- # Destination image according to noodlesLibImagePath()
- $dest_file = DC_ROOT.'/'.$s->public_path.'/noodles-default-image.png';
+ # Destination image according to noodlesLibImagePath()
+ $dest_file = DC_ROOT.'/'.$s->public_path.'/noodles-default-image.png';
- # user upload image
- if ($_POST['noodles_image'] == 'user')
- {
- if (2 == $_FILES['noodlesuserfile']['error'])
- {
- throw new Exception(__('Maximum file size exceeded'));
- }
- if ($_FILES['noodlesuserfile']['type'] != 'image/x-png')
- {
- throw new Exception(__('Image must be in png format'));
- }
- if (0 != $_FILES['noodlesuserfile']['error'])
- {
- throw new Exception(__('Something went wrong while download file'));
- }
- if ($_FILES['noodlesuserfile']['type'] != 'image/x-png')
- {
- throw new Exception(__('Image must be in png format'));
- }
- if (move_uploaded_file($_FILES['noodlesuserfile']['tmp_name'],$dest_file))
- {
- $s->put('noodles_image',1,'boolean');
- }
- }
- # Default gravatar.com avatar
- elseif ($_POST['noodles_image'] == 'gravatar.com')
- {
- $s->put('noodles_image',0,'boolean');
- }
- # existsing noodles image on blog
- elseif ($_POST['noodles_image'] == 'existsing')
- {
- $s->put('noodles_image',1,'boolean');
- }
- # noodles image
- elseif (preg_match('/^gravatar-[0-9]+.png$/',$_POST['noodles_image']))
- {
- $source = dirname(__FILE__).'/default-templates/img/'.$_POST['noodles_image'];
-
- if (!file_exists($source))
- {
- throw new Exception(__('Something went wrong while search file'));
- }
- if (file_put_contents($dest_file,file_get_contents($source)))
- {
- $s->put('noodles_image',1,'boolean');
- }
- }
-
- $core->blog->triggerBlog();
- http::redirect('plugin.php?p=noodles&tab=settings&done=1');
- }
- catch (Exception $e)
- {
- $core->error->add($e->getMessage());
- }
+ # user upload image
+ if ($_POST['noodles_image'] == 'user')
+ {
+ if (2 == $_FILES['noodlesuserfile']['error'])
+ {
+ throw new Exception(__('Maximum file size exceeded'));
+ }
+ if ($_FILES['noodlesuserfile']['type'] != 'image/x-png')
+ {
+ throw new Exception(__('Image must be in png format'));
+ }
+ if (0 != $_FILES['noodlesuserfile']['error'])
+ {
+ throw new Exception(__('Something went wrong while download file'));
+ }
+ if ($_FILES['noodlesuserfile']['type'] != 'image/x-png')
+ {
+ throw new Exception(__('Image must be in png format'));
+ }
+ if (move_uploaded_file($_FILES['noodlesuserfile']['tmp_name'],$dest_file))
+ {
+ $s->put('noodles_image',1,'boolean');
+ }
+ }
+ # Default gravatar.com avatar
+ elseif ($_POST['noodles_image'] == 'gravatar.com')
+ {
+ $s->put('noodles_image',0,'boolean');
+ }
+ # existsing noodles image on blog
+ elseif ($_POST['noodles_image'] == 'existsing')
+ {
+ $s->put('noodles_image',1,'boolean');
+ }
+ # noodles image
+ elseif (preg_match('/^gravatar-[0-9]+.png$/',$_POST['noodles_image']))
+ {
+ $source = dirname(__FILE__).'/default-templates/img/'.$_POST['noodles_image'];
+
+ if (!file_exists($source))
+ {
+ throw new Exception(__('Something went wrong while search file'));
+ }
+ if (file_put_contents($dest_file,file_get_contents($source)))
+ {
+ $s->put('noodles_image',1,'boolean');
+ }
+ }
+
+ $core->blog->triggerBlog();
+ http::redirect('plugin.php?p=noodles&tab=settings&done=1');
+ }
+ catch (Exception $e)
+ {
+ $core->error->add($e->getMessage());
+ }
}
if (!empty($_POST['save']) && $tab == 'blocs' && !empty($_POST['noodle']))
{
- try
- {
- foreach($_POST['noodle'] as $id => $bloc)
- {
- foreach($bloc as $k => $v)
- {
- $__noodles->{$id}->set($k,$v);
- }
- }
- $s->put('noodles_object',$__noodles->encode(),'string');
-
- $core->blog->triggerBlog();
- http::redirect('plugin.php?p=noodles&tab=blocs&done=1');
- }
- catch (Exception $e)
- {
- $core->error->add($e->getMessage());
- }
+ try
+ {
+ foreach($_POST['noodle'] as $id => $bloc)
+ {
+ foreach($bloc as $k => $v)
+ {
+ $__noodles->{$id}->set($k,$v);
+ }
+ }
+ $s->put('noodles_object',$__noodles->encode(),'string');
+
+ $core->blog->triggerBlog();
+ http::redirect('plugin.php?p=noodles&tab=blocs&done=1');
+ }
+ catch (Exception $e)
+ {
+ $core->error->add($e->getMessage());
+ }
}
if (!empty($_POST['reset']) && $tab == 'blocs')
{
- try
- {
- $s->put('noodles_object','','string');
- $core->blog->triggerBlog();
- http::redirect('plugin.php?p=noodles&tab=blocs&done=1');
- }
- catch (Exception $e)
- {
- $core->error->add($e->getMessage());
- }
+ try
+ {
+ $s->put('noodles_object','','string');
+ $core->blog->triggerBlog();
+ http::redirect('plugin.php?p=noodles&tab=blocs&done=1');
+ }
+ catch (Exception $e)
+ {
+ $core->error->add($e->getMessage());
+ }
}
echo
@@ -191,48 +192,48 @@ dcPage::jsPageTabs($tab).
# Blocs
if ($s->noodles_active)
{
- echo
- '';
}
# Settings
@@ -242,7 +243,7 @@ echo
'
'.
''.
'