implement QuestgroupspictureAgent to include the picture of a Questgroup

This commit is contained in:
coderkun 2014-02-14 18:58:47 +01:00
commit 857aeb37af
3 changed files with 98 additions and 0 deletions

View file

@ -0,0 +1,35 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\bottomlevel;
/**
* Agent to display the picture of a Questgroup.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupspictureAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: index.
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
}
?>

View file

@ -0,0 +1,60 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
/**
* Controller of QuestgroupspictureAgent to display the picture of a
* Questgroups.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupspictureController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'questgroups', 'media');
/**
* Action: index.
*
* Show the picture of a Questgroup.
*
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $questgroupUrl URL-Title of a Questgroup
*/
public function index($seminaryUrl, $questgroupUrl)
{
// Get Seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroup
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
// Get Picture
$picture = $this->Media->getMediaById($questgroup['questgroupspicture_id']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('picture', $picture);
}
}
?>

View file

@ -0,0 +1,3 @@
<?php if(!is_null($picture)) : ?>
<img src="<?=$linker->link(array('media','index',$seminary['url'],$picture['url']))?>" />
<?php endif ?>