public function base_render_before($sender)
 {
     // Bail out if we're in the dashboard
     if (inSection('Dashboard')) {
         return;
     }
     // Fetch the currently enabled locale (en by default)
     $locale = Gdn::locale()->current();
     $sender->setData('locale', $locale);
     $sender->Head->addCss('./themes/custom/design/extra.css');
 }
Ejemplo n.º 2
0
 /**
  * Adds 'Discussion' item to menu.
  *
  * 'base_render_before' will trigger before every pageload across apps.
  * If you abuse this hook, Tim will throw a Coke can at your head.
  *
  * @since 2.0.0
  * @package Vanilla
  *
  * @param Gdn_Controller $sender The sending controller object.
  */
 public function base_render_before($sender)
 {
     if ($sender->Menu) {
         $sender->Menu->addLink('Discussions', t('Discussions'), '/discussions', false, ['Standard' => true]);
     }
     if (!inSection('Dashboard')) {
         // Spoilers assets
         $sender->addJsFile('spoilers.js', 'vanilla');
         $sender->addCssFile('spoilers.css', 'vanilla');
         $sender->addDefinition('Spoiler', t('Spoiler'));
         $sender->addDefinition('show', t('show'));
         $sender->addDefinition('hide', t('hide'));
     }
     // Add user's viewable roles to gdn.meta if user is logged in.
     if (!$sender->addDefinition('Roles')) {
         if (Gdn::session()->isValid()) {
             $roleModel = new RoleModel();
             Gdn::controller()->addDefinition("Roles", $roleModel->getPublicUserRoles(Gdn::session()->UserID, "Name"));
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Whether or not this pocket should be processed based on its state.
  *
  * @param array $Data Data specific to the request.
  * @return bool
  */
 public function canRender($Data)
 {
     if (!$this->ShowInDashboard && inSection('Dashboard')) {
         return false;
     }
     $IsMobile = isMobile();
     if ($this->MobileOnly && !$IsMobile || $this->MobileNever && $IsMobile) {
         return false;
     }
     if ($this->isAd() && checkPermission('Garden.NoAds.Allow')) {
         return false;
     }
     if ($this->EmbeddedNever && strcasecmp(Gdn::controller()->RequestMethod, 'embed') == 0) {
         return false;
     }
     // Check to see if the pocket is enabled.
     switch ($this->Disabled) {
         case Pocket::DISABLED:
             return false;
         case Pocket::TESTING:
             if (!checkPermission('Plugins.Pockets.Manage')) {
                 return false;
             }
             break;
     }
     // Check to see if the page matches.
     if ($this->Page && strcasecmp($this->Page, val('PageName', $Data)) != 0) {
         return false;
     }
     // Check to see if this is repeating.
     $Count = val('Count', $Data);
     if ($Count) {
         switch ($this->RepeatType) {
             case Pocket::REPEAT_AFTER:
                 if (strcasecmp($Count, Pocket::REPEAT_AFTER) != 0) {
                     return false;
                 }
                 break;
             case Pocket::REPEAT_BEFORE:
                 if (strcasecmp($Count, Pocket::REPEAT_BEFORE) != 0) {
                     return false;
                 }
                 break;
             case Pocket::REPEAT_ONCE:
                 if ($Count != 1) {
                     return false;
                 }
                 break;
             case Pocket::REPEAT_EVERY:
                 $Frequency = (array) $this->RepeatFrequency;
                 $Every = val(0, $Frequency, 1);
                 if ($Every < 1) {
                     $Every = 1;
                 }
                 $Begin = val(1, $Frequency, 1);
                 if ($Count % $Every != $Begin % $Every) {
                     return false;
                 }
                 break;
             case Pocket::REPEAT_INDEX:
                 if (!in_array($Count, (array) $this->RepeatFrequency)) {
                     return false;
                 }
                 break;
         }
     }
     // If we've passed all of the tests then the pocket can be processed.
     return true;
 }