当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn_Format::Url方法代码示例

本文整理汇总了PHP中Gdn_Format::Url方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::Url方法的具体用法?PHP Gdn_Format::Url怎么用?PHP Gdn_Format::Url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn_Format的用法示例。


在下文中一共展示了Gdn_Format::Url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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 
}
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:60,代码来源:helper_functions.php

示例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();
 }
开发者ID:sipp11,项目名称:Garden,代码行数:35,代码来源:class.searchcontroller.php

示例3: Award

 /**
  * Award a badge to a user and record some activity
  *
  * @param int $BadgeID
  * @param int $UserID This is the user that should get the award
  * @param int $InsertUserID This is the user that gave the award
  * @param string $Reason This is the reason the giver gave with the award
  */
 public function Award($BadgeID, $UserID, $InsertUserID = NULL, $Reason = '')
 {
     $Badge = Yaga::BadgeModel()->GetByID($BadgeID);
     if (!empty($Badge)) {
         if (!$this->Exists($UserID, $BadgeID)) {
             $this->SQL->Insert('BadgeAward', array('BadgeID' => $BadgeID, 'UserID' => $UserID, 'InsertUserID' => $InsertUserID, 'Reason' => $Reason, 'DateInserted' => date(DATE_ISO8601)));
             // Record the points for this badge
             UserModel::GivePoints($UserID, $Badge->AwardValue, 'Badge');
             // Increment the user's badge count
             $this->SQL->Update('User')->Set('CountBadges', 'CountBadges + 1', FALSE)->Where('UserID', $UserID)->Put();
             if (is_null($InsertUserID)) {
                 $InsertUserID = Gdn::Session()->UserID;
             }
             // Record some activity
             $ActivityModel = new ActivityModel();
             $Activity = array('ActivityType' => 'BadgeAward', 'ActivityUserID' => $UserID, 'RegardingUserID' => $InsertUserID, 'Photo' => $Badge->Photo, 'RecordType' => 'Badge', 'RecordID' => $BadgeID, 'Route' => '/badges/detail/' . $Badge->BadgeID . '/' . Gdn_Format::Url($Badge->Name), 'HeadlineFormat' => T('Yaga.Badge.EarnedHeadlineFormat'), 'Data' => array('Name' => $Badge->Name), 'Story' => $Badge->Description);
             // Create a public record
             $ActivityModel->Queue($Activity, FALSE);
             // TODO: enable the grouped notifications after issue #1776 is resolved , array('GroupBy' => 'Route'));
             // Notify the user of the award
             $Activity['NotifyUserID'] = $UserID;
             $ActivityModel->Queue($Activity, 'BadgeAward', array('Force' => TRUE));
             // Actually save the activity
             $ActivityModel->SaveQueue();
             $this->EventArguments['UserID'] = $UserID;
             $this->FireEvent('AfterBadgeAward');
         }
     }
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:37,代码来源:class.badgeawardmodel.php

示例4: AddLabel

 public function AddLabel($Name, $Code = '', $Url = '')
 {
     if ($Code == '') {
         $Code = Gdn_Format::Url(ucwords(trim(Gdn_Format::PlainText($Name))));
     }
     $this->_Labels[] = array('Name' => $Name, 'Code' => $Code, 'Url' => $Url);
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:7,代码来源:class.togglemenumodule.php

示例5: Search

 public function Search($Search, $Offset = 0, $Limit = 20)
 {
     $BaseUrl = C('Plugins.Solr.SearchUrl', 'http://localhost:8983/solr/select/?');
     if (!$BaseUrl) {
         throw new Gdn_UserException("The search url has not been configured.");
     }
     if (!$Search) {
         return array();
     }
     // Escepe the search.
     $Search = preg_replace('`([][+&|!(){}^"~*?:\\\\-])`', "\\\\\$1", $Search);
     // Add the category watch.
     $Categories = CategoryModel::CategoryWatch();
     if ($Categories === FALSE) {
         return array();
     } elseif ($Categories !== TRUE) {
         $Search = 'CategoryID:(' . implode(' ', $Categories) . ') AND ' . $Search;
     }
     // Build the search url.
     $BaseUrl .= strpos($BaseUrl, '?') === FALSE ? '?' : '&';
     $Query = array('q' => $Search, 'start' => $Offset, 'rows' => $Limit);
     $Url = $BaseUrl . http_build_query($Query);
     // Grab the data.
     $Curl = curl_init($Url);
     curl_setopt($Curl, CURLOPT_RETURNTRANSFER, 1);
     $CurlResult = curl_exec($Curl);
     curl_close($Curl);
     // Parse the result into the form that the search controller expects.
     $Xml = new SimpleXMLElement($CurlResult);
     $Result = array();
     if (!isset($Xml->result)) {
         return array();
     }
     foreach ($Xml->result->children() as $Doc) {
         $Row = array();
         foreach ($Doc->children() as $Field) {
             $Name = (string) $Field['name'];
             $Row[$Name] = (string) $Field;
         }
         // Add the url.
         switch ($Row['DocType']) {
             case 'Discussion':
                 $Row['Url'] = '/discussion/' . $Row['PrimaryID'] . '/' . Gdn_Format::Url($Row['Title']);
                 break;
             case 'Comment':
                 $Row['Url'] = "/discussion/comment/{$Row['PrimaryID']}/#Comment_{$Row['PrimaryID']}";
                 break;
         }
         // Fix the time.
         $Row['DateInserted'] = strtotime($Row['DateInserted']);
         $Result[] = $Row;
     }
     // Join the users into the result.
     Gdn_DataSet::Join($Result, array('table' => 'User', 'parent' => 'UserID', 'prefix' => '', 'Name', 'Photo'));
     return $Result;
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:56,代码来源:class.searchmodel.php

示例6: ProfileController_AfterAddSideMenu_Handler

 public function ProfileController_AfterAddSideMenu_Handler($Sender)
 {
     if (!Gdn::Session()->CheckPermission('Garden.SignIn.Allow')) {
         return;
     }
     $SideMenu = $Sender->EventArguments['SideMenu'];
     $ViewingUserID = Gdn::Session()->UserID;
     if ($Sender->User->UserID == $ViewingUserID) {
         $SideMenu->AddLink('Options', T('Quote Settings'), '/profile/quotes', FALSE, array('class' => 'Popup'));
     } else {
         $SideMenu->AddLink('Options', T('Quote Settings'), '/profile/quotes/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name), 'Garden.Users.Edit', array('class' => 'Popup'));
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:13,代码来源:class.quotes.plugin.php

示例7: ProfileController_AfterAddSideMenu_Handler

 public function ProfileController_AfterAddSideMenu_Handler($Sender)
 {
     if (!Gdn::Session()->CheckPermission('Garden.Users.Edit') && $Sender->User->UserID !== Gdn::Session()->UserID) {
         return;
     }
     $SideMenu = $Sender->EventArguments['SideMenu'];
     $SessionUserID = Gdn::Session()->UserID;
     if ($Sender->User->UserID == $SessionUserID) {
         $SideMenu->AddLink('Options', T('My Profile Edit'), '/profile/myprofileedit/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name), FALSE, array('class' => 'Popup'));
     } else {
         $SideMenu->AddLink('Options', T('My Profile Edit'), '/profile/myprofileedit/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name), 'Garden.Users.Edit', array('class' => 'Popup'));
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:13,代码来源:default.php

示例8: ProfileController_AfterAddSideMenu_Handler

 public function ProfileController_AfterAddSideMenu_Handler(&$Sender)
 {
     if (!C('Plugins.Signatures.Enabled')) {
         return;
     }
     $SideMenu = $Sender->EventArguments['SideMenu'];
     $Session = Gdn::Session();
     $ViewingUserID = $Session->UserID;
     if ($Sender->User->UserID == $ViewingUserID) {
         $SideMenu->AddLink('Options', T('Signature Settings'), '/profile/signature', FALSE, array('class' => 'aaaaa'));
     } else {
         $SideMenu->AddLink('Options', T('Signature Settings'), '/profile/signature/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name), 'Garden.Users.Edit', array('class' => 'Popup'));
     }
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:14,代码来源:class.signatures.plugin.php

示例9: 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>";
 }
开发者ID:Nordic-T,项目名称:Nordic-T,代码行数:15,代码来源:class.forumdonatemodule.php

示例10: DiscussionController_AutoExpire_Create

 public function DiscussionController_AutoExpire_Create($Sender, $Args)
 {
     $DiscussionID = intval($Args[0]);
     $DiscussionModel = new DiscussionModel();
     $Discussion = $DiscussionModel->GetID($DiscussionID);
     if (!Gdn::Session()->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $Discussion->PermissionCategoryID)) {
         throw PermissionException('Vanilla.Discussions.Close');
     }
     if (strtolower($Args[1]) == 'reset') {
         Gdn::SQL()->Put('Discussion', array('AutoExpire' => 1, 'Closed' => 0, 'DateReOpened' => Gdn_Format::ToDateTime()), array('DiscussionID' => $DiscussionID));
     } else {
         $Expire = strtolower($Args[1]) == 'on' ? 1 : 0;
         Gdn::SQL()->Put('Discussion', array('AutoExpire' => $Expire), array('DiscussionID' => $DiscussionID));
     }
     Redirect('discussion/' . $DiscussionID . '/' . Gdn_Format::Url($Discussion->Name));
 }
开发者ID:x00,项目名称:AutoExpireDiscussions-Vanilla-Plugin,代码行数:16,代码来源:default.php

示例11: Index

 public function Index()
 {
     $Session = Gdn::Session();
     $categories = array();
     $discussionsPerCategory = 4;
     $DiscussionModel = new DiscussionModel();
     $this->CategoryData = $this->CategoryModel->GetFull();
     $this->CategoryDiscussionData = array();
     foreach ($this->CategoryData->Result() as $Category) {
         $this->Category = $Category;
         if ($Session->CheckPermission('Vanilla.Discussions.View', $this->Category->CategoryID)) {
             //TODO be nice if options could be passed to filter
             // discussions that are closed, sunk, etc etc...
             $this->DiscussionData = $DiscussionModel->Get(0, $discussionsPerCategory, array('d.CategoryID' => $Category->CategoryID));
             $category = array();
             foreach ($Category as $key => $value) {
                 $category[$key] = $value;
             }
             #$category["CategoryURL"] = Gdn::Config('Garden.Domain')."/categories/".$Category->UrlCode;
             $category["CategoryURL"] = Gdn::Request()->Domain() . "/categories/" . $Category->UrlCode;
             if ($this->DiscussionData->NumRows() > 0) {
                 $count = 0;
                 $discussion = array();
                 $category["discussions"] = array();
                 foreach ($this->DiscussionData->Result() as $Discussion) {
                     foreach ($Discussion as $key => $value) {
                         $discussion[$key] = $value;
                     }
                     //$discussion["DiscussionURL"] = Gdn::Config('Garden.Domain').'/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name);
                     $discussion["DiscussionURL"] = Gdn::Request()->Domain() . '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name);
                     if ($count++ < $discussionsPerCategory) {
                         $category["discussions"][] = $discussion;
                     } else {
                         break;
                     }
                 }
             }
             $categories[] = $category;
         }
     }
     $this->SetJSON("categories", $categories);
     $this->Render();
 }
开发者ID:gregroiusairlangga,项目名称:vanilla-api-addon,代码行数:43,代码来源:class.categorycontroller.php

示例12: Anchor

<?php

if (!defined('APPLICATION')) {
    exit;
}
// An individual discussion record for all panel modules to use when rendering a discussion list.
?>
<li id="<?php 
echo 'Bookmark_' . $Discussion->DiscussionID;
?>
">
   <strong><?php 
echo Anchor($Discussion->Name, '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink');
?>
</strong>
   <div class="Meta">
      <?php 
echo '<span>' . $Discussion->CountComments . '</span>';
$CountUnreadComments = $Discussion->CountComments - $Discussion->CountCommentWatch;
// Logic for incomplete comment count.
if ($Discussion->CountCommentWatch == 0 && ($DateLastViewed = GetValue('DateLastViewed', $Discussion))) {
    if (Gdn_Format::ToTimestamp($DateLastViewed) >= Gdn_Format::ToTimestamp($Discussion->LastDate)) {
        $CountUnreadComments = 0;
        $Discussion->CountCommentWatch = $Discussion->CountComments;
    } else {
        $CountUnreadComments = '';
    }
}
if ($CountUnreadComments > 0 || $CountUnreadComments === '') {
    echo '<strong>' . trim(sprintf('%s new', $CountUnreadComments)) . '</strong>';
}
开发者ID:sipp11,项目名称:Garden,代码行数:31,代码来源:discussion.php

示例13: if

<?php if (!defined('APPLICATION')) exit();
$Session = Gdn::Session();
$CancelUrl = '/vanilla/discussions';
if (C('Vanilla.Categories.Use') && is_object($this->Category))
   $CancelUrl = '/vanilla/discussions/0/'.$this->Category->CategoryID.'/'.Gdn_Format::Url($this->Category->Name);

?>
<div id="DiscussionForm">
   <h1><?php echo $this->Data('Title'); ?></h1>
   <?php
      echo $this->Form->Open();
      echo $this->Form->Errors();
      $this->FireEvent('BeforeFormInputs');
		echo '<div class="P">';
			echo $this->Form->Label('Discussion Title', 'Name');
			echo Wrap($this->Form->TextBox('Name', array('maxlength' => 100, 'class' => 'InputBox BigInput')), 'div', array('class' => 'TextBoxWrapper'));
		echo '</div>';

      if ($this->ShowCategorySelector === TRUE) {
			echo '<div class="P">';
				echo '<div class="Category">';
				echo $this->Form->Label('Category', 'CategoryID'), ' ';
				echo $this->Form->DropDown('CategoryID', $this->CategoryData, array('TextField' => 'Name', 'ValueField' => 'CategoryID'));
				echo '</div>';
			echo '</div>';
      }
      
      $this->FireEvent('BeforeBodyInput');
		echo '<div class="P">';
	      echo Wrap($this->Form->TextBox('Body', array('MultiLine' => TRUE)), 'div', array('class' => 'TextBoxWrapper'));
		echo '</div>';
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:31,代码来源:discussion.php

示例14: BuildProfile

 /**
  * Build the user profile: Set the page title, add data to page modules & add
  * modules to assets, Add tabs to tab menu. $this->User must be defined,
  * or this method will throw an exception.
  */
 public function BuildProfile()
 {
     if (!is_object($this->User)) {
         throw new Exception(T('Cannot build profile information if user is not defined.'));
     }
     $Session = Gdn::Session();
     $this->CssClass = 'Profile';
     $this->Title(Gdn_Format::Text($this->User->Name));
     if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
         $UserInfoModule = new UserInfoModule($this);
         $UserInfoModule->User = $this->User;
         $UserInfoModule->Roles = $this->Roles;
         $this->AddModule($UserInfoModule);
         $this->AddJsFile('jquery.jcrop.pack.js');
         $this->AddJsFile('profile.js');
         $this->AddJsFile('activity.js');
         $ActivityUrl = 'profile/activity/';
         if ($this->User->UserID != $Session->UserID) {
             $ActivityUrl .= $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name);
         }
         $this->AddProfileTab(T('Activity'), $ActivityUrl);
         if ($this->User->UserID == $Session->UserID) {
             $Notifications = T('Notifications');
             $CountNotifications = $Session->User->CountNotifications;
             if (is_numeric($CountNotifications) && $CountNotifications > 0) {
                 $Notifications .= '<span>' . $CountNotifications . '</span>';
             }
             $this->AddProfileTab(array($Notifications => 'profile/notifications'));
         }
         $this->FireEvent('AddProfileTabs');
     }
     return TRUE;
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:38,代码来源:class.profilecontroller.php

示例15: ModerationController_MergeDiscussions_Create

 /**
  * Add a method to the ModerationController to handle merging discussions.
  * @param Gdn_Controller $Sender
  */
 public function ModerationController_MergeDiscussions_Create($Sender)
 {
     $Session = Gdn::Session();
     $Sender->Form = new Gdn_Form();
     $Sender->Title(T('Merge Discussions'));
     $DiscussionModel = new DiscussionModel();
     $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
     if (!is_array($CheckedDiscussions)) {
         $CheckedDiscussions = array();
     }
     $DiscussionIDs = $CheckedDiscussions;
     $Sender->SetData('DiscussionIDs', $DiscussionIDs);
     $CountCheckedDiscussions = count($DiscussionIDs);
     $Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
     $Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
     $Sender->SetData('Discussions', $Discussions);
     // Perform the merge
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = FALSE;
         $MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
             if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                 $MergeDiscussion = $Discussion;
                 break;
             }
         }
         if ($MergeDiscussion) {
             $ErrorCount = 0;
             // Verify that the user has permission to perform the merge.
             $Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
             if ($Category && !$Category['PermsDiscussionsEdit']) {
                 throw PermissionException('Vanilla.Discussions.Edit');
             }
             // Assign the comments to the new discussion record
             $DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $MergeDiscussionID)->WhereIn('DiscussionID', $DiscussionIDs)->Put();
             $CommentModel = new CommentModel();
             foreach ($Discussions as $Discussion) {
                 if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                     continue;
                 }
                 // Create a comment out of the discussion.
                 $Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
                 $Comment['DiscussionID'] = $MergeDiscussionID;
                 $CommentModel->Validation->Results(TRUE);
                 $CommentID = $CommentModel->Save($Comment);
                 if ($CommentID) {
                     // Move any attachments (FileUpload plugin awareness)
                     if (class_exists('MediaModel')) {
                         $MediaModel = new MediaModel();
                         $MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                     }
                     // Delete discussion that was merged
                     $DiscussionModel->Delete($Discussion['DiscussionID']);
                 } else {
                     $Sender->InformMessage($CommentModel->Validation->ResultsText());
                     $ErrorCount++;
                 }
             }
             // Update counts on all affected discussions.
             $CommentModel->UpdateCommentCount($MergeDiscussionID);
             $CommentModel->RemovePageCache($MergeDiscussionID);
             // Clear selections
             Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
             ModerationController::InformCheckedDiscussions($Sender);
             if ($ErrorCount == 0) {
                 $Sender->RedirectUrl = Url("/discussion/{$MergeDiscussionID}/" . Gdn_Format::Url($MergeDiscussion['Name']));
             }
         }
     }
     $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
 }
开发者ID:bishopb,项目名称:vanilla,代码行数:76,代码来源:class.splitmerge.plugin.php


注:本文中的Gdn_Format::Url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。