/** */ function smarty_function_category_link($Params, &$Smarty) { $Path = GetValue('path', $Params, '', TRUE); $Text = GetValue('text', $Params, '', TRUE); $Wrap = GetValue('wrap', $Params, 'li'); return Gdn_Theme::Link('category', GetValue('text', $Params, ''), GetValue('format', $Params, Wrap('<a href="%url" class="%class">%text</a>', $Wrap))); }
/** * 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')); } }
public function ToString() { if ($this->_UserData->NumRows() == 0) { return ''; } $String = ''; ob_start(); ?> <div class="Box"> <?php echo panelHeading(T('In this Discussion')); ?> <ul class="PanelInfo"> <?php foreach ($this->_UserData->Result() as $User) { ?> <li> <?php echo Anchor(Wrap(Wrap(Gdn_Format::Date($User->DateLastActive, 'html')), 'span', array('class' => 'Aside')) . ' ' . Wrap(Wrap(GetValue('Name', $User), 'span', array('class' => 'Username')), 'span'), UserUrl($User)); ?> </li> <?php } ?> </ul> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }
/** * Output locale links. * * @return string|void */ public function toString() { if (!$this->Links) { $this->Links = $this->BuildLocales(); } echo Wrap($this->Links, 'div', array('class' => 'LocaleOptions')); }
/** * A placeholder for future menu items. * * @param array The parameters passed into the function. This currently takes no parameters. * @param Smarty The smarty object rendering the template. * @return */ function smarty_function_custom_menu($Params, &$Smarty) { $Controller = $Smarty->Controller; if (is_object($Menu = GetValue('Menu', $Controller))) { $Format = GetValue('format', $Params, Wrap('<a href="%url" class="%class">%text</a>', GetValue('wrap', $Params, 'li'))); $Result = ''; foreach ($Menu->Items as $Group) { foreach ($Group as $Item) { // Make sure the item is a custom item. if (GetValueR('Attributes.Standard', $Item)) { continue; } // Make sure the user has permission for the item. if ($Permission = GetValue('Permission', $Item)) { if (!Gdn::Session()->CheckPermission($Permission)) { continue; } } if (($Url = GetValue('Url', $Item)) && ($Text = GetValue('Text', $Item))) { $Result .= Gdn_Theme::Link($Url, $Text, $Format); } } } return $Result; } return ''; }
/** * Show alternate locale options in Foot. */ public function Base_Render_Before($Sender) { // Not in Dashboard // Block guests until guest sessions are restored if ($Sender->MasterView == 'admin') { return; } // Get locales $LocaleModel = new LocaleModel(); $Options = $LocaleModel->EnabledLocalePacks(); $Locales = $LocaleModel->AvailableLocalePacks(); // Build & add links $Links = ''; foreach ($Options as $Slug => $Code) { $LocaleInfo = GetValue($Slug, $Locales); $LocaleName = str_replace(' Transifex', '', GetValue('Name', $LocaleInfo)); // No 'Transifex' in names, pls. $Links .= $this->BuildLocaleLink($LocaleName, $Code); } // Hackily add English option $Links .= $this->BuildLocaleLink('English', 'en-CA'); $LocaleLinks = Wrap($Links, 'div', array('class' => 'languages')); $Sender->AddAsset('Foot', $LocaleLinks); // Add a simple style $Sender->AddAsset('Head', '<style>.Dashboard .LocaleOptions { display: none; }</style>'); $Sender->setData('Locale', substr(Gdn::Locale()->Current(), 0, 2)); }
/** */ function smarty_function_nomobile_link($Params, &$Smarty) { $Path = GetValue('path', $Params, '', TRUE); $Text = GetValue('text', $Params, '', TRUE); $Wrap = GetValue('wrap', $Params, 'li'); return Gdn_Theme::Link('profile/nomobile', GetValue('text', $Params, T("Full Site")), GetValue('format', $Params, Wrap('<a href="%url" class="%class">%text</a>', $Wrap))); }
/** */ function smarty_function_signin_link($Params, &$Smarty) { if (!Gdn::Session()->IsValid()) { $Wrap = GetValue('wrap', $Params, 'li'); return Gdn_Theme::Link('signinout', GetValue('text', $Params, ''), GetValue('format', $Params, Wrap('<a href="%url" rel="nofollow" class="%class">%text</a>', $Wrap)), $Params); } }
public function Page($Reference) { $PageModel = new PageModel(); $Page = $PageModel->GetFullID($Reference); if (!$Page) { throw NotFoundException(); } $this->Page = $Page; if ($this->Head) { SetMetaTags($Page, $this); if ($Page->CustomCss) { $CustomCss = "\n" . $Page->CustomCss; if (!StringBeginsWith(trim($CustomCss), '<style', True)) { $CustomCss = Wrap($CustomCss, 'style', array('type' => 'text/css')); } $this->Head->AddString($CustomCss); } if ($Page->CustomJs) { $CustomJs = $Page->CustomJs; if (!StringBeginsWith(trim($CustomJs), '<script', True)) { $CustomJs = Wrap($CustomJs, 'script', array('type' => 'text/javascript')); } $this->Head->AddString($CustomJs); } } if ($Page->SectionID) { $this->Section = BuildNode($Page, 'Section'); $this->SectionID = $Page->SectionID; CandyHooks::AddModules($this, $this->Section); } $this->FireEvent('ContentPage'); if ($Page->View) { $this->View = $this->FetchViewLocation($this->View, False, False, False); } if (!$this->View) { $this->View = $this->FetchViewLocation('view', 'page', '', False); if (!$this->View) { $this->View = 'default'; } } $this->Title($Page->Title); $this->SetData('Content', $Page, True); $this->EventArguments['Format'] =& $Page->Format; $this->EventArguments['Body'] =& $Page->Body; $this->FireEvent('BeforeBodyFormat'); $this->ContentBodyHtml = Gdn_Format::To($Page->Body, $Page->Format); $Doc = PqDocument($this->ContentBodyHtml); $Header = $Doc->Find('h1'); $CountH1 = count($Header); if ($CountH1 == 0) { $this->SetData('Headline', Gdn_Format::Text($Page->Title)); } elseif ($CountH1 == 1) { $this->SetData('Headline', $Header->Text()); $Header->Remove(); $this->ContentBodyHtml = $Doc->Html(); } // $this->AddModule('PageInfoModule'); $this->Render(); }
function DiscussionPollAnswerForm($PollForm, $Poll, $PartialAnswers) { echo '<div class="DP_AnswerForm">'; if (GetValue('Title', $Poll) || C('Plugins.DiscussionPolls.DisablePollTitle', FALSE)) { echo $Poll->Title; if (trim($Poll->Title) != FALSE) { echo '<hr />'; } } echo $PollForm->Open(array('action' => Url('/discussion/poll/submit/'), 'method' => 'post', 'ajax' => TRUE)); echo $PollForm->Errors(); $m = 0; // Render poll questions echo '<ol class="DP_AnswerQuestions">'; foreach ($Poll->Questions as $Question) { echo '<li class="DP_AnswerQuestion">'; echo $PollForm->Hidden('DP_AnswerQuestions[]', array('value' => $Question->QuestionID)); echo Wrap($Question->Title, 'span'); echo '<ol class="DP_AnswerOptions">'; foreach ($Question->Options as $Option) { if (GetValue($Question->QuestionID, $PartialAnswers) == $Option->OptionID) { //fill in partial answer echo Wrap($PollForm->Radio('DP_Answer' . $m, $Option->Title, array('Value' => $Option->OptionID, 'checked' => 'checked')), 'li'); } else { echo Wrap($PollForm->Radio('DP_Answer' . $m, $Option->Title, array('Value' => $Option->OptionID)), 'li'); } } echo '</ol>'; echo '</li>'; $m++; } echo '</ol>'; echo $PollForm->Close('Submit'); echo '</div>'; }
function WriteHomepageOption($Title, $Url, $CssClass, $Current, $Description = '') { $SpriteClass = $CssClass; if ($Current == $Url) { $CssClass .= ' Current'; } echo Anchor(T($Title) . Wrap(Sprite($SpriteClass), 'span', array('class' => 'Wrap')), $Url, array('class' => $CssClass, 'title' => $Description)); }
/** * Add a mod message to NoIndex discussions. */ public function DiscussionController_BeforeDiscussionDisplay_Handler($Sender, $Args) { if (!CheckPermission(array('Garden.Moderation.Manage', 'Garden.Curation.Manage'), FALSE)) { return; } if (GetValue('NoIndex', $Sender->Data('Discussion'))) { echo Wrap(T('Discussion marked as noindex'), 'div', array('class' => 'Warning')); } }
function TutLink($TutorialCode, $WriteTitle = TRUE, $ThumbnailSize = 'medium') { $Tutorial = GetTutorials($TutorialCode); if (!$Tutorial) { return ''; } $Thumbnail = $ThumbnailSize == 'medium' ? $Tutorial['Thumbnail'] : $Tutorial['LargeThumbnail']; return Anchor('<img src="' . $Thumbnail . '" alt="' . $Tutorial['Name'] . '" title="' . $Tutorial['Name'] . '" />' . ($WriteTitle ? Wrap($Tutorial['Name']) : ''), 'settings/tutorials/' . $Tutorial['Code']); }
function writeHomepageOption($Title, $Url, $CssClass, $Current, $Description = '') { $SpriteClass = $CssClass; if ($Current == $Url) { $CssClass .= ' Current'; } $CssClass .= ' Choice'; echo anchor(t($Title) . Wrap(sprite($SpriteClass), 'span', array('class' => 'Wrap')), $Url, array('class' => $CssClass, 'title' => $Description, 'rel' => $Url)); }
public function Base_BeforeSignInLink_Handler($Sender) { if (!$this->IsConfigured()) { return; } // if (!IsMobile()) // return; if (!Gdn::Session()->IsValid()) { echo "\n" . Wrap($this->_GetButton(), 'li', array('class' => 'Connect FacebookConnect')); } }
/** * 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')); } } }
function WriteRangeTab($Range, $Sender) { echo Wrap( Anchor( Capitalize($Range), 'settings?' .http_build_query(array('Range' => $Range)) ), 'li', $Range == $Sender->Range ? array('class' => 'Active') : '' )."\n"; }
public function PluginController_MembersListEnh_Create($Sender) { $Session = Gdn::Session(); if ($Sender->Menu && (CheckPermission('Plugins.MembersListEnh.GenView') || CheckPermission('Plugins.MembersListEnh.IPEmailView'))) { $Sender->ClearCssFiles(); $Sender->AddCssFile('style.css'); $Sender->MasterView = 'default'; $Sender->Render('memtable', '', 'plugins/MembersListEnh'); } else { echo Wrap(Anchor(Img('/plugins/MembersListEnh/design/AccessDenied.png', array('width' => '100%'), array('title' => T('You Have No Permission To View This Page Go Back'))), '/discussions', array('target' => '_self')), 'h1'); } }
/** * Allow mods to bump via discussion options. */ public function Base_DiscussionOptions_Handler($Sender, $Args) { $Discussion = $Args['Discussion']; if (CheckPermission('Garden.Moderation.Manage')) { $Label = T('Bump'); $Url = "/discussion/bump?discussionid={$Discussion->DiscussionID}"; // Deal with inconsistencies in how options are passed if (isset($Sender->Options)) { $Sender->Options .= Wrap(Anchor($Label, $Url, 'Bump'), 'li'); } else { $Args['DiscussionOptions']['Bump'] = array('Label' => $Label, 'Url' => $Url, 'Class' => 'Bump'); } } }
/** * Allow admin to Change Author via discussion options. */ public function Base_DiscussionOptions_Handler($Sender, $Args) { $Discussion = $Args['Discussion']; if (Gdn::Session()->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID)) { $Label = T('Change Author'); $Url = "/discussion/author?discussionid={$Discussion->DiscussionID}"; // Deal with inconsistencies in how options are passed if (isset($Sender->Options)) { $Sender->Options .= Wrap(Anchor($Label, $Url, 'ChangeAuthor'), 'li'); } else { $Args['DiscussionOptions']['ChangeAuthor'] = array('Label' => $Label, 'Url' => $Url, 'Class' => 'ChangeAuthor'); } } }
public function ToString() { $String = ''; if ($this->CheckPermission()) { $String = parent::ToString(); } if ($String != '') { $WrapString = GetValue('WrapString', $this, True); if ($WrapString) { $String = Wrap($String, 'div', array('class' => 'Box', 'id' => 'PageInfoModule')); } } return $String; }
public function SettingsController_AfterRenderAsset_Handler($Sender) { $EventArguments = $Sender->EventArguments; $Method = $Sender->RequestMethod; if ($EventArguments['AssetName'] == 'Content') { if ($Method == 'managecategories') { echo Wrap(Wrap(T('RefreshCounts.CatHeading'), 'h3') . Wrap(T('RefreshCounts.CatDescription') . ' ' . Anchor(T('Refresh Counts'), '/categories/refreshcounts', array('class' => 'SmallButton', 'id' => 'RefreshCountsButton', 'title' => T('RefreshCounts.CatTooltip'))), 'div', array('class' => 'Info')), 'div', array('id' => 'RefreshCounts')); } else { if ($Method == 'tagging') { echo Wrap(Wrap(T('RefreshCounts.TagHeading'), 'h3') . Wrap(T('RefreshCounts.TagDescription') . ' ' . Anchor(T('Refresh Counts'), '/settings/refreshtagcounts', array('class' => 'SmallButton', 'id' => 'RefreshCountsButton', 'title' => T('RefreshCounts.TagTooltip'))), 'div', array('class' => 'Info')), 'div', array('id' => 'RefreshCounts')); } } } }
/** * Output user agent information. */ protected function AttachInfo($Sender, $Attributes) { if (!CheckPermission('Garden.Moderation.Manage')) { return; } $Info = ''; if ($Value = GetValue('Browser', $Attributes)) { $Info .= Wrap('Browser', 'dt') . ' ' . Wrap($Value, 'dd'); } if ($Value = GetValue('Platform', $Attributes)) { $Info .= Wrap('OS', 'dt') . ' ' . Wrap($Value, 'dd'); } echo Wrap($Info, 'dl', array('class' => "About UserAgentInfo")); }
public function ToString() { echo '<div class="Box DonateBox">'; echo Wrap(T('Donation Box'), 'h4'); echo '<ul class="PanelInfo">'; echo '<p></p>'; echo T("Your Donations will help keep this forum afloat"); echo '<p></p>'; echo Anchor(Gdn_Format::Text("My donation link"), Gdn_Format::Url("/donations")); // edit the links above to the appropriate paypal or whatever donate links and image echo Wrap(T('Item 1'), 'li'); echo Wrap(T('Item 2'), 'li'); echo "</ul>"; echo "</div>"; }
/** * Just include our JS on all category pages. */ public function CategoriesController_Render_Before($Sender) { $Sender->AddJsFile("category_collapse.js", "plugins/CategoryCollapser"); $Style = Wrap(' .Expando { float: right; background: url(plugins/CategoryCollapser/design/tagsprites.png) no-repeat 0 -52px; height: 16px; width: 16px; color: transparent; text-shadow: none; cursor: pointer; } .Expando-Collapsed .Expando { background-position: 0 -69px; }', 'style'); $Sender->AddAsset('Head', $Style); }
/** * Special manipulations. */ public function ParseSpecialFields($Fields = array()) { foreach ($Fields as $Label => $Value) { switch ($Label) { case 'Twitter': $Fields['Twitter'] = Anchor($Value, 'http://twitter.com/' . $Value); break; case 'Google+': $Fields['Google+'] = Anchor('Google+', $Value, '', array('rel' => 'me')); break; case 'Real Name': $Fields['Real Name'] = Wrap(htmlspecialchars($Value), 'span', array('itemprop' => 'name')); break; } } return $Fields; }
public function ProfileController_EditMyAccountAfter_Handler($Sender) { $Session = Gdn::Session(); // Get the default theme from the configuration $DefaultTheme = array(C('ThemeChooser.DefaultThemeCSS', false) => C('ThemeChooser.DefaultThemeName', false)); // Get the themefiles and themenames $ThemeFiles = explode(',', C('ThemeChooser.ThemeFiles', false)); $ThemeNames = explode(',', C('ThemeChooser.ThemeNames', false)); // Make them an array $ExtraThemes = $this->Combine_Array($ThemeFiles, $ThemeNames); // Merge the default theme and the extra themes $Options = $DefaultTheme + $ExtraThemes; $Selected = $this->GetUserMeta($Session->UserID, 'Theme', true, true); $Fields = array('TextField' => 'Text', 'ValueField' => 'Code', 'Value' => $Selected); echo $Sender->Form->Label('Theme'); echo Wrap($Sender->Form->Dropdown('ThemeChooser', $Options, $Fields), 'li', array('class' => 'ThemeChooser')); }
/** * Return the verified status of a user with a link to change it. * @param array|object $User * @return string */ function UserVerified($User) { $UserID = GetValue('UserID', $User); if (GetValue('Verified', $User)) { $Label = T('Verified'); $Title = T('Verified Description', 'Verified users bypass spam and pre-moderation filters.'); $Url = "/user/verify.json?userid={$UserID}&verified=0"; } else { $Label = T('Not Verified'); $Title = T('Not Verified Description', 'Unverified users are passed thru any enabled spam and pre-moderation filters.'); $Url = "/user/verify.json?userid={$UserID}&verified=1"; } if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) { return Anchor($Label, $Url, array('title' => $Title, 'class' => 'User-Verified Hijack')); } else { return Wrap($Label, 'span', array('title' => $Title, 'class' => 'User-Verified')); } }
/** * Return the verified status of a user with a link to change it. * @param array|object $User * @return string */ function UserVerified($User) { $UserID = GetValue('UserID', $User); if (GetValue('Verified', $User)) { $Label = T('Verified'); $Title = T('This user has been verified as a non-spammer.'); $Url = "/user/verify.json?userid={$UserID}&verified=0"; } else { $Label = T('Not Verified'); $Title = T('This user has not been verified as a non-spammer.'); $Url = "/user/verify.json?userid={$UserID}&verified=1"; } if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) { return Anchor($Label, $Url, array('title' => $Title, 'class' => 'User-Verified Hijack')); } else { return Wrap($Label, 'span', array('title' => $Title, 'class' => 'User-Verified')); } }
public function DiscussionsController_AfterRenderAsset_Handler($Sender) { $AssetName = GetValueR('EventArguments.AssetName', $Sender); if ($AssetName != "Content") { return; } $CurTime = time(); $LastTime = Gdn::Get('TimeCheck', $LastTime); $SFVcount = Gdn::Get('ViewCount', $SFVcount); $SFUcount = Gdn::Get('UserCount', $SFUcount); $SFDcount = Gdn::Get('DiscussionCount', $SFDcount); $SFCcount = Gdn::Get('CommentCount', $SFCcount); // refresh counts every 60 seconds unless config is set // e.g. $Configuration['Plugins']['StatisticsFooter']['Refresh'] = '90'; $IncSec = C('Plugins.StatisticsFooter.Refresh', 60); if ($CurTime > $LastTime) { $LastTime = time() + $IncSec; Gdn::Set('TimeCheck', $LastTime); $SFVcount = $this->GetViewCount(); Gdn::Set('ViewCount', $SFVcount); $SFUcount = $this->GetUserCount(); Gdn::Set('UserCount', $SFUcount); $SFDcount = $this->GetDiscussionCount(); Gdn::Set('DiscussionCount', $SFDcount); $SFCcount = $this->GetCommentCount(); Gdn::Set('CommentCount', $SFCcount); } $SFPcount = $SFDcount + $SFCcount; $ShowMe = C('Plugins.StatisticsFooter.Show'); if (strpos($ShowMe, "v") !== FALSE) { echo Wrap(Wrap(T('View Count')) . Gdn_Format::BigNumber($SFVcount), 'div', array('class' => 'SFBox SFVCBox')); } if (strpos($ShowMe, "u") !== FALSE) { echo Wrap(Wrap(T('User Count')) . Gdn_Format::BigNumber($SFUcount), 'div', array('class' => 'SFBox SFUBox')); } if (strpos($ShowMe, "t") !== FALSE) { echo Wrap(Wrap(T('Topic Count')) . Gdn_Format::BigNumber($SFDcount), 'div', array('class' => 'SFBox SFTBox')); } if (strpos($ShowMe, "c") !== FALSE) { echo Wrap(Wrap(T('Post Count')) . Gdn_Format::BigNumber($SFPcount), 'div', array('class' => 'SFBox SFPBox')); } }