/**
  * Agit selon le résultat de l'execution de l'action de la méthode de l'objet ActionGroup
  * Methode qui va effectuer un affichage de template, une redirection etc... en fonction
  * du code indiqué par le CopixActionReturn.
  * @param CopixActionReturn      $ToProcess   indique le type de resultat
  * @see CopixActionGroup
  * @todo rajouter une sorte de "Fin de traitement" _DoEnd / _DoFirst
  * @access private
  */
 function _processResult($toProcess)
 {
     //ending
     switch ($toProcess->code) {
         case COPIX_AR_ERROR:
             //erreur
             header("Content-Type: text/html");
             $tpl = new CopixTpl();
             if (($assignedTitlePage = $tpl->getAssigned('TITLE_PAGE')) !== null) {
                 $tpl->assign('TITLE_PAGE', '[' . CopixI18N::get('copix:common.messages.error') . ']' . $assignedTitlePage);
             } else {
                 $tpl->assign('TITLE_PAGE', '[' . CopixI18N::get('copix:common.messages.error') . ']');
             }
             $this->_processStandard($tpl);
             $this->_doHTMLHeaders($tpl);
             $tpl->assign('MAIN', $toProcess->data);
             $content = $tpl->fetch('|error.tpl');
             CopixContext::clear();
             $this->_callPluginsMethod_beforeDisplay($content);
             echo $content;
             break;
         case COPIX_AR_DISPLAY:
             header("Content-Type: text/html");
             $this->_processStandard($toProcess->data);
             //appel de la méthode de préparation de la page standard.
             $this->_doHTMLHeaders($toProcess->data);
             //Par ex, bandeaux de pub, menus dynamiques, ... (propres aux projets.)
             CopixContext::clear();
             $content = $toProcess->data->fetch($GLOBALS['COPIX']['CONFIG']->mainTemplate);
             //$content = str_replace ('./', $GLOBALS['COPIX']['CONFIG']->significant_url_basepath, $content);
             $this->_callPluginsMethod_beforeDisplay($content);
             echo $content;
             break;
         case COPIX_AR_DISPLAY_IN:
             $this->_processStandard($toProcess->data);
             //appel de la méthode de préparation de la page standard.
             $this->_doHTMLHeaders($toProcess->data);
             //Par ex, bandeaux de pub, menus dynamiques, ... (propres aux projets.)
             $content = $toProcess->data->fetch($toProcess->more);
             $this->_callPluginsMethod_beforeDisplay($content);
             echo $content;
             break;
         case COPIX_AR_REDIRECT:
             //redirection standard, message http.
             header('location: ' . $toProcess->data);
             break;
         case COPIX_AR_STATIC:
             $tpl =& new CopixTpl();
             $tpl->assign('MAIN', $this->includeStatic($toProcess->data));
             $this->_processStandard($tpl);
             $this->_doHTMLHeaders($tpl);
             $waitForMore = array('TITLE_PAGE', 'TITLE_BAR');
             foreach ($waitForMore as $key) {
                 if (isset($toProcess->more[$key])) {
                     $tpl->assign($key, $toProcess->more[$key]);
                 }
             }
             //Affichage dans le template principal.
             CopixContext::clear();
             $content = $tpl->fetch($GLOBALS['COPIX']['CONFIG']->mainTemplate);
             $this->_callPluginsMethod_beforeDisplay($content);
             echo $content;
             break;
         case COPIX_AR_DOWNLOAD:
             $fileName = $toProcess->data;
             if (is_readable($fileName) && is_file($fileName)) {
                 //quick and dirty..... still.
                 if (strlen(trim($toProcess->more))) {
                     $fileNameOnly = $toProcess->more;
                 } else {
                     $fileNameOnly = explode('/', str_replace('\\', '/', $fileName));
                     $fileNameOnly = $fileNameOnly[count($fileNameOnly) - 1];
                 }
                 header("Content-Type: application/forcedownload");
                 header("Content-Disposition: attachment; filename=" . $fileNameOnly);
                 header("Content-Description: File Transfert");
                 header("Content-Transfer-Encoding: binary");
                 header("Pragma: no-cache");
                 header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
                 header("Expires: 0");
                 header("Content-Length: " . filesize($fileName));
                 readfile($fileName);
                 flush();
             }
             break;
         case COPIX_AR_BINARY:
             $fileName = $toProcess->data;
             //echo $fileName;
             if (is_readable($fileName) && is_file($fileName)) {
                 header("Content-Type: " . $toProcess->more);
                 header("Content-Length: " . filesize($fileName));
                 readfile($fileName);
                 flush();
             }
             break;
         case COPIX_AR_BINARY_CONTENT:
             $content = $toProcess->data;
             header("Content-Type: " . $toProcess->more);
             header("Content-Length: " . strlen($content));
             echo $content;
             flush();
             break;
         case COPIX_AR_DOWNLOAD_CONTENT:
             $content = $toProcess->data;
             header("Content-Type: application/forcedownload");
             header("Content-Disposition: attachment; filename=" . $toProcess->more);
             header("Content-Description: File Transfert");
             header("Content-Transfer-Encoding: binary");
             header("Pragma: no-cache");
             header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
             header("Expires: 0");
             header("Content-Length: " . strlen($content));
             echo $content;
             flush();
             break;
         case COPIX_AR_NONE:
             break;
         case COPIX_AR_XMLRPC:
             header("Content-Type: text/xml");
             require_once COPIX_UTILS_PATH . 'CopixXmlRpc.class.php';
             $content = CopixXmlRpc::encodeResponse($toProcess->data);
             header("Content-length: " . strlen($content));
             echo $content;
             break;
         case COPIX_AR_XMLRPC_FAULT:
             header("Content-Type: text/xml");
             require_once COPIX_UTILS_PATH . 'CopixXmlRpc.class.php';
             $content = CopixXmlRpc::encodeFaultResponse($toProcess->data[0], $toProcess->data[1]);
             header("Content-length: " . strlen($content));
             echo $content;
             break;
         default:
             trigger_error(CopixI18N::get('copix:copix.error.noActionReturn'), E_USER_ERROR);
             break;
     }
     //Calling plugins
     //appel les plugins de post-processing.
     $this->_callPluginsMethod_afterProcess($toProcess);
 }