From da7583392cddedc7094623f89b7593ee5690e614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 29 Sep 2014 17:00:22 +0200 Subject: [PATCH] Fixed Filesystem Uppercase (for *-nix systems) --- www/protected/config/main.php | 2 +- .../controllers/EulerProblemController.php | 2 +- .../controllers/EulerproblemController.php | 169 ++++++++++++++++++ www/protected/views/eulerproblem/_form.php | 57 ++++++ www/protected/views/eulerproblem/_search.php | 41 +++++ www/protected/views/eulerproblem/_view.php | 55 ++++++ www/protected/views/eulerproblem/admin.php | 64 +++++++ www/protected/views/eulerproblem/create.php | 20 +++ www/protected/views/eulerproblem/index.php | 35 ++++ www/protected/views/eulerproblem/update.php | 23 +++ www/protected/views/eulerproblem/view.php | 38 ++++ 11 files changed, 504 insertions(+), 2 deletions(-) create mode 100644 www/protected/controllers/EulerproblemController.php create mode 100644 www/protected/views/eulerproblem/_form.php create mode 100644 www/protected/views/eulerproblem/_search.php create mode 100644 www/protected/views/eulerproblem/_view.php create mode 100644 www/protected/views/eulerproblem/admin.php create mode 100644 www/protected/views/eulerproblem/create.php create mode 100644 www/protected/views/eulerproblem/index.php create mode 100644 www/protected/views/eulerproblem/update.php create mode 100644 www/protected/views/eulerproblem/view.php diff --git a/www/protected/config/main.php b/www/protected/config/main.php index da8aa4a..cccc39a 100644 --- a/www/protected/config/main.php +++ b/www/protected/config/main.php @@ -100,7 +100,7 @@ return ArrayX::merge( 'blog/' => 'blogPost/view/id/', 'blog//' => 'blogPost/view/id/', - 'eulerProblem/' => 'eulerProblem/index', + 'eulerproblem/' => 'eulerproblem/index', 'Highscores/list.php' => 'Highscores/list', // Compatibility 'Highscores/insert.php' => 'Highscores/insert', // Compatibility diff --git a/www/protected/controllers/EulerProblemController.php b/www/protected/controllers/EulerProblemController.php index 080831d..6ab6406 100644 --- a/www/protected/controllers/EulerProblemController.php +++ b/www/protected/controllers/EulerProblemController.php @@ -1,6 +1,6 @@ array('index','view','create','update','admin','delete'), + 'users'=>array('@'), + ), + array('deny', + 'users'=>array('*'), + ), + ); + } + + /** + * Displays a particular model. + * @param integer $id the ID of the model to be displayed + */ + public function actionView($id) + { + $this->render('view',array( + 'model'=>$this->loadModel($id), + )); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + */ + public function actionCreate() + { + $model=new EulerProblem; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if (isset($_POST['EulerProblem'])) { + $model->attributes=$_POST['EulerProblem']; + if ($model->save()) { + $this->redirect(array('view','id'=>$model->Problemnumber)); + } + } + + $this->render('create',array( + 'model'=>$model, + )); + } + + /** + * Updates a particular model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id the ID of the model to be updated + */ + public function actionUpdate($id) + { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if (isset($_POST['EulerProblem'])) { + $model->attributes=$_POST['EulerProblem']; + if ($model->save()) { + $this->redirect(array('view','id'=>$model->Problemnumber)); + } + } + + $this->render('update',array( + 'model'=>$model, + )); + } + + /** + * Deletes a particular model. + * If deletion is successful, the browser will be redirected to the 'admin' page. + * @param integer $id the ID of the model to be deleted + */ + public function actionDelete($id) + { + if (Yii::app()->request->isPostRequest) { + // we only allow deletion via POST request + $this->loadModel($id)->delete(); + + // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser + if (!isset($_GET['ajax'])) { + $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); + } + } else { + throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); + } + } + + /** + * Lists all models. + */ + public function actionIndex() + { + $dataProvider=new CActiveDataProvider('EulerProblem'); + $this->render('index',array( + 'dataProvider'=>$dataProvider, + )); + } + + /** + * Manages all models. + */ + public function actionAdmin() + { + $model=new EulerProblem('search'); + $model->unsetAttributes(); // clear any default values + if (isset($_GET['EulerProblem'])) { + $model->attributes=$_GET['EulerProblem']; + } + + $this->render('admin',array( + 'model'=>$model, + )); + } + + /** + * Returns the data model based on the primary key given in the GET variable. + * If the data model is not found, an HTTP exception will be raised. + * @param integer $id the ID of the model to be loaded + * @return EulerProblem the loaded model + * @throws CHttpException + */ + public function loadModel($id) + { + $model=EulerProblem::model()->findByPk($id); + if ($model===null) { + throw new CHttpException(404,'The requested page does not exist.'); + } + return $model; + } + + /** + * Performs the AJAX validation. + * @param EulerProblem $model the model to be validated + */ + protected function performAjaxValidation($model) + { + if (isset($_POST['ajax']) && $_POST['ajax']==='euler-problem-form') { + echo CActiveForm::validate($model); + Yii::app()->end(); + } + } +} \ No newline at end of file diff --git a/www/protected/views/eulerproblem/_form.php b/www/protected/views/eulerproblem/_form.php new file mode 100644 index 0000000..99350b0 --- /dev/null +++ b/www/protected/views/eulerproblem/_form.php @@ -0,0 +1,57 @@ + + +
+ + beginWidget('bootstrap.widgets.TbActiveForm', array( + 'id'=>'euler-problem-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, +)); ?> + +

Fields with * are required.

+ + errorSummary($model); ?> + + textFieldControlGroup($model,'Problemnumber',array('span'=>8)); ?> + + textFieldControlGroup($model,'Problemtitle',array('span'=>5,'maxlength'=>50)); ?> + + textAreaControlGroup($model,'Problemdescription',array('rows'=>6,'span'=>8)); ?> + + textAreaControlGroup($model,'Code',array('rows'=>6,'span'=>8)); ?> + + textAreaControlGroup($model,'Explanation',array('rows'=>6,'span'=>8)); ?> + + isNewRecord) + echo $form->textFieldControlGroup($model,'AbbreviatedCode',array('span'=>5, 'value' => '0')); + else + echo $form->textFieldControlGroup($model,'AbbreviatedCode',array('span'=>5)); + ?> + + textFieldControlGroup($model,'SolutionSteps',array('span'=>5,'maxlength'=>20)); ?> + + textFieldControlGroup($model,'SolutionTime',array('span'=>5,'maxlength'=>20)); ?> + + textFieldControlGroup($model,'SolutionWidth',array('span'=>5)); ?> + textFieldControlGroup($model,'SolutionHeight',array('span'=>5)); ?> + + textFieldControlGroup($model,'SolutionValue',array('span'=>5,'maxlength'=>20)); ?> + +
+ isNewRecord ? 'Create' : 'Save',array( + 'color'=>TbHtml::BUTTON_COLOR_PRIMARY, + 'size'=>TbHtml::BUTTON_SIZE_LARGE, + )); ?> +
+ + endWidget(); ?> + +
\ No newline at end of file diff --git a/www/protected/views/eulerproblem/_search.php b/www/protected/views/eulerproblem/_search.php new file mode 100644 index 0000000..b93f60b --- /dev/null +++ b/www/protected/views/eulerproblem/_search.php @@ -0,0 +1,41 @@ + + +
+ + beginWidget('bootstrap.widgets.TbActiveForm', array( + 'action'=>Yii::app()->createUrl($this->route), + 'method'=>'get', +)); ?> + + textFieldControlGroup($model,'Problemnumber',array('span'=>5)); ?> + + textFieldControlGroup($model,'Problemtitle',array('span'=>5,'maxlength'=>50)); ?> + + textAreaControlGroup($model,'Problemdescription',array('rows'=>6,'span'=>8)); ?> + + textAreaControlGroup($model,'Code',array('rows'=>6,'span'=>8)); ?> + + textAreaControlGroup($model,'Explanation',array('rows'=>6,'span'=>8)); ?> + + textFieldControlGroup($model,'AbbreviatedCode',array('span'=>5)); ?> + + textFieldControlGroup($model,'SolutionSteps',array('span'=>5,'maxlength'=>20)); ?> + + textFieldControlGroup($model,'SolutionTime',array('span'=>5,'maxlength'=>20)); ?> + + textFieldControlGroup($model,'SolutionWidth',array('span'=>5)); ?> + textFieldControlGroup($model,'SolutionHeight',array('span'=>5)); ?> + + textFieldControlGroup($model,'SolutionValue',array('span'=>5,'maxlength'=>20)); ?> + +
+ TbHtml::BUTTON_COLOR_PRIMARY,));?> +
+ + endWidget(); ?> + +
\ No newline at end of file diff --git a/www/protected/views/eulerproblem/_view.php b/www/protected/views/eulerproblem/_view.php new file mode 100644 index 0000000..0965977 --- /dev/null +++ b/www/protected/views/eulerproblem/_view.php @@ -0,0 +1,55 @@ + + +
+ + getAttributeLabel('Problemnumber')); ?>: + Problemnumber),array('view','id'=>$data->Problemnumber)); ?> +
+ + getAttributeLabel('Problemtitle')); ?>: + Problemtitle)); ?> +
+ + getAttributeLabel('Problemdescription')); ?>: + Problemdescription); ?> +
+ + getAttributeLabel('Code')); ?>: + Code); ?> +
+ + getAttributeLabel('Explanation')); ?>: + Explanation); ?> +
+ + getAttributeLabel('AbbreviatedCode')); ?>: + AbbreviatedCode); ?> +
+ + getAttributeLabel('SolutionSteps')); ?>: + SolutionSteps); ?> +
+ + getAttributeLabel('SolutionWidth')); ?>: + SolutionTime); ?> +
+ + getAttributeLabel('SolutionHeight')); ?>: + SolutionTime); ?> +
+ + getAttributeLabel('SolutionTime')); ?>: + SolutionTime); ?> +
+ + getAttributeLabel('SolutionValue')); ?>: + SolutionValue); ?> +
+ + */ ?> + +
\ No newline at end of file diff --git a/www/protected/views/eulerproblem/admin.php b/www/protected/views/eulerproblem/admin.php new file mode 100644 index 0000000..5859edc --- /dev/null +++ b/www/protected/views/eulerproblem/admin.php @@ -0,0 +1,64 @@ +breadcrumbs=array( + 'Euler Problems'=>array('index'), + 'Manage', +); + +$this->menu=array( + array('label'=>'List EulerProblem', 'url'=>array('index')), + array('label'=>'Create EulerProblem', 'url'=>array('create')), +); + +Yii::app()->clientScript->registerScript('search', " +$('.search-button').click(function(){ + $('.search-form').toggle(); + return false; +}); +$('.search-form form').submit(function(){ + $('#euler-problem-grid').yiiGridView('update', { + data: $(this).serialize() + }); + return false; +}); +"); +?> + +

Manage Euler Problems

+ +

+ You may optionally enter a comparison operator (<, <=, >, >=, + <> +or =) at the beginning of each of your search values to specify how the comparison should be done. +

+ +'search-button btn')); ?> + + +widget('bootstrap.widgets.TbGridView',array( + 'id'=>'euler-problem-grid', + 'dataProvider'=>$model->search(), + 'filter'=>$model, + 'columns'=>array( + 'Problemnumber', + 'Problemdescription', + 'Code', + 'Explanation', + 'AbbreviatedCode', + 'SolutionSteps', + /* + 'SolutionTime', + 'SolutionValue', + */ + array( + 'class'=>'bootstrap.widgets.TbButtonColumn', + ), + ), +)); ?> \ No newline at end of file diff --git a/www/protected/views/eulerproblem/create.php b/www/protected/views/eulerproblem/create.php new file mode 100644 index 0000000..e6a20f2 --- /dev/null +++ b/www/protected/views/eulerproblem/create.php @@ -0,0 +1,20 @@ + + +breadcrumbs=array( + 'Euler Problems'=>array('index'), + 'Create', +); + +$this->menu=array( + array('label'=>'List EulerProblem', 'url'=>array('index')), + array('label'=>'Manage EulerProblem', 'url'=>array('admin')), +); +?> + +

Create EulerProblem

+ +renderPartial('_form', array('model'=>$model)); ?> \ No newline at end of file diff --git a/www/protected/views/eulerproblem/index.php b/www/protected/views/eulerproblem/index.php new file mode 100644 index 0000000..2d9b871 --- /dev/null +++ b/www/protected/views/eulerproblem/index.php @@ -0,0 +1,35 @@ + + +breadcrumbs=array( + 'Euler Problems', +); + +$this->menu=array( + array('label'=>'Create EulerProblem','url'=>array('create')), + array('label'=>'Manage EulerProblem','url'=>array('admin')), +); +?> + +

Euler Problems

+ +widget('bootstrap.widgets.TbGridView',array( + 'type'=>'striped bordered condensed', + + 'dataProvider'=>$dataProvider, + + 'columns'=>array( + 'Problemnumber', + 'Problemtitle', + 'Problemdescription', + 'AbbreviatedCode', + 'SolutionWidth', + 'SolutionHeight', + 'SolutionSteps', + 'SolutionTime', + 'SolutionValue', + ), +)); ?> \ No newline at end of file diff --git a/www/protected/views/eulerproblem/update.php b/www/protected/views/eulerproblem/update.php new file mode 100644 index 0000000..b7ccbbf --- /dev/null +++ b/www/protected/views/eulerproblem/update.php @@ -0,0 +1,23 @@ + + +breadcrumbs=array( + 'Euler Problems'=>array('index'), + '#' . $model->Problemnumber=>array('view','id'=>$model->Problemnumber), + 'Update', +); + +$this->menu=array( + array('label'=>'List EulerProblem', 'url'=>array('index')), + array('label'=>'Create EulerProblem', 'url'=>array('create')), + array('label'=>'View EulerProblem', 'url'=>array('view', 'id'=>$model->Problemnumber)), + array('label'=>'Manage EulerProblem', 'url'=>array('admin')), +); +?> + +

Update EulerProblem Problemnumber; ?>

+ +renderPartial('_form', array('model'=>$model)); ?> \ No newline at end of file diff --git a/www/protected/views/eulerproblem/view.php b/www/protected/views/eulerproblem/view.php new file mode 100644 index 0000000..37c4dc7 --- /dev/null +++ b/www/protected/views/eulerproblem/view.php @@ -0,0 +1,38 @@ + + +breadcrumbs=array( + 'Euler Problems'=>array('index'), + '#' . $model->Problemnumber, +); + +$this->menu=array( + array('label'=>'List EulerProblem', 'url'=>array('index')), + array('label'=>'Create EulerProblem', 'url'=>array('create')), + array('label'=>'Update EulerProblem', 'url'=>array('update', 'id'=>$model->Problemnumber)), + array('label'=>'Delete EulerProblem', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->Problemnumber),'confirm'=>'Are you sure you want to delete this item?')), + array('label'=>'Manage EulerProblem', 'url'=>array('admin')), +); +?> + +

View EulerProblem #Problemnumber; ?>

+ +widget('zii.widgets.CDetailView',array( + 'htmlOptions' => array( + 'class' => 'table table-striped table-condensed table-hover', + ), + 'data'=>$model, + 'attributes'=>array( + 'Problemnumber', + 'Problemdescription', + 'Code', + 'Explanation', + 'AbbreviatedCode', + 'SolutionSteps', + 'SolutionTime', + 'SolutionValue', + ), +)); ?> \ No newline at end of file