18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page_edit_fns.inc';
40 parent::__construct();
41 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
58 if ($asset->attr(
'button_type') ==
'_view_cart')
return TRUE;
60 if ($asset->attr(
'button_type') ==
'_donations') {
61 $field_name =
'Organization name/service';
62 $note =
'The name of your organization or the purpose for the donation. Global keywords can be used here.';
64 $field_name =
'Item name';
65 $note =
'The name of the item or service that you wish to sell. Global keywords can be used here.';
68 $o->openField($field_name,
'', $note);
70 $item_name = $asset->attr(
'item_name');
71 if ($asset->writeAccess(
'attributes')) {
72 text_box($prefix.
'_item_name', $item_name, 60);
74 echo htmlspecialchars($item_name);
94 if (!$asset->writeAccess(
'attributes'))
return FALSE;
95 if ($asset->attr(
'button_type') ==
'_view_cart')
return FALSE;
96 if (!isset($_POST[$prefix.
'_item_name']))
return FALSE;
98 $item_name = $_POST[$prefix.
'_item_name'];
100 return $asset->setAttrValue(
'item_name', $item_name);
117 if ($asset->attr(
'button_type') ==
'_view_cart')
return TRUE;
119 if ($asset->attr(
'button_type') ==
'_donations') {
120 $field_name =
'Donation ID';
121 $note =
'A value to help identify different kinds of contribution payments, for example, the name of your current fund-raising campaign';
123 $field_name =
'Item ID';
124 $note =
'Pass-through variable that will return to Matrix after Paypal finishes processing. This value is usually an asset ID and can be viewed by customers. Thus, it should not be used if the asset ID is secret to customers.';
127 $o->openField($field_name,
'', $note);
129 $item_id = $asset->attr(
'item_id');
130 if ($asset->writeAccess(
'attributes')) {
131 text_box($prefix.
'_item_id', $item_id, 60);
133 echo htmlspecialchars($item_id);
153 if (!$asset->writeAccess(
'attributes'))
return FALSE;
154 if ($asset->attr(
'button_type') ==
'_view_cart')
return FALSE;
155 if (!isset($_POST[$prefix.
'_item_id']))
return FALSE;
157 $item_id = $_POST[$prefix.
'_item_id'];
159 return $asset->setAttrValue(
'item_id', $item_id);
176 if ($asset->attr(
'button_type') ==
'_view_cart')
return TRUE;
178 if ($asset->attr(
'button_type') ==
'_donations') {
179 $field_name =
'Amount';
180 $note =
'The fixed contribution amount. If you leave the field blank, donors enter their own contribution amount after they click the Donate button. Global keywords can be used here.';
182 $field_name =
'Price';
183 $note =
'The fixed price for your item. If you leave the field blank, buyers "name their own price" after they click the Buy Now button. Global keywords can be used here.';
186 $o->openField($field_name,
'', $note);
188 $price = $asset->attr(
'price');
189 if ($asset->writeAccess(
'attributes')) {
190 text_box($prefix.
'_price', $price, 40);
192 echo htmlspecialchars($price);
212 if (!$asset->writeAccess(
'attributes'))
return FALSE;
213 if ($asset->attr(
'button_type') ==
'_view_cart')
return FALSE;
214 if (!isset($_POST[$prefix.
'_price']))
return FALSE;
216 $price = $_POST[$prefix.
'_price'];
218 return $asset->setAttrValue(
'price', $price);
235 if ($asset->attr(
'button_type') ==
'_view_cart')
return TRUE;
237 $field_name =
'Currency';
238 $note =
'The currency of the price.';
240 $o->openField($field_name,
'', $note);
242 $attr = $asset->getAttribute(
'currency');
244 $attr->paint($prefix.
'_'.$attr->id, !$asset->writeAccess(
'attributes'));
263 if (!$asset->writeAccess(
'attributes'))
return FALSE;
264 if ($asset->attr(
'button_type') ==
'_view_cart')
return FALSE;
266 $attr = $asset->getAttribute(
'currency');
268 $attr->process($prefix.
'_'.$attr->id);
270 return ($attr->processed && $asset->setAttrValue($attr->name, $attr->value));
287 if ($asset->attr(
'button_type') !=
'_xclick')
return TRUE;
289 $field_name =
'Undefined quantity?';
290 $note =
'Yes, if buyers can update the item quantity in payment process.';
292 $o->openField($field_name,
'', $note);
299 $undefined_quantity = $asset->attr(
'undefined_quantity');
300 if ($asset->writeAccess(
'attributes')) {
301 combo_box($prefix.
'_undefined_quantity', $options, FALSE, $undefined_quantity);
303 echo $options[$undefined_quantity];
323 if (!$asset->writeAccess(
'attributes'))
return FALSE;
324 if ($asset->attr(
'button_type') !=
'_xclick')
return FALSE;
325 if (!isset($_POST[$prefix.
'_undefined_quantity']))
return FALSE;
327 $undefined_quantity = $_POST[$prefix.
'_undefined_quantity'];
329 return $asset->setAttrValue(
'undefined_quantity', $undefined_quantity);
346 if ($asset->attr(
'button_type') ==
'_view_cart')
return TRUE;
348 $field_name =
'Custom variable';
349 $note =
'Pass-through variable that will return to Matrix after Paypal finishes processing. This value can be any extra information that Paypal will send back after a customer purchases an item. This value is never presented to customers so it can be used to send secret data under the format var1=value1,var2=value2. These values can be extracted by an IPN Receiver asset later. Globals keywords like %globals_user_assetid% can be used.';
352 if ($asset->attr(
'button_type') ==
'_cart') {
353 $note .=
' You should use the same value for this field in all <b>Add to Cart</b> buttons because the last clicked button\'s custom variable is returned and you will not know what it is.';
356 $o->openField($field_name,
'', $note);
358 $custom_var = $asset->attr(
'custom_var');
359 if ($asset->writeAccess(
'attributes')) {
360 text_box($prefix.
'_custom_var', $custom_var, 60);
362 echo htmlspecialchars($custom_var);
382 if (!$asset->writeAccess(
'attributes'))
return FALSE;
383 if ($asset->attr(
'button_type') ==
'_view_cart')
return FALSE;
384 if (!isset($_POST[$prefix.
'_custom_var']))
return FALSE;
386 $custom_var = $_POST[$prefix.
'_custom_var'];
388 return $asset->setAttrValue(
'custom_var', $custom_var);
405 if ($asset->attr(
'button_type') ==
'_view_cart')
return TRUE;
407 $field_name =
'Notify URL';
408 $note =
'This is the URL that Paypal will POST an Instant Payment Notification (IPN) to. It must be the URL of an IPN Receiver asset.';
411 if ($asset->attr(
'button_type') ==
'_cart') {
412 $note .=
' You should use the same value for this field in all <b>Add to Cart</b> buttons because the last clicked button\'s notify URL is used by Paypal and you will not know what it is.';
415 $o->openField($field_name,
'', $note);
417 $notify_url = $asset->attr(
'notify_url');
418 if ($asset->writeAccess(
'attributes')) {
419 text_box($prefix.
'_notify_url', $notify_url, 60);
421 echo htmlspecialchars($notify_url);
441 if (!$asset->writeAccess(
'attributes'))
return FALSE;
442 if ($asset->attr(
'button_type') ==
'_view_cart')
return FALSE;
443 if (!isset($_POST[$prefix.
'_notify_url']))
return FALSE;
445 $notify_url = $_POST[$prefix.
'_notify_url'];
447 return $asset->setAttrValue(
'notify_url', $notify_url);
464 if ($asset->attr(
'button_type') ==
'_view_cart')
return TRUE;
466 $field_name =
'Return URL';
467 $note =
'The URL of the page that the user will be returned after completing a payment.';
470 if ($asset->attr(
'button_type') ==
'_cart') {
471 $note .=
' You should use the same value for this field in all <b>Add to Cart</b> buttons because the last clicked button\'s return URL is used by Paypal and you will not know what it is.';
474 $o->openField($field_name,
'', $note);
476 $return_url = $asset->attr(
'return_url');
477 if ($asset->writeAccess(
'attributes')) {
478 text_box($prefix.
'_return_url', $return_url, 60);
480 echo htmlspecialchars($return_url);
500 if (!$asset->writeAccess(
'attributes'))
return FALSE;
501 if ($asset->attr(
'button_type') ==
'_view_cart')
return FALSE;
502 if (!isset($_POST[$prefix.
'_return_url']))
return FALSE;
504 $return_url = $_POST[$prefix.
'_return_url'];
506 return $asset->setAttrValue(
'return_url', $return_url);
523 if ($asset->attr(
'button_type') ==
'_view_cart')
return TRUE;
525 $field_name =
'Cancel URL';
526 $note =
'The URL of the page that the user will be returned if a payment is cancelled.';
529 if ($asset->attr(
'button_type') ==
'_cart') {
530 $note .=
' You should use the same value for this field in all <b>Add to Cart</b> buttons because the last clicked button\'s cancel URL is used by Paypal and you will not know what it is.';
533 $o->openField($field_name,
'', $note);
535 $cancel_url = $asset->attr(
'cancel_return_url');
536 if ($asset->writeAccess(
'attributes')) {
537 text_box($prefix.
'_cancel_return_url', $cancel_url, 60);
539 echo htmlspecialchars($cancel_url);
559 if (!$asset->writeAccess(
'attributes'))
return FALSE;
560 if ($asset->attr(
'button_type') ==
'_view_cart')
return FALSE;
561 if (!isset($_POST[$prefix.
'_cancel_return_url']))
return FALSE;
563 $cancel_url = $_POST[$prefix.
'_cancel_return_url'];
565 return $asset->setAttrValue(
'cancel_return_url', $cancel_url);
582 if (($asset->attr(
'button_type') !=
'_cart') && ($asset->attr(
'button_type') !=
'_view_cart'))
return TRUE;
584 $field_name =
'Paypal Shopping Cart opens in';
585 $note =
'This field specifies that the Paypal Shopping Cart will be opened in a separate browser window or opened in the same browser window that displays your website.';
587 $o->openField($field_name,
'', $note);
589 $attr = $asset->getAttribute(
'cart_target_window');
591 $attr->paint($prefix.
'_'.$attr->id, !$asset->writeAccess(
'attributes'));
610 if (!$asset->writeAccess(
'attributes'))
return FALSE;
611 if (($asset->attr(
'button_type') !=
'_cart') && ($asset->attr(
'button_type') !=
'_view_cart'))
return FALSE;
613 $attr = $asset->getAttribute(
'cart_target_window');
615 $attr->process($prefix.
'_'.$attr->id);
617 return ($attr->processed && $asset->setAttrValue($attr->name, $attr->value));
634 if (($asset->attr(
'button_type') !=
'_cart') && ($asset->attr(
'button_type') !=
'_view_cart'))
return TRUE;
636 $field_name =
'Shopping URL';
637 $note =
'This field specifies which page PayPal returns buyers to when they click the <b>Continue Shopping</b> button.';
639 $o->openField($field_name,
'', $note);
641 $shopping_url = $asset->attr(
'shopping_url');
642 if ($asset->writeAccess(
'attributes')) {
643 text_box($prefix.
'_shopping_url', $shopping_url, 60);
645 echo htmlspecialchars($shopping_url);
665 if (!$asset->writeAccess(
'attributes'))
return FALSE;
666 if (($asset->attr(
'button_type') !=
'_cart') && ($asset->attr(
'button_type') !=
'_view_cart'))
return FALSE;
667 if (!isset($_POST[$prefix.
'_shopping_url']))
return FALSE;
669 $shopping_url = $_POST[$prefix.
'_shopping_url'];
671 return $asset->setAttrValue(
'shopping_url', $shopping_url);
688 $current_vars = $asset->attr(
'extra_vars');
690 if ($asset->writeAccess(
'attributes')) {
691 text_area($prefix.
'_extra_vars', $current_vars, 80, 30);
693 if ($current_vars ==
'') {
694 echo
'<b>[Empty]</b>';
696 echo
'<b>'.str_replace(
"\n",
'<br />', $current_vars).
'</b>';
717 if (!$asset->writeAccess(
'attributes'))
return FALSE;
718 if (!isset($_POST[$prefix.
'_extra_vars']))
return FALSE;
720 $extra_vars = $_POST[$prefix.
'_extra_vars'];
721 $extra_vars = trim($extra_vars);
723 $extra_vars = str_replace(
"\r\n",
"\n", $extra_vars);
725 return $asset->setAttrValue(
'extra_vars', $extra_vars);