class_LinkGenerator.inc.php
8.76 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
<?php
/**
* @file LinkGenerator.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/>.
*
*/
class LinkGenerator {
public static function getLabelArrayFromUrl(Account &$param_HostAccount, iStorable &$param_iStorable, array $param_URL) {
// D::show($param_URL);
$var_result = array();
if(array_key_exists('p', $param_URL)) {
for($i=count($param_URL['p']); $i>=0; --$i) {
if(array_key_exists($i, $param_URL['p']) && $param_URL['p'][$i]) {
$FncVar_BasisClipboardnameArray = CONFIG::transformStringToArray($param_URL['p'][$i], 'category');
if(class_exists($FncVar_BasisClipboardnameArray[0])) {
if(is_subclass_of($FncVar_BasisClipboardnameArray[0], 'BasisClipboard')) {
if(!array_key_exists('BasisClipboard', $var_result)) {
$var_result['BasisClipboard'] = array();
$var_result['BasisClipboard']['value'] = $param_URL['p'][$i];
$var_result['BasisClipboard']['_i'] = $i;
}
} else if(is_subclass_of($FncVar_BasisClipboardnameArray[0], 'BasisElement')) {
if(!array_key_exists('RootElement', $var_result)) {
$var_result['RootElement'] = array();
$var_result['RootElement']['value'] = $param_URL['p'][$i];
$var_result['RootElement']['_i'] = $i;
}
}
} else if($param_URL['p'][$i]=='ID' && $param_URL['p'][$i+1] && $param_URL['p'][$i-1]=='showSingle') {
$BasisElement =& MultimediaText::loadElement($param_HostAccount, $param_iStorable, $param_Class='*', $param_URL['p'][$i+1], $param_PartOf=null, $param_BasisClipboardArray=null, $param_OnlyWhenLouded=true);
if(!array_key_exists('showSingle', $var_result)) {
$var_result['showSingle'] = array();
if(is_object($BasisElement)) {
$var_result['showSingle']['Subject'] = $BasisElement->getObjVar('Subject');
$var_result['showSingle']['class'] = $BasisElement->ThisClassName;
} else {
$var_result['showSingle']['Subject'] = 'SingleView('.$param_URL['p'][$i+1].')';
}
$var_result['showSingle']['ID'] = $param_URL['p'][$i+1];
$var_result['showSingle']['_i'] = $i;
}
}
}
}
}
//D::show($var_result) ;
if(!empty($var_result)) {
if(!array_key_exists('showSingle', $var_result) && !array_key_exists('BasisClipboard', $var_result) && array_key_exists('RootElement', $var_result) && $var_result['RootElement']['value']) {
if(is_subclass_of('Profile',$var_result['RootElement']['value'])) {
$var_HostClass = 'Profile';
}
$var_Language1 = Language::getClassLinks($var_HostClass, $var_result['RootElement']['value']);
return $var_Language1;
// @warnung terminiert @f
// } else if(!array_key_exists('showSingle', $var_result) && array_key_exists('RootElement', $var_result) && $var_result['RootElement']['_i']+1 == $var_result['BasisClipboard']['_i']) {
} else if(!array_key_exists('showSingle', $var_result) && array_key_exists('RootElement', $var_result) && $var_result['RootElement']['_i']+1 == $var_result['BasisClipboard']['_i']) {
if(is_subclass_of('Profile',$var_result['RootElement']['value'])) {
$var_result['RootElement']['value'] = 'Profile';
}
$var_Language1 = Language::getClassLinks($var_result['RootElement']['value'], $var_result['BasisClipboard']['value']);
return $var_Language1;
// @warnung terminiert @f
// } else if($var_result['showSingle']['_i'] > $var_result['RootElement']['_i'] && $var_result['showSingle']['_i'] > $var_result['BasisClipboard']['_i']) {
} else if(array_key_exists('showSingle', $var_result) && $var_result['showSingle']['_i'] > $var_result['RootElement']['_i'] && $var_result['showSingle']['_i'] > $var_result['BasisClipboard']['_i']) {
return array('label'=>$var_result['showSingle']['Subject']);
// @warnung terminiert @f
// } else if($var_result['showSingle']['_i'] > $var_result['RootElement']['_i'] && $var_result['showSingle']['_i'] < $var_result['BasisClipboard']['_i']) {
} else if(array_key_exists('showSingle', $var_result) && $var_result['showSingle']['_i'] > $var_result['RootElement']['_i'] && $var_result['showSingle']['_i'] < $var_result['BasisClipboard']['_i']) {
$var_Language1 = Language::getClassLinks($var_result['showSingle']['class'], $var_result['BasisClipboard']['value']);
return $var_Language1;
} else {
return array('label'=>'?');
}
} else {
return array('label'=>'?');
}
// return $var_result;
}
public static function transformBEToLinkString(BasisElement $param_BE, $param_KindOf='showSingle') {
$var_PartOfDataArray = $param_BE->getPartOfDataArray($param_BE->getObjVar('PartOfID'));
if(is_array($var_PartOfDataArray) && array_key_exists('WayToRoot', $var_PartOfDataArray) && array_key_exists('string', $var_PartOfDataArray['WayToRoot'])) {
$var_Link = $var_PartOfDataArray['WayToRoot']['string'];
} else {
$var_Link = '';
}
$var_Link .= 'p[]='.$param_KindOf.'&p[]=ID&p[]='.$param_BE->getObjVar('ID').'';
return $var_Link;
}
/**
* make and return String for BasisElement
*
* @param int param_BEID
*/
// public static function getBasisElementLinkString($param_BEID, $param_PartOfID, $param_PartOfObjVar) {
// if($param_PartOfID) {
// if($param_PartOfObjVar) {
// $var_Url= 'p[0]=showSingle&p[1]=ID&p[2]='.$param_PartOfID.'&p[3]='.$param_PartOfObjVar.'&p[4]=showSingle&p[5]=ID&p[6]='.$param_BEID;
// } else {
// $var_Url= 'p[0]=showSingle&p[1]=ID&p[2]='.$param_PartOfID.'&p[3]=LinkList&p[4]=showSingle&p[5]=ID&p[6]='.$param_BEID;
// }
// } else {
// $var_Url= 'p[0]=showSingle&p[1]=ID&p[2]='.$param_BEID.'';
// }
// return $var_Url;
// }
// public static function getBasisElementEditLinkString($param_BEID, $param_PartOfID, $param_PartOfObjVar) {
// if($param_PartOfID && $param_PartOfObjVar) {
// $var_Url= 'p[0]=showSingle&p[1]=ID&p[2]='.$param_PartOfID.'&p[3]='.$param_PartOfObjVar.'&p[4]=edit&p[5]=ID&p[6]='.$param_BEID;
// return $var_Url;
// } else {
// return false;
// }
//
// }
/**
* short recursive function, which returns array_keys and array_values as a url
*
*@param array $param_array the array
*@param String $param_return the return string
*@return String
*/
public static function transformArrayToStringUrl(array $param_array, $param_return = ''){
if(is_array($param_array)){
foreach($param_array as $key => $value){
if(is_array($value))
return LinkGenerator::transformArrayToStringUrl($value,$param_return.'['.$key.']');
else
return $param_return.'['.$key.']'.'='.$value;
}
}
}
/**
* make and return String for Service Link
*
* @param String param_KindOf Service (like rss2, xml, atom, ...)
* @param int param_PartOfID
* @param String param_BasisClipboardname=null
*/
public static function getServiceLinkString($param_KindOf, $param_PartOfID, array $param_BasisClipboardname=null, array $param_ConditionArray = null, $param_UrlString=null, $param_value) {
if($param_PartOfID) {
if($param_UrlString) {
$var_Url= 'output='.$param_KindOf.'&'.$param_UrlString.'';
} else if($param_BasisClipboardname) {
$var_keys = array_keys($param_BasisClipboardname);
// $var_Url= 'output='.$param_KindOf.'&p[0]=showSingle&p[1]=ID&p[2]='.$param_PartOfID.'&p[3]='.$param_BasisClipboardname.'';
$var_Url= 'output='.$param_KindOf.'&p[0]=showSingle&p[1]=ID&p[2]='.$param_PartOfID.'&p[3]='.$var_keys[0].'';
if(is_array($param_ConditionArray)){
$var_Url .= ListCondition::tranformConditionToUrl($param_PartOfID,$var_keys[0],$param_ConditionArray);
}
else if($param_value == CONSTKindOf::LINK_WITH_C){
if(array_key_exists('c',$_GET) && array_key_exists($param_PartOfID,$_GET['c']) && array_key_exists($var_keys[0],$_GET['c'][$param_PartOfID])){
$var_Url.='&c['.$param_PartOfID.']['.$var_keys[0].']';
$var_Url.=LinkGenerator::transformArrayToStringUrl($_GET['c'][$param_PartOfID][$var_keys[0]]);
}
}
} else {
$var_Url= 'output='.$param_KindOf.'&p[0]=showSingle&p[1]=ID&p[2]='.$param_PartOfID.'';
}
} else {
return false;
}
return $var_Url;
}
// public static function transformArrayToUrl(array $param_) {
// }
}
?>