コード例 #1
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Generate the component div
     $div = $this->generateComponentDiv();
     $firstNameDiv = new JFormElement('div', array('class' => 'firstNameDiv'));
     // Add the first name input tag
     $firstName = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-firstName', 'name' => $this->name . '-firstName', 'class' => 'firstName singleLineText', 'value' => $this->initialValues['firstName']));
     $firstNameDiv->insert($firstName);
     // Add the middle initial input tag
     $middleInitialDiv = new JFormElement('div', array('class' => 'middleInitialDiv'));
     $middleInitial = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-middleInitial', 'name' => $this->name . '-middleInitial', 'class' => 'middleInitial singleLineText', 'maxlength' => '1', 'value' => $this->initialValues['middleInitial']));
     if ($this->middleInitialHidden) {
         $middleInitial->setAttribute('style', 'display: none;');
         $middleInitialDiv->setAttribute('style', 'display: none;');
     }
     $middleInitialDiv->insert($middleInitial);
     // Add the last name input tag
     $lastNameDiv = new JFormElement('div', array('class' => 'lastNameDiv'));
     $lastName = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-lastName', 'name' => $this->name . '-lastName', 'class' => 'lastName singleLineText', 'value' => $this->initialValues['lastName']));
     $lastNameDiv->insert($lastName);
     if (!empty($this->emptyValues)) {
         $this->emptyValues = array('firstName' => 'First Name', 'middleInitial' => 'M', 'lastName' => 'Last Name');
         foreach ($this->emptyValues as $key => $value) {
             if ($key == 'firstName') {
                 $firstName->setAttribute('value', $value);
                 $firstName->addClassName('defaultValue');
             }
             if ($key == 'middleInitial') {
                 $middleInitial->setAttribute('value', $value);
                 $middleInitial->addClassName('defaultValue');
             }
             if ($key == 'lastName') {
                 $lastName->setAttribute('value', $value);
                 $lastName->addClassName('defaultValue');
             }
         }
     }
     if ($this->showSublabels) {
         $firstNameDiv->insert('<div class="jFormComponentSublabel"><p>First Name</p></div>');
         $middleInitialDiv->insert('<div class="jFormComponentSublabel"><p>MI</p></div>');
         $lastNameDiv->insert('<div class="jFormComponentSublabel"><p>Last Name</p></div>');
     }
     $div->insert($firstNameDiv);
     $div->insert($middleInitialDiv);
     $div->insert($lastNameDiv);
     // Add any description (optional)
     $div = $this->insertComponentDescription($div);
     // Add a tip (optional)
     $div = $this->insertComponentTip($div);
     return $div->__toString();
 }
コード例 #2
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Generate the component div
     $div = $this->generateComponentDiv();
     // Add the input tag
     $pseudoFileWrapper = new JFormElement('div', array('class' => 'pseudoFile', 'style' => 'position:absolute;'));
     $pseudoFileInput = new JFormElement('input', array('type' => 'text', 'disabled' => 'disabled'));
     $pseudoFileButton = new JFormElement('button', array('onclick' => 'return false;', 'disabled' => 'disabled'));
     $pseudoFileButton->update('Browse...');
     $pseudoFileWrapper->insert($pseudoFileInput);
     $pseudoFileWrapper->insert($pseudoFileButton);
     $input = new JFormElement('input', array('type' => $this->type, 'id' => $this->id, 'name' => $this->name, 'class' => $this->inputClass, 'size' => 15));
     if (!empty($this->styleWidth)) {
         $input->setAttribute('style', 'width: ' . $this->styleWidth . ';');
     }
     if (!empty($this->maxLength)) {
         $input->setAttribute('maxlength', $this->maxLength);
     }
     if ($this->disabled) {
         $input->setAttribute('disabled', 'disabled');
     }
     if ($this->customStyle) {
         $input->addClassName('hidden');
         $div->insert($pseudoFileWrapper);
     }
     $div->insert($input);
     // Add any description (optional)
     $div = $this->insertComponentDescription($div);
     // Add a tip (optional)
     $div = $this->insertComponentTip($div);
     return $div->__toString();
 }
コード例 #3
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Generate the component div
     $div = $this->generateComponentDiv();
     // Add the input tag
     $textArea = new JFormElement('textarea', array('id' => $this->id, 'name' => $this->name, 'class' => $this->inputClass));
     if (!empty($this->width)) {
         if (array_key_exists($this->width, $this->widthArray)) {
             $textArea->setAttribute('style', 'width: ' . $this->widthArray[$this->width] . ';');
         } else {
             $textArea->setAttribute('style', 'width: ' . $this->width . ';');
         }
     }
     if (!empty($this->height)) {
         if (array_key_exists($this->height, $this->heightArray)) {
             $textArea->addToAttribute('style', 'height: ' . $this->heightArray[$this->height] . ';');
         } else {
             $textArea->addToAttribute('style', 'height: ' . $this->height . ';');
         }
     }
     if (!empty($this->style)) {
         $textArea->addToAttribute('style', $this->style);
     }
     if ($this->disabled) {
         $textArea->setAttribute('disabled', 'disabled');
     }
     if ($this->readOnly) {
         $textArea->setAttribute('readonly', 'readonly');
     }
     if ($this->wrap) {
         $textArea->setAttribute('wrap', $this->wrap);
     }
     if (!empty($this->initialValue)) {
         $textArea->update($this->initialValue);
     }
     $div->insert($textArea);
     // Add any description (optional)
     $div = $this->insertComponentDescription($div);
     // Add a tip (optional)
     $div = $this->insertComponentTip($div);
     return $div->__toString();
 }
コード例 #4
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Generate the component div
     $div = $this->generateComponentDiv();
     // Add the input tag
     $input = new JFormElement('input', array('type' => $this->type, 'id' => $this->id, 'name' => $this->name));
     if (!empty($this->width)) {
         if (array_key_exists($this->width, $this->widthArray)) {
             $input->setAttribute('style', 'width: ' . $this->widthArray[$this->width] . ';');
         } else {
             $input->setAttribute('style', 'width: ' . $this->width . ';');
         }
     }
     if (!empty($this->initialValue)) {
         $input->setAttribute('value', $this->initialValue);
     }
     if (!empty($this->maxLength)) {
         $input->setAttribute('maxlength', $this->maxLength);
     }
     if (!empty($this->mask)) {
         $this->formComponentMeta['options']['mask'] = $this->mask;
     }
     if ($this->disabled) {
         $input->setAttribute('disabled', 'disabled');
     }
     if ($this->readOnly) {
         $input->setAttribute('readonly', 'readonly');
     }
     if ($this->enterSubmits) {
         $input->addToAttribute('class', ' jFormComponentEnterSubmits');
     }
     $div->insert($input);
     if (!empty($this->sublabel)) {
         $div->insert('<div class="jFormComponentSublabel">' . $this->sublabel . '</div>');
     }
     // Add any description (optional)
     $div = $this->insertComponentDescription($div);
     // Add a tip (optional)
     $div = $this->insertComponentTip($div);
     return $div->__toString();
 }
コード例 #5
0
 function getMultipleChoiceWrapper($multipleChoiceValue, $multipleChoiceLabel, $multipleChoiceChecked, $multipleChoiceTip, $multipleChoiceDisabled, $multipleChoiceInputHidden, $multipleChoiceCount)
 {
     // Make a wrapper div for the input and label
     $multipleChoiceWrapperDiv = new JFormElement('div', array('id' => $this->id . '-choice' . $multipleChoiceCount . '-wrapper', 'class' => $this->multipleChoiceClass . 'Wrapper'));
     // Input tag
     $input = new JFormElement('input', array('type' => $this->multipleChoiceType, 'id' => $this->id . '-choice' . $multipleChoiceCount, 'name' => $this->name, 'value' => $multipleChoiceValue, 'class' => $this->multipleChoiceClass, 'style' => 'display: inline;'));
     if ($multipleChoiceChecked == 'checked') {
         $input->setAttribute('checked', 'checked');
     }
     if ($multipleChoiceDisabled) {
         $input->setAttribute('disabled', 'disabled');
     }
     if ($multipleChoiceInputHidden) {
         $input->setAttribute('style', 'display: none;');
     }
     $multipleChoiceWrapperDiv->insert($input);
     // Multiple choice label
     $multipleChoiceLabelElement = new JFormElement('label', array('for' => $this->id . '-choice' . $multipleChoiceCount, 'class' => $this->multipleChoiceLabelClass, 'style' => 'display: inline;'));
     // Add an image to the label if there is a tip
     if (!empty($multipleChoiceTip) && $this->showMultipleChoiceTipIcons) {
         $multipleChoiceLabelElement->update($multipleChoiceLabel . ' <span class="jFormComponentMultipleChoiceTipIcon">&nbsp;</span>');
     } else {
         $multipleChoiceLabelElement->update($multipleChoiceLabel);
     }
     // Add a required star if there is only one multiple choice option and it is required
     if (sizeof($this->multipleChoiceArray) == 1) {
         // Add the required star to the label
         if (in_array('required', $this->validationOptions)) {
             $labelRequiredStarSpan = new JFormElement('span', array('class' => $this->labelRequiredStarClass));
             $labelRequiredStarSpan->update(' *');
             $multipleChoiceLabelElement->insert($labelRequiredStarSpan);
         }
     }
     $multipleChoiceWrapperDiv->insert($multipleChoiceLabelElement);
     // Multiple choice tip
     if (!empty($multipleChoiceTip)) {
         $multipleChoiceTipDiv = new JFormElement('div', array('id' => $this->id . '-' . $multipleChoiceValue . '-tip', 'style' => 'display: none;', 'class' => 'jFormComponentMultipleChoiceTip'));
         $multipleChoiceTipDiv->update($multipleChoiceTip);
         $multipleChoiceWrapperDiv->insert($multipleChoiceTipDiv);
     }
     return $multipleChoiceWrapperDiv;
 }
コード例 #6
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Div tag contains everything about the component
     $div = parent::generateComponentDiv();
     // Select tag
     $select = new JFormElement('select', array('id' => $this->id, 'name' => $this->name, 'class' => $this->class));
     // Only use if disabled is set, otherwise will throw an error
     if ($this->disabled) {
         $select->setAttribute('disabled', 'disabled');
     }
     if ($this->multiple) {
         $select->setAttribute('multiple', 'multiple');
     }
     if ($this->size != null) {
         $select->setAttribute('size', $this->size);
     }
     if ($this->width != null) {
         $select->setAttribute('style', 'width:' . $this->width);
     }
     // Check for any opt groups
     $optGroupArray = array();
     foreach ($this->dropDownOptionArray as $dropDownOption) {
         if (isset($dropDownOption['optGroup']) && !empty($dropDownOption['optGroup'])) {
             $optGroupArray[] = $dropDownOption['optGroup'];
         }
     }
     $optGroupArray = array_unique($optGroupArray);
     // Create the optgroup elements
     foreach ($optGroupArray as $optGroup) {
         ${$optGroup} = new JFormElement('optgroup', array('label' => $optGroup));
     }
     // Add any options to their appropriate optgroup
     foreach ($this->dropDownOptionArray as $dropDownOption) {
         if (isset($dropDownOption['optGroup']) && !empty($dropDownOption['optGroup'])) {
             $optionValue = isset($dropDownOption['value']) ? $dropDownOption['value'] : '';
             $optionLabel = isset($dropDownOption['label']) ? $dropDownOption['label'] : '';
             $optionSelected = isset($dropDownOption['selected']) ? $dropDownOption['selected'] : false;
             $optionDisabled = isset($dropDownOption['disabled']) ? $dropDownOption['disabled'] : false;
             $optionOptGroup = isset($dropDownOption['optGroup']) ? $dropDownOption['optGroup'] : '';
             ${$dropDownOption['optGroup']}->insert($this->getOption($optionValue, $optionLabel, $optionSelected, $optionDisabled));
         }
     }
     // Add any options that are not in an opt group to the select
     foreach ($this->dropDownOptionArray as $dropDownOption) {
         // Handle optgroup addition - only add the group if you haven't seen it yet
         if (isset($dropDownOption['optGroup']) && !empty($dropDownOption['optGroup']) && !isset(${$dropDownOption['optGroup'] . 'Added'})) {
             $select->insert(${$dropDownOption['optGroup']});
             ${$dropDownOption['optGroup'] . 'Added'} = true;
         } else {
             if (!isset($dropDownOption['optGroup'])) {
                 $optionValue = isset($dropDownOption['value']) ? $dropDownOption['value'] : '';
                 $optionLabel = isset($dropDownOption['label']) ? $dropDownOption['label'] : '';
                 $optionSelected = isset($dropDownOption['selected']) ? $dropDownOption['selected'] : false;
                 $optionDisabled = isset($dropDownOption['disabled']) ? $dropDownOption['disabled'] : false;
                 $optionOptGroup = isset($dropDownOption['optGroup']) ? $dropDownOption['optGroup'] : '';
                 $select->insert($this->getOption($optionValue, $optionLabel, $optionSelected, $optionDisabled));
             }
         }
     }
     // Add the select box to the div
     $div->insert($select);
     // Add any description (optional)
     $div = $this->insertComponentDescription($div);
     // Add a tip (optional)
     $div = $this->insertComponentTip($div, $this->id . '-div');
     return $div->__toString();
 }
コード例 #7
0
ファイル: JFormSection.php プロジェクト: niieani/jformer
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Section fieldset
     $jFormSectionDiv = new JFormElement('div', array('id' => $this->id, 'class' => $this->class));
     // This causes issues with things that are dependent and should display by default
     // If the section has dependencies and the display type is hidden, hide by default
     //if($this->dependencyOptions !== null && isset($this->dependencyOptions['display']) && $this->dependencyOptions['display'] == 'hide') {
     //    $jFormSectionDiv->setAttribute('style', 'display: none;');
     //}
     // Set the style
     if (!empty($this->style)) {
         $jFormSectionDiv->addToAttribute('style', $this->style);
     }
     // Add a title to the page
     if (!empty($this->title)) {
         $title = new JFormElement('div', array('class' => $this->titleClass));
         $title->update($this->title);
         $jFormSectionDiv->insert($title);
     }
     // Add a description to the page
     if (!empty($this->description)) {
         $description = new JFormElement('div', array('class' => $this->descriptionClass));
         $description->update($this->description);
         $jFormSectionDiv->insert($description);
     }
     // Add the form sections to the page
     foreach ($this->jFormComponentArray as $jFormComponentArray) {
         $jFormSectionDiv->insert($jFormComponentArray);
     }
     return $jFormSectionDiv->__toString();
 }
コード例 #8
0
ファイル: JFormer.php プロジェクト: niieani/jformer
 function getHtml()
 {
     $this->updateRequiredText($this->requiredText);
     // Create the form
     $jFormElement = new JFormElement('form', array('id' => $this->id, 'target' => $this->id . '-iframe', 'enctype' => 'multipart/form-data', 'method' => 'post', 'class' => $this->class, 'action' => $this->action));
     if (!empty($this->onMouseOver)) {
         $formJFormElement->attr('onmouseover', $this->onMouseOver);
     }
     if (!empty($this->onMouseOut)) {
         $formJFormElement->attr('onmouseout', $this->onMouseOut);
     }
     // Set the style
     if (!empty($this->style)) {
         $jFormElement->addToAttribute('style', $this->style);
     }
     // Global messages
     if ($this->alertsEnabled) {
         $jFormerAlertWrapperDiv = new JFormElement('div', array('class' => 'jFormerAlertWrapper', 'style' => 'display: none;'));
         $alertDiv = new JFormElement('div', array('class' => 'jFormerAlert'));
         $jFormerAlertWrapperDiv->insert($alertDiv);
         $jFormElement->insert($jFormerAlertWrapperDiv);
     }
     // If a splash is enabled
     if ($this->splashPageEnabled) {
         // Create a splash page div
         $splashPageDiv = new JFormElement('div', array('id' => $this->id . '-splash-page', 'class' => 'jFormerSplashPage jFormPage'));
         // Set defaults if they aren't set
         if (!isset($this->splashPage['content'])) {
             $this->splashPage['content'] = '';
         }
         if (!isset($this->splashPage['splashButtonText'])) {
             $this->splashPage['splashButtonText'] = 'Begin';
         }
         $splashPageDiv->insert('<div class="jFormerSplashPageContent">' . $this->splashPage['content'] . '</div>');
         // Create a splash button if there is no custom button ID
         if (!isset($this->splashPage['customButtonId'])) {
             $splashLi = new JFormElement('li', array('class' => 'splashLi'));
             $splashButton = new JFormElement('button', array('class' => 'splashButton'));
             $splashButton->update($this->splashPage['splashButtonText']);
             $splashLi->insert($splashButton);
         }
     }
     // Add a title to the form
     if (!empty($this->title)) {
         $title = new JFormElement('div', array('class' => $this->titleClass));
         $title->update($this->title);
         $jFormElement->insert($title);
     }
     // Add a description to the form
     if (!empty($this->description)) {
         $description = new JFormElement('div', array('class' => $this->descriptionClass));
         $description->update($this->description);
         $jFormElement->insert($description);
     }
     // Add the page navigator if enabled
     if ($this->pageNavigatorEnabled) {
         $pageNavigatorDiv = new JFormElement('div', array('class' => 'jFormPageNavigator'));
         if (isset($this->pageNavigator['position']) && $this->pageNavigator['position'] == 'right') {
             $pageNavigatorDiv->addToAttribute('class', ' jFormPageNavigatorRight');
         } else {
             $pageNavigatorDiv->addToAttribute('class', ' jFormPageNavigatorTop');
         }
         $pageNavigatorUl = new JFormElement('ul', array());
         $jFormPageArrayCount = 0;
         foreach ($this->jFormPageArray as $jFormPageKey => $jFormPage) {
             $jFormPageArrayCount++;
             $pageNavigatorLabel = new JFormElement('li', array('id' => 'navigatePage' . $jFormPageArrayCount, 'class' => 'jFormPageNavigatorLink'));
             // If the label is numeric
             if (isset($this->pageNavigator['label']) && $this->pageNavigator['label'] == 'numeric') {
                 $pageNavigatorLabelText = 'Page ' . $jFormPageArrayCount;
             } else {
                 // Add a link prefix if there is a title
                 if (!empty($jFormPage->title)) {
                     $pageNavigatorLabelText = '<span class="jFormNavigatorLinkPrefix">' . $jFormPageArrayCount . '</span> ' . strip_tags($jFormPage->title);
                 } else {
                     $pageNavigatorLabelText = 'Page ' . $jFormPageArrayCount;
                 }
             }
             $pageNavigatorLabel->update($pageNavigatorLabelText);
             if ($jFormPageArrayCount != 1) {
                 $pageNavigatorLabel->addToAttribute('class', ' jFormPageNavigatorLinkLocked');
             } else {
                 $pageNavigatorLabel->addToAttribute('class', ' jFormPageNavigatorLinkUnlocked jFormPageNavigatorLinkActive');
             }
             $pageNavigatorUl->insert($pageNavigatorLabel);
         }
         // Add the page navigator ul to the div
         $pageNavigatorDiv->insert($pageNavigatorUl);
         $jFormElement->insert($pageNavigatorDiv);
     }
     // Add the jFormerControl UL
     $jFormerControlUl = new JFormElement('ul', array('class' => 'jFormerControl'));
     // Create the cancel button
     if ($this->cancelButton) {
         $cancelButtonLi = new JFormElement('li', array('class' => 'cancelLi'));
         $cancelButton = new JFormElement('button', array('class' => $this->cancelButtonClass));
         $cancelButton->update($this->cancelButtonText);
         if (!empty($this->cancelButtonOnClick)) {
             $cancelButton->attr('onclick', $this->cancelButtonOnClick);
         }
         $cancelButtonLi->append($cancelButton);
     }
     // Create the previous button
     $previousButtonLi = new JFormElement('li', array('class' => 'previousLi', 'style' => 'display: none;'));
     $previousButton = new JFormElement('button', array('class' => 'previousButton'));
     $previousButton->update('Previous');
     $previousButtonLi->insert($previousButton);
     // Create the next button
     $nextButtonLi = new JFormElement('li', array('class' => 'nextLi'));
     $nextButton = new JFormElement('button', array('class' => 'nextButton'));
     $nextButton->update($this->submitButtonText);
     // Don't show the next button
     if ($this->splashPageEnabled) {
         $nextButtonLi->setAttribute('style', 'display: none;');
     }
     $nextButtonLi->insert($nextButton);
     // Add a splash page button if it exists
     if (isset($splashLi)) {
         $jFormerControlUl->insert($splashLi);
     }
     // Add the previous and next buttons
     $jFormerControlUl->insert($previousButtonLi);
     if ($this->cancelButton && $this->cancelButtonLiBeforeNextButtonLi) {
         echo 'one';
         $jFormerControlUl->insert($cancelButtonLi);
         $jFormerControlUl->insert($nextButtonLi);
     } else {
         if ($this->cancelButton) {
             echo 'two';
             $jFormerControlUl->insert($nextButtonLi);
             $jFormerControlUl->insert($cancelButtonLi);
         } else {
             $jFormerControlUl->insert($nextButtonLi);
         }
     }
     // Create the page wrapper and scrollers
     $jFormPageWrapper = new JFormElement('div', array('class' => 'jFormPageWrapper'));
     $jFormPageScroller = new JFormElement('div', array('class' => 'jFormPageScroller'));
     // Add a splash page if it exists
     if (isset($splashPageDiv)) {
         $jFormPageScroller->insert($splashPageDiv);
     }
     // Add the form pages to the form
     $jFormPageCount = 0;
     foreach ($this->jFormPageArray as $jFormPage) {
         // Hide everything but the first page
         if ($jFormPageCount != 0 || $jFormPageCount == 0 && $this->splashPageEnabled) {
             $jFormPage->style .= 'display: none;';
         }
         $jFormPageScroller->insert($jFormPage);
         $jFormPageCount++;
     }
     // Page wrapper wrapper
     $pageWrapperContainer = new JFormElement('div', array('class' => 'jFormWrapperContainer'));
     // Insert the page wrapper and the jFormerControl UL to the form
     $jFormElement->insert($pageWrapperContainer->insert($jFormPageWrapper->insert($jFormPageScroller) . $jFormerControlUl));
     // Create a script tag to initialize jFormer JavaScript
     $script = new JFormElement('script', array('type' => 'text/javascript', 'language' => 'javascript'));
     // Update the script tag
     $script->update('$(document).ready(function () { ' . $this->id . 'Object = new JFormer(\'' . $this->id . '\', ' . json_encode($this->getOptions()) . '); });');
     $jFormElement->insert($script);
     // Add a hidden iframe to handle the form posts
     $iframe = new JFormElement('iframe', array('id' => $this->id . '-iframe', 'name' => $this->id . '-iframe', 'class' => 'jFormerIFrame', 'frameborder' => 0, 'src' => '/empty.html'));
     if ($this->debugMode) {
         $iframe->addToAttribute('style', 'display:block;');
     }
     $jFormElement->insert($iframe);
     // After control
     if (!empty($this->afterControl)) {
         $subSubmitInstructions = new JFormElement('div', array('class' => 'jFormerAfterControl'));
         $subSubmitInstructions->update($this->afterControl);
         $jFormElement->insert($subSubmitInstructions);
     }
     return $jFormElement;
 }
コード例 #9
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Generate the component div
     $componentDiv = $this->generateComponentDiv();
     // Add the Address Line 1 input tag
     $addressLine1Div = new JFormElement('div', array('class' => 'addressLine1Div'));
     $addressLine1 = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-addressLine1', 'name' => $this->name . '-addressLine1', 'class' => 'addressLine1'));
     $addressLine1Div->insert($addressLine1);
     // Add the Address Line 2 input tag
     $addressLine2Div = new JFormElement('div', array('class' => 'addressLine2Div'));
     $addressLine2 = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-addressLine2', 'name' => $this->name . '-addressLine2', 'class' => 'addressLine2'));
     $addressLine2Div->insert($addressLine2);
     // Add the city input tag
     $cityDiv = new JFormElement('div', array('class' => 'cityDiv'));
     $city = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-city', 'name' => $this->name . '-city', 'class' => 'city', 'maxlength' => '15'));
     $cityDiv->insert($city);
     // Add the State input tag
     $stateDiv = new JFormElement('div', array('class' => 'stateDiv'));
     if ($this->stateDropDown) {
         $state = new JFormElement('select', array('id' => $this->id . '-state', 'name' => $this->name . '-state', 'class' => 'state'));
         // Add any options that are not in an opt group to the select
         foreach (JFormComponentDropDown::getStateArray($this->selectedState) as $dropDownOption) {
             $optionValue = isset($dropDownOption['value']) ? $dropDownOption['value'] : '';
             $optionLabel = isset($dropDownOption['label']) ? $dropDownOption['label'] : '';
             $optionSelected = isset($dropDownOption['selected']) ? $dropDownOption['selected'] : false;
             $optionDisabled = isset($dropDownOption['disabled']) ? $dropDownOption['disabled'] : false;
             $optionOptGroup = isset($dropDownOption['optGroup']) ? $dropDownOption['optGroup'] : '';
             $state->insert($this->getOption($optionValue, $optionLabel, $optionSelected, $optionDisabled));
         }
     } else {
         $state = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-state', 'name' => $this->name . '-state', 'class' => 'state'));
     }
     $stateDiv->insert($state);
     // Add the Zip input tag
     $zipDiv = new JFormElement('div', array('class' => 'zipDiv'));
     $zip = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-zip', 'name' => $this->name . '-zip', 'class' => 'zip', 'maxlength' => '5'));
     $zipDiv->insert($zip);
     // Add the country input tag
     $countryDiv = new JFormElement('div', array('class' => 'countryDiv'));
     // Don't built a select list if you are United States only
     if ($this->unitedStatesOnly) {
         $country = new JFormElement('input', array('type' => 'hidden', 'id' => $this->id . '-country', 'name' => $this->name . '-country', 'class' => 'country', 'value' => 'US', 'style' => 'display: none;'));
     } else {
         $country = new JFormElement('select', array('id' => $this->id . '-country', 'name' => $this->name . '-country', 'class' => 'country'));
         // Add any options that are not in an opt group to the select
         foreach (JFormComponentDropDown::getCountryArray($this->selectedCountry) as $dropDownOption) {
             $optionValue = isset($dropDownOption['value']) ? $dropDownOption['value'] : '';
             $optionLabel = isset($dropDownOption['label']) ? $dropDownOption['label'] : '';
             $optionSelected = isset($dropDownOption['selected']) ? $dropDownOption['selected'] : false;
             $optionDisabled = isset($dropDownOption['disabled']) ? $dropDownOption['disabled'] : false;
             $optionOptGroup = isset($dropDownOption['optGroup']) ? $dropDownOption['optGroup'] : '';
             $country->insert($this->getOption($optionValue, $optionLabel, $optionSelected, $optionDisabled));
         }
     }
     $countryDiv->insert($country);
     // Set the empty values if they are enabled
     if (!empty($this->emptyValues)) {
         foreach ($this->emptyValues as $empyValueKey => $emptyValue) {
             if ($empyValueKey == 'addressLine1') {
                 $addressLine1->setAttribute('value', $emptyValue);
                 $addressLine1->addClassName('defaultValue');
             }
             if ($empyValueKey == 'addressLine2') {
                 $addressLine2->setAttribute('value', $emptyValue);
                 $addressLine2->addClassName('defaultValue');
             }
             if ($empyValueKey == 'city') {
                 $city->setAttribute('value', $emptyValue);
                 $city->addClassName('defaultValue');
             }
             if ($empyValueKey == 'state' && !$this->stateDropDown) {
                 $state->setAttribute('value', $emptyValue);
                 $state->addClassName('defaultValue');
             }
             if ($empyValueKey == 'zip') {
                 $zip->setAttribute('value', $emptyValue);
                 $zip->addClassName('defaultValue');
             }
         }
     }
     // Put the sublabels in if the option allows for it
     if ($this->showSublabels) {
         $addressLine1Div->insert('<div class="jFormComponentSublabel"><p>Street Address</p></div>');
         $addressLine2Div->insert('<div class="jFormComponentSublabel"><p>Address Line 2</p></div>');
         $cityDiv->insert('<div class="jFormComponentSublabel"><p>City</p></div>');
         if ($this->unitedStatesOnly) {
             $stateDiv->insert('<div class="jFormComponentSublabel"><p>State</p></div>');
         } else {
             $stateDiv->insert('<div class="jFormComponentSublabel"><p>State / Province / Region</p></div>');
         }
         if ($this->unitedStatesOnly) {
             $zipDiv->insert('<div class="jFormComponentSublabel"><p>Zip Code</p></div>');
         } else {
             $zipDiv->insert('<div class="jFormComponentSublabel"><p>Postal / Zip Code</p></div>');
         }
         $countryDiv->insert('<div class="jFormComponentSublabel"><p>Country</p></div>');
     }
     // United States only switch
     if ($this->unitedStatesOnly) {
         $countryDiv->setAttribute('style', 'display: none;');
     }
     // Hide address line 2
     if ($this->addressLine2Hidden) {
         $addressLine2Div->setAttribute('style', 'display: none;');
     }
     // Insert the address components
     $componentDiv->insert($addressLine1Div);
     $componentDiv->insert($addressLine2Div);
     $componentDiv->insert($cityDiv);
     $componentDiv->insert($stateDiv);
     $componentDiv->insert($zipDiv);
     $componentDiv->insert($countryDiv);
     // Add any description (optional)
     $componentDiv = $this->insertComponentDescription($componentDiv);
     // Add a tip (optional)
     $componentDiv = $this->insertComponentTip($componentDiv);
     return $componentDiv->__toString();
 }
コード例 #10
0
ファイル: JFormPage.php プロジェクト: niieani/jformer
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Page div
     $jFormPageDiv = new JFormElement('div', array('id' => $this->id, 'class' => $this->class));
     // Set the styile
     if (!empty($this->style)) {
         $jFormPageDiv->addToAttribute('style', $this->style);
     }
     // Add a title to the page
     if (!empty($this->title)) {
         $title = new JFormElement('div', array('class' => $this->titleClass));
         $title->update($this->title);
         $jFormPageDiv->insert($title);
     }
     // Add a description to the page
     if (!empty($this->description)) {
         $description = new JFormElement('div', array('class' => $this->descriptionClass));
         $description->update($this->description);
         $jFormPageDiv->insert($description);
     }
     // Add the form sections to the page
     foreach ($this->jFormSectionArray as $jFormSection) {
         $jFormPageDiv->insert($jFormSection);
     }
     // Submit instructions
     if (!empty($this->submitInstructions)) {
         $submitInstruction = new JFormElement('div', array('class' => $this->submitInstructionsClass));
         $submitInstruction->update($this->submitInstructions);
         $jFormPageDiv->insert($submitInstruction);
     }
     return $jFormPageDiv->__toString();
 }
コード例 #11
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Generate the component div
     $componentDiv = parent::generateComponentDiv(!$this->collapseLabelIntoTableHeading);
     // Create the table
     $table = new JFormElement('table', array('class' => 'jFormComponentLikertTable'));
     // Generate the first row
     if ($this->showTableHeading) {
         $tableHeadingRow = new JFormElement('tr', array('class' => 'jFormComponentLikertTableHeading'));
         $tableHeading = new JFormElement('th', array('class' => 'jFormComponentLikertStatementColumn'));
         // Collapse the label into the heading if the option is set
         if ($this->collapseLabelIntoTableHeading) {
             $tableHeadingLabel = new JFormElement('label', array('class' => 'jFormComponentLikertStatementLabel'));
             $tableHeadingLabel->update($this->label);
             // Add the required star to the label
             if (in_array('required', $this->validationOptions)) {
                 $labelRequiredStarSpan = new JFormElement('span', array('class' => $this->labelRequiredStarClass));
                 $labelRequiredStarSpan->update(' *');
                 $tableHeadingLabel->insert($labelRequiredStarSpan);
             }
             $tableHeading->insert($tableHeadingLabel);
         }
         $tableHeadingRow->insert($tableHeading);
         foreach ($this->choiceArray as $choice) {
             $tableHeadingRow->insert('<th>' . $choice['label'] . '</th>');
         }
         $table->insert($tableHeadingRow);
     }
     // Insert each of the statements
     $statementCount = 0;
     foreach ($this->statementArray as $statement) {
         // Set the row style
         if ($statementCount % 2 == 0) {
             $statementRowClass = 'jFormComponentLikertTableRowEven';
         } else {
             $statementRowClass = 'jFormComponentLikertTableRowOdd';
         }
         // Set the statement
         $statementRow = new JFormElement('tr', array('class' => $statementRowClass));
         $statementColumn = new JFormElement('td', array('class' => 'jFormComponentLikertStatementColumn'));
         $statementLabel = new JFormElement('label', array('class' => 'jFormComponentLikertStatementLabel', 'for' => $statement['name'] . '-choice1'));
         $statementColumn->insert($statementLabel->insert($statement['statement']));
         // Set the statement description (optional)
         if (!empty($statement['description'])) {
             $statementDescription = new JFormElement('div', array('class' => 'jFormComponentLikertStatementDescription'));
             $statementColumn->insert($statementDescription->update($statement['description']));
         }
         // Insert a tip (optional)
         if (!empty($statement['tip'])) {
             $statementTip = new JFormElement('div', array('class' => 'jFormComponentLikertStatementTip', 'style' => 'display: none;'));
             $statementColumn->insert($statementTip->update($statement['tip']));
         }
         $statementRow->insert($statementColumn);
         $choiceCount = 1;
         foreach ($this->choiceArray as $choice) {
             $choiceColumn = new JFormElement('td');
             $choiceInput = new JFormElement('input', array('id' => $statement['name'] . '-choice' . $choiceCount, 'type' => 'radio', 'value' => $choice['value'], 'name' => $statement['name']));
             // Set a selected value if defined
             if (!empty($statement['selected'])) {
                 if ($statement['selected'] == $choice['value']) {
                     $choiceInput->setAttribute('checked', 'checked');
                 }
             }
             $choiceColumn->insert($choiceInput);
             // Choice sub labels
             if (!empty($choice['sublabel'])) {
                 $choiceSublabel = new JFormElement('label', array('class' => 'jFormComponentLikertSublabel', 'for' => $statement['name'] . '-choice' . $choiceCount));
                 $choiceSublabel->update($choice['sublabel']);
                 $choiceColumn->insert($choiceSublabel);
             }
             $statementRow->insert($choiceColumn);
             $choiceCount++;
         }
         $statementCount++;
         $table->insert($statementRow);
     }
     $componentDiv->insert($table);
     // Add any description (optional)
     $componentDiv = $this->insertComponentDescription($componentDiv);
     // Add a tip (optional)
     $componentDiv = $this->insertComponentTip($componentDiv, $this->id . '-div');
     return $componentDiv->__toString();
 }
コード例 #12
0
ファイル: JFormComponent.php プロジェクト: niieani/jformer
 function insertComponentTip($div)
 {
     // Create the tip div if not empty
     if (!empty($this->tip)) {
         $tipDiv = new JFormElement('div', array('id' => $this->id . '-tip', 'style' => 'display: none;', 'class' => $this->tipClass));
         $tipDiv->update($this->tip);
         $div->insert($tipDiv);
     }
     return $div;
 }
コード例 #13
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Generate the component div
     $componentDiv = $this->generateComponentDiv();
     // Add the card type select tag
     if ($this->showCardType) {
         $cardTypeDiv = new JFormElement('div', array('class' => 'cardTypeDiv'));
         $cardType = new JFormElement('select', array('id' => $this->id . '-cardType', 'name' => $this->name . '-cardType', 'class' => 'cardType'));
         // Have a default value the drop down list if there isn't a sublabel
         if ($this->showSublabels == false) {
             $cardType->insert($this->getOption('', 'Card Type', true, true));
         }
         // Add the card types
         foreach ($this->creditCardProviders as $key => $value) {
             $cardType->insert($this->getOption($key, $value, false, false));
         }
         $cardTypeDiv->insert($cardType);
     }
     // Add the card number input tag
     $cardNumberDiv = new JFormElement('div', array('class' => 'cardNumberDiv'));
     $cardNumber = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-cardNumber', 'name' => $this->name . '-cardNumber', 'class' => 'cardNumber', 'maxlength' => '16'));
     $cardNumberDiv->insert($cardNumber);
     // Add the expiration month select tag
     $expirationDateDiv = new JFormElement('div', array('class' => 'expirationDateDiv'));
     $expirationMonth = new JFormElement('select', array('id' => $this->id . '-expirationMonth', 'name' => $this->name . '-expirationMonth', 'class' => 'expirationMonth'));
     // Have a default value the drop down list if there isn't a sublabel
     if ($this->showSublabels == false) {
         $expirationMonth->insert($this->getOption('', 'Month', true, true));
     }
     // Add the months
     foreach (JFormComponentDropDown::getMonthArray() as $dropDownOption) {
         $optionValue = isset($dropDownOption['value']) ? $dropDownOption['value'] : '';
         $optionLabel = isset($dropDownOption['label']) ? $dropDownOption['label'] : '';
         $optionSelected = isset($dropDownOption['selected']) ? $dropDownOption['selected'] : false;
         $optionDisabled = isset($dropDownOption['disabled']) ? $dropDownOption['disabled'] : false;
         $optionOptGroup = isset($dropDownOption['optGroup']) ? $dropDownOption['optGroup'] : '';
         if ($this->showMonthName) {
             $expirationMonth->insert($this->getOption($optionValue, $optionValue . ' - ' . $optionLabel, $optionSelected, $optionDisabled));
             $expirationMonth->addClassName('long');
         } else {
             $expirationMonth->insert($this->getOption($optionValue, $optionValue, $optionSelected, $optionDisabled));
         }
     }
     $expirationDateDiv->insert($expirationMonth);
     // Add the expiration year select tag
     $expirationYear = new JFormElement('select', array('id' => $this->id . '-expirationYear', 'name' => $this->name . '-expirationYear', 'class' => 'expirationYear'));
     // Add years
     if ($this->showLongYear) {
         $startYear = Date('Y');
         $expirationYear->addClassName('long');
     } else {
         $startYear = Date('y');
         if (!$this->showMonthName) {
             $expirationDateDiv->insert('<span class="expirationDateSeparator">/</span>');
         }
     }
     if ($this->showSublabels == false) {
         $expirationYear->insert($this->getOption('', 'Year', true, true));
     }
     foreach (range($startYear, $startYear + 6) as $year) {
         $expirationYear->insert($this->getOption($year, $year, false, false));
     }
     $expirationDateDiv->insert($expirationYear);
     // Add the security code input tag
     $securityCodeDiv = new JFormElement('div', array('class' => 'securityCodeDiv'));
     $securityCode = new JFormElement('input', array('type' => 'text', 'id' => $this->id . '-securityCode', 'name' => $this->name . '-securityCode', 'class' => 'securityCode', 'maxlength' => '4'));
     $securityCodeDiv->insert($securityCode);
     // Set the empty values if they are enabled
     if (!empty($this->emptyValues)) {
         foreach ($this->emptyValues as $emptyValueKey => $emptyValue) {
             if ($emptyValueKey == 'cardNumber') {
                 $cardNumber->setAttribute('value', $emptyValue);
                 $cardNumber->addClassName('defaultValue');
             }
             if ($emptyValueKey == 'securityCode') {
                 $securityCode->setAttribute('value', $emptyValue);
                 $securityCode->addClassName('defaultValue');
             }
         }
     }
     // Put the sublabels in if the option allows for it
     if ($this->showSublabels) {
         if ($this->showCardType) {
             $cardTypeDiv->insert('<div class="jFormComponentSublabel"><p>Card Type</p></div>');
         }
         $cardNumberDiv->insert('<div class="jFormComponentSublabel"><p>Card Number</p></div>');
         $expirationDateDiv->insert('<div class="jFormComponentSublabel"><p>Expiration Date</p></div>');
         if ($this->showSecurityCode) {
             $securityCodeDiv->insert('<div class="jFormComponentSublabel"><p>Security Code</p></div>');
         }
     }
     // Insert the components
     if ($this->showCardType) {
         $componentDiv->insert($cardTypeDiv);
     }
     $componentDiv->insert($cardNumberDiv);
     $componentDiv->insert($expirationDateDiv);
     if ($this->showSecurityCode) {
         $componentDiv->insert($securityCodeDiv);
     }
     // Add any description (optional)
     $componentDiv = $this->insertComponentDescription($componentDiv);
     // Add a tip (optional)
     $componentDiv = $this->insertComponentTip($componentDiv);
     return $componentDiv->__toString();
 }