<?php if (!defined('APPLICATION')) { exit; } $Message = $this->_Message; if (is_array($Message)) { echo '<div class="DismissMessage' . ($Message['CssClass'] == '' ? '' : ' ' . $Message['CssClass']) . '">'; $Session = Gdn::Session(); if ($Message['AllowDismiss'] == '1' && $Session->IsValid()) { echo Anchor('×', "/dashboard/message/dismiss/{$Message['MessageID']}/" . $Session->TransientKey() . '?Target=' . $this->_Sender->SelfUrl, 'Dismiss'); } // echo Gdn_Format::To($this->_Message->Content, 'Html'); echo nl2br(Gdn_Format::Links($Message['Content'])); echo '</div>'; }
/** * Format a string using Markdown syntax. Also purifies the output html. * * @param mixed $Mixed An object, array, or string to be formatted. * @return string */ public static function Markdown($Mixed) { if (!is_string($Mixed)) { return self::To($Mixed, 'Markdown'); } else { $Formatter = Gdn::Factory('HtmlFormatter'); if (is_null($Formatter)) { return Gdn_Format::Display($Mixed); } else { require_once PATH_LIBRARY . DS . 'vendors' . DS . 'markdown' . DS . 'markdown.php'; $Mixed = Markdown($Mixed); $Mixed = Gdn_Format::Links($Mixed); $Mixed = Gdn_Format::Mentions($Mixed); return $Formatter->Format($Mixed); } } }
<?php if (!defined('APPLICATION')) { exit; } ?> <h1><?php echo $this->Data('Title'); ?> </h1> <div class="padded"> A site map is an <a href="http://en.wikipedia.org/wiki/XML">xml</a> file that search engines can use to help index your site. <ul> <li>Your main site map is located here: <?php echo Gdn_Format::Links(Url('/sitemapindex.xml', TRUE)); ?> .</li> <li>Your <?php echo Anchor('robots.txt', Url('/robots.txt', TRUE)); ?> file contains the location of this site map so that search engines that are aware of your site will know where to look.</li> </ul> </div> <div class="alert alert-info"> <?php echo '<p>', sprintf(t('Learm more about %s from the following sites:'), t('sitemaps')), '</p>'; echo '<ul>'; echo '<li>', Anchor('sitemaps.org', 'http://www.sitemaps.org/'), '</li>'; echo '<li>', Anchor('Google webmaster center', 'http://www.google.com/webmasters/'), '</li>'; echo '</ul>'; ?>
public static function Wysiwyg($Mixed) { static $CustomFormatter; if (!isset($CustomFormatter)) { $CustomFormatter = C('Garden.Format.WysiwygFunction', FALSE); } if (!is_string($Mixed)) { return self::To($Mixed, 'Wysiwyg'); } elseif (is_callable($CustomFormatter)) { return $CustomFormatter($Mixed); } else { // The text contains html and must be purified. $Formatter = Gdn::Factory('HtmlFormatter'); if (is_null($Formatter)) { // If there is no HtmlFormatter then make sure that script injections won't work. return self::Display($Mixed); } // HTML filter first $Mixed = $Formatter->Format($Mixed); // Links $Mixed = Gdn_Format::Links($Mixed); // Mentions & Hashes $Mixed = Gdn_Format::Mentions($Mixed); $Mixed = Emoji::instance()->translateToHtml($Mixed); return $Mixed; } }
/** * Display custom fields on Profile. */ public function UserInfoModule_OnBasicInfo_Handler($Sender) { try { // Get the custom fields $ProfileFields = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Profile.%', 'Profile.'); // Import from CustomProfileFields if available if (!count($ProfileFields) && is_object($Sender->User) && C('Plugins.CustomProfileFields.SuggestedFields', FALSE)) { $ProfileFields = Gdn::UserModel()->GetAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); if ($ProfileFields) { // Migrate to UserMeta & delete original Gdn::UserModel()->SetMeta($Sender->User->UserID, $ProfileFields, 'Profile.'); Gdn::UserModel()->SaveAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); } } // Send them off for magic formatting $ProfileFields = $this->ParseSpecialFields($ProfileFields); // Get all field data, error check $AllFields = $this->GetProfileFields(); if (!is_array($AllFields) || !is_array($ProfileFields)) { return; } // DateOfBirth is special case that core won't handle // Hack it in here instead if (C('ProfileExtender.Fields.DateOfBirth.OnProfile')) { // Do not use Gdn_Format::Date because it shifts to local timezone $ProfileFields['DateOfBirth'] = date(T('Birthday Format', 'F j, Y'), Gdn_Format::ToTimestamp($Sender->User->DateOfBirth)); $AllFields['DateOfBirth'] = array('Label' => T('Birthday'), 'OnProfile' => TRUE); } // Display all non-hidden fields $ProfileFields = array_reverse($ProfileFields); foreach ($ProfileFields as $Name => $Value) { if (!$Value) { continue; } if (!GetValue('OnProfile', $AllFields[$Name])) { continue; } // Non-magic fields must be plain text, but we'll auto-link if (!in_array($Name, $this->MagicLabels)) { $Value = Gdn_Format::Links(Gdn_Format::Text($Value)); } echo ' <dt class="ProfileExtend Profile' . Gdn_Format::AlphaNumeric($Name) . '">' . Gdn_Format::Text($AllFields[$Name]['Label']) . '</dt> '; echo ' <dd class="ProfileExtend Profile' . Gdn_Format::AlphaNumeric($Name) . '">' . Gdn_Format::Html($Value) . '</dd> '; } } catch (Exception $ex) { // No errors } }
/** * Takes a mixed variable, filters unsafe html and returns it. * * @param mixed $Mixed An object, array, or string to be formatted. * @return string */ public static function Html($Mixed) { if (!is_string($Mixed)) { return self::To($Mixed, 'Html'); } else { $IsHtml = strpos($Mixed, '<') !== FALSE || (bool) preg_match('/&#?[a-z0-9]{1,10};/i', $Mixed); if ($IsHtml) { // The text contains html and must be purified. $Formatter = Gdn::Factory('HtmlFormatter'); if (is_null($Formatter)) { // If there is no HtmlFormatter then make sure that script injections won't work. return self::Display($Mixed); } // Allow the code tag to keep all enclosed html encoded. $Mixed = preg_replace(array('/<code([^>]*)>(.+?)<\\/code>/sei'), array('\'<code\'.RemoveQuoteSlashes(\'\\1\').\'>\'.htmlspecialchars(RemoveQuoteSlashes(\'\\2\')).\'</code>\''), $Mixed); // Links $Mixed = Gdn_Format::Links($Mixed); // Mentions & Hashes $Mixed = Gdn_Format::Mentions($Mixed); // nl2br $Mixed = preg_replace("/(\r\n)|(\r)|(\n)/", "<br />", $Mixed); $Result = $Formatter->Format($Mixed); // $Result = $Result. // "<h3>Html</h3><pre>".nl2br(htmlspecialchars(str_replace("<br />", "\n", $Mixed)))."</pre>". // "<h3>Formatted</h3><pre>".nl2br(htmlspecialchars(str_replace("<br />", "\n", $Result)))."</pre>"; } else { // The text does not contain text and does not have to be purified. // This is an optimization because purifying is very slow and memory intense. $Result = htmlspecialchars($Mixed); $Result = Gdn_Format::Mentions($Result); $Result = Gdn_Format::Links($Result); $Result = preg_replace("/(\r\n)|(\r)|(\n)/", "<br />", $Result); } return $Result; } }
/** * Display custom fields on Profile. */ public function UserInfoModule_OnBasicInfo_Handler($Sender) { try { // Get the custom fields $ProfileFields = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Profile.%', 'Profile.'); // Import from CustomProfileFields if available if (!count($ProfileFields) && is_object($Sender->User) && C('Plugins.CustomProfileFields.SuggestedFields', FALSE)) { $ProfileFields = Gdn::UserModel()->GetAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); if ($ProfileFields) { // Migrate to UserMeta & delete original Gdn::UserModel()->SetMeta($Sender->User->UserID, $ProfileFields, 'Profile.'); Gdn::UserModel()->SaveAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); } } // Send them off for magic formatting $ProfileFields = $this->ParseSpecialFields($ProfileFields); // Get all field data, error check $AllFields = $this->GetProfileFields(); if (!is_array($AllFields) || !is_array($ProfileFields)) { return; } // Display all non-hidden fields $ProfileFields = array_reverse($ProfileFields); foreach ($ProfileFields as $Name => $Value) { if (!$Value) { continue; } if (!GetValue('OnProfile', $AllFields[$Name])) { continue; } if (!in_array($Name, $this->MagicLabels)) { $Value = Gdn_Format::Links(htmlspecialchars($Value)); } echo ' <dt class="ProfileExtend Profile' . Gdn_Format::AlphaNumeric($Name) . '">' . Gdn_Format::Text($AllFields[$Name]['Label']) . '</dt> '; echo ' <dd class="ProfileExtend Profile' . Gdn_Format::AlphaNumeric($Name) . '">' . $Value . '</dd> '; } } catch (Exception $ex) { // No errors } }
/** * Display custom fields on Profile. */ public function UserInfoModule_OnBasicInfo_Handler($Sender) { try { // Get the custom fields $Fields = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Profile.%', 'Profile.'); // Reorder the custom fields // Use order of Plugins.ProfileExtender.ProfileFields first $Listed = $this->GetFields('Profile'); $Fields1 = array(); foreach ($Listed as $FieldName) { if (isset($Fields[$FieldName])) { $Fields1[$FieldName] = $Fields[$FieldName]; } } // Then append the user's arbitrary custom fields (if they have any) alphabetically by label $Fields2 = array_diff_key($Fields, $Listed); ksort($Fields2); $Fields = array_merge($Fields1, $Fields2); // Import from CustomProfileFields if available if (!count($Fields) && is_object($Sender->User) && C('Plugins.CustomProfileFields.SuggestedFields', FALSE)) { $Fields = Gdn::UserModel()->GetAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); if ($Fields) { // Migrate to UserMeta & delete original Gdn::UserModel()->SetMeta($Sender->User->UserID, $Fields, 'Profile.'); Gdn::UserModel()->SaveAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); } } // Send them off for magic formatting $Fields = $this->ParseSpecialFields($Fields); // Display all non-hidden fields $HideFields = $this->GetFields('Hide'); foreach ($Fields as $Label => $Value) { if (in_array($Label, $HideFields)) { continue; } if (!in_array($Label, $this->MagicLabels)) { $Value = Gdn_Format::Links(htmlspecialchars($Value)); } echo ' <dt class="ProfileExtend Profile' . Gdn_Format::AlphaNumeric($Label) . '">' . Gdn_Format::Text($Label) . '</dt> '; echo ' <dd class="ProfileExtend Profile' . Gdn_Format::AlphaNumeric($Label) . '">' . $Value . '</dd> '; } } catch (Exception $ex) { // No errors } }