From b5fd33e012197530e54320cb7fbad6c9484d1e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Wed, 28 May 2014 17:19:57 +0200 Subject: [PATCH] Worked on Programs/Index page --- .gitignore | 3 + .idea/workspace.xml | 641 ++++++++---------- DB_Changes.txt | 4 + www/css/styles.css | 7 + www/protected/components/ProgramHelper.php | 2 +- www/protected/components/ThumbnailPreview.php | 20 + .../components/views/thumbnailPreview.php | 66 ++ www/protected/config/env/dev.php | 2 +- www/protected/config/main.php | 2 - .../controllers/ProgramsController.php | 16 +- www/protected/controllers/SiteController.php | 11 + www/protected/models/Program.php | 7 +- www/protected/views/programs/_form.php | 16 +- www/protected/views/programs/_search.php | 2 + www/protected/views/programs/_view.php | 4 + www/protected/views/programs/index.php | 33 +- www/protected/views/site/debugerror.php | 21 + 17 files changed, 456 insertions(+), 401 deletions(-) create mode 100644 .gitignore create mode 100644 DB_Changes.txt create mode 100644 www/protected/components/ThumbnailPreview.php create mode 100644 www/protected/components/views/thumbnailPreview.php create mode 100644 www/protected/views/site/debugerror.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6bdc12a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea +demos +www/images/programs \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e8234c0..0961e2d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -63,49 +63,64 @@ - + - + - - + + - - - - - - - - - - - - - + - - + + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -124,18 +139,14 @@ @@ -439,6 +457,32 @@ - + @@ -836,7 +707,7 @@ - + @@ -878,41 +749,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -933,21 +769,6 @@ - - - - - - - - - - - - - - - @@ -978,23 +799,11 @@ - - - - - - - - - - - - @@ -1073,32 +882,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1106,36 +889,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1143,9 +896,48 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1157,47 +949,154 @@ + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - - - - - + - + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + diff --git a/DB_Changes.txt b/DB_Changes.txt new file mode 100644 index 0000000..eed96ac --- /dev/null +++ b/DB_Changes.txt @@ -0,0 +1,4 @@ +othervalues -> Added Column SValue +othervalues -> Added Key "AdminPassword" +programme -> Added Column ThumbnailName +programme -> Changed Sieb_des_Erasthothenes -> Sieb des Erasthothenes (also ren Imagefiles) \ No newline at end of file diff --git a/www/css/styles.css b/www/css/styles.css index 40ea8bf..b93feb1 100644 --- a/www/css/styles.css +++ b/www/css/styles.css @@ -61,4 +61,11 @@ ul.nav li.dropdown-append:hover > ul.dropdown-menu { display: block; +} + +/* programs/view +-------------------------------------------------- */ + +.progThumbnailCaption { + color: #2C3E50; } \ No newline at end of file diff --git a/www/protected/components/ProgramHelper.php b/www/protected/components/ProgramHelper.php index 3e92aab..4f8553c 100644 --- a/www/protected/components/ProgramHelper.php +++ b/www/protected/components/ProgramHelper.php @@ -22,7 +22,7 @@ class ProgramHelper { $criteria = new CDbCriteria; $criteria->order = "add_date DESC"; $criteria->limit = 8; - $criteria->condition = "Sterne=4 AND visible=1 AND enabled=1"; + $criteria->condition = "Sterne >= 4 AND visible=1 AND enabled=1"; foreach (Program::model()->findAll($criteria) as $row) { $dropDownModels[] = $row; } diff --git a/www/protected/components/ThumbnailPreview.php b/www/protected/components/ThumbnailPreview.php new file mode 100644 index 0000000..dfc79b8 --- /dev/null +++ b/www/protected/components/ThumbnailPreview.php @@ -0,0 +1,20 @@ +date == null) + $this->date = new DateTime('2000-01-01'); + $this->render('thumbnailPreview'); + } +} + +?> \ No newline at end of file diff --git a/www/protected/components/views/thumbnailPreview.php b/www/protected/components/views/thumbnailPreview.php new file mode 100644 index 0000000..0c0e36e --- /dev/null +++ b/www/protected/components/views/thumbnailPreview.php @@ -0,0 +1,66 @@ + + +
  • +
    +
    +
    + +
    +
    + caption) > 13) + echo '

    ' . $this->caption . '

    '; + else + echo '

    ' . $this->caption . '

    '; + ?> + +

    description; ?>

    + +

    + category)) { + echo TbHtml::icon(TbHtml::ICON_TAG); + echo $this->category . ''; + } + ?> +

    + +

    + language as $lang) { + echo TbHtml::icon(TbHtml::ICON_GLOBE); + echo $lang; + echo '       '; + } + ?> +

    + +
    +
    +
  • \ No newline at end of file diff --git a/www/protected/config/env/dev.php b/www/protected/config/env/dev.php index 746211c..8ea7ba6 100644 --- a/www/protected/config/env/dev.php +++ b/www/protected/config/env/dev.php @@ -17,7 +17,7 @@ return [ 'errorHandler' => [ - 'errorAction' => 'site/error', + 'errorAction' => 'site/debugerror', ], ], diff --git a/www/protected/config/main.php b/www/protected/config/main.php index 6a6fd14..290c110 100644 --- a/www/protected/config/main.php +++ b/www/protected/config/main.php @@ -55,8 +55,6 @@ return ArrayX::merge( 'allowAutoLogin' => true, ], - // uncomment the following to enable URLs in path-format - 'urlManager' => [ 'urlFormat' => 'path', diff --git a/www/protected/controllers/ProgramsController.php b/www/protected/controllers/ProgramsController.php index f43f65e..ecc2667 100644 --- a/www/protected/controllers/ProgramsController.php +++ b/www/protected/controllers/ProgramsController.php @@ -47,16 +47,18 @@ class ProgramsController extends Controller /** * Displays a particular model. * @param integer $id the ID of the model to be displayed + * @throws CHttpException when $id is integer */ public function actionView($id) { - if (is_string($id)) + if (is_numeric($id)) { - $model = $this->loadModelByName($id); + throw new CHttpException(400, "You can't access a program by ID"); + //$model = $this->loadModelByID($id); } else { - $model = $this->loadModelByID($id); + $model = $this->loadModelByName($id); } $this->render('view',array( @@ -94,7 +96,7 @@ class ProgramsController extends Controller */ public function actionUpdate($id) { - $model=$this->loadModel($id); + $model=$this->loadModelByID($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); @@ -121,7 +123,7 @@ class ProgramsController extends Controller { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request - $this->loadModel($id)->delete(); + $this->loadModelByID($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { @@ -169,7 +171,7 @@ class ProgramsController extends Controller { $model=Program::model()->findByPk($id); if ($model===null) { - throw new CHttpException(404,'The requested page does not exist.'); + throw new CHttpException(404,'The requested Programm (by ID) does not exist.'); } return $model; } @@ -185,7 +187,7 @@ class ProgramsController extends Controller { $model=Program::model()->findByAttributes(['Name' => $name]); if ($model===null) { - throw new CHttpException(404,'The requested page does not exist.'); + throw new CHttpException(404,'The requested programm (by Name) does not exist.'); } return $model; } diff --git a/www/protected/controllers/SiteController.php b/www/protected/controllers/SiteController.php index 6d1adf0..da0c565 100644 --- a/www/protected/controllers/SiteController.php +++ b/www/protected/controllers/SiteController.php @@ -24,6 +24,17 @@ class SiteController extends Controller } } + public function actionDebugError() + { + if($error=Yii::app()->errorHandler->error) + { + if(Yii::app()->request->isAjaxRequest) + echo $error['message']; + else + $this->render('debugerror', $error); + } + } + public function actionAbout() { $data = array(); diff --git a/www/protected/models/Program.php b/www/protected/models/Program.php index 70d4648..a629559 100644 --- a/www/protected/models/Program.php +++ b/www/protected/models/Program.php @@ -6,6 +6,7 @@ * The followings are the available columns in table 'program': * @property integer $ID * @property string $Name + * @property string Thumbnailname * @property double $Downloads * @property string $Kategorie * @property double $Sterne @@ -41,13 +42,13 @@ class Program extends CActiveRecord // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( - array('Name, Downloads, Kategorie, Sterne, enabled, visible, Language, Description, add_date, download_url, viewable_code, sourceforge_url, homepage_url, github_url, uses_absCanv, update_identifier', 'required'), + array('Name, Thumbnailname, Downloads, Kategorie, Sterne, enabled, visible, Language, Description, add_date, download_url, viewable_code, sourceforge_url, homepage_url, github_url, uses_absCanv, update_identifier', 'required'), array('enabled, visible, viewable_code, uses_absCanv, highscore_gid', 'numerical', 'integerOnly'=>true), array('Downloads, Sterne', 'numerical'), array('update_identifier', 'length', 'max'=>28), // The following rule is used by search(). // @todo Please remove those attributes that should not be searched. - array('ID, Name, Downloads, Kategorie, Sterne, enabled, visible, Language, Description, add_date, download_url, viewable_code, sourceforge_url, homepage_url, github_url, uses_absCanv, update_identifier, highscore_gid', 'safe', 'on'=>'search'), + array('ID, Name, Thumbnailname, Downloads, Kategorie, Sterne, enabled, visible, Language, Description, add_date, download_url, viewable_code, sourceforge_url, homepage_url, github_url, uses_absCanv, update_identifier, highscore_gid', 'safe', 'on'=>'search'), ); } @@ -70,6 +71,7 @@ class Program extends CActiveRecord return array( 'ID' => 'ID', 'Name' => 'Name', + 'Thumbnailname' => 'Thumbnail name', 'Downloads' => 'Downloads', 'Kategorie' => 'Kategorie', 'Sterne' => 'Sterne', @@ -107,6 +109,7 @@ class Program extends CActiveRecord $criteria->compare('ID',$this->ID); $criteria->compare('Name',$this->Name,true); + $criteria->compare('Thumbnailname',$this->Thumbnailname,true); $criteria->compare('Downloads',$this->Downloads); $criteria->compare('Kategorie',$this->Kategorie,true); $criteria->compare('Sterne',$this->Sterne); diff --git a/www/protected/views/programs/_form.php b/www/protected/views/programs/_form.php index 2cb4730..61fbd40 100644 --- a/www/protected/views/programs/_form.php +++ b/www/protected/views/programs/_form.php @@ -19,11 +19,13 @@ errorSummary($model); ?> - textAreaControlGroup($model,'Name',array('rows'=>6,'span'=>8)); ?> + textFieldControlGroup($model,'Name',array('rows'=>6,'span'=>8)); ?> + + textFieldControlGroup($model,'Thumbnailname',array('rows'=>6,'span'=>8)); ?> textFieldControlGroup($model,'Downloads',array('span'=>5)); ?> - textAreaControlGroup($model,'Kategorie',array('rows'=>6,'span'=>8)); ?> + textFieldControlGroup($model,'Kategorie',array('rows'=>6,'span'=>8)); ?> textFieldControlGroup($model,'Sterne',array('span'=>5)); ?> @@ -31,21 +33,21 @@ textFieldControlGroup($model,'visible',array('span'=>5)); ?> - textAreaControlGroup($model,'Language',array('rows'=>6,'span'=>8)); ?> + textFieldControlGroup($model,'Language',array('rows'=>6,'span'=>8)); ?> textAreaControlGroup($model,'Description',array('rows'=>6,'span'=>8)); ?> textFieldControlGroup($model,'add_date',array('span'=>5)); ?> - textAreaControlGroup($model,'download_url',array('rows'=>6,'span'=>8)); ?> + textFieldControlGroup($model,'download_url',array('rows'=>6,'span'=>8)); ?> textFieldControlGroup($model,'viewable_code',array('span'=>5)); ?> - textAreaControlGroup($model,'sourceforge_url',array('rows'=>6,'span'=>8)); ?> + textFieldControlGroup($model,'sourceforge_url',array('rows'=>6,'span'=>8)); ?> - textAreaControlGroup($model,'homepage_url',array('rows'=>6,'span'=>8)); ?> + textFieldControlGroup($model,'homepage_url',array('rows'=>6,'span'=>8)); ?> - textAreaControlGroup($model,'github_url',array('rows'=>6,'span'=>8)); ?> + textFieldControlGroup($model,'github_url',array('rows'=>6,'span'=>8)); ?> textFieldControlGroup($model,'uses_absCanv',array('span'=>5)); ?> diff --git a/www/protected/views/programs/_search.php b/www/protected/views/programs/_search.php index 8ef7b05..af4b16e 100644 --- a/www/protected/views/programs/_search.php +++ b/www/protected/views/programs/_search.php @@ -15,6 +15,8 @@ textAreaControlGroup($model,'Name',array('rows'=>6,'span'=>8)); ?> + textAreaControlGroup($model,'Thumbnailname',array('rows'=>6,'span'=>8)); ?> + textFieldControlGroup($model,'Downloads',array('span'=>5)); ?> textAreaControlGroup($model,'Kategorie',array('rows'=>6,'span'=>8)); ?> diff --git a/www/protected/views/programs/_view.php b/www/protected/views/programs/_view.php index 6842f71..daae53e 100644 --- a/www/protected/views/programs/_view.php +++ b/www/protected/views/programs/_view.php @@ -13,6 +13,10 @@ Name); ?>
    + getAttributeLabel('Thumbnailname')); ?>: + Thumbnailname); ?> +
    + getAttributeLabel('Downloads')); ?>: Downloads); ?>
    diff --git a/www/protected/views/programs/index.php b/www/protected/views/programs/index.php index 77e04dc..1bed143 100644 --- a/www/protected/views/programs/index.php +++ b/www/protected/views/programs/index.php @@ -15,20 +15,33 @@ $this->menu = array( ?>
    -
    -

    My Prog's

    -
    -
    +
    + findAll(); + $rows = ceil((count($all) / 4)); - foreach (Program::model()->findAll() as $record) { - echo "
    "; - echo nl2br(print_r($record->attributes, true)); - echo "
    "; + for ($i = 0; $i < $rows; $i++) { + echo '
      '; + + foreach (array_slice(Program::model()->findAll(), $i * 4, 4) as $record) { + $this->widget('ThumbnailPreview', + [ + 'caption' => $record->attributes['Thumbnailname'], + 'description' => $record->attributes['Description'], + 'category' => $record->attributes['Kategorie'], + 'language' => explode("|", $record->attributes['Language']), + 'image' => '/images/programs/thumbnails/' . $record->attributes['Name'] . '.jpg', + 'starcount' => $record->attributes['Sterne'], + 'downloads' => $record->attributes['Downloads'], + 'date' => new DateTime($record->attributes['add_date']), + ]); + } + + echo '
    '; } - - ?> +
    diff --git a/www/protected/views/site/debugerror.php b/www/protected/views/site/debugerror.php new file mode 100644 index 0000000..e6df265 --- /dev/null +++ b/www/protected/views/site/debugerror.php @@ -0,0 +1,21 @@ +pageTitle=Yii::app()->name . ' - Error'; + + $this->breadcrumbs=array( + 'Error (debug)', + ); + + $content = $message. "\n\n" . + 'File: ' . $file. ' : ' . $line . "\n\n" . + "Stacktrace:\n" . + '
    ' . $trace . '
    ' . "\n"; + + + $this->widget('bootstrap.widgets.TbHeroUnit', array( + 'heading' => 'ERROR ' . $type . ': ' . $code, + 'content' => nl2br($content), + )); +?>