<?php
class Pampa_View_Helper_LangLinkTo {
  public $view;

  public function setView(Zend_View_Interface $view) {
    $this->view = $view;
  }

  public function langLinkTo($controller = "index", $action = NULL, $params = array(), $module = "") {

    // monta os parametros
    $parameters = "";

    foreach($params as $key => $value) {
      $parameters .= $key."/".$value."/";
    }

    // valida o modulo
    if($module == "") {
      $fc = Zend_Controller_Front::getInstance();
      $module = $fc->getRequest()->getModuleName();
    }
    // remove link if module is default or add aslash
    $module = ($module == "site") ? "" : $module."/";

    // start url
    $url = Plugin_Language::getShort()."/".$module.$controller."/";
    // check for action
    if(!empty($action)){
      $url .= $action."/";
    }
    // check for params
    if(!empty($parameters)){
      $url .= $parameters;
    }

    return $this->view->urlTo($url);

  }
}
?>
