<?php
/**
* @package XenCentral Ad Server
* @author Skydevelop EU
* @copyright Drnoyan & Nalyan LDA, Portugal, EU
* @license http://www.dnf.pt/eula.html
* @link http://www.skydevelop.com
* @revision 97
* @version 2.0.0 beta 3 rev. 3
*/

class XenCentral_AdServer_ViewAdmin_ZoneBase extends XenForo_ViewAdmin_Base
{
    public function renderHtml()
    {
        // render location templates
        $groupedLocations=$this->_params['groupedLocations'];
        $zone=$this->_params['item'];

        foreach($groupedLocations['locations'] AS $groupId=>$subGroupLocations) {
            foreach($subGroupLocations AS $subGroupId=>$locations) {
                foreach ($locations AS $locationId => $location) {
                    /** @var  XenCentral_AdServer_Locations_Hooks_Abstract $location */
                    if (!empty($zone['locations'][$locationId])) {
                        $locationInfo = $zone['locations'][$locationId];
                    } else {
                        $locationInfo = array();
                    }
                    $locationInfo = $location->prepareFromData($locationInfo);
                    $locationInfo = $location->preparePhrasesFromData($locationInfo);

                    $location->setPreparedTemplate($this->createTemplateObject(
                        $location->getOptionTemplate(), $locationInfo
                    ));
                }
            }
        }
    }
}