1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* **************************************************************************** |
5
|
|
|
* MYIFRAME - MODULE FOR XOOPS |
6
|
|
|
* Copyright (c) Hervé Thouzard of Instant Zero (https://www.instant-zero.com) |
7
|
|
|
* **************************************************************************** |
8
|
|
|
*/ |
9
|
|
|
defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined.'); |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Returns a module's option |
13
|
|
|
* |
14
|
|
|
* Return's a module's option (for the myiframe module) |
15
|
|
|
* |
16
|
|
|
* @param string $option module option's name |
17
|
|
|
* @param string $repmodule |
18
|
|
|
* @return bool |
19
|
|
|
* @author Instant Zero (https://www.instant-zero.com) |
20
|
|
|
* @copyright Instant Zero (https://www.instant-zero.com) |
21
|
|
|
*/ |
22
|
|
|
function myiframe_getmoduleoption($option, $repmodule = 'myiframe') |
23
|
|
|
{ |
24
|
|
|
global $xoopsModuleConfig, $xoopsModule; |
25
|
|
|
static $tbloptions = []; |
26
|
|
|
if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
27
|
|
|
return $tbloptions[$option]; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
$retval = false; |
31
|
|
|
if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $xoopsModule->getVar('isactive'))) { |
32
|
|
|
if (isset($xoopsModuleConfig[$option])) { |
33
|
|
|
$retval = $xoopsModuleConfig[$option]; |
34
|
|
|
} |
35
|
|
|
} else { |
36
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
37
|
|
|
$moduleHandler = xoops_getHandler('module'); |
38
|
|
|
$module = $moduleHandler->getByDirname($repmodule); |
39
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
40
|
|
|
$configHandler = xoops_getHandler('config'); |
41
|
|
|
if ($module) { |
42
|
|
|
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
43
|
|
|
if (isset($moduleConfig[$option])) { |
44
|
|
|
$retval = $moduleConfig[$option]; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
$tbloptions[$option] = $retval; |
49
|
|
|
|
50
|
|
|
return $retval; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Verify that a field exists inside a mysql table |
55
|
|
|
* |
56
|
|
|
* @param $fieldname |
57
|
|
|
* @param $table |
58
|
|
|
* @return bool |
59
|
|
|
* @author Instant Zero (https://www.instant-zero.com) |
60
|
|
|
* @copyright Instant Zero (https://www.instant-zero.com) |
61
|
|
|
*/ |
62
|
|
|
function myiframe_FieldExists($fieldname, $table) |
63
|
|
|
{ |
64
|
|
|
$result = $GLOBALS['xoopsDB']->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); |
65
|
|
|
|
66
|
|
|
return ($GLOBALS['xoopsDB']->getRowsNum($result) > 0); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Set the page's title, meta description and meta keywords |
71
|
|
|
* Datas are supposed to be sanitized |
72
|
|
|
* |
73
|
|
|
* @param string $page_title Page's Title |
74
|
|
|
* @param string $meta_description Page's meta description |
75
|
|
|
* @param string $meta_keywords Page's meta keywords |
76
|
|
|
* @author Instant Zero https://www.instant-zero.com |
77
|
|
|
* @copyright (c) Instant Zero https://www.instant-zero.com |
78
|
|
|
*/ |
79
|
|
|
function myiframe_set_metas($page_title = '', $meta_description = '', $meta_keywords = ''): void |
80
|
|
|
{ |
81
|
|
|
global $xoTheme, $xoTheme, $xoopsTpl; |
82
|
|
|
$xoopsTpl->assign('xoops_pagetitle', $page_title); |
83
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
84
|
|
|
if (!empty($meta_keywords)) { |
85
|
|
|
$xoTheme->addMeta('meta', 'keywords', $meta_keywords); |
86
|
|
|
} |
87
|
|
|
if (!empty($meta_description)) { |
88
|
|
|
$xoTheme->addMeta('meta', 'description', $meta_description); |
89
|
|
|
} |
90
|
|
|
} elseif (isset($xoopsTpl) && is_object($xoopsTpl)) { // Compatibility for old Xoops versions |
91
|
|
|
if (!empty($meta_keywords)) { |
92
|
|
|
$xoopsTpl->assign('xoops_meta_keywords', $meta_keywords); |
93
|
|
|
} |
94
|
|
|
if (!empty($meta_description)) { |
95
|
|
|
$xoopsTpl->assign('xoops_meta_description', $meta_description); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|