Gdn_Format::display PHP Method

display() public static method

Takes a mixed variable, formats it for display on the screen, and returns it.
public static display ( mixed $Mixed ) : string
$Mixed mixed An object, array, or string to be formatted.
return string
    public static function display($Mixed)
    {
        if (!is_string($Mixed)) {
            return self::to($Mixed, 'Display');
        } else {
            $Mixed = htmlspecialchars($Mixed, ENT_QUOTES, 'UTF-8');
            $Mixed = str_replace(array(""", "&"), array('"', '&'), $Mixed);
            $Mixed = Gdn_Format::processHTML($Mixed);
            return $Mixed;
        }
    }

Usage Example

示例#1
0
 /**
  * Format the content of a log file.
  *
  * @param array $Log The log entry to format.
  * @return string Returns the formatted log entry.
  */
 public function formatContent($Log)
 {
     $Data = $Log['Data'];
     // TODO: Check for a custom log type handler.
     switch ($Log['RecordType']) {
         case 'Activity':
             $Result = $this->formatKey('Story', $Data);
             break;
         case 'Discussion':
             $Result = '<b>' . $this->formatKey('Name', $Data) . '</b><br />' . $this->formatKey('Body', $Data);
             break;
         case 'ActivityComment':
         case 'Comment':
             $Result = $this->formatKey('Body', $Data);
             break;
         case 'Configuration':
             $Result = $this->formatConfiguration($Data);
             break;
         case 'Registration':
         case 'User':
             $Result = $this->formatRecord(['Email', 'Name'], $Data);
             if ($DiscoveryText = val('DiscoveryText', $Data)) {
                 $Result .= '<br /><b>' . t('Why do you want to join?') . '</b><br />' . Gdn_Format::display($DiscoveryText);
             }
             if (val('Banned', $Data)) {
                 $Result .= "<br />" . t('Banned');
             }
             break;
         default:
             $Result = '';
     }
     return $Result;
 }
All Usage Examples Of Gdn_Format::display