public function __construct($config = array()) { $name = isset($config['name']) ? $config['name'] : $this->getName(); $this->document = JFactory::getDocument(); $this->document->setBase(''); $this->profiler = KunenaProfiler::instance('Kunena'); $this->app = JFactory::getApplication(); $this->me = KunenaUserHelper::getMyself(); $this->config = KunenaFactory::getConfig(); $this->ktemplate = KunenaFactory::getTemplate(); // Set the default template search path if ($this->app->isSite() && !isset($config['template_path'])) { $config['template_path'] = $this->ktemplate->getTemplatePaths("html/{$name}", true); } if ($this->app->isAdmin()) { $templateAdmin = KunenaFactory::getAdminTemplate(); $templateAdmin->initialize(); $config['template_path'] = $templateAdmin->getTemplatePaths($name); } parent::__construct($config); if ($this->app->isSite()) { // Add another template file lookup path specific to the current template $fallback = JPATH_THEMES . "/{$this->app->getTemplate()}/html/com_kunena/{$this->ktemplate->name}/{$this->getName()}"; $this->addTemplatePath($fallback); } // Use our own browser side cache settings. JResponse::allowCache(false); JResponse::setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true); JResponse::setHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true); JResponse::setHeader('Cache-Control', 'no-store, must-revalidate, post-check=0, pre-check=0', true); }
/** * Returns layout class. * * <code> * // Output pagination/pages layout with current cart instance. * echo KunenaLayout::factory('Pagination/Pages')->set('pagination', $this->pagination); * </code> * * @param mixed $paths String or array of strings. * @param string $base Base path. * @return KunenaLayout */ public static function factory($paths, $base = 'pages') { $paths = (array) $paths; $app = JFactory::getApplication(); // Add all paths for the template overrides. if ($app->isAdmin()) { $template = KunenaFactory::getAdminTemplate(); } else { $template = KunenaFactory::getTemplate(); } $templatePaths = array(); foreach ($paths as $path) { if (!$path) { continue; } $path = (string) preg_replace('|\\\\|', '/', strtolower($path)); $lookup = $template->getTemplatePaths("{$base}/{$path}", true); foreach ($lookup as $loc) { array_unshift($templatePaths, $loc); } } // Go through all the matching layouts. $path = 'Undefined'; foreach ($paths as $path) { if (!$path) { continue; } // Attempt to load layout class if it doesn't exist. $class = 'KunenaPage' . (string) preg_replace('/[^A-Z0-9_]/i', '', $path); $fpath = (string) preg_replace('|\\\\|', '/', strtolower($path)); if (!class_exists($class)) { $filename = JPATH_BASE . "/components/com_kunena/page/{$fpath}.php"; if (!is_file($filename)) { continue; } require_once $filename; } // Create layout object. return new $class($fpath, $templatePaths); } // Create default layout object. return new KunenaLayoutPage($path, $templatePaths); }
/** * Returns layout class. * * <code> * // Output pagination/pages layout with current cart instance. * echo KunenaLayout::factory('pagination/pages')->set('pagination', $this->pagination); * </code> * * @param mixed $paths String or array of strings. * @return KunenaLayout */ public static function factory($paths) { if (!is_array($paths)) { $paths = (array) $paths; } $app = JFactory::getApplication(); // Add all paths for the template overrides. $templatePaths = new SplPriorityQueue(); if ($app->isAdmin()) { $template = KunenaFactory::getAdminTemplate(); $base = 'layouts'; } else { $template = KunenaFactory::getTemplate(); $base = 'html/layouts'; } foreach ($paths as $path) { if (!$path) { continue; } $lookup = $template->getTemplatePaths("{$base}/{$path}", true); foreach ($lookup as $loc) { $templatePaths->insert($loc, 1); } } // Go through all the matching layouts. foreach ($paths as $path) { if (!$path) { continue; } // Attempt to load layout class if it doesn't exist. $class = 'KunenaLayout' . (string) preg_replace('/[^A-Z0-9_]/i', '', $path); if (!class_exists($class)) { $filename = JPATH_BASE . "/components/com_kunena/layouts/{$path}/layout.php"; if (!is_file($filename)) { continue; } require_once $filename; } // Create layout object. return new $class($templatePaths); } // Create default layout object. return new KunenaLayout($templatePaths); }