<?php

namespace Concrete\Block\CoreGatheringDisplay;

use Concrete\Core\Block\BlockController;
use Core;

/**
 * Displays an gathering stand-alone in a page.
 *
 * @package    Blocks
 * @subpackage Core Gathering Display
 * @author     Andrew Embler
 * @copyright  Copyright (c) 2003-2013 Concrete5.
 * @license    MIT License
 */
class Controller extends BlockController
{
    protected $btCacheBlockRecord = true;
    protected $btTable = 'btCoreGatheringDisplay';
    protected $btIsInternal = true;
    public function getBlockTypeDescription()
    {
        return t("Proxy block for gathering items added to areas.");
    }

    public function getBlockTypeName()
    {
        return t("Gathering Display");
    }

    public function registerViewAssets($outputContent = '')
    {
        $this->requireAsset('core/gathering');
    }

    public function view()
    {
        Core::make('helper/overlay')->init(false);
        $gathering = Gathering::getByID($this->gaID);
        if (is_object($gathering)) {
            $list = new GatheringItemList($gathering);
            $list->sortByDateDescending();
            $this->set('gathering', $gathering);
            $this->set('itemList', $list);
        }
    }
}
