@@ -29,9 +29,9 @@ |
||
29 | 29 | * @param string $title |
30 | 30 | * @param string $description |
31 | 31 | */ |
32 | - public function __construct($id,$title,$description,$display_order) |
|
32 | + public function __construct($id, $title, $description, $display_order) |
|
33 | 33 | { |
34 | - parent::__construct($id,RESOURCE_LINKCATEGORY); |
|
34 | + parent::__construct($id, RESOURCE_LINKCATEGORY); |
|
35 | 35 | $this->title = $title; |
36 | 36 | $this->description = $description; |
37 | 37 | $this->display_order = $display_order; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $this_section = SECTION_COURSES; |
49 | 49 | $nameTools = get_lang('CopyCourse'); |
50 | -$returnLink = api_get_path(WEB_CODE_PATH) . 'course_info/maintenance_coach.php?' . api_get_cidreq(); |
|
50 | +$returnLink = api_get_path(WEB_CODE_PATH).'course_info/maintenance_coach.php?'.api_get_cidreq(); |
|
51 | 51 | $interbreadcrumb[] = array( |
52 | 52 | 'url' => $returnLink, |
53 | 53 | 'name' => get_lang('Maintenance') |
@@ -73,29 +73,29 @@ discard block |
||
73 | 73 | $attrs = ''; |
74 | 74 | if (count($attr) > 0) { |
75 | 75 | foreach ($attr as $key => $value) { |
76 | - $attrs .= ' ' . $key . '="' . $value . '"'; |
|
76 | + $attrs .= ' '.$key.'="'.$value.'"'; |
|
77 | 77 | } |
78 | 78 | } |
79 | - $output = '<select name="' . $name . '" ' . $attrs . '>'; |
|
79 | + $output = '<select name="'.$name.'" '.$attrs.'>'; |
|
80 | 80 | |
81 | 81 | if (count($sessions) == 0) { |
82 | - $output .= '<option value = "0">' . get_lang( |
|
82 | + $output .= '<option value = "0">'.get_lang( |
|
83 | 83 | 'ThereIsNotStillASession' |
84 | - ) . '</option>'; |
|
84 | + ).'</option>'; |
|
85 | 85 | } else { |
86 | - $output .= '<option value = "0">' . get_lang( |
|
86 | + $output .= '<option value = "0">'.get_lang( |
|
87 | 87 | 'SelectASession' |
88 | - ) . '</option>'; |
|
88 | + ).'</option>'; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | if (is_array($sessions)) { |
92 | 92 | foreach ($sessions as $session) { |
93 | 93 | $category_name = ''; |
94 | 94 | if (!empty($session['category_name'])) { |
95 | - $category_name = ' (' . $session['category_name'] . ')'; |
|
95 | + $category_name = ' ('.$session['category_name'].')'; |
|
96 | 96 | } |
97 | 97 | |
98 | - $output .= '<option value="' . $session['id'] . '">' . $session['name'] . ' ' . $category_name . '</option>'; |
|
98 | + $output .= '<option value="'.$session['id'].'">'.$session['name'].' '.$category_name.'</option>'; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | $output .= '</select>'; |
@@ -120,43 +120,43 @@ discard block |
||
120 | 120 | // Actions |
121 | 121 | $html .= '<div class="actions">'; |
122 | 122 | // Link back to the documents overview |
123 | - $html .= '<a href="' . $returnLink . '">' . Display::return_icon( |
|
124 | - 'back.png', get_lang('BackTo') . ' ' . get_lang('Maintenance'), '', ICON_SIZE_MEDIUM |
|
125 | - ) . '</a>'; |
|
123 | + $html .= '<a href="'.$returnLink.'">'.Display::return_icon( |
|
124 | + 'back.png', get_lang('BackTo').' '.get_lang('Maintenance'), '', ICON_SIZE_MEDIUM |
|
125 | + ).'</a>'; |
|
126 | 126 | $html .= '</div>'; |
127 | 127 | |
128 | 128 | $html .= Display::return_message( |
129 | 129 | get_lang('CopyCourseFromSessionToSessionExplanation') |
130 | 130 | ); |
131 | 131 | |
132 | - $html .= '<form name="formulaire" method="post" action="' . api_get_self( |
|
133 | - ) . '?' . api_get_cidreq() . '" >'; |
|
132 | + $html .= '<form name="formulaire" method="post" action="'.api_get_self( |
|
133 | + ).'?'.api_get_cidreq().'" >'; |
|
134 | 134 | $html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">'; |
135 | 135 | |
136 | 136 | // Source |
137 | - $html .= '<tr><td width="15%"><b>' . get_lang( |
|
137 | + $html .= '<tr><td width="15%"><b>'.get_lang( |
|
138 | 138 | 'OriginCoursesFromSession' |
139 | - ) . ':</b></td>'; |
|
140 | - $html .= '<td width="10%" align="left">' . api_get_session_name( |
|
139 | + ).':</b></td>'; |
|
140 | + $html .= '<td width="10%" align="left">'.api_get_session_name( |
|
141 | 141 | $sessionId |
142 | - ) . '</td>'; |
|
142 | + ).'</td>'; |
|
143 | 143 | $html .= '<td width="50%">'; |
144 | - $html .= "{$courseInfo['title']} ({$courseInfo['code']})" . '</td></tr>'; |
|
144 | + $html .= "{$courseInfo['title']} ({$courseInfo['code']})".'</td></tr>'; |
|
145 | 145 | |
146 | 146 | // Destination |
147 | - $html .= '<tr><td width="15%"><b>' . get_lang( |
|
147 | + $html .= '<tr><td width="15%"><b>'.get_lang( |
|
148 | 148 | 'DestinationCoursesFromSession' |
149 | - ) . ':</b></td>'; |
|
149 | + ).':</b></td>'; |
|
150 | 150 | $html .= '<td width="10%" align="left"><div id="ajax_sessions_list_destination">'; |
151 | 151 | $html .= '<select name="sessions_list_destination" onchange="javascript: xajax_searchCourses(this.value,\'destination\');">'; |
152 | 152 | if (empty($sessions)) { |
153 | - $html .= '<option value = "0">' . get_lang( |
|
153 | + $html .= '<option value = "0">'.get_lang( |
|
154 | 154 | 'ThereIsNotStillASession' |
155 | - ) . '</option>'; |
|
155 | + ).'</option>'; |
|
156 | 156 | } else { |
157 | - $html .= '<option value = "0">' . get_lang( |
|
157 | + $html .= '<option value = "0">'.get_lang( |
|
158 | 158 | 'SelectASession' |
159 | - ) . '</option>'; |
|
159 | + ).'</option>'; |
|
160 | 160 | foreach ($sessions as $session) { |
161 | 161 | if ($session['id'] == $sessionId) { |
162 | 162 | continue; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | continue; |
167 | 167 | } |
168 | 168 | |
169 | - $html .= '<option value="' . $session['id'] . '">' . $session['name'] . '</option>'; |
|
169 | + $html .= '<option value="'.$session['id'].'">'.$session['name'].'</option>'; |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -178,17 +178,17 @@ discard block |
||
178 | 178 | $html .= '</tr></table>'; |
179 | 179 | |
180 | 180 | $html .= "<fieldset>"; |
181 | - $html .= '<legend>' . get_lang('TypeOfCopy') . ' <small>(' . get_lang('CopyOnlySessionItems') . ')</small></legend>'; |
|
181 | + $html .= '<legend>'.get_lang('TypeOfCopy').' <small>('.get_lang('CopyOnlySessionItems').')</small></legend>'; |
|
182 | 182 | $html .= '<label class="radio"><input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>'; |
183 | - $html .= get_lang('FullCopy') . '</label>'; |
|
183 | + $html .= get_lang('FullCopy').'</label>'; |
|
184 | 184 | $html .= '<label class="radio"><input type="radio" id="copy_option_2" name="copy_option" value="select_items"/>'; |
185 | - $html .= ' ' . get_lang('LetMeSelectItems') . '</label><br/>'; |
|
185 | + $html .= ' '.get_lang('LetMeSelectItems').'</label><br/>'; |
|
186 | 186 | |
187 | 187 | $html .= "</fieldset>"; |
188 | 188 | |
189 | - $html .= '<button class="save" type="submit" onclick="javascript:if(!confirm(' . "'" . addslashes( |
|
189 | + $html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes( |
|
190 | 190 | api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES) |
191 | - ) . "'" . ')) return false;">' . get_lang('CopyCourse') . '</button>'; |
|
191 | + )."'".')) return false;">'.get_lang('CopyCourse').'</button>'; |
|
192 | 192 | $html .= '</form>'; |
193 | 193 | echo $html; |
194 | 194 | } |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | |
215 | 215 | $courseTitle = str_replace("'", "\'", $course['title']); |
216 | 216 | |
217 | - $return .= '<option value="' . $course['code'] . '" title="' . @htmlspecialchars( |
|
218 | - $course['title'] . ' (' . $course['visual_code'] . ')', ENT_QUOTES, api_get_system_encoding() |
|
219 | - ) . '">' . |
|
220 | - $course['title'] . ' (' . $course['visual_code'] . ')</option>'; |
|
217 | + $return .= '<option value="'.$course['code'].'" title="'.@htmlspecialchars( |
|
218 | + $course['title'].' ('.$course['visual_code'].')', ENT_QUOTES, api_get_system_encoding() |
|
219 | + ).'">'. |
|
220 | + $course['title'].' ('.$course['visual_code'].')</option>'; |
|
221 | 221 | } |
222 | 222 | $return .= '</select>'; |
223 | 223 | $_SESSION['course_list_destination'] = $course_list_destination; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | /* HTML head extra */ |
236 | 236 | |
237 | 237 | $htmlHeadXtra[] = $xajax->getJavascript( |
238 | - api_get_path(WEB_LIBRARY_PATH) . 'xajax/' |
|
238 | + api_get_path(WEB_LIBRARY_PATH).'xajax/' |
|
239 | 239 | ); |
240 | 240 | $htmlHeadXtra[] = '<script> |
241 | 241 | function checkSelected(id_select,id_radio,id_title,id_destination) { |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | |
381 | 381 | CourseSelectForm :: display_form($course, $hiddenFields, true); |
382 | 382 | |
383 | - echo '<div style="float:right"><a href="javascript:window.history.go(-1);">' . |
|
383 | + echo '<div style="float:right"><a href="javascript:window.history.go(-1);">'. |
|
384 | 384 | Display::return_icon( |
385 | 385 | 'back.png', |
386 | 386 | get_lang('Back').' '.get_lang('To').' '.get_lang( |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | ), |
389 | 389 | array('style' => 'vertical-align:middle') |
390 | 390 | ). |
391 | - get_lang('Back') . '</a></div>'; |
|
391 | + get_lang('Back').'</a></div>'; |
|
392 | 392 | } else { |
393 | 393 | Display::display_error_message( |
394 | 394 | get_lang('You must select a course from original session and select a destination session') |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $form = new FormValidator( |
101 | 101 | 'survey', |
102 | 102 | 'post', |
103 | - api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.$survey_id. '&' . api_get_cidreq() |
|
103 | + api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.$survey_id.'&'.api_get_cidreq() |
|
104 | 104 | ); |
105 | 105 | |
106 | 106 | $form->addElement('header', $tool_name); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | foreach ($field_list as $key => & $field) { |
217 | 217 | if ($field['visibility'] == 1) { |
218 | 218 | $form->addElement('checkbox', 'profile_'.$key, ' ', ' '.$field['name']); |
219 | - $input_name_list.= 'profile_'.$key.','; |
|
219 | + $input_name_list .= 'profile_'.$key.','; |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 |
@@ -230,7 +230,7 @@ |
||
230 | 230 | /** |
231 | 231 | * Get id |
232 | 232 | * |
233 | - * @return boolean |
|
233 | + * @return integer |
|
234 | 234 | */ |
235 | 235 | public function getId() |
236 | 236 | { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | - require_once api_get_path(SYS_PLUGIN_PATH) . 'buycourses/database.php'; |
|
94 | + require_once api_get_path(SYS_PLUGIN_PATH).'buycourses/database.php'; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | $item = $this->getItemByProduct(intval($productId), $productType); |
136 | 136 | $return['html'] = '<div class="buycourses-price">'; |
137 | 137 | if ($item) { |
138 | - $return['html'] .= '<span class="label label-primary"><b>'. $item['iso_code'] .' ' . $item['price'] . '</b></span>'; |
|
138 | + $return['html'] .= '<span class="label label-primary"><b>'.$item['iso_code'].' '.$item['price'].'</b></span>'; |
|
139 | 139 | $return['verificator'] = true; |
140 | 140 | } else { |
141 | - $return['html'] .= '<span class="label label-primary"><b>'. $this->get_lang('Free'). '</b></span>'; |
|
141 | + $return['html'] .= '<span class="label label-primary"><b>'.$this->get_lang('Free').'</b></span>'; |
|
142 | 142 | $return['verificator'] = false; |
143 | 143 | } |
144 | 144 | $return['html'] .= '</div>'; |
@@ -156,15 +156,15 @@ discard block |
||
156 | 156 | * @return string $html |
157 | 157 | */ |
158 | 158 | public function returnBuyCourseButton($productId, $productType) { |
159 | - $url = api_get_path(WEB_PLUGIN_PATH) . |
|
160 | - 'buycourses/src/process.php?i=' . |
|
161 | - intval($productId) . |
|
162 | - '&t=' . |
|
159 | + $url = api_get_path(WEB_PLUGIN_PATH). |
|
160 | + 'buycourses/src/process.php?i='. |
|
161 | + intval($productId). |
|
162 | + '&t='. |
|
163 | 163 | $productType |
164 | 164 | ; |
165 | 165 | |
166 | - $html = ' <a class="btn btn-success btn-sm" title="' . $this->get_lang('Buy') . '" href="' . $url . '">' . |
|
167 | - Display::returnFontAwesomeIcon('fa fa-shopping-cart') . '</a>'; |
|
166 | + $html = ' <a class="btn btn-success btn-sm" title="'.$this->get_lang('Buy').'" href="'.$url.'">'. |
|
167 | + Display::returnFontAwesomeIcon('fa fa-shopping-cart').'</a>'; |
|
168 | 168 | |
169 | 169 | return $html; |
170 | 170 | } |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | ); |
710 | 710 | |
711 | 711 | if (!empty($sessionImage)) { |
712 | - $sessionInfo['image'] = api_get_path(WEB_UPLOAD_PATH) . $sessionImage['value']; |
|
712 | + $sessionInfo['image'] = api_get_path(WEB_UPLOAD_PATH).$sessionImage['value']; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | $sessionCourses = $session->getCourses(); |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | $str = ''; |
1153 | 1153 | |
1154 | - srand((double)microtime() * 1000000); |
|
1154 | + srand((double) microtime() * 1000000); |
|
1155 | 1155 | |
1156 | 1156 | for ($i = 0; $i < $length; $i++) { |
1157 | 1157 | $numbers = rand(0, strlen($salt) - 1); |
@@ -1498,8 +1498,8 @@ discard block |
||
1498 | 1498 | */ |
1499 | 1499 | public function getPayouts($status = self::PAYOUT_STATUS_PENDING, $payoutId = false, $userId = false) |
1500 | 1500 | { |
1501 | - $condition = ($payoutId) ? 'AND p.id = '. intval($payoutId) : ''; |
|
1502 | - $condition2 = ($userId) ? ' AND p.user_id = ' . intval($userId) : ''; |
|
1501 | + $condition = ($payoutId) ? 'AND p.id = '.intval($payoutId) : ''; |
|
1502 | + $condition2 = ($userId) ? ' AND p.user_id = '.intval($userId) : ''; |
|
1503 | 1503 | $typeResult = ($condition) ? 'first' : 'all'; |
1504 | 1504 | $payoutsTable = Database::get_main_table(BuyCoursesPlugin::TABLE_PAYPAL_PAYOUTS); |
1505 | 1505 | $saleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SALE); |
@@ -1526,14 +1526,14 @@ discard block |
||
1526 | 1526 | INNER JOIN $saleTable s ON s.id = p.sale_id |
1527 | 1527 | INNER JOIN $currencyTable c ON s.currency_id = c.id |
1528 | 1528 | LEFT JOIN $extraFieldValues efv ON p.user_id = efv.item_id |
1529 | - AND field_id = " . intval($paypalExtraField['id']) . " |
|
1529 | + AND field_id = ".intval($paypalExtraField['id'])." |
|
1530 | 1530 | "; |
1531 | 1531 | |
1532 | 1532 | $payouts = Database::select( |
1533 | 1533 | "p.* , u.firstname, u.lastname, efv.value as paypal_account, s.reference as sale_reference, s.price as item_price, c.iso_code", |
1534 | 1534 | "$payoutsTable p $innerJoins", |
1535 | 1535 | [ |
1536 | - 'where' => ['p.status = ? '.$condition . ' ' .$condition2 => $status] |
|
1536 | + 'where' => ['p.status = ? '.$condition.' '.$condition2 => $status] |
|
1537 | 1537 | ], |
1538 | 1538 | $typeResult |
1539 | 1539 | ); |
@@ -1597,7 +1597,7 @@ discard block |
||
1597 | 1597 | $platformCommission = $this->getPlatformCommission(); |
1598 | 1598 | |
1599 | 1599 | $sale = $this->getSale($saleId); |
1600 | - $teachersCommission = number_format((floatval($sale['price']) * intval($platformCommission['commission']))/100, 2); |
|
1600 | + $teachersCommission = number_format((floatval($sale['price']) * intval($platformCommission['commission'])) / 100, 2); |
|
1601 | 1601 | |
1602 | 1602 | |
1603 | 1603 | $beneficiaries = $this->getBeneficiariesBySale($saleId); |
@@ -1609,7 +1609,7 @@ discard block |
||
1609 | 1609 | 'payout_date' => getdate(), |
1610 | 1610 | 'sale_id' => intval($saleId), |
1611 | 1611 | 'user_id' => $beneficiary['user_id'], |
1612 | - 'commission' => number_format((floatval($teachersCommission) * intval($beneficiary['commissions']))/100, 2), |
|
1612 | + 'commission' => number_format((floatval($teachersCommission) * intval($beneficiary['commissions'])) / 100, 2), |
|
1613 | 1613 | 'status' => self::PAYOUT_STATUS_PENDING |
1614 | 1614 | ] |
1615 | 1615 | ); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | /** |
47 | 47 | * |
48 | - * @return StaticPlugin |
|
48 | + * @return BuyCoursesPlugin |
|
49 | 49 | */ |
50 | 50 | static function create() |
51 | 51 | { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | /** |
269 | 269 | * Save a transfer account information |
270 | 270 | * @param array $params The transfer account |
271 | - * @return int Rows affected. Otherwise return false |
|
271 | + * @return false|string Rows affected. Otherwise return false |
|
272 | 272 | */ |
273 | 273 | public function saveTransferAccount($params) |
274 | 274 | { |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | /** |
681 | 681 | * Get session info |
682 | 682 | * @param array $sessionId The session ID |
683 | - * @return array |
|
683 | + * @return Session |
|
684 | 684 | */ |
685 | 685 | public function getSessionInfo($sessionId) |
686 | 686 | { |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | * Register a sale |
774 | 774 | * @param int $itemId The product ID |
775 | 775 | * @param int $paymentType The payment type |
776 | - * @return boolean |
|
776 | + * @return false|string |
|
777 | 777 | */ |
778 | 778 | public function registerSale($itemId, $paymentType) |
779 | 779 | { |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | |
956 | 956 | /** |
957 | 957 | * Get payment types |
958 | - * @return array |
|
958 | + * @return string[] |
|
959 | 959 | */ |
960 | 960 | public function getPaymentTypes() |
961 | 961 | { |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | |
995 | 995 | /** |
996 | 996 | * Get the statuses for sales |
997 | - * @return array |
|
997 | + * @return string[] |
|
998 | 998 | */ |
999 | 999 | public function getSaleStatuses() |
1000 | 1000 | { |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | |
1008 | 1008 | /** |
1009 | 1009 | * Get the statuses for Payouts |
1010 | - * @return array |
|
1010 | + * @return string[] |
|
1011 | 1011 | */ |
1012 | 1012 | public function getPayoutStatuses() |
1013 | 1013 | { |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | |
1021 | 1021 | /** |
1022 | 1022 | * Get the list of product types |
1023 | - * @return array |
|
1023 | + * @return string[] |
|
1024 | 1024 | */ |
1025 | 1025 | public function getProductTypes() |
1026 | 1026 | { |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | /** |
1402 | 1402 | * Register a item |
1403 | 1403 | * @param array $itemData The item data |
1404 | - * @return int The item ID. Otherwise return false |
|
1404 | + * @return false|string The item ID. Otherwise return false |
|
1405 | 1405 | */ |
1406 | 1406 | public function registerItem(array $itemData) |
1407 | 1407 | { |
@@ -1559,7 +1559,7 @@ discard block |
||
1559 | 1559 | /** |
1560 | 1560 | * Verify if the beneficiary have a paypal account |
1561 | 1561 | * @param int $userId |
1562 | - * @return true if the user have a paypal account, false if not |
|
1562 | + * @return boolean if the user have a paypal account, false if not |
|
1563 | 1563 | */ |
1564 | 1564 | public function verifyPaypalAccountByBeneficiary($userId) |
1565 | 1565 | { |
@@ -1681,7 +1681,7 @@ discard block |
||
1681 | 1681 | /** |
1682 | 1682 | * Register addicional service |
1683 | 1683 | * @param array params $service |
1684 | - * @return mixed response |
|
1684 | + * @return string|false response |
|
1685 | 1685 | */ |
1686 | 1686 | public function storeService($service) |
1687 | 1687 | { |
@@ -1838,7 +1838,7 @@ discard block |
||
1838 | 1838 | |
1839 | 1839 | /** |
1840 | 1840 | * Get the statuses for sales |
1841 | - * @return array |
|
1841 | + * @return string[] |
|
1842 | 1842 | */ |
1843 | 1843 | public function getServiceSaleStatuses() |
1844 | 1844 | { |
@@ -2094,7 +2094,7 @@ discard block |
||
2094 | 2094 | * @param int $paymentType The payment type |
2095 | 2095 | * @param int $infoSelect The ID for Service Type |
2096 | 2096 | * @param int $trial trial mode |
2097 | - * @return boolean |
|
2097 | + * @return false|string |
|
2098 | 2098 | */ |
2099 | 2099 | public function registerServiceSale($serviceId, $paymentType, $infoSelect, $trial = null) |
2100 | 2100 | { |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | |
71 | 71 | $zip_file = CourseArchiver::write_course($course); |
72 | 72 | Display::display_confirmation_message(get_lang('BackupCreated')); |
73 | - echo '<br /><a class="btn btn-primary btn-large" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . $zip_file . '&' . api_get_cidreq() . '"> |
|
74 | - ' . get_lang('Download') . '</a>'; |
|
73 | + echo '<br /><a class="btn btn-primary btn-large" href="'.api_get_path(WEB_CODE_PATH).'course_info/download.php?archive='.$zip_file.'&'.api_get_cidreq().'"> |
|
74 | + ' . get_lang('Download').'</a>'; |
|
75 | 75 | |
76 | 76 | } elseif (Security::check_token('post') && ( |
77 | 77 | isset($_POST['backup_option']) && |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $form = new FormValidator( |
97 | 97 | 'create_backup_form', |
98 | 98 | 'post', |
99 | - api_get_self() . '?' . api_get_cidreq() |
|
99 | + api_get_self().'?'.api_get_cidreq() |
|
100 | 100 | ); |
101 | 101 | $form->addElement('header', get_lang('SelectOptionForBackup')); |
102 | 102 | $form->addElement('radio', 'backup_option', '', get_lang('CreateFullBackup'), 'full_backup'); |
@@ -3054,7 +3054,7 @@ |
||
3054 | 3054 | * @param integer $thread_qualify |
3055 | 3055 | * @param integer $qualify_time |
3056 | 3056 | * @param integer $session_id |
3057 | - * @return array optional |
|
3057 | + * @return string|null optional |
|
3058 | 3058 | * @author Isaac Flores <[email protected]>, U.N.A.S University |
3059 | 3059 | * @version October 2008, dokeos 1.8.6 |
3060 | 3060 | */ |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | var l = $(this); |
65 | 65 | var id = l.closest("tr").attr("id"); |
66 | 66 | var filename = l.closest("tr").find(".attachFilename").html(); |
67 | - if (confirm("' . get_lang('AreYouSureToDeleteJS') . '", filename)) { |
|
67 | + if (confirm("' . get_lang('AreYouSureToDeleteJS').'", filename)) { |
|
68 | 68 | $.ajax({ |
69 | 69 | type: "POST", |
70 | - url: "'.api_get_path(WEB_AJAX_PATH) . 'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId .'&forum='.$forumId .'", |
|
70 | + url: "'.api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId.'&forum='.$forumId.'", |
|
71 | 71 | dataType: "json", |
72 | 72 | success: function(data) { |
73 | 73 | if (data.error == false) { |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | function show_add_forumcategory_form($inputvalues = array(), $lp_id) |
181 | 181 | { |
182 | 182 | // Initialize the object. |
183 | - $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq()); |
|
183 | + $form = new FormValidator('forumcategory', 'post', 'index.php?'.api_get_cidreq()); |
|
184 | 184 | // hidden field if from learning path |
185 | 185 | |
186 | 186 | $form->addElement('hidden', 'lp_id', $lp_id); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | function show_add_forum_form($inputvalues = array(), $lp_id) |
231 | 231 | { |
232 | 232 | $_course = api_get_course_info(); |
233 | - $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq()); |
|
233 | + $form = new FormValidator('forumcategory', 'post', 'index.php?'.api_get_cidreq()); |
|
234 | 234 | |
235 | 235 | // The header for the form |
236 | 236 | if (!empty($inputvalues)) { |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | // Forum image |
348 | 348 | $form->addProgress(); |
349 | 349 | if (!empty($inputvalues['forum_image'])) { |
350 | - $baseImagePath = api_get_course_path() . '/upload/forum/images/' . $inputvalues['forum_image']; |
|
351 | - $image_path = api_get_path(WEB_COURSE_PATH) . $baseImagePath; |
|
352 | - $sysImagePath = api_get_path(SYS_COURSE_PATH) . $baseImagePath; |
|
350 | + $baseImagePath = api_get_course_path().'/upload/forum/images/'.$inputvalues['forum_image']; |
|
351 | + $image_path = api_get_path(WEB_COURSE_PATH).$baseImagePath; |
|
352 | + $sysImagePath = api_get_path(SYS_COURSE_PATH).$baseImagePath; |
|
353 | 353 | |
354 | 354 | if (file_exists($sysImagePath)) { |
355 | 355 | $show_preview_image = Display::img($image_path, null, ['class' => 'img-responsive']); |
@@ -1007,24 +1007,24 @@ discard block |
||
1007 | 1007 | $html = ''; |
1008 | 1008 | $id = Security::remove_XSS($id); |
1009 | 1009 | if ($current_visibility_status == '1') { |
1010 | - $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&'; |
|
1010 | + $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&'; |
|
1011 | 1011 | if (is_array($additional_url_parameters)) { |
1012 | 1012 | foreach ($additional_url_parameters as $key => $value) { |
1013 | - $html .= $key . '=' . $value . '&'; |
|
1013 | + $html .= $key.'='.$value.'&'; |
|
1014 | 1014 | } |
1015 | 1015 | } |
1016 | - $html.='action=invisible&content='.$content.'&id='.$id.'">'. |
|
1016 | + $html .= 'action=invisible&content='.$content.'&id='.$id.'">'. |
|
1017 | 1017 | Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>'; |
1018 | 1018 | } |
1019 | 1019 | if ($current_visibility_status == '0') { |
1020 | - $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&'; |
|
1020 | + $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&'; |
|
1021 | 1021 | if (is_array($additional_url_parameters)) { |
1022 | 1022 | foreach ($additional_url_parameters as $key => $value) { |
1023 | - $html .= $key . '=' . $value . '&'; |
|
1023 | + $html .= $key.'='.$value.'&'; |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | - $html .= 'action=visible&content=' . $content . '&id=' . $id . '">' . |
|
1027 | - Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
1026 | + $html .= 'action=visible&content='.$content.'&id='.$id.'">'. |
|
1027 | + Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL).'</a>'; |
|
1028 | 1028 | } |
1029 | 1029 | return $html; |
1030 | 1030 | } |
@@ -1052,21 +1052,21 @@ discard block |
||
1052 | 1052 | $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&'; |
1053 | 1053 | if (is_array($additional_url_parameters)) { |
1054 | 1054 | foreach ($additional_url_parameters as $key => $value) { |
1055 | - $html .= $key . '=' . $value . '&'; |
|
1055 | + $html .= $key.'='.$value.'&'; |
|
1056 | 1056 | } |
1057 | 1057 | } |
1058 | - $html.= 'action=unlock&content='.$content.'&id='.$id.'">'. |
|
1058 | + $html .= 'action=unlock&content='.$content.'&id='.$id.'">'. |
|
1059 | 1059 | Display::return_icon('lock.png', get_lang('Unlock'), array(), ICON_SIZE_SMALL).'</a>'; |
1060 | 1060 | } |
1061 | 1061 | if ($current_lock_status == '0') { |
1062 | 1062 | $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&'; |
1063 | 1063 | if (is_array($additional_url_parameters)) { |
1064 | 1064 | foreach ($additional_url_parameters as $key => $value) { |
1065 | - $html .= $key . '=' . $value . '&'; |
|
1065 | + $html .= $key.'='.$value.'&'; |
|
1066 | 1066 | } |
1067 | 1067 | } |
1068 | - $html .= 'action=lock&content=' . $content . '&id=' . $id . '">' . |
|
1069 | - Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
1068 | + $html .= 'action=lock&content='.$content.'&id='.$id.'">'. |
|
1069 | + Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL).'</a>'; |
|
1070 | 1070 | } |
1071 | 1071 | return $html; |
1072 | 1072 | } |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | $sort_column = 'forum_order'; |
1245 | 1245 | // We also need the forum_category of this forum. |
1246 | 1246 | $sql = "SELECT forum_category FROM $table_forums |
1247 | - WHERE c_id = $course_id AND forum_id = " . intval($id); |
|
1247 | + WHERE c_id = $course_id AND forum_id = ".intval($id); |
|
1248 | 1248 | $result = Database::query($sql); |
1249 | 1249 | $row = Database::fetch_array($result); |
1250 | 1250 | $forum_category = $row['forum_category']; |
@@ -1269,7 +1269,7 @@ discard block |
||
1269 | 1269 | forum_categories.c_id = $course_id AND |
1270 | 1270 | item_properties.c_id = $course_id AND |
1271 | 1271 | forum_categories.cat_id=item_properties.ref AND |
1272 | - item_properties.tool='" . TOOL_FORUM_CATEGORY . "' |
|
1272 | + item_properties.tool='".TOOL_FORUM_CATEGORY."' |
|
1273 | 1273 | ORDER BY forum_categories.cat_order $sort_direction"; |
1274 | 1274 | } |
1275 | 1275 | if ($content == 'forum') { |
@@ -1277,7 +1277,7 @@ discard block |
||
1277 | 1277 | FROM $table |
1278 | 1278 | WHERE |
1279 | 1279 | c_id = $course_id AND |
1280 | - forum_category='" . Database::escape_string($forum_category) . "' |
|
1280 | + forum_category='".Database::escape_string($forum_category)."' |
|
1281 | 1281 | ORDER BY forum_order $sort_direction"; |
1282 | 1282 | } |
1283 | 1283 | // Finding the items that need to be switched. |
@@ -1301,16 +1301,16 @@ discard block |
||
1301 | 1301 | // We do an extra check if we do not have illegal values. If your remove this if statment you will |
1302 | 1302 | // be able to mess with the sorting by refreshing the page over and over again. |
1303 | 1303 | if ($this_sort != '' && $next_sort != '' && $next_id != '' && $this_id != '') { |
1304 | - $sql = "UPDATE $table SET $sort_column='" . Database::escape_string($this_sort) . "' |
|
1305 | - WHERE c_id = $course_id AND $id_column='" . Database::escape_string($next_id) . "'"; |
|
1304 | + $sql = "UPDATE $table SET $sort_column='".Database::escape_string($this_sort)."' |
|
1305 | + WHERE c_id = $course_id AND $id_column='".Database::escape_string($next_id)."'"; |
|
1306 | 1306 | Database::query($sql); |
1307 | 1307 | |
1308 | - $sql = "UPDATE $table SET $sort_column='" . Database::escape_string($next_sort) . "' |
|
1309 | - WHERE c_id = $course_id AND $id_column='" . Database::escape_string($this_id) . "'"; |
|
1308 | + $sql = "UPDATE $table SET $sort_column='".Database::escape_string($next_sort)."' |
|
1309 | + WHERE c_id = $course_id AND $id_column='".Database::escape_string($this_id)."'"; |
|
1310 | 1310 | Database::query($sql); |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - return get_lang(ucfirst($content) . 'Moved'); |
|
1313 | + return get_lang(ucfirst($content).'Moved'); |
|
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | /** |
@@ -1572,7 +1572,7 @@ discard block |
||
1572 | 1572 | INNER JOIN $table_forums forum |
1573 | 1573 | ON (forum.forum_id = item_properties.ref AND forum.c_id = item_properties.c_id) |
1574 | 1574 | WHERE |
1575 | - forum.forum_id = " . intval($id) . " AND |
|
1575 | + forum.forum_id = ".intval($id)." AND |
|
1576 | 1576 | forum.c_id = $course_id AND |
1577 | 1577 | item_properties.visibility != 2 AND |
1578 | 1578 | item_properties.tool = '".TOOL_FORUM."' |
@@ -1582,7 +1582,7 @@ discard block |
||
1582 | 1582 | $sql2 = "SELECT count(*) AS number_of_threads, forum_id |
1583 | 1583 | FROM $table_threads |
1584 | 1584 | WHERE |
1585 | - forum_id = " . intval($id) . " |
|
1585 | + forum_id = ".intval($id)." |
|
1586 | 1586 | GROUP BY forum_id"; |
1587 | 1587 | } |
1588 | 1588 | |
@@ -1810,7 +1810,7 @@ discard block |
||
1810 | 1810 | $groupCondition = ''; |
1811 | 1811 | if (!empty($groupInfo)) { |
1812 | 1812 | $groupIid = $groupInfo['iid']; |
1813 | - $groupCondition = " AND item_properties.to_group_id = '$groupIid' "; |
|
1813 | + $groupCondition = " AND item_properties.to_group_id = '$groupIid' "; |
|
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | $sessionCondition = api_get_session_condition($sessionId, true, false, 'item_properties.session_id'); |
@@ -2301,7 +2301,7 @@ discard block |
||
2301 | 2301 | { |
2302 | 2302 | $table_forums = Database :: get_course_table(TABLE_FORUM); |
2303 | 2303 | $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
2304 | - $courseId = empty($courseId) ? api_get_course_int_id(): intval($courseId); |
|
2304 | + $courseId = empty($courseId) ? api_get_course_int_id() : intval($courseId); |
|
2305 | 2305 | $forum_id = intval($forum_id); |
2306 | 2306 | |
2307 | 2307 | $sql = "SELECT * |
@@ -2742,11 +2742,11 @@ discard block |
||
2742 | 2742 | $form = new FormValidator( |
2743 | 2743 | 'thread', |
2744 | 2744 | 'post', |
2745 | - api_get_self() . '?' . http_build_query([ |
|
2745 | + api_get_self().'?'.http_build_query([ |
|
2746 | 2746 | 'forum' => $myForum, |
2747 | 2747 | 'gradebook' => $myGradebook, |
2748 | 2748 | 'thread' => $myThread, |
2749 | - ]) . '&' . api_get_cidreq() |
|
2749 | + ]).'&'.api_get_cidreq() |
|
2750 | 2750 | ); |
2751 | 2751 | |
2752 | 2752 | $form->addElement('header', get_lang('EditThread')); |
@@ -2809,7 +2809,7 @@ discard block |
||
2809 | 2809 | $form->addElement('html', '</div>'); |
2810 | 2810 | |
2811 | 2811 | if (!empty($formValues)) { |
2812 | - $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0 ; |
|
2812 | + $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0; |
|
2813 | 2813 | $defaults['thread_title'] = prepare4display($formValues['threadTitle']); |
2814 | 2814 | $defaults['thread_sticky'] = strval(intval($formValues['threadSticky'])); |
2815 | 2815 | $defaults['thread_peer_qualify'] = intval($formValues['threadPeerQualify']); |
@@ -2877,13 +2877,13 @@ discard block |
||
2877 | 2877 | $my_post = isset($_GET['post']) ? (int) $_GET['post'] : ''; |
2878 | 2878 | $my_gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : ''; |
2879 | 2879 | |
2880 | - $url = api_get_self() . '?' . http_build_query([ |
|
2880 | + $url = api_get_self().'?'.http_build_query([ |
|
2881 | 2881 | 'action' => $action, |
2882 | 2882 | 'forum' => $forumId, |
2883 | 2883 | 'gradebook' => $my_gradebook, |
2884 | 2884 | 'thread' => $myThread, |
2885 | 2885 | 'post' => $my_post |
2886 | - ]) . '&' . api_get_cidreq(); |
|
2886 | + ]).'&'.api_get_cidreq(); |
|
2887 | 2887 | |
2888 | 2888 | $form = new FormValidator( |
2889 | 2889 | 'thread', |
@@ -3180,7 +3180,7 @@ discard block |
||
3180 | 3180 | |
3181 | 3181 | if ($row[0] == 0) { |
3182 | 3182 | $sql = "INSERT INTO $table_threads_qualify (c_id, user_id, thread_id,qualify,qualify_user_id,qualify_time,session_id) |
3183 | - VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float)$thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')"; |
|
3183 | + VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')"; |
|
3184 | 3184 | Database::query($sql); |
3185 | 3185 | |
3186 | 3186 | $insertId = Database::insert_id(); |
@@ -4772,9 +4772,9 @@ discard block |
||
4772 | 4772 | continue; |
4773 | 4773 | } |
4774 | 4774 | |
4775 | - $course_dir = $_course['path'] . '/upload/forum'; |
|
4775 | + $course_dir = $_course['path'].'/upload/forum'; |
|
4776 | 4776 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
4777 | - $updir = $sys_course_path . $course_dir; |
|
4777 | + $updir = $sys_course_path.$course_dir; |
|
4778 | 4778 | |
4779 | 4779 | // Try to add an extension to the file if it hasn't one. |
4780 | 4780 | $new_file_name = add_ext_on_mime( |
@@ -4791,7 +4791,7 @@ discard block |
||
4791 | 4791 | } |
4792 | 4792 | |
4793 | 4793 | $new_file_name = uniqid(''); |
4794 | - $new_path = $updir . '/' . $new_file_name; |
|
4794 | + $new_path = $updir.'/'.$new_file_name; |
|
4795 | 4795 | $result = @move_uploaded_file($attachment['tmp_name'], $new_path); |
4796 | 4796 | $safe_file_comment = Database::escape_string($file_comment); |
4797 | 4797 | $safe_file_name = Database::escape_string($file_name); |
@@ -4957,16 +4957,16 @@ discard block |
||
4957 | 4957 | $forum_table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT); |
4958 | 4958 | $course_id = api_get_course_int_id(); |
4959 | 4959 | |
4960 | - $cond = (!empty($id_attach)) ? " iid = " . (int) $id_attach . "" : " post_id = " . (int) $post_id . ""; |
|
4960 | + $cond = (!empty($id_attach)) ? " iid = ".(int) $id_attach."" : " post_id = ".(int) $post_id.""; |
|
4961 | 4961 | $sql = "SELECT path FROM $forum_table_attachment WHERE c_id = $course_id AND $cond"; |
4962 | 4962 | $res = Database::query($sql); |
4963 | 4963 | $row = Database::fetch_array($res); |
4964 | 4964 | |
4965 | - $course_dir = $_course['path'] . '/upload/forum'; |
|
4965 | + $course_dir = $_course['path'].'/upload/forum'; |
|
4966 | 4966 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
4967 | - $updir = $sys_course_path . $course_dir; |
|
4967 | + $updir = $sys_course_path.$course_dir; |
|
4968 | 4968 | $my_path = isset($row['path']) ? $row['path'] : null; |
4969 | - $file = $updir . '/' . $my_path; |
|
4969 | + $file = $updir.'/'.$my_path; |
|
4970 | 4970 | if (Security::check_abs_path($file, $updir)) { |
4971 | 4971 | @unlink($file); |
4972 | 4972 | } |
@@ -5520,37 +5520,37 @@ discard block |
||
5520 | 5520 | $post_list = get_thread_user_post_limit($course_code, $thread['thread_id'], $user_id, 1); |
5521 | 5521 | $post_counter = count($post_list); |
5522 | 5522 | if (is_array($post_list) && count($post_list) > 0) { |
5523 | - $hand_forums.= '<div id="social-thread">'; |
|
5524 | - $hand_forums.= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM); |
|
5525 | - $hand_forums.= ' '.Security::remove_XSS($thread['thread_title'], STUDENT); |
|
5526 | - $hand_forums.= '</div>'; |
|
5523 | + $hand_forums .= '<div id="social-thread">'; |
|
5524 | + $hand_forums .= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM); |
|
5525 | + $hand_forums .= ' '.Security::remove_XSS($thread['thread_title'], STUDENT); |
|
5526 | + $hand_forums .= '</div>'; |
|
5527 | 5527 | |
5528 | 5528 | foreach ($post_list as $posts) { |
5529 | - $hand_forums.= '<div id="social-post">'; |
|
5530 | - $hand_forums.= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>'; |
|
5531 | - $hand_forums.= '<br / >'; |
|
5532 | - $hand_forums.= Security::remove_XSS($posts['post_text'], STUDENT); |
|
5533 | - $hand_forums.= '</div>'; |
|
5534 | - $hand_forums.= '<br / >'; |
|
5529 | + $hand_forums .= '<div id="social-post">'; |
|
5530 | + $hand_forums .= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>'; |
|
5531 | + $hand_forums .= '<br / >'; |
|
5532 | + $hand_forums .= Security::remove_XSS($posts['post_text'], STUDENT); |
|
5533 | + $hand_forums .= '</div>'; |
|
5534 | + $hand_forums .= '<br / >'; |
|
5535 | 5535 | } |
5536 | 5536 | } |
5537 | 5537 | } |
5538 | 5538 | $i++; |
5539 | 5539 | } |
5540 | - $forum_results .='<div id="social-forum">'; |
|
5541 | - $forum_results .='<div class="clear"></div><br />'; |
|
5542 | - $forum_results .='<div id="social-forum-title">'. |
|
5540 | + $forum_results .= '<div id="social-forum">'; |
|
5541 | + $forum_results .= '<div class="clear"></div><br />'; |
|
5542 | + $forum_results .= '<div id="social-forum-title">'. |
|
5543 | 5543 | Display::return_icon('forum.gif', get_lang('Forum')).' '.Security::remove_XSS($forum['forum_title'], STUDENT). |
5544 | 5544 | '<div style="float:right;margin-top:-35px"> |
5545 | 5545 | <a href="../forum/viewforum.php?'.api_get_cidreq_params($course_code).'&forum='.$forum['forum_id'].' " >'. |
5546 | 5546 | get_lang('SeeForum').' |
5547 | 5547 | </a> |
5548 | 5548 | </div></div>'; |
5549 | - $forum_results .='<br / >'; |
|
5549 | + $forum_results .= '<br / >'; |
|
5550 | 5550 | if ($post_counter > 0) { |
5551 | - $forum_results .=$hand_forums; |
|
5551 | + $forum_results .= $hand_forums; |
|
5552 | 5552 | } |
5553 | - $forum_results .='</div>'; |
|
5553 | + $forum_results .= '</div>'; |
|
5554 | 5554 | }$j++; |
5555 | 5555 | } |
5556 | 5556 | } |
@@ -5691,16 +5691,16 @@ discard block |
||
5691 | 5691 | $courseId = intval($courseId); |
5692 | 5692 | if (empty($courseId)) { |
5693 | 5693 | // $courseId can be null, use api method |
5694 | - $courseId= api_get_course_int_id(); |
|
5694 | + $courseId = api_get_course_int_id(); |
|
5695 | 5695 | } |
5696 | 5696 | /* |
5697 | 5697 | * Check if Attachment ID and Course ID are greater than zero |
5698 | 5698 | * and array of field values is not empty |
5699 | 5699 | */ |
5700 | 5700 | if ($id > 0 && $courseId > 0 && !empty($array) && is_array($array)) { |
5701 | - foreach($array as $key => &$item) { |
|
5701 | + foreach ($array as $key => &$item) { |
|
5702 | 5702 | $item = Database::escape_string($item); |
5703 | - $setString .= $key . ' = "' .$item . '", '; |
|
5703 | + $setString .= $key.' = "'.$item.'", '; |
|
5704 | 5704 | } |
5705 | 5705 | // Delete last comma |
5706 | 5706 | $setString = substr($setString, 0, strlen($setString) - 2); |
@@ -5760,10 +5760,10 @@ discard block |
||
5760 | 5760 | foreach ($uploadedFiles as $k => $uploadedFile) { |
5761 | 5761 | if (!empty($uploadedFile) && in_array($uploadedFile['id'], $attachIds)) { |
5762 | 5762 | // Buil html table including an input with attachmentID |
5763 | - $fileDataContent .= '<tr id="' . $uploadedFile['id'] . '" ><td>' . $uploadedFile['name'] . '</td><td>' . $uploadedFile['size'] . '</td><td> ' . $uploadedFile['result'] . |
|
5764 | - ' </td><td> <input style="width:90%;" type="text" value="' . $uploadedFile['comment'] . '" name="file_comments[]"> </td><td>' . |
|
5765 | - $uploadedFile['delete'] . '</td>' . |
|
5766 | - '<input type="hidden" value="' . $uploadedFile['id'] .'" name="file_ids[]">' . '</tr>'; |
|
5763 | + $fileDataContent .= '<tr id="'.$uploadedFile['id'].'" ><td>'.$uploadedFile['name'].'</td><td>'.$uploadedFile['size'].'</td><td> '.$uploadedFile['result']. |
|
5764 | + ' </td><td> <input style="width:90%;" type="text" value="'.$uploadedFile['comment'].'" name="file_comments[]"> </td><td>'. |
|
5765 | + $uploadedFile['delete'].'</td>'. |
|
5766 | + '<input type="hidden" value="'.$uploadedFile['id'].'" name="file_ids[]">'.'</tr>'; |
|
5767 | 5767 | } else { |
5768 | 5768 | /* |
5769 | 5769 | * If attachment data is empty, then delete it from $_SESSION |
@@ -5776,7 +5776,7 @@ discard block |
||
5776 | 5776 | $style = empty($fileDataContent) ? 'display: none;' : ''; |
5777 | 5777 | // Forum attachment Ajax table |
5778 | 5778 | $fileData = ' |
5779 | - <div class="control-group " style="'. $style . '"> |
|
5779 | + <div class="control-group " style="'. $style.'"> |
|
5780 | 5780 | <label class="control-label">'.get_lang('AttachmentList').'</label> |
5781 | 5781 | <div class="controls"> |
5782 | 5782 | <table id="attachmentFileList" class="files data_table span10"> |
@@ -5848,7 +5848,7 @@ discard block |
||
5848 | 5848 | // name contains an URL to download attachment file and its filename |
5849 | 5849 | $json['name'] = Display::url( |
5850 | 5850 | api_htmlentities($row['filename']), |
5851 | - api_get_path(WEB_CODE_PATH) . 'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(), |
|
5851 | + api_get_path(WEB_CODE_PATH).'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(), |
|
5852 | 5852 | array('target'=>'_blank', 'class' => 'attachFilename') |
5853 | 5853 | ); |
5854 | 5854 | $json['id'] = $row['iid']; |
@@ -5859,9 +5859,9 @@ discard block |
||
5859 | 5859 | if (!empty($row) && is_array($row)) { |
5860 | 5860 | // Set result as success and bring delete URL |
5861 | 5861 | $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded')); |
5862 | - $url = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&action=delete_attach&forum=' . $forumId . '&thread=' . $threadId.'&id_attach=' . $row['iid']; |
|
5862 | + $url = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&action=delete_attach&forum='.$forumId.'&thread='.$threadId.'&id_attach='.$row['iid']; |
|
5863 | 5863 | $json['delete'] = Display::url( |
5864 | - Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL), |
|
5864 | + Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), |
|
5865 | 5865 | $url, |
5866 | 5866 | array('class' => 'deleteLink') |
5867 | 5867 | ); |
@@ -5950,7 +5950,7 @@ discard block |
||
5950 | 5950 | WHERE c_id = $courseId AND post_id = $postId"; |
5951 | 5951 | $result = Database::query($sql); |
5952 | 5952 | if ($result !== false && Database::num_rows($result) > 0) { |
5953 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
5953 | + while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
5954 | 5954 | $array[] = $row['id']; |
5955 | 5955 | } |
5956 | 5956 | } |
@@ -29,11 +29,11 @@ |
||
29 | 29 | krsort($langs, SORT_NUMERIC); |
30 | 30 | // Choosing the best match |
31 | 31 | foreach($langs as $weight => $codes) { |
32 | - foreach ($codes as $code) { |
|
33 | - if (in_array($code, $available_langs)) { |
|
34 | - return $code; |
|
35 | - } |
|
36 | - } |
|
32 | + foreach ($codes as $code) { |
|
33 | + if (in_array($code, $available_langs)) { |
|
34 | + return $code; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | // No match |
39 | 39 | return null; |
@@ -28,7 +28,7 @@ |
||
28 | 28 | } |
29 | 29 | krsort($langs, SORT_NUMERIC); |
30 | 30 | // Choosing the best match |
31 | - foreach($langs as $weight => $codes) { |
|
31 | + foreach ($langs as $weight => $codes) { |
|
32 | 32 | foreach ($codes as $code) { |
33 | 33 | if (in_array($code, $available_langs)) { |
34 | 34 | return $code; |
@@ -52,7 +52,7 @@ |
||
52 | 52 | * @param string $encoding character encoding scheme of message |
53 | 53 | * @param string $method method for which XML is parsed (unused?) |
54 | 54 | * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
55 | - * @return void|bool |
|
55 | + * @return false|null |
|
56 | 56 | * @access public |
57 | 57 | */ |
58 | 58 | function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
@@ -11,236 +11,236 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class nusoap_parser extends nusoap_base |
13 | 13 | { |
14 | - var $xml = ''; |
|
15 | - var $xml_encoding = ''; |
|
16 | - var $method = ''; |
|
17 | - var $root_struct = ''; |
|
18 | - var $root_struct_name = ''; |
|
19 | - var $root_struct_namespace = ''; |
|
20 | - var $root_header = ''; |
|
14 | + var $xml = ''; |
|
15 | + var $xml_encoding = ''; |
|
16 | + var $method = ''; |
|
17 | + var $root_struct = ''; |
|
18 | + var $root_struct_name = ''; |
|
19 | + var $root_struct_namespace = ''; |
|
20 | + var $root_header = ''; |
|
21 | 21 | var $document = ''; // incoming SOAP body (text) |
22 | - // determines where in the message we are (envelope,header,body,method) |
|
23 | - var $status = ''; |
|
24 | - var $position = 0; |
|
25 | - var $depth = 0; |
|
26 | - var $default_namespace = ''; |
|
27 | - var $namespaces = array(); |
|
28 | - var $message = array(); |
|
22 | + // determines where in the message we are (envelope,header,body,method) |
|
23 | + var $status = ''; |
|
24 | + var $position = 0; |
|
25 | + var $depth = 0; |
|
26 | + var $default_namespace = ''; |
|
27 | + var $namespaces = array(); |
|
28 | + var $message = array(); |
|
29 | 29 | var $parent; |
30 | - var $fault = false; |
|
31 | - var $fault_code = ''; |
|
32 | - var $fault_str = ''; |
|
33 | - var $fault_detail = ''; |
|
34 | - var $depth_array = array(); |
|
35 | - var $debug_flag = true; |
|
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | - var $body_position = 0; |
|
40 | - // for multiref parsing: |
|
41 | - // array of id => pos |
|
42 | - var $ids = array(); |
|
43 | - // array of id => hrefs => pos |
|
44 | - var $multirefs = array(); |
|
45 | - // toggle for auto-decoding element content |
|
46 | - var $decode_utf8 = true; |
|
30 | + var $fault = false; |
|
31 | + var $fault_code = ''; |
|
32 | + var $fault_str = ''; |
|
33 | + var $fault_detail = ''; |
|
34 | + var $depth_array = array(); |
|
35 | + var $debug_flag = true; |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | + var $body_position = 0; |
|
40 | + // for multiref parsing: |
|
41 | + // array of id => pos |
|
42 | + var $ids = array(); |
|
43 | + // array of id => hrefs => pos |
|
44 | + var $multirefs = array(); |
|
45 | + // toggle for auto-decoding element content |
|
46 | + var $decode_utf8 = true; |
|
47 | 47 | |
48 | - /** |
|
49 | - * constructor that actually does the parsing |
|
50 | - * |
|
51 | - * @param string $xml SOAP message |
|
52 | - * @param string $encoding character encoding scheme of message |
|
53 | - * @param string $method method for which XML is parsed (unused?) |
|
54 | - * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | - * @return void|bool |
|
56 | - * @access public |
|
57 | - */ |
|
58 | - function __construct($xml,$encoding='UTF-8',$method='',$decode_utf8=true) |
|
48 | + /** |
|
49 | + * constructor that actually does the parsing |
|
50 | + * |
|
51 | + * @param string $xml SOAP message |
|
52 | + * @param string $encoding character encoding scheme of message |
|
53 | + * @param string $method method for which XML is parsed (unused?) |
|
54 | + * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | + * @return void|bool |
|
56 | + * @access public |
|
57 | + */ |
|
58 | + function __construct($xml,$encoding='UTF-8',$method='',$decode_utf8=true) |
|
59 | 59 | { |
60 | - parent::__construct(); |
|
61 | - $this->xml = $xml; |
|
62 | - $this->xml_encoding = $encoding; |
|
63 | - $this->method = $method; |
|
64 | - $this->decode_utf8 = $decode_utf8; |
|
60 | + parent::__construct(); |
|
61 | + $this->xml = $xml; |
|
62 | + $this->xml_encoding = $encoding; |
|
63 | + $this->method = $method; |
|
64 | + $this->decode_utf8 = $decode_utf8; |
|
65 | 65 | |
66 | - // Check whether content has been read. |
|
67 | - if(!empty($this->xml)){ |
|
68 | - // Check XML encoding |
|
69 | - $pos_xml = strpos($xml, '<?xml'); |
|
70 | - if ($pos_xml !== FALSE) { |
|
71 | - $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
72 | - if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
73 | - $xml_encoding = $res[1]; |
|
74 | - if (strtoupper($xml_encoding) != $encoding) { |
|
75 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
76 | - $this->debug($err); |
|
77 | - if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
78 | - $this->setError($err); |
|
79 | - return false; |
|
80 | - } |
|
81 | - // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
82 | - } else { |
|
83 | - $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
84 | - } |
|
85 | - } else { |
|
86 | - $this->debug('No encoding specified in XML declaration'); |
|
87 | - } |
|
88 | - } else { |
|
89 | - $this->debug('No XML declaration'); |
|
90 | - } |
|
91 | - $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
92 | - // Create an XML parser - why not xml_parser_create_ns? |
|
93 | - $this->parser = xml_parser_create($this->xml_encoding); |
|
94 | - // Set the options for parsing the XML data. |
|
95 | - //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
96 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
97 | - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
98 | - // Set the object for the parser. |
|
99 | - xml_set_object($this->parser, $this); |
|
100 | - // Set the element handlers for the parser. |
|
101 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
102 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
66 | + // Check whether content has been read. |
|
67 | + if(!empty($this->xml)){ |
|
68 | + // Check XML encoding |
|
69 | + $pos_xml = strpos($xml, '<?xml'); |
|
70 | + if ($pos_xml !== FALSE) { |
|
71 | + $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
72 | + if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
73 | + $xml_encoding = $res[1]; |
|
74 | + if (strtoupper($xml_encoding) != $encoding) { |
|
75 | + $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
76 | + $this->debug($err); |
|
77 | + if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
78 | + $this->setError($err); |
|
79 | + return false; |
|
80 | + } |
|
81 | + // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
82 | + } else { |
|
83 | + $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
84 | + } |
|
85 | + } else { |
|
86 | + $this->debug('No encoding specified in XML declaration'); |
|
87 | + } |
|
88 | + } else { |
|
89 | + $this->debug('No XML declaration'); |
|
90 | + } |
|
91 | + $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
92 | + // Create an XML parser - why not xml_parser_create_ns? |
|
93 | + $this->parser = xml_parser_create($this->xml_encoding); |
|
94 | + // Set the options for parsing the XML data. |
|
95 | + //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
96 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
97 | + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
98 | + // Set the object for the parser. |
|
99 | + xml_set_object($this->parser, $this); |
|
100 | + // Set the element handlers for the parser. |
|
101 | + xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
102 | + xml_set_character_data_handler($this->parser,'character_data'); |
|
103 | 103 | |
104 | - xml_parse($this->parser, $this->xml); |
|
104 | + xml_parse($this->parser, $this->xml); |
|
105 | 105 | |
106 | - // Parse the XML file. |
|
107 | - //if (!xml_parse($this->parser,$xml,true)){ |
|
108 | - if (false) { |
|
109 | - // Display an error message. |
|
110 | - $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
111 | - xml_get_current_line_number($this->parser), |
|
112 | - xml_error_string(xml_get_error_code($this->parser))); |
|
113 | - $this->debug($err); |
|
114 | - $this->debug("XML payload:\n" . $xml); |
|
115 | - $this->setError($err); |
|
116 | - } else { |
|
117 | - $this->debug('in nusoap_parser ctor, message:'); |
|
118 | - $this->appendDebug($this->varDump($this->message)); |
|
119 | - $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
120 | - // get final value |
|
121 | - $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
122 | - // get header value |
|
123 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
124 | - $this->soapheader = $this->message[$this->root_header]['result']; |
|
125 | - } |
|
126 | - // resolve hrefs/ids |
|
127 | - if(sizeof($this->multirefs) > 0){ |
|
128 | - foreach($this->multirefs as $id => $hrefs){ |
|
129 | - $this->debug('resolving multirefs for id: '.$id); |
|
130 | - $idVal = $this->buildVal($this->ids[$id]); |
|
131 | - if (is_array($idVal) && isset($idVal['!id'])) { |
|
132 | - unset($idVal['!id']); |
|
133 | - } |
|
134 | - foreach($hrefs as $refPos => $ref){ |
|
135 | - $this->debug('resolving href at pos '.$refPos); |
|
136 | - $this->multirefs[$id][$refPos] = $idVal; |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
140 | - } |
|
141 | - xml_parser_free($this->parser); |
|
142 | - } else { |
|
143 | - $this->debug('xml was empty, didn\'t parse!'); |
|
144 | - $this->setError('xml was empty, didn\'t parse!'); |
|
145 | - } |
|
146 | - } |
|
106 | + // Parse the XML file. |
|
107 | + //if (!xml_parse($this->parser,$xml,true)){ |
|
108 | + if (false) { |
|
109 | + // Display an error message. |
|
110 | + $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
111 | + xml_get_current_line_number($this->parser), |
|
112 | + xml_error_string(xml_get_error_code($this->parser))); |
|
113 | + $this->debug($err); |
|
114 | + $this->debug("XML payload:\n" . $xml); |
|
115 | + $this->setError($err); |
|
116 | + } else { |
|
117 | + $this->debug('in nusoap_parser ctor, message:'); |
|
118 | + $this->appendDebug($this->varDump($this->message)); |
|
119 | + $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
120 | + // get final value |
|
121 | + $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
122 | + // get header value |
|
123 | + if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
124 | + $this->soapheader = $this->message[$this->root_header]['result']; |
|
125 | + } |
|
126 | + // resolve hrefs/ids |
|
127 | + if(sizeof($this->multirefs) > 0){ |
|
128 | + foreach($this->multirefs as $id => $hrefs){ |
|
129 | + $this->debug('resolving multirefs for id: '.$id); |
|
130 | + $idVal = $this->buildVal($this->ids[$id]); |
|
131 | + if (is_array($idVal) && isset($idVal['!id'])) { |
|
132 | + unset($idVal['!id']); |
|
133 | + } |
|
134 | + foreach($hrefs as $refPos => $ref){ |
|
135 | + $this->debug('resolving href at pos '.$refPos); |
|
136 | + $this->multirefs[$id][$refPos] = $idVal; |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | + } |
|
141 | + xml_parser_free($this->parser); |
|
142 | + } else { |
|
143 | + $this->debug('xml was empty, didn\'t parse!'); |
|
144 | + $this->setError('xml was empty, didn\'t parse!'); |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * start-element handler |
|
150 | - * |
|
151 | - * @param resource $parser XML parser object |
|
152 | - * @param string $name element name |
|
153 | - * @param array $attrs associative array of attributes |
|
154 | - * @access private |
|
155 | - */ |
|
156 | - function start_element($parser, $name, $attrs) { |
|
148 | + /** |
|
149 | + * start-element handler |
|
150 | + * |
|
151 | + * @param resource $parser XML parser object |
|
152 | + * @param string $name element name |
|
153 | + * @param array $attrs associative array of attributes |
|
154 | + * @access private |
|
155 | + */ |
|
156 | + function start_element($parser, $name, $attrs) { |
|
157 | 157 | |
158 | - // position in a total number of elements, starting from 0 |
|
159 | - // update class level pos |
|
160 | - $pos = $this->position++; |
|
161 | - // and set mine |
|
162 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
163 | - // depth = how many levels removed from root? |
|
164 | - // set mine as current global depth and increment global depth value |
|
165 | - $this->message[$pos]['depth'] = $this->depth++; |
|
158 | + // position in a total number of elements, starting from 0 |
|
159 | + // update class level pos |
|
160 | + $pos = $this->position++; |
|
161 | + // and set mine |
|
162 | + $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
163 | + // depth = how many levels removed from root? |
|
164 | + // set mine as current global depth and increment global depth value |
|
165 | + $this->message[$pos]['depth'] = $this->depth++; |
|
166 | 166 | |
167 | - // else add self as child to whoever the current parent is |
|
168 | - if($pos != 0){ |
|
169 | - $this->message[$this->parent]['children'] .= '|'.$pos; |
|
170 | - } |
|
171 | - // set my parent |
|
172 | - $this->message[$pos]['parent'] = $this->parent; |
|
173 | - // set self as current parent |
|
174 | - $this->parent = $pos; |
|
175 | - // set self as current value for this depth |
|
176 | - $this->depth_array[$this->depth] = $pos; |
|
177 | - // get element prefix |
|
178 | - if(strpos($name,':')){ |
|
179 | - // get ns prefix |
|
180 | - $prefix = substr($name,0,strpos($name,':')); |
|
181 | - // get unqualified name |
|
182 | - $name = substr(strstr($name,':'),1); |
|
183 | - } |
|
184 | - // set status |
|
185 | - if ($name == 'Envelope' && $this->status == '') { |
|
186 | - $this->status = 'envelope'; |
|
187 | - } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
188 | - $this->root_header = $pos; |
|
189 | - $this->status = 'header'; |
|
190 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
191 | - $this->status = 'body'; |
|
192 | - $this->body_position = $pos; |
|
193 | - // set method |
|
194 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
195 | - $this->status = 'method'; |
|
196 | - $this->root_struct_name = $name; |
|
197 | - $this->root_struct = $pos; |
|
198 | - $this->message[$pos]['type'] = 'struct'; |
|
199 | - $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
200 | - } |
|
201 | - // set my status |
|
202 | - $this->message[$pos]['status'] = $this->status; |
|
203 | - // set name |
|
204 | - $this->message[$pos]['name'] = htmlspecialchars($name); |
|
205 | - // set attrs |
|
206 | - $this->message[$pos]['attrs'] = $attrs; |
|
167 | + // else add self as child to whoever the current parent is |
|
168 | + if($pos != 0){ |
|
169 | + $this->message[$this->parent]['children'] .= '|'.$pos; |
|
170 | + } |
|
171 | + // set my parent |
|
172 | + $this->message[$pos]['parent'] = $this->parent; |
|
173 | + // set self as current parent |
|
174 | + $this->parent = $pos; |
|
175 | + // set self as current value for this depth |
|
176 | + $this->depth_array[$this->depth] = $pos; |
|
177 | + // get element prefix |
|
178 | + if(strpos($name,':')){ |
|
179 | + // get ns prefix |
|
180 | + $prefix = substr($name,0,strpos($name,':')); |
|
181 | + // get unqualified name |
|
182 | + $name = substr(strstr($name,':'),1); |
|
183 | + } |
|
184 | + // set status |
|
185 | + if ($name == 'Envelope' && $this->status == '') { |
|
186 | + $this->status = 'envelope'; |
|
187 | + } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
188 | + $this->root_header = $pos; |
|
189 | + $this->status = 'header'; |
|
190 | + } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
191 | + $this->status = 'body'; |
|
192 | + $this->body_position = $pos; |
|
193 | + // set method |
|
194 | + } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
195 | + $this->status = 'method'; |
|
196 | + $this->root_struct_name = $name; |
|
197 | + $this->root_struct = $pos; |
|
198 | + $this->message[$pos]['type'] = 'struct'; |
|
199 | + $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
200 | + } |
|
201 | + // set my status |
|
202 | + $this->message[$pos]['status'] = $this->status; |
|
203 | + // set name |
|
204 | + $this->message[$pos]['name'] = htmlspecialchars($name); |
|
205 | + // set attrs |
|
206 | + $this->message[$pos]['attrs'] = $attrs; |
|
207 | 207 | |
208 | - // loop through atts, logging ns and type declarations |
|
208 | + // loop through atts, logging ns and type declarations |
|
209 | 209 | $attstr = ''; |
210 | - foreach($attrs as $key => $value){ |
|
211 | - $key_prefix = $this->getPrefix($key); |
|
212 | - $key_localpart = $this->getLocalPart($key); |
|
213 | - // if ns declarations, add to class level array of valid namespaces |
|
210 | + foreach($attrs as $key => $value){ |
|
211 | + $key_prefix = $this->getPrefix($key); |
|
212 | + $key_localpart = $this->getLocalPart($key); |
|
213 | + // if ns declarations, add to class level array of valid namespaces |
|
214 | 214 | if($key_prefix == 'xmlns'){ |
215 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
216 | - $this->XMLSchemaVersion = $value; |
|
217 | - $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
218 | - $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
219 | - } |
|
215 | + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
216 | + $this->XMLSchemaVersion = $value; |
|
217 | + $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
218 | + $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
219 | + } |
|
220 | 220 | $this->namespaces[$key_localpart] = $value; |
221 | - // set method namespace |
|
222 | - if($name == $this->root_struct_name){ |
|
223 | - $this->methodNamespace = $value; |
|
224 | - } |
|
225 | - // if it's a type declaration, set type |
|
221 | + // set method namespace |
|
222 | + if($name == $this->root_struct_name){ |
|
223 | + $this->methodNamespace = $value; |
|
224 | + } |
|
225 | + // if it's a type declaration, set type |
|
226 | 226 | } elseif($key_localpart == 'type'){ |
227 | - if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
228 | - // do nothing: already processed arrayType |
|
229 | - } else { |
|
230 | - $value_prefix = $this->getPrefix($value); |
|
231 | - $value_localpart = $this->getLocalPart($value); |
|
232 | - $this->message[$pos]['type'] = $value_localpart; |
|
233 | - $this->message[$pos]['typePrefix'] = $value_prefix; |
|
234 | - if(isset($this->namespaces[$value_prefix])){ |
|
235 | - $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
236 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
237 | - $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
238 | - } |
|
239 | - // should do something here with the namespace of specified type? |
|
240 | - } |
|
241 | - } elseif($key_localpart == 'arrayType'){ |
|
242 | - $this->message[$pos]['type'] = 'array'; |
|
243 | - /* do arrayType ereg here |
|
227 | + if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
228 | + // do nothing: already processed arrayType |
|
229 | + } else { |
|
230 | + $value_prefix = $this->getPrefix($value); |
|
231 | + $value_localpart = $this->getLocalPart($value); |
|
232 | + $this->message[$pos]['type'] = $value_localpart; |
|
233 | + $this->message[$pos]['typePrefix'] = $value_prefix; |
|
234 | + if(isset($this->namespaces[$value_prefix])){ |
|
235 | + $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
236 | + } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
237 | + $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
238 | + } |
|
239 | + // should do something here with the namespace of specified type? |
|
240 | + } |
|
241 | + } elseif($key_localpart == 'arrayType'){ |
|
242 | + $this->message[$pos]['type'] = 'array'; |
|
243 | + /* do arrayType ereg here |
|
244 | 244 | [1] arrayTypeValue ::= atype asize |
245 | 245 | [2] atype ::= QName rank* |
246 | 246 | [3] rank ::= '[' (',')* ']' |
@@ -248,129 +248,129 @@ discard block |
||
248 | 248 | [5] length ::= nextDimension* Digit+ |
249 | 249 | [6] nextDimension ::= Digit+ ',' |
250 | 250 | */ |
251 | - $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
252 | - if(preg_match($expr,$value,$regs)){ |
|
253 | - $this->message[$pos]['typePrefix'] = $regs[1]; |
|
254 | - $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
255 | - if (isset($this->namespaces[$regs[1]])) { |
|
256 | - $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
257 | - } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
258 | - $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
259 | - } |
|
260 | - $this->message[$pos]['arrayType'] = $regs[2]; |
|
261 | - $this->message[$pos]['arraySize'] = $regs[3]; |
|
262 | - $this->message[$pos]['arrayCols'] = $regs[4]; |
|
263 | - } |
|
264 | - // specifies nil value (or not) |
|
265 | - } elseif ($key_localpart == 'nil'){ |
|
266 | - $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
267 | - // some other attribute |
|
268 | - } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
269 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
270 | - } |
|
251 | + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
252 | + if(preg_match($expr,$value,$regs)){ |
|
253 | + $this->message[$pos]['typePrefix'] = $regs[1]; |
|
254 | + $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
255 | + if (isset($this->namespaces[$regs[1]])) { |
|
256 | + $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
257 | + } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
258 | + $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
259 | + } |
|
260 | + $this->message[$pos]['arrayType'] = $regs[2]; |
|
261 | + $this->message[$pos]['arraySize'] = $regs[3]; |
|
262 | + $this->message[$pos]['arrayCols'] = $regs[4]; |
|
263 | + } |
|
264 | + // specifies nil value (or not) |
|
265 | + } elseif ($key_localpart == 'nil'){ |
|
266 | + $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
267 | + // some other attribute |
|
268 | + } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
269 | + $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
270 | + } |
|
271 | 271 | |
272 | - if ($key == 'xmlns') { |
|
273 | - $this->default_namespace = $value; |
|
274 | - } |
|
275 | - // log id |
|
276 | - if($key == 'id'){ |
|
277 | - $this->ids[$value] = $pos; |
|
278 | - } |
|
279 | - // root |
|
280 | - if($key_localpart == 'root' && $value == 1){ |
|
281 | - $this->status = 'method'; |
|
282 | - $this->root_struct_name = $name; |
|
283 | - $this->root_struct = $pos; |
|
284 | - $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
285 | - } |
|
272 | + if ($key == 'xmlns') { |
|
273 | + $this->default_namespace = $value; |
|
274 | + } |
|
275 | + // log id |
|
276 | + if($key == 'id'){ |
|
277 | + $this->ids[$value] = $pos; |
|
278 | + } |
|
279 | + // root |
|
280 | + if($key_localpart == 'root' && $value == 1){ |
|
281 | + $this->status = 'method'; |
|
282 | + $this->root_struct_name = $name; |
|
283 | + $this->root_struct = $pos; |
|
284 | + $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
285 | + } |
|
286 | 286 | // for doclit |
287 | 287 | $attstr .= " $key=\"$value\""; |
288 | - } |
|
288 | + } |
|
289 | 289 | // get namespace - must be done after namespace atts are processed |
290 | - if(isset($prefix)){ |
|
291 | - $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
292 | - $this->default_namespace = $this->namespaces[$prefix]; |
|
293 | - } else { |
|
294 | - $this->message[$pos]['namespace'] = $this->default_namespace; |
|
295 | - } |
|
290 | + if(isset($prefix)){ |
|
291 | + $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
292 | + $this->default_namespace = $this->namespaces[$prefix]; |
|
293 | + } else { |
|
294 | + $this->message[$pos]['namespace'] = $this->default_namespace; |
|
295 | + } |
|
296 | 296 | if($this->status == 'header'){ |
297 | - if ($this->root_header != $pos) { |
|
298 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
299 | - } |
|
297 | + if ($this->root_header != $pos) { |
|
298 | + $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
299 | + } |
|
300 | 300 | } elseif($this->root_struct_name != ''){ |
301 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
301 | + $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
302 | 302 | } |
303 | - } |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * end-element handler |
|
307 | - * |
|
308 | - * @param resource $parser XML parser object |
|
309 | - * @param string $name element name |
|
310 | - * @access private |
|
311 | - */ |
|
312 | - function end_element($parser, $name) { |
|
313 | - // position of current element is equal to the last value left in depth_array for my depth |
|
314 | - $pos = $this->depth_array[$this->depth--]; |
|
305 | + /** |
|
306 | + * end-element handler |
|
307 | + * |
|
308 | + * @param resource $parser XML parser object |
|
309 | + * @param string $name element name |
|
310 | + * @access private |
|
311 | + */ |
|
312 | + function end_element($parser, $name) { |
|
313 | + // position of current element is equal to the last value left in depth_array for my depth |
|
314 | + $pos = $this->depth_array[$this->depth--]; |
|
315 | 315 | |
316 | 316 | // get element prefix |
317 | - if(strpos($name,':')){ |
|
318 | - // get ns prefix |
|
319 | - $prefix = substr($name,0,strpos($name,':')); |
|
320 | - // get unqualified name |
|
321 | - $name = substr(strstr($name,':'),1); |
|
322 | - } |
|
317 | + if(strpos($name,':')){ |
|
318 | + // get ns prefix |
|
319 | + $prefix = substr($name,0,strpos($name,':')); |
|
320 | + // get unqualified name |
|
321 | + $name = substr(strstr($name,':'),1); |
|
322 | + } |
|
323 | 323 | |
324 | - // build to native type |
|
325 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
326 | - // deal w/ multirefs |
|
327 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
328 | - // get id |
|
329 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
330 | - // add placeholder to href array |
|
331 | - $this->multirefs[$id][$pos] = 'placeholder'; |
|
332 | - // add set a reference to it as the result value |
|
333 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
324 | + // build to native type |
|
325 | + if(isset($this->body_position) && $pos > $this->body_position){ |
|
326 | + // deal w/ multirefs |
|
327 | + if(isset($this->message[$pos]['attrs']['href'])){ |
|
328 | + // get id |
|
329 | + $id = substr($this->message[$pos]['attrs']['href'],1); |
|
330 | + // add placeholder to href array |
|
331 | + $this->multirefs[$id][$pos] = 'placeholder'; |
|
332 | + // add set a reference to it as the result value |
|
333 | + $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
334 | 334 | // build complexType values |
335 | - } elseif($this->message[$pos]['children'] != ''){ |
|
336 | - // if result has already been generated (struct/array) |
|
337 | - if(!isset($this->message[$pos]['result'])){ |
|
338 | - $this->message[$pos]['result'] = $this->buildVal($pos); |
|
339 | - } |
|
340 | - // build complexType values of attributes and possibly simpleContent |
|
341 | - } elseif (isset($this->message[$pos]['xattrs'])) { |
|
342 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
343 | - $this->message[$pos]['xattrs']['!'] = null; |
|
344 | - } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
345 | - if (isset($this->message[$pos]['type'])) { |
|
346 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
347 | - } else { |
|
348 | - $parent = $this->message[$pos]['parent']; |
|
349 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
350 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
351 | - } else { |
|
352 | - $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
353 | - } |
|
354 | - } |
|
355 | - } |
|
356 | - $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
357 | - // set value of simpleType (or nil complexType) |
|
358 | - } else { |
|
359 | - //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
360 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
361 | - $this->message[$pos]['xattrs']['!'] = null; |
|
362 | - } elseif (isset($this->message[$pos]['type'])) { |
|
363 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
364 | - } else { |
|
365 | - $parent = $this->message[$pos]['parent']; |
|
366 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
367 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
368 | - } else { |
|
369 | - $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
370 | - } |
|
371 | - } |
|
335 | + } elseif($this->message[$pos]['children'] != ''){ |
|
336 | + // if result has already been generated (struct/array) |
|
337 | + if(!isset($this->message[$pos]['result'])){ |
|
338 | + $this->message[$pos]['result'] = $this->buildVal($pos); |
|
339 | + } |
|
340 | + // build complexType values of attributes and possibly simpleContent |
|
341 | + } elseif (isset($this->message[$pos]['xattrs'])) { |
|
342 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
343 | + $this->message[$pos]['xattrs']['!'] = null; |
|
344 | + } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
345 | + if (isset($this->message[$pos]['type'])) { |
|
346 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
347 | + } else { |
|
348 | + $parent = $this->message[$pos]['parent']; |
|
349 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
350 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
351 | + } else { |
|
352 | + $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
353 | + } |
|
354 | + } |
|
355 | + } |
|
356 | + $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
357 | + // set value of simpleType (or nil complexType) |
|
358 | + } else { |
|
359 | + //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
360 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
361 | + $this->message[$pos]['xattrs']['!'] = null; |
|
362 | + } elseif (isset($this->message[$pos]['type'])) { |
|
363 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
364 | + } else { |
|
365 | + $parent = $this->message[$pos]['parent']; |
|
366 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
367 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
368 | + } else { |
|
369 | + $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
370 | + } |
|
371 | + } |
|
372 | 372 | |
373 | - /* add value to parent's result, if parent is struct/array |
|
373 | + /* add value to parent's result, if parent is struct/array |
|
374 | 374 | $parent = $this->message[$pos]['parent']; |
375 | 375 | if($this->message[$parent]['type'] != 'map'){ |
376 | 376 | if(strtolower($this->message[$parent]['type']) == 'array'){ |
@@ -380,261 +380,261 @@ discard block |
||
380 | 380 | } |
381 | 381 | } |
382 | 382 | */ |
383 | - } |
|
384 | - } |
|
383 | + } |
|
384 | + } |
|
385 | 385 | |
386 | 386 | // for doclit |
387 | 387 | if($this->status == 'header'){ |
388 | - if ($this->root_header != $pos) { |
|
389 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
390 | - } |
|
388 | + if ($this->root_header != $pos) { |
|
389 | + $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
390 | + } |
|
391 | 391 | } elseif($pos >= $this->root_struct){ |
392 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
392 | + $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
393 | 393 | } |
394 | - // switch status |
|
395 | - if ($pos == $this->root_struct){ |
|
396 | - $this->status = 'body'; |
|
397 | - $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
398 | - } elseif ($pos == $this->root_header) { |
|
399 | - $this->status = 'envelope'; |
|
400 | - } elseif ($name == 'Body' && $this->status == 'body') { |
|
401 | - $this->status = 'envelope'; |
|
402 | - } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
403 | - $this->status = 'envelope'; |
|
404 | - } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
405 | - $this->status = ''; |
|
406 | - } |
|
407 | - // set parent back to my parent |
|
408 | - $this->parent = $this->message[$pos]['parent']; |
|
409 | - } |
|
394 | + // switch status |
|
395 | + if ($pos == $this->root_struct){ |
|
396 | + $this->status = 'body'; |
|
397 | + $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
398 | + } elseif ($pos == $this->root_header) { |
|
399 | + $this->status = 'envelope'; |
|
400 | + } elseif ($name == 'Body' && $this->status == 'body') { |
|
401 | + $this->status = 'envelope'; |
|
402 | + } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
403 | + $this->status = 'envelope'; |
|
404 | + } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
405 | + $this->status = ''; |
|
406 | + } |
|
407 | + // set parent back to my parent |
|
408 | + $this->parent = $this->message[$pos]['parent']; |
|
409 | + } |
|
410 | 410 | |
411 | - /** |
|
412 | - * element content handler |
|
413 | - * |
|
414 | - * @param resource $parser XML parser object |
|
415 | - * @param string $data element content |
|
416 | - * @access private |
|
417 | - */ |
|
418 | - function character_data($parser, $data) |
|
411 | + /** |
|
412 | + * element content handler |
|
413 | + * |
|
414 | + * @param resource $parser XML parser object |
|
415 | + * @param string $data element content |
|
416 | + * @access private |
|
417 | + */ |
|
418 | + function character_data($parser, $data) |
|
419 | 419 | { |
420 | - $pos = $this->depth_array[$this->depth]; |
|
421 | - if ($this->xml_encoding == 'UTF-8'){ |
|
422 | - // TODO: add an option to disable this for folks who want |
|
423 | - // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
424 | - // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
425 | - if($this->decode_utf8){ |
|
426 | - $data = utf8_decode($data); |
|
427 | - } |
|
428 | - } |
|
420 | + $pos = $this->depth_array[$this->depth]; |
|
421 | + if ($this->xml_encoding == 'UTF-8'){ |
|
422 | + // TODO: add an option to disable this for folks who want |
|
423 | + // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
424 | + // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
425 | + if($this->decode_utf8){ |
|
426 | + $data = utf8_decode($data); |
|
427 | + } |
|
428 | + } |
|
429 | 429 | $this->message[$pos]['cdata'] .= $data; |
430 | 430 | // for doclit |
431 | 431 | if($this->status == 'header'){ |
432 | - $this->responseHeaders .= $data; |
|
432 | + $this->responseHeaders .= $data; |
|
433 | 433 | } else { |
434 | - $this->document .= $data; |
|
434 | + $this->document .= $data; |
|
435 | 435 | } |
436 | - } |
|
436 | + } |
|
437 | 437 | |
438 | - /** |
|
439 | - * get the parsed message (SOAP Body) |
|
440 | - * |
|
441 | - * @return mixed |
|
442 | - * @access public |
|
443 | - * @deprecated use get_soapbody instead |
|
444 | - */ |
|
445 | - function get_response(){ |
|
446 | - return $this->soapresponse; |
|
447 | - } |
|
438 | + /** |
|
439 | + * get the parsed message (SOAP Body) |
|
440 | + * |
|
441 | + * @return mixed |
|
442 | + * @access public |
|
443 | + * @deprecated use get_soapbody instead |
|
444 | + */ |
|
445 | + function get_response(){ |
|
446 | + return $this->soapresponse; |
|
447 | + } |
|
448 | 448 | |
449 | - /** |
|
450 | - * get the parsed SOAP Body (NULL if there was none) |
|
451 | - * |
|
452 | - * @return mixed |
|
453 | - * @access public |
|
454 | - */ |
|
455 | - function get_soapbody(){ |
|
456 | - return $this->soapresponse; |
|
457 | - } |
|
449 | + /** |
|
450 | + * get the parsed SOAP Body (NULL if there was none) |
|
451 | + * |
|
452 | + * @return mixed |
|
453 | + * @access public |
|
454 | + */ |
|
455 | + function get_soapbody(){ |
|
456 | + return $this->soapresponse; |
|
457 | + } |
|
458 | 458 | |
459 | - /** |
|
460 | - * get the parsed SOAP Header (NULL if there was none) |
|
461 | - * |
|
462 | - * @return mixed |
|
463 | - * @access public |
|
464 | - */ |
|
465 | - function get_soapheader(){ |
|
466 | - return $this->soapheader; |
|
467 | - } |
|
459 | + /** |
|
460 | + * get the parsed SOAP Header (NULL if there was none) |
|
461 | + * |
|
462 | + * @return mixed |
|
463 | + * @access public |
|
464 | + */ |
|
465 | + function get_soapheader(){ |
|
466 | + return $this->soapheader; |
|
467 | + } |
|
468 | 468 | |
469 | - /** |
|
470 | - * get the unparsed SOAP Header |
|
471 | - * |
|
472 | - * @return string XML or empty if no Header |
|
473 | - * @access public |
|
474 | - */ |
|
475 | - function getHeaders(){ |
|
476 | - return $this->responseHeaders; |
|
477 | - } |
|
469 | + /** |
|
470 | + * get the unparsed SOAP Header |
|
471 | + * |
|
472 | + * @return string XML or empty if no Header |
|
473 | + * @access public |
|
474 | + */ |
|
475 | + function getHeaders(){ |
|
476 | + return $this->responseHeaders; |
|
477 | + } |
|
478 | 478 | |
479 | - /** |
|
480 | - * decodes simple types into PHP variables |
|
481 | - * |
|
482 | - * @param string $value value to decode |
|
483 | - * @param string $type XML type to decode |
|
484 | - * @param string $typens XML type namespace to decode |
|
485 | - * @return mixed PHP value |
|
486 | - * @access private |
|
487 | - */ |
|
488 | - function decodeSimple($value, $type, $typens) { |
|
489 | - // TODO: use the namespace! |
|
490 | - if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
491 | - return (string) $value; |
|
492 | - } |
|
493 | - if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
494 | - return (int) $value; |
|
495 | - } |
|
496 | - if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
497 | - return (double) $value; |
|
498 | - } |
|
499 | - if ($type == 'boolean') { |
|
500 | - if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
501 | - return false; |
|
502 | - } |
|
503 | - return (boolean) $value; |
|
504 | - } |
|
505 | - if ($type == 'base64' || $type == 'base64Binary') { |
|
506 | - $this->debug('Decode base64 value'); |
|
507 | - return base64_decode($value); |
|
508 | - } |
|
509 | - // obscure numeric types |
|
510 | - if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
511 | - || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
512 | - || $type == 'unsignedInt' |
|
513 | - || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
514 | - return (int) $value; |
|
515 | - } |
|
516 | - // bogus: parser treats array with no elements as a simple type |
|
517 | - if ($type == 'array') { |
|
518 | - return array(); |
|
519 | - } |
|
520 | - // everything else |
|
521 | - return (string) $value; |
|
522 | - } |
|
479 | + /** |
|
480 | + * decodes simple types into PHP variables |
|
481 | + * |
|
482 | + * @param string $value value to decode |
|
483 | + * @param string $type XML type to decode |
|
484 | + * @param string $typens XML type namespace to decode |
|
485 | + * @return mixed PHP value |
|
486 | + * @access private |
|
487 | + */ |
|
488 | + function decodeSimple($value, $type, $typens) { |
|
489 | + // TODO: use the namespace! |
|
490 | + if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
491 | + return (string) $value; |
|
492 | + } |
|
493 | + if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
494 | + return (int) $value; |
|
495 | + } |
|
496 | + if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
497 | + return (double) $value; |
|
498 | + } |
|
499 | + if ($type == 'boolean') { |
|
500 | + if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
501 | + return false; |
|
502 | + } |
|
503 | + return (boolean) $value; |
|
504 | + } |
|
505 | + if ($type == 'base64' || $type == 'base64Binary') { |
|
506 | + $this->debug('Decode base64 value'); |
|
507 | + return base64_decode($value); |
|
508 | + } |
|
509 | + // obscure numeric types |
|
510 | + if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
511 | + || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
512 | + || $type == 'unsignedInt' |
|
513 | + || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
514 | + return (int) $value; |
|
515 | + } |
|
516 | + // bogus: parser treats array with no elements as a simple type |
|
517 | + if ($type == 'array') { |
|
518 | + return array(); |
|
519 | + } |
|
520 | + // everything else |
|
521 | + return (string) $value; |
|
522 | + } |
|
523 | 523 | |
524 | - /** |
|
525 | - * builds response structures for compound values (arrays/structs) |
|
526 | - * and scalars |
|
527 | - * |
|
528 | - * @param integer $pos position in node tree |
|
529 | - * @return mixed PHP value |
|
530 | - * @access private |
|
531 | - */ |
|
532 | - function buildVal($pos){ |
|
533 | - if(!isset($this->message[$pos]['type'])){ |
|
534 | - $this->message[$pos]['type'] = ''; |
|
535 | - } |
|
536 | - $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
537 | - // if there are children... |
|
538 | - if($this->message[$pos]['children'] != ''){ |
|
539 | - $this->debug('in buildVal, there are children'); |
|
540 | - $children = explode('|',$this->message[$pos]['children']); |
|
541 | - array_shift($children); // knock off empty |
|
542 | - // md array |
|
543 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
544 | - $r=0; // rowcount |
|
545 | - $c=0; // colcount |
|
546 | - foreach($children as $child_pos){ |
|
547 | - $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
548 | - $params[$r][] = $this->message[$child_pos]['result']; |
|
549 | - $c++; |
|
550 | - if($c == $this->message[$pos]['arrayCols']){ |
|
551 | - $c = 0; |
|
552 | - $r++; |
|
553 | - } |
|
524 | + /** |
|
525 | + * builds response structures for compound values (arrays/structs) |
|
526 | + * and scalars |
|
527 | + * |
|
528 | + * @param integer $pos position in node tree |
|
529 | + * @return mixed PHP value |
|
530 | + * @access private |
|
531 | + */ |
|
532 | + function buildVal($pos){ |
|
533 | + if(!isset($this->message[$pos]['type'])){ |
|
534 | + $this->message[$pos]['type'] = ''; |
|
535 | + } |
|
536 | + $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
537 | + // if there are children... |
|
538 | + if($this->message[$pos]['children'] != ''){ |
|
539 | + $this->debug('in buildVal, there are children'); |
|
540 | + $children = explode('|',$this->message[$pos]['children']); |
|
541 | + array_shift($children); // knock off empty |
|
542 | + // md array |
|
543 | + if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
544 | + $r=0; // rowcount |
|
545 | + $c=0; // colcount |
|
546 | + foreach($children as $child_pos){ |
|
547 | + $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
548 | + $params[$r][] = $this->message[$child_pos]['result']; |
|
549 | + $c++; |
|
550 | + if($c == $this->message[$pos]['arrayCols']){ |
|
551 | + $c = 0; |
|
552 | + $r++; |
|
553 | + } |
|
554 | 554 | } |
555 | 555 | // array |
556 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
556 | + } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
557 | 557 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
558 | 558 | foreach($children as $child_pos){ |
559 | - $params[] = &$this->message[$child_pos]['result']; |
|
559 | + $params[] = &$this->message[$child_pos]['result']; |
|
560 | 560 | } |
561 | 561 | // apache Map type: java hashtable |
562 | 562 | } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
563 | 563 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
564 | 564 | foreach($children as $child_pos){ |
565 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
566 | - $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
565 | + $kv = explode("|",$this->message[$child_pos]['children']); |
|
566 | + $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
567 | 567 | } |
568 | 568 | // generic compound type |
569 | 569 | //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') { |
570 | - } else { |
|
571 | - // Apache Vector type: treat as an array |
|
570 | + } else { |
|
571 | + // Apache Vector type: treat as an array |
|
572 | 572 | $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']); |
573 | - if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
574 | - $notstruct = 1; |
|
575 | - } else { |
|
576 | - $notstruct = 0; |
|
577 | - } |
|
578 | - // |
|
579 | - foreach($children as $child_pos){ |
|
580 | - if($notstruct){ |
|
581 | - $params[] = &$this->message[$child_pos]['result']; |
|
582 | - } else { |
|
583 | - if (isset($params[$this->message[$child_pos]['name']])) { |
|
584 | - // de-serialize repeated element name into an array |
|
585 | - if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
586 | - $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
587 | - } |
|
588 | - $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
589 | - } else { |
|
590 | - $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
591 | - } |
|
592 | - } |
|
573 | + if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
574 | + $notstruct = 1; |
|
575 | + } else { |
|
576 | + $notstruct = 0; |
|
593 | 577 | } |
594 | - } |
|
595 | - if (isset($this->message[$pos]['xattrs'])) { |
|
578 | + // |
|
579 | + foreach($children as $child_pos){ |
|
580 | + if($notstruct){ |
|
581 | + $params[] = &$this->message[$child_pos]['result']; |
|
582 | + } else { |
|
583 | + if (isset($params[$this->message[$child_pos]['name']])) { |
|
584 | + // de-serialize repeated element name into an array |
|
585 | + if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
586 | + $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
587 | + } |
|
588 | + $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
589 | + } else { |
|
590 | + $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + } |
|
595 | + if (isset($this->message[$pos]['xattrs'])) { |
|
596 | 596 | $this->debug('in buildVal, handling attributes'); |
597 | - foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
598 | - $params[$n] = $v; |
|
599 | - } |
|
600 | - } |
|
601 | - // handle simpleContent |
|
602 | - if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
597 | + foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
598 | + $params[$n] = $v; |
|
599 | + } |
|
600 | + } |
|
601 | + // handle simpleContent |
|
602 | + if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
603 | 603 | $this->debug('in buildVal, handling simpleContent'); |
604 | - if (isset($this->message[$pos]['type'])) { |
|
605 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
606 | - } else { |
|
607 | - $parent = $this->message[$pos]['parent']; |
|
608 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
609 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
610 | - } else { |
|
611 | - $params['!'] = $this->message[$pos]['cdata']; |
|
612 | - } |
|
613 | - } |
|
614 | - } |
|
615 | - $ret = is_array($params) ? $params : array(); |
|
616 | - $this->debug('in buildVal, return:'); |
|
617 | - //$this->appendDebug($this->varDump($ret)); |
|
618 | - return $ret; |
|
619 | - } else { |
|
620 | - $this->debug('in buildVal, no children, building scalar'); |
|
621 | - $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
622 | - if (isset($this->message[$pos]['type'])) { |
|
623 | - $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
624 | - $this->debug("in buildVal, return: $ret"); |
|
625 | - return $ret; |
|
626 | - } |
|
627 | - $parent = $this->message[$pos]['parent']; |
|
628 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
629 | - $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
630 | - $this->debug("in buildVal, return: $ret"); |
|
631 | - return $ret; |
|
632 | - } |
|
633 | - $ret = $this->message[$pos]['cdata']; |
|
634 | - $this->debug("in buildVal, return: $ret"); |
|
635 | - return $ret; |
|
636 | - } |
|
637 | - } |
|
604 | + if (isset($this->message[$pos]['type'])) { |
|
605 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
606 | + } else { |
|
607 | + $parent = $this->message[$pos]['parent']; |
|
608 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
609 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
610 | + } else { |
|
611 | + $params['!'] = $this->message[$pos]['cdata']; |
|
612 | + } |
|
613 | + } |
|
614 | + } |
|
615 | + $ret = is_array($params) ? $params : array(); |
|
616 | + $this->debug('in buildVal, return:'); |
|
617 | + //$this->appendDebug($this->varDump($ret)); |
|
618 | + return $ret; |
|
619 | + } else { |
|
620 | + $this->debug('in buildVal, no children, building scalar'); |
|
621 | + $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
622 | + if (isset($this->message[$pos]['type'])) { |
|
623 | + $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
624 | + $this->debug("in buildVal, return: $ret"); |
|
625 | + return $ret; |
|
626 | + } |
|
627 | + $parent = $this->message[$pos]['parent']; |
|
628 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
629 | + $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
630 | + $this->debug("in buildVal, return: $ret"); |
|
631 | + return $ret; |
|
632 | + } |
|
633 | + $ret = $this->message[$pos]['cdata']; |
|
634 | + $this->debug("in buildVal, return: $ret"); |
|
635 | + return $ret; |
|
636 | + } |
|
637 | + } |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | /** |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | var $root_struct_name = ''; |
19 | 19 | var $root_struct_namespace = ''; |
20 | 20 | var $root_header = ''; |
21 | - var $document = ''; // incoming SOAP body (text) |
|
21 | + var $document = ''; // incoming SOAP body (text) |
|
22 | 22 | // determines where in the message we are (envelope,header,body,method) |
23 | 23 | var $status = ''; |
24 | 24 | var $position = 0; |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | var $fault_detail = ''; |
34 | 34 | var $depth_array = array(); |
35 | 35 | var $debug_flag = true; |
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | 39 | var $body_position = 0; |
40 | 40 | // for multiref parsing: |
41 | 41 | // array of id => pos |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return void|bool |
56 | 56 | * @access public |
57 | 57 | */ |
58 | - function __construct($xml,$encoding='UTF-8',$method='',$decode_utf8=true) |
|
58 | + function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true) |
|
59 | 59 | { |
60 | 60 | parent::__construct(); |
61 | 61 | $this->xml = $xml; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->decode_utf8 = $decode_utf8; |
65 | 65 | |
66 | 66 | // Check whether content has been read. |
67 | - if(!empty($this->xml)){ |
|
67 | + if (!empty($this->xml)) { |
|
68 | 68 | // Check XML encoding |
69 | 69 | $pos_xml = strpos($xml, '<?xml'); |
70 | 70 | if ($pos_xml !== FALSE) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
73 | 73 | $xml_encoding = $res[1]; |
74 | 74 | if (strtoupper($xml_encoding) != $encoding) { |
75 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | + $err = "Charset from HTTP Content-Type '".$encoding."' does not match encoding from XML declaration '".$xml_encoding."'"; |
|
76 | 76 | $this->debug($err); |
77 | 77 | if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
78 | 78 | $this->setError($err); |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | // Set the object for the parser. |
99 | 99 | xml_set_object($this->parser, $this); |
100 | 100 | // Set the element handlers for the parser. |
101 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
102 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
101 | + xml_set_element_handler($this->parser, 'start_element', 'end_element'); |
|
102 | + xml_set_character_data_handler($this->parser, 'character_data'); |
|
103 | 103 | |
104 | 104 | xml_parse($this->parser, $this->xml); |
105 | 105 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | xml_get_current_line_number($this->parser), |
112 | 112 | xml_error_string(xml_get_error_code($this->parser))); |
113 | 113 | $this->debug($err); |
114 | - $this->debug("XML payload:\n" . $xml); |
|
114 | + $this->debug("XML payload:\n".$xml); |
|
115 | 115 | $this->setError($err); |
116 | 116 | } else { |
117 | 117 | $this->debug('in nusoap_parser ctor, message:'); |
@@ -120,18 +120,18 @@ discard block |
||
120 | 120 | // get final value |
121 | 121 | $this->soapresponse = $this->message[$this->root_struct]['result']; |
122 | 122 | // get header value |
123 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | + if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) { |
|
124 | 124 | $this->soapheader = $this->message[$this->root_header]['result']; |
125 | 125 | } |
126 | 126 | // resolve hrefs/ids |
127 | - if(sizeof($this->multirefs) > 0){ |
|
128 | - foreach($this->multirefs as $id => $hrefs){ |
|
127 | + if (sizeof($this->multirefs) > 0) { |
|
128 | + foreach ($this->multirefs as $id => $hrefs) { |
|
129 | 129 | $this->debug('resolving multirefs for id: '.$id); |
130 | 130 | $idVal = $this->buildVal($this->ids[$id]); |
131 | 131 | if (is_array($idVal) && isset($idVal['!id'])) { |
132 | 132 | unset($idVal['!id']); |
133 | 133 | } |
134 | - foreach($hrefs as $refPos => $ref){ |
|
134 | + foreach ($hrefs as $refPos => $ref) { |
|
135 | 135 | $this->debug('resolving href at pos '.$refPos); |
136 | 136 | $this->multirefs[$id][$refPos] = $idVal; |
137 | 137 | } |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | // update class level pos |
160 | 160 | $pos = $this->position++; |
161 | 161 | // and set mine |
162 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | + $this->message[$pos] = array('pos' => $pos, 'children'=>'', 'cdata'=>''); |
|
163 | 163 | // depth = how many levels removed from root? |
164 | 164 | // set mine as current global depth and increment global depth value |
165 | 165 | $this->message[$pos]['depth'] = $this->depth++; |
166 | 166 | |
167 | 167 | // else add self as child to whoever the current parent is |
168 | - if($pos != 0){ |
|
168 | + if ($pos != 0) { |
|
169 | 169 | $this->message[$this->parent]['children'] .= '|'.$pos; |
170 | 170 | } |
171 | 171 | // set my parent |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | // set self as current value for this depth |
176 | 176 | $this->depth_array[$this->depth] = $pos; |
177 | 177 | // get element prefix |
178 | - if(strpos($name,':')){ |
|
178 | + if (strpos($name, ':')) { |
|
179 | 179 | // get ns prefix |
180 | - $prefix = substr($name,0,strpos($name,':')); |
|
180 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
181 | 181 | // get unqualified name |
182 | - $name = substr(strstr($name,':'),1); |
|
182 | + $name = substr(strstr($name, ':'), 1); |
|
183 | 183 | } |
184 | 184 | // set status |
185 | 185 | if ($name == 'Envelope' && $this->status == '') { |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | } elseif ($name == 'Header' && $this->status == 'envelope') { |
188 | 188 | $this->root_header = $pos; |
189 | 189 | $this->status = 'header'; |
190 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | + } elseif ($name == 'Body' && $this->status == 'envelope') { |
|
191 | 191 | $this->status = 'body'; |
192 | 192 | $this->body_position = $pos; |
193 | 193 | // set method |
194 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | + } elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) { |
|
195 | 195 | $this->status = 'method'; |
196 | 196 | $this->root_struct_name = $name; |
197 | 197 | $this->root_struct = $pos; |
@@ -207,23 +207,23 @@ discard block |
||
207 | 207 | |
208 | 208 | // loop through atts, logging ns and type declarations |
209 | 209 | $attstr = ''; |
210 | - foreach($attrs as $key => $value){ |
|
210 | + foreach ($attrs as $key => $value) { |
|
211 | 211 | $key_prefix = $this->getPrefix($key); |
212 | 212 | $key_localpart = $this->getLocalPart($key); |
213 | 213 | // if ns declarations, add to class level array of valid namespaces |
214 | - if($key_prefix == 'xmlns'){ |
|
215 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
214 | + if ($key_prefix == 'xmlns') { |
|
215 | + if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) { |
|
216 | 216 | $this->XMLSchemaVersion = $value; |
217 | 217 | $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
218 | 218 | $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
219 | 219 | } |
220 | 220 | $this->namespaces[$key_localpart] = $value; |
221 | 221 | // set method namespace |
222 | - if($name == $this->root_struct_name){ |
|
222 | + if ($name == $this->root_struct_name) { |
|
223 | 223 | $this->methodNamespace = $value; |
224 | 224 | } |
225 | 225 | // if it's a type declaration, set type |
226 | - } elseif($key_localpart == 'type'){ |
|
226 | + } elseif ($key_localpart == 'type') { |
|
227 | 227 | if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
228 | 228 | // do nothing: already processed arrayType |
229 | 229 | } else { |
@@ -231,14 +231,14 @@ discard block |
||
231 | 231 | $value_localpart = $this->getLocalPart($value); |
232 | 232 | $this->message[$pos]['type'] = $value_localpart; |
233 | 233 | $this->message[$pos]['typePrefix'] = $value_prefix; |
234 | - if(isset($this->namespaces[$value_prefix])){ |
|
234 | + if (isset($this->namespaces[$value_prefix])) { |
|
235 | 235 | $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
236 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | + } else if (isset($attrs['xmlns:'.$value_prefix])) { |
|
237 | 237 | $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
238 | 238 | } |
239 | 239 | // should do something here with the namespace of specified type? |
240 | 240 | } |
241 | - } elseif($key_localpart == 'arrayType'){ |
|
241 | + } elseif ($key_localpart == 'arrayType') { |
|
242 | 242 | $this->message[$pos]['type'] = 'array'; |
243 | 243 | /* do arrayType ereg here |
244 | 244 | [1] arrayTypeValue ::= atype asize |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | [6] nextDimension ::= Digit+ ',' |
250 | 250 | */ |
251 | 251 | $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
252 | - if(preg_match($expr,$value,$regs)){ |
|
252 | + if (preg_match($expr, $value, $regs)) { |
|
253 | 253 | $this->message[$pos]['typePrefix'] = $regs[1]; |
254 | 254 | $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
255 | 255 | if (isset($this->namespaces[$regs[1]])) { |
@@ -262,22 +262,22 @@ discard block |
||
262 | 262 | $this->message[$pos]['arrayCols'] = $regs[4]; |
263 | 263 | } |
264 | 264 | // specifies nil value (or not) |
265 | - } elseif ($key_localpart == 'nil'){ |
|
265 | + } elseif ($key_localpart == 'nil') { |
|
266 | 266 | $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
267 | 267 | // some other attribute |
268 | 268 | } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
269 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | + $this->message[$pos]['xattrs']['!'.$key] = $value; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | if ($key == 'xmlns') { |
273 | 273 | $this->default_namespace = $value; |
274 | 274 | } |
275 | 275 | // log id |
276 | - if($key == 'id'){ |
|
276 | + if ($key == 'id') { |
|
277 | 277 | $this->ids[$value] = $pos; |
278 | 278 | } |
279 | 279 | // root |
280 | - if($key_localpart == 'root' && $value == 1){ |
|
280 | + if ($key_localpart == 'root' && $value == 1) { |
|
281 | 281 | $this->status = 'method'; |
282 | 282 | $this->root_struct_name = $name; |
283 | 283 | $this->root_struct = $pos; |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | $attstr .= " $key=\"$value\""; |
288 | 288 | } |
289 | 289 | // get namespace - must be done after namespace atts are processed |
290 | - if(isset($prefix)){ |
|
290 | + if (isset($prefix)) { |
|
291 | 291 | $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
292 | 292 | $this->default_namespace = $this->namespaces[$prefix]; |
293 | 293 | } else { |
294 | 294 | $this->message[$pos]['namespace'] = $this->default_namespace; |
295 | 295 | } |
296 | - if($this->status == 'header'){ |
|
296 | + if ($this->status == 'header') { |
|
297 | 297 | if ($this->root_header != $pos) { |
298 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | + $this->responseHeaders .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>"; |
|
299 | 299 | } |
300 | - } elseif($this->root_struct_name != ''){ |
|
301 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
300 | + } elseif ($this->root_struct_name != '') { |
|
301 | + $this->document .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>"; |
|
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
@@ -314,27 +314,27 @@ discard block |
||
314 | 314 | $pos = $this->depth_array[$this->depth--]; |
315 | 315 | |
316 | 316 | // get element prefix |
317 | - if(strpos($name,':')){ |
|
317 | + if (strpos($name, ':')) { |
|
318 | 318 | // get ns prefix |
319 | - $prefix = substr($name,0,strpos($name,':')); |
|
319 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
320 | 320 | // get unqualified name |
321 | - $name = substr(strstr($name,':'),1); |
|
321 | + $name = substr(strstr($name, ':'), 1); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | // build to native type |
325 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | + if (isset($this->body_position) && $pos > $this->body_position) { |
|
326 | 326 | // deal w/ multirefs |
327 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | + if (isset($this->message[$pos]['attrs']['href'])) { |
|
328 | 328 | // get id |
329 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | + $id = substr($this->message[$pos]['attrs']['href'], 1); |
|
330 | 330 | // add placeholder to href array |
331 | 331 | $this->multirefs[$id][$pos] = 'placeholder'; |
332 | 332 | // add set a reference to it as the result value |
333 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
333 | + $this->message[$pos]['result'] = & $this->multirefs[$id][$pos]; |
|
334 | 334 | // build complexType values |
335 | - } elseif($this->message[$pos]['children'] != ''){ |
|
335 | + } elseif ($this->message[$pos]['children'] != '') { |
|
336 | 336 | // if result has already been generated (struct/array) |
337 | - if(!isset($this->message[$pos]['result'])){ |
|
337 | + if (!isset($this->message[$pos]['result'])) { |
|
338 | 338 | $this->message[$pos]['result'] = $this->buildVal($pos); |
339 | 339 | } |
340 | 340 | // build complexType values of attributes and possibly simpleContent |
@@ -384,15 +384,15 @@ discard block |
||
384 | 384 | } |
385 | 385 | |
386 | 386 | // for doclit |
387 | - if($this->status == 'header'){ |
|
387 | + if ($this->status == 'header') { |
|
388 | 388 | if ($this->root_header != $pos) { |
389 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | + $this->responseHeaders .= "</".(isset($prefix) ? $prefix.':' : '')."$name>"; |
|
390 | 390 | } |
391 | - } elseif($pos >= $this->root_struct){ |
|
392 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
391 | + } elseif ($pos >= $this->root_struct) { |
|
392 | + $this->document .= "</".(isset($prefix) ? $prefix.':' : '')."$name>"; |
|
393 | 393 | } |
394 | 394 | // switch status |
395 | - if ($pos == $this->root_struct){ |
|
395 | + if ($pos == $this->root_struct) { |
|
396 | 396 | $this->status = 'body'; |
397 | 397 | $this->root_struct_namespace = $this->message[$pos]['namespace']; |
398 | 398 | } elseif ($pos == $this->root_header) { |
@@ -418,17 +418,17 @@ discard block |
||
418 | 418 | function character_data($parser, $data) |
419 | 419 | { |
420 | 420 | $pos = $this->depth_array[$this->depth]; |
421 | - if ($this->xml_encoding == 'UTF-8'){ |
|
421 | + if ($this->xml_encoding == 'UTF-8') { |
|
422 | 422 | // TODO: add an option to disable this for folks who want |
423 | 423 | // raw UTF-8 that, e.g., might not map to iso-8859-1 |
424 | 424 | // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
425 | - if($this->decode_utf8){ |
|
425 | + if ($this->decode_utf8) { |
|
426 | 426 | $data = utf8_decode($data); |
427 | 427 | } |
428 | 428 | } |
429 | 429 | $this->message[$pos]['cdata'] .= $data; |
430 | 430 | // for doclit |
431 | - if($this->status == 'header'){ |
|
431 | + if ($this->status == 'header') { |
|
432 | 432 | $this->responseHeaders .= $data; |
433 | 433 | } else { |
434 | 434 | $this->document .= $data; |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * @access public |
443 | 443 | * @deprecated use get_soapbody instead |
444 | 444 | */ |
445 | - function get_response(){ |
|
445 | + function get_response() { |
|
446 | 446 | return $this->soapresponse; |
447 | 447 | } |
448 | 448 | |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * @return mixed |
453 | 453 | * @access public |
454 | 454 | */ |
455 | - function get_soapbody(){ |
|
455 | + function get_soapbody() { |
|
456 | 456 | return $this->soapresponse; |
457 | 457 | } |
458 | 458 | |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @return mixed |
463 | 463 | * @access public |
464 | 464 | */ |
465 | - function get_soapheader(){ |
|
465 | + function get_soapheader() { |
|
466 | 466 | return $this->soapheader; |
467 | 467 | } |
468 | 468 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * @return string XML or empty if no Header |
473 | 473 | * @access public |
474 | 474 | */ |
475 | - function getHeaders(){ |
|
475 | + function getHeaders() { |
|
476 | 476 | return $this->responseHeaders; |
477 | 477 | } |
478 | 478 | |
@@ -529,40 +529,40 @@ discard block |
||
529 | 529 | * @return mixed PHP value |
530 | 530 | * @access private |
531 | 531 | */ |
532 | - function buildVal($pos){ |
|
533 | - if(!isset($this->message[$pos]['type'])){ |
|
532 | + function buildVal($pos) { |
|
533 | + if (!isset($this->message[$pos]['type'])) { |
|
534 | 534 | $this->message[$pos]['type'] = ''; |
535 | 535 | } |
536 | 536 | $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
537 | 537 | // if there are children... |
538 | - if($this->message[$pos]['children'] != ''){ |
|
538 | + if ($this->message[$pos]['children'] != '') { |
|
539 | 539 | $this->debug('in buildVal, there are children'); |
540 | - $children = explode('|',$this->message[$pos]['children']); |
|
540 | + $children = explode('|', $this->message[$pos]['children']); |
|
541 | 541 | array_shift($children); // knock off empty |
542 | 542 | // md array |
543 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
544 | - $r=0; // rowcount |
|
545 | - $c=0; // colcount |
|
546 | - foreach($children as $child_pos){ |
|
543 | + if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') { |
|
544 | + $r = 0; // rowcount |
|
545 | + $c = 0; // colcount |
|
546 | + foreach ($children as $child_pos) { |
|
547 | 547 | $this->debug("in buildVal, got an MD array element: $r, $c"); |
548 | 548 | $params[$r][] = $this->message[$child_pos]['result']; |
549 | 549 | $c++; |
550 | - if($c == $this->message[$pos]['arrayCols']){ |
|
550 | + if ($c == $this->message[$pos]['arrayCols']) { |
|
551 | 551 | $c = 0; |
552 | 552 | $r++; |
553 | 553 | } |
554 | 554 | } |
555 | 555 | // array |
556 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
556 | + } elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') { |
|
557 | 557 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
558 | - foreach($children as $child_pos){ |
|
558 | + foreach ($children as $child_pos) { |
|
559 | 559 | $params[] = &$this->message[$child_pos]['result']; |
560 | 560 | } |
561 | 561 | // apache Map type: java hashtable |
562 | - } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
|
562 | + } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
563 | 563 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
564 | - foreach($children as $child_pos){ |
|
565 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
564 | + foreach ($children as $child_pos) { |
|
565 | + $kv = explode("|", $this->message[$child_pos]['children']); |
|
566 | 566 | $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
567 | 567 | } |
568 | 568 | // generic compound type |
@@ -576,8 +576,8 @@ discard block |
||
576 | 576 | $notstruct = 0; |
577 | 577 | } |
578 | 578 | // |
579 | - foreach($children as $child_pos){ |
|
580 | - if($notstruct){ |
|
579 | + foreach ($children as $child_pos) { |
|
580 | + if ($notstruct) { |
|
581 | 581 | $params[] = &$this->message[$child_pos]['result']; |
582 | 582 | } else { |
583 | 583 | if (isset($params[$this->message[$child_pos]['name']])) { |