public static function display() { $app = JFactory::getApplication(); $input = $app->input; if (!$app->isAdmin()) { $tpl = $app->getTemplate(true); // get template name if ($input->getCmd('canvasaction') && ($styleid = $input->getInt('styleid', '')) && $tpl->id != $styleid) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('template, params'); $query->from('#__template_styles'); $query->where('client_id = 0'); $query->where('id = ' . $styleid); $db->setQuery($query); $tpl = $db->loadObject(); if ($tpl) { $registry = new JRegistry(); $registry->loadString($tpl->params); $tpl->params = $registry; } if (!$tpl) { die(json_encode(array('error' => JText::_('CANVAS_MSG_UNKNOW_ACTION')))); } } } else { $tplid = $input->getCmd('view') == 'style' ? $input->getCmd('id', 0) : false; if (!$tplid) { die(json_encode(array('error' => JText::_('CANVAS_MSG_UNKNOW_ACTION')))); } $cache = JFactory::getCache('com_templates', ''); if (!($templates = $cache->get('canvastpl'))) { // Load styles $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id, home, template, s.params'); $query->from('#__template_styles as s'); $query->where('s.client_id = 0'); $query->where('e.enabled = 1'); $query->leftJoin('#__extensions as e ON e.element=s.template AND e.type=' . $db->quote('template') . ' AND e.client_id=s.client_id'); $db->setQuery($query); $templates = $db->loadObjectList('id'); foreach ($templates as &$template) { $registry = new JRegistry(); $registry->loadString($template->params); $template->params = $registry; } $cache->store($templates, 'canvastpl'); } if (isset($templates[$tplid])) { $tpl = $templates[$tplid]; } else { $tpl = $templates[0]; } } //load language for template JFactory::getLanguage()->load('tpl_' . CANVAS_TEMPLATE, JPATH_SITE); //clean all unnecessary datas if (ob_get_length()) { @ob_end_clean(); } $canvasapp = CANVAS::getSite($tpl); $layout = $canvasapp->getLayout(); $canvasapp->loadLayout($layout); $lbuffer = ob_get_clean(); die($lbuffer); }