Ticket #501: lib.diff

File lib.diff, 4.6 kB (added by sylvain261, 5 months ago)

Response et maj du manifest

  • build/manifests/jelix-lib.mn

    old new  
    6464  jResponseCss.class.php 
    6565  jResponseLatexToPdf.class.php 
    6666  jResponseTcpdf.class.php 
     67  jResponseHtmlFragment.class.php 
    6768 
    6869cd lib/jelix/core-modules/jelix 
    6970  module.xml 
  • lib/jelix/core/response/jResponseHtmlFragment.class.php

    old new  
     1<?php 
     2/** 
     3* @package     jelix 
     4* @subpackage  core_response 
     5* @author      Tahina Ramaroson 
     6* @contributor Sylvain de Vathaire 
     7* @copyright   2008 Tahina Ramaroson, Sylvain de Vathaire 
     8* @link        http://www.jelix.org 
     9* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     10*/ 
     11 
     12/** 
     13 * Send Html part 
     14 * @package  jelix 
     15 * @subpackage core_response 
     16 */ 
     17class jResponseHtmlFragment extends jResponse { 
     18 
     19    /** 
     20    * jresponse id 
     21    * @var string 
     22    */ 
     23    protected $_type = 'htmlfragment'; 
     24 
     25    /** 
     26    * template selector 
     27    * set the template name in this property 
     28    * @var string 
     29    */ 
     30    public $tplname = ''; 
     31 
     32    /** 
     33    * the jtpl object created automatically 
     34    * @var jTpl 
     35    */ 
     36    public $tpl = null; 
     37 
     38    /** 
     39    * constructor; 
     40    * setup the template engine 
     41    */ 
     42    function __construct (){ 
     43        $this->tpl = new jTpl(); 
     44        parent::__construct(); 
     45    } 
     46 
     47    /** 
     48    * send the Html part 
     49    * @return boolean    true if it's ok 
     50    */ 
     51    final public function output(){ 
     52 
     53        global $gJConfig; 
     54 
     55        if($this->hasErrors()) return false; 
     56 
     57        $this->doAfterActions(); 
     58 
     59        if($this->hasErrors()) return false; 
     60 
     61        $content = ''; 
     62        if($this->tplname!=''){ 
     63            $content=$this->tpl->fetch($this->tplname,'html'); 
     64            if($this->hasErrors()) return false; 
     65        } 
     66 
     67        $this->_httpHeaders['Content-Type']='text/plain;charset='.$gJConfig->charset; 
     68        $this->_httpHeaders['Content-length']=strlen($content); 
     69        $this->sendHttpHeaders(); 
     70        echo $content; 
     71        return true; 
     72    } 
     73 
     74    /** 
     75     * The method you can overload in your inherited htmlfragment response 
     76     * after all actions 
     77     * @since 1.1 
     78     */ 
     79    protected function doAfterActions(){ 
     80        $this->_commonProcess(); // for compatibility with jelix 1.0 
     81    } 
     82 
     83    /** 
     84     * same use as doAfterActions, but deprecated method. It is just here for compatibility with Jelix 1.0. 
     85     * Use doAfterActions instead 
     86     * @deprecated 
     87     */ 
     88    protected function _commonProcess(){ 
     89    } 
     90 
     91    /** 
     92     * output errors 
     93     */ 
     94    final public function outputErrors(){ 
     95 
     96        global $gJConfig; 
     97        $this->clearHttpHeaders(); 
     98        $this->_httpStatusCode ='500'; 
     99        $this->_httpStatusMsg ='Internal Server Error'; 
     100        $this->_httpHeaders['Content-Type']='text/plain;charset='.$gJConfig->charset; 
     101 
     102        if($this->hasErrors()){ 
     103            $content = $this->getFormatedErrorMsg(); 
     104        }else{ 
     105            $content = '<p style="color:#FF0000">Unknow Error</p>'; 
     106        } 
     107 
     108        $this->_httpHeaders['Content-length'] = strlen($content); 
     109        $this->sendHttpHeaders(); 
     110        echo $content; 
     111    } 
     112 
     113    /** 
     114     * create html error messages 
     115     * @return string html content 
     116     */ 
     117    protected function getFormatedErrorMsg(){ 
     118        $errors=''; 
     119        foreach( $GLOBALS['gJCoord']->errorMessages  as $e){ 
     120           $errors .=  '<p style="margin:0;"><b>['.$e[0].' '.$e[1].']</b> <span style="color:#FF0000">'.htmlspecialchars($e[2], ENT_NOQUOTES, $this->_charset)."</span> \t".$e[3]." \t".$e[4]."</p>\n"; 
     121        } 
     122        return $errors; 
     123    } 
     124} 
     125?> 
  • lib/jelix/core/defaultconfig.ini.php

    old new  
    4545css= jResponseCss 
    4646ltx2pdf= jResponseLatexToPdf 
    4747tcpdf = jResponseTcpdf 
     48htmlfragment = jResponseHtmlFragment 
    4849 
    4950[_coreResponses] 
    5051html = jResponseHtml 
     
    6768css= jResponseCss 
    6869ltx2pdf= jResponseLatexToPdf 
    6970tcpdf = jResponseTcpdf 
     71htmlfragment = jResponseHtmlFragment 
    7072 
    7173[error_handling] 
    7274messageLogFormat = "%date%\t[%code%]\t%msg%\t%file%\t%line%\n" 
Download in other formats: Original Format