<?php
/**
 * 
 */
class Fiktiv_Controller_Plugin_Navigation extends Zend_Controller_Plugin_Abstract
{
    protected $_lang;

    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
        $navigtion = $bootstrap->getResource('nav');

        $this->_lang = $request->getParam('lang');

        // This can't be right?!
        // TODO: Fix Zend_Navigation + route (:lang)
        $this->setLangParam($navigtion);

    }

    protected function setLangParam($nav)
    {
        $pages = $nav->getPages();
        foreach ($pages as $page) {
            
            $page->setParams(array('lang' => $this->_lang));

            if ($page->hasChildren())
                $this->setLangParam($page);
        }
    }
}