Added new Images for programs/index (+ other things)
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class ProgramHelper
|
||||
*/
|
||||
class ProgramHelper {
|
||||
|
||||
/**
|
||||
* @param bool $doDelimiter
|
||||
* @return Program[]
|
||||
*/
|
||||
public static function GetHighlightedProgList($doDelimiter)
|
||||
{
|
||||
$dropDownModels = array();
|
||||
@@ -26,7 +33,7 @@ class ProgramHelper {
|
||||
foreach (Program::model()->findAll($criteria) as $row) {
|
||||
$contains = false;
|
||||
foreach($dropDownModels as $modelElem)
|
||||
if ($modelElem != null && $modelElem->attributes['ID'] == $row->attributes['ID'])
|
||||
if ($modelElem != null && $modelElem->ID == $row->ID)
|
||||
$contains = true;
|
||||
if (! $contains)
|
||||
$dropDownModels[] = $row;
|
||||
@@ -35,6 +42,9 @@ class ProgramHelper {
|
||||
return $dropDownModels;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Program
|
||||
*/
|
||||
public static function GetRecentProg()
|
||||
{
|
||||
$criteria = new CDbCriteria;
|
||||
@@ -45,6 +55,9 @@ class ProgramHelper {
|
||||
return Program::model()->find($criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Program
|
||||
*/
|
||||
public static function GetDailyProg()
|
||||
{
|
||||
$recent = self::GetRecentProg();
|
||||
@@ -62,6 +75,9 @@ class ProgramHelper {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function GetProgDropDownList()
|
||||
{
|
||||
$progDropDown = array();
|
||||
@@ -72,7 +88,7 @@ class ProgramHelper {
|
||||
if (is_null($row))
|
||||
$progDropDown[] = TbHtml::menuDivider();
|
||||
else
|
||||
$progDropDown[] = array('label' => $row->attributes['Name'], 'url' => '/programs/view/' . $row->attributes['Name']);
|
||||
$progDropDown[] = array('label' => $row->Name, 'url' => $row->getLink());
|
||||
}
|
||||
return $progDropDown;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,12 @@ class ThumbnailPreview extends CWidget {
|
||||
public $downloads = 0;
|
||||
public $date = null;
|
||||
public $image = '';
|
||||
public $programminglang = '???';
|
||||
|
||||
public function run() {
|
||||
if ($this->date == null)
|
||||
$this->date = new DateTime('2000-01-01');
|
||||
|
||||
$this->render('thumbnailPreview');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="thumbnail <?php if (! $this->enabled) print("thumbnailDisabled"); ?>">
|
||||
<div class="thumbnailInnerHead">
|
||||
<a <?php if($this->enabled) echo 'href="'. $this->link . '"'; ?>>
|
||||
<img style="width: 100%" <?php if (! $this->enabled) print('class="grayscale"'); ?> src="<?php echo $this->image; ?>">
|
||||
<img class="thumbnailInnerImage <?php if (! $this->enabled) print('grayscale'); ?>" src="<?php echo $this->image; ?>">
|
||||
</a>
|
||||
</div>
|
||||
<div class="caption">
|
||||
@@ -66,8 +66,8 @@
|
||||
<div class="span4"><b><?php echo $this->date->format('d.m.y'); ?></b><br/>
|
||||
<small>Added On</small>
|
||||
</div>
|
||||
<div class="span4"><b><?php echo $this->starcount . '/4'; ?></b><br/>
|
||||
<small>Rating</small>
|
||||
<div class="span4"><b><?php echo $this->programminglang; ?></b><br/>
|
||||
<small>Language</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<?php
|
||||
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->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 '<ul class="thumbnails">';
|
||||
|
||||
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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user