Beispiel #1
0
if (($next = $section->getNextSection()) !== null) {
    $right = ' <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>';
    echo '<div class="pull-right">' . Html::a(Html::encode($next[1]) . $right, ['guide/view', 'section' => $next[0], 'version' => $guide->version, 'language' => $guide->language, 'type' => $guide->typeUrlName]) . '</div>';
}
echo '<div class="text-center"><a href="#">Go to Top <span class="glyphicon glyphicon-chevron-up" aria-hidden="true"></span></a></div>';
?>
                </div>

                <?php 
if (($editUrl = $section->editUrl) !== false) {
    ?>
                <div class="edit-icon"><i class="fa fa-github"></i></div>
                <p class="lang-en">
                    <em>Found a typo or you think this page needs improvement?<br />
                        <a href="<?php 
    echo $editUrl;
    ?>
">Edit it on github</a>!</em>
                </p>
                <?php 
}
?>
            </div>

            <?php 
echo \app\components\Comments::widget(['objectType' => 'guide', 'objectId' => $section->name . '-' . $guide->version]);
?>
        </div>
    </div>
</div>
 public function actionEdit()
 {
     $post = Yii::$app->request->post();
     return json_encode(['status' => Comments::editComment($post['commentId'], $post['type'], $post['text'])]);
 }
use yii\helpers\Url;
$this->title = "API Documentation for Yii {$version}";
if (!empty($title)) {
    $this->title = "{$title} - {$this->title}";
}
?>

<div class="container api-content">
	<?php 
echo strtr($content, ['<!-- YII_VERSION_SELECTOR -->' => $this->render('_versions.php', compact('version', 'versions', 'section')), '<!-- YII_DOWNLOAD_OPTIONS -->' => '<p>You may download the API documentation for offline use: </p><ul>' . '<li>' . Html::a("yii-docs-{$version}-en.tar.bz2", ['guide/download', 'version' => $version, 'language' => 'en', 'format' => 'tar.bz2']) . '</li>' . '<li>' . Html::a("yii-docs-{$version}-en.tar.gz", ['guide/download', 'version' => $version, 'language' => 'en', 'format' => 'tar.gz']) . '</li>' . '</ul>' . '<p>This page is also available in <a href="?_format=' . urlencode('json') . '">JSON format</a>:<br>' . '<code>curl ' . Url::to(['', 'version' => $version], true) . ' -H \'Accept: application/json\'</code></p>']);
?>
</div>

<div class="container">
    <?php 
echo \app\components\Comments::widget(['objectType' => 'api', 'objectId' => $version . '-' . $section]);
?>
</div>

<?php 
$this->registerJs(<<<'JS'

$(".api-content a.toggle").on('click', function () {
    var $this = $(this);
    if ($this.hasClass('properties-hidden')) {
        $this.text($this.text().replace(/Show/,'Hide'));
        $this.parents(".summary").find(".inherited").show();
        $this.removeClass('properties-hidden');
    } else {
        $this.text($this.text().replace(/Hide/,'Show'));
        $this.parents(".summary").find(".inherited").hide();
 public function actionPhoto($photo_id)
 {
     $photo = ClubPhoto::getAllPhotoInfo($photo_id);
     $club_id = $photo['club_id'];
     $this->getClubInfo($club_id, $club, $role, $potentialMembers, $isOpen);
     if (!$club['club_id']) {
         throw new \yii\web\HttpException(404);
     }
     if (!$isOpen) {
         return $this->redirect("/club{$club_id}");
     }
     View::viewPhotoClub($photo_id);
     $model = new CommentsClub();
     $from = "comments_club";
     $comments = Comments::getCommentsNew($photo_id, $from);
     $request = Yii::$app->request;
     if (!$club['is_closed_comments'] && $request->isAjax && $model->load($request->post()) && $model->validate()) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $model->date_time = date('Y-m-d H:i:s');
         $model->id_user = Yii::$app->user->getId();
         $model->text = htmlspecialchars($model->text);
         //визначення чи це простий комент чи це ре-комент
         $text = explode(":", $model->text);
         //перевіряємо чи введено коректне ім'я користувача якому дана відповідь
         $true_name = 0;
         foreach ($comments as $key) {
             if ($key['name'] == $text[0]) {
                 $true_name = 1;
             }
         }
         if (!$true_name) {
             $model->answer_id = 0;
         }
         if ($model->save()) {
             ClubPhoto::updateComments($photo_id, 1);
             $latest_id = $model->id;
             $user = User::find()->select('avatar, name')->where(["id" => $model->id_user])->one();
             echo json_encode(['text' => $model->text, 'id_user' => $model->id_user, 'name' => $user[name], 'avatar' => $user[avatar], 'id_comment' => $latest_id]);
             die;
         } else {
             echo 0;
         }
     }
     return $this->render('photo_page', ['club' => $club, 'photo' => $photo, 'comments' => $comments, 'model' => $model]);
 }
 public function actionPost($slug)
 {
     $model = new CommentsBlog();
     //витягнення статті
     $post = Blog::getPostByUrl($slug);
     //якщо немає 404
     if (!$post['article_id']) {
         throw new \yii\web\HttpException(404);
     }
     //якщо стаття закрита адміністратором, то редірект на всі статті
     if (!$post['article_id'] || time() < $post['time_closed']) {
         return $this->redirect('/blog/all');
     }
     View::viewArticle($post['article_id'], $post['views']);
     //перевірка чи користувач лайкнув
     if (!Yii::$app->user->isGuest) {
         $post['islike'] = Blog::isLikeArticle($post['article_id'], Yii::$app->user->getId());
     } else {
         $post['islike'] = false;
     }
     $i_blocked = User::checkIfIInBlaclList($post['id_author']);
     $user_id = $post['user_id'];
     $marks = Marks::getArticleMarks(20);
     $categories = Category::getAllCategory();
     //інші статті автора
     $other_articles = Blog::getOtherArticle($user_id, 0, 2, $post['article_id']);
     foreach ($other_articles as &$article) {
         $article['text'] = substr($article['text'], 0, 350) . '...';
     }
     ////        КОМЕНТАРІ         ////
     //витягуємо всі коменті до статті
     $from = "comments_blog";
     //отримання всіх коментарів до фотографії
     $comments = Comments::getCommentsNew($post['article_id'], $from);
     $request = Yii::$app->request;
     if ($request->isAjax && $model->load($request->post()) && $model->validate()) {
         if (!Yii::$app->user->isGuest) {
             $author_id = Blog::getIdAuthorArticle($model['id_article']);
             if (!User::checkIfIInBlaclList($author_id)) {
                 Yii::$app->response->format = Response::FORMAT_JSON;
                 $model->date_time = date('Y-m-d H:i:s');
                 $model->id_user = Yii::$app->user->getId();
                 $model->text = htmlspecialchars($model->text);
                 //визначення чи це простий комент чи це ре-комент
                 $text = explode(":", $model->text);
                 //перевіряємо чи введено коректне ім'я користувача якому дана відповідь
                 $true_name = 0;
                 foreach ($comment as $key) {
                     if ($key['name'] == $text[0]) {
                         $true_name = 1;
                     }
                 }
                 if (!$true_name) {
                     $model->answer_id = 0;
                 }
                 if ($model->save()) {
                     Blog::updateComments($post['article_id'], 1);
                     $latest_id = $model->id;
                     $user = User::find()->select('avatar, name')->where(["id" => $model->id_user])->one();
                     echo json_encode(['text' => $model->text, 'id_user' => $model->id_user, 'name' => $user['name'], 'avatar' => $user['avatar'], 'sex' => $user['sex'], 'id_comment' => $latest_id]);
                     die;
                 } else {
                     echo 0;
                 }
             } else {
                 return json_encode('error');
             }
         }
         ////        КОМЕНТАРІ         ////
     } else {
         return $this->render('post', ['post' => $post, 'other_articles' => $other_articles, 'marks' => $marks, 'categories' => $categories, 'user_id' => $user_id, 'model' => $model, 'comments' => $comments, 'i_blocked' => $i_blocked]);
     }
 }
 public function actionPhoto_page($id)
 {
     if (Photo::isClosedPhoto($id) == 1) {
         if (!Photo::checkPhotoAccess($id)) {
             $this->redirect('/id' . Yii::$app->user->getId());
         }
     }
     $model = new CommentsPhoto();
     $photo = Photo::getAllPhotoInfo($id);
     $i_blocked = User::checkIfIInBlaclList($photo['user_id']);
     if (!$photo['photo_id']) {
         throw new \yii\web\HttpException(404);
     }
     if ($photo['time_closed'] > time() && $photo['user_id'] != Yii::$app->user->getId()) {
         return $this->render('close_photo.php', ['time' => $photo['time_closed']]);
     }
     if ($photo['time_closed'] > time()) {
         $photo['photo_closed'] = "Дане фото було заблоковане";
     }
     //отримання всіх коментарів до фотографії
     $from = "comments_photo";
     $comments = Comments::getCommentsNew($photo['photo_id'], $from);
     $request = Yii::$app->request;
     if ($request->isAjax && $model->load($request->post()) && $model->validate()) {
         if (!User::checkIfIInBlaclList($photo['user_id'])) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             $model->date_time = date('Y-m-d H:i:s');
             $model->id_user = Yii::$app->user->getId();
             $model->text = htmlspecialchars($model->text);
             //визначення чи це простий комент чи це ре-комент
             $text = explode(":", $model->text);
             //перевіряємо чи введено коректне ім'я користувача якому дана відповідь
             $true_name = 0;
             foreach ($comments as $key) {
                 if ($key['name'] == $text[0]) {
                     $true_name = 1;
                 }
             }
             if (!$true_name) {
                 $model->answer_id = 0;
             }
             if ($model->save()) {
                 Photo::updateComments($photo['photo_id'], 1);
                 $latest_id = $model->id;
                 $user = User::find()->select('avatar, name')->where(["id" => $model->id_user])->one();
                 echo json_encode(['text' => $model->text, 'id_user' => $model->id_user, 'name' => $user['name'], 'avatar' => $user['avatar'], 'id_comment' => $latest_id]);
                 die;
             } else {
                 echo 0;
             }
         } else {
             return json_encode('error');
         }
     }
     View::viewPhoto($photo['photo_id'], $photo['photo_views']);
     return $this->render('photo_page', ['photo' => $photo, 'comments' => $comments, 'model' => $model, 'estimation' => self::$estimation, 'i_blocked' => $i_blocked]);
 }