|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/* |
|
3
|
|
|
* **************************************************************************** |
|
4
|
|
|
* Module generated by TDMCreate from TDM "http://www.tdmxoops.net" |
|
5
|
|
|
* **************************************************************************** |
|
6
|
|
|
* xsitemap - MODULE FOR XOOPS CMS |
|
7
|
|
|
* Copyright (c) Urbanspaceman (http://www.takeaweb.it) |
|
8
|
|
|
* |
|
9
|
|
|
* You may not change or alter any portion of this comment or credits |
|
10
|
|
|
* of supporting developers from this source code or any supporting source code |
|
11
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
15
|
|
|
*/ |
|
16
|
|
|
/** |
|
17
|
|
|
* Module: xsitemap |
|
18
|
|
|
* |
|
19
|
|
|
* @package module\xsitemap\class |
|
20
|
|
|
* @author XOOPS Module Development Team |
|
21
|
|
|
* @author http://www.takeaweb.it Urbanspaceman |
|
22
|
|
|
* @copyright http://www.takeaweb.it Urbanspaceman |
|
23
|
|
|
* @copyright http://xoops.org 2001-2017 XOOPS Project |
|
24
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
|
25
|
|
|
* @link http://xoops.org XOOPS |
|
26
|
|
|
* @since 1.00 |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
|
30
|
|
|
|
|
31
|
|
|
class XsitemapPlugin extends XoopsObject |
|
|
|
|
|
|
32
|
|
|
{ |
|
33
|
|
|
//Constructor |
|
34
|
|
|
public function __construct() |
|
35
|
|
|
{ |
|
36
|
|
|
parent::__construct(); |
|
37
|
|
|
$this->initVar('plugin_id', XOBJ_DTYPE_INT, null, false, 8); |
|
38
|
|
|
$this->initVar('plugin_name', XOBJ_DTYPE_TXTBOX, null, false); |
|
39
|
|
|
$this->initVar('plugin_mod_version', XOBJ_DTYPE_TXTBOX, null, false); |
|
40
|
|
|
$this->initVar('plugin_mod_table', XOBJ_DTYPE_TXTBOX, null, false); |
|
41
|
|
|
$this->initVar('plugin_cat_id', XOBJ_DTYPE_TXTBOX, null, false); |
|
42
|
|
|
$this->initVar('plugin_cat_pid', XOBJ_DTYPE_TXTBOX, null, false); |
|
43
|
|
|
$this->initVar('plugin_cat_name', XOBJ_DTYPE_TXTBOX, null, false); |
|
44
|
|
|
$this->initVar('plugin_weight', XOBJ_DTYPE_TXTBOX, null, false); |
|
45
|
|
|
$this->initVar('plugin_call', XOBJ_DTYPE_TXTBOX, null, false); |
|
46
|
|
|
$this->initVar('plugin_submitter', XOBJ_DTYPE_INT, null, false, 10); |
|
47
|
|
|
$this->initVar('plugin_date_created', XOBJ_DTYPE_INT, null, false, 10); |
|
48
|
|
|
$this->initVar('plugin_online', XOBJ_DTYPE_INT, null, false, 1); |
|
49
|
|
|
|
|
50
|
|
|
// to allow html |
|
51
|
|
|
$this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function __toString() { |
|
|
|
|
|
|
56
|
|
|
return $this->getVar('plugin_name', 's'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function getForm($action = false) |
|
|
|
|
|
|
60
|
|
|
{ |
|
61
|
|
|
global $xoopsDB, $xoopsModuleConfig; |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
if (false === $action) { |
|
64
|
|
|
$action = $_SERVER["REQUEST_URI"]; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if ($this->isNew()) { |
|
68
|
|
|
$title = _AM_XSITEMAP_PLUGIN_ADD; |
|
69
|
|
|
$plugin_date_created = time(); |
|
70
|
|
|
$plugin_online = 1; |
|
71
|
|
|
} else { |
|
72
|
|
|
$title = _AM_XSITEMAP_PLUGIN_EDIT; |
|
73
|
|
|
$plugin_date_created = $this->getVar("plugin_date_created"); |
|
74
|
|
|
$plugin_online = $this->getVar("plugin_online"); |
|
75
|
|
|
} |
|
76
|
|
|
// $title = $this->isNew() ? sprintf(_AM_XSITEMAP_PLUGIN_ADD) : sprintf(_AM_XSITEMAP_PLUGIN_EDIT); |
|
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
include_once $GLOBALS['xoops']->path("class/xoopsformloader.php"); |
|
79
|
|
|
|
|
80
|
|
|
$form = new XoopsThemeForm($title, 'form', $action, 'post', true); |
|
81
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
|
82
|
|
|
|
|
83
|
|
|
$form->addElement(new XoopsFormText(_AM_XSITEMAP_PLUGIN_NAME, "plugin_name", 50, 255, $this->getVar("plugin_name")), true); |
|
84
|
|
|
$form->addElement(new XoopsFormText(_AM_XSITEMAP_PLUGIN_MOD_VERSION, "plugin_mod_version", 50, 255, $this->getVar("plugin_mod_version")), true); |
|
85
|
|
|
$form->addElement(new XoopsFormText(_AM_XSITEMAP_PLUGIN_MOD_TABLE, "plugin_mod_table", 50, 255, $this->getVar("plugin_mod_table")), true); |
|
86
|
|
|
$form->addElement(new XoopsFormText(_AM_XSITEMAP_PLUGIN_CAT_ID, "plugin_cat_id", 50, 255, $this->getVar("plugin_cat_id")), true); |
|
87
|
|
|
$form->addElement(new XoopsFormText(_AM_XSITEMAP_PLUGIN_CAT_PID, "plugin_cat_pid", 50, 255, $this->getVar("plugin_cat_pid")), true); |
|
88
|
|
|
$form->addElement(new XoopsFormText(_AM_XSITEMAP_PLUGIN_CAT_NAME, "plugin_cat_name", 50, 255, $this->getVar("plugin_cat_name")), true); |
|
89
|
|
|
$form->addElement(new XoopsFormText(_AM_XSITEMAP_PLUGIN_WEIGHT, "plugin_weight", 50, 255, $this->getVar("plugin_weight")), true); |
|
90
|
|
|
$form->addElement(new XoopsFormText(_AM_XSITEMAP_PLUGIN_CALL, "plugin_call", 50, 255, $this->getVar("plugin_call")), true); |
|
91
|
|
|
$form->addElement(new XoopsFormSelectUser(_AM_XSITEMAP_PLUGIN_SUBMITTER, "plugin_submitter", false, $this->getVar("plugin_submitter"), 1, false), true); |
|
92
|
|
|
// $plugin_date_created = $this->isNew() ? time() : $this->getVar("plugin_date_created"); |
|
|
|
|
|
|
93
|
|
|
$form->addElement(new XoopsFormTextDateSelect(_AM_XSITEMAP_PLUGIN_DATE_CREATED, "plugin_date_created", "", $plugin_date_created)); |
|
94
|
|
|
// $plugin_online = $this->isNew() ? 1 : $this->getVar("plugin_online"); |
|
|
|
|
|
|
95
|
|
|
$check_plugin_online = new XoopsFormCheckBox(_AM_XSITEMAP_PLUGIN_ONLINE, "plugin_online", $plugin_online); |
|
96
|
|
|
$check_plugin_online->addOption(1, " "); |
|
97
|
|
|
$form->addElement($check_plugin_online); |
|
98
|
|
|
$form->addElement(new XoopsFormHidden("op", "save_plugin")); |
|
99
|
|
|
if (!$this->isNew()) { |
|
100
|
|
|
$form->addElement(new XoopsFormHidden("plugin_id", $this->getVar('plugin_id'))); |
|
101
|
|
|
} |
|
102
|
|
|
$form->addElement(new XoopsFormButtonTray('submit', _SUBMIT)); |
|
103
|
|
|
|
|
104
|
|
|
return $form->display(); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
class XsitemapPluginHandler extends XoopsPersistableObjectHandler |
|
|
|
|
|
|
108
|
|
|
{ |
|
109
|
|
|
|
|
110
|
|
|
public function __construct(&$db) |
|
111
|
|
|
{ |
|
112
|
|
|
parent::__construct($db, "xsitemap_plugin", "XsitemapPlugin", "plugin_id", "plugin_name"); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.