public function run()
 {
     if (Yii::app()->request->isAjaxRequest) {
         if (isset($_POST['page_url'])) {
             $url = $_POST['page_url'];
             $disqusComponent = Yii::app()->disqusComments;
             /** @var EDisqusComments $disqusComponent */
             $duration = $disqusComponent->queryCacheDuration;
             $dependency = new \CGlobalStateCacheDependency('DisqusComments');
             $comments = DisqusComments::model()->cache($duration, $dependency)->findByAttributes(array('page_url' => $url));
             if (!isset($comments)) {
                 DisqusComments::saveNewUrl($url);
             }
             echo EDisqusComments::createCommentsJSON($comments->comments_block);
         }
     }
 }
 public function run()
 {
     $disqusComponent = Yii::app()->disqusComments;
     /** @var EDisqusComments $disqusComponent */
     $commentsBlock = $disqusComponent->getCache('commentBlock_' . md5($this->pageUrl));
     if ($commentsBlock === false) {
         $duration = $disqusComponent->queryCacheDuration;
         $dependency = new \CGlobalStateCacheDependency('DisqusComments');
         $disqusComments = DisqusComments::model()->cache($duration, $dependency)->findByAttributes(array('page_url' => $this->pageUrl));
         if (isset($disqusComments)) {
             $comments = json_decode($disqusComments->comments_block);
             $commentsBlock = EDisqusComments::createCommentsHTML($comments);
         } else {
             $commentsBlock = '';
             if ($disqusComponent->autoUpdateMap && !empty($this->pageUrl)) {
                 DisqusComments::saveNewUrl($this->pageUrl);
             }
         }
         $disqusComponent->setCache('commentBlock_' . md5($this->pageUrl), $commentsBlock);
     }
     $this->render('disqusCommentsWidget', array('commentsBlock' => $commentsBlock, 'apiKey' => $disqusComponent->apiKey, 'shortName' => $disqusComponent->shortName));
 }