Added Visible & Enabled to BlogPost
This commit is contained in:
parent
5c940826de
commit
ff5ecbc144
@ -264,6 +264,13 @@ ul.nav li.dropdown-append:hover > ul.dropdown-menu {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.collHeaderPseudoLink {
|
||||
color: #2C3E50;
|
||||
}
|
||||
|
||||
.collHeaderStroked {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
/* FullProgPreview
|
||||
-------------------------------------------------- */
|
||||
|
@ -4,6 +4,7 @@ class BlogLink extends CWidget {
|
||||
public $date;
|
||||
public $caption = '';
|
||||
public $link = '';
|
||||
public $stroked = false;
|
||||
|
||||
public function run() {
|
||||
if ($this->date == null)
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<div class="row collHeader collHeaderLinkParent">
|
||||
<div class="collHeaderSpan-front"><?php echo $this->date->format('d.m.Y'); ?></div>
|
||||
<div class="collHeaderSpan"><?php echo $this->caption; ?></div>
|
||||
<div class="collHeaderSpan"><a class="collHeaderPseudoLink<?php if ($this->stroked) echo ' collHeaderStroked';?>" href="<?php echo $this->link; ?>"><?php echo $this->caption; ?></a></div>
|
||||
<div class="collHeaderSpan-drop"><i class="icon-file" ></i></div>
|
||||
<a class="collHeaderLink" href="<?php echo $this->link; ?>"> </a>
|
||||
</div>
|
@ -42,11 +42,14 @@ class APIController extends MSController
|
||||
|
||||
public function actionUpdate2($Name)
|
||||
{
|
||||
if (! isset($_GET['Name'])) {
|
||||
throw new CHttpException(404,'Invalid Request - [Name] missing');
|
||||
}
|
||||
|
||||
$data = ProgramUpdates::model()->findByAttributes(['Name' => $Name]);
|
||||
|
||||
if (! isset($_GET['Name'])) {
|
||||
if (is_null($data)) {
|
||||
throw new CHttpException(404,'Invalid Request - [Name] not found');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->render('update', ['data' => $data]);
|
||||
|
@ -43,12 +43,19 @@ class BlogPostController extends MSController
|
||||
/**
|
||||
* Displays a particular model.
|
||||
* @param integer $id the ID of the model to be displayed
|
||||
* @throws CHttpException if Enabled is false
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$this->render('view',array(
|
||||
'model'=>$this->loadModel($id),
|
||||
));
|
||||
$model = $this->loadModel($id);
|
||||
|
||||
if (! $model->Enabled && Yii::app()->user->name != 'admin')
|
||||
throw new CHttpException(403, 'This Blogpost is locked');
|
||||
|
||||
$this->render('view',
|
||||
[
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,6 +135,12 @@ class BlogPostController extends MSController
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->order = "Date DESC";
|
||||
|
||||
if (Yii::app()->user->name != 'admin')
|
||||
{
|
||||
$criteria->addCondition('Visible = 1');
|
||||
$criteria->addCondition('Enabled = 1');
|
||||
}
|
||||
|
||||
$all = BlogPost::model()->findAll($criteria);
|
||||
|
||||
$this->render('index',
|
||||
|
@ -8,6 +8,8 @@
|
||||
* @property string $Date
|
||||
* @property string $Title
|
||||
* @property string $Content
|
||||
* @property string $Visible
|
||||
* @property string $Enabled
|
||||
*/
|
||||
class BlogPost extends CActiveRecord
|
||||
{
|
||||
@ -27,10 +29,10 @@ class BlogPost extends CActiveRecord
|
||||
// NOTE: you should only define rules for those attributes that
|
||||
// will receive user inputs.
|
||||
return array(
|
||||
array('Date, Title, Content', 'required'),
|
||||
// The following rule is used by search().
|
||||
// @todo Please remove those attributes that should not be searched.
|
||||
array('ID, Date, Title, Content', 'safe', 'on'=>'search'),
|
||||
array('Date, Title, Content, Visible, Enabled', 'required'),
|
||||
array('Visible, Enabled', 'numerical', 'integerOnly'=>true),
|
||||
|
||||
array('ID, Date, Title, Content, Visible, Enabled', 'safe', 'on'=>'search'),
|
||||
);
|
||||
}
|
||||
|
||||
@ -55,6 +57,8 @@ class BlogPost extends CActiveRecord
|
||||
'Date' => 'Date',
|
||||
'Title' => 'Title',
|
||||
'Content' => 'Content',
|
||||
'Visible' => 'Visible',
|
||||
'Enabled' => 'Enabled',
|
||||
);
|
||||
}
|
||||
|
||||
@ -72,14 +76,14 @@ class BlogPost extends CActiveRecord
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
// @todo Please modify the following code to remove attributes that should not be searched.
|
||||
|
||||
$criteria=new CDbCriteria;
|
||||
|
||||
$criteria->compare('ID',$this->ID);
|
||||
$criteria->compare('Date',$this->Date,true);
|
||||
$criteria->compare('Title',$this->Title,true);
|
||||
$criteria->compare('Content',$this->Content,true);
|
||||
$criteria->compare('Visible',$this->Visible,true);
|
||||
$criteria->compare('Enabled',$this->Enabled,true);
|
||||
|
||||
return new CActiveDataProvider($this, array(
|
||||
'criteria'=>$criteria,
|
||||
|
@ -30,6 +30,20 @@
|
||||
|
||||
<?php echo $form->textAreaControlGroup($model,'Content',array('rows'=>30,'span'=>8)); ?>
|
||||
|
||||
<?php
|
||||
if ($model->isNewRecord)
|
||||
echo $form->textFieldControlGroup($model,'Visible',array('span'=>5, 'value' => '1'));
|
||||
else
|
||||
echo $form->textFieldControlGroup($model,'Visible',array('span'=>5, ));
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ($model->isNewRecord)
|
||||
echo $form->textFieldControlGroup($model,'Enabled',array('span'=>5, 'value' => '1'));
|
||||
else
|
||||
echo $form->textFieldControlGroup($model,'Enabled',array('span'=>5, ));
|
||||
?>
|
||||
|
||||
<?php echo MsHtml::ajaxButton ("Preview", CController::createUrl('blog/ajaxMarkdownPreview'),
|
||||
[
|
||||
'type'=>'POST',
|
||||
|
@ -17,6 +17,11 @@
|
||||
|
||||
<?php echo $form->textAreaControlGroup($model,'Content',array('rows'=>6,'span'=>8)); ?>
|
||||
|
||||
<?php echo $form->textFieldControlGroup($model,'Visible',array('span'=>5)); ?>
|
||||
|
||||
<?php echo $form->textFieldControlGroup($model,'Enabled',array('span'=>5)); ?>
|
||||
|
||||
|
||||
<div class="form-actions">
|
||||
<?php echo TbHtml::submitButton('Search', array('color' => TbHtml::BUTTON_COLOR_PRIMARY,));?>
|
||||
</div>
|
||||
|
@ -21,5 +21,13 @@
|
||||
<?php echo CHtml::encode($data->Content); ?>
|
||||
<br />
|
||||
|
||||
<b><?php echo CHtml::encode($data->getAttributeLabel('Visible')); ?>:</b>
|
||||
<?php echo CHtml::encode($data->Visible); ?>
|
||||
<br />
|
||||
|
||||
<b><?php echo CHtml::encode($data->getAttributeLabel('Enabled')); ?>:</b>
|
||||
<?php echo CHtml::encode($data->Enabled); ?>
|
||||
<br />
|
||||
|
||||
|
||||
</div>
|
@ -29,6 +29,7 @@ $this->selectedNav = 'blog';
|
||||
'date' => new DateTime($blogpost->Date),
|
||||
'caption' => $blogpost->Title,
|
||||
'link' => $blogpost->getLink(),
|
||||
'stroked' => !($blogpost->Enabled && $blogpost->Visible),
|
||||
]);
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user