<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Core_Form_Admin_Language_Upload extends Engine_Form
{
  public function init()
  {
    $this
      ->setTitle('Language Pack')
      ->setDescription('Upload a modified language pack.  This will overwrite any language entries already in a language file.')
      ->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()))
      ;
    
    
    $languageList     = Zend_Locale_Data::getList('en', 'language');
    $territoryList    = Zend_Locale_Data::getList('en', 'territory');

    $languageNameList = array();
    foreach (array_keys(Zend_Locale::getLocaleList()) as $localeCode) {
      $localeArray = explode('_', $localeCode);
      $locale      = array_shift($localeArray);
      $territory   = array_shift($localeArray);
      if (isset($languageList[$locale]) && !empty($languageList[$locale])) {
        $languageNameList[$localeCode] = $languageList[$locale];
        if (isset($territoryList[$territory]) && !empty($territoryList[$territory])) {
          $languageNameList[$localeCode] .= " ({$territoryList[$territory]})";
        }
        $languageNameList[$localeCode]   .= "  [$localeCode]";
      }
    }
    asort($languageNameList);
    $this->addElement('Select', 'locale', array(
      'label' => 'Language',
      'description' => 'Which language will this language pack be applied to?',
      'multiOptions' => $languageNameList,
    ));

    


    $this->addElement('File', 'file', array(
      'label' => 'Language File',
      'description' => 'Upload a language CSV file.',
      'required' => true,
    ));


    // Init submit
    $this->addElement('Button', 'submit', array(
      'label' => 'Upload',
      'type' => 'submit',
      'decorators' => array(
        'ViewHelper',
      ),
    ));

    $this->addElement('Cancel', 'cancel', array(
      'prependText' => ' or ',
      'link' => true,
      'label' => 'cancel',
      'onclick' => 'history.go(-1); return false;',
      'decorators' => array(
        'ViewHelper'
      )
    ));
  }
}
