">
@@ -66,8 +66,8 @@
date->format('d.m.y'); ?>
Added On
-
starcount . '/4'; ?>
-
Rating
+
programminglang; ?>
+ Language
diff --git a/www/protected/models/Program.php b/www/protected/models/Program.php
index a629559..34d479d 100644
--- a/www/protected/models/Program.php
+++ b/www/protected/models/Program.php
@@ -13,6 +13,7 @@
* @property integer $enabled
* @property integer $visible
* @property string $Language
+ * @property string $programming_lang
* @property string $Description
* @property string $add_date
* @property string $download_url
@@ -42,13 +43,14 @@ class Program extends CActiveRecord
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
- 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('Name, Thumbnailname, Downloads, Kategorie, Sterne, enabled, visible, Language, programming_lang, 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),
+ array('programming_lang', 'length', 'max'=>16),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
- 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'),
+ array('ID, Name, Thumbnailname, Downloads, Kategorie, Sterne, enabled, visible, Language, programming_lang, Description, add_date, download_url, viewable_code, sourceforge_url, homepage_url, github_url, uses_absCanv, update_identifier, highscore_gid', 'safe', 'on'=>'search'),
);
}
@@ -78,6 +80,7 @@ class Program extends CActiveRecord
'enabled' => 'Enabled',
'visible' => 'Visible',
'Language' => 'Language',
+ 'programming_lang' => 'programming_lang',
'Description' => 'Description',
'add_date' => 'Add Date',
'download_url' => 'Download Url',
@@ -116,6 +119,7 @@ class Program extends CActiveRecord
$criteria->compare('enabled',$this->enabled);
$criteria->compare('visible',$this->visible);
$criteria->compare('Language',$this->Language,true);
+ $criteria->compare('programming_lang',$this->programming_lang,true);
$criteria->compare('Description',$this->Description,true);
$criteria->compare('add_date',$this->add_date,true);
$criteria->compare('download_url',$this->download_url,true);
@@ -145,4 +149,33 @@ class Program extends CActiveRecord
{
return parent::model($className);
}
+
+ //####################################
+ //########### MY FUNCTIONS ###########
+ //####################################
+
+ /**
+ * @return string
+ */
+ public function getImagePath() {
+ if (file_exists('images/programs/thumbnails/' . $this->Name . '.png'))
+ return '/images/programs/thumbnails/' . $this->Name . '.png';
+ else if (file_exists('images/programs/thumbnails/' . $this->Name . '.jpg'))
+ return '/images/programs/thumbnails/' . $this->Name . '.jpg'; //TODO REM ME - never use jpg
+ else throw new CHttpException(500, "Could not find Program Thumbnail '" . $this->Name . "'");
+ }
+
+ /**
+ * @return string
+ */
+ public function getLink() {
+ return '/programs/view/' . $this->Name;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getLanguageList() {
+ return explode("|", $this->Language);
+ }
}
diff --git a/www/protected/views/programs/index.php b/www/protected/views/programs/index.php
index 9608876..eb86fdf 100644
--- a/www/protected/views/programs/index.php
+++ b/www/protected/views/programs/index.php
@@ -31,7 +31,7 @@
order = "add_date DESC";
+ $criteria->order = "Sterne DESC, add_date DESC";
$criteria->condition = "visible=1";
$all = Program::model()->findAll($criteria);
@@ -46,18 +46,21 @@
echo '
';
foreach (array_slice($all, $i * PROGS_INDEX_ROWSIZE, PROGS_INDEX_ROWSIZE) as $record) {
+ /* @var $record Program */
+
$this->widget('ThumbnailPreview',
[
- 'caption' => $record->attributes['Thumbnailname'],
- 'link' => '/programs/view/' . $record->attributes['Name'],
- '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']),
- 'enabled' => $record->attributes['enabled'],
+ 'caption' => $record->Thumbnailname,
+ 'link' => $record->getLink(),
+ 'description' => $record->Description,
+ 'category' => $record->Kategorie,
+ 'language' => $record->getLanguageList(),
+ 'image' => $record->getImagePath(),
+ 'starcount' => $record->Sterne,
+ 'downloads' => $record->Downloads,
+ 'date' => new DateTime($record->add_date),
+ 'enabled' => $record->enabled,
+ 'programminglang' => $record->programming_lang,
]);
}