예제 #1
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();
 }
예제 #2
0
 function getOption($optionValue, $optionLabel, $optionSelected, $optionDisabled)
 {
     $option = new JFormElement('option', array('value' => $optionValue));
     $option->update($optionLabel);
     if ($optionSelected) {
         $option->setAttribute('selected', 'selected');
     }
     if ($optionDisabled) {
         $option->setAttribute('disabled', 'disabled');
     }
     return $option;
 }
 /**
  *
  * @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();
 }
 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;
 }
예제 #5
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;
 }
예제 #6
0
 /**
  *
  * @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();
 }
예제 #7
0
 /**
  *
  * @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();
 }
예제 #8
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();
 }
예제 #9
0
 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;
 }