2014-05-28 09:35:46 +02:00
|
|
|
<?php
|
|
|
|
|
2014-05-28 11:02:52 +02:00
|
|
|
class ProgramHelper {
|
2014-05-28 09:35:46 +02:00
|
|
|
|
|
|
|
public static function GetHighlightedProgList($doDelimiter)
|
|
|
|
{
|
|
|
|
$dropDownModels = array();
|
|
|
|
|
|
|
|
$criteria = new CDbCriteria;
|
|
|
|
$criteria->order = "add_date DESC";
|
|
|
|
$criteria->condition = "visible=1 AND enabled=1";
|
|
|
|
$criteria->limit = 3;
|
2014-05-28 11:02:52 +02:00
|
|
|
foreach (Program::model()->findAll($criteria) as $row) {
|
2014-05-28 09:35:46 +02:00
|
|
|
$dropDownModels[] = $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($doDelimiter)
|
|
|
|
{
|
|
|
|
$dropDownModels[] = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$criteria = new CDbCriteria;
|
|
|
|
$criteria->order = "add_date DESC";
|
|
|
|
$criteria->limit = 8;
|
|
|
|
$criteria->condition = "Sterne=4 AND visible=1 AND enabled=1";
|
2014-05-28 11:02:52 +02:00
|
|
|
foreach (Program::model()->findAll($criteria) as $row) {
|
2014-05-28 09:35:46 +02:00
|
|
|
$dropDownModels[] = $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $dropDownModels;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetRecentProg()
|
|
|
|
{
|
|
|
|
$criteria = new CDbCriteria;
|
|
|
|
$criteria->order = "add_date DESC";
|
|
|
|
$criteria->condition = "DATEDIFF(CURDATE(), add_date) <= 14 AND visible=1 AND enabled=1";
|
|
|
|
$criteria->limit = 1;
|
|
|
|
|
2014-05-28 11:02:52 +02:00
|
|
|
return Program::model()->find($criteria);
|
2014-05-28 09:35:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetDailyProg()
|
|
|
|
{
|
|
|
|
$recent = self::GetRecentProg();
|
|
|
|
|
|
|
|
if ($recent != null)
|
|
|
|
return $recent;
|
|
|
|
|
|
|
|
$toparray = self::GetHighlightedProgList(false);
|
|
|
|
|
|
|
|
$msrand = new SeededRandom();
|
|
|
|
$msrand->seedWithDailySeed();
|
|
|
|
|
|
|
|
$result = $msrand->getRandomElement($toparray);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetProgDropDownList()
|
|
|
|
{
|
|
|
|
$progDropDown = array();
|
|
|
|
|
|
|
|
$dropDownModels = self::GetHighlightedProgList(true);
|
|
|
|
|
|
|
|
foreach ($dropDownModels as $row) {
|
|
|
|
if (is_null($row))
|
|
|
|
$progDropDown[] = TbHtml::menuDivider();
|
|
|
|
else
|
2014-05-28 11:26:17 +02:00
|
|
|
$progDropDown[] = array('label' => $row->attributes['Name'], 'url' => '/programs/view/' . $row->attributes['Name']);
|
2014-05-28 09:35:46 +02:00
|
|
|
}
|
|
|
|
return $progDropDown;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|