예제 #1
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();
 }
 /**
  *
  * @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();
 }
예제 #3
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;
 }
예제 #4
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();
 }
예제 #5
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();
 }
예제 #6
0
 function generateComponentDiv($includeLabel = true)
 {
     // Div tag contains everything about the component
     $componentDiv = new JFormElement('div', array('id' => $this->id . '-wrapper', 'class' => 'jFormComponent ' . $this->class));
     // This causes issues with things that are dependent and should display by default
     // If the component has dependencies and the display type is hidden, hide by default
     //if($this->dependencyOptions !== null && isset($this->dependencyOptions['display']) && $this->dependencyOptions['display'] == 'hide') {
     //    $componentDiv->setAttribute('style', 'display: none;');
     //}
     // Style
     if (!empty($this->style)) {
         $componentDiv->addToAttribute('style', $this->style);
     }
     // Label tag
     if ($includeLabel) {
         $label = $this->generateComponentLabel();
         $componentDiv->insert($label);
     }
     return $componentDiv;
 }