1
0

Added DB Access + Error page

This commit is contained in:
2014-05-12 10:11:20 +02:00
parent 3efba81ebc
commit ffdc17efd5
124 changed files with 6346 additions and 82 deletions

View File

@@ -0,0 +1,22 @@
<?php foreach($comments as $comment): ?>
<div class="comment" id="c<?php echo $comment->id; ?>">
<?php echo CHtml::link("#{$comment->id}", $comment->getUrl($post), array(
'class'=>'cid',
'title'=>'Permalink to this comment',
)); ?>
<div class="author">
<?php echo $comment->authorLink; ?> says:
</div>
<div class="time">
<?php echo date('F j, Y \a\t h:i a',$comment->create_time); ?>
</div>
<div class="content">
<?php echo nl2br(CHtml::encode($comment->content)); ?>
</div>
</div><!-- comment -->
<?php endforeach; ?>

View File

@@ -0,0 +1,47 @@
<div class="form">
<?php $form=$this->beginWidget('CActiveForm'); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo CHtml::errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'title'); ?>
<?php echo $form->textField($model,'title',array('size'=>80,'maxlength'=>128)); ?>
<?php echo $form->error($model,'title'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'content'); ?>
<?php echo CHtml::activeTextArea($model,'content',array('rows'=>10, 'cols'=>70)); ?>
<p class="hint">You may use <a target="_blank" href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a>.</p>
<?php echo $form->error($model,'content'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'tags'); ?>
<?php $this->widget('CAutoComplete', array(
'model'=>$model,
'attribute'=>'tags',
'url'=>array('suggestTags'),
'multiple'=>true,
'htmlOptions'=>array('size'=>50),
)); ?>
<p class="hint">Please separate different tags with commas.</p>
<?php echo $form->error($model,'tags'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'status'); ?>
<?php echo $form->dropDownList($model,'status',Lookup::items('PostStatus')); ?>
<?php echo $form->error($model,'status'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->

View File

@@ -0,0 +1,23 @@
<div class="post">
<div class="title">
<?php echo CHtml::link(CHtml::encode($data->title), $data->url); ?>
</div>
<div class="author">
posted by <?php echo $data->author->username . ' on ' . date('F j, Y',$data->create_time); ?>
</div>
<div class="content">
<?php
$this->beginWidget('CMarkdown', array('purifyOutput'=>true));
echo $data->content;
$this->endWidget();
?>
</div>
<div class="nav">
<b>Tags:</b>
<?php echo implode(', ', $data->tagLinks); ?>
<br/>
<?php echo CHtml::link('Permalink', $data->url); ?> |
<?php echo CHtml::link("Comments ({$data->commentCount})",$data->url.'#comments'); ?> |
Last updated on <?php echo date('F j, Y',$data->update_time); ?>
</div>
</div>

View File

@@ -0,0 +1,31 @@
<?php
$this->breadcrumbs=array(
'Manage Posts',
);
?>
<h1>Manage Posts</h1>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'name'=>'title',
'type'=>'raw',
'value'=>'CHtml::link(CHtml::encode($data->title), $data->url)'
),
array(
'name'=>'status',
'value'=>'Lookup::item("PostStatus",$data->status)',
'filter'=>Lookup::items('PostStatus'),
),
array(
'name'=>'create_time',
'type'=>'datetime',
'filter'=>false,
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>

View File

@@ -0,0 +1,8 @@
<?php
$this->breadcrumbs=array(
'Create Post',
);
?>
<h1>Create Post</h1>
<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>

View File

@@ -0,0 +1,9 @@
<?php if(!empty($_GET['tag'])): ?>
<h1>Posts Tagged with <i><?php echo CHtml::encode($_GET['tag']); ?></i></h1>
<?php endif; ?>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'template'=>"{items}\n{pager}",
)); ?>

View File

@@ -0,0 +1,10 @@
<?php
$this->breadcrumbs=array(
$model->title=>$model->url,
'Update',
);
?>
<h1>Update <i><?php echo CHtml::encode($model->title); ?></i></h1>
<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>

View File

@@ -0,0 +1,36 @@
<?php
$this->breadcrumbs=array(
$model->title,
);
$this->pageTitle=$model->title;
?>
<?php $this->renderPartial('_view', array(
'data'=>$model,
)); ?>
<div id="comments">
<?php if($model->commentCount>=1): ?>
<h3>
<?php echo $model->commentCount>1 ? $model->commentCount . ' comments' : 'One comment'; ?>
</h3>
<?php $this->renderPartial('_comments',array(
'post'=>$model,
'comments'=>$model->comments,
)); ?>
<?php endif; ?>
<h3>Leave a Comment</h3>
<?php if(Yii::app()->user->hasFlash('commentSubmitted')): ?>
<div class="flash-success">
<?php echo Yii::app()->user->getFlash('commentSubmitted'); ?>
</div>
<?php else: ?>
<?php $this->renderPartial('/comment/_form',array(
'model'=>$comment,
)); ?>
<?php endif; ?>
</div><!-- comments -->