prepare to DC 2.24
This commit is contained in:
parent
f5493d6544
commit
10dcadb1dd
11 changed files with 175 additions and 185 deletions
14
_admin.php
14
_admin.php
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -14,10 +14,10 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
return;
|
||||
}
|
||||
|
||||
$_menu['Plugins']->addItem(
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
__('Noodles'),
|
||||
$core->adminurl->get('admin.plugin.noodles'),
|
||||
dcCore::app()->adminurl->get('admin.plugin.noodles'),
|
||||
dcPage::getPF('noodles/icon.png'),
|
||||
preg_match('/noodles(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
$core->auth->check('admin', $core->blog->id)
|
||||
);
|
||||
dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id)
|
||||
);
|
||||
|
|
18
_define.php
18
_define.php
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -14,16 +14,16 @@ $this->registerModule(
|
|||
'Noodles',
|
||||
'Add users gravatars everywhere',
|
||||
'Jean-Christian Denis and contributors',
|
||||
'0.8',
|
||||
'0.9',
|
||||
[
|
||||
'requires' => [['core', '2.19']],
|
||||
'permissions' => 'admin',
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://github.com/JcDenis/noodles',
|
||||
'details' => 'http://plugins.dotaddict.org/dc2/details/noodles',
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/noodles/master/dcstore.xml',
|
||||
'settings' => [
|
||||
'self' => ''
|
||||
]
|
||||
'self' => '',
|
||||
],
|
||||
]
|
||||
);
|
||||
);
|
||||
|
|
26
_install.php
26
_install.php
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -14,16 +14,16 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$new_version = $core->plugins->moduleInfo('noodles', 'version');
|
||||
$old_version = $core->getVersion('noodles');
|
||||
$new_version = dcCore::app()->plugins->moduleInfo('noodles', 'version');
|
||||
$old_version = dcCore::app()->getVersion('noodles');
|
||||
|
||||
if (version_compare($old_version, $new_version, '>=')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$core->blog->settings->addNamespace('noodles');
|
||||
$core->blog->settings->noodles->put(
|
||||
dcCore::app()->blog->settings->addNamespace('noodles');
|
||||
dcCore::app()->blog->settings->noodles->put(
|
||||
'noodles_active',
|
||||
false,
|
||||
'boolean',
|
||||
|
@ -31,7 +31,7 @@ try {
|
|||
false,
|
||||
true
|
||||
);
|
||||
$core->blog->settings->noodles->put(
|
||||
dcCore::app()->blog->settings->noodles->put(
|
||||
'noodles_api',
|
||||
'http://www.gravatar.com/',
|
||||
'string',
|
||||
|
@ -39,7 +39,7 @@ try {
|
|||
false,
|
||||
true
|
||||
);
|
||||
$core->blog->settings->noodles->put(
|
||||
dcCore::app()->blog->settings->noodles->put(
|
||||
'noodles_image',
|
||||
'',
|
||||
'string',
|
||||
|
@ -47,7 +47,7 @@ try {
|
|||
false,
|
||||
true
|
||||
);
|
||||
$core->blog->settings->noodles->put(
|
||||
dcCore::app()->blog->settings->noodles->put(
|
||||
'noodles_object',
|
||||
'',
|
||||
'string',
|
||||
|
@ -55,11 +55,11 @@ try {
|
|||
false,
|
||||
true
|
||||
);
|
||||
$core->setVersion('noodles', $new_version);
|
||||
dcCore::app()->setVersion('noodles', $new_version);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
|
|
22
_prepend.php
22
_prepend.php
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -14,32 +14,32 @@ if (!defined('DC_RC_PATH')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$__autoload['noodlesImg'] = dirname(__FILE__) . '/inc/lib.noodles.img.php';
|
||||
$__autoload['noodlesLibImagePath'] = dirname(__FILE__) . '/inc/lib.image.path.php';
|
||||
Clearbricks::lib()->autoload(['noodlesImg' => __DIR__ . '/inc/lib.noodles.img.php']);
|
||||
Clearbricks::lib()->autoload(['noodlesLibImagePath' => __DIR__ . '/inc/lib.image.path.php']);
|
||||
|
||||
$core->blog->settings->addNamespace('noodles');
|
||||
dcCore::app()->blog->settings->addNamespace('noodles');
|
||||
|
||||
$core->url->register(
|
||||
dcCore::app()->url->register(
|
||||
'noodlesmodule',
|
||||
'noodles',
|
||||
'^noodles/(.+)$',
|
||||
['urlNoodles', 'noodles']
|
||||
);
|
||||
$core->url->register(
|
||||
dcCore::app()->url->register(
|
||||
'noodlesservice',
|
||||
'noodle',
|
||||
'^noodle/$',
|
||||
['urlNoodles', 'service']
|
||||
);
|
||||
$core->url->register(
|
||||
dcCore::app()->url->register(
|
||||
'noodlescss',
|
||||
'noodles.css',
|
||||
'^noodles\.css',
|
||||
['urlNoodles', 'css']
|
||||
);
|
||||
$core->url->register(
|
||||
dcCore::app()->url->register(
|
||||
'noodlesjs',
|
||||
'noodles.js',
|
||||
'^noodles\.js',
|
||||
['urlNoodles', 'js']
|
||||
);
|
||||
);
|
||||
|
|
68
_public.php
68
_public.php
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -14,19 +14,19 @@ if (!defined('DC_RC_PATH')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!$core->blog->settings->noodles->noodles_active) {
|
||||
if (!dcCore::app()->blog->settings->noodles->noodles_active) {
|
||||
return null;
|
||||
}
|
||||
|
||||
include dirname(__FILE__) . '/inc/_default_noodles.php';
|
||||
require_once dirname(__FILE__) . '/inc/_noodles_functions.php';
|
||||
include __DIR__ . '/inc/_default_noodles.php';
|
||||
require_once __DIR__ . '/inc/_noodles_functions.php';
|
||||
|
||||
$core->addBehavior('publicHeadContent', ['publicNoodles', 'publicHeadContent']);
|
||||
dcCore::app()->addBehavior('publicHeadContent', ['publicNoodles', 'publicHeadContent']);
|
||||
|
||||
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__) . '/default-templates');
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), __DIR__ . '/default-templates');
|
||||
|
||||
global $__noodles;
|
||||
$__noodles = noodles::decode($core->blog->settings->noodles->noodles_object);
|
||||
$__noodles = noodles::decode(dcCore::app()->blog->settings->noodles->noodles_object);
|
||||
|
||||
if ($__noodles->isEmpty()) {
|
||||
$__noodles = $__default_noodles;
|
||||
|
@ -36,18 +36,18 @@ if ($__noodles->isEmpty()) {
|
|||
|
||||
foreach ($__noodles->noodles() as $noodle) {
|
||||
if ($noodle->active && $noodle->hasPhpCallback()) {
|
||||
$noodle->phpCallback($core);
|
||||
$noodle->phpCallback(dcCore::app());
|
||||
}
|
||||
}
|
||||
|
||||
class publicNoodles
|
||||
{
|
||||
public static function publicHeadContent($core)
|
||||
public static function publicHeadContent()
|
||||
{
|
||||
echo
|
||||
dcUtils::cssLoad($core->blog->url . $core->url->getURLFor('noodlescss')) .
|
||||
dcUtils::jsLoad($core->blog->url . $core->url->getBase('noodlesmodule') . '/js/jquery.noodles.js') .
|
||||
dcUtils::jsLoad($core->blog->url . $core->url->getURLFor('noodlesjs'));
|
||||
dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('noodlescss')) .
|
||||
dcUtils::jsLoad(dcCore::app()->blog->url . dcCore::app()->url->getBase('noodlesmodule') . '/js/jquery.noodles.js') .
|
||||
dcUtils::jsLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('noodlesjs'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class urlNoodles extends dcUrlHandlers
|
|||
{
|
||||
public static function css($args)
|
||||
{
|
||||
global $core, $__noodles;
|
||||
global $__noodles;
|
||||
|
||||
$css = '';
|
||||
foreach ($__noodles->noodles() as $noodle) {
|
||||
|
@ -74,7 +74,7 @@ class urlNoodles extends dcUrlHandlers
|
|||
|
||||
public static function js($args)
|
||||
{
|
||||
global $core, $__noodles;
|
||||
global $__noodles;
|
||||
|
||||
$targets = [];
|
||||
foreach ($__noodles->noodles() as $noodle) {
|
||||
|
@ -91,7 +91,7 @@ class urlNoodles extends dcUrlHandlers
|
|||
|
||||
echo
|
||||
"\$(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(dcCore::app()->blog->url . dcCore::app()->url->getBase('noodlesservice') . '/') . "'; \n" .
|
||||
"\$.fn.noodles.defaults.service_func = '" . html::escapeJS('getNoodle') . "'; \n" .
|
||||
implode("\n", $targets) .
|
||||
"})\n";
|
||||
|
@ -101,8 +101,6 @@ class urlNoodles extends dcUrlHandlers
|
|||
|
||||
public static function service($args)
|
||||
{
|
||||
global $core;
|
||||
|
||||
header('Content-Type: text/xml; charset=UTF-8');
|
||||
|
||||
$rsp = new xmlTag('rsp');
|
||||
|
@ -110,23 +108,23 @@ class urlNoodles extends dcUrlHandlers
|
|||
$i = !empty($_POST['noodleId']) ? $_POST['noodleId'] : null;
|
||||
$c = !empty($_POST['noodleContent']) ? $_POST['noodleContent'] : null;
|
||||
|
||||
if (!$core->blog->settings->noodles->noodles_active) {
|
||||
if (!dcCore::app()->blog->settings->noodles->noodles_active) {
|
||||
$rsp->status = 'failed';
|
||||
$rsp->message(__('noodles is disabled on this blog'));
|
||||
echo $rsp->toXML(1);
|
||||
echo $rsp->toXML(true);
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($i === null || $c === null) {
|
||||
$rsp->status = 'failed';
|
||||
$rsp->message(__('noodles failed because of missing informations'));
|
||||
echo $rsp->toXML(1);
|
||||
echo $rsp->toXML(true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$__noodles = noodles::decode($core->blog->settings->noodles->noodles_object);
|
||||
$__noodles = noodles::decode(dcCore::app()->blog->settings->noodles->noodles_object);
|
||||
|
||||
if ($__noodles->isEmpty()) {
|
||||
$__noodles = $GLOBALS['__default_noodles'];
|
||||
|
@ -134,7 +132,7 @@ class urlNoodles extends dcUrlHandlers
|
|||
} catch (Excetpion $e) {
|
||||
$rsp->status = 'failed';
|
||||
$rsp->message(__('Failed to load default noodles'));
|
||||
echo $rsp->toXML(1);
|
||||
echo $rsp->toXML(true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -142,7 +140,7 @@ class urlNoodles extends dcUrlHandlers
|
|||
if (!$__noodles->exists($i)) {
|
||||
$rsp->status = 'failed';
|
||||
$rsp->message(__('Failed to load noodle'));
|
||||
echo $rsp->toXML(1);
|
||||
echo $rsp->toXML(true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -150,10 +148,10 @@ class urlNoodles extends dcUrlHandlers
|
|||
$m = $__noodles->get($i)->jsCallback($__noodles->get($i), $c);
|
||||
$s = $__noodles->get($i)->size;
|
||||
$r = $__noodles->get($i)->rating;
|
||||
$d = $core->blog->settings->noodles->noodles_image ?
|
||||
urlencode(noodlesLibImagePath::getUrl($core, 'noodles')) : '';
|
||||
$d = dcCore::app()->blog->settings->noodles->noodles_image ?
|
||||
urlencode(noodlesLibImagePath::getUrl('noodles')) : '';
|
||||
|
||||
$u = $core->blog->settings->noodles->noodles_api;
|
||||
$u = dcCore::app()->blog->settings->noodles->noodles_api;
|
||||
if (empty($u)) {
|
||||
$u = 'http://www.gravatar.com/';
|
||||
}
|
||||
|
@ -174,15 +172,13 @@ class urlNoodles extends dcUrlHandlers
|
|||
$rsp->insertNode($im);
|
||||
|
||||
$rsp->status = 'ok';
|
||||
echo $rsp->toXML(1);
|
||||
echo $rsp->toXML(true);
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function noodles($args)
|
||||
{
|
||||
global $core;
|
||||
|
||||
if (!$core->blog->settings->noodles->noodles_active) {
|
||||
if (!dcCore::app()->blog->settings->noodles->noodles_active) {
|
||||
self::p404();
|
||||
|
||||
return;
|
||||
|
@ -213,12 +209,12 @@ class urlNoodles extends dcUrlHandlers
|
|||
header('Content-Type: ' . $type . '; charset=UTF-8');
|
||||
header('Content-Length: ' . filesize($f));
|
||||
|
||||
if ($type != 'text/css' || $core->blog->settings->system->url_scan == 'path_info') {
|
||||
if ($type != 'text/css' || dcCore::app()->blog->settings->system->url_scan == 'path_info') {
|
||||
readfile($f);
|
||||
} else {
|
||||
echo preg_replace(
|
||||
'#url\((?!(http:)|/)#',
|
||||
'url(' . $core->blog->url . $core->url->getBase('noodlesmodule') . '/',
|
||||
'url(' . dcCore::app()->blog->url . dcCore::app()->url->getBase('noodlesmodule') . '/',
|
||||
file_get_contents($f)
|
||||
);
|
||||
}
|
||||
|
@ -231,7 +227,7 @@ class urlNoodles extends dcUrlHandlers
|
|||
if (strstr($file, '..') !== false) {
|
||||
return false;
|
||||
}
|
||||
$paths = $GLOBALS['core']->tpl->getPath();
|
||||
$paths = dcCore::app()->tpl->getPath();
|
||||
|
||||
foreach ($paths as $path) {
|
||||
if (preg_match('/tpl(\/|)$/', $path)) {
|
||||
|
@ -244,4 +240,4 @@ class urlNoodles extends dcUrlHandlers
|
|||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -56,4 +56,4 @@ $this->addDirectAction(
|
|||
'noodles',
|
||||
/* description */
|
||||
sprintf(__('delete %s plugin files'), 'noodles')
|
||||
);
|
||||
);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ if (!defined('DC_RC_PATH')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
require dirname(__FILE__) . '/class.noodles.php';
|
||||
require __DIR__ . '/class.noodles.php';
|
||||
|
||||
global $__default_noodles;
|
||||
$__default_noodles = new noodles();
|
||||
|
@ -38,7 +38,7 @@ $__default_noodles
|
|||
->target('.post-title a')
|
||||
->css('margin-right:2px;');
|
||||
|
||||
if ($core->plugins->moduleExists('widgets')) {
|
||||
if (dcCore::app()->plugins->moduleExists('widgets')) {
|
||||
# Widget Selected entries
|
||||
$__default_noodles
|
||||
->add('bestof', __('Selected entries'), ['genericNoodles', 'postURL'])
|
||||
|
@ -60,8 +60,8 @@ if ($core->plugins->moduleExists('widgets')) {
|
|||
}
|
||||
|
||||
# Plugin auhtorMode
|
||||
if ($core->plugins->moduleExists('authorMode')
|
||||
&& $core->blog->settings->authormode->authormode_active
|
||||
if (dcCore::app()->plugins->moduleExists('authorMode')
|
||||
&& dcCore::app()->blog->settings->authormode->authormode_active
|
||||
) {
|
||||
$__default_noodles
|
||||
->add('authorswidget', __('Authors widget'), ['authormodeNoodles', 'authors'])
|
||||
|
@ -84,8 +84,8 @@ if ($core->plugins->moduleExists('authorMode')
|
|||
}
|
||||
|
||||
# Plugin rateIt
|
||||
if ($core->plugins->moduleExists('rateIt')
|
||||
&& $core->blog->settings->rateit->rateit_active
|
||||
if (dcCore::app()->plugins->moduleExists('rateIt')
|
||||
&& dcCore::app()->blog->settings->rateit->rateit_active
|
||||
) {
|
||||
$__default_noodles
|
||||
->add('rateitpostsrank', __('Top rated entries'), ['genericNoodles', 'postURL'])
|
||||
|
@ -94,7 +94,7 @@ if ($core->plugins->moduleExists('rateIt')
|
|||
}
|
||||
|
||||
# Plugin lastpostsExtend
|
||||
if ($core->plugins->moduleExists('lastpostsExtend')) {
|
||||
if (dcCore::app()->plugins->moduleExists('lastpostsExtend')) {
|
||||
$__default_noodles
|
||||
->add('lastpostsextend', __('Last entries (extend)'), ['genericNoodles', 'postURL'])
|
||||
->target('.lastpostsextend ul li a')
|
||||
|
@ -102,4 +102,4 @@ if ($core->plugins->moduleExists('lastpostsExtend')) {
|
|||
}
|
||||
|
||||
# --BEHAVIOR-- initDefaultNoodles
|
||||
$core->callBehavior('initDefaultNoodles', $__default_noodles);
|
||||
dcCore::app()->callBehavior('initDefaultNoodles', $__default_noodles);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -18,15 +18,13 @@ class genericNoodles
|
|||
{
|
||||
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 = dcCore::app()->getPostTypes();
|
||||
$reg = '@^' . str_replace('%s', '(.*?)', preg_quote(dcCore::app()->blog->url . $types['post']['public_url'])) . '$@';
|
||||
$ok = preg_match($reg, $content, $m);
|
||||
if (!$ok || !$m[1]) {
|
||||
return '';
|
||||
}
|
||||
$rs = $core->blog->getPosts(['no_content' => 1, 'post_url' => urldecode($m[1]), 'limit' => 1]);
|
||||
$rs = dcCore::app()->blog->getPosts(['no_content' => 1, 'post_url' => urldecode($m[1]), 'limit' => 1]);
|
||||
if ($rs->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
|
@ -38,7 +36,7 @@ class genericNoodles
|
|||
# Miscellaneous
|
||||
class othersNoodles
|
||||
{
|
||||
public static function publicPosts($core, $noodle)
|
||||
public static function publicPosts($noodle)
|
||||
{
|
||||
if (!$noodle->active) {
|
||||
return null;
|
||||
|
@ -46,19 +44,19 @@ class othersNoodles
|
|||
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
||||
'publicEntryBeforeContent' : 'publicEntryAfterContent';
|
||||
|
||||
$core->addBehavior($bhv, ['othersNoodles', 'publicEntryContent']);
|
||||
dcCore::app()->addBehavior($bhv, ['othersNoodles', 'publicEntryContent']);
|
||||
}
|
||||
|
||||
public static function publicEntryContent()
|
||||
{
|
||||
global $core,$_ctx,$__noodles;
|
||||
global $__noodles;
|
||||
|
||||
$m = $_ctx->posts->getAuthorEmail(false);
|
||||
$m = dcCore::app()->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')) : '';
|
||||
$d = dcCore::app()->blog->settings->noodles->noodles_image ?
|
||||
urlencode(noodlesLibImagePath::getUrl('noodles')) : '';
|
||||
|
||||
echo
|
||||
'<img class="noodles-posts" style="width:' . $s . 'px;height:' . $s . 'px;' . $c . '"' .
|
||||
|
@ -66,7 +64,7 @@ class othersNoodles
|
|||
'?s=' . $s . '&r=' . $r . '&d=' . $d . '" alt="" />';
|
||||
}
|
||||
|
||||
public static function publicComments($core, $noodle)
|
||||
public static function publicComments($noodle)
|
||||
{
|
||||
if (!$noodle->active) {
|
||||
return null;
|
||||
|
@ -75,19 +73,19 @@ class othersNoodles
|
|||
$bhv = $noodle->place == 'prepend' || $noodle->place == 'before' ?
|
||||
'publicCommentBeforeContent' : 'publicCommentAfterContent';
|
||||
|
||||
$core->addBehavior($bhv, ['othersNoodles', 'publicCommentContent']);
|
||||
dcCore::app()->addBehavior($bhv, ['othersNoodles', 'publicCommentContent']);
|
||||
}
|
||||
|
||||
public static function publicCommentContent()
|
||||
{
|
||||
global $core,$_ctx,$__noodles;
|
||||
global $__noodles;
|
||||
|
||||
$m = $_ctx->comments->getEmail(false);
|
||||
$m = dcCore::app()->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')) : '';
|
||||
$d = dcCore::app()->blog->settings->noodles->noodles_image ?
|
||||
urlencode(noodlesLibImagePath::getUrl('noodles')) : '';
|
||||
|
||||
echo
|
||||
'<img class="noodles-comments" style="width:' . $s . 'px;height:' . $s . 'px;' . $c . '"' .
|
||||
|
@ -101,13 +99,11 @@ class widgetsNoodles
|
|||
{
|
||||
public static function lastcomments($noodle, $content = '')
|
||||
{
|
||||
global $core;
|
||||
|
||||
$ok = preg_match('@\#c([0-9]+)$@', urldecode($content), $m);
|
||||
if (!$ok || !$m[1]) {
|
||||
return '';
|
||||
}
|
||||
$rs = $core->blog->getComments(['no_content' => 1, 'comment_id' => $m[1], 'limit' => 1]);
|
||||
$rs = dcCore::app()->blog->getComments(['no_content' => 1, 'comment_id' => $m[1], 'limit' => 1]);
|
||||
if (!$rs->isEmpty()) {
|
||||
return $rs->comment_email;
|
||||
}
|
||||
|
@ -121,13 +117,11 @@ class authormodeNoodles
|
|||
{
|
||||
public static function authors($noodle, $content = '')
|
||||
{
|
||||
global $core;
|
||||
|
||||
$ok = preg_match('@\/([^\/]*?)$@', $content, $m);
|
||||
if (!$ok || !$m[1]) {
|
||||
return '';
|
||||
}
|
||||
$rs = $core->getUser($m[1]);
|
||||
$rs = dcCore::app()->getUser($m[1]);
|
||||
if ($rs->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
|
@ -135,29 +129,29 @@ class authormodeNoodles
|
|||
return $rs->user_email;
|
||||
}
|
||||
|
||||
public static function author($core, $noodle)
|
||||
public static function author($noodle)
|
||||
{
|
||||
if ($noodle->active) {
|
||||
$core->addBehavior('publicHeadContent', ['authormodeNoodles', 'publicHeadContent']);
|
||||
dcCore::app()->addBehavior('publicHeadContent', ['authormodeNoodles', 'publicHeadContent']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function publicHeadContent()
|
||||
{
|
||||
global $core, $_ctx, $__noodles;
|
||||
global $__noodles;
|
||||
|
||||
if ($_ctx->current_tpl != 'author.html') {
|
||||
if (dcCore::app()->ctx->current_tpl != 'author.html') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$id = $_ctx->users->user_id;
|
||||
$u = $core->getUser($id);
|
||||
$id = dcCore::app()->ctx->users->user_id;
|
||||
$u = dcCore::app()->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')) : '';
|
||||
$d = dcCore::app()->blog->settings->noodles->noodles_image ?
|
||||
urlencode(noodlesLibImagePath::getUrl('noodles')) : '';
|
||||
|
||||
echo
|
||||
'<script type="text/javascript">' . "\n" .
|
||||
|
@ -171,4 +165,4 @@ class authormodeNoodles
|
|||
"\n//]]>\n" .
|
||||
"</script>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -87,7 +87,7 @@ class noodle
|
|||
'rating' => 'g',
|
||||
'size' => 16,
|
||||
'target' => '',
|
||||
'place' => 'prepend'
|
||||
'place' => 'prepend',
|
||||
];
|
||||
|
||||
public function __construct($id, $name, $js_callback, $php_callback = null)
|
||||
|
@ -122,13 +122,13 @@ class noodle
|
|||
return !empty($this->js_callback);
|
||||
}
|
||||
|
||||
public function phpCallback($core)
|
||||
public function phpCallback()
|
||||
{
|
||||
if (!is_callable($this->php_callback)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return call_user_func($this->php_callback, $core, $this);
|
||||
return call_user_func($this->php_callback, $this);
|
||||
}
|
||||
|
||||
public function hasPhpCallback()
|
||||
|
@ -142,32 +142,32 @@ class noodle
|
|||
case 'active':
|
||||
$this->settings['active'] = abs((int) $value);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'rating':
|
||||
$this->settings['rating'] = in_array($value, ['g', 'pg', 'r', 'x']) ? $value : 'g';
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'size':
|
||||
$this->settings['size'] = in_array($value, [16, 24, 32, 48, 56, 64, 92, 128, 256]) ? $value : 16;
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'css':
|
||||
$this->settings['css'] = (string) $value;
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'target':
|
||||
$this->settings['target'] = (string) $value;
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'place':
|
||||
$this->settings['place'] = in_array($value, ['append', 'prepend', 'before', 'after']) ? $value : 'prepend';
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -217,4 +217,4 @@ class noodle
|
|||
{
|
||||
return $this->get($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -18,10 +18,10 @@ class noodlesLibImagePath
|
|||
{
|
||||
public static $version = '1.1';
|
||||
|
||||
public static function getArray($core, $m = '')
|
||||
public static function getArray($m = '')
|
||||
{
|
||||
if (!$core->plugins->moduleExists($m)
|
||||
|| !$core->url->getBase($m . 'module')
|
||||
if (!dcCore::app()->plugins->moduleExists($m)
|
||||
|| !dcCore::app()->url->getBase($m . 'module')
|
||||
) {
|
||||
return [
|
||||
'theme' => ['dir' => null, 'url' => null],
|
||||
|
@ -32,23 +32,23 @@ class noodlesLibImagePath
|
|||
|
||||
return [
|
||||
'theme' => [
|
||||
'dir' => path::real($core->blog->themes_path . '/' . $core->blog->settings->system->theme . '/img') . '/' . $m . '-default-image.png',
|
||||
'url' => $core->blog->settings->system->themes_url . $core->blog->settings->system->theme . '/img/' . $m . '-default-image.png'
|
||||
'dir' => path::real(dcCore::app()->blog->themes_path . '/' . dcCore::app()->blog->settings->system->theme . '/img') . '/' . $m . '-default-image.png',
|
||||
'url' => dcCore::app()->blog->settings->system->themes_url . dcCore::app()->blog->settings->system->theme . '/img/' . $m . '-default-image.png',
|
||||
],
|
||||
'public' => [
|
||||
'dir' => path::real($core->blog->public_path) . '/' . $m . '-default-image.png',
|
||||
'url' => $core->blog->host . path::clean($core->blog->settings->system->public_url) . '/' . $m . '-default-image.png'
|
||||
'dir' => path::real(dcCore::app()->blog->public_path) . '/' . $m . '-default-image.png',
|
||||
'url' => dcCore::app()->blog->host . path::clean(dcCore::app()->blog->settings->system->public_url) . '/' . $m . '-default-image.png',
|
||||
],
|
||||
'module' => [
|
||||
'dir' => path::real($core->plugins->moduleRoot($m) . '/default-templates/img') . '/' . $m . '-default-image.png',
|
||||
'url' => $core->blog->url . $core->url->getBase($m . 'module') . '/img/' . $m . '-default-image.png'
|
||||
]
|
||||
'dir' => path::real(dcCore::app()->plugins->moduleRoot($m) . '/default-templates/img') . '/' . $m . '-default-image.png',
|
||||
'url' => dcCore::app()->blog->url . dcCore::app()->url->getBase($m . 'module') . '/img/' . $m . '-default-image.png',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public static function getUrl($core, $m = '')
|
||||
public static function getUrl($m = '')
|
||||
{
|
||||
$files = self::getArray($core, $m);
|
||||
$files = self::getArray($m);
|
||||
foreach ($files as $k => $file) {
|
||||
if (file_exists($files[$k]['dir'])) {
|
||||
return $files[$k]['url'];
|
||||
|
@ -58,9 +58,9 @@ class noodlesLibImagePath
|
|||
return null;
|
||||
}
|
||||
|
||||
public static function getPath($core, $m = '')
|
||||
public static function getPath($m = '')
|
||||
{
|
||||
$files = self::getArray($core, $m);
|
||||
$files = self::getArray($m);
|
||||
foreach ($files as $k => $file) {
|
||||
if (file_exists($files[$k]['dir'])) {
|
||||
return $files[$k]['dir'];
|
||||
|
@ -70,13 +70,13 @@ class noodlesLibImagePath
|
|||
return null;
|
||||
}
|
||||
|
||||
public static function getSize($core, $m = '')
|
||||
public static function getSize($m = '')
|
||||
{
|
||||
if (!($img = self::getPath($core, $m))) {
|
||||
if (!($img = self::getPath($m))) {
|
||||
return ['w' => 16, 'h' => 16];
|
||||
}
|
||||
$info = getimagesize($img);
|
||||
|
||||
return ['w' => $info[0], 'h' => floor($info[1] / 3)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
52
index.php
52
index.php
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief noodles, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
@ -14,11 +14,11 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
dcPage::check('admin');
|
||||
dcPage::check(dcAuth::PERMISSION_CONTENT_ADMIN);
|
||||
|
||||
include dirname(__FILE__) . '/inc/_default_noodles.php';
|
||||
include __DIR__ . '/inc/_default_noodles.php';
|
||||
|
||||
$s = $core->blog->settings->noodles;
|
||||
$s = dcCore::app()->blog->settings->noodles;
|
||||
|
||||
$__noodles = noodles::decode($s->noodles_object);
|
||||
if ($__noodles->isEmpty()) {
|
||||
|
@ -32,11 +32,11 @@ if ($__noodles->isEmpty()) {
|
|||
$__noodles->set($id, $noodle);
|
||||
}
|
||||
}
|
||||
$public_path = path::real($core->blog->public_path);
|
||||
$public_path = path::real(dcCore::app()->blog->public_path);
|
||||
if (!is_dir($public_path) || !is_writable($public_path)) {
|
||||
$public_path = false;
|
||||
}
|
||||
$default_images = files::scandir(dirname(__FILE__) . '/default-templates/img/');
|
||||
$default_images = files::scandir(__DIR__ . '/default-templates/img/');
|
||||
if (!is_array($default_images)) {
|
||||
$default_images = [];
|
||||
}
|
||||
|
@ -44,20 +44,20 @@ $default_image = $s->noodles_image;
|
|||
|
||||
$combo_api = [
|
||||
'gravatar' => 'http://www.gravatar.com/',
|
||||
'libravatar' => 'http://cdn.libravatar.org/'
|
||||
'libravatar' => 'http://cdn.libravatar.org/',
|
||||
];
|
||||
|
||||
$combo_place = [
|
||||
__('Begin') => 'prepend',
|
||||
__('End') => 'append',
|
||||
__('Before') => 'before',
|
||||
__('After') => 'after'
|
||||
__('After') => 'after',
|
||||
];
|
||||
$combo_rating = [
|
||||
'G' => 'g',
|
||||
'PG' => 'pg',
|
||||
'R' => 'r',
|
||||
'X' => 'x'
|
||||
'X' => 'x',
|
||||
];
|
||||
$combo_size = [
|
||||
'16px' => 16,
|
||||
|
@ -68,7 +68,7 @@ $combo_size = [
|
|||
'64px' => 64,
|
||||
'92px' => 92,
|
||||
'128px' => 128,
|
||||
'256px' => 256
|
||||
'256px' => 256,
|
||||
];
|
||||
|
||||
if (!empty($_POST['save'])) {
|
||||
|
@ -94,7 +94,7 @@ if (!empty($_POST['save'])) {
|
|||
throw new Exception(__('Failed to save image'));
|
||||
}
|
||||
|
||||
// Default gravatar.com avatar
|
||||
// Default gravatar.com avatar
|
||||
} elseif ($_POST['noodles_image'] == 'gravatar.com') {
|
||||
$s->put('noodles_image', 0, 'boolean');
|
||||
|
||||
|
@ -126,28 +126,28 @@ if (!empty($_POST['save'])) {
|
|||
->set('css', $bloc['css'] ?? '')
|
||||
->set('target', $bloc['target'] ?? '')
|
||||
->set('place', $bloc['place'] ?? 'prepend')
|
||||
;
|
||||
;
|
||||
}
|
||||
$s->put('noodles_object', $__noodles->encode(), 'string');
|
||||
|
||||
$core->blog->triggerBlog();
|
||||
dcPage::addSuccessNotice(__('Configuration successfully updated'));
|
||||
$core->adminurl->redirect('admin.plugin.noodles');
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
dcAdminNotices::addSuccessNotice(__('Configuration successfully updated'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.noodles');
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
echo '<html><head><title>' . __('Noodles') . '</title></head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML($core->blog->name) => '',
|
||||
__('Noodles') => '',
|
||||
__('Plugin configuration') => ''
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
__('Noodles') => '',
|
||||
__('Plugin configuration') => '',
|
||||
]) .
|
||||
dcPage::notices() . '
|
||||
|
||||
<form id="module_config" action="' .
|
||||
$core->adminurl->get('admin.plugin.noodles') .
|
||||
dcCore::app()->adminurl->get('admin.plugin.noodles') .
|
||||
'" method="post" enctype="multipart/form-data">
|
||||
<h3>' . sprintf(__('Configure "%s"'), __('Noodles')) . '</h3>
|
||||
<div class="fieldset"><h4>' . __('Activation') . '</h4>
|
||||
|
@ -188,7 +188,7 @@ if (!empty($public_path)) {
|
|||
|
||||
echo '<div class="one-box">';
|
||||
|
||||
if (null !== ($default_image_path = noodlesLibImagePath::getPath($core, 'noodles'))) {
|
||||
if (null !== ($default_image_path = noodlesLibImagePath::getPath('noodles'))) {
|
||||
$sz = getimagesize($default_image_path);
|
||||
$sz[2] = files::size(filesize($default_image_path));
|
||||
|
||||
|
@ -197,7 +197,7 @@ if (null !== ($default_image_path = noodlesLibImagePath::getPath($core, 'noodles
|
|||
<p>' . form::radio(['noodles_image', 'public_image'], 'existing', !empty($default_image)) . '
|
||||
<label class="classic" for="public_image">' . __('Blog default image') . '</label></p>
|
||||
<div class="two-box"><div class="box">
|
||||
<p><img src="' . noodlesLibImagePath::getUrl($core, 'noodles') . '?' . rand() . '" alt="" /></p>
|
||||
<p><img src="' . noodlesLibImagePath::getUrl('noodles') . '?' . rand() . '" alt="" /></p>
|
||||
</div><div class="box">
|
||||
<p>' . $sz[0] . 'x' . $sz[1] . '<br />' . $sz[2] . '</p>
|
||||
</div></div>
|
||||
|
@ -265,7 +265,7 @@ echo '
|
|||
|
||||
<p class="clear">
|
||||
<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' .
|
||||
$core->formNonce() . '</p>
|
||||
dcCore::app()->formNonce() . '</p>
|
||||
</form>
|
||||
|
||||
</body></html>';
|
||||
</body></html>';
|
||||
|
|
Loading…
Reference in a new issue