本文整理汇总了PHP中ArrayInArray函数的典型用法代码示例。如果您正苦于以下问题:PHP ArrayInArray函数的具体用法?PHP ArrayInArray怎么用?PHP ArrayInArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ArrayInArray函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Base_Render_Before
public function Base_Render_Before(&$Sender)
{
$Session = Gdn::Session();
// Enable theme previewing
if ($Session->IsValid()) {
$PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
// echo 'test'.$PreviewThemeFolder;
if ($PreviewThemeFolder != '') {
$Sender->Theme = $PreviewThemeFolder;
$Sender->AddAsset('Content', $Sender->FetchView('previewtheme', 'settingscontroller', 'dashboard'));
$Sender->AddCssFile('previewtheme.css');
}
}
// 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 ($Sender->MasterView == 'admin') {
$Exceptions[] = '[Admin]';
} else {
if (in_array($Sender->MasterView, array('', 'default'))) {
$Exceptions[] = '[NonAdmin]';
}
}
if ($Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache)) {
$MessageModel = new MessageModel();
$MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions);
foreach ($MessageData as $Message) {
$MessageModule = new MessageModule($Sender, $Message);
$Sender->AddModule($MessageModule);
}
}
}
示例2: Base_Render_Before
public function Base_Render_Before(&$Sender)
{
$Session = Gdn::Session();
// Enable theme previewing
if ($Session->IsValid()) {
$PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
// echo 'test'.$PreviewThemeFolder;
if ($PreviewThemeFolder != '') {
$Sender->Theme = $PreviewThemeFolder;
$Sender->AddAsset('Content', $Sender->FetchView('previewtheme', 'settingscontroller', 'dashboard'));
$Sender->AddCssFile('previewtheme.css');
}
}
// 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 ($Sender->MasterView == 'admin') {
$Exceptions[] = '[Admin]';
} else {
if (in_array($Sender->MasterView, array('', 'default'))) {
$Exceptions[] = '[NonAdmin]';
}
}
if ($Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache)) {
$MessageModel = new MessageModel();
$MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions);
foreach ($MessageData as $Message) {
$MessageModule = new MessageModule($Sender, $Message);
$Sender->AddModule($MessageModule);
}
}
// If there are applicants, alert admins by showing in the main menu
if (in_array($Sender->MasterView, array('', 'default')) && $Sender->Menu && C('Garden.Registration.Method') == 'Approval') {
$CountApplicants = Gdn::UserModel()->GetApplicants()->NumRows();
if ($CountApplicants > 0) {
$Sender->Menu->AddLink('Applicants', T('Applicants') . ' <span>' . $CountApplicants . '</span>', '/dashboard/user/applicants', array('Garden.Registration.Manage'));
}
}
}
示例3: CheckPermission
/**
* Checks the currently authenticated user's permissions for the specified
* permission. Returns a boolean value indicating if the action is
* permitted.
*
* @param mixed $Permission The permission (or array of permissions) to check.
* @param int $JunctionID The JunctionID associated with $Permission (ie. A discussion category identifier).
* @param bool $FullMatch If $Permission is an array, $FullMatch indicates if all permissions specified are required. If false, the user only needs one of the specified permissions.
* @param string $JunctionTable The name of the junction table for a junction permission.
* @param in $JunctionID The ID of the junction permission.
* * @return boolean
*/
public function CheckPermission($Permission, $FullMatch = TRUE, $JunctionTable = '', $JunctionID = '')
{
if (is_object($this->User) && $this->User->Admin == '1') {
return TRUE;
}
$Permissions = $this->GetPermissions();
if (is_numeric($JunctionID) && $JunctionID > 0 && !C('Garden.Permissions.Disabled' . $JunctionTable)) {
// Junction permission ($Permissions[PermissionName] = array(JunctionIDs))
if (is_array($Permission)) {
foreach ($Permission as $PermissionName) {
if ($this->CheckPermission($PermissionName, FALSE, $JunctionTable, $JunctionID)) {
if (!$FullMatch) {
return TRUE;
}
} else {
if ($FullMatch) {
return FALSE;
}
}
}
return TRUE;
} else {
return array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && in_array($JunctionID, $Permissions[$Permission]);
}
} else {
// Non-junction permission ($Permissions = array(PermissionNames))
if (is_array($Permission)) {
return ArrayInArray($Permission, $Permissions, $FullMatch);
} else {
return in_array($Permission, $Permissions) || array_key_exists($Permission, $Permissions);
}
}
}
示例4: ToString
public function ToString($HighlightRoute = '')
{
if ($HighlightRoute == '') {
$HighlightRoute = $this->_HighlightRoute;
}
if ($HighlightRoute == '') {
$HighlightRoute = Gdn_Url::Request();
}
$this->FireEvent('BeforeToString');
$Username = '';
$UserID = '';
$Session_TransientKey = '';
$Permissions = array();
$Session = Gdn::Session();
$HasPermissions = FALSE;
$Admin = FALSE;
if ($Session->IsValid() === TRUE) {
$UserID = $Session->User->UserID;
$Username = $Session->User->Name;
$Session_TransientKey = $Session->TransientKey();
$Permissions = $Session->GetPermissions();
$HasPermissions = count($Permissions) > 0;
$Admin = $Session->User->Admin == '1' ? TRUE : FALSE;
}
$Menu = '';
if (count($this->Items) > 0) {
// Apply the menu group sort if present...
if (is_array($this->Sort)) {
$Items = array();
$Count = count($this->Sort);
for ($i = 0; $i < $Count; ++$i) {
$Group = $this->Sort[$i];
if (array_key_exists($Group, $this->Items)) {
$Items[$Group] = $this->Items[$Group];
unset($this->Items[$Group]);
}
}
foreach ($this->Items as $Group => $Links) {
$Items[$Group] = $Links;
}
} else {
$Items = $this->Items;
}
foreach ($Items as $GroupName => $Links) {
$ItemCount = 0;
$LinkCount = 0;
$OpenGroup = FALSE;
$Group = '';
foreach ($Links as $Key => $Link) {
$CurrentLink = FALSE;
$ShowLink = FALSE;
$RequiredPermissions = array_key_exists('Permission', $Link) ? $Link['Permission'] : FALSE;
if ($RequiredPermissions !== FALSE && !is_array($RequiredPermissions)) {
$RequiredPermissions = explode(',', $RequiredPermissions);
}
// Show if there are no permissions or the user has the required permissions or the user is admin
$ShowLink = $Admin || $RequiredPermissions === FALSE || ArrayInArray($RequiredPermissions, $Permissions, FALSE) === TRUE;
if ($ShowLink === TRUE) {
if ($ItemCount == 1) {
$Group .= '<ul>';
$OpenGroup = TRUE;
} else {
if ($ItemCount > 1) {
$Group .= "</li>\r\n";
}
}
$Url = ArrayValue('Url', $Link);
if (substr($Link['Text'], 0, 1) === '\\') {
$Text = substr($Link['Text'], 1);
} else {
$Text = str_replace('{Username}', $Username, $Link['Text']);
}
$Attributes = ArrayValue('Attributes', $Link, array());
$AnchorAttributes = ArrayValue('AnchorAttributes', $Link, array());
if ($Url !== FALSE) {
$Url = Url(str_replace(array('{Username}', '{UserID}', '{Session_TransientKey}'), array(urlencode($Username), $UserID, $Session_TransientKey), $Link['Url']));
$CurrentLink = $Url == Url($HighlightRoute);
$CssClass = ArrayValue('class', $Attributes, '');
if ($CurrentLink) {
$Attributes['class'] = $CssClass . ' Highlight';
}
$Group .= '<li' . Attribute($Attributes) . '><a' . Attribute($AnchorAttributes) . ' href="' . $Url . '">' . $Text . '</a>';
++$LinkCount;
} else {
$Group .= '<li' . Attribute($Attributes) . '>' . $Text;
}
++$ItemCount;
}
}
if ($OpenGroup === TRUE) {
$Group .= "</li>\r\n</ul>\r\n";
}
if ($Group != '' && $LinkCount > 0) {
$Menu .= $Group . "</li>\r\n";
}
}
if ($Menu != '') {
$Menu = '<ul id="' . $this->HtmlId . '"' . ($this->CssClass != '' ? ' class="' . $this->CssClass . '"' : '') . '>' . $Menu . '</ul>';
}
}
//.........这里部分代码省略.........
示例5: CheckPermission
/**
* Checks the currently authenticated user's permissions for the specified
* permission. Returns a boolean value indicating if the action is
* permitted.
*
* @param mixed $Permission The permission (or array of permissions) to check.
* @param int $JunctionID The JunctionID associated with $Permission (ie. A discussion category identifier).
* @param bool $FullMatch If $Permission is an array, $FullMatch indicates if all permissions specified are required. If false, the user only needs one of the specified permissions.
* @param string $JunctionTable The name of the junction table for a junction permission.
* @param in $JunctionID The ID of the junction permission.
* * @return boolean
*/
public function CheckPermission($Permission, $FullMatch = TRUE, $JunctionTable = '', $JunctionID = '')
{
if (is_object($this->User)) {
if ($this->User->Admin) {
return TRUE;
} elseif ($this->User->Banned || GetValue('Deleted', $this->User)) {
return FALSE;
}
}
// Allow wildcard permission checks (e.g. 'any' Category)
if ($JunctionID == 'any') {
$JunctionID = '';
}
$Permissions = $this->GetPermissions();
if ($JunctionTable && !C('Garden.Permissions.Disabled.' . $JunctionTable)) {
// Junction permission ($Permissions[PermissionName] = array(JunctionIDs))
if (is_array($Permission)) {
foreach ($Permission as $PermissionName) {
if ($this->CheckPermission($PermissionName, FALSE, $JunctionTable, $JunctionID)) {
if (!$FullMatch) {
return TRUE;
}
} else {
if ($FullMatch) {
return FALSE;
}
}
}
return TRUE;
} else {
if ($JunctionID !== '') {
$Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && in_array($JunctionID, $Permissions[$Permission]);
} else {
$Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && count($Permissions[$Permission]);
}
return $Result;
}
} else {
// Non-junction permission ($Permissions = array(PermissionNames))
if (is_array($Permission)) {
return ArrayInArray($Permission, $Permissions, $FullMatch);
} else {
return in_array($Permission, $Permissions) || array_key_exists($Permission, $Permissions);
}
}
}
示例6: base_render_before
/**
* Fire before every page render.
*
* @param Gdn_Controller $Sender
*/
public function base_render_before($Sender)
{
$Session = Gdn::session();
if ($Sender->MasterView == 'admin') {
if (val('Form', $Sender)) {
$Sender->Form->setStyles('bootstrap');
}
$Sender->CssClass = htmlspecialchars($Sender->CssClass);
$Sections = Gdn_Theme::section(null, 'get');
if (is_array($Sections)) {
foreach ($Sections as $Section) {
$Sender->CssClass .= ' Section-' . $Section;
}
}
// Get our plugin nav items.
$navAdapter = new NestedCollectionAdapter(DashboardNavModule::getDashboardNav());
$Sender->EventArguments['SideMenu'] = $navAdapter;
$Sender->fireEvent('GetAppSettingsMenuItems');
$Sender->removeJsFile('jquery.popup.js');
$Sender->addJsFile('vendors/jquery.checkall.min.js', 'dashboard');
$Sender->addJsFile('dashboard.js', 'dashboard');
$Sender->addJsFile('jquery.expander.js');
$Sender->addJsFile('settings.js', 'dashboard');
$Sender->addJsFile('vendors/tether.min.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/util.js', 'dashboard');
$Sender->addJsFile('vendors/drop.min.js', 'dashboard');
$Sender->addJsFile('vendors/moment.min.js', 'dashboard');
$Sender->addJsFile('vendors/daterangepicker.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/tooltip.js', 'dashboard');
$Sender->addJsFile('vendors/clipboard.min.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/dropdown.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/collapse.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/modal.js', 'dashboard');
$Sender->addJsFile('vendors/icheck.min.js', 'dashboard');
$Sender->addJsFile('jquery.tablejenga.js', 'dashboard');
$Sender->addJsFile('jquery.fluidfixed.js', 'dashboard');
$Sender->addJsFile('vendors/prettify/prettify.js', 'dashboard');
$Sender->addJsFile('vendors/ace/ace.js', 'dashboard');
$Sender->addJsFile('vendors/ace/ext-searchbox.js', 'dashboard');
$Sender->addCssFile('vendors/tomorrow.css', 'dashboard');
}
// Check the statistics.
if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
Gdn::statistics()->check();
}
// Inform user of theme previewing
if ($Session->isValid()) {
$PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', ''));
$PreviewMobileThemeFolder = htmlspecialchars($Session->getPreference('PreviewMobileThemeFolder', ''));
$PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', $PreviewThemeFolder));
$PreviewMobileThemeName = htmlspecialchars($Session->getPreference('PreviewMobileThemeName', $PreviewMobileThemeFolder));
if ($PreviewThemeFolder != '') {
$Sender->informMessage(sprintf(t('You are previewing the %s desktop theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
}
if ($PreviewMobileThemeFolder != '') {
$Sender->informMessage(sprintf(t('You are previewing the %s mobile theme.'), wrap($PreviewMobileThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/mobilethemes/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), '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);
//.........这里部分代码省略.........
示例7: 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');
}
//.........这里部分代码省略.........
示例8: Base_Render_Before
/**
*
* @param Gdn_Controller $Sender
*/
public function Base_Render_Before($Sender)
{
$Session = Gdn::Session();
// Enable theme previewing
if ($Session->IsValid()) {
$PreviewThemeName = $Session->GetPreference('PreviewThemeName', '');
$PreviewThemeFolder = $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()) {
$ConfirmEmail = C('Garden.Registration.ConfirmEmail', false);
$Confirmed = GetValue('Confirmed', Gdn::Session()->User, true);
if ($ConfirmEmail && !$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]');
// 2011-09-09 - mosullivan - No longer allowing messages in dashboard
// if ($Sender->MasterView == 'admin')
// $Exceptions[] = '[Admin]';
// else if (in_array($Sender->MasterView, array('', 'default')))
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') && (GetValue('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);
}
// Force embedding?
if (!IsSearchEngine() && !IsMobile() && strtolower($Sender->ControllerName) != 'entry') {
$Sender->AddDefinition('ForceEmbedForum', C('Garden.Embed.ForceForum') ? '1' : '0');
$Sender->AddDefinition('ForceEmbedDashboard', C('Garden.Embed.ForceDashboard') ? '1' : '0');
}
$Sender->AddDefinition('Path', Gdn::Request()->Path());
// $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');
}
// Allow return to mobile site
$ForceNoMobile = Gdn_CookieIdentity::GetCookiePayload('VanillaNoMobile');
if ($ForceNoMobile !== FALSE && is_array($ForceNoMobile) && in_array('force', $ForceNoMobile)) {
$Sender->AddAsset('Foot', Wrap(Anchor(T('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink');
}
}
示例9: ToString
public function ToString($HighlightRoute = '')
{
if ($HighlightRoute == '') {
$HighlightRoute = $this->_HighlightRoute;
}
if ($HighlightRoute == '') {
$HighlightRoute = Gdn_Url::Request();
}
$Username = '';
$UserID = '';
$Session_TransientKey = '';
$Permissions = array();
$Session = Gdn::Session();
$HasPermissions = FALSE;
$Admin = FALSE;
if ($Session->IsValid() === TRUE) {
$UserID = $Session->User->UserID;
$Username = $Session->User->Name;
$Session_TransientKey = $Session->TransientKey();
$Permissions = $Session->GetPermissions();
$HasPermissions = count($Permissions) > 0;
$Admin = $Session->User->Admin == '1' ? TRUE : FALSE;
}
$Menu = '';
if (count($this->Items) > 0) {
// Apply the menu sort if present...
if (is_array($this->Sort)) {
$Items = array();
$Count = count($this->Sort);
for ($i = 0; $i < $Count; ++$i) {
$Group = $this->Sort[$i];
if (array_key_exists($Group, $this->Items)) {
$Items[$Group] = $this->Items[$Group];
unset($this->Items[$Group]);
}
}
foreach ($Items as $Group => $Links) {
$LinkNames = ConsolidateArrayValuesByKey($Links, 'Text');
$SortedLinks = array();
for ($j = 0; $j < $Count; ++$j) {
$SortName = $this->Sort[$j];
$Key = array_search($SortName, $LinkNames);
if ($Key !== FALSE) {
$SortedLinks[] = $Links[$Key];
unset($Links[$Key]);
$LinkNames[$Key] = '-=EMPTY=-';
}
}
$SortedLinks = array_merge($SortedLinks, $Links);
$Items[$Group] = $SortedLinks;
}
} else {
$Items = $this->Items;
}
// Build the menu
foreach ($Items as $GroupName => $Links) {
$ItemCount = 0;
$LinkCount = 0;
$OpenGroup = FALSE;
$GroupIsActive = FALSE;
$GroupAnchor = '';
$Group = '';
foreach ($Links as $Key => $Link) {
$CurrentLink = FALSE;
$ShowLink = FALSE;
$RequiredPermissions = array_key_exists('Permission', $Link) ? $Link['Permission'] : FALSE;
if ($RequiredPermissions !== FALSE && !is_array($RequiredPermissions)) {
$RequiredPermissions = explode(',', $RequiredPermissions);
}
// Show if there are no permissions or the user has the required permissions or the user is admin
$ShowLink = $Admin || $RequiredPermissions === FALSE || ArrayInArray($RequiredPermissions, $Permissions, FALSE) === TRUE;
if ($ShowLink === TRUE) {
if ($ItemCount == 1) {
$Group .= '<ul class="PanelInfo">';
$OpenGroup = TRUE;
} else {
if ($ItemCount > 1) {
$Group .= "</li>\r\n";
}
}
$Url = ArrayValue('Url', $Link);
if (substr($Link['Text'], 0, 1) === '\\') {
$Text = substr($Link['Text'], 1);
} else {
$Text = str_replace('{Username}', $Username, $Link['Text']);
}
$Attributes = ArrayValue('Attributes', $Link, array());
if ($Url !== FALSE) {
$Url = str_replace(array('{Username}', '{UserID}', '{Session_TransientKey}'), array(urlencode($Username), $UserID, $Session_TransientKey), $Link['Url']);
if (substr($Url, 0, 5) != 'http:') {
if ($GroupAnchor == '' && $this->AutoLinkGroups) {
$GroupAnchor = $Url;
}
$Url = Url($Url);
$CurrentLink = $Url == Url($HighlightRoute);
if ($CurrentLink && !$GroupIsActive) {
$GroupIsActive = TRUE;
}
}
$CssClass = ArrayValue('class', $Attributes, '');
//.........这里部分代码省略.........
示例10: Base_Render_Before
/**
*
* @param Gdn_Controller $Sender
*/
public function Base_Render_Before(&$Sender)
{
$Session = Gdn::Session();
// Enable theme previewing
if ($Session->IsValid()) {
$PreviewThemeName = $Session->GetPreference('PreviewThemeName', '');
$PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
if ($PreviewThemeName != '') {
$Sender->Theme = $PreviewThemeName;
$Sender->InformMessage(sprintf(T('You are previewing the %s theme.'), Wrap($PreviewThemeName, 'em')) . '<div class="PreviewButtons">' . Anchor(T('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->TransientKey(), 'PreviewButton') . ' ' . Anchor(T('Cancel'), 'settings/cancelpreview/', 'PreviewButton') . '</div>', 'DoNotDismiss');
}
}
if ($Session->IsValid() && ($EmailKey = Gdn::Session()->GetAttribute('EmailKey'))) {
$NotifyEmailConfirm = TRUE;
// If this user was manually moved out of the confirmation role, get rid of their 'awaiting confirmation' flag
$ConfirmEmailRole = C('Garden.Registration.ConfirmEmailRole', FALSE);
$UserRoles = array();
$RoleData = Gdn::UserModel()->GetRoles($Session->UserID);
if ($RoleData !== FALSE && $RoleData->NumRows() > 0) {
$UserRoles = ConsolidateArrayValuesByKey($RoleData->Result(DATASET_TYPE_ARRAY), 'RoleID', 'Name');
}
if ($ConfirmEmailRole !== FALSE && !array_key_exists($ConfirmEmailRole, $UserRoles)) {
Gdn::UserModel()->SaveAttribute($Session->UserID, "EmailKey", NULL);
$NotifyEmailConfirm = FALSE;
}
if ($NotifyEmailConfirm) {
$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]');
// 2011-09-09 - mosullivan - No longer allowing messages in dashboard
// if ($Sender->MasterView == 'admin')
// $Exceptions[] = '[Admin]';
// else if (in_array($Sender->MasterView, array('', 'default')))
if (in_array($Sender->MasterView, array('', 'default'))) {
$Exceptions[] = '[NonAdmin]';
}
if ($Sender->MasterView != 'admin' && (GetValue('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache))) {
$MessageModel = new MessageModel();
$MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions);
foreach ($MessageData as $Message) {
$MessageModule = new MessageModule($Sender, $Message);
$Sender->AddModule($MessageModule);
}
$Sender->MessagesLoaded = '1';
// Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
}
// If there are applicants, alert admins by showing in the main menu
if (in_array($Sender->MasterView, array('', 'default')) && $Sender->Menu && C('Garden.Registration.Method') == 'Approval') {
$CountApplicants = Gdn::UserModel()->GetApplicantCount();
if ($CountApplicants > 0) {
$Sender->Menu->AddLink('Applicants', T('Applicants') . ' <span class="Alert">' . $CountApplicants . '</span>', '/dashboard/user/applicants', array('Garden.Applicants.Manage'));
}
}
if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
$Gdn_Statistics = Gdn::Factory('Statistics');
$Gdn_Statistics->Check($Sender);
}
// Allow forum embedding
if (C('Garden.Embed.Allow')) {
$Sender->AddJsFile('js/embed_local.js');
}
}
示例11: Base_Render_Before
/**
*
* @param Gdn_Controller $Sender
*/
public function Base_Render_Before($Sender)
{
$Session = Gdn::Session();
// Enable theme previewing
if ($Session->IsValid()) {
$PreviewThemeName = $Session->GetPreference('PreviewThemeName', '');
$PreviewThemeFolder = $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() && ($EmailKey = Gdn::Session()->GetAttribute('EmailKey'))) {
$NotifyEmailConfirm = TRUE;
// If this user was manually moved out of the confirmation role, get rid of their 'awaiting confirmation' flag
$ConfirmEmailRole = C('Garden.Registration.ConfirmEmailRole', FALSE);
$UserRoles = array();
$RoleData = Gdn::UserModel()->GetRoles($Session->UserID);
if ($RoleData !== FALSE && $RoleData->NumRows() > 0) {
$UserRoles = ConsolidateArrayValuesByKey($RoleData->Result(DATASET_TYPE_ARRAY), 'RoleID', 'Name');
}
if ($ConfirmEmailRole !== FALSE && !array_key_exists($ConfirmEmailRole, $UserRoles)) {
Gdn::UserModel()->SaveAttribute($Session->UserID, "EmailKey", NULL);
$NotifyEmailConfirm = FALSE;
}
if ($NotifyEmailConfirm) {
$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]');
// 2011-09-09 - mosullivan - No longer allowing messages in dashboard
// if ($Sender->MasterView == 'admin')
// $Exceptions[] = '[Admin]';
// else if (in_array($Sender->MasterView, array('', 'default')))
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' && (GetValue('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache))) {
$MessageModel = new MessageModel();
$MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions);
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 there are applicants, alert admins by showing in the main menu
if (in_array($Sender->MasterView, array('', 'default')) && $Sender->Menu && C('Garden.Registration.Method') == 'Approval') {
// $CountApplicants = Gdn::UserModel()->GetApplicantCount();
// if ($CountApplicants > 0)
// $Sender->Menu->AddLink('Applicants', T('Applicants').' <span class="Alert">'.$CountApplicants.'</span>', '/dashboard/user/applicants', array('Garden.Applicants.Manage'));
$Sender->Menu->AddLink('Applicants', T('Applicants'), '/dashboard/user/applicants', array('Garden.Applicants.Manage'));
}
if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
$Gdn_Statistics = Gdn::Factory('Statistics');
$Gdn_Statistics->Check($Sender);
}
// Allow forum embedding
if (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);
}
// Force embedding?
if (!IsSearchEngine() && !IsMobile()) {
$Sender->AddDefinition('ForceEmbedForum', C('Garden.Embed.ForceForum') ? '1' : '0');
$Sender->AddDefinition('ForceEmbedDashboard', C('Garden.Embed.ForceDashboard') ? '1' : '0');
}
$Sender->AddDefinition('Path', Gdn::Request()->Path());
// $Sender->AddDefinition('MasterView', $Sender->MasterView);
$Sender->AddDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
$Sender->AddJsFile('js/embed_local.js');
}
// Allow return to mobile site
//.........这里部分代码省略.........