don't give a f* about module name

This commit is contained in:
Jean-Christian Paul Denis 2022-12-10 17:16:41 +01:00
parent 3da605b8cf
commit 31ba55df92
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
11 changed files with 69 additions and 71 deletions

View File

@ -14,7 +14,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
require_once __DIR__ . '/_widgets.php';
@ -22,15 +22,15 @@ $perm = dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id);
if (dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
&& '' != dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_user
if (dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_active
&& '' != dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_user
) {
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Feeds server'),
dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer'),
dcPage::getPF('zoneclearFeedServer/icon.svg'),
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
dcPage::getPF(basename(__DIR__) . '/icon.svg'),
preg_match(
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer')) . '(&.*)?$/',
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/',
$_SERVER['REQUEST_URI']
),
$perm
@ -94,9 +94,9 @@ class zcfsAdminBehaviors
{
$favs->register('zcfs', [
'title' => __('Feeds server'),
'url' => dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer'),
'small-icon' => dcPage::getPF('zoneclearFeedServer/icon.svg'),
'large-icon' => dcPage::getPF('zoneclearFeedServer/icon.svg'),
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
'small-icon' => dcPage::getPF(basename(__DIR__) . '/icon.svg'),
'large-icon' => dcPage::getPF(basename(__DIR__) . '/icon.svg'),
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_USAGE,
dcAuth::PERMISSION_CONTENT_ADMIN,
@ -120,9 +120,9 @@ class zcfsAdminBehaviors
}
$fav['title'] .= '<br />' . sprintf(__('%s feed disabled', '%s feeds disabled', $count), $count);
$fav['large-icon'] = dcPage::getPF('zoneclearFeedServer/icon-pdate.svg');
$fav['large-icon'] = dcPage::getPF(basename(__DIR__) . '/icon-update.svg');
$fav['url'] = dcCore::app()->adminurl->get(
'admin.plugin.zoneclearFeedServer',
'admin.plugin.' . basename(__DIR__),
['part' => 'feeds', 'sortby' => 'feed_status', 'order' => 'asc']
);
}
@ -183,7 +183,7 @@ class zcfsAdminBehaviors
*/
public static function adminPostHeaders()
{
return dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/post.js'));
return dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/post.js'));
}
/**
@ -241,7 +241,7 @@ class zcfsAdminBehaviors
$edit = sprintf(
'<p><a href="%s">%s</a></p>',
dcCore::app()->adminurl->get(
'admin.plugin.zoneclearFeedServer',
'admin.plugin.' . basename(__DIR__),
['part' => 'feed', 'feed_id' => $fid->meta_id]
),
__('Edit this feed')

View File

@ -17,8 +17,8 @@ if (!defined('DC_CONTEXT_MODULE')) {
$redir = empty($_REQUEST['redir']) ? dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings --
dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
$active = (bool) $s->zoneclearFeedServer_active;
$pub_active = (bool) $s->zoneclearFeedServer_pub_active;
@ -79,7 +79,7 @@ if (!empty($_POST['save'])) {
);
dcCore::app()->adminurl->redirect(
'admin.plugins',
['module' => 'zoneclearFeedServer', 'conf' => 1, 'redir' => dcCore::app()->admin->list->getRedir()]
['module' => basename(__DIR__), 'conf' => 1, 'redir' => dcCore::app()->admin->list->getRedir()]
);
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
@ -124,7 +124,7 @@ __('Enable plugin') . '</label></p>
<div class="fieldset">';
if (dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
if ($s->zoneclearFeedServer_pub_active) {
echo sprintf(
'<p><a class="onblog_link outgoing" href="%s" title="%s">%s <img alt="" src="images/outgoing-link.svg"></a></p>',
$pub_page_url,

View File

@ -25,8 +25,8 @@ $this->registerModule(
dcAuth::PERMISSION_CONTENT_ADMIN,
]),
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/zoneclearFeedServer',
'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman',
'repository' => 'https://raw.githubusercontent.com/JcDenis/zoneclearFeedServer/master/dcstore.xml',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
]
);

View File

@ -16,5 +16,5 @@ if (!defined('DC_RC_PATH')) {
class initZoneclearFeedServer
{
public const FEED_TABLE_NAME = 'zc_feed';
public const TABLE_NAME = 'zc_feed';
}

View File

@ -25,7 +25,7 @@ try {
# Tables
$t = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$t->{initZoneclearFeedServer::FEED_TABLE_NAME}
$t->{initZoneclearFeedServer::TABLE_NAME}
->feed_id('bigint', 0, false)
->feed_creadt('timestamp', 0, false, 'now()')
->feed_upddt('timestamp', 0, false, 'now()')

View File

@ -15,8 +15,8 @@ if (!defined('DC_RC_PATH')) {
}
# Namespace for settings
dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
# Widgets
require_once __DIR__ . '/_widgets.php';
@ -236,7 +236,7 @@ class zcfsRsExtPosts extends rsExtPost
public static function getURL(dcRecord $rs): string
{
$url = $rs->zcFeed('url');
$types = @unserialize(dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_title_redir);
$types = @unserialize(dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_post_title_redir);
$full = is_array($types) && in_array(dcCore::app()->url->type, $types);
return $url && $full ?
@ -257,7 +257,7 @@ class zcfsRsExtPosts extends rsExtPost
$content = self::zcFeedBrother('getContent', [&$rs, $absolute_urls]);
if ($url && $sitename && $rs->post_type == 'post') {
$types = @unserialize(dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_full_tpl);
$types = @unserialize(dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_post_full_tpl);
if (is_array($types) && in_array(dcCore::app()->url->type, $types)) {
return $content . sprintf(
@ -297,7 +297,7 @@ class zcfsUrlHandler extends dcUrlHandlers
*/
public static function zcFeedsPage($args)
{
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
# Not active
if (!$s->zoneclearFeedServer_active) {

View File

@ -14,15 +14,13 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
$mod_id = 'zoneclearFeedServer';
$this->addUserAction(
/* type */
'settings',
/* action */
'delete_all',
/* ns */
$mod_id,
basename(__DIR__),
/* desc */
__('delete all settings')
);
@ -32,7 +30,7 @@ $this->addUserAction(
/* action */
'delete',
/* ns */
initZoneclearFeedServer::FEED_TABLE_NAME,
initZoneclearFeedServer::TABLE_NAME,
/* desc */
__('delete table')
);
@ -42,7 +40,7 @@ $this->addUserAction(
/* action */
'delete',
/* ns */
$mod_id,
basename(__DIR__),
/* desc */
__('delete plugin files')
);
@ -52,7 +50,7 @@ $this->addUserAction(
/* action */
'delete',
/* ns */
$mod_id,
basename(__DIR__),
/* desc */
__('delete the version number')
);
@ -63,9 +61,9 @@ $this->addDirectAction(
/* action */
'delete_all',
/* ns */
$mod_id,
basename(__DIR__),
/* desc */
sprintf(__('delete all %s settings'), $mod_id)
sprintf(__('delete all %s settings'), basename(__DIR__))
);
$this->addDirectAction(
/* type */
@ -73,9 +71,9 @@ $this->addDirectAction(
/* action */
'delete',
/* ns */
initZoneclearFeedServer::FEED_TABLE_NAME,
initZoneclearFeedServer::TABLE_NAME,
/* desc */
sprintf(__('delete %s table'), $mod_id)
sprintf(__('delete %s table'), basename(__DIR__))
);
$this->addDirectAction(
/* type */
@ -83,9 +81,9 @@ $this->addDirectAction(
/* action */
'delete',
/* ns */
$mod_id,
basename(__DIR__),
/* desc */
sprintf(__('delete %s plugin files'), $mod_id)
sprintf(__('delete %s plugin files'), basename(__DIR__))
);
$this->addDirectAction(
/* type */
@ -93,9 +91,9 @@ $this->addDirectAction(
/* action */
'delete',
/* ns */
$mod_id,
basename(__DIR__),
/* desc */
sprintf(__('delete %s version number'), $mod_id)
sprintf(__('delete %s version number'), basename(__DIR__))
);
$this->addDirectCallback(
/* function */
@ -106,7 +104,7 @@ $this->addDirectCallback(
function zoneclearfeedServerUninstall($id)
{
if ($id != 'zoneclearFeedServer') {
if ($id != basename(__DIR__)) {
return null;
}
//...

View File

@ -152,7 +152,7 @@ class zoneclearFeedServerWidget
return null;
}
if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_active
|| !$w->checkHomeOnly(dcCore::app()->url->type)
) {
return null;
@ -184,7 +184,7 @@ class zoneclearFeedServerWidget
$i++;
}
$pub = '';
if ($w->pagelink && dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
if ($w->pagelink && dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_pub_active) {
$pub = sprintf(
'<p><strong><a href="%s">%s</a></strong></p>',
dcCore::app()->blog->url . dcCore::app()->url->getBase('zoneclearFeedsPage'),
@ -212,7 +212,7 @@ class zoneclearFeedServerWidget
return;
}
if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_active
|| !$w->checkHomeOnly(dcCore::app()->url->type)
) {
return null;
@ -232,7 +232,7 @@ class zoneclearFeedServerWidget
$text = $count ? sprintf(__('one source', '%d sources', $count), $count) : __('no sources');
if (dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
if (dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_pub_active) {
$text = sprintf(
'<a href="%s">%s</a>',
dcCore::app()->blog->url . dcCore::app()->url->getBase('zoneclearFeedsPage'),

View File

@ -38,7 +38,7 @@ class zoneclearFeedServer
{
$this->con = dcCore::app()->con;
$this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
$this->table = dcCore::app()->prefix . initZoneclearFeedServer::FEED_TABLE_NAME;
$this->table = dcCore::app()->prefix . initZoneclearFeedServer::TABLE_NAME;
}
/**
@ -395,7 +395,7 @@ class zoneclearFeedServer
*/
public function checkFeedsUpdate($id = null, $throw = false)
{
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
$s = dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)));
# Not configured
if (!$s->zoneclearFeedServer_active || !$s->zoneclearFeedServer_user) {

View File

@ -98,7 +98,7 @@ class zcfsFeedsList extends adminGenericList
$shunk_feed = substr($shunk_feed, 0, 50) . '...' . substr($shunk_feed, -20);
}
$url = 'plugin.php?p=zoneclearFeedServer&amp;part=feed&amp;feed_id=' . $this->rs->feed_id;
$url = dcCore::app()->adminurl->get('admin.plugin.' . basename(dirname('../' . __DIR__)), ['part' => 'feed', 'feed_id' => $this->rs->feed_id]);
$cols = [
'check' => '<td class="nowrap minimal">' .

View File

@ -28,8 +28,8 @@ dcPage::check(dcCore::app()->auth->makePermissions([
$zcfs = new zoneclearFeedServer();
# Not configured
if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
|| !dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_user
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_active
|| !dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer_user
) {
echo
'<html><head><title>' . __('Feeds server') . '</title></head><body>' .
@ -224,7 +224,7 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
__('Feed successfully updated.')
);
dcCore::app()->adminurl->redirect(
'admin.plugin.zoneclearFeedServer',
'admin.plugin.' . basename(__DIR__),
['part' => 'feed', 'feed_id' => $feed_id]
);
} catch (Exception $e) {
@ -244,7 +244,7 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
__('Feed successfully created.')
);
dcCore::app()->adminurl->redirect(
'admin.plugin.zoneclearFeedServer',
'admin.plugin.' . basename(__DIR__),
['part' => 'feed', 'feed_id' => $return_id]
);
} catch (Exception $e) {
@ -259,7 +259,7 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
$posts_actions_page = new dcPostsActions(
'plugin.php',
[
'p' => 'zoneclearFeedServer',
'p' => basename(__DIR__),
'part' => 'feed',
'feed_id' => $feed_id,
'_ANCHOR' => 'entries',
@ -309,8 +309,8 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
echo
'<html><head><title>' . __('Feeds server') . '</title>' .
($feed_id && !dcCore::app()->error->flag() ?
$post_filter->js(dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $feed_id], '&') . '#entries') .
dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/list.js'))
$post_filter->js(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['part' => 'feed', 'feed_id' => $feed_id], '&') . '#entries') .
dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/list.js'))
: '') .
dcPage::jsPageTabs() .
$next_headlink . "\n" . $prev_headlink .
@ -426,7 +426,7 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
'<p class="clear">
<input type="submit" name="save" value="' . __('Save') . ' (s)" accesskey="s"/>' .
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), [
'part' => 'feed',
'feed_id' => $feed_id,
'action' => 'savefeed',
@ -443,8 +443,8 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
# show filters
$post_filter->display(
['admin.plugin.zoneclearFeedServer','#entries'],
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
['admin.plugin.' . basename(__DIR__),'#entries'],
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), [
'part' => 'feed',
'feed_id' => $feed_id,
])
@ -459,8 +459,8 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
$post_list->display(
$post_filter->page,
$post_filter->nb,
dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', $args, '&') . '#entries',
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed']) . '#entries" method="post" id="form-entries">' .
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), $args, '&') . '#entries',
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['part' => 'feed']) . '#entries" method="post" id="form-entries">' .
'%s' .
'<div class="two-cols">' .
@ -469,8 +469,8 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
'<p class="col right">' . __('Selected entries action:') . ' ' .
form::combo('action', $posts_actions_page->getCombo()) .
'<input type="submit" name="save" value="' . __('ok') . '" /></p>' .
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', $post_filter->values()) .
form::hidden('redir', dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', $post_filter->values())) .
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), $post_filter->values()) .
form::hidden('redir', dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), $post_filter->values())) .
dcCore::app()->formNonce() .
'</div>' .
'</form>',
@ -489,7 +489,7 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
# actions
$feeds_actions_page = new zcfsFeedsActionsPage(
'plugin.php',
['p' => 'zoneclearFeedServer', 'part' => 'feeds']
['p' => basename(__DIR__), 'part' => 'feeds']
);
if ($feeds_actions_page->process()) {
return null;
@ -518,8 +518,8 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
# display
echo
'<html><head><title>' . __('Feeds server') . '</title>' .
$feeds_filter->js(dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feeds'], '&')) .
dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/list.js')) .
$feeds_filter->js(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['part' => 'feeds'], '&')) .
dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/list.js')) .
dcPage::jsPageTabs() .
# --BEHAVIOR-- adminZoneclearFeedServerHeader
@ -534,25 +534,25 @@ if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_act
dcPage::notices() .
'<p class="top-add">' .
'<a class="button add" href="' . dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed']) . '">' .
'<a class="button add" href="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['part' => 'feed']) . '">' .
__('New feed') . '</a></p>';
$feeds_filter->display(
'admin.plugin.zoneclearFeedServer',
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', ['part' => 'feeds'])
'admin.plugin.' . basename(__DIR__),
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), ['part' => 'feeds'])
);
$feeds_list->feedsDisplay(
$feeds_filter->page,
$feeds_filter->nb,
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feeds']) . '" method="post" id="form-actions">' .
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['part' => 'feeds']) . '" method="post" id="form-actions">' .
'%s' .
'<div class="two-cols">' .
'<p class="col checkboxes-helpers"></p>' .
'<p class="col right">' . __('Selected feeds action:') . ' ' .
form::combo(['action'], $feeds_actions_page->getCombo()) .
'<input type="submit" value="' . __('ok') . '" />' .
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', $feeds_filter->values(true)) .
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), $feeds_filter->values(true)) .
dcCore::app()->formNonce() .
'</p>' .
'</div>' .