本文整理汇总了PHP中Gdn_Controller类的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Controller类的具体用法?PHP Gdn_Controller怎么用?PHP Gdn_Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gdn_Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: informNotifications
/**
* Grabs all new notifications and adds them to the sender's inform queue.
*
* This method gets called by dashboard's hooks file to display new
* notifications on every pageload.
*
* @since 2.0.18
* @access public
*
* @param Gdn_Controller $Sender The object calling this method.
*/
public static function informNotifications($Sender)
{
$Session = Gdn::session();
if (!$Session->isValid()) {
return;
}
$ActivityModel = new ActivityModel();
// Get five pending notifications.
$Where = array('NotifyUserID' => Gdn::session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
// If we're in the middle of a visit only get very recent notifications.
$Where['DateUpdated >'] = Gdn_Format::toDateTime(strtotime('-5 minutes'));
$Activities = $ActivityModel->getWhere($Where, 0, 5)->resultArray();
$ActivityIDs = array_column($Activities, 'ActivityID');
$ActivityModel->setNotified($ActivityIDs);
$Sender->EventArguments['Activities'] =& $Activities;
$Sender->fireEvent('InformNotifications');
foreach ($Activities as $Activity) {
if ($Activity['Photo']) {
$UserPhoto = anchor(img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
} else {
$UserPhoto = '';
}
$Excerpt = Gdn_Format::plainText($Activity['Story']);
$ActivityClass = ' Activity-' . $Activity['ActivityType'];
$Sender->informMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
}
}
示例2: base_render_before
/**
* Add Timeago to all controllers
*
* @since 2.0.0
* @access public
* @param Gdn_Controller $sender
*/
public function base_render_before($sender)
{
// Plugin definitions for use in Javascript
$definitions = array('locale' => array('prefixAgo' => t('timeago.prefixAgo', null), 'prefixFromNow' => t('timeago.prefixFromNow', null), 'suffixAgo' => t('timeago.suffixAgo', 'ago'), 'suffixFromNow' => t('timeago.suffixFromNow', 'from now'), 'seconds' => t('timeago.seconds', 'less than a minute'), 'minute' => t('timeago.minute', 'about a minute'), 'minutes' => t('timeago.minutes', '%d minutes'), 'hour' => t('timeago.hour', 'about an hour'), 'hours' => t('timeago.hours', 'about %d hours'), 'day' => t('timeago.day', 'a day'), 'days' => t('timeago.days', '%d days'), 'month' => t('timeago.month', 'about a month'), 'months' => t('timeago.months', '%d months'), 'year' => t('timeago.year', 'about a year'), 'years' => t('timeago.years', '%d years'), 'wordSeparator' => t('timeago.wordSeparator', ' '), 'numbers' => array()));
$sender->addDefinition('Timeago', json_encode($definitions));
// Add required assets
$sender->addJsFile('timeago.min.js', 'plugins/timeago');
}
示例3: AttachButtonBar
/**
* Attach button bar in place
*
* This method is abstracted because it is called from multiple places, due
* to the way that the comment.php view is invoked both by the DiscussionController
* and the PostController.
*
* @param Gdn_Controller $Sender
*/
protected function AttachButtonBar($Sender, $Wrap = FALSE)
{
$View = $Sender->FetchView('buttonbar', '', 'plugins/ButtonBar');
if ($Wrap) {
echo Wrap($View, 'div', array('class' => 'P'));
} else {
echo $View;
}
}
示例4: render
/**
* Wrapper for captcha rendering.
*
* Allows conditional ignoring of captcha rendering if skipped in the config.
*
* @param Gdn_Controller $controller
* @return null;
*/
public static function render($controller)
{
if (!Captcha::enabled()) {
return null;
}
// Hook to allow rendering of captcha form
$controller->fireAs('captcha')->fireEvent('render');
return null;
}
示例5: 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();
}
示例6: SettingsController_Render_Before
/**
*
* @param Gdn_Controller $Sender
* @param array $Args
*/
public function SettingsController_Render_Before($Sender, $Args)
{
if (strcasecmp($Sender->RequestMethod, 'locales') != 0) {
return;
}
// Add a little pointer to the settings.
$Text = '<div class="Info">' . sprintf(T('Locale Developer Settings %s.'), Anchor(T('here'), '/dashboard/settings/localedeveloper')) . '</div>';
$Sender->AddAsset('Content', $Text, 'LocaleDeveloperLink');
}
示例7: Base_Render_Before
/**
* Add the rtl stylesheets to the page.
*
* The rtl stylesheets should always be added separately so that they aren't combined with other stylesheets when
* a non-rtl language is still being displayed.
*
* @param Gdn_Controller $Sender
*/
public function Base_Render_Before(&$Sender)
{
$currentLocale = substr(Gdn::Locale()->Current(), 0, 2);
if (in_array($currentLocale, $this->rtlLocales)) {
if (InSection('Dashboard')) {
$Sender->AddCssFile('admin_rtl.css', 'plugins/RightToLeft');
} else {
$Sender->AddCssFile('style_rtl.css', 'plugins/RightToLeft');
}
$Sender->CssClass .= ' rtl';
}
}
示例8: EntryController_Render_Before
/**
* @param Gdn_Controller $Sender
* @param array $Args
*/
public function EntryController_Render_Before($Sender, $Args)
{
if ($Sender->RequestMethod != 'passwordreset') {
return;
}
if (isset($Sender->Data['User'])) {
// Get all of the users with the same email.
$Email = $Sender->Data('User.Email');
$Users = Gdn::SQL()->Select('Name')->From('User')->Where('Email', $Email)->Get()->ResultArray();
$Names = array_column($Users, 'Name');
SetValue('Name', $Sender->Data['User'], implode(', ', $Names));
}
}
示例9: initialize
/**
* Adds JS, CSS, & modules. Automatically run on every use.
*
* @since 2.0.0
* @access public
*/
public function initialize()
{
$this->ModuleSortContainer = 'Profile';
$this->Head = new HeadModule($this);
$this->addJsFile('jquery.js');
$this->addJsFile('jquery.form.js');
$this->addJsFile('jquery.popup.js');
$this->addJsFile('jquery.gardenhandleajaxform.js');
$this->addJsFile('jquery.autosize.min.js');
$this->addJsFile('global.js');
$this->addCssFile('style.css');
$this->addCssFile('vanillicon.css', 'static');
$this->addModule('GuestModule');
parent::initialize();
Gdn_Theme::section('Profile');
if ($this->EditMode) {
$this->CssClass .= 'EditMode';
}
/**
* The default Cache-Control header does not include no-store, which can cause issues with outdated session
* information (e.g. message button missing). The same check is performed here as in Gdn_Controller before the
* Cache-Control header is added, but this value includes the no-store specifier.
*/
if (Gdn::session()->isValid()) {
$this->setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');
}
$this->setData('Breadcrumbs', array());
$this->CanEditPhotos = Gdn::session()->checkRankedPermission(c('Garden.Profile.EditPhotos', true)) || Gdn::session()->checkPermission('Garden.Users.Edit');
}
示例10: attachButtonBarResources
/**
* Insert buttonbar resources
*
* This method is abstracted because it is invoked by multiple controllers.
*
* @param Gdn_Controller $Sender
*/
protected function attachButtonBarResources($Sender, $Formatter)
{
if (!in_array($Formatter, $this->Formats)) {
return;
}
$Sender->addJsFile('buttonbar.js', 'plugins/ButtonBar');
$Sender->addJsFile('jquery.hotkeys.js', 'plugins/ButtonBar');
$Sender->addDefinition('ButtonBarLinkUrl', t('ButtonBar.LinkUrlText', 'Enter your URL:'));
$Sender->addDefinition('ButtonBarImageUrl', t('ButtonBar.ImageUrlText', 'Enter image URL:'));
$Sender->addDefinition('ButtonBarBBCodeHelpText', t('ButtonBar.BBCodeHelp', 'You can use <b><a href="http://en.wikipedia.org/wiki/BBCode" target="_new">BBCode</a></b> in your post.'));
$Sender->addDefinition('ButtonBarHtmlHelpText', t('ButtonBar.HtmlHelp', 'You can use <b><a href="http://htmlguide.drgrog.com/cheatsheet.php" target="_new">Simple Html</a></b> in your post.'));
$Sender->addDefinition('ButtonBarMarkdownHelpText', t('ButtonBar.MarkdownHelp', 'You can use <b><a href="http://en.wikipedia.org/wiki/Markdown" target="_new">Markdown</a></b> in your post.'));
$Sender->addDefinition('InputFormat', $Formatter);
}
示例11: Initialize
/**
* This is a good place to include JS, CSS, and modules used by all methods of this controller.
*
* Always called by dispatcher before controller's requested method.
*
* @since 1.0
* @access public
*/
public function Initialize() {
// There are 4 delivery types used by Render().
// DELIVERY_TYPE_ALL is the default and indicates an entire page view.
if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
$this->Head = new HeadModule($this);
// Call Gdn_Controller's Initialize() as well.
parent::Initialize();
}
示例12: Error
public function Error()
{
$this->RemoveCssFile('admin.css');
$this->AddCssFile('style.css');
$this->MasterView = 'default';
$this->CssClass = 'SplashMessage NoPanel';
$this->SetData('_NoMessages', TRUE);
$Code = $this->Data('Code', 400);
header("HTTP/1.0 {$Code} " . Gdn_Controller::GetStatusMessage($Code), TRUE, $Code);
$this->Render();
}
示例13: FetchViewLocation
public function FetchViewLocation($View = '', $ControllerName = FALSE, $ApplicationFolder = FALSE, $ThrowError = TRUE)
{
if (!$ControllerName) {
$ControllerName = '';
}
return parent::FetchViewLocation($View, $ControllerName, $ApplicationFolder, $ThrowError);
}
示例14: fetchViewLocation
/**
* Get the file location of a view.
*
* @param string $view
* @param bool $controllerName
* @param bool $applicationFolder
* @param bool $throwError
* @param bool $useController
* @return bool|mixed
* @throws Exception
*/
public function fetchViewLocation($view = '', $controllerName = false, $applicationFolder = false, $throwError = true, $useController = true)
{
if (!$controllerName) {
$controllerName = '';
}
return parent::fetchViewLocation($view, $controllerName, $applicationFolder, $throwError, $useController);
}
示例15: Initialize
public function Initialize()
{
if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
$this->Head = new HeadModule($this);
}
parent::Initialize();
}