public function getAjaxTemplate() { $files = JRequest::getVar('names', ''); if (empty($files)) { return false; } // Ensure the integrity of each items submitted to be an array. if (!is_array($files)) { $files = array($files); } $result = array(); foreach ($files as $file) { $template = Komento::getTheme(); $out = $template->fetch($file . '.ejs'); $obj = new stdClass(); $obj->name = $file; $obj->content = $out; $result[] = $obj; } Komento::getClass('json', 'KomentoJson'); header('Content-type: text/x-json; UTF-8'); $json = new KomentoJson(); echo $json->encode($result); exit; }
public function getResource() { $resources = JRequest::getVar('resource'); $component = JRequest::getCmd('kmtcomponent'); Komento::setCurrentComponent($component); if (!is_array($resources)) { header('Content-type: text/x-json; UTF-8'); echo '[]'; exit; } foreach ($resources as &$resource) { $resource = (object) $resource; switch ($resource->type) { case 'language': $resource->content = JText::_(strtoupper($resource->name)); break; case 'view': $template = Komento::getTheme(); $out = $template->fetch($resource->name . '.ejs'); if ($out !== false) { $resource->content = $out; } break; } } Komento::getClass('json', 'KomentoJson'); header('Content-type: text/x-json; UTF-8'); $json = new KomentoJson(); echo $json->encode($resources); exit; }
public function send() { // if( ob_get_length() !== false ) // { // while (@ ob_end_clean()); // if( function_exists( 'ob_clean' ) ) // { // @ob_clean(); // } // } header('Content-type: text/x-json; UTF-8'); require_once KOMENTO_CLASSES . DIRECTORY_SEPARATOR . 'json.php'; $json = new KomentoJson(); $callback = JRequest::getVar('callback'); if (isset($callback)) { echo $callback . '(' . $json->encode($this->commands) . ');'; } else { echo $json->encode($this->commands); } exit; }
public function getLanguage() { $languages = JRequest::getVar('languages'); $result = array(); // If this is not an array, make it as an array. if (!is_array($languages)) { $languages = array($languages); } foreach ($languages as $key) { $result[$key] = JText::_(strtoupper($key)); } Komento::getClass('json', 'Services_JSON'); header('Content-type: text/x-json; UTF-8'); $json = new KomentoJson(); echo $json->encode($result); exit; }