2014-02-14 1 views
1

사이트에서 필자가 설치하지 않았기 때문에 설치시/public_html/libraries/joomla/document/json을 추가했습니다. 사이트가 1.5에서 실행되고 로컬로 Joomla 2.5를 사용하고 있습니다./libraries/joomla/document/json 아래의 jDocument 클래스가 무시되었습니다.

내 URL은 &format=json이 추가되었지만 응답 헤더는 text/html입니다. 아마 2.5의 파일이 1.5와 호환되지 않을 수 있습니다.

<?php 
defined('JPATH_PLATFORM') or die; 
class JDocumentJSON extends JDocument 
{ 
    protected $_name = 'joomla'; 
    public function __construct($options = array()) 
    { 
     parent::__construct($options); 
     $this->_mime = 'application/json'; 
     $this->_type = 'json'; 
    } 
    public function render($cache = false, $params = array()) 
    { 
     JResponse::allowCache(false); 
     JResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true); 

     parent::render(); 

     return $this->getBuffer(); 
    } 
    public function getName() 
    { 
     return $this->_name; 
    } 
    public function setName($name = 'joomla') 
    { 
     $this->_name = $name; 

     return $this; 
    } 
} 
+0

방금 ​​파일을 2.5에서 가져 와서 1.5로 고정 시켰다고 하시겠습니까? 아니, 그럴 일은 없을거야. – Elin

+0

@Elin 작동하지 않는 것을 제거해 주셔서 감사합니다. 무관 한 주제에; 1.5에 대한 API 참조를 알고 있습니까? 그것은 Joomla 사이트에있는 것 같지 않거나 꽤 잘 숨기고있어. – HMR

+0

@Elin 발견 : http://docs.joomla.org/Framework/1.5도 삭제 된 다른 페이지로 리디렉션됩니다. 이 문서를 작성하고 번역하는 데 시간을 투자 한 모든 사람들에게 유감입니다. – HMR

답변

1

난 단지 작은 차이를 발견 1.5 버전의 raw.php 확인 : 그것은 다음과 같은 내용이

은 1.5

그리고 어쩌면 더 중요한 공공 수정이없는 렌더링 :: 렌더링 부모가 먼저라고, 그래서 코드는 이제 다음과 같습니다

<?php 
/** 
* @version  $Id: json.php 14401 2010-01-26 14:10:00Z louis $ 
* @package  Joomla.Framework 
* @subpackage Document 
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 
* @license  GNU/GPL, see LICENSE.php 
* Joomla! is free software. This version may have been modified pursuant 
* to the GNU General Public License, and as distributed it includes or 
* is derivative of works licensed under the GNU General Public License or 
* other free or open source software licenses. 
* See COPYRIGHT.php for copyright notices and details. 
*/ 

// Check to ensure this file is within the rest of the framework 
defined('JPATH_BASE') or die(); 

/** 
* DocumentJSON class, provides an easy interface to parse and display json output 
* 
* @package  Joomla.Framework 
* @subpackage Document 
* @since  1.5 
*/ 

class JDocumentJSON extends JDocument 
{ 

    /** 
    * Class constructore 
    * 
    * @access protected 
    * @param array $options Associative array of options 
    */ 
    protected $_name = 'joomla'; 
    function __construct($options = array()) 
    { 
     parent::__construct($options); 
     $this->_mime = 'application/json'; 
     $this->_type = 'json'; 
    } 

    /** 
    * Render the document. 
    * 
    * @access public 
    * @param boolean $cache  If true, cache the output 
    * @param array  $params  Associative array of attributes 
    * @return The rendered data 
    */ 
    function render($cache = false, $params = array()) 
    { 
     parent::render(); 
     JResponse::allowCache(false); 
     JResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true); 
     return $this->getBuffer(); 
    } 
    public function getName() 
    { 
     return $this->_name; 
    } 
    public function setName($name = 'joomla') 
    { 
     $this->_name = $name; 
     return $this; 
    } 
} 

헤더가 올바르게 설정되어

관련 문제