Skip to content

Commit

Permalink
Merge pull request #8 from mambax7/master
Browse files Browse the repository at this point in the history
1.32 BETA-1
  • Loading branch information
mambax7 authored Oct 21, 2021
2 parents b0fca4d + c10db3f commit 7540c50
Show file tree
Hide file tree
Showing 51 changed files with 326 additions and 753 deletions.
16 changes: 16 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ build:
- git clone --depth=1 https://github.com/mambax7/wfdownloads
- git clone --depth=1 https://github.com/mambax7/wflinks
- git clone --depth=1 https://github.com/mambax7/xoopstube
- git clone --depth=1 https://github.com/mambax7/wgdiaries
- git clone --depth=1 https://github.com/mambax7/wggallery
- git clone --depth=1 https://github.com/mambax7/wggithub
- git clone --depth=1 https://github.com/mambax7/wglinks
- git clone --depth=1 https://github.com/mambax7/wgsimpleacc
- git clone --depth=1 https://github.com/mambax7/wgteams
- git clone --depth=1 https://github.com/mambax7/wgtimelines
- git clone --depth=1 https://github.com/mambax7/wgtransifex
project_setup:
override: true
tests:
Expand All @@ -54,4 +62,12 @@ filter:
- wfdownloads/*
- wflinks/*
- xoopstube/*
- wgdiaries/*
- wggallery/*
- wggithub/*
- wglinks/*
- wgsimpleacc/*
- wgteams/*
- wgtimelines/*
- wgtransifex/*

12 changes: 4 additions & 8 deletions admin/do_about.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,24 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

use Xmf\Module\Admin;

/**
* @copyright XOOPS Project (https://xoops.org)
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author XOOPS Development Team
*/

use Xmf\Request;
use XoopsModules\Rssfit;
use Xmf\Module\Admin;
/** @var Admin $adminObject */

if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) {
header('Location: index.php');
redirect_header('index.php');
}

require_once __DIR__ . '/admin_header.php';

$adminObject = Admin::getInstance();
//xoops_cp_header();

$adminObject->displayNavigation(basename(__FILE__));
Admin::setPaypal('xoopsfoundation@gmail.com');
$adminObject::setPaypal('xoopsfoundation@gmail.com');
$adminObject->displayAbout(false);

require_once __DIR__ . '/admin_footer.php';
2 changes: 1 addition & 1 deletion admin/do_channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/** @var FeedHandler $feedHandler */

if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) {
header('Location: index.php');
redirect_header('index.php');
}

switch ($op) {
Expand Down
6 changes: 3 additions & 3 deletions admin/do_intro.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/** @var MiscHandler $miscHandler */

if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) {
header('Location: index.php');
redirect_header('index.php');
}

$intr = $miscHandler->getObjects2(new \Criteria('misc_category', 'intro'));
Expand All @@ -47,10 +47,10 @@
$contentTray->setDescription(_AM_RSSFIT_EDIT_INTRO_TEXT_DESC . _AM_RSSFIT_EDIT_INTRO_TEXT_DESC_SUB);
$contentTray->addElement(new \XoopsFormDhtmlTextArea('', 'content', $intro->getVar('misc_content', 'e'), 15, 60));
$dohtml = new \XoopsFormCheckBox('', 'dohtml', $setting['dohtml'] ?? '');
$dohtml->addOption(1, _AM_RSSFIT_DO_HTML);
$dohtml->addOption('1', _AM_RSSFIT_DO_HTML);
$contentTray->addElement($dohtml);
$dobr = new \XoopsFormCheckBox('', 'dobr', $setting['dobr'] ?? '');
$dobr->addOption(1, _AM_RSSFIT_DO_BR);
$dobr->addOption('1', _AM_RSSFIT_DO_BR);
$contentTray->addElement($dobr);

$sub = new \XoopsFormTextArea(_AM_RSSFIT_EDIT_INTRO_SUB, 'sub', htmlspecialchars($setting['sub'] ?? '', ENT_QUOTES | ENT_HTML5));
Expand Down
8 changes: 4 additions & 4 deletions admin/do_migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
/** @var Migrate $migrator */

if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) {
header('Location: index.php');
redirect_header('index.php');
}

require_once __DIR__ . '/admin_header.php';
Expand Down Expand Up @@ -72,9 +72,9 @@
$migrator = new Migrate();

$op = Request::getCmd('op', 'show');
$opShow = Request::getCmd('show', null, 'POST');
$opMigrate = Request::getCmd('migrate', null, 'POST');
$opSchema = Request::getCmd('schema', null, 'POST');
$opShow = Request::getCmd('show', '', 'POST');
$opMigrate = Request::getCmd('migrate', '', 'POST');
$opSchema = Request::getCmd('schema', '', 'POST');
$op = !empty($opShow) ? 'show' : $op;
$op = !empty($opMigrate) ? 'migrate' : $op;
$op = !empty($opSchema) ? 'schema' : $op;
Expand Down
58 changes: 32 additions & 26 deletions admin/do_plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/** @var PluginHandler $pluginHandler */

if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) {
header('Location: index.php');
redirect_header('index.php');
}

/** @varHelper $helper */
Expand Down Expand Up @@ -144,7 +144,7 @@
$list = \XoopsLists::getFileListAsArray($helper->path('class/Plugins'));
$installable = [];
foreach ($list as $f) {
if (preg_match('/[a-zA-Z0-9_]+\.php$/', $f) && !in_array($f, $filelist)) {
if (preg_match('/\w+\.php$/', $f) && !in_array($f, $filelist)) {
$installable[] = $f;
}
}
Expand All @@ -168,21 +168,25 @@
$action->addOption('i', ' ');
$ret .= "<tr>\n" . "<td class='odd' align='center'>" . $i . "</td>\n" . "<td class='even' align='center'>";
$p = $pluginHandler->create();
$p->setVar('rssf_filename', $i);
$handler = $pluginHandler->checkPlugin($p);
if ($handler) {
$ret .= $handler->modname;
} else {
if (count($p->getErrors()) > 0) {
$ret .= '<b>' . _ERRORS . "</b>\n";
foreach ($p->getErrors() as $e) {
$ret .= '<br>' . $e;
}

if (null !== $p) {
$p->setVar('rssf_filename', $i);
$handler = $pluginHandler->checkPlugin($p);
if ($handler) {
$ret .= $handler->modname;
} else {
$ret .= '<b>' . _AM_RSSFIT_PLUGIN_UNKNOWNERROR . '</b>';
if (count($p->getErrors()) > 0) {
$ret .= '<b>' . _ERRORS . "</b>\n";
foreach ($p->getErrors() as $e) {
$ret .= '<br>' . $e;
}
} else {
$ret .= '<b>' . _AM_RSSFIT_PLUGIN_UNKNOWNERROR . '</b>';
}
$action->setExtra('disabled="disabled"');
}
$action->setExtra('disabled="disabled"');
}

$ret .= "</td>\n";
$ret .= "<td class='odd' align='center'>" . $action->render() . "</td>\n";
}
Expand All @@ -206,7 +210,7 @@
}
break;
case 'save':
$rssfGrab = Request::getArray('rssf_grab', [], 'POST');
$rssfGrab = Request::getArray('rssf_grab', [], 'POST');
$rssf_order = Request::getArray('rssf_order', [], 'POST');
$action = Request::getArray('action', null, 'POST');
$install = Request::getArray('install', [], 'POST');
Expand Down Expand Up @@ -246,17 +250,19 @@
$files = array_keys($install);
foreach ($files as $f) {
$p = $pluginHandler->create();
$p->setVar('rssf_filename', $f);
$handler = $pluginHandler->checkPlugin($p);
if ($handler) {
$p->setVar('rssf_activated', 1);
$p->setVar('rssf_grab', $helper->getConfig('plugin_entries'));
$p->setVar('sub_entries', $helper->getConfig('plugin_entries'));
$p->setVar('sub_link', XOOPS_URL . '/modules/' . $handler->dirname);
$p->setVar('sub_title', $xoopsConfig['sitename'] . ' - ' . $handler->modname);
$p->setVar('sub_desc', $xoopsConfig['slogan']);
if (!$result = $pluginHandler->insert($p)) {
$err .= $p->getHtmlErrors();
if (null !== $p) {
$p->setVar('rssf_filename', $f);
$handler = $pluginHandler->checkPlugin($p);
if ($handler) {
$p->setVar('rssf_activated', 1);
$p->setVar('rssf_grab', $helper->getConfig('plugin_entries'));
$p->setVar('sub_entries', $helper->getConfig('plugin_entries'));
$p->setVar('sub_link', XOOPS_URL . '/modules/' . $handler->dirname);
$p->setVar('sub_title', $xoopsConfig['sitename'] . ' - ' . $handler->modname);
$p->setVar('sub_desc', $xoopsConfig['slogan']);
if (!$result = $pluginHandler->insert($p)) {
$err .= $p->getHtmlErrors();
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions admin/do_sticky.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use XoopsModules\Rssfit;

if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) {
header('Location: index.php');
redirect_header('index.php');
}

$intr = $miscHandler->getObjects2(new \Criteria('misc_category', 'sticky'));
Expand All @@ -44,10 +44,10 @@
$content = new \XoopsFormTextArea('', 'content', $sticky->getVar('misc_content', 'e'), 10);
$contentTray->addElement($content);
$dohtml = new \XoopsFormCheckBox('', 'dohtml', $setting['dohtml']);
$dohtml->addOption(1, _AM_RSSFIT_DO_HTML);
$dohtml->addOption('1', _AM_RSSFIT_DO_HTML);
$contentTray->addElement($dohtml);
$dobr = new \XoopsFormCheckBox('', 'dobr', $setting['dobr']);
$dobr->addOption(1, _AM_RSSFIT_DO_BR);
$dobr->addOption('1', _AM_RSSFIT_DO_BR);
$contentTray->addElement($dobr);

$link = new \XoopsFormText(_AM_RSSFIT_STICKY_LINK, 'link', 50, 255, htmlspecialchars($setting['link'] ?? '', ENT_QUOTES | ENT_HTML5));
Expand Down
10 changes: 5 additions & 5 deletions admin/do_subfeeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/** @var PluginHandler $pluginHandler */

if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) {
header('Location: index.php');
redirect_header('index.php');
}

switch ($op) {
Expand Down Expand Up @@ -68,7 +68,7 @@
$config = '&nbsp;';
$urlLink = $feedHandler->subFeedUrl($p->getVar('rssf_filename'));
}
$activate->addOption(1, ' ');
$activate->addOption('1', ' ');
$ret .= "<tr>\n"
. "<td class='even'>"
. $p->getVar('rssf_filename')
Expand Down Expand Up @@ -124,7 +124,7 @@
$id = Request::getInt('feed', 0, 'GET');
if (!empty($id)) {
$sub = $pluginHandler->get($id);
if (!$handler = $pluginHandler->checkPlugin($sub)) {
if (null !== $sub && !$handler = $pluginHandler->checkPlugin($sub)) {
$pluginHandler->forceDeactivate($sub);
}
}
Expand All @@ -145,7 +145,7 @@
$form->addElement(new \XoopsFormText('link', 'img_link', 50, 255, $sub->getVar('img_link', 'e')));
$form->addElement(new \XoopsFormText('title', 'img_title', 50, 255, $sub->getVar('img_title', 'e')));

$form->addElement(new \XoopsFormHidden('feed', $id));
$form->addElement(new \XoopsFormHidden('feed', (string)$id));
$form->addElement(new \XoopsFormHidden('op', 'savefeed'));
$form->addElement($hiddenDo);
$form->addElement($saveCancelTray);
Expand All @@ -155,7 +155,7 @@
$id = Request::getInt('feed', 0, 'POST');
if (!empty($id)) {
$sub = $pluginHandler->get($id);
if (!$handler = $pluginHandler->checkPlugin($sub)) {
if (null !== $sub && !$handler = $pluginHandler->checkPlugin($sub)) {
$pluginHandler->forceDeactivate($sub);
}
}
Expand Down
1 change: 0 additions & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

use Xmf\Request;
use XoopsModules\Rssfit\{
Common,
FeedHandler,
Helper,
PluginHandler,
Expand Down
29 changes: 8 additions & 21 deletions class/AbstractPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
* @author XOOPS Development Team
*/

/*
* About this RSSFit plug-in
* Author: tuff <http://www.brandycoke.com>
* Requirements (Tested with):
* Module: SmartSection <http://www.smartfactory.ca>
* Version: 1.0.4 Beta 2 / 1.1 Beta 1 / 1.05 Beta 1
* RSSFit verision: 1.2 / 1.5
* XOOPS version: 2.0.13.2 / 2.2.3
*/

if (!\defined('RSSFIT_ROOT_PATH')) {
exit();
}
Expand All @@ -44,27 +34,24 @@ abstract class AbstractPlugin implements PluginInterface
{
public $modname;
public $grab;
public $module; // optional, see line 67
public $module;
public $helper;
public $dirname = '';


public function loadModule(): ?\XoopsModule
{
$mod = $GLOBALS['module_handler']->getByDirname($this->dirname);
if (!$mod || !$mod->getVar('isactive')) {
return null;
$mod = null;
if (null !== $this->helper) {
$this->module = $this->helper->getModule();
$this->modname = $this->module->getVar('name');
$mod = $this->module;
}

if (!$mod->getVar('isactive')) {
return null;
}
$this->modname = $mod->getVar('name');
$this->module = $mod; // optional, remove this line if there is nothing to do with module info when grabbing entries

return $mod;
}

public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array
{
return null;
}
}
3 changes: 3 additions & 0 deletions class/Common/Breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
*/
class Breadcrumb
{
/**
* @var string
*/
public $dirname;
private $bread = [];

Expand Down
2 changes: 1 addition & 1 deletion class/Common/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function renameColumns(): void
$oldName = $tableName['from'];
$newName = $tableName['to'];
$attributes = $this->tableHandler->getColumnAttributes($tableName, $oldName);
if (is_string($attributes) && false !== \strpos($attributes, ' int(')) {
if (\is_string($attributes) && false !== \strpos($attributes, ' int(')) {
$this->tableHandler->alterColumn($tableName, $oldName, $attributes, $newName);
}
}
Expand Down
2 changes: 1 addition & 1 deletion class/Common/TestdataButtons.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function loadButtonConfig(Admin $adminObject): void
$displaySampleButton = $config['displaySampleButton'];
$helper = Helper::getInstance();

if (1 == $displaySampleButton) {
if (1 === $displaySampleButton) {
\xoops_loadLanguage('admin/modulesadmin', 'system');
$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
Expand Down
6 changes: 2 additions & 4 deletions class/Common/VersionChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public static function checkVerXoops(?\XoopsModule $module = null, ?string $requ
/**
* Verifies PHP version meets minimum requirements for this module
* @static
* @param \XoopsModule|bool|null $module
*
* @return bool true if meets requirements, false if not
*/
Expand Down Expand Up @@ -91,7 +90,6 @@ public static function checkVerPhp(?\XoopsModule $module = null): bool
* compares current module version with the latest GitHub release
* @static
*
* @return string|array info about the latest module version, if newer
*/

public static function checkVerModule(Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
Expand All @@ -112,9 +110,9 @@ public static function checkVerModule(Helper $helper, ?string $source = 'github'
$curlReturn = \curl_exec($curlHandle);
if (false === $curlReturn) {
\trigger_error(\curl_error($curlHandle));
} elseif (false !== \strpos($curlReturn, 'Not Found')) {
} elseif (\is_string($curlReturn) && false !== \strpos($curlReturn, 'Not Found')) {
\trigger_error('Repository Not Found: ' . $infoReleasesUrl);
} else {
} elseif (\is_string($curlReturn)) {
$file = json_decode($curlReturn, false);
$latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
$latestVersion = $file[0]->tag_name;
Expand Down
Loading

0 comments on commit 7540c50

Please sign in to comment.