A Qcodo based CMS/ecommerce framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.8 KiB

13 years ago
  1. <?php
  2. /*
  3. * This class is INTENDED to be modified. Please define any custom "Render"-based methods
  4. * to handle custom global rendering functionality for all your controls.
  5. *
  6. * As an EXAMPLE, a RenderWithName method is included for you. Feel free to modify this method,
  7. * or to add as many of your own as you wish.
  8. *
  9. * Please note: All custom render methods should start with a RenderHelper call and end with a RenderOUtput call.
  10. */
  11. abstract class QControl extends QControlBase {
  12. // This will call GetControlHtml() for the bulk of the work, but will add layout html as well. It will include
  13. // the rendering of the Controls' name label, any errors or warnings, instructions, and html before/after (if specified).
  14. //
  15. // This one method can define how ALL controls should be rendered when "Rendered with Name" throughout the entire site.
  16. // For example:
  17. // <Name> <HTML Before><Control><HTML After>
  18. // <Instructions> <Error> or <warning>
  19. //
  20. // REMEMBER: THIS IS JUST AN EXAMPLE!!! Feel free to modify.
  21. public function RenderWithName($blnDisplayOutput = true) {
  22. ////////////////////
  23. // Call RenderHelper
  24. $this->RenderHelper(func_get_args(), __FUNCTION__);
  25. ////////////////////
  26. // Custom Render Functionality Here
  27. // Because this example RenderWithName will render a block-based element (e.g. a DIV), let's ensure
  28. // that IsBlockElement is set to true
  29. $this->blnIsBlockElement = true;
  30. // Render the Control's Dressing
  31. $strToReturn = '<div class="renderWithName">';
  32. // Render the Left side
  33. $strLeftClass = "left";
  34. if ($this->blnRequired)
  35. $strLeftClass .= ' required';
  36. if (!$this->blnEnabled)
  37. $strLeftClass .= ' disabled';
  38. if ($this->strInstructions)
  39. $strInstructions = '<br/><span class="instructions">' . $this->strInstructions . '</span>';
  40. else
  41. $strInstructions = '';
  42. $strToReturn .= sprintf('<div class="%s"><label for="%s">%s</label>%s</div>' , $strLeftClass, $this->strControlId, $this->strName, $strInstructions);
  43. // Render the Right side
  44. if ($this->strValidationError)
  45. $strMessage = sprintf('<span class="error">%s</span>', $this->strValidationError);
  46. else if ($this->strWarning)
  47. $strMessage = sprintf('<span class="error">%s</span>', $this->strWarning);
  48. else
  49. $strMessage = '';
  50. try {
  51. $strToReturn .= sprintf('<div class="right">%s%s%s%s</div>',
  52. $this->strHtmlBefore, $this->GetControlHtml(), $this->strHtmlAfter, $strMessage);
  53. } catch (QCallerException $objExc) {
  54. $objExc->IncrementOffset();
  55. throw $objExc;
  56. }
  57. $strToReturn .= '</div>';
  58. ////////////////////////////////////////////
  59. // Call RenderOutput, Returning its Contents
  60. return $this->RenderOutput($strToReturn, $blnDisplayOutput);
  61. ////////////////////////////////////////////
  62. }
  63. }
  64. ?>