Exemple #1
0
 /**
  * Attempts to find the member and send them an email
  *
  * @param  \yii\db\ActiveRecord  $member
  * @param  \yii\db\ActiveRecord  $snippet
  * @return bool
  */
 public function save($member, $snippet)
 {
     if ($this->comment && strlen($this->comment) > 3) {
         $cmt = new SnippetComment();
         $cmt->memberId = $member->id;
         $cmt->snippetId = $snippet->id;
         $cmt->comment = $this->comment;
         return $cmt->save();
     }
     return false;
 }
 /**
  * Site Homepage
  *
  * @return string
  */
 public function actionView()
 {
     $memberId = (int) $this->request->getQueryParam('id');
     if (!$memberId) {
         return $this->goHome();
     }
     $member = Member::find()->where(['id' => $memberId])->limit(1)->one();
     if (!$member) {
         return $this->goHome();
     }
     $snippetCount = Snippet::find()->where(['memberId' => $member->id, 'isHidden' => 0])->count();
     $commentCount = SnippetComment::find()->where(['memberId' => $member->id])->count();
     return $this->render('view', ['member' => $member, 'snippetCount' => $snippetCount, 'commentCount' => $commentCount, 'snippets' => MemberSnippetsList::get($member)]);
 }
Exemple #3
0
/* @var $snippet common\models\Snippet */
use yii\helpers\Html;
use cebe\markdown\GithubMarkdown;
use common\models\SnippetComment;
use common\models\Bookmark;
use yii\bootstrap\ActiveForm;
$this->title = $snippet->name;
$geshi = new GeSHi($snippet->code, $language->renderCode);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$geshi->set_header_type(GESHI_HEADER_DIV);
$geshi->set_tab_width(4);
$geshiCode = $geshi->parse_code();
$markdown = new GithubMarkdown();
$markdown->html5 = true;
$markdown->enableNewlines = true;
$comments = SnippetComment::find()->where(['snippetId' => $snippet->id])->with('member')->orderBy('createdTime ASC')->all();
$hasBookmarked = false;
if ($this->context->member) {
    $hasBookmarked = Bookmark::find()->where(['memberId' => $this->context->member->id, 'snippetId' => $snippet->id])->count();
}
if (!$this->context->member && $this->context->params['registrationsOpen']) {
    ?>
    <span class="bookmark">
        <a href="/login?r=<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
" title="Login and return here">Login</a>
        or
        <a href="/register" title="Register an account">Register</a> to Bookmark this snippet
    </span>
    <?php 
Exemple #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getComments()
 {
     return $this->hasMany(SnippetComment::className(), ['memberId' => 'id']);
 }