부터: 1.0
저자: Kartik Visweswaran (kartikv2@gmail.com)
예제 #1
0
 /**
  * Convert markdown text to HTML for preview
  *
  * @returns JSON encoded HTML output
  */
 public function actionPreview()
 {
     $output = '';
     $module = Yii::$app->controller->module;
     if (isset($_POST['source'])) {
         $output = strlen($_POST['source']) > 0 ? Markdown::convert($_POST['source'], ['custom' => $module->customConversion]) : $_POST['nullMsg'];
     }
     echo Json::encode(HtmlPurifier::process($output));
 }
예제 #2
0
 /**
  * Convert markdown text to HTML for preview
  *
  * @returns JSON encoded HTML output
  */
 public function actionPreview()
 {
     $output = '';
     $module = Config::getModule(Module::MODULE);
     if (isset($_POST['source'])) {
         $output = strlen($_POST['source']) > 0 ? Markdown::convert($_POST['source'], ['custom' => $module->customConversion]) : $_POST['nullMsg'];
     }
     echo Json::encode(HtmlPurifier::process($output));
 }
예제 #3
0
 /**
  * @param $string
  * @param $str
  * @return bool|string
  */
 private function cutText($string, $str)
 {
     if ($string) {
         $string = strip_tags(Markdown::convert($string));
         $string = substr($string, 0, $str);
         $string = substr($string, 0, strrpos($string, ' '));
         $string = chop($string, ':;?!,.-+');
         return $string;
     }
     return false;
 }
예제 #4
0
파일: Post.php 프로젝트: Dominus77/blog
 /**
  * @inheritdoc
  *
  *  [
  *      'class' => TimestampBehavior::className(),
  *      'createdAtAttribute' => 'created_at',
  *      'updatedAtAttribute' => 'updated_at',
  *      'value' => function() {
  *          return date('U'); // unix timestamp
  *      },
  *  ]
  */
 public function behaviors()
 {
     return ['timestamp' => ['class' => TimestampBehavior::className()], 'search' => ['class' => SearchBehavior::className(), 'searchScope' => function ($model) {
         /** @var \yii\db\ActiveQuery $model */
         $model->select(['id', 'title', 'anons', 'content']);
         $model->andWhere(['publish_status' => [self::STATUS_PUBLISH, self::STATUS_ARCHIVE]]);
     }, 'searchFields' => function ($model) {
         /** @var self $model */
         return [['name' => 'title', 'value' => $model->title, 'type' => SearchBehavior::FIELD_TEXT], ['name' => 'body', 'value' => strip_tags(Html::decode(Markdown::convert($model->anons))), 'type' => SearchBehavior::FIELD_TEXT], ['name' => 'url', 'value' => '/blog/default/' . $model->id, 'type' => SearchBehavior::FIELD_KEYWORD], ['name' => 'content', 'value' => Markdown::convert($model->content), 'type' => SearchBehavior::FIELD_UNSTORED]];
     }]];
 }
예제 #5
0
 public function actionCreateentry()
 {
     $name = Yii::$app->request->post('name');
     $body = Yii::$app->request->post('body');
     $category = Yii::$app->request->post('category');
     Yii::$app->response->format = Response::FORMAT_JSON;
     $entry = new Entry();
     $entry->name = $name;
     $entry->body = Markdown::convert($body);
     $entry->category = $category;
     $entry->save();
     $tag = EntryTag::setTags($entry->id, Yii::$app->request->post('tags'));
     return $tag;
 }
예제 #6
0
$this->params['breadcrumbs'][] = ['label' => '话题管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="topic-admin-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'title', 'content:ntext', 'describe', 'tags', 'status', 'create_time:datetime', 'update_time:datetime', 'author_id', 'viewcount', 'up', 'classify']]);
?>

    <?php 
// default call
echo Markdown::convert($model->content);
// with custom post processing
echo Markdown::convert($model->content, ['custom' => ['<h1>' => '<h1 class="custom-h1>', '<h2>' => '<h1 class="custom-h2>']]);
?>
</div>
예제 #7
0
 public function actionPreview()
 {
     $module = Yii::$app->getModule('markdown');
     if (\Yii::$app->user->can('smarty')) {
         $module->smarty = true;
         $module->smartyYiiApp = \Yii::$app->user->can('smartyYiiApp') ? true : false;
         $module->smartyYiiParams = Yii::$app->user->can('smartyYiiParams') ? true : false;
     }
     if (isset($_POST['source'])) {
         $output = strlen($_POST['source']) > 0 ? Markdown::convert($_POST['source'], ['custom' => $module->customConversion]) : $_POST['nullMsg'];
     }
     echo Json::encode(HtmlPurifier::process($output));
 }
예제 #8
0
파일: help.php 프로젝트: kleitz/golfleague
    if ($file) {
        $fn = $docdir . $file . '.md';
        if (file_exists($fn)) {
            $content = file_get_contents($fn);
        }
    }
}
$this->params['breadcrumbs'][] = isset($file) ? $file : $this->title;
?>
<div class="site-help">

<?php 
if (isset($content)) {
    ?>
	<?php 
    echo Markdown::convert($content);
} else {
    ?>
	<h1><?php 
    echo Yii::t('store', 'Help');
    ?>
</h1>

	<ul>
	<?php 
    foreach (new DirectoryIterator($docdir) as $file) {
        if (strrpos($file, '.md') == strlen($file) - 3) {
            $fn = str_replace('.md', '', $file);
            echo '<li>' . Html::a($fn, Url::to(['/site/help', 'f' => $fn])) . '</li>';
            // ;
        }
예제 #9
0
</h2>

                        <p>
                            Category: <?php 
    echo Html::a($post->category->name, '#');
    ?>
, by <?php 
    echo Html::a(ucfirst($post->user->username), '#');
    ?>
 on <?php 
    echo Yii::$app->formatter->asDate($post->created, 'long');
    ?>
                        </p>
                        <p>
                            <?php 
    echo Html::decode(nl2br(StringHelper::byteSubstr(Markdown::convert($post->content), 0, 400))) . '...';
    ?>
                            <br>
                            <?php 
    echo Html::a('Read more...', ['/post/view', 'id' => $post->id], ['class' => 'col-md-2 pull-right btn btn-primary']);
    ?>
                        </p>
                    </div>
                </div>
            </article>
        <?php 
}
?>
    </div>
    <div class="pagination">
        <?php 
예제 #10
0
파일: view.php 프로젝트: artoodetoo/BlogMVC
</h1>
    <section>
        <p>
            Category: <?php 
echo Html::a($model->category->name, '#');
?>
, by <?php 
echo Html::a(ucfirst($model->user->username), '#');
?>
 on <?php 
echo Yii::$app->formatter->asDate($model->created, 'long');
?>
        </p>
        <p>
            <?php 
echo Html::decode(nl2br(Markdown::convert($model->content)));
?>
        </p>
    </section>

    <aside>
        <h2>Add Comment</h2>
        <?php 
if ($commentForm->hasErrors() === true) {
    ?>
            <div class="alert alert-danger">
                <?php 
    echo Html::errorSummary($commentForm);
    ?>
            </div>
        <?php 
예제 #11
0
파일: view.php 프로젝트: Dominus77/blog
/* @var $this yii\web\View */
/* @var $model app\modules\admin\modules\blog\models\Post */
/* @var $author app\modules\user\models\User */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => Module::t('module', 'ADMIN'), 'url' => ['/admin/default/index']];
$this->params['breadcrumbs'][] = ['label' => Module::t('module', 'ADMIN_BLOG'), 'url' => ['/admin/blog/default/index']];
$this->params['breadcrumbs'][] = ['label' => Module::t('module', 'ADMIN_POSTS'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="admin-blog-post-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Module::t('module', 'BUTTON_UPDATE'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Module::t('module', 'BUTTON_DELETE'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Module::t('module', 'WANT_YOU_DELETE_ELEMENT'), 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'title', ['attribute' => 'anons', 'format' => 'raw', 'value' => Markdown::convert($model->anons)], ['attribute' => 'content', 'format' => 'raw', 'value' => Markdown::convert($model->content)], ['attribute' => Module::t('module', 'LABEL_CATEGORY'), 'format' => 'raw', 'value' => $model->category->title], ['attribute' => Module::t('module', 'LABEL_AUTHOR'), 'format' => 'raw', 'value' => $model->author->username], ['attribute' => 'publish_status', 'format' => 'raw', 'value' => Post::getDetailStatusTitle($model->publish_status)], ['attribute' => 'created_at', 'format' => ['date', 'php:d M Y г., H:i:s']], ['attribute' => 'updated_at', 'format' => ['date', 'php:d M Y г., H:i:s']]]]);
?>

</div>
예제 #12
0
<div role="tabpanel">
    <?php 
$tab = Yii::$app->request->get('tab');
$items = [['text' => 'Change history', 'url' => '/', 'active' => !$tab], ['text' => 'Methods (' . $stat['actions_count'] . ')', 'url' => '/?tab=methods', 'active' => $tab == 'methods'], ['text' => 'Оbjects (' . $stat['objects_count'] . ')', 'url' => '/?tab=objects', 'active' => $tab == 'objects'], ['text' => 'README.md', 'url' => '/?tab=doc', 'active' => $tab == 'doc']];
switch ($tab) {
    case 'methods':
        $content = \app\components\widgets\MethodsListWidget::widget();
        break;
    case 'objects':
        $content = \app\components\widgets\ObjectsListWidget::widget();
        break;
    case 'errors':
        $content = \app\components\widgets\ErrorsList::widget();
        break;
    case 'doc':
        $content = \kartik\markdown\Markdown::convert(file_get_contents(Yii::getAlias('@app') . '/README.md'));
        break;
    default:
        $content = \app\components\widgets\DiffWidget::widget();
}
?>

    <ul class="nav nav-tabs">
        <?php 
foreach ($items as $item) {
    ?>
            <li role="presentation"
                <?php 
    if ($item['active']) {
        ?>
                    class="active"
예제 #13
0
파일: qa.php 프로젝트: songwanfu/SummerNut
	<div class="row col-lg-10 col-md-10 col-sm-10 user-qa">
		<div id="tabs" class="tabs">
			<nav>
				<ul>
					<li><a href="#section-ask" class="fa fa-question"><span>我的提问</span></a></li>
					<li><a href="#section-reply" class="fa fa-reply"><span>我的回答</span></a></li>
					<li><a href="#section-focus" class="fa fa-eye"><span>我的关注</span></a></li>
				</ul>
			</nav>
			<div class="content">
				<section id="section-ask">
					<?php if (Question::myQuestion($user->id) ): ?>
						<?php foreach (Question::myQuestion($user->id) as $question): ?>
							<div class="panel panel-default">
							  <div class="panel-heading">
							    <h3 class="panel-title"><?php echo Markdown::convert($question->content)?></h3>
							    <span style="font-size: 12px;color: gray;float: right;margin-top: -10px"><?php echo Common::getAwayTime($question->create_time)?></span>
							  </div>
							  <div class="panel-body">
							    <span>[最新回答] <?php echo empty(Answer::replyLatest($question->id)->content) ? '暂无' : Answer::replyLatest($question->id)->content?></span>
							    <a href="/course/qadetail?qid=<?php echo $question->id?>"><span class="fa fa-comments comment-down"><?php echo count(Answer::replyList($question->id))?></span></a>
							    <a href="/course/qadetail?qid=<?php echo $question->id?>"><span class="fa fa-eye comment-up"><?php echo $question->views?></span></a>
							  </div>
							</div>
						<?php endforeach ?>
					<?php else: ?>
					  <div class="alert alert-warning" role="alert"><?php echo Yii::t('app', 'No more questions.');?></div>
					<?php endif ?>
					
				</section>
				<section id="section-reply">
예제 #14
0
" title="" data-toggle="tooltip" data-original-title="顶"><span class="glyphicon glyphicon-thumbs-up"></span> <em><?php 
echo $model->up;
?>
</em></a><a class="down" href="/"  params="type=<?php 
echo $type;
?>
&action=down&id=<?php 
echo $model->id;
?>
" title="" data-toggle="tooltip" data-original-title="踩"><span class="glyphicon glyphicon-thumbs-down"></span> <em>0</em></a></span>
    </div>


    <?php 
// default call
echo Markdown::convert($model->content);
/*清空content显示*/
$model->content = null;
?>
    <div class="action" ></div>



<?php 
#//Widget直接渲染Tag
#echo \xj\ueditor\Ueditor::widget([
#    'model' => $model->content,
#    'attribute' => 'password',
#    'name' => 'customName',
#    'value' => 'content',
#    'style' => 'width:100%;height:400px',
예제 #15
0
						]);
					?>
				</div>

				<div class="qa-detail">
					<?php foreach (Question::getQuestionList($course->id) as $question): ?>
						<div class="media col-lg-12">
						  <div class="media-left media-middle col-lg-2">
						    <a href="#">
						      <img class="media-object img-circle" style="margin: 6% 0 0 0 " src="<?php echo User::findModel($question->user_id)->head_picture?>" alt="" width="60px">
						    </a>
						    <span class="qa-name" style="text-align: center"><?php echo User::findModel($question->user_id)->username?></span>
						  </div>
						  <div class="media-body">
						  	<span class="fa fa-question-circle fa-lg col-lg-1 qa-question-fa"></span>
						    <span class="media-heading qa-content" ><?php echo Markdown::convert($question->content)?></span>
						    <div class="qa-new">
						    	<span class="fa fa-comment fa-lg col-lg-1"></span>
						    	<?php if (Answer::replyLatest($question->id)): ?>
						    		<span>[最新回答]</span>
						    		<span><a href=""><?php echo User::findModel(Answer::replyLatest($question->id)->answer_user_id)->username?> :</a></span>
						    		<span><?php echo Answer::replyLatest($question->id)->content?></span>
						    	<?php else: ?>
						    		<span>[还没有人回答]</span>
						    	<?php endif ?>
						    	
						    </div>
						    <span class="evaluation-time col-lg-4">时间:<?php echo Common::getAwayTime($question->create_time)?></span>
						    <a href="/course/qadetail?qid=<?php echo $question->id?>"><span class="fa fa-comments comment-down"><?php echo count(Answer::replyList($question->id))?></span></a>
						    <a href="/course/qadetail?qid=<?php echo $question->id?>"><span class="fa fa-eye comment-up"><?php echo $question->views?></span></a>
						  </div>
예제 #16
0
<?php

use kartik\markdown\Markdown;
$html = $this->render('/ticket/htmlEmail', ['model' => $model]);
$text = Markdown::convert($html);
echo $text;
예제 #17
0
파일: view.php 프로젝트: Dominus77/blog
        <p>
            <span class="glyphicon glyphicon glyphicon-user"></span> <?php 
echo $post->author->profile->name ? $post->author->profile->name . ' ' . $post->author->profile->surname : $post->author->username;
?>
 |
            <span class="glyphicon glyphicon-time"></span> <?php 
echo Yii::$app->formatter->asDate($post->created_at);
?>
 |
            <span class="glyphicon glyphicon-th-large"></span> <?php 
echo $post->category->title;
?>
        </p>
        <hr>        
        <p><?php 
echo Markdown::convert($post->content);
?>
</p>

        <?php 
if ($post->tagLinks) {
    ?>
            <hr>
            <p><span class="glyphicon glyphicon-tags"></span>&nbsp; <?php 
    echo Tags::array2string($post->tagLinks);
    ?>
</p>
        <?php 
}
?>
예제 #18
0
 ],
 [
     'attribute' => 'image',
     'format' => 'raw',
     'value' => empty($model->image) ? Yii::t('app', 'Null') : Html::img($model->image),
 ],
 [
     'attribute' => 'option_json',
     'label' => Yii::t('app', 'Options'),
     'format' => 'raw',
     'value' => empty($htmlStr) ? Yii::t('app', 'Null') : $htmlStr,
 ],
 [
     'attribute' => 'answer_json',
     'format' => 'raw',
     'value' => $model->task_type == Task::TYPE_CHOICE ? $answerStr : Markdown::convert($model->answer_json),
 ],
 'score',
 [
     'attribute' => 'task_type',
     'value' => $typeList[$model->task_type],
 ],
 [
     'attribute' => 'is_timing',
     'value' => $timingList[$model->is_timing],
 ],
 [
     'attribute' => 'complete_time',
     'value' => $model->complete_time,
 ],
 'create_time',
예제 #19
0
             $optionStr = '';
             $optionStr = Common::parseJsonToStr($model->option_json);
             return mb_substr($optionStr, 0, 400, 'utf-8');
         } else {
             return Yii::t('app', 'Null');
         }
     }
 ],
 [
     'attribute' => 'answer_json',
     'format' => 'raw',
     'value' => function ($model) {
         if ($model->task_type == $model::TYPE_CHOICE) {
             return implode(',', json_decode($model->answer_json));
         }
         return mb_substr(Markdown::convert($model->answer_json), 0, 400, 'utf-8');
     }
 ],
 [
     'attribute' => 'score',
     'format' => 'raw',
     'filter' => Html::activeDropDownList($searchModel, 'score', Task::scoreList(Task::INCLUDE_ALL), ['class' => 'form-control']),
     'value' => function ($model) {
         $list = Task::scoreList();
         return $list[$model->score];
     },
     'headerOptions' => ['width' => '95px'],
 ],
 [
     'attribute' => 'task_type',
     'format' => 'raw',
예제 #20
0
<?php

use yii\helpers\Html;
use kartik\markdown\Markdown;
?>
<div class="row">
	<article class="thread-view col-xs-<?php 
echo 12 - $model->level;
?>
 col-xs-push-<?php 
echo $model->level;
?>
">
	    <h4><?php 
echo Html::encode($model->title);
?>
</h4>
		<?php 
echo Markdown::convert($model->body);
?>
		<?php 
echo ($parent = $model->parent()->one()) ? $parent->title : NULL;
?>
	</article>
</div>
예제 #21
0
    ?>

              <?php 
    echo $form->fieldSetEnd();
    ?>
          <?php 
}
?>

          <?php 
if ($extension->readme) {
    ?>
              <?php 
    echo $form->fieldSet(\Yii::t('app', 'For developer'));
    ?>
              <?php 
    echo \kartik\markdown\Markdown::convert($extension->readme);
    ?>
              <?php 
    echo $form->fieldSetEnd();
    ?>
          <?php 
}
?>


          <?php 
\skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab::end();
?>
      </div>
</div>
예제 #22
0
    <span class="glyphicon glyphicon glyphicon-user"></span> <?php 
echo $model->author->profile->name ? $model->author->profile->name . ' ' . $model->author->profile->surname : $model->author->username;
?>
 |
    <span class="glyphicon glyphicon-time"></span> <?php 
echo Yii::$app->formatter->asDate($model->created_at);
?>
 |
    <span class="glyphicon glyphicon-th-large"></span> <?php 
echo $model->category->title;
?>
</p>
<hr>

<p><?php 
echo Markdown::convert($model->anons);
?>
</p>


<p>
    <?php 
if (PostComment::getCountComments($model->id) > 0) {
    ?>
        <span class="glyphicon glyphicon-comment"></span>&nbsp; <a href="<?php 
    echo Url::to(['default/view', 'id' => $model->id, '#' => 'comments']);
    ?>
"><?php 
    echo Module::t('module', 'COMMENTS:{count}', ['count' => PostComment::getCountComments($model->id)]);
    ?>
</a> |
예제 #23
0
		</div>
		
		<?php foreach ($replyList as $reply): ?>
		<div class="col-lg-12 col-md-12 col-sm-12 qadetail-reply">
			
				<div class="col-lg-2 col-md-2 col-sm-2 reply-user-info">
					<div  style="margin: 0 25%"><a href='#'><img src="<?php echo User::findModel($reply->answer_user_id)->head_picture?>" class="img-circle" width="60px"></a></div>
					<div class="reply-user-info-name"><?php echo User::findModel($reply->answer_user_id)->username?></div>
				</div>
				<div class="col-lg-3 col-md-2 col-sm-2">
					<?php if ($user->id != $reply->answered_user_id): ?>
						<span style="color: rgba(102,102,102,0.5)">[<?php echo User::findModel($reply->answer_user_id)->username?>回复<?php echo User::findModel($reply->answered_user_id)->username?>]</span>
					<?php endif ?>
				</div>
				<div class="col-lg-10 col-md-10 col-sm-10">
					<?php echo Markdown::convert($reply->content)?>
				</div>
				<div class="col-lg-10 col-md-10 col-sm-10">
					<div class="col-lg-4 col-md-4 col-sm-4">
						<?php echo Common::getAwayTime($reply->create_time)?>
					</div>
					<div class="col-lg-2 col-md-2 col-sm-2" style="float:right">
						<?php if ($reply->answer_user_id != Yii::$app->user->id): ?>
							<span class="fa fa-reply" onclick="changeAnsweredName(<?php echo $reply->answer_user_id?>)">回复</span>
	
						<?php endif ?>
					</div>
				</div>
			
			
		</div>