本文整理汇总了PHP中Gdn_Controller::data方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Controller::data方法的具体用法?PHP Gdn_Controller::data怎么用?PHP Gdn_Controller::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Controller
的用法示例。
在下文中一共展示了Gdn_Controller::data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: postController_afterDiscussionFormOptions_handler
/**
* Add the tag input to the discussion form.
*
* @param Gdn_Controller $Sender
*/
public function postController_afterDiscussionFormOptions_handler($Sender)
{
if (in_array($Sender->RequestMethod, array('discussion', 'editdiscussion', 'question'))) {
// Setup, get most popular tags
$TagModel = TagModel::instance();
$Tags = $TagModel->getWhere(array('Type' => array_keys($TagModel->defaultTypes())), 'CountDiscussions', 'desc', c('Plugins.Tagging.ShowLimit', 50))->Result(DATASET_TYPE_ARRAY);
$TagsHtml = count($Tags) ? '' : t('No tags have been created yet.');
$Tags = Gdn_DataSet::index($Tags, 'FullName');
ksort($Tags);
// The tags must be fetched.
if ($Sender->Request->isPostBack()) {
$tag_ids = TagModel::SplitTags($Sender->Form->getFormValue('Tags'));
$tags = TagModel::instance()->getWhere(array('TagID' => $tag_ids))->resultArray();
$tags = array_column($tags, 'TagID', 'FullName');
} else {
// The tags should be set on the data.
$tags = array_column($Sender->data('Tags', array()), 'FullName', 'TagID');
$xtags = $Sender->data('XTags', array());
foreach (TagModel::instance()->defaultTypes() as $key => $row) {
if (isset($xtags[$key])) {
$xtags2 = array_column($xtags[$key], 'FullName', 'TagID');
foreach ($xtags2 as $id => $name) {
$tags[$id] = $name;
}
}
}
}
echo '<div class="Form-Tags P">';
// Tag text box
echo $Sender->Form->label('Tags', 'Tags');
echo $Sender->Form->textBox('Tags', array('data-tags' => json_encode($tags)));
// Available tags
echo wrap(Anchor(t('Show popular tags'), '#'), 'span', array('class' => 'ShowTags'));
foreach ($Tags as $Tag) {
$TagsHtml .= anchor(htmlspecialchars($Tag['FullName']), '#', 'AvailableTag', array('data-name' => $Tag['Name'], 'data-id' => $Tag['TagID'])) . ' ';
}
echo wrap($TagsHtml, 'div', array('class' => 'Hidden AvailableTags'));
echo '</div>';
}
}
示例3: base_render_before
/**
* Fire before every page render.
*
* @param Gdn_Controller $Sender
*/
public function base_render_before($Sender)
{
$Session = Gdn::session();
// Check the statistics.
if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
Gdn::statistics()->check();
}
// Enable theme previewing
if ($Session->isValid()) {
$PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', ''));
$PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', ''));
if ($PreviewThemeName != '') {
$Sender->Theme = $PreviewThemeName;
$Sender->informMessage(sprintf(t('You are previewing the %s theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/', 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
}
}
if ($Session->isValid()) {
$Confirmed = val('Confirmed', Gdn::session()->User, true);
if (UserModel::requireConfirmEmail() && !$Confirmed) {
$Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
$Sender->informMessage($Message, '');
}
}
// Add Message Modules (if necessary)
$MessageCache = Gdn::config('Garden.Messages.Cache', array());
$Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
$Exceptions = array('[Base]');
if (in_array($Sender->MasterView, array('', 'default'))) {
$Exceptions[] = '[NonAdmin]';
}
// SignIn popup is a special case
$SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
if ($SignInOnly) {
$Exceptions = array();
}
if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) {
$MessageModel = new MessageModel();
$MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID'));
foreach ($MessageData as $Message) {
$MessageModule = new MessageModule($Sender, $Message);
if ($SignInOnly) {
// Insert special messages even in SignIn popup
echo $MessageModule;
} elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
$Sender->addModule($MessageModule);
}
}
$Sender->MessagesLoaded = '1';
// Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
}
if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
$Gdn_Statistics = Gdn::factory('Statistics');
$Gdn_Statistics->check($Sender);
}
// Allow forum embedding
if ($Embed = c('Garden.Embed.Allow')) {
// Record the remote url where the forum is being embedded.
$RemoteUrl = c('Garden.Embed.RemoteUrl');
if (!$RemoteUrl) {
$RemoteUrl = GetIncomingValue('remote');
if ($RemoteUrl) {
saveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl);
}
}
if ($RemoteUrl) {
$Sender->addDefinition('RemoteUrl', $RemoteUrl);
}
if ($remoteUrlFormat = c('Garden.Embed.RemoteUrlFormat')) {
$Sender->addDefinition('RemoteUrlFormat', $remoteUrlFormat);
}
// Force embedding?
if (!IsSearchEngine() && strtolower($Sender->ControllerName) != 'entry') {
if (IsMobile()) {
$forceEmbedForum = c('Garden.Embed.ForceMobile') ? '1' : '0';
} else {
$forceEmbedForum = c('Garden.Embed.ForceForum') ? '1' : '0';
}
$Sender->addDefinition('ForceEmbedForum', $forceEmbedForum);
$Sender->addDefinition('ForceEmbedDashboard', c('Garden.Embed.ForceDashboard') ? '1' : '0');
}
$Sender->addDefinition('Path', Gdn::request()->path());
$get = Gdn::request()->get();
unset($get['p']);
// kludge for old index.php?p=/path
$Sender->addDefinition('Query', http_build_query($get));
// $Sender->addDefinition('MasterView', $Sender->MasterView);
$Sender->addDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
if ($Embed === 2) {
$Sender->addJsFile('vanilla.embed.local.js');
} else {
$Sender->addJsFile('embed_local.js');
}
} else {
$Sender->setHeader('X-Frame-Options', 'SAMEORIGIN');
}
//.........这里部分代码省略.........