/**
  *  Renvoie les titres nécessaires a la balise thead
  *  @return array
  */
 private function _indexGetHeads()
 {
     $localesModel = new Application_Model_DbTable_Locale_Language();
     $locales = $localesModel->getList();
     unset($localesModel);
     $heads = array("actions" => "Actions", "date" => "Date de parution", "active" => "Visible");
     foreach ($locales as $locale) {
         $title = "Titre {$locale}";
         $text = "Texte {$locale}";
         $heads['titre_' . $locale] = $title;
         $heads['text_' . $locale] = $text;
     }
     return $heads;
 }
 public function addCgvAction()
 {
     $params = $this->_getParams();
     /**
      * Savoir si on crée un set neuf ou si l'on souhaite partir du set actuel
      */
     if (empty($params['scratch'])) {
         $params['scratch'] = false;
     }
     try {
         $form = new Form_Unlog_Backend_About_Cgv_Add();
         $formName = "Form_Unlog_Backend_About_Cgv_Add_";
         $locales = new Application_Model_DbTable_Locale_Language();
         if (!$params['scratch'] && empty($params[$formName . 'Submit'])) {
             $latest = Application_Model_About_Cgv_Multilang::getLatest();
             $params[$formName . 'Date'] = $latest->getDate()->toString("dd/MM/yyyy hh:mm");
             $params[$formName . 'Active'] = $latest->getActive();
             foreach ($locales->getList() as $locale) {
                 $params[$formName . 'Text_' . $locale] = $latest->getText($locale);
             }
             $form->populate($params);
         } elseif (!empty($params[$formName . 'Submit']) && !$form->isValid($params)) {
             $form->populate($params);
         } elseif (!empty($params[$formName . 'Submit']) && $form->isValid($params)) {
             $data = new Application_Model_About_Cgv_Writer_Data($params[$formName . 'Date'], $params[$formName . 'Active']);
             foreach ($params as $key => $param) {
                 if (preg_match("#^{$formName}Text_#", $key)) {
                     $localeCode = substr($key, strlen($formName . "Text_"));
                     $data->addLocale($localeCode, $params[$formName . 'Text_' . $localeCode]);
                 }
             }
             $writer = new Application_Model_About_Cgv_Writer();
             $writer->insert($data);
             $this->_forward("cgv", "about", "unlog-backend");
         }
         $this->view->form = $form;
         $this->view->resources = Application_Model_Resources::get(array("returnButton" => "img_button_return_png"));
     } catch (Zend_Exception $e) {
         throw new Zend_Controller_Action_Exception("Error in Action : unlog-backend | about | cgv", null, $e);
     }
 }