clean up code
parent
7b63f7f111
commit
e78f1507a8
34
_install.php
34
_install.php
|
@ -11,30 +11,24 @@
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @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 null;
|
||||||
|
}
|
||||||
|
|
||||||
$new_version = $core->plugins->moduleInfo('noodles','version');
|
$new_version = $core->plugins->moduleInfo('noodles', 'version');
|
||||||
$old_version = $core->getVersion('noodles');
|
$old_version = $core->getVersion('noodles');
|
||||||
|
|
||||||
if (version_compare($old_version,$new_version,'>=')) return;
|
if (version_compare($old_version, $new_version, '>=')) {
|
||||||
|
return null;
|
||||||
try
|
|
||||||
{
|
|
||||||
if (version_compare(DC_VERSION,'2.2-beta','<'))
|
|
||||||
{
|
|
||||||
throw new Exception('noodles requires Dotclear 2.2');
|
|
||||||
}
|
|
||||||
|
|
||||||
$core->blog->settings->addNamespace('noodles');
|
|
||||||
|
|
||||||
$core->blog->settings->noodles->put('noodles_active',false,'boolean','Enable extension',false,true);
|
|
||||||
|
|
||||||
$core->setVersion('noodles',$new_version);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
try {
|
||||||
{
|
$core->blog->settings->addNamespace('noodles');
|
||||||
|
$core->blog->settings->noodles->put(
|
||||||
|
'noodles_active', false, 'boolean', 'Enable extension', false, true
|
||||||
|
);
|
||||||
|
$core->setVersion('noodles', $new_version);
|
||||||
|
return true;
|
||||||
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
26
_prepend.php
26
_prepend.php
|
@ -11,16 +11,24 @@
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @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 null;
|
||||||
|
}
|
||||||
|
|
||||||
global $__autoload, $core;
|
$__autoload['noodlesImg'] = dirname(__FILE__) . '/inc/lib.noodles.img.php';
|
||||||
|
$__autoload['noodlesLibImagePath'] = dirname(__FILE__) . '/inc/lib.image.path.php';
|
||||||
$__autoload['noodlesImg'] = dirname(__FILE__).'/inc/lib.noodles.img.php';
|
|
||||||
$__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(
|
||||||
array('urlNoodles','noodles'));
|
'noodlesmodule',
|
||||||
$core->url->register('noodlesservice','noodle','^noodle/$',
|
'noodles',
|
||||||
array('urlNoodles','service'));
|
'^noodles/(.+)$',
|
||||||
|
['urlNoodles', 'noodles']
|
||||||
|
);
|
||||||
|
$core->url->register(
|
||||||
|
'noodlesservice',
|
||||||
|
'noodle',
|
||||||
|
'^noodle/$',
|
||||||
|
['urlNoodles', 'service']
|
||||||
|
);
|
155
_public.php
155
_public.php
|
@ -11,29 +11,34 @@
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @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 null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$core->blog->settings->noodles->noodles_active) return;
|
if (!$core->blog->settings->noodles->noodles_active) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
include dirname(__FILE__).'/inc/_default_noodles.php';
|
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', ['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');
|
||||||
|
|
||||||
global $__noodles;
|
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
|
||||||
|
@ -45,34 +50,33 @@ class publicNoodles
|
||||||
$css = "\n";
|
$css = "\n";
|
||||||
$targets = array();
|
$targets = array();
|
||||||
foreach($__noodles->noodles() AS $noodle) {
|
foreach($__noodles->noodles() AS $noodle) {
|
||||||
|
if (!$noodle->active || !$noodle->hasJsCallback()) {
|
||||||
if (!$noodle->active || !$noodle->hasJsCallback()) continue;
|
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)) {
|
||||||
if (empty($targets)) return;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
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=\"".
|
dcUtils::jsLoad($core->blog->url . $core->url->getBase('noodlesmodule') . "/js/jquery.noodles.js") .
|
||||||
$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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,64 +94,60 @@ class urlNoodles extends dcUrlHandlers
|
||||||
$i = !empty($_POST['noodleId']) ? $_POST['noodleId'] : null;
|
$i = !empty($_POST['noodleId']) ? $_POST['noodleId'] : null;
|
||||||
$c = !empty($_POST['noodleContent']) ? $_POST['noodleContent'] : null;
|
$c = !empty($_POST['noodleContent']) ? $_POST['noodleContent'] : null;
|
||||||
|
|
||||||
if (!$core->blog->settings->noodles->noodles_active)
|
if (!$core->blog->settings->noodles->noodles_active) {
|
||||||
{
|
|
||||||
$rsp->status = 'failed';
|
$rsp->status = 'failed';
|
||||||
$rsp->message(__('noodles is disabled on this blog'));
|
$rsp->message(__('noodles is disabled on this blog'));
|
||||||
echo $rsp->toXML(1);
|
echo $rsp->toXML(1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ($i === null || $c === null) {
|
||||||
if ($i === null || $c === null)
|
|
||||||
{
|
|
||||||
$rsp->status = 'failed';
|
$rsp->status = 'failed';
|
||||||
$rsp->message(__('noodles failed because of missing informations'));
|
$rsp->message(__('noodles failed because of missing informations'));
|
||||||
echo $rsp->toXML(1);
|
echo $rsp->toXML(1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$__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 = $GLOBALS['__default_noodles'];
|
$__noodles = $GLOBALS['__default_noodles'];
|
||||||
}
|
}
|
||||||
}
|
} catch(Excetpion $e) {
|
||||||
catch(Excetpion $e)
|
|
||||||
{
|
|
||||||
$rsp->status = 'failed';
|
$rsp->status = 'failed';
|
||||||
$rsp->message(__('Failed to load default noodles'));
|
$rsp->message(__('Failed to load default noodles'));
|
||||||
echo $rsp->toXML(1);
|
echo $rsp->toXML(1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$__noodles->exists($i))
|
if (!$__noodles->exists($i)) {
|
||||||
{
|
|
||||||
$rsp->status = 'failed';
|
$rsp->status = 'failed';
|
||||||
$rsp->message(__('Failed to load noodle'));
|
$rsp->message(__('Failed to load noodle'));
|
||||||
echo $rsp->toXML(1);
|
echo $rsp->toXML(1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$m = $__noodles->{$i}->jsCallback($__noodles->{$i},$c);
|
$m = $__noodles->{$i}->jsCallback($__noodles->{$i}, $c);
|
||||||
|
|
||||||
$s = $__noodles->{$i}->size;
|
$s = $__noodles->{$i}->size;
|
||||||
$r = $__noodles->{$i}->rating;
|
$r = $__noodles->{$i}->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')) : '';
|
||||||
|
|
||||||
if (!$m) $m = 'nobody@nowhere.tld';
|
if (!$m) {
|
||||||
if (!$s) $s = 32;
|
$m = 'nobody@nowhere.tld';
|
||||||
if (!$r) $r = 'g';
|
}
|
||||||
|
if (!$s) {
|
||||||
|
$s = 32;
|
||||||
|
}
|
||||||
|
if (!$r) {
|
||||||
|
$r = 'g';
|
||||||
|
}
|
||||||
|
|
||||||
$m = mb_strtolower($m);
|
$m = mb_strtolower($m);
|
||||||
$m = md5($m);
|
$m = md5($m);
|
||||||
|
|
||||||
$im = new xmlTag('noodle');
|
$im = new xmlTag('noodle');
|
||||||
$im->size = $s;
|
$im->size = $s;
|
||||||
$im->src = 'http://www.gravatar.com/avatar/'.$m.'?s='.$s.'&r='.$r.'&d='.$d;
|
$im->src = 'http://www.gravatar.com/avatar/' . $m . '?s=' . $s . '&r=' . $r . '&d=' . $d;
|
||||||
$rsp->insertNode($im);
|
$rsp->insertNode($im);
|
||||||
|
|
||||||
$rsp->status = 'ok';
|
$rsp->status = 'ok';
|
||||||
|
@ -159,44 +159,41 @@ class urlNoodles extends dcUrlHandlers
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
if (!$core->blog->settings->noodles->noodles_active)
|
if (!$core->blog->settings->noodles->noodles_active) {
|
||||||
{
|
|
||||||
self::p404();
|
self::p404();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preg_match('#^(.*?)$#',$args,$m))
|
if (!preg_match('#^(.*?)$#', $args, $m)) {
|
||||||
{
|
|
||||||
self::p404();
|
self::p404();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$f = $m[1];
|
$f = $m[1];
|
||||||
|
|
||||||
if (!($f = self::searchTplFiles($f)))
|
if (!($f = self::searchTplFiles($f))) {
|
||||||
{
|
|
||||||
self::p404();
|
self::p404();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowed_types = array('png','jpg','jpeg','gif','css','js','swf');
|
$allowed_types = ['png', 'jpg', 'jpeg', 'gif', 'css', 'js', 'swf'];
|
||||||
if (!in_array(files::getExtension($f),$allowed_types))
|
if (!in_array(files::getExtension($f), $allowed_types)) {
|
||||||
{
|
|
||||||
self::p404();
|
self::p404();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$type = files::getMimeType($f);
|
$type = files::getMimeType($f);
|
||||||
|
|
||||||
header('Content-Type: '.$type.'; charset=UTF-8');
|
header('Content-Type: ' . $type . '; charset=UTF-8');
|
||||||
header('Content-Length: '.filesize($f));
|
header('Content-Length: ' . filesize($f));
|
||||||
|
|
||||||
if ($type != "text/css" || $core->blog->settings->system->url_scan == 'path_info')
|
if ($type != "text/css" || $core->blog->settings->system->url_scan == 'path_info') {
|
||||||
{
|
|
||||||
readfile($f);
|
readfile($f);
|
||||||
}
|
} else {
|
||||||
else
|
echo preg_replace(
|
||||||
{
|
'#url\((?!(http:)|/)#',
|
||||||
echo preg_replace('#url\((?!(http:)|/)#','url('.$core->blog->url.$core->url->getBase('noodlesmodule').'/',file_get_contents($f));
|
'url(' . $core->blog->url . $core->url->getBase('noodlesmodule') . '/',
|
||||||
|
file_get_contents($f)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -204,21 +201,17 @@ class urlNoodles extends dcUrlHandlers
|
||||||
# Search noodles files like JS, CSS in default-templates subdirectories
|
# Search noodles files like JS, CSS in default-templates subdirectories
|
||||||
private static function searchTplFiles($file)
|
private static function searchTplFiles($file)
|
||||||
{
|
{
|
||||||
if (strstr($file,"..") !== false)
|
if (strstr($file,"..") !== false) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$paths = $GLOBALS['core']->tpl->getPath();
|
$paths = $GLOBALS['core']->tpl->getPath();
|
||||||
|
|
||||||
foreach($paths as $path)
|
foreach($paths as $path) {
|
||||||
{
|
if (preg_match('/tpl(\/|)$/',$path)) {
|
||||||
if (preg_match('/tpl(\/|)$/',$path))
|
$path = path::real($path . '/..');
|
||||||
{
|
|
||||||
$path = path::real($path.'/..');
|
|
||||||
}
|
}
|
||||||
if (file_exists($path.'/'.$file))
|
if (file_exists($path . '/' . $file)) {
|
||||||
{
|
return $path . '/' . $file;
|
||||||
return $path.'/'.$file;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @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 null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'settings',
|
/* type */ 'settings',
|
||||||
|
@ -31,12 +33,12 @@ $this->addDirectAction(
|
||||||
/* type */ 'settings',
|
/* type */ 'settings',
|
||||||
/* action */ 'delete_all',
|
/* action */ 'delete_all',
|
||||||
/* ns */ 'noodles',
|
/* ns */ 'noodles',
|
||||||
/* description */ sprintf(__('delete all %s settings'),'noodles')
|
/* description */ sprintf(__('delete all %s settings'), 'noodles')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
/* type */ 'plugins',
|
/* type */ 'plugins',
|
||||||
/* action */ 'delete',
|
/* action */ 'delete',
|
||||||
/* ns */ 'noodles',
|
/* ns */ 'noodles',
|
||||||
/* description */ sprintf(__('delete %s plugin files'),'noodles')
|
/* description */ sprintf(__('delete %s plugin files'), 'noodles')
|
||||||
);
|
);
|
|
@ -0,0 +1,12 @@
|
||||||
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
|
<module id="noodles">
|
||||||
|
<name>Noodles</name>
|
||||||
|
<version>0.6.1</version>
|
||||||
|
<author>Jean-Christian Denis and contributors</author>
|
||||||
|
<desc>Add users gravatars everywhere</desc>
|
||||||
|
<file>https://github.com/JcDenis/noodles/releases/download/v0.6.1/plugin-noodles.zip</file>
|
||||||
|
<da:dcmin>2.19</da:dcmin>
|
||||||
|
<da:details>http://plugins.dotaddict.org/dc2/details/noodles</da:details>
|
||||||
|
<da:support>https://github.com/JcDenis/noodles</da:support>
|
||||||
|
</module>
|
||||||
|
</modules>
|
|
@ -1,14 +1,3 @@
|
||||||
/* -- BEGIN LICENSE BLOCK ----------------------------------
|
|
||||||
* This file is part of noodles, a plugin for Dotclear 2.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2009 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 ------------------------------------*/
|
|
||||||
|
|
||||||
;if(window.jQuery) (function($) {
|
;if(window.jQuery) (function($) {
|
||||||
|
|
||||||
$.fn.noodles = function(options) {
|
$.fn.noodles = function(options) {
|
||||||
|
|
|
@ -11,85 +11,96 @@
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @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 null;
|
||||||
|
}
|
||||||
|
|
||||||
require dirname(__FILE__).'/class.noodles.php';
|
require dirname(__FILE__) . '/class.noodles.php';
|
||||||
|
|
||||||
global $__default_noodles;
|
global $__default_noodles;
|
||||||
$__default_noodles = new noodles();
|
$__default_noodles = new noodles;
|
||||||
|
|
||||||
# Posts (by public behavior)
|
# Posts (by public behavior)
|
||||||
$__default_noodles->add('posts',__('Entries'),'',array('othersNoodles','publicPosts'));
|
$__default_noodles
|
||||||
$__default_noodles->posts->size = 48;
|
->add('posts', __('Entries'), '', ['othersNoodles', 'publicPosts'])
|
||||||
$__default_noodles->posts->css = 'float:right;margin:4px;';
|
->size(48)
|
||||||
|
->css('float:right;margin:4px;');
|
||||||
|
|
||||||
# Comments (by public behavior)
|
# Comments (by public behavior)
|
||||||
$__default_noodles->add('comments',__('Comments'),'',array('othersNoodles','publicComments'));
|
$__default_noodles
|
||||||
$__default_noodles->comments->active = true;
|
->add('comments', __('Comments'), '', ['othersNoodles', 'publicComments'])
|
||||||
$__default_noodles->comments->size = 48;
|
->active(true)
|
||||||
$__default_noodles->comments->css = 'float:left;margin:4px;';
|
->size(48)
|
||||||
|
->css('float:left;margin:4px;');
|
||||||
|
|
||||||
# Block with post title link (like homepage posts)
|
# Block with post title link (like homepage posts)
|
||||||
$__default_noodles->add('titlesposts',__('Entries titles'),array('genericNoodles','postURL'));
|
$__default_noodles
|
||||||
$__default_noodles->titlesposts->target = '.post-title a';
|
->add('titlesposts', __('Entries titles'), ['genericNoodles', 'postURL'])
|
||||||
$__default_noodles->titlesposts->css = 'margin-right:2px;';
|
->target('.post-title a')
|
||||||
|
->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
|
||||||
$__default_noodles->bestof->target = '.selected li a';
|
->add('bestof', __('Selected entries'), ['genericNoodles', 'postURL'])
|
||||||
$__default_noodles->bestof->css = 'margin-right:2px;';
|
->target('.selected li a')
|
||||||
|
->css('margin-right:2px;');
|
||||||
|
|
||||||
# Widget Last entries
|
# Widget Last entries
|
||||||
$__default_noodles->add('lastposts',__('Last entries'),array('genericNoodles','postURL'));
|
$__default_noodles
|
||||||
$__default_noodles->lastposts->target = '.lastposts li a';
|
->add('lastposts', __('Last entries'), ['genericNoodles', 'postURL'])
|
||||||
$__default_noodles->lastposts->css = 'margin-right:2px;';
|
->target('.lastposts li a')
|
||||||
|
->css('margin-right:2px;');
|
||||||
|
|
||||||
# Widget Last comments
|
# Widget Last comments
|
||||||
$__default_noodles->add('lastcomments',__('Last comments'),array('widgetsNoodles','lastcomments'));
|
$__default_noodles
|
||||||
$__default_noodles->lastcomments->active = true;
|
->add('lastcomments', __('Last comments'), ['widgetsNoodles', 'lastcomments'])
|
||||||
$__default_noodles->lastcomments->target = '.lastcomments li a';
|
->active(true)
|
||||||
$__default_noodles->lastcomments->css = 'margin-right:2px;';
|
->target('.lastcomments li a')
|
||||||
|
->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'), ['authormodeNoodles', 'authors'])
|
||||||
|
->target('#authors ul li a')
|
||||||
|
->css('margin-right:2px;');
|
||||||
|
|
||||||
$__default_noodles->add('authorswidget',__('Authors widget'),array('authormodeNoodles','authors'));
|
$__default_noodles
|
||||||
$__default_noodles->authorswidget->target = '#authors ul li a';
|
->add('author', __('Author'), '', ['authormodeNoodles', 'author'])
|
||||||
$__default_noodles->authorswidget->css = 'margin-right:2px;';
|
->active(true)
|
||||||
|
->size(48)
|
||||||
|
->target('.dc-author #content-info h2')
|
||||||
|
->css('clear:left; float:left;margin-right:2px;');
|
||||||
|
|
||||||
$__default_noodles->add('author',__('Author'),'',array('authormodeNoodles','author'));
|
$__default_noodles
|
||||||
$__default_noodles->author->active = true;
|
->add('authors', __('Authors'), ['authormodeNoodles', 'authors'])
|
||||||
$__default_noodles->author->size = 48;
|
->active(true)
|
||||||
$__default_noodles->author->target = '.dc-author #content-info h2';
|
->size(32)
|
||||||
$__default_noodles->author->css = 'clear:left; float:left;margin-right:2px;';
|
->target('.dc-authors .author-info h2 a')
|
||||||
|
->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
|
# 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
|
||||||
$__default_noodles->rateitpostsrank->target = '.rateitpostsrank.rateittypepost ul li a'; // Only "post" type
|
->add('rateitpostsrank', __('Top rated entries'), ['genericNoodles', 'postURL'])
|
||||||
$__default_noodles->rateitpostsrank->css = 'margin-right:2px;';
|
->target('.rateitpostsrank.rateittypepost ul li a') // Only "post" type
|
||||||
|
->css('margin-right:2px;');
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plugin lastpostsExtend
|
# Plugin lastpostsExtend
|
||||||
if ($core->plugins->moduleExists('lastpostsExtend')) {
|
if ($core->plugins->moduleExists('lastpostsExtend')) {
|
||||||
|
$__default_noodles
|
||||||
$__default_noodles->add('lastpostsextend',__('Last entries (extend)'),array('genericNoodles','postURL'));
|
->add('lastpostsextend', __('Last entries (extend)'), ['genericNoodles', 'postURL'])
|
||||||
$__default_noodles->lastpostsextend->target = '.lastpostsextend ul li a';
|
->target('.lastpostsextend ul li a')
|
||||||
$__default_noodles->lastpostsextend->css = 'margin-right:2px;';
|
->css('margin-right:2px;');
|
||||||
}
|
}
|
||||||
|
|
||||||
# --BEHAVIOR-- initDefaultNoodles
|
# --BEHAVIOR-- initDefaultNoodles
|
||||||
$core->callBehavior('initDefaultNoodles',$__default_noodles);
|
$core->callBehavior('initDefaultNoodles', $__default_noodles);
|
|
@ -11,28 +11,26 @@
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @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 null;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
if (!$ok || !$m[1]){
|
||||||
$ok = preg_match($reg,$content,$m);
|
return '';
|
||||||
|
}
|
||||||
if (!$ok || !$m[1]) return '';
|
$rs = $core->blog->getPosts(['no_content' => 1, 'post_url' => urldecode($m[1]), 'limit' => 1]);
|
||||||
|
if ($rs->isEmpty()) {
|
||||||
$rs = $core->blog->getPosts(
|
return '';
|
||||||
array('no_content'=>1,'post_url'=>urldecode($m[1]),'limit'=>1)
|
}
|
||||||
);
|
|
||||||
|
|
||||||
if ($rs->isEmpty()) return '';
|
|
||||||
|
|
||||||
return $rs->user_email;
|
return $rs->user_email;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,14 +38,15 @@ class genericNoodles
|
||||||
# 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 null;
|
||||||
|
}
|
||||||
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
||||||
'publicEntryBeforeContent' : 'publicEntryAfterContent';
|
'publicEntryBeforeContent' : 'publicEntryAfterContent';
|
||||||
|
|
||||||
$core->addBehavior($bhv,array('othersNoodles','publicEntryContent'));
|
$core->addBehavior($bhv, ['othersNoodles', 'publicEntryContent']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function publicEntryContent()
|
public static function publicEntryContent()
|
||||||
|
@ -59,22 +58,24 @@ class othersNoodles
|
||||||
$s = $__noodles->posts->size;
|
$s = $__noodles->posts->size;
|
||||||
$r = $__noodles->posts->rating;
|
$r = $__noodles->posts->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
|
||||||
'<img class="noodles-posts" style="width:'.$s.'px;height:'.$s.'px;'.$c.'"'.
|
'<img class="noodles-posts" 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="" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function publicComments($core,$noodle)
|
public static function publicComments($core, $noodle)
|
||||||
{
|
{
|
||||||
if (!$noodle->active) return;
|
if (!$noodle->active) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
||||||
'publicCommentBeforeContent' : 'publicCommentAfterContent';
|
'publicCommentBeforeContent' : 'publicCommentAfterContent';
|
||||||
|
|
||||||
$core->addBehavior($bhv,array('othersNoodles','publicCommentContent'));
|
$core->addBehavior($bhv, ['othersNoodles', 'publicCommentContent']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function publicCommentContent()
|
public static function publicCommentContent()
|
||||||
|
@ -86,32 +87,30 @@ class othersNoodles
|
||||||
$s = $__noodles->comments->size;
|
$s = $__noodles->comments->size;
|
||||||
$r = $__noodles->comments->rating;
|
$r = $__noodles->comments->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
|
||||||
'<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="" />';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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]) {
|
||||||
if (!$ok || !$m[1]) return '';
|
return '' null;
|
||||||
|
}
|
||||||
$rs = $core->blog->getComments(
|
$rs = $core->blog->getComments(['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 '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,34 +118,35 @@ class widgetsNoodles
|
||||||
# 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);
|
|
||||||
|
|
||||||
if (!$ok || !$m[1]) return '';
|
|
||||||
|
|
||||||
|
$ok = preg_match('@\/([^\/]*?)$@', $content, $m);
|
||||||
|
if (!$ok || !$m[1]) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
$rs = $core->getUser($m[1]);
|
$rs = $core->getUser($m[1]);
|
||||||
|
if ($rs->isEmpty()) {
|
||||||
if ($rs->isEmpty()) return '';
|
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', ['authormodeNoodles', 'publicHeadContent']);
|
||||||
$core->addBehavior('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 null;
|
||||||
|
}
|
||||||
|
|
||||||
$id = $_ctx->users->user_id;
|
$id = $_ctx->users->user_id;
|
||||||
$u = $core->getUser($id);
|
$u = $core->getUser($id);
|
||||||
|
@ -158,15 +158,15 @@ class authormodeNoodles
|
||||||
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";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,16 +11,20 @@
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @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 null;
|
||||||
|
}
|
||||||
|
|
||||||
class noodles
|
class noodles
|
||||||
{
|
{
|
||||||
private $noodles = array();
|
private $noodles = [];
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,9 +33,10 @@ class noodles
|
||||||
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);
|
||||||
|
return $this->noodles[$id];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __get($id)
|
public function __get($id)
|
||||||
|
@ -39,7 +44,7 @@ class noodles
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -66,15 +71,15 @@ class noodle
|
||||||
private $name;
|
private $name;
|
||||||
private $js_callback;
|
private $js_callback;
|
||||||
private $php_callback;
|
private $php_callback;
|
||||||
private $settings = array(
|
private $settings = [
|
||||||
'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;
|
||||||
|
@ -92,10 +97,12 @@ class noodle
|
||||||
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 call_user_func($this->js_callback,$g,$content);
|
return null;
|
||||||
|
}
|
||||||
|
return call_user_func($this->js_callback, $g, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasJsCallback()
|
public function hasJsCallback()
|
||||||
|
@ -105,8 +112,10 @@ class noodle
|
||||||
|
|
||||||
public function phpCallback($core)
|
public function phpCallback($core)
|
||||||
{
|
{
|
||||||
if (!is_callable($this->php_callback)) return null;
|
if (!is_callable($this->php_callback)) {
|
||||||
return call_user_func($this->php_callback,$core,$this);
|
return null;
|
||||||
|
}
|
||||||
|
return call_user_func($this->php_callback, $core, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasPhpCallback()
|
public function hasPhpCallback()
|
||||||
|
@ -114,23 +123,19 @@ class noodle
|
||||||
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, ['g', 'pg', 'r', 'x']) ? $value : 'g';
|
||||||
$value : 'g';
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'size':
|
case 'size':
|
||||||
$this->settings['size'] =
|
$this->settings['size'] = in_array($value, [16, 24, 32, 48, 56, 64, 92, 128, 256]) ? $value : 16;
|
||||||
in_array($value,array(16,24,32,48,56,64,92,128,256)) ?
|
|
||||||
$value : 16;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'css':
|
case 'css':
|
||||||
|
@ -142,16 +147,45 @@ class noodle
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'place':
|
case 'place':
|
||||||
$this->settings['place'] =
|
$this->settings['place'] = in_array($value, ['append', 'prepend', 'before', 'after']) ? $value : 'prepend';
|
||||||
in_array($value,array('append','prepend','before','after')) ?
|
|
||||||
$value : 'prepend';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __set($type,$value)
|
public function active($value)
|
||||||
{
|
{
|
||||||
$this->set($type,$value);
|
return $this->set('active', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rating($value)
|
||||||
|
{
|
||||||
|
return $this->set('rating', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function size($value)
|
||||||
|
{
|
||||||
|
return $this->set('size', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function css($value)
|
||||||
|
{
|
||||||
|
return $this->set('css', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function target($value)
|
||||||
|
{
|
||||||
|
return $this->set('target', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function place($value)
|
||||||
|
{
|
||||||
|
return $this->set('place', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __set($type, $value)
|
||||||
|
{
|
||||||
|
$this->set($type, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($type)
|
public function get($type)
|
||||||
|
|
|
@ -11,40 +11,45 @@
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
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(
|
) {
|
||||||
'theme'=>array('dir'=>null,'url'=>null),
|
return [
|
||||||
'public'=>array('dir'=>null,'url'=>null),
|
'theme' => ['dir' = >null, 'url' = >null],
|
||||||
'module'=>array('dir'=>null,'url'=>null),
|
'public' => ['dir' => null, 'url' => null],
|
||||||
);
|
'module' => ['dir' => null, 'url' => null],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
'theme' => array(
|
'theme' => [
|
||||||
'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' => [
|
||||||
'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' => [
|
||||||
'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'];
|
||||||
|
@ -52,9 +57,9 @@ class noodlesLibImagePath
|
||||||
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'];
|
||||||
|
@ -62,13 +67,13 @@ class noodlesLibImagePath
|
||||||
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 ['w' => 16, 'h' => 16];
|
||||||
else {
|
else {
|
||||||
$info = getimagesize($img);
|
$info = getimagesize($img);
|
||||||
return array('w'=>$info[0],'h'=>floor($info[1] /3));
|
return ['w' => $info[0], 'h' => floor($info[1] /3)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue