1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
/** |
12
|
|
|
* Alumni module for Xoops |
13
|
|
|
* |
14
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
15
|
|
|
* @license GPL 2.0 or later |
16
|
|
|
* @package alumni |
17
|
|
|
* @since 2.6.x |
18
|
|
|
* @author John Mordo (jlm69) |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
22
|
|
|
|
23
|
|
|
$xoops = Xoops::getInstance(); |
24
|
|
|
$listingHandler = $xoops->getModuleHandler('listing', 'alumni'); |
25
|
|
|
|
26
|
|
View Code Duplication |
function alumni_ShowImg() |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
global $moduleDirName; |
|
|
|
|
29
|
|
|
|
30
|
|
|
echo "<script type=\"text/javascript\">\n"; |
31
|
|
|
echo "<!--\n\n"; |
32
|
|
|
echo "function showimage() {\n"; |
33
|
|
|
echo "if (!document.images)\n"; |
34
|
|
|
echo "return\n"; |
35
|
|
|
echo "document.images.avatar.src=\n"; |
36
|
|
|
echo "'" . XOOPS_URL . "/modules/{$moduleDirName}/assets/images/cat/' + document.imcat.img.options[document.imcat.img.selectedIndex].value\n"; |
37
|
|
|
echo "}\n\n"; |
38
|
|
|
echo "//-->\n"; |
39
|
|
|
echo "</script>\n"; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
View Code Duplication |
function alumni_ShowImg2() |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
global $moduleDirName; |
|
|
|
|
45
|
|
|
|
46
|
|
|
echo "<script type=\"text/javascript\">\n"; |
47
|
|
|
echo "<!--\n\n"; |
48
|
|
|
echo "function showimage2() {\n"; |
49
|
|
|
echo "if (!document.images)\n"; |
50
|
|
|
echo "return\n"; |
51
|
|
|
echo "document.images.scphoto.src=\n"; |
52
|
|
|
echo "'" . XOOPS_URL . "/modules/{$moduleDirName}/assets/images/schools/' + document.imcat.scphoto.options[document.imcat.scphoto.selectedIndex].value\n"; |
53
|
|
|
echo "}\n\n"; |
54
|
|
|
echo "//-->\n"; |
55
|
|
|
echo "</script>\n"; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
//Reusable Link Sorting Functions |
59
|
|
|
/** |
60
|
|
|
* @param $orderby |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
function alumni_convertorderbyin($orderby) |
|
|
|
|
64
|
|
|
{ |
65
|
|
|
switch (trim($orderby)) { |
66
|
|
|
case 'nameA': |
67
|
|
|
$orderby = 'lname ASC'; |
68
|
|
|
break; |
69
|
|
|
case 'schoolA': |
70
|
|
|
$orderby = 'school ASC'; |
71
|
|
|
break; |
72
|
|
|
case 'studiesA': |
73
|
|
|
$orderby = 'studies ASC'; |
74
|
|
|
break; |
75
|
|
|
case 'yearA': |
76
|
|
|
$orderby = 'year ASC'; |
77
|
|
|
break; |
78
|
|
|
case 'dateA': |
79
|
|
|
$orderby = 'date ASC'; |
80
|
|
|
break; |
81
|
|
|
case 'viewA': |
82
|
|
|
$orderby = 'view ASC'; |
83
|
|
|
break; |
84
|
|
|
case 'nameD': |
85
|
|
|
$orderby = 'lname DESC'; |
86
|
|
|
break; |
87
|
|
|
case 'schoolD': |
88
|
|
|
$orderby = 'school DESC'; |
89
|
|
|
break; |
90
|
|
|
case 'studiesD': |
91
|
|
|
$orderby = 'studies DESC'; |
92
|
|
|
break; |
93
|
|
|
case 'yearD': |
94
|
|
|
$orderby = 'year DESC'; |
95
|
|
|
break; |
96
|
|
|
case 'viewD': |
97
|
|
|
$orderby = 'view DESC'; |
98
|
|
|
break; |
99
|
|
|
case 'dateD': |
100
|
|
|
default: |
101
|
|
|
$orderby = 'date DESC'; |
102
|
|
|
break; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $orderby; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param $orderby |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
|
|
function alumni_convertorderbytrans($orderby) |
|
|
|
|
113
|
|
|
{ |
114
|
|
|
global $main_lang; |
|
|
|
|
115
|
|
|
|
116
|
|
|
if ('view ASC' === $orderby) { |
117
|
|
|
$orderbyTrans = '' . constant($main_lang . '_POPULARITYLTOM') . ''; |
|
|
|
|
118
|
|
|
} |
119
|
|
|
if ('view DESC' === $orderby) { |
120
|
|
|
$orderbyTrans = '' . constant($main_lang . '_POPULARITYMTOL') . ''; |
|
|
|
|
121
|
|
|
} |
122
|
|
|
if ('lname ASC' === $orderby) { |
123
|
|
|
$orderbyTrans = '' . constant($main_lang . '_NAMEATOZ') . ''; |
|
|
|
|
124
|
|
|
} |
125
|
|
|
if ('lname DESC' === $orderby) { |
126
|
|
|
$orderbyTrans = '' . constant($main_lang . '_NAMEZTOA') . ''; |
|
|
|
|
127
|
|
|
} |
128
|
|
|
if ('school ASC' === $orderby) { |
129
|
|
|
$orderbyTrans = '' . constant($main_lang . '_SCHOOLATOZ') . ''; |
|
|
|
|
130
|
|
|
} |
131
|
|
|
if ('school DESC' === $orderby) { |
132
|
|
|
$orderbyTrans = '' . constant($main_lang . '_SCHOOLZTOA') . ''; |
|
|
|
|
133
|
|
|
} |
134
|
|
|
if ('studies ASC' === $orderby) { |
135
|
|
|
$orderbyTrans = '' . constant($main_lang . '_STUDIESATOZ') . ''; |
|
|
|
|
136
|
|
|
} |
137
|
|
|
if ('studies DESC' === $orderby) { |
138
|
|
|
$orderbyTrans = '' . constant($main_lang . '_STUDIESZTOA') . ''; |
|
|
|
|
139
|
|
|
} |
140
|
|
|
if ('year ASC' === $orderby) { |
141
|
|
|
$orderbyTrans = '' . constant($main_lang . '_YEAROLD') . ''; |
|
|
|
|
142
|
|
|
} |
143
|
|
|
if ('year DESC' === $orderby) { |
144
|
|
|
$orderbyTrans = '' . constant($main_lang . '_YEARNEW') . ''; |
|
|
|
|
145
|
|
|
} |
146
|
|
|
if ('date ASC' === $orderby) { |
147
|
|
|
$orderbyTrans = '' . constant($main_lang . '_DATEOLD') . ''; |
|
|
|
|
148
|
|
|
} |
149
|
|
|
if ('date DESC' === $orderby) { |
150
|
|
|
$orderbyTrans = '' . constant($main_lang . '_DATENEW') . ''; |
|
|
|
|
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
return $orderbyTrans; |
|
|
|
|
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param $orderby |
158
|
|
|
* @return string |
159
|
|
|
*/ |
160
|
|
|
function alumni_convertorderbyout($orderby) |
|
|
|
|
161
|
|
|
{ |
162
|
|
|
if ('lname ASC' === $orderby) { |
163
|
|
|
$orderby = 'nameA'; |
164
|
|
|
} |
165
|
|
|
if ('school ASC' === $orderby) { |
166
|
|
|
$orderby = 'schoolA'; |
167
|
|
|
} |
168
|
|
|
if ('studies ASC' === $orderby) { |
169
|
|
|
$orderby = 'studiesA'; |
170
|
|
|
} |
171
|
|
|
if ('year ASC' === $orderby) { |
172
|
|
|
$orderby = 'yearA'; |
173
|
|
|
} |
174
|
|
|
if ('date ASC' === $orderby) { |
175
|
|
|
$orderby = 'dateA'; |
176
|
|
|
} |
177
|
|
|
if ('view ASC' === $orderby) { |
178
|
|
|
$orderby = 'viewA'; |
179
|
|
|
} |
180
|
|
|
if ('lname DESC' === $orderby) { |
181
|
|
|
$orderby = 'nameD'; |
182
|
|
|
} |
183
|
|
|
if ('school DESC' === $orderby) { |
184
|
|
|
$orderby = 'schoolD'; |
185
|
|
|
} |
186
|
|
|
if ('studies DESC' === $orderby) { |
187
|
|
|
$orderby = 'studiesD'; |
188
|
|
|
} |
189
|
|
|
if ('year DESC' === $orderby) { |
190
|
|
|
$orderby = 'yearD'; |
191
|
|
|
} |
192
|
|
|
if ('date DESC' === $orderby) { |
193
|
|
|
$orderby = 'dateD'; |
194
|
|
|
} |
195
|
|
|
if ('view DESC' === $orderby) { |
196
|
|
|
$orderby = 'viewD'; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
return $orderby; |
200
|
|
|
} |
201
|
|
|
|
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.