예제 #1
0
 /**
  * Form settings.
  *
  * @return void
  *
  * @author Sascha Koehler <*****@*****.**>
  * @since 11.04.2011
  */
 public function preferences()
 {
     parent::preferences();
     $this->preferences['submitButtonTitle'] = _t('SilvercartPage.LOGIN');
     $this->formFields['emailaddress']['title'] = _t('SilvercartPage.EMAIL_ADDRESS');
     $this->formFields['password']['title'] = _t('SilvercartPage.PASSWORD');
 }
 /**
  * Set texts for preferences with i18n methods.
  *
  * @return void
  *
  * @author Sascha Koehler <*****@*****.**>
  * @since 11.04.2011
  */
 public function preferences()
 {
     $this->preferences['submitButtonTitle'] = _t('SilvercartPage.LOGIN');
     $this->preferences['doJsValidationScrolling'] = false;
     $this->formFields['emailaddress']['title'] = _t('SilvercartPage.EMAIL_ADDRESS') . ':';
     $this->formFields['password']['title'] = _t('SilvercartPage.PASSWORD') . ':';
     parent::preferences();
 }
 /**
  * Returns the forms fields.
  * 
  * @param bool $withUpdate Call the method with decorator updates or not?
  *
  * @return array
  */
 public function getFormFields($withUpdate = true)
 {
     parent::getFormFields(false);
     if (!array_key_exists('SearchQuery', $this->formFields)) {
         $this->formFields['SearchQuery'] = array('type' => 'SilvercartTextField', 'title' => '', 'value' => '', 'maxLength' => '30', 'checkRequirements' => array('isFilledIn' => true));
         if ($withUpdate) {
             $this->extend('updateFormFields', $this->formFields);
         }
     }
     return $this->formFields;
 }
 /**
  * Here we insert the translations of the field labels.
  * 
  * Registered users don't have to insert their data, they only get the
  * option to subscribe to or unsubscribe from the newsletter.
  *
  * @return void
  * 
  * @author Sebastian Diel <*****@*****.**>,
  *         Sascha Koehler <*****@*****.**>
  * @since 23.04.2014
  */
 protected function fillInFieldValues()
 {
     parent::fillInFieldValues();
     $member = SilvercartCustomer::currentRegisteredCustomer();
     $this->clearSessionMessages();
     // Set translations
     $this->formFields['Salutation']['value'] = array('' => _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE'), "Frau" => _t('SilvercartAddress.MISSES'), "Herr" => _t('SilvercartAddress.MISTER'));
     $this->formFields['Salutation']['title'] = _t('SilvercartAddress.SALUTATION');
     $this->formFields['FirstName']['title'] = _t('SilvercartAddress.FIRSTNAME', 'firstname');
     $this->formFields['Surname']['title'] = _t('SilvercartAddress.SURNAME');
     $this->formFields['Email']['title'] = _t('SilvercartAddress.EMAIL', 'email address');
     $this->formFields['NewsletterAction']['title'] = _t('SilvercartNewsletterForm.ACTIONFIELD_TITLE');
     $this->formFields['NewsletterAction']['value']['1'] = _t('SilvercartNewsletterForm.ACTIONFIELD_SUBSCRIBE');
     $this->formFields['NewsletterAction']['value']['2'] = _t('SilvercartNewsletterForm.ACTIONFIELD_UNSUBSCRIBE');
     $this->preferences['submitButtonTitle'] = _t('SilvercartPage.SUBMIT');
     // Fill in field values for registered customers and set them to readonly.
     if ($member) {
         $this->formFields['Salutation']['checkRequirements'] = array();
         $this->formFields['Salutation']['type'] = 'ReadonlyField';
         $this->formFields['Salutation']['value'] = $member->Salutation;
         $this->formFields['FirstName']['checkRequirements'] = array();
         $this->formFields['FirstName']['type'] = 'ReadonlyField';
         $this->formFields['FirstName']['value'] = $member->FirstName;
         $this->formFields['Surname']['checkRequirements'] = array();
         $this->formFields['Surname']['type'] = 'ReadonlyField';
         $this->formFields['Surname']['value'] = $member->Surname;
         $this->formFields['Email']['checkRequirements'] = array();
         $this->formFields['Email']['type'] = 'ReadonlyField';
         $this->formFields['Email']['value'] = $member->Email;
         // Remove action field according to newsletter status of the customer
         if ($member->SubscribedToNewsletter) {
             $this->formFields['NewsletterAction']['value'] = array('2' => _t('SilvercartNewsletterForm.ACTIONFIELD_UNSUBSCRIBE'));
             $this->formFields['NewsletterAction']['title'] = _t('SilvercartNewsletter.SUBSCRIBED') . ' - ' . $this->formFields['NewsletterAction']['title'];
         } else {
             $this->formFields['NewsletterAction']['value'] = array('1' => _t('SilvercartNewsletterForm.ACTIONFIELD_SUBSCRIBE'));
             $this->formFields['NewsletterAction']['title'] = _t('SilvercartNewsletter.UNSUBSCRIBED') . ' - ' . $this->formFields['NewsletterAction']['title'];
         }
     }
 }
 /**
  * Dynamically enables and disables the validation of some context dependant
  * fields
  *
  * @param SS_HTTPRequest $data submit data
  * @param Form           $form form object
  *
  * @return ViewableData
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 09.10.2012
  */
 public function submit($data, $form)
 {
     $formData = $this->getFormData($data);
     if (array_key_exists('IsPackstation', $formData)) {
         if ($formData['IsPackstation'] == '0') {
             $this->deactivateValidationFor('PostNumber');
             $this->deactivateValidationFor('Packstation');
         } else {
             $this->deactivateValidationFor('Street');
             $this->deactivateValidationFor('StreetNumber');
         }
     } elseif (array_key_exists('Shipping_IsPackstation', $formData)) {
         if ($formData['Shipping_IsPackstation'] == '0') {
             $this->deactivateValidationFor('Shipping_PostNumber');
             $this->deactivateValidationFor('Shipping_Packstation');
         } else {
             $this->deactivateValidationFor('Shipping_Street');
             $this->deactivateValidationFor('Shipping_StreetNumber');
         }
     }
     return parent::submit($data, $form);
 }
 /**
  * Fills in the field values
  * 
  * @return void
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 11.03.2013
  */
 protected function fillInFieldValues()
 {
     parent::fillInFieldValues();
     if ($this->getProduct()->isInCart()) {
         $this->formFields['productQuantity']['value'] = $this->getProduct()->getQuantityInCart();
     }
 }
예제 #7
0
 /**
  * Enables the CustomHtmlForm file cache
  * 
  * @return void
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 22.03.2013
  */
 public static function enableCache()
 {
     self::$cache_enabled = true;
 }
 /**
  * Set initial values in form fields
  *
  * @return void
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 11.04.2014
  */
 protected function fillInFieldValues()
 {
     parent::fillInFieldValues();
 }
 /**
  * Sets some dynamic preferences
  * 
  * @return void
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 11.03.2013
  */
 public function preferences()
 {
     $this->preferences['submitButtonToolTip'] = _t('SilvercartPage.DECREMENT_POSITION');
     return parent::preferences();
 }
 /**
  * Returns the form fields for this form
  *
  * @param bool $withUpdate Call the method with decorator updates or not?
  * 
  * @return array
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 13.09.2013
  */
 public function getFormFields($withUpdate = true)
 {
     if (!array_key_exists('SortOrder', $this->formFields)) {
         $productsPerPage = $this->controller->getProductsPerPageSetting();
         if ($productsPerPage == SilvercartConfig::getProductsPerPageUnlimitedNumber()) {
             $productsPerPage = 0;
         }
         $product = singleton('SilvercartProduct');
         $sortableFrontendFields = $product->sortableFrontendFields();
         $sortableFrontendFieldValues = array_keys($sortableFrontendFields);
         $sortableFrontendFieldValues = array_flip($sortableFrontendFieldValues);
         if (!array_key_exists($product->getDefaultSort(), $sortableFrontendFieldValues)) {
             $sortableFrontendFieldValues[$product->getDefaultSort()] = 0;
         }
         $sortOrder = $sortableFrontendFieldValues[$product->getDefaultSort()];
         $sortableFrontendFieldsForDropdown = array_values($sortableFrontendFields);
         asort($sortableFrontendFieldsForDropdown);
         $this->formFields = array('SortOrder' => array('type' => 'DropdownField', 'title' => _t('SilvercartProductGroupPageSelector.SORT_ORDER'), 'value' => $sortableFrontendFieldsForDropdown, 'selectedValue' => $sortOrder, 'checkRequirements' => array()));
         $productsPerPageOptions = SilvercartConfig::getProductsPerPageOptions();
         if (!empty($productsPerPageOptions)) {
             $this->formFields['productsPerPage'] = array('type' => 'DropdownField', 'title' => _t('SilvercartProductGroupPageSelector.PRODUCTS_PER_PAGE'), 'value' => SilvercartConfig::getProductsPerPageOptions(), 'selectedValue' => $productsPerPage, 'checkRequirements' => array());
         } else {
             $this->formFields['productsPerPage'] = array('type' => 'HiddenField', 'value' => SilvercartConfig::getProductsPerPageDefault());
         }
     }
     return parent::getFormFields($withUpdate = true);
 }
 /**
  * Sets the preferences for this form
  * 
  * @return array
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 25.09.2014
  */
 public function preferences()
 {
     $this->preferences = array('markRequiredFields' => true);
     parent::preferences();
     return $this->preferences;
 }
예제 #12
0
// ----------------------------------------------------------------------------
// Define path constants
// ----------------------------------------------------------------------------
$path = dirname(__FILE__) . '/';
$relPath = substr(Director::makeRelative($path), 1);
define('PIXELTRICKS_CHECKOUT_BASE_PATH', $path);
define('PIXELTRICKS_CHECKOUT_BASE_PATH_REL', $relPath);
// ----------------------------------------------------------------------------
// Register at required modules
// ----------------------------------------------------------------------------
CustomHtmlForm::registerModule('silvercart', 49);
CustomHtmlFormActionHandler::addHandler('SilvercartActionHandler');
// ----------------------------------------------------------------------------
// Set spam check for forms
// ----------------------------------------------------------------------------
CustomHtmlForm::useSpamCheckFor('SilvercartContactForm');
// ----------------------------------------------------------------------------
// Check if the page.php descends from the SilvercartPage
// ----------------------------------------------------------------------------
if (class_exists('Page')) {
    $ext = new ReflectionClass('Page');
    if ($ext->getParentClass()->getName() != 'SilvercartPage') {
        throw new Exception('Class "Page" has to extend "SilvercartPage".');
    }
}
if (class_exists('Page_Controller')) {
    $ext = new ReflectionClass('Page_Controller');
    if ($ext->getParentClass()->getName() != 'SilvercartPage_Controller') {
        throw new Exception('Class "Page_Controller" has to extend "SilvercartPage_Controller".');
    }
}
 /**
  * Form settings.
  *
  * @return void
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 11.11.2016
  */
 public function preferences()
 {
     parent::preferences();
     $this->preferences['submitButtonTitle'] = _t('SilvercartPage.LOGIN');
     $this->preferences['doJsValidationScrolling'] = false;
 }
 /**
  * Set texts for preferences with i18n methods.
  *
  * @return void
  * 
  * @author Sascha Koehler <*****@*****.**>,
  *         Sebastian Diel <*****@*****.**>
  * @since 26.06.2013
  */
 public function preferences()
 {
     $this->preferences['submitButtonTitle'] = _t('SilvercartSearchWidgetForm.SUBMITBUTTONTITLE');
     $this->preferences['doJsValidationScrolling'] = false;
     $this->formFields['quickSearchQuery']['title'] = _t('SilvercartSearchWidgetForm.SEARCHLABEL');
     parent::preferences();
 }
 /**
  * Returns the preferences for this form
  * 
  * @param bool $withUpdate Call the method with decorator updates or not?
  *
  * @return array
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 27.04.2012
  */
 public function getFormFields($withUpdate = true)
 {
     $this->formFields = array('Language' => array('type' => 'SilvercartLanguageDropdownField', 'title' => _t('Silvercart.LANGUAGE'), 'value' => array(), 'checkRequirements' => array('isFilledIn' => true)));
     return parent::getFormFields($withUpdate);
 }
 /**
  * Sets the preferences for this form
  * 
  * @return array
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 04.06.2014
  */
 public function preferences()
 {
     $this->preferences = array('submitButtonTitle' => _t('SilvercartPage.SUBMIT_MESSAGE', 'submit message'), 'markRequiredFields' => true);
     parent::preferences();
     return $this->preferences;
 }