コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function blockAccess(AccountInterface $account)
 {
     if ($account->hasPermission('access content')) {
         $daytop = $this->configuration['top_day_num'];
         if (!$daytop || !($result = statistics_title_list('daycount', $daytop)) || !($this->day_list = node_title_list($result, t("Today's:")))) {
             return FALSE;
         }
         $alltimetop = $this->configuration['top_all_num'];
         if (!$alltimetop || !($result = statistics_title_list('totalcount', $alltimetop)) || !($this->all_time_list = node_title_list($result, t('All time:')))) {
             return FALSE;
         }
         $lasttop = $this->configuration['top_last_num'];
         if (!$lasttop || !($result = statistics_title_list('timestamp', $lasttop)) || !($this->last_list = node_title_list($result, t('Last viewed:')))) {
             return FALSE;
         }
         return TRUE;
     }
     return FALSE;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function blockAccess(AccountInterface $account)
 {
     $access = AccessResult::allowedIfHasPermission($account, 'access content');
     if ($account->hasPermission('access content')) {
         $daytop = $this->configuration['top_day_num'];
         if (!$daytop || !($result = statistics_title_list('daycount', $daytop)) || !($this->day_list = node_title_list($result, $this->t("Today's:")))) {
             return AccessResult::forbidden()->inheritCacheability($access);
         }
         $alltimetop = $this->configuration['top_all_num'];
         if (!$alltimetop || !($result = statistics_title_list('totalcount', $alltimetop)) || !($this->all_time_list = node_title_list($result, $this->t('All time:')))) {
             return AccessResult::forbidden()->inheritCacheability($access);
         }
         $lasttop = $this->configuration['top_last_num'];
         if (!$lasttop || !($result = statistics_title_list('timestamp', $lasttop)) || !($this->last_list = node_title_list($result, $this->t('Last viewed:')))) {
             return AccessResult::forbidden()->inheritCacheability($access);
         }
         return $access;
     }
     return AccessResult::forbidden()->inheritCacheability($access);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $content = array();
     if ($this->configuration['top_day_num'] > 0) {
         $result = statistics_title_list('daycount', $this->configuration['top_day_num']);
         if ($result) {
             $content['top_day'] = node_title_list($result, $this->t("Today's:"));
             $content['top_day']['#suffix'] = '<br />';
         }
     }
     if ($this->configuration['top_all_num'] > 0) {
         $result = statistics_title_list('totalcount', $this->configuration['top_all_num']);
         if ($result) {
             $content['top_all'] = node_title_list($result, $this->t('All time:'));
             $content['top_all']['#suffix'] = '<br />';
         }
     }
     if ($this->configuration['top_last_num'] > 0) {
         $result = statistics_title_list('timestamp', $this->configuration['top_last_num']);
         $content['top_last'] = node_title_list($result, $this->t('Last viewed:'));
         $content['top_last']['#suffix'] = '<br />';
     }
     return $content;
 }