本文整理汇总了PHP中Gdn::Controller方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::Controller方法的具体用法?PHP Gdn::Controller怎么用?PHP Gdn::Controller使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::Controller方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MediaCache
public function MediaCache()
{
if ($this->_MediaCache === NULL) {
$this->CacheAttachedMedia(Gdn::Controller());
}
return $this->_MediaCache;
}
示例2: ToString
public function ToString()
{
$Session = Gdn::Session();
$Controller = Gdn::Controller();
$UserID = $Controller->User->UserID;
$MemberOptions = array();
$ProfileOptions = array();
$Controller->EventArguments['UserID'] = $UserID;
$Controller->EventArguments['ProfileOptions'] =& $ProfileOptions;
$Controller->EventArguments['MemberOptions'] =& $MemberOptions;
if ($Controller->EditMode) {
return '<div class="ProfileOptions">' . Anchor(T('Back to Profile'), UserUrl($Controller->User), array('class' => 'ProfileButtons')) . '</div>';
// $ProfileOptions[] = array('Text' => T('Back to Profile'), 'Url' => UserUrl($Controller->User), 'CssClass' => 'BackToProfile');
} else {
// Profile Editing
if (hasEditProfile($Controller->User->UserID)) {
$ProfileOptions[] = array('Text' => Sprite('SpEditProfile') . ' ' . T('Edit Profile'), 'Url' => UserUrl($Controller->User, '', 'edit'));
}
// Ban/Unban
$MayBan = CheckPermission('Garden.Moderation.Manage') || CheckPermission('Garden.Users.Edit') || CheckPermission('Moderation.Users.Ban');
if ($MayBan && $UserID != $Session->UserID) {
if ($Controller->User->Banned) {
$ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Unban'), 'Url' => "/user/ban?userid={$UserID}&unban=1", 'CssClass' => 'Popup');
} elseif (!$Controller->User->Admin) {
$ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Ban'), 'Url' => "/user/ban?userid={$UserID}", 'CssClass' => 'Popup');
}
}
// Delete content.
if (CheckPermission('Garden.Moderation.Manage')) {
$ProfileOptions[] = array('Text' => Sprite('SpDelete') . ' ' . T('Delete Content'), 'Url' => "/user/deletecontent?userid={$UserID}", 'CssClass' => 'Popup');
}
}
return parent::ToString();
}
示例3: InformMessage
private static function InformMessage($Message, $Sprite = 'Check')
{
$Controller = Gdn::Controller();
if ($Controller) {
$Options = array('Sprite' => $Sprite, 'CssClass' => 'Dismissable AutoDismiss');
$Controller->InformMessage($Message, $Options);
}
}
示例4: ToString
public function ToString()
{
if (!$this->Data('Discussions')) {
$this->GetData();
}
require_once Gdn::Controller()->FetchViewLocation('helper_functions', 'Discussions', 'Vanilla');
return parent::ToString();
}
示例5: CommentModel_BeforeUpdateCommentCount_Handler
/**
* Set Comment's DateInserted to Discussion's DateLastComment so there's no change.
*/
public function CommentModel_BeforeUpdateCommentCount_Handler($Sender)
{
if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) {
if (Gdn::Controller()->Form->GetFormValue('NoBump')) {
$Sender->EventArguments['Discussion']['Sink'] = 1;
}
}
}
示例6: ToString
public function ToString()
{
Gdn::Controller()->EventArguments['NewDiscussionModule'] =& $this;
Gdn::Controller()->FireEvent('BeforeNewDiscussionButton');
$HasPermission = Gdn::Session()->CheckPermission('Vanilla.Discussions.Add', TRUE, 'Category', 'any');
if (!$HasPermission) {
return '';
}
return parent::ToString();
}
示例7: LoadData
public function LoadData()
{
$UserID = Gdn::Controller()->Data('Profile.UserID', Gdn::Session()->UserID);
$this->User = Gdn::UserModel()->GetID($UserID);
$this->Roles = Gdn::UserModel()->GetRoles($UserID)->ResultArray();
// Hide personal info roles
if (!CheckPermission('Garden.PersonalInfo.View')) {
$this->Roles = array_filter($this->Roles, 'RoleModel::FilterPersonalInfo');
}
}
示例8: MeModule_FlyoutMenu_Handler
/**
* Adds "Mark All Viewed" and (conditionally) "Mark Category Viewed" to MeModule menu.
*
* @since 2.0
* @access public
*/
public function MeModule_FlyoutMenu_Handler($Sender)
{
// Add "Mark All Viewed" to menu
if (Gdn::Session()->IsValid()) {
echo Wrap(Anchor(Sprite('SpMarkAllViewed') . ' ' . T('Mark All Viewed'), '/discussions/markallviewed'), 'li', array('class' => 'MarkAllViewed'));
$CategoryID = (int) (empty(Gdn::Controller()->CategoryID) ? 0 : Gdn::Controller()->CategoryID);
if ($CategoryID > 0) {
echo Wrap(Anchor(Sprite('SpMarkCategoryViewed') . ' ' . T('Mark Category Viewed'), "/discussions/markcategoryviewed/{$CategoryID}"), 'li', array('class' => 'MarkCategoryViewed'));
}
}
}
示例9: SettingsController_Render_Before
public function SettingsController_Render_Before($Sender)
{
$RequestMethod = $Sender->RequestMethod;
if ($RequestMethod == 'managecategories' || $RequestMethod == 'tagging') {
$Sender->AddJsFile($this->GetResource('js/refreshcounts.js', FALSE, FALSE));
//check for any stashed messages from the pre
$Message = Gdn::Session()->Stash('RefreshCountsMessage');
if ($Message) {
//inform
Gdn::Controller()->InformMessage($Message);
}
}
}
示例10: Gdn_Form_BeforeBodyBox_Handler
/**
*
* @param Gdn_Form $Sender
*/
public function Gdn_Form_BeforeBodyBox_Handler($Sender, $Args)
{
$this->_AddCLEditor(Gdn::Controller());
$Format = $Sender->GetValue('Format');
if ($Format) {
$Formatter = Gdn::Factory($Format . 'Formatter');
if ($Formatter && method_exists($Formatter, 'FormatForWysiwyg')) {
$Body = $Formatter->FormatForWysiwyg($Sender->GetValue('Body'));
$Sender->SetValue('Body', $Body);
} elseif (!in_array($Format, array('Html', 'Wysiwyg'))) {
$Sender->SetValue('Body', Gdn_Format::To($Sender->GetValue('Body'), $Format));
}
}
$Sender->SetValue('Format', 'Wysiwyg');
}
示例11: ToString
public function ToString()
{
Gdn::Controller()->EventArguments['NewDiscussionModule'] =& $this;
Gdn::Controller()->FireEvent('BeforeNewDiscussionButton');
$HasPermission = Gdn::Session()->CheckPermission('Vanilla.Discussions.Add', TRUE, 'Category', 'any');
if (!$HasPermission) {
return '';
}
if ($this->QueryString) {
foreach ($this->Buttons as &$Row) {
$Row['Url'] .= (strpos($Row['Url'], '?') !== FALSE ? '&' : '?') . $this->QueryString;
}
}
return parent::ToString();
}
示例12: ToString
/**
* Render the module.
*
* @return string
*/
public function ToString()
{
// Set CategoryID if we have one.
if ($this->CategoryID === NULL) {
$this->CategoryID = Gdn::Controller()->Data('Category.CategoryID', FALSE);
}
// Allow plugins and themes to modify parameters.
Gdn::Controller()->EventArguments['NewDiscussionModule'] =& $this;
Gdn::Controller()->FireEvent('BeforeNewDiscussionButton');
// Make sure the user has the most basic of permissions first.
$PermissionCategory = CategoryModel::PermissionCategory($this->CategoryID);
if ($this->CategoryID) {
$Category = CategoryModel::Categories($this->CategoryID);
$HasPermission = Gdn::Session()->CheckPermission('Vanilla.Discussions.Add', TRUE, 'Category', GetValue('CategoryID', $PermissionCategory));
} else {
$HasPermission = Gdn::Session()->CheckPermission('Vanilla.Discussions.Add', TRUE, 'Category', 'any');
}
// Determine if this is a guest & we're using "New Discussion" button as call to action.
$PrivilegedGuest = $this->ShowGuests && !Gdn::Session()->IsValid();
// No module for you!
if (!$HasPermission && !$PrivilegedGuest) {
return '';
}
// Grab the allowed discussion types.
$DiscussionTypes = CategoryModel::AllowedDiscussionTypes($PermissionCategory);
foreach ($DiscussionTypes as $Key => $Type) {
if (isset($Type['AddPermission']) && !Gdn::Session()->CheckPermission($Type['AddPermission'])) {
unset($DiscussionTypes[$Key]);
continue;
}
// If user !$HasPermission, they are $PrivilegedGuest so redirect to $GuestUrl.
$Url = $HasPermission ? GetValue('AddUrl', $Type) : $this->GuestUrl;
if (!$Url) {
continue;
}
if (isset($Category) && $HasPermission) {
$Url .= '/' . rawurlencode(GetValue('UrlCode', $Category));
}
$this->AddButton(T(GetValue('AddText', $Type)), $Url);
}
// Add QueryString to URL if one is defined.
if ($this->QueryString && $HasPermission) {
foreach ($this->Buttons as &$Row) {
$Row['Url'] .= (strpos($Row['Url'], '?') !== FALSE ? '&' : '?') . $this->QueryString;
}
}
return parent::ToString();
}
示例13: ConnectButton
function ConnectButton($Row)
{
$c = Gdn::Controller();
$Connected = GetValue('Connected', $Row);
$CssClass = $Connected ? 'Active' : 'InActive';
$ConnectUrl = GetValue('ConnectUrl', $Row);
$DisconnectUrl = UserUrl($c->User, '', 'Disconnect', array('provider' => $Row['ProviderKey']));
$Result = '<span class="ActivateSlider ActivateSlider-' . $CssClass . '">';
if ($Connected) {
$Result .= Anchor(T('Connected'), $DisconnectUrl, 'Button Primary Hijack');
} else {
$Result .= Anchor(T('Connect'), $ConnectUrl, 'Button');
}
$Result .= '</span>';
return $Result;
}
示例14: API
public function API($Path, $Post = FALSE)
{
// Build the url.
$Url = 'https://graph.facebook.com/' . ltrim($Path, '/');
$AccessToken = $this->AccessToken();
if (!$AccessToken) {
throw new Gdn_UserException("You don't have a valid Facebook connection.");
}
if (strpos($Url, '?') === false) {
$Url .= '?';
} else {
$Url .= '&';
}
$Url .= 'access_token=' . urlencode($AccessToken);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $Url);
if ($Post !== false) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $Post);
Trace(" POST {$Url}");
} else {
Trace(" GET {$Url}");
}
$Response = curl_exec($ch);
$HttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$ContentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
Gdn::Controller()->SetJson('Type', $ContentType);
if (strpos($ContentType, 'javascript') !== FALSE) {
$Result = json_decode($Response, TRUE);
if (isset($Result['error'])) {
Gdn::Dispatcher()->PassData('FacebookResponse', $Result);
throw new Gdn_UserException($Result['error']['message']);
}
} else {
$Result = $Response;
}
return $Result;
}
示例15: __construct
/**
* Class constructor
*
* @param object $Sender
*/
public function __construct($Sender = '', $ApplicationFolder = FALSE)
{
if (!$Sender) {
$Sender = Gdn::Controller();
}
if (is_object($Sender)) {
$this->_ApplicationFolder = $Sender->ApplicationFolder;
$this->_ThemeFolder = $Sender->Theme;
} else {
$this->_ApplicationFolder = 'dashboard';
$this->_ThemeFolder = Gdn::Config('Garden.Theme');
}
if ($ApplicationFolder !== FALSE) {
$this->_ApplicationFolder = $ApplicationFolder;
}
if (is_object($Sender)) {
$this->_Sender = $Sender;
}
parent::__construct();
}