Beispiel #1
0
 /**
  * Returns the html for the control.
  * @return string
  * @throws \QCallerException
  */
 public function GetControlHtml()
 {
     $strHtml = \QHtml::RenderString($this->Name);
     if (!$this->blnAsButton) {
         $strHtml .= ' <span class="caret"></span>';
         $strHtml = $this->RenderTag("a", ["href" => "#", "data-toggle" => "dropdown", "aria-haspopup" => "true", "aria-expanded" => "false"], null, $strHtml);
     } else {
         if (!$this->blnSplit) {
             $strHtml .= ' <span class="caret"></span>';
             $strHtml = $this->RenderTag("button", ["data-toggle" => "dropdown", "aria-haspopup" => "true", "aria-expanded" => "false"], null, $strHtml);
         } else {
             $strHtml = $this->RenderTag("button", null, null, $strHtml);
             $strClass = "btn dropdown-toggle " . $this->strButtonSize . " " . $this->strButtonStyle;
             $strHtml .= \QHtml::RenderTag("button", ["class" => $strClass, "data-toggle" => "dropdown", "aria-haspopup" => "true", "aria-expanded" => "false"]);
         }
     }
     if ($this->HasDataBinder()) {
         $this->CallDataBinder();
     }
     if ($this->GetItemCount()) {
         $strListHtml = '';
         foreach ($this->GetAllItems() as $objItem) {
             $strListHtml .= $this->GetItemHtml($objItem);
         }
         $strHtml .= \QHtml::RenderTag("ul", ["id" => $this->ControlId . "_list", "class" => "dropdown-menu", "aria-labelledby" => $this->ControlId], $strListHtml);
     }
     if ($this->HasDataBinder()) {
         $this->RemoveAllItems();
     }
     return $strHtml;
 }
/**
 * Standard Print as Block function.  To aid with possible cross-scripting vulnerabilities,
 * this will automatically perform htmlspecialchars unless otherwise specified.
 *
 * Difference between _b() and _p() is that _b() will convert any linebreaks to <br/> tags.
 * This allows _b() to print any "block" of text that will have linebreaks in standard HTML.
 *
 * @param string $strString
 * @param boolean $blnHtmlEntities
 */
function _b($strString, $blnHtmlEntities = true)
{
    // Text Block Print
    if ($blnHtmlEntities && gettype($strString) != 'object') {
        print QHtml::RenderString($strString);
    } else {
        print nl2br($strString);
    }
}
 /**
  * Renders the control with an attached name
  *
  * This will call {@link QControlBase::GetControlHtml()} for the bulk of the work, but will add layout html as well.  It will include
  * the rendering of the Controls' name label, any errors or warnings, instructions, and html before/after (if specified).
  * As this is the parent class of all controls, this method defines how ALL controls will render when rendered with a name.
  * If you need certain controls to display differently, override this function in that control's class.
  *
  * @param boolean $blnDisplayOutput true to send to display buffer, false to just return then html
  * @throws QCallerException
  * @return string HTML of rendered Control
  */
 public function RenderWithName($blnDisplayOutput = true)
 {
     ////////////////////
     // Call RenderHelper
     $this->RenderHelper(func_get_args(), __FUNCTION__);
     ////////////////////
     $aWrapperAttributes = array();
     if (!$this->blnUseWrapper) {
         //there is no wrapper --> add the special attribute data-qrel to the name control
         $aWrapperAttributes['data-qrel'] = $this->strControlId;
         if (!$this->blnDisplay) {
             $aWrapperAttributes['style'] = 'display: none';
         }
     }
     // Custom Render Functionality Here
     // Because this example RenderWithName will render a block-based element (e.g. a DIV), let's ensure
     // that IsBlockElement is set to true
     $this->blnIsBlockElement = true;
     // Render the Left side
     $strLabelClass = "form-name";
     if ($this->blnRequired) {
         $strLabelClass .= ' required';
     }
     if (!$this->Enabled) {
         $strLabelClass .= ' disabled';
     }
     if ($this->strInstructions) {
         $strInstructions = '<br/>' . QHtml::RenderTag('span', ['class' => "instructions"], QHtml::RenderString($this->strInstructions));
     } else {
         $strInstructions = '';
     }
     $strLabel = QHtml::RenderTag('label', null, QHtml::RenderString($this->strName));
     $strToReturn = QHtml::RenderTag('div', ['class' => $strLabelClass], $strLabel . $strInstructions);
     // Render the Right side
     $strMessage = '';
     if ($this->strValidationError) {
         $strMessage = sprintf('<span class="error">%s</span>', QHtml::RenderString($this->strValidationError));
     } else {
         if ($this->strWarning) {
             $strMessage = sprintf('<span class="warning">%s</span>', QHtml::RenderString($this->strWarning));
         }
     }
     try {
         $strToReturn .= sprintf('<div class="form-field">%s%s%s%s</div>', $this->strHtmlBefore, $this->GetControlHtml(), $this->strHtmlAfter, $strMessage);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     // render control dressing, which is essentially a wrapper. Not sure why we are not just rendering a wrapper here!
     $strToReturn = QHtml::RenderTag('div', $aWrapperAttributes, $strToReturn);
     ////////////////////////////////////////////
     // Call RenderOutput, Returning its Contents
     return $this->RenderOutput($strToReturn, $blnDisplayOutput, false);
     ////////////////////////////////////////////
 }