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


PHP Gdn_Controller::setData方法代码示例

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


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

示例1: settingsController_vanillicon_create

 /**
  * The settings page for vanillicon.
  *
  * @param Gdn_Controller $sender
  */
 public function settingsController_vanillicon_create($sender)
 {
     $sender->permission('Garden.Settings.Manage');
     $cf = new ConfigurationModule($sender);
     $items = array('v1' => 'Vanillicon 1', 'v2' => 'Vanillicon 2');
     $cf->initialize(array('Plugins.Vanillicon.Type' => array('LabelCode' => 'Vanillicon Set', 'Control' => 'radiolist', 'Description' => 'Which vanillicon set do you want to use?', 'Items' => $items, 'Options' => array('display' => 'after'), 'Default' => 'v1')));
     $sender->setData('Title', sprintf(t('%s Settings'), 'Vanillicon'));
     $cf->renderAll();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:14,代码来源:class.vanillicon.plugin.php

示例2: homeController_homepage_create

 /**
  * Homepage of VanillaForums.org.
  *
  * @param Gdn_Controller $sender
  */
 public function homeController_homepage_create($sender)
 {
     try {
         $AddonModel = new AddonModel();
         $Addon = $AddonModel->getSlug('vanilla-core', true);
         $sender->setData('CountDownloads', val('CountDownloads', $Addon));
         $sender->setData('Version', val('Version', $Addon));
         $sender->setData('DateUploaded', val('DateInserted', $Addon));
     } catch (Exception $ex) {
     }
     $sender->title('The most powerful custom community solution in the world');
     $sender->setData('Description', "Vanilla is forum software that powers discussions on hundreds of thousands of sites. Built for flexibility and integration, Vanilla is the best, most powerful community solution in the world.");
     $sender->Head->addTag('meta', array('name' => 'description', 'content' => $sender->data('Description')));
     $sender->clearJsFiles();
     $sender->addJsFile('jquery.js', 'vforg');
     $sender->addJsFile('easySlider1.7.js', 'vforg');
     saveToConfig('Garden.Embed.Allow', false, false);
     // Prevent JS errors
     $sender->clearCssFiles();
     $sender->addCssFile('vforg-home.css', 'vforg');
     $sender->MasterView = 'empty';
     $sender->render('index', 'home', 'vforg');
 }
开发者ID:vanilla,项目名称:community,代码行数:28,代码来源:class.hooks.php

示例3: base_connectData_handler

 /**
  *
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function base_connectData_handler($Sender, $Args)
 {
     if (val(0, $Args) != 'facebook') {
         return;
     }
     if (isset($_GET['error'])) {
         // TODO global nope x2
         throw new Gdn_UserException(val('error_description', $_GET, t('There was an error connecting to Facebook')));
     }
     $AppID = c('Plugins.Facebook.ApplicationID');
     $Secret = c('Plugins.Facebook.Secret');
     $Code = val('code', $_GET);
     // TODO nope
     $Query = '';
     if ($Sender->Request->get('display')) {
         $Query = 'display=' . urlencode($Sender->Request->get('display'));
     }
     $RedirectUri = concatSep('&', $this->redirectUri(), $Query);
     $AccessToken = $Sender->Form->getFormValue('AccessToken');
     // Get the access token.
     if (!$AccessToken && $Code) {
         // Exchange the token for an access token.
         $Code = urlencode($Code);
         $AccessToken = $this->getAccessToken($Code, $RedirectUri);
         $NewToken = true;
     }
     // Get the profile.
     try {
         $Profile = $this->getProfile($AccessToken);
     } catch (Exception $Ex) {
         if (!isset($NewToken)) {
             // There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
             if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
                 redirect($this->authorizeUri());
             } else {
                 $Sender->setHeader('Content-type', 'application/json');
                 $Sender->deliveryMethod(DELIVERY_METHOD_JSON);
                 $Sender->RedirectUrl = $this->authorizeUri();
             }
         } else {
             $Sender->Form->addError('There was an error with the Facebook connection.');
         }
     }
     $Form = $Sender->Form;
     //new Gdn_Form();
     $ID = val('id', $Profile);
     $Form->setFormValue('UniqueID', $ID);
     $Form->setFormValue('Provider', self::ProviderKey);
     $Form->setFormValue('ProviderName', 'Facebook');
     $Form->setFormValue('FullName', val('name', $Profile));
     $Form->setFormValue('Email', val('email', $Profile));
     $Form->setFormValue('Photo', "//graph.facebook.com/{$ID}/picture?width=200&height=200");
     $Form->addHidden('AccessToken', $AccessToken);
     if (c('Plugins.Facebook.UseFacebookNames')) {
         $Form->setFormValue('Name', val('name', $Profile));
         saveToConfig(array('Garden.User.ValidationRegex' => UserModel::USERNAME_REGEX_MIN, 'Garden.User.ValidationLength' => '{3,50}', 'Garden.Registration.NameUnique' => false), '', false);
     }
     // Save some original data in the attributes of the connection for later API calls.
     $Attributes = array();
     $Attributes[self::ProviderKey] = array('AccessToken' => $AccessToken, 'Profile' => $Profile);
     $Form->setFormValue('Attributes', $Attributes);
     $Sender->setData('Verified', true);
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:68,代码来源:class.facebook.plugin.php

示例4: base_connectData_handler

 /**
  *
  *
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function base_connectData_handler($Sender, $Args)
 {
     if (val(0, $Args) != 'twitter') {
         return;
     }
     $Form = $Sender->Form;
     //new Gdn_Form();
     $RequestToken = val('oauth_token', $_GET);
     $AccessToken = $Form->getFormValue('AccessToken');
     if ($AccessToken) {
         $AccessToken = $this->getOAuthToken($AccessToken);
         $this->accessToken($AccessToken);
     }
     // Get the access token.
     if ($RequestToken && !$AccessToken) {
         // Get the request secret.
         $RequestToken = $this->getOAuthToken($RequestToken);
         $Consumer = new OAuthConsumer(c('Plugins.Twitter.ConsumerKey'), c('Plugins.Twitter.Secret'));
         $Url = 'https://api.twitter.com/oauth/access_token';
         $Params = array('oauth_verifier' => val('oauth_verifier', $_GET));
         $Request = OAuthRequest::from_consumer_and_token($Consumer, $RequestToken, 'POST', $Url, $Params);
         $SignatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
         $Request->sign_request($SignatureMethod, $Consumer, $RequestToken);
         $Post = $Request->to_postdata();
         $Curl = $this->_Curl($Request);
         $Response = curl_exec($Curl);
         if ($Response === false) {
             $Response = curl_error($Curl);
         }
         $HttpCode = curl_getinfo($Curl, CURLINFO_HTTP_CODE);
         curl_close($Curl);
         if ($HttpCode == '200') {
             $Data = OAuthUtil::parse_parameters($Response);
             $AccessToken = new OAuthToken(val('oauth_token', $Data), val('oauth_token_secret', $Data));
             // Save the access token to the database.
             $this->setOAuthToken($AccessToken->key, $AccessToken->secret, 'access');
             $this->accessToken($AccessToken->key, $AccessToken->secret);
             // Delete the request token.
             $this->deleteOAuthToken($RequestToken);
         } else {
             // There was some sort of error.
             throw new Exception('There was an error authenticating with twitter.', 400);
         }
         $NewToken = true;
     }
     // Get the profile.
     try {
         $Profile = $this->getProfile($AccessToken);
     } catch (Exception $Ex) {
         if (!isset($NewToken)) {
             // There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
             if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
                 redirect($this->_AuthorizeHref());
             } else {
                 $Sender->setHeader('Content-type', 'application/json');
                 $Sender->deliveryMethod(DELIVERY_METHOD_JSON);
                 $Sender->RedirectUrl = $this->_authorizeHref();
             }
         } else {
             throw $Ex;
         }
     }
     $ID = val('id', $Profile);
     $Form->setFormValue('UniqueID', $ID);
     $Form->setFormValue('Provider', self::ProviderKey);
     $Form->setFormValue('ProviderName', 'Twitter');
     $Form->setValue('ConnectName', val('screen_name', $Profile));
     $Form->setFormValue('Name', val('screen_name', $Profile));
     $Form->setFormValue('FullName', val('name', $Profile));
     $Form->setFormValue('Photo', val('profile_image_url_https', $Profile));
     $Form->addHidden('AccessToken', $AccessToken->key);
     // Save some original data in the attributes of the connection for later API calls.
     $Attributes = array(self::ProviderKey => array('AccessToken' => array($AccessToken->key, $AccessToken->secret), 'Profile' => $Profile));
     $Form->setFormValue('Attributes', $Attributes);
     $Sender->setData('Verified', true);
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:82,代码来源:class.twitter.plugin.php

示例5: attachUploadsToComment

 /**
  *
  *
  * @param Gdn_Controller $Controller
  * @param string $Type
  * @return void
  */
 protected function attachUploadsToComment($Controller, $Type = 'comment')
 {
     $RawType = ucfirst($Type);
     if (StringEndsWith($Controller->RequestMethod, 'Comment', true) && $Type != 'comment') {
         $Type = 'comment';
         $RawType = 'Comment';
         if (!isset($Controller->Comment)) {
             return;
         }
         $Controller->EventArguments['Comment'] = $Controller->Comment;
     }
     $MediaList = $this->mediaCache();
     if (!is_array($MediaList)) {
         return;
     }
     $Param = $Type == 'comment' ? 'CommentID' : 'DiscussionID';
     $MediaKey = $Type . '/' . val($Param, val($RawType, $Controller->EventArguments));
     if (array_key_exists($MediaKey, $MediaList)) {
         include_once $Controller->fetchViewLocation('fileupload_functions', '', 'plugins/FileUpload');
         $Controller->setData('CommentMediaList', $MediaList[$MediaKey]);
         $Controller->setData('GearImage', $this->getWebResource('images/gear.png'));
         $Controller->setData('Garbage', $this->getWebResource('images/trash.png'));
         $Controller->setData('CanDownload', $this->CanDownload);
         echo $Controller->fetchView($this->getView('link_files.php'));
     }
 }
开发者ID:vanilla,项目名称:addons,代码行数:33,代码来源:class.fileupload.plugin.php

示例6: toString

 /**
  * Render the email.
  *
  * @return string The rendered email.
  */
 public function toString()
 {
     if ($this->isPlaintext()) {
         return $this->plainTextEmail();
     }
     $controller = new Gdn_Controller();
     $controller->setData('email', $this->objectToArray($this));
     $email = $controller->fetchView($this->view);
     // Append plaintext version
     $email .= self::PLAINTEXT_START . $this->plainTextEmail();
     return $email;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:17,代码来源:class.emailtemplate.php

示例7: 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);
     // Make sure none of the selected discussions are ghost redirects.
     $discussionTypes = array_column($Discussions, 'Type');
     if (in_array('redirect', $discussionTypes)) {
         throw Gdn_UserException('You cannot merge redirects.', 400);
     }
     // 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 = val('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:alim4egg,项目名称:vanilla,代码行数:93,代码来源:class.splitmerge.plugin.php

示例8: controller_delete

 /**
  * Delete a Tag
  *
  * @param Gdn_Controller $Sender
  */
 public function controller_delete($Sender)
 {
     $Sender->permission('Garden.Settings.Manage');
     $TagID = val(1, $Sender->RequestArgs);
     $TagModel = new TagModel();
     $Tag = $TagModel->getID($TagID, DATASET_TYPE_ARRAY);
     if ($Sender->Form->authenticatedPostBack()) {
         // Delete tag & tag relations.
         $SQL = Gdn::sql();
         $SQL->delete('TagDiscussion', array('TagID' => $TagID));
         $SQL->delete('Tag', array('TagID' => $TagID));
         $Sender->informMessage(formatString(t('<b>{Name}</b> deleted.'), $Tag));
         $Sender->jsonTarget("#Tag_{$Tag['TagID']}", null, 'Remove');
     }
     $Sender->setData('Title', t('Delete Tag'));
     $Sender->render('delete', '', 'plugins/Tagging');
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:22,代码来源:class.tagging.plugin.php

示例9: settingsController_vanillicon_create

 /**
  * The settings page for vanillicon.
  *
  * @param Gdn_Controller $sender
  */
 public function settingsController_vanillicon_create($sender)
 {
     $sender->permission('Garden.Settings.Manage');
     $cf = new ConfigurationModule($sender);
     $items = array('v1' => 'Vanillicon 1', 'v2' => 'Vanillicon 2 (beta)');
     $cachePath = self::getCachePath();
     $writable = is_writable($cachePath);
     $txtNotWritable = '<p style="color: #c00;">' . T('<b>Warning:</b> the cache directory is not writable. If you want to use the cache mechanism, you have to enable write permissions for') . '</p><code>' . $cachePath . '</code><br><br><br>';
     $txtProxyActive = '<p style="color: #090;">' . T('<b>Congratulations: The privacy of your users is respected!</b> All requests to vanillicon.com are made by your server and not by your users.') . '</p><br>';
     $cf->initialize(array('Plugins.Vanillicon.Type' => array('LabelCode' => 'Vanillicon Proxy', 'Control' => 'radiolist', 'Description' => $txtProxyActive . ($writable ? '' : $txtNotWritable) . ' ' . T('Which vanillicon set do you want to use?'), 'Items' => $items, 'Options' => array('list' => true, 'listclass' => 'icon-list', 'display' => 'after'), 'Default' => 'v1')));
     $sender->addSideMenu();
     $sender->setData('Title', sprintf(t('%s Settings'), 'Vanillicon'));
     $cf->renderAll();
 }
开发者ID:korelstar,项目名称:vanilla-proxyvanillicon,代码行数:19,代码来源:class.proxyvanillicon.plugin.php

示例10: controller_edit

 /**
  * Edit a Tag
  *
  * @param Gdn_Controller $Sender
  */
 public function controller_edit($Sender)
 {
     $Sender->addSideMenu('settings/tagging');
     $Sender->title(t('Edit Tag'));
     $TagID = val(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:vanilla,项目名称:vanilla,代码行数:36,代码来源:class.tagging.plugin.php


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