Пример #1
0
 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;
 }
Пример #2
0
 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;
 }
Пример #3
0
 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 Services_JSON();
     echo $json->encode($result);
     exit;
 }
Пример #4
0
 public static function _()
 {
     $class = 'KomentoLegacy16';
     if (Komento::joomlaVersion() == '1.5') {
         $class = 'KomentoLegacy15';
     }
     $legacy = Komento::getClass('legacy', $class);
     $args = func_get_args();
     $function = array_shift($args);
     if (strstr($function, '::')) {
         $function = str_replace('::', '_', $function);
     }
     if (is_callable(array($class, $function))) {
         return call_user_func_array(array($class, $function), $args);
     } else {
         return false;
     }
 }
Пример #5
0
if (Komento::joomlaVersion() >= '1.6') {
    if (!JFactory::getUser()->authorise('core.manage', 'com_komento')) {
        JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
        JFactory::getApplication()->close();
    }
}
// else
// {
// 	if ( !JFactory::getUser()->authorize('com_komento', 'manage') )
// 	{
// 		return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
// 	}
// }
if (JRequest::getBool('compile')) {
    $minify = JRequest::getBool('minify', false);
    $compiler = Komento::getClass('compiler', 'KomentoCompiler');
    $results = $compiler->compile($minify);
    header('Content-type: text/x-json; UTF-8');
    echo json_encode($results);
    exit;
}
Komento::getHelper('Ajax')->process();
// Get the task
$task = JRequest::getCmd('task', 'display');
// We treat the view as the controller. Load other controller if there is any.
$controller = JRequest::getCmd('c', JRequest::getCmd('controller', ''));
// If task is getLanguage, then set c = lang
if ($task == 'getLanguage') {
    $controller = 'lang';
}
$controller = KomentoController::getInstance($controller);