TLabel displays a piece of text on a Web page. Use {@link setText Text} property to set the text to be displayed. TLabel will render the contents enclosed within its component tag if {@link setText Text} is empty. To use TLabel as a form label, associate it with a control by setting the {@link setForControl ForControl} property. The associated control must be locatable within the label's naming container. If the associated control is not visible, the label will not be rendered, either. Note, {@link setText Text} will NOT be encoded for rendering. Make sure it does not contain dangerous characters that you want to avoid.
Since: 3.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends TWebControl, implements Prado\IDataRenderer
コード例 #1
0
ファイル: TBaseValidator.php プロジェクト: pradosoft/prado
 /**
  * Renders the validator control.
  * @param THtmlWriter writer for the rendering purpose
  */
 public function renderContents($writer)
 {
     if (($text = $this->getText()) !== '') {
         $writer->write($text);
     } else {
         if (($text = $this->getErrorMessage()) !== '') {
             $writer->write($text);
         } else {
             parent::renderContents($writer);
         }
     }
 }
コード例 #2
0
ファイル: TDataGrid.php プロジェクト: pradosoft/prado
 /**
  * Creates a pager button.
  * Depending on the button type, a TLinkButton or a TButton may be created.
  * If it is enabled (clickable), its command name and parameter will also be set.
  * Derived classes may override this method to create additional types of buttons, such as TImageButton.
  * @param mixed the container pager instance of TActiveDatagridPager
  * @param string button type, either LinkButton or PushButton
  * @param boolean whether the button should be enabled
  * @param string caption of the button
  * @param string CommandName corresponding to the OnCommand event of the button
  * @param string CommandParameter corresponding to the OnCommand event of the button
  * @return mixed the button instance
  */
 protected function createPagerButton($pager, $buttonType, $enabled, $text, $commandName, $commandParameter)
 {
     if ($buttonType === TDataGridPagerButtonType::LinkButton) {
         if ($enabled) {
             $button = new TLinkButton();
         } else {
             $button = new TLabel();
             $button->setText($text);
             return $button;
         }
     } else {
         $button = new TButton();
         if (!$enabled) {
             $button->setEnabled(false);
         }
     }
     $button->setText($text);
     $button->setCommandName($commandName);
     $button->setCommandParameter($commandParameter);
     $button->setCausesValidation(false);
     return $button;
 }
コード例 #3
0
ファイル: TLabelTest.php プロジェクト: pradosoft/prado
 public function testSetText()
 {
     $label = new TLabel();
     $label->setText('Test');
     $this->assertEquals('Test', $label->getText());
 }
コード例 #4
0
ファイル: TPager.php プロジェクト: pradosoft/prado
 /**
  * Creates a pager button.
  * Depending on the button type, a TLinkButton or a TButton may be created.
  * If it is enabled (clickable), its command name and parameter will also be set.
  * Derived classes may override this method to create additional types of buttons, such as TImageButton.
  * @param string button type, either LinkButton or PushButton
  * @param boolean whether the button should be enabled
  * @param string caption of the button.
  * @param string CommandName corresponding to the OnCommand event of the button.
  * @param string CommandParameter corresponding to the OnCommand event of the button
  * @return mixed the button instance
  */
 protected function createPagerButton($buttonType, $enabled, $text, $commandName, $commandParameter)
 {
     if ($buttonType === TPagerButtonType::LinkButton) {
         if ($enabled) {
             $button = new TLinkButton();
         } else {
             $button = new TLabel();
             $button->setText($text);
             $button->setCssClass($this->getButtonCssClass());
             return $button;
         }
     } else {
         if ($buttonType === TPagerButtonType::ImageButton) {
             $button = new TImageButton();
             $button->setImageUrl($this->getPageImageUrl($text, $commandName));
         } else {
             $button = new TButton();
         }
         if (!$enabled) {
             $button->setEnabled(false);
         }
     }
     $button->setText($text);
     $button->setCommandName($commandName);
     $button->setCommandParameter($commandParameter);
     $button->setCausesValidation(false);
     $button->setCssClass($this->getButtonCssClass());
     return $button;
 }
コード例 #5
0
ファイル: TActiveDataGrid.php プロジェクト: pradosoft/prado
 /**
  * Creates a pager button.
  * Depending on the button type, a TActiveLinkButton or a TActiveButton may be created.
  * If it is enabled (clickable), its command name and parameter will also be set.
  * It overrides the datagrid's original method to create active controls instead, thus
  * the pager will do callbacks instead of the regular postbacks.
  * @param mixed the container pager instance of TActiveDatagridPager
  * @param string button type, either LinkButton or PushButton
  * @param boolean whether the button should be enabled
  * @param string caption of the button
  * @param string CommandName corresponding to the OnCommand event of the button
  * @param string CommandParameter corresponding to the OnCommand event of the button
  * @return mixed the button instance
  */
 protected function createPagerButton($pager, $buttonType, $enabled, $text, $commandName, $commandParameter)
 {
     if ($buttonType === TDataGridPagerButtonType::LinkButton) {
         if ($enabled) {
             $button = new TActiveLinkButton();
         } else {
             $button = new TLabel();
             $button->setText($text);
             return $button;
         }
     } else {
         $button = new TActiveButton();
         if (!$enabled) {
             $button->setEnabled(false);
         }
     }
     $button->setText($text);
     $button->setCommandName($commandName);
     $button->setCommandParameter($commandParameter);
     $button->setCausesValidation(false);
     $button->getAdapter()->getBaseActiveControl()->setClientSide($pager->getClientSide());
     return $button;
 }
コード例 #6
0
ファイル: TActiveLabel.php プロジェクト: pradosoft/prado
 /**
  * Adds attribute id to the renderer.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 protected function addAttributesToRender($writer)
 {
     $writer->addAttribute('id', $this->getClientID());
     parent::addAttributesToRender($writer);
 }
コード例 #7
0
ファイル: TActivePager.php プロジェクト: pradosoft/prado
 /**
  * Creates a pager button.
  * Override parent implementation to create, depending on the button type, a TActiveLinkButton,
  * a TActiveButton or a TActiveImageButton may be created.
  *
  * @param string button type, either LinkButton or PushButton
  * @param boolean whether the button should be enabled
  * @param string caption of the button
  * @param string CommandName corresponding to the OnCommand event of the button
  * @param string CommandParameter corresponding to the OnCommand event of the button
  * @return mixed the button instance
  */
 protected function createPagerButton($buttonType, $enabled, $text, $commandName, $commandParameter)
 {
     if ($buttonType === TPagerButtonType::LinkButton) {
         if ($enabled) {
             $button = new TActiveLinkButton();
         } else {
             $button = new TLabel();
             $button->setText($text);
             $button->setCssClass($this->getButtonCssClass());
             return $button;
         }
     } else {
         if ($buttonType === TPagerButtonType::ImageButton) {
             $button = new TActiveImageButton();
             $button->setImageUrl($this->getPageImageUrl($text, $commandName));
             if ($enabled) {
                 $button->Visible = true;
             } else {
                 $button->Visible = false;
             }
         } else {
             $button = new TActiveButton();
             if (!$enabled) {
                 $button->setEnabled(false);
             }
         }
     }
     if ($buttonType === TPagerButtonType::ImageButton) {
         $button->ImageUrl = $text;
     }
     $button->setText($text);
     $button->setCommandName($commandName);
     $button->setCommandParameter($commandParameter);
     $button->setCausesValidation(false);
     $button->setCssClass($this->getButtonCssClass());
     $button->attachEventHandler('OnCallback', array($this, 'handleCallback'));
     $button->getAdapter()->getBaseActiveControl()->setClientSide($this->getClientSide());
     return $button;
 }