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
30
_admin.php
30
_admin.php
|
@ -1,22 +1,22 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')){return;}
|
||||
|
||||
# Admin menu
|
||||
$_menu['Plugins']->addItem(
|
||||
__('Noodles'),
|
||||
'plugin.php?p=noodles','index.php?pf=noodles/icon.png',
|
||||
preg_match('/plugin.php\?p=noodles(&.*)?$/',$_SERVER['REQUEST_URI']),
|
||||
$core->auth->check('admin',$core->blog->id)
|
||||
__('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)
|
||||
);
|
||||
?>
|
36
_define.php
36
_define.php
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')){return;}
|
||||
|
||||
$this->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
|
||||
?>
|
||||
/* date */ #20100705
|
40
_install.php
40
_install.php
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')){return;}
|
||||
|
||||
|
@ -19,22 +20,21 @@ if (version_compare($old_version,$new_version,'>=')) return;
|
|||
|
||||
try
|
||||
{
|
||||
if (version_compare(DC_VERSION,'2.2-beta','<'))
|
||||
{
|
||||
throw new Exception('noodles requires Dotclear 2.2');
|
||||
}
|
||||
if (version_compare(DC_VERSION,'2.2-beta','<'))
|
||||
{
|
||||
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)
|
||||
{
|
||||
$core->error->add($e->getMessage());
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
return false;
|
||||
?>
|
27
_prepend.php
27
_prepend.php
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
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->url->register('noodlesmodule','noodles','^noodles/(.+)$',
|
||||
array('urlNoodles','noodles'));
|
||||
array('urlNoodles','noodles'));
|
||||
$core->url->register('noodlesservice','noodle','^noodle/$',
|
||||
array('urlNoodles','service'));
|
||||
|
||||
?>
|
||||
array('urlNoodles','service'));
|
332
_public.php
332
_public.php
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
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';
|
||||
|
||||
$core->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<!-- CSS for noodles --> \n".
|
||||
'<style type="text/css">'.html::escapeHTML($css).'</style>'.
|
||||
"\n<!-- JS for noodles --> \n".
|
||||
"<script type=\"text/javascript\" src=\"".
|
||||
$core->blog->url.$core->url->getBase('noodlesmodule')."/js/jquery.noodles.js\"></script> \n".
|
||||
"<script type=\"text/javascript\"> \n".
|
||||
"//<![CDATA[\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_func = '".html::escapeJS('getNoodle')."'; \n".
|
||||
implode("\n",$targets)."\n".
|
||||
"})\n".
|
||||
"\n//]]>\n".
|
||||
"</script>\n";
|
||||
}
|
||||
echo
|
||||
"\n<!-- CSS for noodles --> \n".
|
||||
'<style type="text/css">'.html::escapeHTML($css).'</style>'.
|
||||
"\n<!-- JS for noodles --> \n".
|
||||
"<script type=\"text/javascript\" src=\"".
|
||||
$core->blog->url.$core->url->getBase('noodlesmodule')."/js/jquery.noodles.js\"></script> \n".
|
||||
"<script type=\"text/javascript\"> \n".
|
||||
"//<![CDATA[\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_func = '".html::escapeJS('getNoodle')."'; \n".
|
||||
implode("\n",$targets)."\n".
|
||||
"})\n".
|
||||
"\n//]]>\n".
|
||||
"</script>\n";
|
||||
}
|
||||
}
|
||||
|
||||
class urlNoodles extends dcUrlHandlers
|
||||
{
|
||||
public static function service($args)
|
||||
{
|
||||
global $core;
|
||||
public static function service($args)
|
||||
{
|
||||
global $core;
|
||||
|
||||
header('Content-Type: text/xml; charset=UTF-8');
|
||||
header('Content-Type: text/xml; charset=UTF-8');
|
||||
|
||||
$rsp = new xmlTag('rsp');
|
||||
$rsp = new xmlTag('rsp');
|
||||
|
||||
$i = !empty($_POST['noodleId']) ? $_POST['noodleId'] : null;
|
||||
$c = !empty($_POST['noodleContent']) ? $_POST['noodleContent'] : null;
|
||||
$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 (!$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;
|
||||
}
|
||||
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);
|
||||
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->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;
|
||||
}
|
||||
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);
|
||||
$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')) : '';
|
||||
$s = $__noodles->{$i}->size;
|
||||
$r = $__noodles->{$i}->rating;
|
||||
$d = $core->blog->settings->noodles->noodles_image ?
|
||||
urlencode(noodlesLibImagePath::getUrl($core,'noodles')) : '';
|
||||
|
||||
if (!$m) $m = 'nobody@nowhere.tld';
|
||||
if (!$s) $s = 32;
|
||||
if (!$r) $r = 'g';
|
||||
if (!$m) $m = 'nobody@nowhere.tld';
|
||||
if (!$s) $s = 32;
|
||||
if (!$r) $r = 'g';
|
||||
|
||||
$m = mb_strtolower($m);
|
||||
$m = md5($m);
|
||||
$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);
|
||||
$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;
|
||||
}
|
||||
$rsp->status = 'ok';
|
||||
echo $rsp->toXML(1);
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function noodles($args)
|
||||
{
|
||||
global $core;
|
||||
public static function noodles($args)
|
||||
{
|
||||
global $core;
|
||||
|
||||
if (!$core->blog->settings->noodles->noodles_active)
|
||||
{
|
||||
self::p404();
|
||||
return;
|
||||
}
|
||||
if (!$core->blog->settings->noodles->noodles_active)
|
||||
{
|
||||
self::p404();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preg_match('#^(.*?)$#',$args,$m))
|
||||
{
|
||||
self::p404();
|
||||
return;
|
||||
}
|
||||
if (!preg_match('#^(.*?)$#',$args,$m))
|
||||
{
|
||||
self::p404();
|
||||
return;
|
||||
}
|
||||
|
||||
$f = $m[1];
|
||||
$f = $m[1];
|
||||
|
||||
if (!($f = self::searchTplFiles($f)))
|
||||
{
|
||||
self::p404();
|
||||
return;
|
||||
}
|
||||
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);
|
||||
$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));
|
||||
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;
|
||||
}
|
||||
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();
|
||||
# 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;
|
||||
}
|
||||
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
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')){return;}
|
||||
|
||||
$this->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')
|
||||
);
|
||||
|
||||
?>
|
||||
$this->addDirectAction(
|
||||
/* type */ 'plugins',
|
||||
/* action */ 'delete',
|
||||
/* ns */ 'noodles',
|
||||
/* description */ sprintf(__('delete %s plugin files'),'noodles')
|
||||
);
|
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')){return;}
|
||||
|
||||
|
@ -35,62 +36,60 @@ $__default_noodles->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);
|
||||
|
||||
?>
|
|
@ -1,172 +1,172 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')){return;}
|
||||
|
||||
class genericNoodles
|
||||
{
|
||||
public static function postURL($noodle,$content='')
|
||||
{
|
||||
global $core;
|
||||
public static function postURL($noodle,$content='')
|
||||
{
|
||||
global $core;
|
||||
|
||||
$types = $core->getPostTypes();
|
||||
$reg = '@^'.str_replace('%s','(.*?)',
|
||||
preg_quote($core->blog->url.$types['post']['public_url'])).'$@';
|
||||
$types = $core->getPostTypes();
|
||||
$reg = '@^'.str_replace('%s','(.*?)',
|
||||
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(
|
||||
array('no_content'=>1,'post_url'=>urldecode($m[1]),'limit'=>1)
|
||||
);
|
||||
$rs = $core->blog->getPosts(
|
||||
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
|
||||
class othersNoodles
|
||||
{
|
||||
public static function publicPosts($core,$noodle)
|
||||
{
|
||||
if (!$noodle->active) return;
|
||||
public static function publicPosts($core,$noodle)
|
||||
{
|
||||
if (!$noodle->active) return;
|
||||
|
||||
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
||||
'publicEntryBeforeContent' : 'publicEntryAfterContent';
|
||||
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
||||
'publicEntryBeforeContent' : 'publicEntryAfterContent';
|
||||
|
||||
$core->addBehavior($bhv,array('othersNoodles','publicEntryContent'));
|
||||
}
|
||||
$core->addBehavior($bhv,array('othersNoodles','publicEntryContent'));
|
||||
}
|
||||
|
||||
public static function publicEntryContent()
|
||||
{
|
||||
global $core,$_ctx,$__noodles;
|
||||
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')) : '';
|
||||
$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="" />';
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (!$noodle->active) return;
|
||||
public static function publicComments($core,$noodle)
|
||||
{
|
||||
if (!$noodle->active) return;
|
||||
|
||||
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
||||
'publicCommentBeforeContent' : 'publicCommentAfterContent';
|
||||
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
||||
'publicCommentBeforeContent' : 'publicCommentAfterContent';
|
||||
|
||||
$core->addBehavior($bhv,array('othersNoodles','publicCommentContent'));
|
||||
}
|
||||
$core->addBehavior($bhv,array('othersNoodles','publicCommentContent'));
|
||||
}
|
||||
|
||||
public static function publicCommentContent()
|
||||
{
|
||||
global $core,$_ctx,$__noodles;
|
||||
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')) : '';
|
||||
$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="" />';
|
||||
}
|
||||
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
|
||||
class widgetsNoodles
|
||||
{
|
||||
public static function lastcomments($noodle,$content='')
|
||||
{
|
||||
global $core;
|
||||
public static function lastcomments($noodle,$content='')
|
||||
{
|
||||
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(
|
||||
array('no_content'=>1,'comment_id'=>$m[1],'limit'=>1)
|
||||
);
|
||||
$rs = $core->blog->getComments(
|
||||
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
|
||||
class authormodeNoodles
|
||||
{
|
||||
public static function authors($noodle,$content='')
|
||||
{
|
||||
global $core;
|
||||
$ok = preg_match('@\/([^\/]*?)$@',$content,$m);
|
||||
public static function authors($noodle,$content='')
|
||||
{
|
||||
global $core;
|
||||
$ok = preg_match('@\/([^\/]*?)$@',$content,$m);
|
||||
|
||||
if (!$ok || !$m[1]) return '';
|
||||
if (!$ok || !$m[1]) return '';
|
||||
|
||||
$rs = $core->getUser($m[1]);
|
||||
$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)
|
||||
{
|
||||
if ($noodle->active)
|
||||
{
|
||||
$core->addBehavior('publicHeadContent',
|
||||
array('authormodeNoodles','publicHeadContent'));
|
||||
}
|
||||
}
|
||||
public static function author($core,$noodle)
|
||||
{
|
||||
if ($noodle->active)
|
||||
{
|
||||
$core->addBehavior('publicHeadContent',
|
||||
array('authormodeNoodles','publicHeadContent'));
|
||||
}
|
||||
}
|
||||
|
||||
public static function publicHeadContent()
|
||||
{
|
||||
global $core,$_ctx,$__noodles;
|
||||
public static function publicHeadContent()
|
||||
{
|
||||
global $core,$_ctx,$__noodles;
|
||||
|
||||
if ($_ctx->current_tpl != 'author.html') return;
|
||||
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')) : '';
|
||||
$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
|
||||
'<script type="text/javascript">'."\n".
|
||||
"//<![CDATA[\n".
|
||||
"$(function(){if(!document.getElementById){return;}\n".
|
||||
"$('".$__noodles->author->target."').".$__noodles->author->place."('".
|
||||
'<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="" />'.
|
||||
"');});".
|
||||
"\n//]]>\n".
|
||||
"</script>\n";
|
||||
}
|
||||
echo
|
||||
'<script type="text/javascript">'."\n".
|
||||
"//<![CDATA[\n".
|
||||
"$(function(){if(!document.getElementById){return;}\n".
|
||||
"$('".$__noodles->author->target."').".$__noodles->author->place."('".
|
||||
'<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="" />'.
|
||||
"');});".
|
||||
"\n//]]>\n".
|
||||
"</script>\n";
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,166 +1,166 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')){return;}
|
||||
|
||||
class noodles
|
||||
{
|
||||
private $noodles = array();
|
||||
private $noodles = array();
|
||||
|
||||
public static function decode($s)
|
||||
{
|
||||
$o = @unserialize(base64_decode($s));
|
||||
if ($o instanceof self) return $o;
|
||||
return new self;
|
||||
}
|
||||
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 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 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 __get($id)
|
||||
{
|
||||
return isset($this->noodles[$id]) ? $this->noodles[$id] : null;
|
||||
}
|
||||
|
||||
public function __set($id,$noodle)
|
||||
{
|
||||
return $this->noodles[$id] = $noodle;
|
||||
}
|
||||
public function __set($id,$noodle)
|
||||
{
|
||||
return $this->noodles[$id] = $noodle;
|
||||
}
|
||||
|
||||
public function exists($id)
|
||||
{
|
||||
return isset($this->noodles[$id]);
|
||||
}
|
||||
public function exists($id)
|
||||
{
|
||||
return isset($this->noodles[$id]);
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return !count($this->noodles);
|
||||
}
|
||||
public function isEmpty()
|
||||
{
|
||||
return !count($this->noodles);
|
||||
}
|
||||
|
||||
public function noodles()
|
||||
{
|
||||
return $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'
|
||||
);
|
||||
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 __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 id()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function name()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
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 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 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 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 hasPhpCallback()
|
||||
{
|
||||
return !empty($this->php_callback);
|
||||
}
|
||||
|
||||
public function set($type,$value)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case 'active':
|
||||
$this->settings['active'] = abs((integer) $value);
|
||||
break;
|
||||
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 '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 '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 'css':
|
||||
$this->settings['css'] = (string) $value;
|
||||
break;
|
||||
|
||||
case 'target':
|
||||
$this->settings['target'] = (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;
|
||||
}
|
||||
}
|
||||
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 __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 isset($this->settings[$type]) ? $this->settings[$type] : null;
|
||||
}
|
||||
|
||||
public function __get($type)
|
||||
{
|
||||
return $this->get($type);
|
||||
}
|
||||
public function __get($type)
|
||||
{
|
||||
return $this->get($type);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,74 +1,74 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
class noodlesLibImagePath
|
||||
{
|
||||
public static $version = '1.1';
|
||||
public static $version = '1.1';
|
||||
|
||||
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),
|
||||
);
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
410
index.php
410
index.php
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
# This file is part of noodles, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2010 JC Denis and contributors
|
||||
# jcdenis@gdwd.com
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief noodles, a for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage \u
|
||||
*
|
||||
* @author JC Denis
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')){return;}
|
||||
|
||||
|
@ -26,155 +27,155 @@ $__noodles = noodles::decode($s->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'];
|
||||
# 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');
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
$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');
|
||||
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());
|
||||
}
|
||||
$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
|
||||
'<div class="multi-part" id="blocs" title="'.__('Controls').'">'.
|
||||
'<form method="post" action="plugin.php">'.
|
||||
'<table><thead><tr>'.
|
||||
'<th class="nowrap">'.__('Name').'</th>'.
|
||||
'<th class="nowrap">'.__('Enable').'</th>'.
|
||||
'<th class="nowrap">'.__('Size').'</th>'.
|
||||
'<th class="nowrap">'.__('Rating').'</th>'.
|
||||
'<th class="nowrap">'.__('PHP').'</th>'.
|
||||
'<th class="nowrap">'.__('JS').'</th>'.
|
||||
'<th class="nowrap">'.__('JS target').'</th>'.
|
||||
'<th class="nowrap">'.__('JS place').'</th>'.
|
||||
'<th class="nowrap">'.__('Adjust avatar CSS').'</th>'.
|
||||
'</tr></thead>';
|
||||
echo
|
||||
'<div class="multi-part" id="blocs" title="'.__('Controls').'">'.
|
||||
'<form method="post" action="plugin.php">'.
|
||||
'<table><thead><tr>'.
|
||||
'<th class="nowrap">'.__('Name').'</th>'.
|
||||
'<th class="nowrap">'.__('Enable').'</th>'.
|
||||
'<th class="nowrap">'.__('Size').'</th>'.
|
||||
'<th class="nowrap">'.__('Rating').'</th>'.
|
||||
'<th class="nowrap">'.__('PHP').'</th>'.
|
||||
'<th class="nowrap">'.__('JS').'</th>'.
|
||||
'<th class="nowrap">'.__('JS target').'</th>'.
|
||||
'<th class="nowrap">'.__('JS place').'</th>'.
|
||||
'<th class="nowrap">'.__('Adjust avatar CSS').'</th>'.
|
||||
'</tr></thead>';
|
||||
|
||||
foreach($__noodles->noodles() as $noodle)
|
||||
{
|
||||
echo
|
||||
'<tr class="line">'.
|
||||
'<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().'][size]'),$combo_size,$noodle->size).'</td>'.
|
||||
'<td>'.form::combo(array('noodle['.$noodle->id().'][rating]'),$combo_rating,$noodle->rating).'</td>'.
|
||||
'<td>'.($noodle->hasPhpCallback() ? $img_green : $img_red).'</td>'.
|
||||
'<td>'.$img_green.'</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 class="maximal">'.
|
||||
form::textArea(array('noodle['.$noodle->id().'][css]'),50,2,$noodle->css).
|
||||
' .noodles-'.$noodle->id().'{}</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
echo
|
||||
'</table>'.
|
||||
'<p>'.
|
||||
form::hidden(array('p'),'noodles').
|
||||
form::hidden(array('tab'),'blocs').
|
||||
$core->formNonce().
|
||||
'<input type="submit" name="save" value="'.__('Save').'" /> '.
|
||||
'<input type="submit" name="reset" value="'.__('Reset').'" /></p>'.
|
||||
'</form>'.
|
||||
'</div>';
|
||||
foreach($__noodles->noodles() as $noodle)
|
||||
{
|
||||
echo
|
||||
'<tr class="line">'.
|
||||
'<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().'][size]'),$combo_size,$noodle->size).'</td>'.
|
||||
'<td>'.form::combo(array('noodle['.$noodle->id().'][rating]'),$combo_rating,$noodle->rating).'</td>'.
|
||||
'<td>'.($noodle->hasPhpCallback() ? $img_green : $img_red).'</td>'.
|
||||
'<td>'.$img_green.'</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 class="maximal">'.
|
||||
form::textArea(array('noodle['.$noodle->id().'][css]'),50,2,$noodle->css).
|
||||
' .noodles-'.$noodle->id().'{}</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
echo
|
||||
'</table>'.
|
||||
'<p>'.
|
||||
form::hidden(array('p'),'noodles').
|
||||
form::hidden(array('tab'),'blocs').
|
||||
$core->formNonce().
|
||||
'<input type="submit" name="save" value="'.__('Save').'" /> '.
|
||||
'<input type="submit" name="reset" value="'.__('Reset').'" /></p>'.
|
||||
'</form>'.
|
||||
'</div>';
|
||||
}
|
||||
|
||||
# Settings
|
||||
|
@ -242,7 +243,7 @@ echo
|
|||
'<fieldset id="settings-plugin"><legend>'.__('Options').'</legend>'.
|
||||
'<p class="field"><label>'.
|
||||
form::combo(array('noodles_active'),$combo_active,$s->noodles_active).' '.
|
||||
__('Enable plugin').'</label></p>'.
|
||||
__('Enable plugin').'</label></p>'.
|
||||
|
||||
'</fieldset>'.
|
||||
'<fieldset id="setting-avatar"><legend>'.__('Default avatar').'</legend>'.
|
||||
|
@ -261,53 +262,53 @@ __('gravatar.com default image').'</label></td>'.
|
|||
|
||||
if (!$default)
|
||||
{
|
||||
$exists = false;
|
||||
$exists = false;
|
||||
|
||||
// then use theme image
|
||||
if (file_exists($avatar_paths['theme']['dir']))
|
||||
{
|
||||
$exists = $avatar_paths['theme'];
|
||||
}
|
||||
// then public image
|
||||
elseif (file_exists($avatar_paths['public']['dir']))
|
||||
{
|
||||
$exists = $avatar_paths['public'];
|
||||
}
|
||||
// then module
|
||||
elseif (file_exists($avatar_paths['module']['dir']))
|
||||
{
|
||||
$exists = $avatar_paths['module'];
|
||||
}
|
||||
if ($exists)
|
||||
{
|
||||
$sz = getimagesize($exists['dir']);
|
||||
$sz[2] = files::size(filesize($exists['dir']));
|
||||
// then use theme image
|
||||
if (file_exists($avatar_paths['theme']['dir']))
|
||||
{
|
||||
$exists = $avatar_paths['theme'];
|
||||
}
|
||||
// then public image
|
||||
elseif (file_exists($avatar_paths['public']['dir']))
|
||||
{
|
||||
$exists = $avatar_paths['public'];
|
||||
}
|
||||
// then module
|
||||
elseif (file_exists($avatar_paths['module']['dir']))
|
||||
{
|
||||
$exists = $avatar_paths['module'];
|
||||
}
|
||||
if ($exists)
|
||||
{
|
||||
$sz = getimagesize($exists['dir']);
|
||||
$sz[2] = files::size(filesize($exists['dir']));
|
||||
|
||||
echo
|
||||
'<tr class="line">'.
|
||||
'<td><label class="classic">'.form::radio(array('noodles_image'),'existing',1).
|
||||
basename($exists['dir']).'</label></td>'.
|
||||
'<td><img src="'.$exists['url'].'" alt="" /></td>'.
|
||||
'<td>'.$sz[0].'x'.$sz[1].'<br />'.$sz[2].'</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
echo
|
||||
'<tr class="line">'.
|
||||
'<td><label class="classic">'.form::radio(array('noodles_image'),'existing',1).
|
||||
basename($exists['dir']).'</label></td>'.
|
||||
'<td><img src="'.$exists['url'].'" alt="" /></td>'.
|
||||
'<td>'.$sz[0].'x'.$sz[1].'<br />'.$sz[2].'</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
// noodles avatars
|
||||
sort($default_avatars_images);
|
||||
foreach($default_avatars_images AS $f)
|
||||
{
|
||||
if (!preg_match('/gravatar-[0-9]+.png/',$f)) continue;
|
||||
$sz = getimagesize(dirname(__FILE__).'/default-templates/img/'.$f);
|
||||
$sz[2] = files::size(filesize(dirname(__FILE__).'/default-templates/img/'.$f));
|
||||
if (!preg_match('/gravatar-[0-9]+.png/',$f)) continue;
|
||||
$sz = getimagesize(dirname(__FILE__).'/default-templates/img/'.$f);
|
||||
$sz[2] = files::size(filesize(dirname(__FILE__).'/default-templates/img/'.$f));
|
||||
|
||||
echo
|
||||
'<tr class="line">'.
|
||||
'<td><label class="classic">'.form::radio(array('noodles_image'),$f).
|
||||
basename($f).'</label></td>'.
|
||||
'<td><img src="index.php?pf=noodles/default-templates/img/'.$f.'" alt="" /></td>'.
|
||||
'<td>'.$sz[0].'x'.$sz[1].'<br />'.$sz[2].'</td>'.
|
||||
'</tr>';
|
||||
echo
|
||||
'<tr class="line">'.
|
||||
'<td><label class="classic">'.form::radio(array('noodles_image'),$f).
|
||||
basename($f).'</label></td>'.
|
||||
'<td><img src="index.php?pf=noodles/default-templates/img/'.$f.'" alt="" /></td>'.
|
||||
'<td>'.$sz[0].'x'.$sz[1].'<br />'.$sz[2].'</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
// user upload avatar
|
||||
|
@ -315,7 +316,7 @@ echo
|
|||
'<tr class="line">'.
|
||||
'<td>'.form::radio(array('noodles_image'),'user').'</td>'.
|
||||
'<td colspan="2">'.form::hidden(array('MAX_FILE_SIZE'),30000).
|
||||
'<input type="file" name="noodlesuserfile" /> *</td>'.
|
||||
'<input type="file" name="noodlesuserfile" /> *</td>'.
|
||||
'</tr>'.
|
||||
'</table>'.
|
||||
'<p class="form-note">* '.__('Image must be in "png" format and have a maximum file size of 30Ko').'</p>'.
|
||||
|
@ -336,4 +337,3 @@ noodles - '.$core->plugins->moduleInfo('noodles','version').'
|
|||
<img alt="'.__('Noodles').'" src="index.php?pf=noodles/icon.png" />
|
||||
</p>
|
||||
</body></html>';
|
||||
?>
|
|
@ -79,5 +79,3 @@ $GLOBALS['__l10n']['gravatar.com default image'] = 'Image par défaut de gravata
|
|||
|
||||
#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';
|
||||
|
||||
?>
|
Loading…
Reference in a new issue