public function sendJson($data, $code = null) { $this->removeCookie(); if ($this->_allow_cros && isset($_SERVER['HTTP_ORIGIN'])) { if (isset($_SERVER['HTTP_HOST'])) { if (strpos($_SERVER['HTTP_ORIGIN'], '://' . $_SERVER['HTTP_HOST']) === false) { header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); header('Access-Control-Allow-Credentials: true'); header('Access-Control-Allow-Headers: Authorization,Content-Type'); if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { header('Access-Control-Allow-Methods: POST,GET,OPTIONS'); header('Access-Control-Max-Age: 86400'); } } } } if (Is_int($code)) { @http_response_code($code); } header('Content-Type: text/json; charset=utf-8'); echo json_encode($data, JSON_UNESCAPED_UNICODE); exit; }
/*------------------------------------------------------------------------ # mod_insertfieldsattach # ------------------------------------------------------------------------ # author Cristian Grañó (percha.com) # copyright Copyright (C) 2010 percha.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.percha.com # Technical Support: Forum - http://www.percha.com/ -------------------------------------------------------------------------*/ //no direct access defined('_JEXEC') or die('Direct Access to this location is not allowed.'); // include the helper file require_once dirname(__FILE__) . DS . 'helper.php'; $sitepath = JPATH_BASE; JLoader::register('fieldattach', $sitepath . 'components/com_fieldsattach/helpers/fieldattach.php'); $args['id'] = $params->get('id'); $type = ModHCSwitch::getType($args); $type = JRequest::getVar('view'); $id = JRequest::getVar("id", 0); if (!Is_int($id)) { $tmp = explode(":", $id); $id = $tmp[0]; } JPluginHelper::importPlugin('fieldsattachment'); // very important $function = "echo plgfieldsattachment_" . $type . "::getHTML(" . $id . "," . $args['id'] . ");"; // Initialize module parameters. $params->def('function', $function); //$item = ModInsertarticle::getArticles($args); // include the template for display require JModuleHelper::getLayoutPath('mod_hcswitch', $params->get('layout', 'default'));