public function getTemplatePaths($path = '', $fullpath = false) { if ($path) { $path = KunenaPath::clean("/{$path}"); } $array = array(); $array[] = ($fullpath ? KPATH_ADMIN : KPATH_COMPONENT_RELATIVE) . '/template/joomla25' . $path; return $array; }
public function template() { $name = JRequest::getString('name', JRequest::getString('kunena_template', '', 'COOKIE')); if ($name) { $name = KunenaPath::clean($name); if (!is_readable(KPATH_SITE . "/template/{$name}/template.xml")) { $name = 'blue_eagle'; } setcookie('kunena_template', $name, 0, JUri::root(true) . '/'); } else { setcookie('kunena_template', null, time() - 3600, JUri::root(true) . '/'); } $this->setRedirect(KunenaRoute::_('index.php?option=com_kunena', false)); }
/** * Returns the global KunenaTemplate object, only creating it if it doesn't already exist. * * @access public * @param int $name Template name or null for default/selected template in your configuration * @return KunenaTemplate The template object. * @since 1.6 */ public static function getInstance($name = null) { $app = JFactory::getApplication(); if (!$name) { $name = JRequest::getString('kunena_template', KunenaFactory::getConfig()->template, 'COOKIE'); } $name = KunenaPath::clean($name); if (empty(self::$_instances[$name])) { // Find overridden template class (use $templatename to avoid creating new objects if the template doesn't exist) $templatename = $name; $classname = "KunenaTemplate{$templatename}"; if (!is_file(KPATH_SITE . "/template/{$templatename}/template.xml") && !is_file(KPATH_SITE . "/template/{$templatename}/config.xml")) { // If template xml doesn't exist, raise warning and use blue eagle instead $file = JPATH_THEMES . "/{$app->getTemplate()}/html/com_kunena/template.php"; $templatename = 'blue_eagle'; $classname = "KunenaTemplate{$templatename}"; if (is_dir(KPATH_SITE . "/template/{$templatename}")) { KunenaError::warning(JText::sprintf('COM_KUNENA_LIB_TEMPLATE_NOTICE_INCOMPATIBLE', $name, $templatename)); } } if (!class_exists($classname) && $app->isSite()) { $file = KPATH_SITE . "/template/{$templatename}/template.php"; if (!is_file($file)) { $classname = "KunenaTemplateBlue_Eagle"; $file = KPATH_SITE . "/template/blue_eagle/template.php"; } if (is_file($file)) { require_once $file; } } if (class_exists($classname)) { self::$_instances[$name] = new $classname($templatename); } else { self::$_instances[$name] = new KunenaTemplate($templatename); } } return self::$_instances[$name]; }
/** * Load a template file -- first look in the templates folder for an override * * @param string $tpl The name of the template source file ... * automatically searches the template paths and compiles as needed. * @param array $hmvcParams Extra parameters for HMVC. * @return string The output of the the template script. */ public function loadTemplateFile($tpl = null, $hmvcParams = null) { KUNENA_PROFILER ? $this->profiler->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null; // HMVC legacy support. $view = $this->getName(); $layout = $this->getLayout(); list($name, $override) = $this->ktemplate->mapLegacyView("{$view}/{$layout}_{$tpl}"); $hmvc = KunenaLayout::factory($name)->setLayout($override); if ($hmvc->getPath()) { if ($hmvcParams) { $hmvc->setProperties($hmvcParams); } KUNENA_PROFILER ? $this->profiler->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null; return $hmvc->setLegacy($this); } // Create the template file name based on the layout $file = isset($tpl) ? $layout . '_' . $tpl : $layout; if (!isset($this->templatefiles[$file])) { // Clean the file name $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file); $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl; // Load the template script $filetofind = $this->_createFileName('template', array('name' => $file)); $this->templatefiles[$file] = KunenaPath::find($this->_path['template'], $filetofind); } $this->_template = $this->templatefiles[$file]; if ($this->_template != false) { $templatefile = preg_replace('%' . KunenaPath::clean(JPATH_ROOT, '/') . '/%', '', KunenaPath::clean($this->_template, '/')); // Unset so as not to introduce into template scope unset($tpl); unset($file); // Never allow a 'this' property if (isset($this->this)) { unset($this->this); } // Start capturing output into a buffer ob_start(); // Include the requested template filename in the local scope // (this will execute the view logic). include $this->_template; // Done with the requested template; get the buffer and // clear it. $output = ob_get_contents(); ob_end_clean(); if (JDEBUG || $this->config->get('debug')) { $output = trim($output); $output = "\n<!-- START {$templatefile} -->\n{$output}\n<!-- END {$templatefile} -->\n"; } } else { $output = JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $this->getName() . '/' . $file)); } KUNENA_PROFILER ? $this->profiler->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null; return $output; }
/** * @param JForm $form A form object. * @param mixed $data The data expected for the form. * @param string $group Form group. * * @return mixed True if successful. * @throws Exception if there is an error in the form event. * @since 1.6 */ protected function preprocessForm(JForm $form, $data, $group = 'content') { $folder = $this->getState('item.folder'); $element = $this->getState('item.element'); $lang = JFactory::getLanguage(); // Load the core and/or local language sys file(s) for the ordering field. $db = JFactory::getDbo(); $query = 'SELECT element' . ' FROM #__extensions' . ' WHERE (type =' . $db->Quote('plugin') . 'AND folder=' . $db->Quote($folder) . ')'; $db->setQuery($query); $elements = $db->loadColumn(); foreach ($elements as $elementa) { $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_PLUGINS . '/' . $folder . '/' . $elementa, null, false, false) || $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_PLUGINS . '/' . $folder . '/' . $elementa, $lang->getDefault(), false, false); } if (empty($folder) || empty($element)) { $app = JFactory::getApplication(); $app->redirect(JRoute::_('index.php?option=com_kunena&view=plugins', false)); } $formFile = KunenaPath::clean(JPATH_PLUGINS . '/' . $folder . '/' . $element . '/' . $element . '.xml'); if (!is_file($formFile)) { throw new Exception(JText::sprintf('COM_PLUGINS_ERROR_FILE_NOT_FOUND', $element . '.xml')); } // Load the core and/or local language file(s). $lang->load('plg_' . $folder . '_' . $element, JPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_' . $folder . '_' . $element, JPATH_PLUGINS . '/' . $folder . '/' . $element, null, false, false) || $lang->load('plg_' . $folder . '_' . $element, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_' . $folder . '_' . $element, JPATH_PLUGINS . '/' . $folder . '/' . $element, $lang->getDefault(), false, false); if (is_file($formFile)) { // Get the plugin form. if (!$form->loadFile($formFile, false, '//config')) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } } // Attempt to load the xml file. if (!($xml = simplexml_load_file($formFile))) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Get the help data from the XML file if present. $help = $xml->xpath('/extension/help'); if (!empty($help)) { $helpKey = trim((string) $help[0]['key']); $helpURL = trim((string) $help[0]['url']); $this->helpKey = $helpKey ? $helpKey : $this->helpKey; $this->helpURL = $helpURL ? $helpURL : $this->helpURL; } // Trigger the default form events. parent::preprocessForm($form, $data, $group); }
/** * */ function chooseless() { $template = $this->app->input->getArray(array('cid' => '')); $templatename = array_shift($template['cid']); $this->app->setUserState('kunena.templatename', $templatename); $tBaseDir = KunenaPath::clean(KPATH_SITE . '/template'); if (!is_dir($tBaseDir . '/' . $templatename . '/less')) { $this->app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_NO_LESS'), 'warning'); return; } $this->setRedirect(KunenaRoute::_($this->baseurl . "&layout=chooseless", false)); }