original_string: protected function _showText($caption, $logFile, $emptyLabel = null, $context = null)
      {
          $this->html->h2($caption);
  
          if ($emptyLabel && (1 == $this->_getParam(\MUtil_Model::REQUEST_ID)) && file_exists($logFile)) {
              unlink($logFile);
          }
  
          if (file_exists($logFile)) {
              if (is_readable($logFile)) {
                  $content = trim(file_get_contents($logFile));
  
                  if ($content) {
                      $error = false;
                  } else {
                      $error = $this->_('empty file');
                  }
              } else {
                  $error = $this->_('file content not readable');
              }
          } else {
              $content = null;
              $error   = $this->_('file not found');
          }
  
          if ($emptyLabel) {
              $buttons = $this->html->buttonDiv();
              if ($error) {
                  $buttons->actionDisabled($emptyLabel);
              } else {
                  $buttons->actionLink(array(\MUtil_Model::REQUEST_ID => 1), $emptyLabel);
              }
          }
  
          if ($error) {
              $this->html->pre($error, array('class' => 'disabled logFile'));
          } elseif (substr($logFile, -3) == '.md') {            
              $parseDown = new \Gems\Parsedown($context);
              $this->html->div(array('class'=>'logFile'))->raw($parseDown->parse($content));
          } else {
              $this->html->pre($content, array('class' => 'logFile'));
          }
  
          if ($emptyLabel) {
              // Buttons at both bottom and top.
              $this->html[] = $buttons;
          }
      }
code: protected function _showText($caption, $logFile, $emptyLabel = null, $context = null)
      {
          $this->html->h2($caption);
  
          if ($emptyLabel && (1 == $this->_getParam(\MUtil_Model::REQUEST_ID)) && file_exists($logFile)) {
              unlink($logFile);
          }
  
          if (file_exists($logFile)) {
              if (is_readable($logFile)) {
                  $content = trim(file_get_contents($logFile));
  
                  if ($content) {
                      $error = false;
                  } else {
                      $error = $this->_('empty file');
                  }
              } else {
                  $error = $this->_('file content not readable');
              }
          } else {
              $content = null;
              $error   = $this->_('file not found');
          }
  
          if ($emptyLabel) {
              $buttons = $this->html->buttonDiv();
              if ($error) {
                  $buttons->actionDisabled($emptyLabel);
              } else {
                  $buttons->actionLink(array(\MUtil_Model::REQUEST_ID => 1), $emptyLabel);
              }
          }
  
          if ($error) {
              $this->html->pre($error, array('class' => 'disabled logFile'));
          } elseif (substr($logFile, -3) == '.md') {            
              $parseDown = new \Gems\Parsedown($context);
              $this->html->div(array('class'=>'logFile'))->raw($parseDown->parse($content));
          } else {
              $this->html->pre($content, array('class' => 'logFile'));
          }
  
          if ($emptyLabel) {
              // Buttons at both bottom and top.
              $this->html[] = $buttons;
          }
      }
code_tokens: protected function _showText ( $ caption , $ logFile , $ emptyLabel = null , $ context = null ) { $ this -> html -> h2 ( $ caption ) ; if ( $ emptyLabel && ( 1 == $ this -> _getParam ( \ MUtil_Model :: REQUEST_ID ) ) && file_exists ( $ logFile ) ) { unlink ( $ logFile ) ; } if ( file_exists ( $ logFile ) ) { if ( is_readable ( $ logFile ) ) { $ content = trim ( file_get_contents ( $ logFile ) ) ; if ( $ content ) { $ error = false ; } else { $ error = $ this -> _ ( 'empty file' ) ; } } else { $ error = $ this -> _ ( 'file content not readable' ) ; } } else { $ content = null ; $ error = $ this -> _ ( 'file not found' ) ; } if ( $ emptyLabel ) { $ buttons = $ this -> html -> buttonDiv ( ) ; if ( $ error ) { $ buttons -> actionDisabled ( $ emptyLabel ) ; } else { $ buttons -> actionLink ( array ( \ MUtil_Model :: REQUEST_ID => 1 ) , $ emptyLabel ) ; } } if ( $ error ) { $ this -> html -> pre ( $ error , array ( 'class' => 'disabled logFile' ) ) ; } elseif ( substr ( $ logFile , - 3 ) == '.md' ) { $ parseDown = new \ Gems \ Parsedown ( $ context ) ; $ this -> html -> div ( array ( 'class' => 'logFile' ) ) -> raw ( $ parseDown -> parse ( $ content ) ) ; } else { $ this -> html -> pre ( $ content , array ( 'class' => 'logFile' ) ) ; } if ( $ emptyLabel ) { // Buttons at both bottom and top. $ this -> html [ ] = $ buttons ; } }
docstring: Helper function to show content of a text file
  
  @param string $caption
  @param string $logFile
  @param string $emptyLabel
docstring_tokens: Helper function to show content of a text file