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


PHP Gdn_Controller::Title方法代码示例

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


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

示例1: 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

示例2: 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;
             }
         }
         $RedirectLink = $Sender->Form->GetFormValue('RedirectLink');
         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');
             }
             $DiscussionModel->DefineSchema();
             $MaxNameLength = GetValue('Length', $DiscussionModel->Schema->GetField('Name'));
             // 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');
                     }
                     if ($RedirectLink) {
                         // The discussion needs to be changed to a moved link.
                         $RedirectDiscussion = array('Name' => SliceString(sprintf(T('Merged: %s'), $Discussion['Name']), $MaxNameLength), 'Type' => 'redirect', 'Body' => FormatString(T('This discussion has been <a href="{url,html}">merged</a>.'), array('url' => DiscussionUrl($MergeDiscussion))), 'Format' => 'Html');
                         $DiscussionModel->SetField($Discussion['DiscussionID'], $RedirectDiscussion);
                         $CommentModel->UpdateCommentCount($Discussion['DiscussionID']);
                         $CommentModel->RemovePageCache($Discussion['DiscussionID']);
                     } else {
                         // 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->JsonTarget('', '', 'Refresh');
             }
         }
     }
     $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:87,代码来源:class.splitmerge.plugin.php

示例3: SettingsController_CustomizeText_Create

 /**
  * Add the customize text page to the dashboard.
  * 
  * @param Gdn_Controller $Sender
  */
 public function SettingsController_CustomizeText_Create($Sender)
 {
     $Sender->Permission('Garden.Settings.Manage');
     $Sender->AddSideMenu('settings/customizetext');
     $Sender->AddJsFile('jquery.autogrow.js');
     $Sender->Title('Customize Text');
     $Directive = GetValue(0, $Sender->RequestArgs, '');
     $View = 'customizetext';
     if ($Directive == 'rebuild') {
         $View = 'rebuild';
     } elseif ($Directive == 'rebuildcomplete') {
         $View = 'rebuildcomplete';
     }
     $Method = 'none';
     if ($Sender->Form->IsPostback()) {
         $Method = 'search';
         if ($Sender->Form->GetValue('Save_All')) {
             $Method = 'save';
         }
     }
     $Matches = array();
     $Keywords = NULL;
     switch ($Method) {
         case 'none':
             break;
         case 'search':
         case 'save':
             $Keywords = strtolower($Sender->Form->GetValue('Keywords'));
             if ($Method == 'search') {
                 $Sender->Form->ClearInputs();
                 $Sender->Form->SetFormValue('Keywords', $Keywords);
             }
             $Definitions = Gdn::Locale()->GetDeveloperDefinitions();
             $CountDefinitions = sizeof($Definitions);
             $Sender->SetData('CountDefinitions', $CountDefinitions);
             $Changed = FALSE;
             foreach ($Definitions as $Key => $BaseDefinition) {
                 $KeyHash = md5($Key);
                 $ElementName = "def_{$KeyHash}";
                 // Look for matches
                 $k = strtolower($Key);
                 $d = strtolower($BaseDefinition);
                 // If this key doesn't match, skip it
                 if ($Keywords != '*' && !(strlen($Keywords) > 0 && (strpos($k, $Keywords) !== FALSE || strpos($d, $Keywords) !== FALSE))) {
                     continue;
                 }
                 $Modified = FALSE;
                 // Found a definition, look it up in the real locale first, to see if it has been overridden
                 $CurrentDefinition = Gdn::Locale()->Translate($Key, FALSE);
                 if ($CurrentDefinition !== FALSE && $CurrentDefinition != $BaseDefinition) {
                     $Modified = TRUE;
                 } else {
                     $CurrentDefinition = $BaseDefinition;
                 }
                 $Matches[$Key] = array('def' => $CurrentDefinition, 'mod' => $Modified);
                 if ($CurrentDefinition[0] == "\r\n") {
                     $CurrentDefinition = "\r\n{$CurrentDefinition}";
                 } else {
                     if ($CurrentDefinition[0] == "\r") {
                         $CurrentDefinition = "\r{$CurrentDefinition}";
                     } else {
                         if ($CurrentDefinition[0] == "\n") {
                             $CurrentDefinition = "\n{$CurrentDefinition}";
                         }
                     }
                 }
                 if ($Method == 'save') {
                     $SuppliedDefinition = $Sender->Form->GetValue($ElementName);
                     // Has this field been changed?
                     if ($SuppliedDefinition != FALSE && $SuppliedDefinition != $CurrentDefinition) {
                         // Changed from what it was, but is it a change from the *base* value?
                         $SaveDefinition = $SuppliedDefinition != $BaseDefinition ? $SuppliedDefinition : NULL;
                         if (!is_null($SaveDefinition)) {
                             $CurrentDefinition = $SaveDefinition;
                             $SaveDefinition = str_replace("\r\n", "\n", $SaveDefinition);
                         }
                         Gdn::Locale()->SetTranslation($Key, $SaveDefinition, array('Save' => TRUE, 'RemoveEmpty' => TRUE));
                         $Matches[$Key] = array('def' => $SuppliedDefinition, 'mod' => !is_null($SaveDefinition));
                         $Changed = TRUE;
                     }
                 }
                 $Sender->Form->SetFormValue($ElementName, $CurrentDefinition);
             }
             if ($Changed) {
                 $Sender->InformMessage("Locale changes have been saved!");
             }
             break;
     }
     $Sender->SetData('Matches', $Matches);
     $CountMatches = sizeof($Matches);
     $Sender->SetData('CountMatches', $CountMatches);
     $Sender->Render($View, '', 'plugins/CustomizeText');
 }
开发者ID:vanilla,项目名称:addons,代码行数:98,代码来源:class.customizetext.plugin.php

示例4: Controller_Edit

 /**
  * Edit a Tag
  *
  * @param Gdn_Controller $Sender
  */
 public function Controller_Edit($Sender)
 {
     $Sender->AddSideMenu('settings/tagging');
     $Sender->Title(T('Edit Tag'));
     $TagID = GetValue(1, $Sender->RequestArgs);
     // Set the model on the form.
     $TagModel = new TagModel();
     $Sender->Form->SetModel($TagModel);
     $Tag = $TagModel->GetID($TagID);
     $Sender->Form->SetData($Tag);
     // Make sure the form knows which item we are editing.
     $Sender->Form->AddHidden('TagID', $TagID);
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Make sure the tag is valid
         $TagData = $Sender->Form->GetFormValue('Name');
         if (!TagModel::ValidateTag($TagData)) {
             $Sender->Form->AddError('@' . T('ValidateTag', 'Tags cannot contain commas.'));
         }
         // Make sure that the tag name is not already in use.
         if ($TagModel->GetWhere(array('TagID <>' => $TagID, 'Name' => $TagData))->NumRows() > 0) {
             $Sender->SetData('MergeTagVisible', TRUE);
             if (!$Sender->Form->GetFormValue('MergeTag')) {
                 $Sender->Form->AddError('The specified tag name is already in use.');
             }
         }
         if ($Sender->Form->Save()) {
             $Sender->InformMessage(T('Your changes have been saved.'));
         }
     }
     $Sender->Render('addedit', '', 'plugins/Tagging');
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:36,代码来源:class.tagging.plugin.php

示例5: SettingsController_Tagging_Create

   /**
    * Tag management (let admins rename tags, remove tags, etc).
    * TODO: manage the Plugins.Tagging.Required boolean setting that makes tagging required or not.
    * @param Gdn_Controller $Sender
    */
   public function SettingsController_Tagging_Create($Sender, $Args) {
      $Sender->Permission('Garden.Settings.Manage');
      $Sender->Title('Tagging');
      $Sender->AddSideMenu('settings/tagging');
      $Sender->AddCSSFile('plugins/Tagging/design/tagadmin.css');
      $Sender->AddJSFile('plugins/Tagging/admin.js');
      $SQL = Gdn::SQL();

      list($Offset, $Limit) = OffsetLimit($Sender->Request->Get('Page'), 100);
      $Sender->SetData('_Limit', $Limit);

      $Sender->SetData('Tags', $SQL
         ->Select('t.*')
         ->From('Tag t')
         ->OrderBy('t.Name', 'asc')
         ->OrderBy('t.CountDiscussions', 'desc')
         ->Limit($Limit, $Offset)
         ->Get()->ResultArray());

      $Sender->SetData('RecordCount', $SQL->GetCount('Tag'));
         
      $Sender->Render('Tagging', '', 'plugins/Tagging');
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:28,代码来源:class.tagging.plugin.php


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