Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins module #515

Merged
merged 2 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions htdocs/modules/plugins/admin/about.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* plugins module
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package plugins
* @since 2.6.0
* @author trabis <lusopoemas@gmail.com>
* @version $Id$
*/

include __DIR__ . '/header.php';
$xoops = Xoops::getInstance();
$xoops->header();
$aboutAdmin = new \Xoops\Module\Admin();
$aboutAdmin->displayNavigation('about.php');
$aboutAdmin->displayAbout(true);
$xoops->footer();
23 changes: 23 additions & 0 deletions htdocs/modules/plugins/admin/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* plugins module
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package plugins
* @since 2.6.0
* @author trabis <lusopoemas@gmail.com>
* @version $Id$
*/

require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
34 changes: 34 additions & 0 deletions htdocs/modules/plugins/admin/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* plugins module
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package plugins
* @since 2.6.0
* @author trabis <lusopoemas@gmail.com>
* @version $Id$
*/

include __DIR__ . '/header.php';
$xoops = Xoops::getInstance();

// header
$xoops->header();

$admin_page = new \Xoops\Module\Admin();
$admin_page->displayNavigation('index.php');
$admin_page->displayIndex();

// footer
$xoops->footer();
35 changes: 35 additions & 0 deletions htdocs/modules/plugins/admin/menu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* plugins module
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package plugins
* @since 2.6.0
* @author trabis <lusopoemas@gmail.com>
* @version $Id$
*/

$adminmenu = array();
$i = 1;
$adminmenu[$i]['title'] = XoopsLocale::HOME;
$adminmenu[$i]['link'] = "admin/index.php";
$adminmenu[$i]['icon'] = 'home.png';
++$i;
$adminmenu[$i]['title'] = PluginsLocale::PLUGINS_MANAGER;
$adminmenu[$i]['link'] = "admin/plugins.php";
$adminmenu[$i]['icon'] = 'synchronized.png';
++$i;
$adminmenu[$i]['title'] = XoopsLocale::ABOUT;
$adminmenu[$i]['link'] = 'admin/about.php';
$adminmenu[$i]['icon'] = 'about.png';
151 changes: 151 additions & 0 deletions htdocs/modules/plugins/admin/plugins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

use Xmf\Request;
use PluginsLocale as t;

/**
* banners module
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package banners
* @since 2.6.0
* @author Mage Grégory (AKA Mage)
* @version $Id$
*/
include __DIR__ . '/header.php';

// Get main instance
$xoops = Xoops::getInstance();
$helper = Plugins::getInstance();
$handler = $helper->getHandlerPlugin();

//Adds new plugins if available and remove them if modules were deactivated
PluginsManager::updatePlugins();

// Call header
$xoops->header('admin:plugins/plugins_admin_plugins.tpl');
// Get Action type
$op = Request::getCmd('op', 'list');
// Get start pager
$start = Request::getInt('start', 0);
// Listener
$listener = Request::getCmd('listener');
// Caller
$caller = Request::getCmd('caller');

$admin_page = new \Xoops\Module\Admin();
$admin_page->renderNavigation('plugins.php');

switch ($op) {
case 'update':
$orders = Request::getArray('order');
foreach ($orders as $id => $order) {
$handler->updateOrder((int) $id, (int) $order);
}
$statuses = Request::getArray('status');
foreach ($statuses as $id => $status) {
$handler->updateStatus((int) $id, (int) $status);
}
$xoops->tpl()->assign('infoMsg', $xoops->alert('success', XoopsLocale::S_DATA_UPDATED));
//No break;
case 'list':
default:
$admin_page->addTips(t::TIPS_PLUGINS);
$admin_page->renderTips();

if ($listener) {
$objects = $handler->getByListener($listener);
} else if ($caller) {
$objects = $handler->getByCaller($caller);
} else {
$objects = $handler->getThemAll();
}

//In the impossible case no plugins were found, we alert the user
if (!$objects) {
$xoops->tpl()->assign('errorMsg', $xoops->alert('info', t::NO_PLUGINS_FOUND));
break;
}

$plugins = array();
foreach ($objects as $object) {
/* @var $object XoopsObject */
$plugin = $object->toArray();
$plugin['plugin_caller_name'] = $xoops->getModuleByDirname($plugin['plugin_caller'])->getVar('name');
$plugin['plugin_listener_name'] = $xoops->getModuleByDirname($plugin['plugin_listener'])->getVar('name');

//Add order field
$order = new \Xoops\Form\Text('', 'order[' . $plugin['plugin_id'] . ']', 2, 2, $plugin['plugin_order']);
$order->set('style', 'width:3em');
$plugin['plugin_order_field'] = $order->render();
//Add status field
$status = new \Xoops\Form\RadioYesNo('', 'status[' . $plugin['plugin_id'] . ']', $plugin['plugin_status'], false);
$plugin['plugin_status_field'] = $status->render();
$plugins[] = $plugin;
}
$xoops->tpl()->assign('pluginsCount', count($plugins));
$xoops->tpl()->assign('plugins', $plugins);

//Listeners form
$objects = $handler->getListeners();
$form = new \Xoops\Form\ThemeForm('', 'listenersForm', 'plugins.php', 'post');
$form->addElement(new \Xoops\Form\Hidden('op', 'list'));
$select = new \Xoops\Form\Select('', 'listener', $listener);
$select->set("onchange", 'submit()');
$select->addOption('', XoopsLocale::ALL_TYPES);
foreach ($objects as $l => $name) {
$select->addOption($l, $name);
}
$form->addElement($select);
$xoops->tpl()->assign('listenersForm', $form->render());

//Callers form
$objects = $handler->getCallers();
$form = new \Xoops\Form\ThemeForm('', 'callersForm', 'plugins.php', 'post');
$form->addElement(new \Xoops\Form\Hidden('op', 'list'));
$select = new \Xoops\Form\Select('', 'caller', $caller);
$select->set("onchange", 'submit()');
$select->addOption('', XoopsLocale::ALL_TYPES);
foreach ($objects as $c => $name) {
$select->addOption($c, $name);
}
$form->addElement($select);
$xoops->tpl()->assign('callersForm', $form->render());

//Submit button
$submitButton = new \Xoops\Form\Button(XoopsLocale::A_SUBMIT, 'submit', XoopsLocale::A_SUBMIT, 'submit');
$xoops->tpl()->assign('submitButton', $submitButton->render());

//Hidden fields
$hiddenFields = '';
$hidden = new \Xoops\Form\Hidden('op', 'update');
$hiddenFields .= $hidden->render();
$hidden = new \Xoops\Form\Hidden('listener', $listener);
$hiddenFields .= $hidden->render();
$hidden = new \Xoops\Form\Hidden('caller', $caller);
$hiddenFields .= $hidden->render();
$xoops->tpl()->assign('hiddenFields', $hiddenFields);
break;
case 'status':
// Get the plugin id
$id = Request::getInt('id', 0);
// Get new status
$status = Request::getInt('status', 0);
if ($object = $handler->get($id)) {
$object->setVar('plugin_status', $status);
return $handler->insert($object);
}
return false;
break;
}
$xoops->footer();
51 changes: 51 additions & 0 deletions htdocs/modules/plugins/class/helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* plugins module
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package plugins
* @since 2.6.0
* @author trabis <lusopoemas@gmail.com>
* @version $Id$
*/

class Plugins extends Xoops\Module\Helper\HelperAbstract
{
/**
* Init the module
*
* @return null|void
*/
public function init()
{
$this->setDirname('plugins');
}

/**
* @return Plugins|\Xoops\Module\Helper\HelperAbstract
*/
public static function getInstance()
{
return parent::getInstance();
}

/**
* @return PluginsPluginHandler
*/
public function getHandlerPlugin()
{
return $this->getHandler('plugin');
}

}
1 change: 1 addition & 0 deletions htdocs/modules/plugins/class/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script>history.go(-1);</script>
Loading