本文整理汇总了PHP中Gdn_Format::Text方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::Text方法的具体用法?PHP Gdn_Format::Text怎么用?PHP Gdn_Format::Text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Format
的用法示例。
在下文中一共展示了Gdn_Format::Text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DiscussionController_Render_Before
public function DiscussionController_Render_Before(&$Sender) {
$Sender->Head->AddTag('meta', array('content' => Gdn_Format::Text($Sender->Discussion->Name), 'property' => 'og:title'));
$Sender->Head->AddTag('meta', array('content' => Gdn_Url::Request(true, true, true), 'property' => 'og:url'));
$Sender->Head->AddTag('meta', array('content' => C('Garden.Title'), 'property' => 'og:site_name'));
$Sender->Head->AddTag('meta', array('content' => 'article', 'property' => 'og:type'));
$Sender->addJsFile('http://connect.facebook.net/en_US/all.js#xfbml=1');
}
示例2: Index
public function Index($Offset = 0, $Limit = NULL)
{
$this->AddJsFile('/js/library/jquery.gardenmorepager.js');
$this->AddJsFile('search.js');
$this->Title(T('Search'));
if (!is_numeric($Limit)) {
$Limit = Gdn::Config('Garden.Search.PerPage', 20);
}
$Search = $this->Form->GetFormValue('Search');
$ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
$this->SetData('SearchResults', $ResultSet, TRUE);
$this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
if ($ResultSet) {
$NumResults = $ResultSet->NumRows();
} else {
$NumResults = 0;
}
if ($NumResults == $Offset + $Limit) {
$NumResults++;
}
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$Pager = $PagerFactory->GetPager('MorePager', $this);
$Pager->MoreCode = 'More Results';
$Pager->LessCode = 'Previous Results';
$Pager->ClientID = 'Pager';
$Pager->Configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::Url($Search));
$this->SetData('Pager', $Pager, TRUE);
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
$this->View = 'results';
}
$this->Render();
}
示例3: WriteModuleDiscussion
function WriteModuleDiscussion($Discussion, $Px = 'Bookmark')
{
?>
<li id="<?php
echo "{$Px}_{$Discussion->DiscussionID}";
?>
" class="<?php
echo CssClass($Discussion);
?>
">
<span class="Options">
<?php
// echo OptionsList($Discussion);
echo BookmarkButton($Discussion);
?>
</span>
<div class="Title"><?php
echo Anchor(Gdn_Format::Text($Discussion->Name, FALSE), DiscussionUrl($Discussion) . ($Discussion->CountCommentWatch > 0 ? '#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink');
?>
</div>
<div class="Meta">
<?php
$Last = new stdClass();
$Last->UserID = $Discussion->LastUserID;
$Last->Name = $Discussion->LastName;
echo NewComments($Discussion);
echo '<span class="MItem">' . Gdn_Format::Date($Discussion->LastDate, 'html') . UserAnchor($Last) . '</span>';
?>
</div>
</li>
<?php
}
示例4: WriteDiscussion
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt)
{
$CssClass = 'Item';
$CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
$CssClass .= $Alt . ' ';
$CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
$CssClass .= $Discussion->Closed == '1' ? ' Closed' : '';
$CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
$CssClass .= $Discussion->CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
$Sender->EventArguments['Discussion'] =& $Discussion;
$Sender->FireEvent('BeforeDiscussionName');
$DiscussionName = Gdn_Format::Text($Discussion->Name);
if ($DiscussionName == '') {
$DiscussionName = T('Blank Discussion Topic');
}
static $FirstDiscussion = TRUE;
if (!$FirstDiscussion) {
$Sender->FireEvent('BetweenDiscussion');
} else {
$FirstDiscussion = FALSE;
}
?>
<li class="<?php
echo $CssClass;
?>
">
<?php
if ($Discussion->FirstPhoto != '') {
if (strtolower(substr($Discussion->FirstPhoto, 0, 7)) == 'http://' || strtolower(substr($Discussion->FirstPhoto, 0, 8)) == 'https://') {
$PhotoUrl = $Discussion->FirstPhoto;
} else {
$PhotoUrl = 'uploads/' . ChangeBasename($Discussion->FirstPhoto, 'n%s');
}
echo Img($PhotoUrl, array('alt' => $Discussion->FirstName));
}
?>
<div class="ItemContent Discussion">
<?php
echo Anchor($DiscussionName, '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'Title');
?>
<?php
$Sender->FireEvent('AfterDiscussionTitle');
?>
<div class="Meta">
<span class="Author"><?php
echo $Discussion->FirstName;
?>
</span>
<?php
echo '<span class="Counts' . ($Discussion->CountUnreadComments > 0 ? ' NewCounts' : '') . '">' . ($Discussion->CountUnreadComments > 0 ? $Discussion->CountUnreadComments . '/' : '') . $Discussion->CountComments . '</span>';
if ($Discussion->LastCommentID != '') {
echo '<span class="LastCommentBy">' . sprintf(T('Latest %1$s'), $Discussion->LastName) . '</span> ';
}
echo '<span class="LastCommentDate">' . Gdn_Format::Date($Discussion->FirstDate) . '</span> ';
?>
</div>
</div>
</li>
<?php
}
示例5: FormatKey
public function FormatKey($Key, $Data) {
if (isset($Data['_New']) && isset($Data['_New'][$Key])) {
$Old = Gdn_Format::Text(GetValue($Key, $Data, ''), FALSE);
$New = Gdn_Format::Text($Data['_New'][$Key], FALSE);
$Result = $this->FormatDiff($Old, $New);
} else {
$Result = Gdn_Format::Text(GetValue($Key, $Data, ''), FALSE);
}
return nl2br(trim(($Result)));
}
示例6: xHtml
function xHtml($String)
{
$HtmlFormatter = Gdn::Factory('HtmlFormatter');
if ($HtmlFormatter) {
$String = $HtmlFormatter->Format($String);
} else {
$String = Gdn_Format::Text($String);
}
return $String;
}
示例7: Index
public function Index($Offset = 0, $Limit = NULL) {
$this->AddJsFile('jquery.gardenmorepager.js');
$this->AddJsFile('search.js');
$this->Title(T('Search'));
if(!is_numeric($Limit))
$Limit = Gdn::Config('Garden.Search.PerPage', 20);
$Search = $this->Form->GetFormValue('Search');
$Mode = $this->Form->GetFormValue('Mode');
if ($Mode)
$this->SearchModel->ForceSearchMode = $Mode;
try {
$ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
} catch (Gdn_UserException $Ex) {
$this->Form->AddError($Ex);
$ResultSet = array();
} catch (Exception $Ex) {
$ResultSet = array();
}
$this->SetData('SearchResults', $ResultSet, TRUE);
$this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
if($ResultSet)
$NumResults = count($ResultSet);
else
$NumResults = 0;
if ($NumResults == $Offset + $Limit)
$NumResults++;
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('MorePager', $this);
$this->Pager->MoreCode = 'More Results';
$this->Pager->LessCode = 'Previous Results';
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure(
$Offset,
$Limit,
$NumResults,
'dashboard/search/%1$s/%2$s/?Search='.Gdn_Format::Url($Search)
);
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
$this->View = 'results';
}
$this->CanonicalUrl(Url('search', TRUE));
$this->Render();
}
示例8: ToString
public function ToString()
{
echo '<div class="Box DonateBox">';
echo Wrap(T('Donation Box'), 'h4');
echo '<ul class="PanelInfo">';
echo '<p></p>';
echo T("Your Donations will help keep this forum afloat");
echo '<p></p>';
echo Anchor(Gdn_Format::Text("My donation link"), Gdn_Format::Url("/donations"));
// edit the links above to the appropriate paypal or whatever donate links and image
echo Wrap(T('Item 1'), 'li');
echo Wrap(T('Item 2'), 'li');
echo "</ul>";
echo "</div>";
}
示例9: WriteDiscussionEvent
function WriteDiscussionEvent($Discussion, $Prefix = null)
{
?>
<li class="<?php
echo CssClass($Discussion);
?>
">
<div class="Title">
<?php
echo Anchor(Gdn_Format::Text($Discussion->Name, false), DiscussionUrl($Discussion) . ($Discussion->CountCommentWatch > 0 ? '#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink');
?>
</div><div class="Meta"><span class="MItem">
<?php
echo Gdn_Format::Date($Discussion->DiscussionEventDate, 'html');
?>
</span></div>
</li>
<?php
}
示例10: ProfileController_AfterUserInfo_Handler
public function ProfileController_AfterUserInfo_Handler($Sender)
{
if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage') || $Sender->User->UserID == Gdn::Session()->User->UserID) {
$Warnings = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Warnings.%', 'Warnings.', array());
krsort($Warnings);
$History = False;
echo '<div class="Warnings">';
echo Wrap(T('Warning.Warnings', 'Warnings'), 'h2', array('class' => 'H'));
foreach ($Warnings as $Date => $Warning) {
$Warning = Gdn_Format::Unserialize($Warning);
$Reason = '';
if (is_array($Warning)) {
$Reason = $Warning['Reason'];
$Warning = $Warning['Type'];
}
if ($History && $Warning != 'None') {
$WarningClass = "{$Warning} Historical";
} else {
$WarningClass = $Warning;
}
if (!$History && $Warning == 'None') {
echo '<div class="NoWarning">' . T('Warning.NoWarnings', 'There are no current warnings for this user. ') . '</div>';
}
echo '<div class="Warn ' . $WarningClass . '">' . T('Warning.Level.' . $Warning, $Warning) . '<span class="WarningDate">' . Gdn_Format::Date($Date) . '</span></div>';
if ($Reason) {
echo '<div class="WarningReason ' . $WarningClass . '">' . Gdn_Format::Text($Reason) . '</div>';
}
$History = True;
}
if (count($Warnings) == 0) {
echo '<div class="NoWarning">' . T('Warning.NoWarnings', 'There are no current warnings for this user. ') . '</div>';
}
if (count($Warnings) > 1) {
echo '<a class="WarningTogggleHistory" href="#">' . T('Warning.ToggleHistory', 'Toggle History') . '</a>';
}
echo '</div>';
}
}
示例11: Search
public function Search($Search, $Offset = 0, $Limit = 20)
{
// If there are no searches then return an empty array.
if (trim($Search) == '') {
return array();
}
// Figure out the exact search mode.
if ($this->ForceSearchMode) {
$SearchMode = $this->ForceSearchMode;
} else {
$SearchMode = strtolower(C('Garden.Search.Mode', 'matchboolean'));
}
if ($SearchMode == 'matchboolean') {
if (strpos($Search, '+') !== FALSE || strpos($Search, '-') !== FALSE) {
$SearchMode = 'boolean';
} else {
$SearchMode = 'match';
}
} else {
$this->_SearchMode = $SearchMode;
}
if ($ForceDatabaseEngine = C('Database.ForceStorageEngine')) {
if (strcasecmp($ForceDatabaseEngine, 'myisam') != 0) {
$SearchMode = 'like';
}
}
$this->_SearchMode = $SearchMode;
$this->FireEvent('Search');
if (count($this->_SearchSql) == 0) {
return array();
}
// Perform the search by unioning all of the sql together.
$Sql = $this->SQL->Select()->From('_TBL_ s')->OrderBy('s.DateInserted', 'desc')->Limit($Limit, $Offset)->GetSelect();
$Sql = str_replace($this->Database->DatabasePrefix . '_TBL_', "(\n" . implode("\nunion all\n", $this->_SearchSql) . "\n)", $Sql);
$this->EventArguments['Search'] = $Search;
$this->FireEvent('AfterBuildSearchQuery');
if ($this->_SearchMode == 'like') {
$Search = '%' . $Search . '%';
}
foreach ($this->_Parameters as $Key => $Value) {
$this->_Parameters[$Key] = $Search;
}
$Parameters = $this->_Parameters;
$this->Reset();
$this->SQL->Reset();
$Result = $this->Database->Query($Sql, $Parameters)->ResultArray();
foreach ($Result as $Key => $Value) {
if (isset($Value['Summary'])) {
$Value['Summary'] = Gdn_Format::Text(Gdn_Format::To($Value['Summary'], $Value['Format']));
$Result[$Key] = $Value;
}
}
return $Result;
}
示例12: Search
public function Search($Search, $Offset = 0, $Limit = 20)
{
$AllSettings = SphinxFactory::BuildSettings();
$Settings = $AllSettings->GetAllSettings();
// if (($Settings['Status']->SearchdRunning == 1) && ($Settings['Status']->EnableSphinxSearch == 1))
if (true) {
// Force this to be true while the sphinxsearch plugin is enabled!
return FALSE;
} else {
// If there are no searches then return an empty array.
if (trim($Search) == '') {
return array();
}
// Figure out the exact search mode.
if ($this->ForceSearchMode) {
$SearchMode = $this->ForceSearchMode;
} else {
$SearchMode = strtolower(C('Garden.Search.Mode', 'matchboolean'));
}
if ($SearchMode == 'matchboolean') {
if (strpos($Search, '+') !== FALSE || strpos($Search, '-') !== FALSE) {
$SearchMode = 'boolean';
} else {
$SearchMode = 'match';
}
} else {
$this->_SearchMode = $SearchMode;
}
$this->_SearchMode = $SearchMode;
$this->FireEvent('Search');
//print_r($this->_SearchSql);
if (count($this->_SearchSql) == 0) {
return array();
}
// Perform the search by unioning all of the sql together.
$Sql = $this->SQL->Select()->From('_TBL_ s')->OrderBy('s.DateInserted', 'desc')->Limit($Limit, $Offset)->GetSelect();
$Sql = str_replace($this->Database->DatabasePrefix . '_TBL_', "(\n" . implode("\nunion all\n", $this->_SearchSql) . "\n)", $Sql);
$this->EventArguments['Search'] = $Search;
$this->FireEvent('AfterBuildSearchQuery');
if ($this->_SearchMode == 'like') {
$Search = '%' . $Search . '%';
}
foreach ($this->_Parameters as $Key => $Value) {
$this->_Parameters[$Key] = $Search;
}
$Result = $this->Database->Query($Sql, $this->_Parameters)->ResultArray();
$this->Reset();
$this->SQL->Reset();
foreach ($Result as $Key => $Value) {
if (isset($Value['Summary'])) {
$Value['Summary'] = Gdn_Format::Text(Gdn_Format::To($Value['Summary'], $Value['Format']));
$Result[$Key] = $Value;
}
}
return $Result;
}
}
示例13: ModerationController_SplitComments_Create
/**
* Add a method to the ModerationController to handle splitting comments out to a new discussion.
*/
public function ModerationController_SplitComments_Create($Sender)
{
$Session = Gdn::Session();
$Sender->Form = new Gdn_Form();
$Sender->Title(T('Split Comments'));
$Sender->Category = FALSE;
$DiscussionID = GetValue('0', $Sender->RequestArgs, '');
if (!is_numeric($DiscussionID)) {
return;
}
$DiscussionModel = new DiscussionModel();
$Discussion = $DiscussionModel->GetID($DiscussionID);
if (!$Discussion) {
return;
}
// Verify that the user has permission to perform the split
$Sender->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID);
$CheckedComments = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedComments', array());
if (!is_array($CheckedComments)) {
$CheckedComments = array();
}
$CommentIDs = array();
foreach ($CheckedComments as $DiscID => $Comments) {
foreach ($Comments as $Comment) {
if ($DiscID == $DiscussionID) {
$CommentIDs[] = str_replace('Comment_', '', $Comment);
}
}
}
// Load category data.
$Sender->ShowCategorySelector = (bool) C('Vanilla.Categories.Use');
$CountCheckedComments = count($CommentIDs);
$Sender->SetData('CountCheckedComments', $CountCheckedComments);
// Perform the split
if ($Sender->Form->AuthenticatedPostBack()) {
// Create a new discussion record
$Data = $Sender->Form->FormValues();
$Data['Body'] = sprintf(T('This discussion was created from comments split from: %s.'), Anchor(Gdn_Format::Text($Discussion->Name), 'discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . '/'));
$Data['Format'] = 'Html';
$Data['Type'] = 'Discussion';
$NewDiscussionID = $DiscussionModel->Save($Data);
$Sender->Form->SetValidationResults($DiscussionModel->ValidationResults());
if ($Sender->Form->ErrorCount() == 0 && $NewDiscussionID > 0) {
// Re-assign the comments to the new discussion record
$DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $NewDiscussionID)->WhereIn('CommentID', $CommentIDs)->Put();
// Update counts on both discussions
$CommentModel = new CommentModel();
$CommentModel->UpdateCommentCount($DiscussionID);
// $CommentModel->UpdateUserCommentCounts($DiscussionID);
$CommentModel->UpdateCommentCount($NewDiscussionID);
$CommentModel->RemovePageCache($DiscussionID, 1);
// Clear selections
unset($CheckedComments[$DiscussionID]);
Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedComments', $CheckedComments);
ModerationController::InformCheckedComments($Sender);
$Sender->RedirectUrl = Url('discussion/' . $NewDiscussionID . '/' . Gdn_Format::Url($Data['Name']));
}
} else {
$Sender->Form->SetValue('CategoryID', GetValue('CategoryID', $Discussion));
}
$Sender->Render($this->GetView('splitcomments.php'));
}
示例14: T
<?php
if (!defined('APPLICATION')) {
exit;
}
?>
<li class="SteamProfile">
<?php
echo $Sender->Form->Label('Steam Profile');
// Do we happen to already have a Steam ID for our current user?
if ($Sender->Data('SteamID64')) {
// If so, we just output it. Nothing fancy.
echo '<div>' . T('Steam ID') . ': ' . Gdn_Format::Text($Sender->Data('SteamID64')) . '</div>';
} else {
// If not, we drop in a button and set the stage for OpenID magic.
echo Anchor(Img('plugins/steamprofile/design/images/sits_small.png', array('alt' => 'Sign in through Steam')), $Sender->Data('SteamAuthenticationUrl'), '', array('title' => 'Sign in through Steam'));
}
?>
</li>
示例15: RegisterApproval
/**
* Registration that requires approval.
*
* Events: RegistrationPending
*
* @access private
* @since 2.0.0
*/
private function RegisterApproval()
{
Gdn::UserModel()->AddPasswordStrength($this);
// If the form has been posted back...
if ($this->Form->IsPostBack()) {
// Add validation rules that are not enforced by the model
$this->UserModel->DefineSchema();
$this->UserModel->Validation->ApplyRule('Name', 'Username', $this->UsernameError);
$this->UserModel->Validation->ApplyRule('TermsOfService', 'Required', T('You must agree to the terms of service.'));
$this->UserModel->Validation->ApplyRule('Password', 'Required');
$this->UserModel->Validation->ApplyRule('Password', 'Strength');
$this->UserModel->Validation->ApplyRule('Password', 'Match');
$this->UserModel->Validation->ApplyRule('DiscoveryText', 'Required', 'Tell us why you want to join!');
// $this->UserModel->Validation->ApplyRule('DateOfBirth', 'MinimumAge');
$this->FireEvent('RegisterValidation');
try {
$Values = $this->Form->FormValues();
unset($Values['Roles']);
$AuthUserID = $this->UserModel->Register($Values);
if (!$AuthUserID) {
$this->Form->SetValidationResults($this->UserModel->ValidationResults());
} else {
// The user has been created successfully, so sign in now.
Gdn::Session()->Start($AuthUserID);
if ($this->Form->GetFormValue('RememberMe')) {
Gdn::Authenticator()->SetIdentity($AuthUserID, TRUE);
}
// Notification text
$Label = T('NewApplicantEmail', 'New applicant:');
$Story = Anchor(Gdn_Format::Text($Label . ' ' . $Values['Name']), ExternalUrl('dashboard/user/applicants'));
$this->EventArguments['AuthUserID'] = $AuthUserID;
$this->EventArguments['Story'] =& $Story;
$this->FireEvent('RegistrationPending');
$this->View = "RegisterThanks";
// Tell the user their application will be reviewed by an administrator.
// Grab all of the users that need to be notified.
$Data = Gdn::Database()->SQL()->GetWhere('UserMeta', array('Name' => 'Preferences.Email.Applicant'))->ResultArray();
$ActivityModel = new ActivityModel();
foreach ($Data as $Row) {
$ActivityModel->Add($AuthUserID, 'Applicant', $Story, $Row['UserID'], '', '/dashboard/user/applicants', 'Only');
}
}
} catch (Exception $Ex) {
$this->Form->AddError($Ex);
}
}
$this->Render();
}