コード例 #1
0
    function createForm()
    {
        $f = new Am_Form();
        $f->addHidden('s')->setValue($this->getFiltered('s'));
        $f->addHidden('e')->setValue($this->getParam('e'));
        $g = $f->addGroup('newsletter', array('id' => 'newsletter-group'))->setLabel(___('Untick checkbox to cancel subscription'));
        $g->setSeparator("<br />\n");
        $ids = $this->view->guest->getLists();
        foreach ($this->lists as $l) {
            $title = $l->title;
            if ($l->desc) {
                $title .= " - " . $l->desc;
            }
            $el = $g->addCheckbox($l->pk())->setContent($title);
            if (in_array($l->list_id, $ids) && !$this->_request->isPost()) {
                $el->setAttribute('checked');
            }
            // checked by default
        }
        if (count($this->lists) > 1) {
            $f->addCheckbox('unsubscribe')->setLabel(___('Cancel all Subscriptions'));
            $f->addScript()->setScript(<<<CUT
jQuery(document).ready(function(\$) {
    \$("input#unsubscribe-0").change(function(){
        \$("#row-newsletter-group").toggle(!this.checked);
    });
});
CUT
);
        }
        $f->addSubmit('do', array('value' => ___('Change Subscription')));
        return $f;
    }
コード例 #2
0
 function createForm(array $vars)
 {
     $form = new Am_Form();
     $form->setDataSources(array(new Am_Request($vars)));
     $select = $form->addSelect('', array('size' => 1, 'id' => 'search-add-field'));
     $search = $form->addGroup($this->prefix);
     $search->options[''] = '** ' . ___('Select a condition to add into search') . ' **';
     foreach ($this->possibleConditions as $cond) {
         $cond->renderElement($search);
     }
     $select->loadOptions($search->options);
     $this->form = $form;
 }
コード例 #3
0
 function createForm()
 {
     $f = new Am_Form();
     $g = $f->addGroup('newsletter')->setLabel(___('Choose Newsletters'));
     $g->addRule('required', 'This field is required');
     $g->setSeparator("<br />\n");
     foreach ($this->lists as $l) {
         $title = $l->title;
         if ($l->desc) {
             $title .= " - " . $l->desc;
         }
         $el = $g->addCheckbox($l->pk())->setContent($title);
         if ($_SERVER['REQUEST_METHOD'] == 'GET') {
             $el->setAttribute('checked');
         }
         // checked by default
     }
     $f->addText('name', array('size' => 40))->setLabel(___('Name'))->addRule('required', 'This field is required');
     $f->addText('email', array('size' => 40))->setLabel(___('E-Mail Address'))->addRule('required', 'This field is required')->addRule('callback', "Please enter valid e-mail address", array('Am_Validate', 'email'))->addRule('callback', "There is a user registered with this e-mail address. Please login to manage your subscriptions", array($this, 'checkUserEmail'));
     $f->addSubmit('do', array('value' => ___('Subscribe')));
     return $f;
 }
コード例 #4
0
ファイル: paymill.php プロジェクト: grlf/eyedock
    public function createForm($label, $cc_mask = null)
    {
        $form = new Am_Form('cc-paymill');
        $name = $form->addGroup()->setLabel(___("Cardholder Name\n" . 'cardholder first and last name, exactly as on the card'));
        $name->addRule('required', ___('Please enter credit card holder name'));
        $name_f = $name->addText('cc_name_f', array('size' => 15, 'id' => 'cc_name_f'));
        $name_f->addRule('required', ___('Please enter credit card holder first name'))->addRule('regex', ___('Please enter credit card holder first name'), '|^[a-zA-Z_\' -]+$|');
        $name_l = $name->addText('cc_name_l', array('size' => 15, 'id' => 'cc_name_l'));
        $name_l->addRule('required', ___('Please enter credit card holder last name'))->addRule('regex', ___('Please enter credit card holder last name'), '|^[a-zA-Z_\' -]+$|');
        $cc = $form->addText('', array('autocomplete' => 'off', 'size' => 22, 'maxlength' => 22, 'id' => 'cc_number'))->setLabel(___('Credit Card Number'), ___('for example: 1111-2222-3333-4444'));
        if ($cc_mask) {
            $cc->setAttribute('placeholder', $cc_mask);
        }
        $cc->addRule('required', ___('Please enter Credit Card Number'))->addRule('regex', ___('Invalid Credit Card Number'), '/^[0-9 -]+$/');
        class_exists('Am_Form_CreditCard', true);
        // preload element
        $expire = $form->addElement(new Am_Form_Element_CreditCardExpire('cc_expire'))->setLabel(___("Card Expire\n" . 'Select card expiration date - month and year'));
        $code = $form->addPassword('', array('autocomplete' => 'off', 'size' => 4, 'maxlength' => 4, 'id' => 'cc_code'))->setLabel(___('Credit Card Code'), sprintf(___('The "Card Code" is a three- or four-digit security code that is printed on the back of credit cards in the card\'s signature panel (or on the front for American Express cards).'), '<br>', '<br>'));
        $code->addRule('required', ___('Please enter Credit Card Code'))->addRule('regex', ___('Please enter Credit Card Code'), '/^\\s*\\d{3,4}\\s*$/');
        /**/
        $fieldSet = $form->addFieldset(___('Address Info'))->setLabel(___("Address Info\n" . '(must match your credit card statement delivery address)'));
        $street = $fieldSet->addText('cc_street')->setLabel(___('Street Address'))->addRule('required', ___('Please enter Street Address'));
        $city = $fieldSet->addText('cc_city')->setLabel(___('City'))->addRule('required', ___('Please enter City'));
        $zip = $fieldSet->addText('cc_zip')->setLabel(___('ZIP'))->addRule('required', ___('Please enter ZIP code'));
        $country = $fieldSet->addSelect('cc_country')->setLabel(___('Country'))->setId('f_cc_country')->loadOptions(Am_Di::getInstance()->countryTable->getOptions(true));
        $country->addRule('required', ___('Please enter Country'));
        $group = $fieldSet->addGroup()->setLabel(___('State'));
        $group->addRule('required', ___('Please enter State'));
        $stateSelect = $group->addSelect('cc_state')->setId('f_cc_state')->loadOptions($stateOptions = Am_Di::getInstance()->stateTable->getOptions(@$_REQUEST['cc_country'], true));
        $stateText = $group->addText('cc_state')->setId('t_cc_state');
        $disableObj = $stateOptions ? $stateText : $stateSelect;
        $disableObj->setAttribute('disabled', 'disabled')->setAttribute('style', 'display: none');
        /**/
        $form->addSubmit('', array('value' => $label));
        $form->addHidden('id')->setValue($this->_request->get('id'));
        $form->addHidden('paymill_token', 'id=paymill_token')->addRule('required');
        //$key = json_encode($this->plugin->getConfig('public_key'));
        $key = $this->plugin->getConfig('public_key');
        $amount = $this->invoice->isFirstPayment() ? $this->invoice->first_total : $this->invoice->second_total;
        $amount = sprintf('%.02f', $amount) * 100;
        $form->addProlog('<script type="text/javascript" src="https://bridge.paymill.com/"></script>');
        $form->addScript()->setScript("var PAYMILL_PUBLIC_KEY = '" . $key . "';");
        if ($this->testMode) {
            $form->addScript()->setScript("var PAYMILL_TEST_MODE = true;");
        }
        $form->addScript()->setScript(file_get_contents(dirname(__FILE__) . '/../../default/views/public/js/json2.min.js'));
        $form->addScript()->setScript(<<<CUT
jQuery(function(\$){
    \$("form#cc-paymill").submit(function(event){
        var frm = \$(this);
        \$('.submit-button').attr("disabled", "disabled");
                
        if (frm.find("input[name=paymill_token]").val() > '')
            return true; // submit the form!
        event.stopPropagation();

        paymill.createToken({
            number:         frm.find("#cc_number").val(),       // required
            exp_month:      frm.find("[name='cc_expire[m]']").val(), // required
            exp_year:       frm.find("[name='cc_expire[y]']").val(),  // required
            cvc:            frm.find("#cc_code").val(),          // required
            amount_int:     {$amount},   // required, z.B. "4900" for 49.00 EUR
            currency:       '{$this->invoice->currency}',          // required
            cardholder:     frm.find("#cc_name_f").val() + " " + frm.find("#cc_name_l").val()    // optional
        }, function(error, result){ // handle response
            if (error) {
                frm.find("input[type=submit]").prop('disabled', null);
                var el = frm.find("#cc_number");
                var cnt = el.closest(".element");
                cnt.addClass("error");
                cnt.find("span.error").remove();
                
                var errorMessage = '';
                switch (error.apierror)
                {
                    case 'internal_server_error':
                        errorMessage = 'Communication with PSP failed';
                        break;
                    case 'invalid_public_key':
                        errorMessage = 'Invalid Public Key';
                        break;
                    case 'unknown_error':
                        errorMessage = 'Unknown Error';
                        break;

                    case '3ds_cancelled':
                        errorMessage = 'Password Entry of 3-D Secure password was cancelled by the user';
                        break;
                    case 'field_invalid_card_number':
                        errorMessage = 'Missing or invalid creditcard number';
                        break;
                    case 'field_invalid_card_exp_year':
                        errorMessage = 'Missing or invalid expiry year';
                        break;
                    case 'field_invalid_card_exp_month':
                        errorMessage = 'Missing or invalid expiry month';
                        break;
                    case 'field_invalid_card_exp':
                        errorMessage = 'Card is no longer valid or has expired';
                        break;
                    case 'field_invalid_card_cvc':
                        errorMessage = 'Invalid checking number';
                        break;
                    case 'field_invalid_card_holder':
                        errorMessage = 'Invalid cardholder';
                        break;
                    case 'field_invalid_amount_int':
                        errorMessage = 'Invalid or missing amount for 3-D Secure';
                        break;
                    case 'field_invalid_amount':
                        errorMessage = 'Invalid or missing amount for 3-D Secure deprecated, see blog post';
                        break;
                    case 'field_invalid_currency':
                        errorMessage = 'Invalid or missing currency code for 3-D Secure';
                        break;
                    case 'field_invalid_account_number':
                        errorMessage = 'Missing or invalid bank account number';
                        break;
                    case 'field_invalid_account_holder':
                        errorMessage = 'Missing or invalid bank account holder';
                        break;
                    case 'field_invalid_bank_code':
                        errorMessage = 'Missing or invalid bank code ';
                        break;
                    default:
                        errorMessage = error.apierror;
                }
                el.after("<span class='error'><br />"+errorMessage+"</span>");
            } else {
                frm.find("input[name=paymill_token]").val(result.token);
                frm.submit();
            }
        });                
        frm.find("input[type=submit]").prop('disabled', 'disabled');
        return false;
    });
});   
CUT
);
        return $form;
    }
コード例 #5
0
ファイル: stripe.php プロジェクト: grlf/eyedock
    public function createForm($label, $cc_mask = null)
    {
        $form = new Am_Form('cc-stripe');
        $name = $form->addGroup()->setLabel(___("Cardholder Name\n" . 'cardholder first and last name, exactly as on the card'));
        $name->addRule('required', ___('Please enter credit card holder name'));
        $name_f = $name->addText('cc_name_f', array('size' => 15, 'id' => 'cc_name_f'));
        $name_f->addRule('required', ___('Please enter credit card holder first name'))->addRule('regex', ___('Please enter credit card holder first name'), '|^[a-zA-Z_\' -]+$|');
        $name_l = $name->addText('cc_name_l', array('size' => 15, 'id' => 'cc_name_l'));
        $name_l->addRule('required', ___('Please enter credit card holder last name'))->addRule('regex', ___('Please enter credit card holder last name'), '|^[a-zA-Z_\' -]+$|');
        $cc = $form->addText('', array('autocomplete' => 'off', 'size' => 22, 'maxlength' => 22, 'id' => 'cc_number'))->setLabel(___('Credit Card Number'), ___('for example: 1111-2222-3333-4444'));
        if ($cc_mask) {
            $cc->setAttribute('placeholder', $cc_mask);
        }
        $cc->addRule('required', ___('Please enter Credit Card Number'))->addRule('regex', ___('Invalid Credit Card Number'), '/^[0-9 -]+$/');
        class_exists('Am_Form_CreditCard', true);
        // preload element
        $expire = $form->addElement(new Am_Form_Element_CreditCardExpire('cc_expire'))->setLabel(___("Card Expire\n" . 'Select card expiration date - month and year'));
        $expire->addRule('required', ___('Please enter Credit Card expiration date'));
        $code = $form->addPassword('', array('autocomplete' => 'off', 'size' => 4, 'maxlength' => 4, 'id' => 'cc_code'))->setLabel(___('Credit Card Code'), sprintf(___('The "Card Code" is a three- or four-digit security code that is printed on the back of credit cards in the card\'s signature panel (or on the front for American Express cards).'), '<br>', '<br>'));
        $code->addRule('required', ___('Please enter Credit Card Code'))->addRule('regex', ___('Please enter Credit Card Code'), '/^\\s*\\d{3,4}\\s*$/');
        $fieldSet = $form->addFieldset(___('Address Info'))->setLabel(___("Address Info\n" . '(must match your credit card statement delivery address)'));
        $street = $fieldSet->addText('cc_street')->setLabel(___('Street Address'))->addRule('required', ___('Please enter Street Address'));
        $city = $fieldSet->addText('cc_city')->setLabel(___('City '))->addRule('required', ___('Please enter City'));
        $zip = $fieldSet->addText('cc_zip')->setLabel(___('ZIP'))->addRule('required', ___('Please enter ZIP code'));
        $country = $fieldSet->addSelect('cc_country')->setLabel(___('Country'))->setId('f_cc_country')->loadOptions(Am_Di::getInstance()->countryTable->getOptions(true));
        $country->addRule('required', ___('Please enter Country'));
        $group = $fieldSet->addGroup()->setLabel(___('State'));
        $group->addRule('required', ___('Please enter State'));
        /** @todo load correct states */
        $stateSelect = $group->addSelect('cc_state')->setId('f_cc_state')->loadOptions($stateOptions = Am_Di::getInstance()->stateTable->getOptions(@$_REQUEST['cc_country'], true));
        $stateText = $group->addText('cc_state')->setId('t_cc_state');
        $disableObj = $stateOptions ? $stateText : $stateSelect;
        $disableObj->setAttribute('disabled', 'disabled')->setAttribute('style', 'display: none');
        $form->addSubmit('', array('value' => $label));
        $form->addHidden('id')->setValue($this->_request->get('id'));
        $form->addHidden('stripe_info', 'id=stripe_info')->addRule('required');
        $key = json_encode($this->plugin->getConfig('public_key'));
        $form->addScript()->setScript(file_get_contents(dirname(__FILE__) . '/../../default/views/public/js/json2.min.js'));
        $form->addScript()->setScript(<<<CUT
jQuery(function(\$){
    function am_make_base_auth(user, password) {
        return "Basic " + btoa(user + ':' + password);
    }
    \$("form#cc-stripe").submit(function(event){
        var frm = \$(this);
        if (frm.find("input[name=stripe_info]").val() > '')
            return true; // submit the form!
        event.stopPropagation();
        Stripe.setPublishableKey({$key});
        Stripe.createToken({
            number: frm.find("#cc_number").val(),
            cvc: frm.find("#cc_code").val(),
            exp_month: frm.find("[name='cc_expire[m]']").val(),
            exp_year: frm.find("[name='cc_expire[y]']").val(),
            name: frm.find("#cc_name_f").val() + " " + frm.find("#cc_name_l").val(),
            address_zip : frm.find("[name=cc_zip]").val(),
            address_line1 : frm.find("[name=cc_street]").val(),
            address_country : frm.find("[name=cc_country]").val(),
            address_city : frm.find("[name=cc_city]").val(),
            address_state : frm.find("[name=cc_state]").val()
            
        }, function(status, response){ // handle response
            if (status == '200')
            {
                frm.find("input[name=stripe_info]").val(JSON.stringify(response));
                frm.submit();
            } else {
                frm.find("input[type=submit]").prop('disabled', null);
                var msg;
                if (response.error.type == 'card_error')
                    msg = response.error.message;
                else
                    msg = 'Payment failure, please try again later';
                var el = frm.find("#cc_number");
                var cnt = el.closest(".element");
                cnt.addClass("error");
                cnt.find("span.error").remove();
                el.after("<span class='error'><br />"+msg+"</span>");
            }
        });
        frm.find("input[type=submit]").prop('disabled', 'disabled');
        return false;
    });
});   
CUT
);
        $form->setDataSources(array($this->_request, new HTML_QuickForm2_DataSource_Array($this->getDefaultValues($this->invoice->getUser()))));
        return $form;
    }
コード例 #6
0
ファイル: smart-debit.php プロジェクト: alexanderTsig/arabic
    public function createConfirmationForm($vars, $address)
    {
        $form = new Am_Form('dd-confirmation');
        $name = $this->escape($this->plugin->getConfig('legal_name'));
        $addr = $this->plugin->getConfig('legal_address');
        $form->addProlog(<<<CUT
<h1>Confirmation</h1>
<strong>{$name}</strong>
<br />
{$addr}
<br />
<br />
CUT
);
        $form->addStatic()->setContent($this->escape(sprintf('%s %s', $vars['name_f'], $vars['name_l'])))->setLabel('Name of Account Holder');
        $form->addStatic()->setContent($this->escape($vars['account_number']))->setLabel('Bank/Building Society Account Number');
        $form->addStatic()->setContent($this->escape($vars['sort_code']))->setLabel('Branch Sort Code');
        $street = implode('<br/>', array_map(array($this, 'escape'), array_filter(array($address['address1'], $address['address2'], $address['address3'], $address['address4']))));
        $form->addStatic()->setContent(sprintf('
%s<br />
%s<br />
%s<br />
%s<br />
%s<br />
%s', $this->escape($address['bank_name']), $this->escape($address['branch']), $street, $this->escape($address['town']), $this->escape($address['county']), $this->escape($address['postcode'])))->setLabel('Name and full postal address of your Bank or Building Society');
        $form->addStatic()->setContent($this->plugin->getConfig('sun'))->setLabel('Service User Number (SUN)');
        $form->addStatic()->setContent(Am_Paysystem_SmartDebit::REF_PREFIX . $this->invoice->public_id)->setLabel('Reference');
        $form->addStatic(null, array('class' => 'no-label'))->setContent(<<<CUT
<strong>Instruction to your Bank or Building Society</strong>
<br /><br />
Please pay <strong>{$name}</strong> Direct Debits from the account detailed in this Instruction
subject to the safeguards assured by the Direct Debit Guarantee. I understand
that this Instruction may remain with <strong>{$name}</strong> and, if so, details will be passed
electronically to my Bank/Building Society.
CUT
);
        $g = $form->addGroup(null, array('class' => 'no-label'));
        $g->setSeparator('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
        $g->addSubmit('confirm', array('value' => 'Confirm'));
        $g->addSubmit('amend', array('value' => 'Amend'));
        $g->addSubmit('cancel', array('value' => 'Cancel'));
        $g->addSubmit('print', array('value' => 'Print'));
        $form->addScript()->setScript(<<<CUT
\$('input[name=print]').click(function(){
    window.print();
    return false;
})
CUT
);
        $form->addHidden(Am_Controller::ACTION_KEY)->setValue($this->getRequest()->getActionName());
        $form->addHidden('id')->setValue($this->getFiltered('id'));
        return $form;
    }
コード例 #7
0
ファイル: Standard.php プロジェクト: alexanderTsig/arabic
 public function setupElements(Am_Form $form, $prefix = null)
 {
     $gr = $form->addGroup()->setLabel(___("Default Size\n" . "width&times;height"));
     $gr->addText($prefix . 'width', array('size' => 4));
     $gr->addStatic()->setContent(' &times ');
     $gr->addText($prefix . 'height', array('size' => 4));
     $form->addElement('select', $prefix . 'autoPlay')->setLabel(___("Auto Play\n" . 'whether the player should start playback immediately upon loading'))->loadOptions(array(0 => ___('No'), 1 => ___('Yes')));
     $form->addElement('select', $prefix . 'autoBuffering')->setLabel(___("Auto Buffering\n" . 'whether loading of clip into player\'s memory should begin ' . 'straight away. When this is true and autoPlay is false then ' . 'the clip will automatically stop at the first frame of the video.'))->loadOptions(array(0 => ___('No'), 1 => ___('Yes')));
     $form->addInteger($prefix . 'bufferLength')->setLabel(___("Buffer Length\n" . 'The amount of video data (in seconds) which should be loaded ' . 'into Flowplayer\'s memory in advance of playback commencing.'));
     $form->addElement('select', $prefix . 'scaling')->setLabel(___("Scaling\n" . "Setting which defines how video is scaled on the video screen. Available options are:\n" . "<strong>fit</strong>: Fit to window by preserving the aspect ratio encoded in the file's metadata.\n" . "<strong>half</strong>: Half-size (preserves aspect ratio)\n" . "<strong>orig</strong>: Use the dimensions encoded in the file. " . "If the video is too big for the available space, the video is scaled using the 'fit' option.\n" . "<strong>scale</strong>: Scale the video to fill all available space. " . "Ignores the dimensions in the metadata. This is the default setting."))->loadOptions(array('fit' => 'fit', 'half' => 'half', 'orig' => 'orig', 'scale' => 'scale'));
 }