1
0

Added CRUD for Logs

This commit is contained in:
2014-06-06 19:31:05 +02:00
parent 53211ea359
commit 4b9310d69c
21 changed files with 811 additions and 479 deletions

View File

@@ -47,10 +47,10 @@
['label' => 'Programs', 'url' => '/programs/', 'active' => ($this->selectedNav === 'prog')],
['label' => '', 'items' => ProgramHelper::GetProgDropDownList(), 'htmlOptions' => ['class' => 'dropdown-append']],
['label' => 'About', 'url' => '/about', 'active' => ($this->selectedNav === 'about')],
['label' => '[[Log "'.Yii::app()->user->name.'" out]]', 'url' => '/logout', 'visible' => !Yii::app()->user->isGuest]
['label' => '[[Log "'.Yii::app()->user->name.'" out]]', 'url' => '/logout', 'visible' => !Yii::app()->user->isGuest, 'htmlOptions' => ['class' => 'cstm-main-navbar-highlight']]
],
],
MsHtml::navbarSearchForm('search', '',
MsHtml::navbarSearchForm('/search', '',
[
'class' => 'pull-right',
'placeholder' => 'Search',
@@ -89,10 +89,6 @@
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
<script src="<?php echo (YII_DEBUG ? 'bootstrap.js' : 'bootstrap.min.js') ?>"></script>
<script src="/js/plugins.js"></script>
<script src="/js/main.js"></script>
<script src="/javascript/scripts.js"></script>
</body>
</html>

View File

@@ -0,0 +1,7 @@
<?php
$this->beginWidget('CMarkdown');
echo $content;
$this->endWidget();

View File

@@ -0,0 +1,52 @@
<?php
/* @var $this LogController */
/* @var $model Log */
/* @var $form TbActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'log-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<?php echo $form->textFieldControlGroup($model,'date',array('span'=>5, 'value'=>date('Y-m-d'))); ?>
<?php echo $form->textAreaControlGroup($model,'title',array('rows'=>6,'span'=>8)); ?>
<?php echo $form->textAreaControlGroup($model,'content',array('rows'=>6,'span'=>8)); ?>
<?php echo MsHtml::ajaxButton ("Preview", CController::createUrl('log/ajaxMarkdownPreview'),
[
'type'=>'POST',
'data' => ['content'=> 'js: $("#Log_content").val()'],
'update' => '#markdownAjaxContent',
'error'=>'function(msg){alert("An error has happened");}',
]); ?>
<br>
<br>
<div class="well markdownOwner" id="markdownAjaxContent">
<?php $this->renderPartial('_ajaxMarkdownPreview', ['content' => $model->content, ], false, true); ?>
</div>
<div class="form-actions">
<?php echo MsHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(
'color'=>MsHtml::BUTTON_COLOR_PRIMARY,
'size'=>MsHtml::BUTTON_SIZE_LARGE,
)); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->

View File

@@ -0,0 +1,28 @@
<?php
/* @var $this LogController */
/* @var $model Log */
/* @var $form CActiveForm */
?>
<div class="wide form">
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<?php echo $form->textFieldControlGroup($model,'ID',array('span'=>5)); ?>
<?php echo $form->textFieldControlGroup($model,'date',array('span'=>5)); ?>
<?php echo $form->textAreaControlGroup($model,'title',array('rows'=>6,'span'=>8)); ?>
<?php echo $form->textAreaControlGroup($model,'content',array('rows'=>6,'span'=>8)); ?>
<div class="form-actions">
<?php echo MsHtml::submitButton('Search', array('color' => MsHtml::BUTTON_COLOR_PRIMARY,));?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->

View File

@@ -0,0 +1,25 @@
<?php
/* @var $this LogController */
/* @var $data Log */
?>
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('ID')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->ID),array('view','id'=>$data->ID)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('date')); ?>:</b>
<?php echo CHtml::encode($data->date); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('title')); ?>:</b>
<?php echo CHtml::encode($data->title); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('content')); ?>:</b>
<?php echo CHtml::encode($data->content); ?>
<br />
</div>

View File

@@ -0,0 +1,58 @@
<?php
/* @var $this LogController */
/* @var $model Log */
$this->breadcrumbs=array(
'Logs'=>array('index'),
'Manage',
);
$this->menu=array(
array('label'=>'List Log', 'url'=>array('index')),
array('label'=>'Create Log', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#log-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Manage Logs</h1>
<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>
&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button btn')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'log-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'ID',
'date',
'title',
'content',
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),
)); ?>

View File

@@ -0,0 +1,20 @@
<?php
/* @var $this LogController */
/* @var $model Log */
?>
<?php
$this->breadcrumbs=array(
'Logs'=>array('index'),
'Create',
);
$this->menu=array(
array('label'=>'List Log', 'url'=>array('index')),
array('label'=>'Manage Log', 'url'=>array('admin')),
);
?>
<h1>Create Log</h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>

View File

@@ -0,0 +1,40 @@
<?php
/* @var $this MsMainController */
/* @var $logs Log[] */
/* @var $logid integer */
$this->pageTitle=Yii::app()->name;
$this->breadcrumbs=
[
'Log'
];
$this->selectedNav = '';
?>
<div class="container">
<?php echo MsHtml::pageHeader("Site-log", "Changelog and Blog for mikescher.de"); ?>
<div class="accordion" id="lca">
<?php
$i = 0;
foreach($logs as $logelem) { //TODO-MS Translate all log things to eng
$i++;
$this->widget('ExpandedLogHeader',
[
'date' => new DateTime($logelem->date),
'caption' => $logelem->title,
'content' => $logelem->content,
'collapseID' => $i,
'collapseOwner' => '#lca',
'collapseOpen' => ($logelem->ID == $logid),
]);
}
?>
</div>
</div>

View File

@@ -0,0 +1,23 @@
<?php
/* @var $this LogController */
/* @var $model Log */
?>
<?php
$this->breadcrumbs=array(
'Logs'=>array('index'),
$model->title=>array('view','id'=>$model->ID),
'Update',
);
$this->menu=array(
array('label'=>'List Log', 'url'=>array('index')),
array('label'=>'Create Log', 'url'=>array('create')),
array('label'=>'View Log', 'url'=>array('view', 'id'=>$model->ID)),
array('label'=>'Manage Log', 'url'=>array('admin')),
);
?>
<h1>Update Log <?php echo $model->ID; ?></h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>

View File

@@ -0,0 +1,34 @@
<?php
/* @var $this LogController */
/* @var $model Log */
?>
<?php
$this->breadcrumbs=array(
'Logs'=>array('index'),
$model->title,
);
$this->menu=array(
array('label'=>'List Log', 'url'=>array('index')),
array('label'=>'Create Log', 'url'=>array('create')),
array('label'=>'Update Log', 'url'=>array('update', 'id'=>$model->ID)),
array('label'=>'Delete Log', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->ID),'confirm'=>'Are you sure you want to delete this item?')),
array('label'=>'Manage Log', 'url'=>array('admin')),
);
?>
<h1>View Log #<?php echo $model->ID; ?></h1>
<?php $this->widget('zii.widgets.CDetailView',array(
'htmlOptions' => array(
'class' => 'table table-striped table-condensed table-hover',
),
'data'=>$model,
'attributes'=>array(
'ID',
'date',
'title',
'content',
),
)); ?>

View File

@@ -1,5 +1,5 @@
<?php
/* @var $this SiteController */
/* @var $this MsMainController */
/* @var $error array */
$this->pageTitle=Yii::app()->name . ' - Error';

View File

@@ -1,5 +1,5 @@
<?php
/* @var $this SiteController */
/* @var $this MsMainController */
/* @var $error array */
$this->pageTitle=Yii::app()->name . ' - Error';

View File

@@ -1,40 +0,0 @@
<?php
/* @var $this MsMainController */
/* @var $logs Log[] */
/* @var $logid integer */
$this->pageTitle=Yii::app()->name;
$this->breadcrumbs=
[
'Log'
];
$this->selectedNav = '';
?>
<div class="container">
<?php echo MsHtml::pageHeader("Site-log", "Changelog and Blog for mikescher.de"); ?>
<div class="accordion" id="lca">
<?php
$i = 0;
foreach($logs as $logelem) {
$i++;
$this->widget('ExpandedLogHeader',
[
'date' => new DateTime($logelem->date),
'caption' => $logelem->title,
'content' => $logelem->content,
'collapseID' => $i,
'collapseOwner' => '#lca',
'collapseOpen' => ($logelem->ID == $logid),
]);
}
?>
</div>
</div>

View File

@@ -1,5 +1,5 @@
<?php
/* @var $this SiteController */
/* @var $this MsMainController */
/* @var $model LoginForm */
/* @var $form CActiveForm */