class_XSLPHPFunction.inc.php
7.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
/**
* @file XSLPHPFunction.inc.php
* @category freeSN
* @mailto code [at] netz.coop
* @version 0.4.200901
* @link http://netz.coop
*
* @copyright Copyright by netz.coop e.G. 2015
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* In dieser Klasse stehen die PHP Funktionen drinn, die aus dem XSL Script ausgerufen werden
*
* @version 0.070115 (CD-0.8.3)
* @author dev [at] mensch [dot] coop
*/
class XSLPHPFunction{
public static function getLinkAccountManagement(){ return CONSTKindOf::LINK_ACCOUNTMANAGEMENT;}
/**
* nocht nicht geprüfte Funktionen
*/
public static function getLastIndex($param_url){
$var = strrchr ($param_url, "[");
$var = substr ($var, 1, strpos($var,"]")-1);
if($var==""){
$var = 0;
} else {
$var++;
}
return trim($var);
}
public static function getURL(){
return $_SERVER['PHP_SELF'];
}
/**
* benötigt in default.xsl Function_TimeFormular
*/
public static function getThisDay($time){
if($time) return date('j', $time);
else return date('j', time());
}
public static function getThisMonth($time, $text='n'){
if($time){
if($text=='F' || $text=='M'){
return Language::getWord(date($text, $time));
}
return date($text, $time);
}
else return date($text, time());
}
public static function getThisYear($time, $text='Y'){
if($time) return date($text, $time);
else return date($text, time());
}
public static function getThisHour($time){
if($time) return date('G', $time);
else return date('G', time());
}
public static function getThisMinute($time){
if($time) return date('i', $time);
else return date('i', time());
}
public static function getStampToIcal($time){
return date('Ymd',$time).'T'.date('Gis',$time);
}
public static function getThisDate($param_start, $param_end){
if($param_start == $param_end or $param_end < $param_start){
return Language::getWord(date('l', $param_start))." ".date('d.m.y G:i', $param_start);
}
$var_return = Language::getWord(date('l', $param_start))." ".date('d.m.y G:i', $param_start)." - ";
if(date('z',$param_end) > date('z',$param_start) || date('y',$param_end) > date('y',$param_start)){
$var_return .= Language::getWord(date('l', $param_end))." ".date('d.m.y G:i', $param_end);
}
else{
$var_return .= date('G:i', $param_end);
}
return $var_return;
}
public static function getTextForService($text){
if($text){
$text = strip_tags($text);
$kill = array("\r\n", "\n", "\r");
$text = str_replace($kill, " ", $text);
}
return trim($text);
}
public static function getTextForRSS($text){
if($text){
$text = strip_tags($text);
$text = htmlspecialchars($text);
$text = strip_tags($text);
}
return $text;
}
/**
* benötigt in default.xsl loop_FormularOption
*/
public static function getStartTagSelectOptionSelected(){return "<option selected>"; }
public static function getStartTagSelectOption(){ return "<option>"; }
public static function getEndTagSelectOption(){ return "</option>"; }
public static function getLinkallFromThisClipboardType() { return CONSTKindOf::LINK_ALLFROMTHISCLIPBOARDTYPE; }
public static function getLinkShowAll() { return CONSTKindOf::LINK_SHOWALL; }
public static function getLinkShowList() { return CONSTKindOf::LINK_SHOWLIST; }
public static function getLinkMakeNew() { return CONSTKindOf::LINK_MAKENEW; }
public static function getLinkEdit() { return CONSTKindOf::LINK_EDIT; }
public static function getLinkEditSB() { return CONSTKindOf::LINK_EDITSB; }
public static function getLinkShowSingle() { return CONSTKindOf::LINK_SHOWSINGLE; }
public static function getLinkID() { return CONSTKindOf::LINK_ID; }
public static function getLinkShowAllChildren(){ return CONSTKindOf::LINK_SHOWALLCHILDREN; }
public static function getLinkShowAllParents(){ return CONSTKindOf::LINK_SHOWALLPARENTS; }
public static function getLinkShowLinkList(){ return CONSTKindOf::LINK_SHOWLINKLIST; }
public static function getLinkAddToLinkList(){ return CONSTKindOf::LINK_ADDTOLINKLIST; }
public static function getLinkRemoveFromLinkList(){ return CONSTKindOf::LINK_REMOVEFROMLINKLIST;}
public static function getLinkAddElementTo(){ return CONSTKindOf::LINK_ADDELEMENTTO; }
public static function getLinkAnswerAspirant() { return CONSTKindOf::LINK_ANSWERASPIRANT; }
public static function getLinkShowWriteMembers() { return CONSTKindOf::LINK_SHOWWRITEMEMBERS; }
public static function getLinkRequestAspirant() { return CONSTKindOf::LINK_REQUESTASPIRANT; }
public static function getLinkError() { return CONSTKindOf::LINK_ERROR; }
public static function getLinkChangePassword() { return CONSTKindOf::LINK_CHANGEPASSWORD; }
// public static function getLinkListNavigatorStart(){ return CONSTKindOf::LINK_LISTNAVIGATOR_START;}
// public static function getLinkListNavigatorLimit(){ return CONSTKindOf::LINK_LISTNAVIGATOR_LIMIT;}
// public static function getLinkListNavigatorDirection(){ return CONSTKindOf::LINK_LISTNAVIGATOR_DIRECTION; }
// public static function getLinkListNavigatorUpDirection(){ return CONSTKindOf::LINK_LISTNAVIGATOR_UPDIRECTION; }
// public static function getLinkListNavigatorDownDirection(){ return CONSTKindOf::LINK_LISTNAVIGATOR_DOWNDIRECTION; }
public static function getLinkShowAspirant() { return CONSTKindOf::LINK_SHOWASPIRANT; }
public static function checkTags($param_string, $param_index) {
if(strlen($param_string) > $param_index){
$param_string = substr($param_string, 0 ,$param_index);
//offene tags entfernen
if(strrpos($param_string,'<') > strrpos($param_string,'>')){
$param_string=substr($param_string,0,strrpos($param_string,'<'));
}
//schliessende Tags hinzufügen
/*preg_match_all("/(<\w+)(?:.){0,}?>/", $param_string, $v1);*/
preg_match_all("/<[^>]*[^\/]>/", $param_string, $v1);
preg_match_all("/<\/\w+>/", $param_string, $v2);
$open = array_map('strtolower', $v1[0]);
$closed = array_map('strtolower', $v2[0]);
$string_add = '';
foreach ($open as $tag)
{
/*$end_tag = preg_replace("/<(.*)/", "</$1>", $tag);*/
//$end_tag = preg_replace("/<([^>^ ]*)/", "</$1>", $tag);
$end_tag = substr($tag,1);
if($index = strpos($end_tag," ")){
$end_tag = '</'.substr($end_tag,0,$index).'>';
}
else{
$end_tag = '</'.substr($end_tag,0,-1).'>';
}
if (!in_array($end_tag, $closed)){
$string_add =$end_tag.$string_add;
}
unset($closed[array_search($end_tag, $closed)]);
}
$param_string .= "...";
$param_string .= $string_add;
}
//entferne [BasisElement]
$param_string = preg_replace('/\[BasisElement\s\w*\s\d*\]/i', '', $param_string);
return $param_string;
}
}
?>