Пример #1
0
 /**
  * /lists/latest
  *
  * @return string
  */
 public function actionLatest()
 {
     $language = null;
     $languageSlug = $this->request->getQueryParam('languageSlug');
     if ($languageSlug) {
         $language = Language::find()->where(['isHidden' => 0, 'slug' => $languageSlug])->limit(1)->one();
     }
     return $this->render('latest', ['language' => $language, 'list' => LatestSnippets::get($language)]);
 }
Пример #2
0
 /**
  * /snippets/language-slug[/snippet-slug]
  *
  * @return string
  */
 public function actionIndex()
 {
     $this->parseQueryParams(true);
     // Make sure at least language slug is there
     if (!$this->language) {
         return $this->goHome();
     }
     if ($this->snippet) {
         $this->snippet->updateCounters(['views' => 1]);
         return $this->render('snippet', ['language' => $this->language, 'snippet' => $this->snippet, 'commentModel' => new CommentForm()]);
     } else {
         return $this->render('language', ['language' => $this->language, 'latestSnippets' => LatestSnippets::getTopTen($this->language), 'popularSnippets' => PopularSnippets::getTopTen($this->language)]);
     }
 }
Пример #3
0
 /**
  * Site Homepage
  *
  * @return string
  */
 public function actionIndex()
 {
     return $this->render('index', ['latestSnippets' => LatestSnippets::getTopTen(), 'popularSnippets' => PopularSnippets::getTopTen()]);
 }