update license and fix new lines, tabs, etc...
This commit is contained in:
parent
f6e9c63d94
commit
557a5db1db
12 changed files with 915 additions and 921 deletions
32
_admin.php
32
_admin.php
|
@ -1,22 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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
|
# Admin menu
|
||||||
$_menu['Plugins']->addItem(
|
$_menu['Plugins']->addItem(
|
||||||
__('Noodles'),
|
__('Noodles'),
|
||||||
'plugin.php?p=noodles','index.php?pf=noodles/icon.png',
|
'plugin.php?p=noodles','index.php?pf=noodles/icon.png',
|
||||||
preg_match('/plugin.php\?p=noodles(&.*)?$/',$_SERVER['REQUEST_URI']),
|
preg_match('/plugin.php\?p=noodles(&.*)?$/',$_SERVER['REQUEST_URI']),
|
||||||
$core->auth->check('admin',$core->blog->id)
|
$core->auth->check('admin',$core->blog->id)
|
||||||
);
|
);
|
||||||
?>
|
|
36
_define.php
36
_define.php
|
@ -1,24 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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;}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
/* Name */ "Noodles",
|
/* Name */ "Noodles",
|
||||||
/* Description*/ "Add users gravatars everywhere",
|
/* Description*/ "Add users gravatars everywhere",
|
||||||
/* Author */ "JC Denis",
|
/* Author */ "JC Denis",
|
||||||
/* Version */ '0.6.1',
|
/* Version */ '0.6.1',
|
||||||
/* Permissions */ 'admin'
|
/* Permissions */ 'admin'
|
||||||
//* Priority */ 10000000
|
//* Priority */ 10000000
|
||||||
);
|
);
|
||||||
/* date */ #20100705
|
/* date */ #20100705
|
||||||
?>
|
|
50
_install.php
50
_install.php
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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;}
|
||||||
|
|
||||||
|
@ -19,22 +20,21 @@ if (version_compare($old_version,$new_version,'>=')) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (version_compare(DC_VERSION,'2.2-beta','<'))
|
if (version_compare(DC_VERSION,'2.2-beta','<'))
|
||||||
{
|
{
|
||||||
throw new Exception('noodles requires Dotclear 2.2');
|
throw new Exception('noodles requires Dotclear 2.2');
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->blog->settings->addNamespace('noodles');
|
$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);
|
$core->setVersion('noodles',$new_version);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
?>
|
|
27
_prepend.php
27
_prepend.php
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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;}
|
||||||
|
|
||||||
|
@ -20,8 +21,6 @@ $__autoload['noodlesLibImagePath'] = dirname(__FILE__).'/inc/lib.image.path.php'
|
||||||
$core->blog->settings->addNamespace('noodles');
|
$core->blog->settings->addNamespace('noodles');
|
||||||
|
|
||||||
$core->url->register('noodlesmodule','noodles','^noodles/(.+)$',
|
$core->url->register('noodlesmodule','noodles','^noodles/(.+)$',
|
||||||
array('urlNoodles','noodles'));
|
array('urlNoodles','noodles'));
|
||||||
$core->url->register('noodlesservice','noodle','^noodle/$',
|
$core->url->register('noodlesservice','noodle','^noodle/$',
|
||||||
array('urlNoodles','service'));
|
array('urlNoodles','service'));
|
||||||
|
|
||||||
?>
|
|
372
_public.php
372
_public.php
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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;}
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ include dirname(__FILE__).'/inc/_default_noodles.php';
|
||||||
require_once dirname(__FILE__).'/inc/_noodles_functions.php';
|
require_once dirname(__FILE__).'/inc/_noodles_functions.php';
|
||||||
|
|
||||||
$core->addBehavior('publicHeadContent',
|
$core->addBehavior('publicHeadContent',
|
||||||
array('publicNoodles','publicHeadContent'));
|
array('publicNoodles','publicHeadContent'));
|
||||||
|
|
||||||
$core->tpl->setPath($core->tpl->getPath(),dirname(__FILE__).'/default-templates');
|
$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);
|
$__noodles = noodles::decode($core->blog->settings->noodles->noodles_object);
|
||||||
|
|
||||||
if ($__noodles->isEmpty())
|
if ($__noodles->isEmpty())
|
||||||
$__noodles = $__default_noodles;
|
$__noodles = $__default_noodles;
|
||||||
|
|
||||||
//$GLOBALS['__noodles'] =& $__noodles;
|
//$GLOBALS['__noodles'] =& $__noodles;
|
||||||
|
|
||||||
foreach($__noodles->noodles() AS $noodle) {
|
foreach($__noodles->noodles() AS $noodle) {
|
||||||
if ($noodle->active && $noodle->hasPhpCallback())
|
if ($noodle->active && $noodle->hasPhpCallback())
|
||||||
$noodle->phpCallback($core);
|
$noodle->phpCallback($core);
|
||||||
}
|
}
|
||||||
|
|
||||||
class publicNoodles
|
class publicNoodles
|
||||||
{
|
{
|
||||||
public static function publicHeadContent($core)
|
public static function publicHeadContent($core)
|
||||||
{
|
{
|
||||||
$__noodles =& $GLOBALS['__noodles'];
|
$__noodles =& $GLOBALS['__noodles'];
|
||||||
|
|
||||||
$css = "\n";
|
$css = "\n";
|
||||||
$targets = array();
|
$targets = array();
|
||||||
foreach($__noodles->noodles() AS $noodle) {
|
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[] =
|
$targets[] =
|
||||||
' $(\''.html::escapeJS($noodle->target).'\').noodles({'.
|
' $(\''.html::escapeJS($noodle->target).'\').noodles({'.
|
||||||
'imgId:\''.html::escapeJS($noodle->id()).'\','.
|
'imgId:\''.html::escapeJS($noodle->id()).'\','.
|
||||||
'imgPlace:\''.html::escapeJS($noodle->place).'\''.
|
'imgPlace:\''.html::escapeJS($noodle->place).'\''.
|
||||||
'});';
|
'});';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($targets)) return;
|
if (empty($targets)) return;
|
||||||
|
|
||||||
echo
|
echo
|
||||||
"\n<!-- CSS for noodles --> \n".
|
"\n<!-- CSS for noodles --> \n".
|
||||||
'<style type="text/css">'.html::escapeHTML($css).'</style>'.
|
'<style type="text/css">'.html::escapeHTML($css).'</style>'.
|
||||||
"\n<!-- JS for noodles --> \n".
|
"\n<!-- JS for noodles --> \n".
|
||||||
"<script type=\"text/javascript\" src=\"".
|
"<script type=\"text/javascript\" src=\"".
|
||||||
$core->blog->url.$core->url->getBase('noodlesmodule')."/js/jquery.noodles.js\"></script> \n".
|
$core->blog->url.$core->url->getBase('noodlesmodule')."/js/jquery.noodles.js\"></script> \n".
|
||||||
"<script type=\"text/javascript\"> \n".
|
"<script type=\"text/javascript\"> \n".
|
||||||
"//<![CDATA[\n".
|
"//<![CDATA[\n".
|
||||||
" \$(function(){if(!document.getElementById){return;} \n".
|
" \$(function(){if(!document.getElementById){return;} \n".
|
||||||
" \$.fn.noodles.defaults.service_url = '".html::escapeJS($core->blog->url.$core->url->getBase('noodlesservice').'/')."'; \n".
|
" \$.fn.noodles.defaults.service_url = '".html::escapeJS($core->blog->url.$core->url->getBase('noodlesservice').'/')."'; \n".
|
||||||
" \$.fn.noodles.defaults.service_func = '".html::escapeJS('getNoodle')."'; \n".
|
" \$.fn.noodles.defaults.service_func = '".html::escapeJS('getNoodle')."'; \n".
|
||||||
implode("\n",$targets)."\n".
|
implode("\n",$targets)."\n".
|
||||||
"})\n".
|
"})\n".
|
||||||
"\n//]]>\n".
|
"\n//]]>\n".
|
||||||
"</script>\n";
|
"</script>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class urlNoodles extends dcUrlHandlers
|
class urlNoodles extends dcUrlHandlers
|
||||||
{
|
{
|
||||||
public static function service($args)
|
public static function service($args)
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
header('Content-Type: text/xml; charset=UTF-8');
|
|
||||||
|
|
||||||
$rsp = new xmlTag('rsp');
|
|
||||||
|
|
||||||
$i = !empty($_POST['noodleId']) ? $_POST['noodleId'] : null;
|
header('Content-Type: text/xml; charset=UTF-8');
|
||||||
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function noodles($args)
|
$rsp = new xmlTag('rsp');
|
||||||
{
|
|
||||||
global $core;
|
|
||||||
|
|
||||||
if (!$core->blog->settings->noodles->noodles_active)
|
$i = !empty($_POST['noodleId']) ? $_POST['noodleId'] : null;
|
||||||
{
|
$c = !empty($_POST['noodleContent']) ? $_POST['noodleContent'] : null;
|
||||||
self::p404();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!preg_match('#^(.*?)$#',$args,$m))
|
if (!$core->blog->settings->noodles->noodles_active)
|
||||||
{
|
{
|
||||||
self::p404();
|
$rsp->status = 'failed';
|
||||||
return;
|
$rsp->message(__('noodles is disabled on this blog'));
|
||||||
}
|
echo $rsp->toXML(1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$f = $m[1];
|
if ($i === null || $c === null)
|
||||||
|
{
|
||||||
if (!($f = self::searchTplFiles($f)))
|
$rsp->status = 'failed';
|
||||||
{
|
$rsp->message(__('noodles failed because of missing informations'));
|
||||||
self::p404();
|
echo $rsp->toXML(1);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowed_types = array('png','jpg','jpeg','gif','css','js','swf');
|
try
|
||||||
if (!in_array(files::getExtension($f),$allowed_types))
|
{
|
||||||
{
|
$__noodles = noodles::decode($core->blog->settings->noodles->noodles_object);
|
||||||
self::p404();
|
|
||||||
return;
|
if ($__noodles->isEmpty())
|
||||||
}
|
{
|
||||||
$type = files::getMimeType($f);
|
$__noodles = $GLOBALS['__default_noodles'];
|
||||||
|
}
|
||||||
header('Content-Type: '.$type.'; charset=UTF-8');
|
}
|
||||||
header('Content-Length: '.filesize($f));
|
catch(Excetpion $e)
|
||||||
|
{
|
||||||
if ($type != "text/css" || $core->blog->settings->system->url_scan == 'path_info')
|
$rsp->status = 'failed';
|
||||||
{
|
$rsp->message(__('Failed to load default noodles'));
|
||||||
readfile($f);
|
echo $rsp->toXML(1);
|
||||||
}
|
return false;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
echo preg_replace('#url\((?!(http:)|/)#','url('.$core->blog->url.$core->url->getBase('noodlesmodule').'/',file_get_contents($f));
|
if (!$__noodles->exists($i))
|
||||||
}
|
{
|
||||||
exit;
|
$rsp->status = 'failed';
|
||||||
}
|
$rsp->message(__('Failed to load noodle'));
|
||||||
|
echo $rsp->toXML(1);
|
||||||
# Search noodles files like JS, CSS in default-templates subdirectories
|
return false;
|
||||||
private static function searchTplFiles($file)
|
}
|
||||||
{
|
|
||||||
if (strstr($file,"..") !== false)
|
$m = $__noodles->{$i}->jsCallback($__noodles->{$i},$c);
|
||||||
{
|
|
||||||
return false;
|
$s = $__noodles->{$i}->size;
|
||||||
}
|
$r = $__noodles->{$i}->rating;
|
||||||
$paths = $GLOBALS['core']->tpl->getPath();
|
$d = $core->blog->settings->noodles->noodles_image ?
|
||||||
|
urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
|
||||||
foreach($paths as $path)
|
|
||||||
{
|
if (!$m) $m = 'nobody@nowhere.tld';
|
||||||
if (preg_match('/tpl(\/|)$/',$path))
|
if (!$s) $s = 32;
|
||||||
{
|
if (!$r) $r = 'g';
|
||||||
$path = path::real($path.'/..');
|
|
||||||
}
|
$m = mb_strtolower($m);
|
||||||
if (file_exists($path.'/'.$file))
|
$m = md5($m);
|
||||||
{
|
|
||||||
return $path.'/'.$file;
|
$im = new xmlTag('noodle');
|
||||||
}
|
$im->size = $s;
|
||||||
}
|
$im->src = 'http://www.gravatar.com/avatar/'.$m.'?s='.$s.'&r='.$r.'&d='.$d;
|
||||||
return false;
|
$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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,44 +1,42 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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;}
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'settings',
|
/* type */ 'settings',
|
||||||
/* action */ 'delete_all',
|
/* action */ 'delete_all',
|
||||||
/* ns */ 'noodles',
|
/* ns */ 'noodles',
|
||||||
/* description */ __('delete all settings')
|
/* description */ __('delete all settings')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'plugins',
|
/* type */ 'plugins',
|
||||||
/* action */ 'delete',
|
/* action */ 'delete',
|
||||||
/* ns */ 'noodles',
|
/* ns */ 'noodles',
|
||||||
/* description */ __('delete plugin files')
|
/* description */ __('delete plugin files')
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$this->addDirectAction(
|
|
||||||
/* type */ 'settings',
|
|
||||||
/* action */ 'delete_all',
|
|
||||||
/* ns */ 'noodles',
|
|
||||||
/* description */ sprintf(__('delete all %s settings'),'noodles')
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
/* type */ 'plugins',
|
/* type */ 'settings',
|
||||||
/* action */ 'delete',
|
/* action */ 'delete_all',
|
||||||
/* ns */ 'noodles',
|
/* ns */ 'noodles',
|
||||||
/* description */ sprintf(__('delete %s plugin files'),'noodles')
|
/* description */ sprintf(__('delete all %s settings'),'noodles')
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
$this->addDirectAction(
|
||||||
|
/* type */ 'plugins',
|
||||||
|
/* action */ 'delete',
|
||||||
|
/* ns */ 'noodles',
|
||||||
|
/* description */ sprintf(__('delete %s plugin files'),'noodles')
|
||||||
|
);
|
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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;}
|
||||||
|
|
||||||
|
@ -35,62 +36,60 @@ $__default_noodles->titlesposts->css = 'margin-right:2px;';
|
||||||
|
|
||||||
if ($core->plugins->moduleExists('widgets')) {
|
if ($core->plugins->moduleExists('widgets')) {
|
||||||
|
|
||||||
# Widget Selected entries
|
# Widget Selected entries
|
||||||
$__default_noodles->add('bestof',__('Selected entries'),array('genericNoodles','postURL'));
|
$__default_noodles->add('bestof',__('Selected entries'),array('genericNoodles','postURL'));
|
||||||
$__default_noodles->bestof->target = '.selected li a';
|
$__default_noodles->bestof->target = '.selected li a';
|
||||||
$__default_noodles->bestof->css = 'margin-right:2px;';
|
$__default_noodles->bestof->css = 'margin-right:2px;';
|
||||||
|
|
||||||
# Widget Last entries
|
# Widget Last entries
|
||||||
$__default_noodles->add('lastposts',__('Last entries'),array('genericNoodles','postURL'));
|
$__default_noodles->add('lastposts',__('Last entries'),array('genericNoodles','postURL'));
|
||||||
$__default_noodles->lastposts->target = '.lastposts li a';
|
$__default_noodles->lastposts->target = '.lastposts li a';
|
||||||
$__default_noodles->lastposts->css = 'margin-right:2px;';
|
$__default_noodles->lastposts->css = 'margin-right:2px;';
|
||||||
|
|
||||||
# Widget Last comments
|
# Widget Last comments
|
||||||
$__default_noodles->add('lastcomments',__('Last comments'),array('widgetsNoodles','lastcomments'));
|
$__default_noodles->add('lastcomments',__('Last comments'),array('widgetsNoodles','lastcomments'));
|
||||||
$__default_noodles->lastcomments->active = true;
|
$__default_noodles->lastcomments->active = true;
|
||||||
$__default_noodles->lastcomments->target = '.lastcomments li a';
|
$__default_noodles->lastcomments->target = '.lastcomments li a';
|
||||||
$__default_noodles->lastcomments->css = 'margin-right:2px;';
|
$__default_noodles->lastcomments->css = 'margin-right:2px;';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plugin auhtorMode
|
# Plugin auhtorMode
|
||||||
if ($core->plugins->moduleExists('authorMode')
|
if ($core->plugins->moduleExists('authorMode')
|
||||||
&& $core->blog->settings->authormode->authormode_active) {
|
&& $core->blog->settings->authormode->authormode_active) {
|
||||||
|
|
||||||
$__default_noodles->add('authorswidget',__('Authors widget'),array('authormodeNoodles','authors'));
|
$__default_noodles->add('authorswidget',__('Authors widget'),array('authormodeNoodles','authors'));
|
||||||
$__default_noodles->authorswidget->target = '#authors ul li a';
|
$__default_noodles->authorswidget->target = '#authors ul li a';
|
||||||
$__default_noodles->authorswidget->css = 'margin-right:2px;';
|
$__default_noodles->authorswidget->css = 'margin-right:2px;';
|
||||||
|
|
||||||
$__default_noodles->add('author',__('Author'),'',array('authormodeNoodles','author'));
|
$__default_noodles->add('author',__('Author'),'',array('authormodeNoodles','author'));
|
||||||
$__default_noodles->author->active = true;
|
$__default_noodles->author->active = true;
|
||||||
$__default_noodles->author->size = 48;
|
$__default_noodles->author->size = 48;
|
||||||
$__default_noodles->author->target = '.dc-author #content-info h2';
|
$__default_noodles->author->target = '.dc-author #content-info h2';
|
||||||
$__default_noodles->author->css = 'clear:left; float:left;margin-right:2px;';
|
$__default_noodles->author->css = 'clear:left; float:left;margin-right:2px;';
|
||||||
|
|
||||||
$__default_noodles->add('authors',__('Authors'),array('authormodeNoodles','authors'));
|
$__default_noodles->add('authors',__('Authors'),array('authormodeNoodles','authors'));
|
||||||
$__default_noodles->authors->active = true;
|
$__default_noodles->authors->active = true;
|
||||||
$__default_noodles->authors->size = 32;
|
$__default_noodles->authors->size = 32;
|
||||||
$__default_noodles->authors->target = '.dc-authors .author-info h2 a';
|
$__default_noodles->authors->target = '.dc-authors .author-info h2 a';
|
||||||
$__default_noodles->authors->css = 'clear:left; float:left; margin:4px;';
|
$__default_noodles->authors->css = 'clear:left; float:left; margin:4px;';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plugin rateIt
|
# Plugin rateIt
|
||||||
if ($core->plugins->moduleExists('rateIt')
|
if ($core->plugins->moduleExists('rateIt')
|
||||||
&& $core->blog->settings->rateit->rateit_active) {
|
&& $core->blog->settings->rateit->rateit_active) {
|
||||||
|
|
||||||
$__default_noodles->add('rateitpostsrank',__('Top rated entries'),array('genericNoodles','postURL'));
|
$__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->target = '.rateitpostsrank.rateittypepost ul li a'; // Only "post" type
|
||||||
$__default_noodles->rateitpostsrank->css = 'margin-right:2px;';
|
$__default_noodles->rateitpostsrank->css = 'margin-right:2px;';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plugin lastpostsExtend
|
# Plugin lastpostsExtend
|
||||||
if ($core->plugins->moduleExists('lastpostsExtend')) {
|
if ($core->plugins->moduleExists('lastpostsExtend')) {
|
||||||
|
|
||||||
$__default_noodles->add('lastpostsextend',__('Last entries (extend)'),array('genericNoodles','postURL'));
|
$__default_noodles->add('lastpostsextend',__('Last entries (extend)'),array('genericNoodles','postURL'));
|
||||||
$__default_noodles->lastpostsextend->target = '.lastpostsextend ul li a';
|
$__default_noodles->lastpostsextend->target = '.lastpostsextend ul li a';
|
||||||
$__default_noodles->lastpostsextend->css = 'margin-right:2px;';
|
$__default_noodles->lastpostsextend->css = 'margin-right:2px;';
|
||||||
}
|
}
|
||||||
|
|
||||||
# --BEHAVIOR-- initDefaultNoodles
|
# --BEHAVIOR-- initDefaultNoodles
|
||||||
$core->callBehavior('initDefaultNoodles',$__default_noodles);
|
$core->callBehavior('initDefaultNoodles',$__default_noodles);
|
||||||
|
|
||||||
?>
|
|
|
@ -1,172 +1,172 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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;}
|
||||||
|
|
||||||
class genericNoodles
|
class genericNoodles
|
||||||
{
|
{
|
||||||
public static function postURL($noodle,$content='')
|
public static function postURL($noodle,$content='')
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
$types = $core->getPostTypes();
|
$types = $core->getPostTypes();
|
||||||
$reg = '@^'.str_replace('%s','(.*?)',
|
$reg = '@^'.str_replace('%s','(.*?)',
|
||||||
preg_quote($core->blog->url.$types['post']['public_url'])).'$@';
|
preg_quote($core->blog->url.$types['post']['public_url'])).'$@';
|
||||||
|
|
||||||
$ok = preg_match($reg,$content,$m);
|
$ok = preg_match($reg,$content,$m);
|
||||||
|
|
||||||
if (!$ok || !$m[1]) return '';
|
if (!$ok || !$m[1]) return '';
|
||||||
|
|
||||||
$rs = $core->blog->getPosts(
|
$rs = $core->blog->getPosts(
|
||||||
array('no_content'=>1,'post_url'=>urldecode($m[1]),'limit'=>1)
|
array('no_content'=>1,'post_url'=>urldecode($m[1]),'limit'=>1)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($rs->isEmpty()) return '';
|
if ($rs->isEmpty()) return '';
|
||||||
|
|
||||||
return $rs->user_email;
|
return $rs->user_email;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
class othersNoodles
|
class othersNoodles
|
||||||
{
|
{
|
||||||
public static function publicPosts($core,$noodle)
|
public static function publicPosts($core,$noodle)
|
||||||
{
|
{
|
||||||
if (!$noodle->active) return;
|
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
|
|
||||||
'<img class="noodles-posts" style="width:'.$s.'px;height:'.$s.'px;'.$c.'"'.
|
|
||||||
'src="http://www.gravatar.com/avatar/'.md5($m).
|
|
||||||
'?s='.$s.'&r='.$r.'&d='.$d.'" alt="" />';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function publicComments($core,$noodle)
|
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
||||||
{
|
'publicEntryBeforeContent' : 'publicEntryAfterContent';
|
||||||
if (!$noodle->active) return;
|
|
||||||
|
$core->addBehavior($bhv,array('othersNoodles','publicEntryContent'));
|
||||||
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
}
|
||||||
'publicCommentBeforeContent' : 'publicCommentAfterContent';
|
|
||||||
|
public static function publicEntryContent()
|
||||||
$core->addBehavior($bhv,array('othersNoodles','publicCommentContent'));
|
{
|
||||||
}
|
global $core,$_ctx,$__noodles;
|
||||||
|
|
||||||
public static function publicCommentContent()
|
$m = $_ctx->posts->getAuthorEmail(false);
|
||||||
{
|
$c = $__noodles->posts->css;
|
||||||
global $core,$_ctx,$__noodles;
|
$s = $__noodles->posts->size;
|
||||||
|
$r = $__noodles->posts->rating;
|
||||||
$m = $_ctx->comments->getEmail(false);
|
$d = $core->blog->settings->noodles->noodles_image ?
|
||||||
$c = $__noodles->comments->css;
|
urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
|
||||||
$s = $__noodles->comments->size;
|
|
||||||
$r = $__noodles->comments->rating;
|
echo
|
||||||
$d = $core->blog->settings->noodles->noodles_image ?
|
'<img class="noodles-posts" style="width:'.$s.'px;height:'.$s.'px;'.$c.'"'.
|
||||||
urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
|
'src="http://www.gravatar.com/avatar/'.md5($m).
|
||||||
|
'?s='.$s.'&r='.$r.'&d='.$d.'" alt="" />';
|
||||||
echo
|
}
|
||||||
'<img class="noodles-comments" style="width:'.$s.'px;height:'.$s.'px;'.$c.'"'.
|
|
||||||
'src="http://www.gravatar.com/avatar/'.md5($m).
|
public static function publicComments($core,$noodle)
|
||||||
'?s='.$s.'&r='.$r.'&d='.$d.'" alt="" />';
|
{
|
||||||
}
|
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
|
||||||
|
'<img class="noodles-comments" style="width:'.$s.'px;height:'.$s.'px;'.$c.'"'.
|
||||||
|
'src="http://www.gravatar.com/avatar/'.md5($m).
|
||||||
|
'?s='.$s.'&r='.$r.'&d='.$d.'" alt="" />';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plugin Widgets
|
# Plugin Widgets
|
||||||
class widgetsNoodles
|
class widgetsNoodles
|
||||||
{
|
{
|
||||||
public static function lastcomments($noodle,$content='')
|
public static function lastcomments($noodle,$content='')
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
$ok = preg_match('@\#c([0-9]+)$@',urldecode($content),$m);
|
$ok = preg_match('@\#c([0-9]+)$@',urldecode($content),$m);
|
||||||
|
|
||||||
if (!$ok || !$m[1]) return '';
|
if (!$ok || !$m[1]) return '';
|
||||||
|
|
||||||
$rs = $core->blog->getComments(
|
$rs = $core->blog->getComments(
|
||||||
array('no_content'=>1,'comment_id'=>$m[1],'limit'=>1)
|
array('no_content'=>1,'comment_id'=>$m[1],'limit'=>1)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$rs->isEmpty()) return $rs->comment_email;
|
if (!$rs->isEmpty()) return $rs->comment_email;
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plugin authorMode
|
# Plugin authorMode
|
||||||
class authormodeNoodles
|
class authormodeNoodles
|
||||||
{
|
{
|
||||||
public static function authors($noodle,$content='')
|
public static function authors($noodle,$content='')
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
$ok = preg_match('@\/([^\/]*?)$@',$content,$m);
|
$ok = preg_match('@\/([^\/]*?)$@',$content,$m);
|
||||||
|
|
||||||
if (!$ok || !$m[1]) return '';
|
if (!$ok || !$m[1]) return '';
|
||||||
|
|
||||||
$rs = $core->getUser($m[1]);
|
$rs = $core->getUser($m[1]);
|
||||||
|
|
||||||
if ($rs->isEmpty()) return '';
|
if ($rs->isEmpty()) return '';
|
||||||
|
|
||||||
return $rs->user_email;
|
return $rs->user_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function author($core,$noodle)
|
public static function author($core,$noodle)
|
||||||
{
|
{
|
||||||
if ($noodle->active)
|
if ($noodle->active)
|
||||||
{
|
{
|
||||||
$core->addBehavior('publicHeadContent',
|
$core->addBehavior('publicHeadContent',
|
||||||
array('authormodeNoodles','publicHeadContent'));
|
array('authormodeNoodles','publicHeadContent'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function publicHeadContent()
|
public static function publicHeadContent()
|
||||||
{
|
{
|
||||||
global $core,$_ctx,$__noodles;
|
global $core,$_ctx,$__noodles;
|
||||||
|
|
||||||
if ($_ctx->current_tpl != 'author.html') return;
|
if ($_ctx->current_tpl != 'author.html') return;
|
||||||
|
|
||||||
$id = $_ctx->users->user_id;
|
$id = $_ctx->users->user_id;
|
||||||
$u = $core->getUser($id);
|
$u = $core->getUser($id);
|
||||||
$m = $u->user_email;
|
$m = $u->user_email;
|
||||||
$c = $__noodles->author->css;
|
$c = $__noodles->author->css;
|
||||||
$s = $__noodles->author->size;
|
$s = $__noodles->author->size;
|
||||||
$r = $__noodles->author->rating;
|
$r = $__noodles->author->rating;
|
||||||
$d = $core->blog->settings->noodles->noodles_image ?
|
$d = $core->blog->settings->noodles->noodles_image ?
|
||||||
urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
|
urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<script type="text/javascript">'."\n".
|
'<script type="text/javascript">'."\n".
|
||||||
"//<![CDATA[\n".
|
"//<![CDATA[\n".
|
||||||
"$(function(){if(!document.getElementById){return;}\n".
|
"$(function(){if(!document.getElementById){return;}\n".
|
||||||
"$('".$__noodles->author->target."').".$__noodles->author->place."('".
|
"$('".$__noodles->author->target."').".$__noodles->author->place."('".
|
||||||
'<img class="noodles-comments" style="width:'.$s.'px;height:'.$s.'px;'.$c.'"'.
|
'<img class="noodles-comments" style="width:'.$s.'px;height:'.$s.'px;'.$c.'"'.
|
||||||
'src="http://www.gravatar.com/avatar/'.md5($m).
|
'src="http://www.gravatar.com/avatar/'.md5($m).
|
||||||
'?s='.$s.'&r='.$r.'&d='.$d.'" alt="" />'.
|
'?s='.$s.'&r='.$r.'&d='.$d.'" alt="" />'.
|
||||||
"');});".
|
"');});".
|
||||||
"\n//]]>\n".
|
"\n//]]>\n".
|
||||||
"</script>\n";
|
"</script>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -1,166 +1,166 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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;}
|
||||||
|
|
||||||
class noodles
|
class noodles
|
||||||
{
|
{
|
||||||
private $noodles = array();
|
private $noodles = array();
|
||||||
|
|
||||||
public static function decode($s)
|
public static function decode($s)
|
||||||
{
|
{
|
||||||
$o = @unserialize(base64_decode($s));
|
$o = @unserialize(base64_decode($s));
|
||||||
if ($o instanceof self) return $o;
|
if ($o instanceof self) return $o;
|
||||||
return new self;
|
return new self;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function encode()
|
public function encode()
|
||||||
{
|
{
|
||||||
return base64_encode(serialize($this));
|
return base64_encode(serialize($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($id,$name,$js_callback,$php_callback=null)
|
public function add($id,$name,$js_callback,$php_callback=null)
|
||||||
{
|
{
|
||||||
$this->noodles[$id] = new noodle($id,$name,$js_callback,$php_callback);
|
$this->noodles[$id] = new noodle($id,$name,$js_callback,$php_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __get($id)
|
public function __get($id)
|
||||||
{
|
{
|
||||||
return isset($this->noodles[$id]) ? $this->noodles[$id] : null;
|
return isset($this->noodles[$id]) ? $this->noodles[$id] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __set($id,$noodle)
|
public function __set($id,$noodle)
|
||||||
{
|
{
|
||||||
return $this->noodles[$id] = $noodle;
|
return $this->noodles[$id] = $noodle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exists($id)
|
public function exists($id)
|
||||||
{
|
{
|
||||||
return isset($this->noodles[$id]);
|
return isset($this->noodles[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isEmpty()
|
public function isEmpty()
|
||||||
{
|
{
|
||||||
return !count($this->noodles);
|
return !count($this->noodles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function noodles()
|
public function noodles()
|
||||||
{
|
{
|
||||||
return $this->noodles;
|
return $this->noodles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class noodle
|
class noodle
|
||||||
{
|
{
|
||||||
private $id;
|
private $id;
|
||||||
private $name;
|
private $name;
|
||||||
private $js_callback;
|
private $js_callback;
|
||||||
private $php_callback;
|
private $php_callback;
|
||||||
private $settings = array(
|
private $settings = array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'rating' => 'g',
|
'rating' => 'g',
|
||||||
'size' => 16,
|
'size' => 16,
|
||||||
'target' => '',
|
'target' => '',
|
||||||
'place' => 'prepend'
|
'place' => 'prepend'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function __construct($id,$name,$js_callback,$php_callback=null)
|
public function __construct($id,$name,$js_callback,$php_callback=null)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->js_callback = $js_callback;
|
$this->js_callback = $js_callback;
|
||||||
$this->php_callback = $php_callback;
|
$this->php_callback = $php_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function id()
|
public function id()
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function name()
|
public function name()
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsCallback($g,$content='')
|
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);
|
return call_user_func($this->js_callback,$g,$content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasJsCallback()
|
public function hasJsCallback()
|
||||||
{
|
{
|
||||||
return !empty($this->js_callback);
|
return !empty($this->js_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function phpCallback($core)
|
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);
|
return call_user_func($this->php_callback,$core,$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasPhpCallback()
|
public function hasPhpCallback()
|
||||||
{
|
{
|
||||||
return !empty($this->php_callback);
|
return !empty($this->php_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set($type,$value)
|
public function set($type,$value)
|
||||||
{
|
{
|
||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
case 'active':
|
case 'active':
|
||||||
$this->settings['active'] = abs((integer) $value);
|
$this->settings['active'] = abs((integer) $value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'rating':
|
case 'rating':
|
||||||
$this->settings['rating'] = in_array($value,array('g','pg','r','x')) ?
|
$this->settings['rating'] = in_array($value,array('g','pg','r','x')) ?
|
||||||
$value : 'g';
|
$value : 'g';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'size':
|
case 'size':
|
||||||
$this->settings['size'] =
|
$this->settings['size'] =
|
||||||
in_array($value,array(16,24,32,48,56,64,92,128,256)) ?
|
in_array($value,array(16,24,32,48,56,64,92,128,256)) ?
|
||||||
$value : 16;
|
$value : 16;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'css':
|
case 'css':
|
||||||
$this->settings['css'] = (string) $value;
|
$this->settings['css'] = (string) $value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'target':
|
case 'target':
|
||||||
$this->settings['target'] = (string) $value;
|
$this->settings['target'] = (string) $value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'place':
|
case 'place':
|
||||||
$this->settings['place'] =
|
$this->settings['place'] =
|
||||||
in_array($value,array('append','prepend','before','after')) ?
|
in_array($value,array('append','prepend','before','after')) ?
|
||||||
$value : 'prepend';
|
$value : 'prepend';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __set($type,$value)
|
public function __set($type,$value)
|
||||||
{
|
{
|
||||||
$this->set($type,$value);
|
$this->set($type,$value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($type)
|
public function get($type)
|
||||||
{
|
{
|
||||||
return isset($this->settings[$type]) ? $this->settings[$type] : null;
|
return isset($this->settings[$type]) ? $this->settings[$type] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __get($type)
|
public function __get($type)
|
||||||
{
|
{
|
||||||
return $this->get($type);
|
return $this->get($type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -1,74 +1,74 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
|
|
||||||
class noodlesLibImagePath
|
class noodlesLibImagePath
|
||||||
{
|
{
|
||||||
public static $version = '1.1';
|
public static $version = '1.1';
|
||||||
|
|
||||||
public static function getArray($core,$m='')
|
public static function getArray($core,$m='')
|
||||||
{
|
{
|
||||||
if (!$core->plugins->moduleExists($m)
|
if (!$core->plugins->moduleExists($m)
|
||||||
|| !$core->url->getBase($m.'module')) {
|
|| !$core->url->getBase($m.'module')) {
|
||||||
return array(
|
return array(
|
||||||
'theme'=>array('dir'=>null,'url'=>null),
|
'theme'=>array('dir'=>null,'url'=>null),
|
||||||
'public'=>array('dir'=>null,'url'=>null),
|
'public'=>array('dir'=>null,'url'=>null),
|
||||||
'module'=>array('dir'=>null,'url'=>null),
|
'module'=>array('dir'=>null,'url'=>null),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'theme' => array(
|
'theme' => array(
|
||||||
'dir' => $core->blog->themes_path.'/'.$core->blog->settings->system->theme.'/img/'.$m.'-default-image.png',
|
'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'
|
'url' => $core->blog->settings->system->themes_url.$core->blog->settings->system->theme.'/img/'.$m.'-default-image.png'
|
||||||
),
|
),
|
||||||
'public' => array(
|
'public' => array(
|
||||||
'dir' => $core->blog->public_path.'/'.$m.'-default-image.png',
|
'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'
|
'url' => $core->blog->host.path::clean($core->blog->settings->system->public_url).'/'.$m.'-default-image.png'
|
||||||
),
|
),
|
||||||
'module' => array(
|
'module' => array(
|
||||||
'dir' => $core->plugins->moduleRoot($m).'/default-templates/img/'.$m.'-default-image.png',
|
'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'
|
'url' => $core->blog->url.$core->url->getBase($m.'module').'/img/'.$m.'-default-image.png'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUrl($core,$m='')
|
public static function getUrl($core,$m='')
|
||||||
{
|
{
|
||||||
$files = self::getArray($core,$m);
|
$files = self::getArray($core,$m);
|
||||||
foreach($files as $k => $file) {
|
foreach($files as $k => $file) {
|
||||||
if (file_exists($files[$k]['dir']))
|
if (file_exists($files[$k]['dir']))
|
||||||
return $files[$k]['url'];
|
return $files[$k]['url'];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPath($core,$m='')
|
public static function getPath($core,$m='')
|
||||||
{
|
{
|
||||||
$files = self::getArray($core,$m);
|
$files = self::getArray($core,$m);
|
||||||
foreach($files as $k => $file) {
|
foreach($files as $k => $file) {
|
||||||
if (file_exists($files[$k]['dir']))
|
if (file_exists($files[$k]['dir']))
|
||||||
return $files[$k]['dir'];
|
return $files[$k]['dir'];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSize($core,$m='')
|
public static function getSize($core,$m='')
|
||||||
{
|
{
|
||||||
if (!($img = self::getPath($core,$m)))
|
if (!($img = self::getPath($core,$m)))
|
||||||
return array('w'=>16,'h'=>16);
|
return array('w'=>16,'h'=>16);
|
||||||
else {
|
else {
|
||||||
$info = getimagesize($img);
|
$info = getimagesize($img);
|
||||||
return array('w'=>$info[0],'h'=>floor($info[1] /3));
|
return array('w'=>$info[0],'h'=>floor($info[1] /3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
424
index.php
424
index.php
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
/**
|
||||||
# This file is part of noodles, a plugin for Dotclear 2.
|
* @brief noodles, a for Dotclear 2
|
||||||
#
|
*
|
||||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
* @package Dotclear
|
||||||
# jcdenis@gdwd.com
|
* @subpackage \u
|
||||||
#
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author JC Denis
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
* @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;}
|
||||||
|
|
||||||
|
@ -26,155 +27,155 @@ $__noodles = noodles::decode($s->noodles_object);
|
||||||
|
|
||||||
if ($__noodles->isEmpty())
|
if ($__noodles->isEmpty())
|
||||||
{
|
{
|
||||||
$__noodles = $__default_noodles;
|
$__noodles = $__default_noodles;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$default_noodles_array = $__default_noodles->noodles();
|
$default_noodles_array = $__default_noodles->noodles();
|
||||||
foreach($default_noodles_array AS $id => $noodle)
|
foreach($default_noodles_array AS $id => $noodle)
|
||||||
{
|
{
|
||||||
if ($__noodles->exists($id)) continue;
|
if ($__noodles->exists($id)) continue;
|
||||||
$__noodles->{$id} = $noodle;
|
$__noodles->{$id} = $noodle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$s->noodles_active)
|
if (!$s->noodles_active)
|
||||||
{
|
{
|
||||||
$tab = 'settings';
|
$tab = 'settings';
|
||||||
}
|
}
|
||||||
|
|
||||||
$default_avatars_images = files::scandir(dirname(__FILE__).'/default-templates/img/');
|
$default_avatars_images = files::scandir(dirname(__FILE__).'/default-templates/img/');
|
||||||
$avatar_paths = noodlesLibImagePath::getArray($core,'noodles');
|
$avatar_paths = noodlesLibImagePath::getArray($core,'noodles');
|
||||||
|
|
||||||
$combo_active = array(
|
$combo_active = array(
|
||||||
__('no') => 0,
|
__('no') => 0,
|
||||||
__('yes') => 1
|
__('yes') => 1
|
||||||
);
|
);
|
||||||
$combo_place = array(
|
$combo_place = array(
|
||||||
__('Begin') => 'prepend',
|
__('Begin') => 'prepend',
|
||||||
__('End') => 'append',
|
__('End') => 'append',
|
||||||
__('Before') => 'before',
|
__('Before') => 'before',
|
||||||
__('After') => 'after'
|
__('After') => 'after'
|
||||||
);
|
);
|
||||||
$combo_rating = array(
|
$combo_rating = array(
|
||||||
'G'=>'g',
|
'G'=>'g',
|
||||||
'PG'=>'pg',
|
'PG'=>'pg',
|
||||||
'R'=>'r',
|
'R'=>'r',
|
||||||
'X'=>'x'
|
'X'=>'x'
|
||||||
);
|
);
|
||||||
$combo_size = array(
|
$combo_size = array(
|
||||||
'16px'=>16,
|
'16px'=>16,
|
||||||
'24px'=>24,
|
'24px'=>24,
|
||||||
'32px'=>32,
|
'32px'=>32,
|
||||||
'48px'=>48,
|
'48px'=>48,
|
||||||
'56px'=>56,
|
'56px'=>56,
|
||||||
'64px'=>64,
|
'64px'=>64,
|
||||||
'92px'=>92,
|
'92px'=>92,
|
||||||
'128px'=>128,
|
'128px'=>128,
|
||||||
'256px'=>256
|
'256px'=>256
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!empty($_POST['save']) && $tab == 'settings')
|
if (!empty($_POST['save']) && $tab == 'settings')
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$s->put('noodles_active',$_POST['noodles_active'],'boolean');
|
$s->put('noodles_active',$_POST['noodles_active'],'boolean');
|
||||||
|
|
||||||
# Destination image according to noodlesLibImagePath()
|
# Destination image according to noodlesLibImagePath()
|
||||||
$dest_file = DC_ROOT.'/'.$s->public_path.'/noodles-default-image.png';
|
$dest_file = DC_ROOT.'/'.$s->public_path.'/noodles-default-image.png';
|
||||||
|
|
||||||
# user upload image
|
# user upload image
|
||||||
if ($_POST['noodles_image'] == 'user')
|
if ($_POST['noodles_image'] == 'user')
|
||||||
{
|
{
|
||||||
if (2 == $_FILES['noodlesuserfile']['error'])
|
if (2 == $_FILES['noodlesuserfile']['error'])
|
||||||
{
|
{
|
||||||
throw new Exception(__('Maximum file size exceeded'));
|
throw new Exception(__('Maximum file size exceeded'));
|
||||||
}
|
}
|
||||||
if ($_FILES['noodlesuserfile']['type'] != 'image/x-png')
|
if ($_FILES['noodlesuserfile']['type'] != 'image/x-png')
|
||||||
{
|
{
|
||||||
throw new Exception(__('Image must be in png format'));
|
throw new Exception(__('Image must be in png format'));
|
||||||
}
|
}
|
||||||
if (0 != $_FILES['noodlesuserfile']['error'])
|
if (0 != $_FILES['noodlesuserfile']['error'])
|
||||||
{
|
{
|
||||||
throw new Exception(__('Something went wrong while download file'));
|
throw new Exception(__('Something went wrong while download file'));
|
||||||
}
|
}
|
||||||
if ($_FILES['noodlesuserfile']['type'] != 'image/x-png')
|
if ($_FILES['noodlesuserfile']['type'] != 'image/x-png')
|
||||||
{
|
{
|
||||||
throw new Exception(__('Image must be in png format'));
|
throw new Exception(__('Image must be in png format'));
|
||||||
}
|
}
|
||||||
if (move_uploaded_file($_FILES['noodlesuserfile']['tmp_name'],$dest_file))
|
if (move_uploaded_file($_FILES['noodlesuserfile']['tmp_name'],$dest_file))
|
||||||
{
|
{
|
||||||
$s->put('noodles_image',1,'boolean');
|
$s->put('noodles_image',1,'boolean');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Default gravatar.com avatar
|
# Default gravatar.com avatar
|
||||||
elseif ($_POST['noodles_image'] == 'gravatar.com')
|
elseif ($_POST['noodles_image'] == 'gravatar.com')
|
||||||
{
|
{
|
||||||
$s->put('noodles_image',0,'boolean');
|
$s->put('noodles_image',0,'boolean');
|
||||||
}
|
}
|
||||||
# existsing noodles image on blog
|
# existsing noodles image on blog
|
||||||
elseif ($_POST['noodles_image'] == 'existsing')
|
elseif ($_POST['noodles_image'] == 'existsing')
|
||||||
{
|
{
|
||||||
$s->put('noodles_image',1,'boolean');
|
$s->put('noodles_image',1,'boolean');
|
||||||
}
|
}
|
||||||
# noodles image
|
# noodles image
|
||||||
elseif (preg_match('/^gravatar-[0-9]+.png$/',$_POST['noodles_image']))
|
elseif (preg_match('/^gravatar-[0-9]+.png$/',$_POST['noodles_image']))
|
||||||
{
|
{
|
||||||
$source = dirname(__FILE__).'/default-templates/img/'.$_POST['noodles_image'];
|
$source = dirname(__FILE__).'/default-templates/img/'.$_POST['noodles_image'];
|
||||||
|
|
||||||
if (!file_exists($source))
|
if (!file_exists($source))
|
||||||
{
|
{
|
||||||
throw new Exception(__('Something went wrong while search file'));
|
throw new Exception(__('Something went wrong while search file'));
|
||||||
}
|
}
|
||||||
if (file_put_contents($dest_file,file_get_contents($source)))
|
if (file_put_contents($dest_file,file_get_contents($source)))
|
||||||
{
|
{
|
||||||
$s->put('noodles_image',1,'boolean');
|
$s->put('noodles_image',1,'boolean');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
http::redirect('plugin.php?p=noodles&tab=settings&done=1');
|
http::redirect('plugin.php?p=noodles&tab=settings&done=1');
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['save']) && $tab == 'blocs' && !empty($_POST['noodle']))
|
if (!empty($_POST['save']) && $tab == 'blocs' && !empty($_POST['noodle']))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach($_POST['noodle'] as $id => $bloc)
|
foreach($_POST['noodle'] as $id => $bloc)
|
||||||
{
|
{
|
||||||
foreach($bloc as $k => $v)
|
foreach($bloc as $k => $v)
|
||||||
{
|
{
|
||||||
$__noodles->{$id}->set($k,$v);
|
$__noodles->{$id}->set($k,$v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$s->put('noodles_object',$__noodles->encode(),'string');
|
$s->put('noodles_object',$__noodles->encode(),'string');
|
||||||
|
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
http::redirect('plugin.php?p=noodles&tab=blocs&done=1');
|
http::redirect('plugin.php?p=noodles&tab=blocs&done=1');
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['reset']) && $tab == 'blocs')
|
if (!empty($_POST['reset']) && $tab == 'blocs')
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$s->put('noodles_object','','string');
|
$s->put('noodles_object','','string');
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
http::redirect('plugin.php?p=noodles&tab=blocs&done=1');
|
http::redirect('plugin.php?p=noodles&tab=blocs&done=1');
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@ -191,48 +192,48 @@ dcPage::jsPageTabs($tab).
|
||||||
# Blocs
|
# Blocs
|
||||||
if ($s->noodles_active)
|
if ($s->noodles_active)
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<div class="multi-part" id="blocs" title="'.__('Controls').'">'.
|
'<div class="multi-part" id="blocs" title="'.__('Controls').'">'.
|
||||||
'<form method="post" action="plugin.php">'.
|
'<form method="post" action="plugin.php">'.
|
||||||
'<table><thead><tr>'.
|
'<table><thead><tr>'.
|
||||||
'<th class="nowrap">'.__('Name').'</th>'.
|
'<th class="nowrap">'.__('Name').'</th>'.
|
||||||
'<th class="nowrap">'.__('Enable').'</th>'.
|
'<th class="nowrap">'.__('Enable').'</th>'.
|
||||||
'<th class="nowrap">'.__('Size').'</th>'.
|
'<th class="nowrap">'.__('Size').'</th>'.
|
||||||
'<th class="nowrap">'.__('Rating').'</th>'.
|
'<th class="nowrap">'.__('Rating').'</th>'.
|
||||||
'<th class="nowrap">'.__('PHP').'</th>'.
|
'<th class="nowrap">'.__('PHP').'</th>'.
|
||||||
'<th class="nowrap">'.__('JS').'</th>'.
|
'<th class="nowrap">'.__('JS').'</th>'.
|
||||||
'<th class="nowrap">'.__('JS target').'</th>'.
|
'<th class="nowrap">'.__('JS target').'</th>'.
|
||||||
'<th class="nowrap">'.__('JS place').'</th>'.
|
'<th class="nowrap">'.__('JS place').'</th>'.
|
||||||
'<th class="nowrap">'.__('Adjust avatar CSS').'</th>'.
|
'<th class="nowrap">'.__('Adjust avatar CSS').'</th>'.
|
||||||
'</tr></thead>';
|
'</tr></thead>';
|
||||||
|
|
||||||
foreach($__noodles->noodles() as $noodle)
|
foreach($__noodles->noodles() as $noodle)
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<tr class="line">'.
|
'<tr class="line">'.
|
||||||
'<td class="nowrap">'.$noodle->name().'</td>'.
|
'<td class="nowrap">'.$noodle->name().'</td>'.
|
||||||
'<td>'.form::combo(array('noodle['.$noodle->id().'][active]'),$combo_active,$noodle->active).'</td>'.
|
'<td>'.form::combo(array('noodle['.$noodle->id().'][active]'),$combo_active,$noodle->active).'</td>'.
|
||||||
'<td>'.form::combo(array('noodle['.$noodle->id().'][size]'),$combo_size,$noodle->size).'</td>'.
|
'<td>'.form::combo(array('noodle['.$noodle->id().'][size]'),$combo_size,$noodle->size).'</td>'.
|
||||||
'<td>'.form::combo(array('noodle['.$noodle->id().'][rating]'),$combo_rating,$noodle->rating).'</td>'.
|
'<td>'.form::combo(array('noodle['.$noodle->id().'][rating]'),$combo_rating,$noodle->rating).'</td>'.
|
||||||
'<td>'.($noodle->hasPhpCallback() ? $img_green : $img_red).'</td>'.
|
'<td>'.($noodle->hasPhpCallback() ? $img_green : $img_red).'</td>'.
|
||||||
'<td>'.$img_green.'</td>'.
|
'<td>'.$img_green.'</td>'.
|
||||||
'<td>'.form::field(array('noodle['.$noodle->id().'][target]'),20,255,$noodle->target).'</td>'.
|
'<td>'.form::field(array('noodle['.$noodle->id().'][target]'),20,255,$noodle->target).'</td>'.
|
||||||
'<td>'.form::combo(array('noodle['.$noodle->id().'][place]'),$combo_place,$noodle->place).'</td>'.
|
'<td>'.form::combo(array('noodle['.$noodle->id().'][place]'),$combo_place,$noodle->place).'</td>'.
|
||||||
'<td class="maximal">'.
|
'<td class="maximal">'.
|
||||||
form::textArea(array('noodle['.$noodle->id().'][css]'),50,2,$noodle->css).
|
form::textArea(array('noodle['.$noodle->id().'][css]'),50,2,$noodle->css).
|
||||||
' .noodles-'.$noodle->id().'{}</td>'.
|
' .noodles-'.$noodle->id().'{}</td>'.
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
echo
|
echo
|
||||||
'</table>'.
|
'</table>'.
|
||||||
'<p>'.
|
'<p>'.
|
||||||
form::hidden(array('p'),'noodles').
|
form::hidden(array('p'),'noodles').
|
||||||
form::hidden(array('tab'),'blocs').
|
form::hidden(array('tab'),'blocs').
|
||||||
$core->formNonce().
|
$core->formNonce().
|
||||||
'<input type="submit" name="save" value="'.__('Save').'" /> '.
|
'<input type="submit" name="save" value="'.__('Save').'" /> '.
|
||||||
'<input type="submit" name="reset" value="'.__('Reset').'" /></p>'.
|
'<input type="submit" name="reset" value="'.__('Reset').'" /></p>'.
|
||||||
'</form>'.
|
'</form>'.
|
||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
|
@ -242,7 +243,7 @@ echo
|
||||||
'<fieldset id="settings-plugin"><legend>'.__('Options').'</legend>'.
|
'<fieldset id="settings-plugin"><legend>'.__('Options').'</legend>'.
|
||||||
'<p class="field"><label>'.
|
'<p class="field"><label>'.
|
||||||
form::combo(array('noodles_active'),$combo_active,$s->noodles_active).' '.
|
form::combo(array('noodles_active'),$combo_active,$s->noodles_active).' '.
|
||||||
__('Enable plugin').'</label></p>'.
|
__('Enable plugin').'</label></p>'.
|
||||||
|
|
||||||
'</fieldset>'.
|
'</fieldset>'.
|
||||||
'<fieldset id="setting-avatar"><legend>'.__('Default avatar').'</legend>'.
|
'<fieldset id="setting-avatar"><legend>'.__('Default avatar').'</legend>'.
|
||||||
|
@ -261,53 +262,53 @@ __('gravatar.com default image').'</label></td>'.
|
||||||
|
|
||||||
if (!$default)
|
if (!$default)
|
||||||
{
|
{
|
||||||
$exists = false;
|
$exists = false;
|
||||||
|
|
||||||
// then use theme image
|
// then use theme image
|
||||||
if (file_exists($avatar_paths['theme']['dir']))
|
if (file_exists($avatar_paths['theme']['dir']))
|
||||||
{
|
{
|
||||||
$exists = $avatar_paths['theme'];
|
$exists = $avatar_paths['theme'];
|
||||||
}
|
}
|
||||||
// then public image
|
// then public image
|
||||||
elseif (file_exists($avatar_paths['public']['dir']))
|
elseif (file_exists($avatar_paths['public']['dir']))
|
||||||
{
|
{
|
||||||
$exists = $avatar_paths['public'];
|
$exists = $avatar_paths['public'];
|
||||||
}
|
}
|
||||||
// then module
|
// then module
|
||||||
elseif (file_exists($avatar_paths['module']['dir']))
|
elseif (file_exists($avatar_paths['module']['dir']))
|
||||||
{
|
{
|
||||||
$exists = $avatar_paths['module'];
|
$exists = $avatar_paths['module'];
|
||||||
}
|
}
|
||||||
if ($exists)
|
if ($exists)
|
||||||
{
|
{
|
||||||
$sz = getimagesize($exists['dir']);
|
$sz = getimagesize($exists['dir']);
|
||||||
$sz[2] = files::size(filesize($exists['dir']));
|
$sz[2] = files::size(filesize($exists['dir']));
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<tr class="line">'.
|
'<tr class="line">'.
|
||||||
'<td><label class="classic">'.form::radio(array('noodles_image'),'existing',1).
|
'<td><label class="classic">'.form::radio(array('noodles_image'),'existing',1).
|
||||||
basename($exists['dir']).'</label></td>'.
|
basename($exists['dir']).'</label></td>'.
|
||||||
'<td><img src="'.$exists['url'].'" alt="" /></td>'.
|
'<td><img src="'.$exists['url'].'" alt="" /></td>'.
|
||||||
'<td>'.$sz[0].'x'.$sz[1].'<br />'.$sz[2].'</td>'.
|
'<td>'.$sz[0].'x'.$sz[1].'<br />'.$sz[2].'</td>'.
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// noodles avatars
|
// noodles avatars
|
||||||
sort($default_avatars_images);
|
sort($default_avatars_images);
|
||||||
foreach($default_avatars_images AS $f)
|
foreach($default_avatars_images AS $f)
|
||||||
{
|
{
|
||||||
if (!preg_match('/gravatar-[0-9]+.png/',$f)) continue;
|
if (!preg_match('/gravatar-[0-9]+.png/',$f)) continue;
|
||||||
$sz = getimagesize(dirname(__FILE__).'/default-templates/img/'.$f);
|
$sz = getimagesize(dirname(__FILE__).'/default-templates/img/'.$f);
|
||||||
$sz[2] = files::size(filesize(dirname(__FILE__).'/default-templates/img/'.$f));
|
$sz[2] = files::size(filesize(dirname(__FILE__).'/default-templates/img/'.$f));
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<tr class="line">'.
|
'<tr class="line">'.
|
||||||
'<td><label class="classic">'.form::radio(array('noodles_image'),$f).
|
'<td><label class="classic">'.form::radio(array('noodles_image'),$f).
|
||||||
basename($f).'</label></td>'.
|
basename($f).'</label></td>'.
|
||||||
'<td><img src="index.php?pf=noodles/default-templates/img/'.$f.'" alt="" /></td>'.
|
'<td><img src="index.php?pf=noodles/default-templates/img/'.$f.'" alt="" /></td>'.
|
||||||
'<td>'.$sz[0].'x'.$sz[1].'<br />'.$sz[2].'</td>'.
|
'<td>'.$sz[0].'x'.$sz[1].'<br />'.$sz[2].'</td>'.
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// user upload avatar
|
// user upload avatar
|
||||||
|
@ -315,7 +316,7 @@ echo
|
||||||
'<tr class="line">'.
|
'<tr class="line">'.
|
||||||
'<td>'.form::radio(array('noodles_image'),'user').'</td>'.
|
'<td>'.form::radio(array('noodles_image'),'user').'</td>'.
|
||||||
'<td colspan="2">'.form::hidden(array('MAX_FILE_SIZE'),30000).
|
'<td colspan="2">'.form::hidden(array('MAX_FILE_SIZE'),30000).
|
||||||
'<input type="file" name="noodlesuserfile" /> *</td>'.
|
'<input type="file" name="noodlesuserfile" /> *</td>'.
|
||||||
'</tr>'.
|
'</tr>'.
|
||||||
'</table>'.
|
'</table>'.
|
||||||
'<p class="form-note">* '.__('Image must be in "png" format and have a maximum file size of 30Ko').'</p>'.
|
'<p class="form-note">* '.__('Image must be in "png" format and have a maximum file size of 30Ko').'</p>'.
|
||||||
|
@ -335,5 +336,4 @@ echo
|
||||||
noodles - '.$core->plugins->moduleInfo('noodles','version').'
|
noodles - '.$core->plugins->moduleInfo('noodles','version').'
|
||||||
<img alt="'.__('Noodles').'" src="index.php?pf=noodles/icon.png" />
|
<img alt="'.__('Noodles').'" src="index.php?pf=noodles/icon.png" />
|
||||||
</p>
|
</p>
|
||||||
</body></html>';
|
</body></html>';
|
||||||
?>
|
|
|
@ -78,6 +78,4 @@ $GLOBALS['__l10n']['size'] = 'taille';
|
||||||
$GLOBALS['__l10n']['gravatar.com default image'] = 'Image par défaut de gravatar.com';
|
$GLOBALS['__l10n']['gravatar.com default image'] = 'Image par défaut de gravatar.com';
|
||||||
|
|
||||||
#index.php:321
|
#index.php:321
|
||||||
$GLOBALS['__l10n']['Image must be in "png" format and have a maximum file size of 30Ko'] = 'L\'image doit être au format "png" et avoir une taille maximum de 30Ko';
|
$GLOBALS['__l10n']['Image must be in "png" format and have a maximum file size of 30Ko'] = 'L\'image doit être au format "png" et avoir une taille maximum de 30Ko';
|
||||||
|
|
||||||
?>
|
|
Loading…
Reference in a new issue