function list_layouts($theme = null, $theme_option = null) { global $prefs; if (empty($theme) && empty($theme_option)) { // if you submit no parameters, return the current theme/theme option if (isset($prefs['site_theme'])) { $theme = $prefs['site_theme']; } if (isset($prefs['theme_option'])) { $theme_option = $prefs['theme_option']; } } $themelib = TikiLib::lib('theme'); $available_layouts = array(); foreach (scandir(TIKI_PATH . '/templates/layouts/') as $layoutName) { if ($layoutName[0] != '.' && $layoutName != 'index.php') { $available_layouts[$layoutName] = ucfirst($layoutName); } } foreach (TikiAddons::getPaths() as $path) { if (file_exists($path . '/templates/layouts/')) { foreach (scandir($path . '/templates/layouts/') as $layoutName) { if ($layoutName[0] != '.' && $layoutName != 'index.php') { $available_layouts[$layoutName] = ucfirst($layoutName); } } } } $main_theme_path = $themelib->get_theme_path($theme, '', '', 'templates'); // path to the main site theme if (file_exists(TIKI_PATH . "/" . $main_theme_path . '/layouts/')) { foreach (scandir(TIKI_PATH . "/" . $main_theme_path . '/layouts/') as $layoutName) { if ($layoutName[0] != '.' && $layoutName != 'index.php') { $available_layouts[$layoutName] = ucfirst($layoutName); } } } if ($theme_option) { $theme_path = $themelib->get_theme_path($theme, $theme_option, '', 'templates'); // path to the site theme options if (file_exists(TIKI_PATH . "/" . $theme_path . '/layouts/')) { foreach (scandir(TIKI_PATH . "/" . $theme_path . '/layouts/') as $layoutName) { if ($layoutName[0] != '.' && $layoutName != 'index.php') { $available_layouts[$layoutName] = ucfirst($layoutName); } } } } return $available_layouts; }
function wikiplugin_showpref($data, $params) { global $prefs; $tikilib = TikiLib::lib('tiki'); $name = $params['pref']; if (substr($name, 0, 3) == 'ta_') { $midpos = strpos($name, '_', 3); $pos = strpos($name, '_', $midpos + 1); $file = substr($name, 0, $pos); } elseif (false !== ($pos = strpos($name, '_'))) { $file = substr($name, 0, $pos); } else { $file = 'global'; } $inc_file = "lib/prefs/{$file}.php"; if (substr($file, 0, 3) == "ta_") { $paths = TikiAddons::getPaths(); $package = str_replace('_', '/', substr($file, 3)); $inc_file = $paths[$package] . "/prefs/{$file}.php"; } if (file_exists($inc_file)) { require_once $inc_file; $function = "prefs_{$file}_list"; if (function_exists($function)) { $preffile = $function(); } else { $preffile = array(); } } // Security public prefs only, you would not want all prefs to be displayed via wiki syntax if (isset($preffile[$name]['public']) && $preffile[$name]['public']) { return $tikilib->get_preference($name); } else { return ''; } }
if (!empty($_SESSION['try_theme'])) { list($theme_active, $theme_option_active) = $themelib->extract_theme_and_option($_SESSION['try_theme']); } //START loading theme related items //1) Always add default bootstrap JS and make some preference settings $headerlib->add_jsfile('vendor/twitter/bootstrap/dist/js/bootstrap.js'); $headerlib->add_jsfile('lib/jquery_tiki/tiki-bootstrapmodalfix.js'); if ($prefs['feature_fixed_width'] === 'y') { $headerlib->add_css('@media (min-width: 1200px) { .container { width:' . (!empty($prefs['layout_fixed_width']) ? $prefs['layout_fixed_width'] : '1170px') . '; } }'); } //2) Always add tiki_base.css. Add it first, so that it can be overriden in the custom themes $headerlib->add_cssfile("themes/base_files/css/tiki_base.css"); //3) Always add bundled font-awesome css for the default icon fonts $headerlib->add_cssfile('vendor/fortawesome/font-awesome/css/font-awesome.min.css'); //4) Add Addon custom css first, so it can be overridden by themes foreach (TikiAddons::getPaths() as $path) { foreach (glob('addons/' . basename($path) . '/css/*.css') as $filename) { $headerlib->add_cssfile($filename); } } //5) Now add the theme or theme option $themelib = TikiLib::lib('theme'); // compile a new CSS file using header_custom_less and using the real theme and the theme option if (!empty($prefs['header_custom_less'])) { $cssfiles = $headerlib->compile_custom_less($prefs['header_custom_less'], $theme_active, $theme_option_active); foreach ($cssfiles as $cssfile) { $headerlib->add_cssfile($cssfile); } } else { if ($theme_active == 'custom_url' && !empty($prefs['theme_custom_url'])) { //custom URL, use only if file exists at the custom location
private function getAvailableFiles() { $files = array(); foreach (glob(__DIR__ . '/prefs/*.php') as $file) { if (basename($file) === "index.php") { continue; } $files[] = substr(basename($file), 0, -4); } foreach (TikiAddons::getPaths() as $path) { foreach (glob($path . '/prefs/*.php') as $file) { if (basename($file) === "index.php") { continue; } $files[] = substr(basename($file), 0, -4); } } return $files; }
function initializePaths() { global $prefs, $tikidomainslash, $section; if (!$this->main_template_dir) { // First run only $this->main_template_dir = TIKI_PATH . '/templates/'; $this->setCompileDir(TIKI_PATH . "/templates_c"); $this->setPluginsDir(array(TIKI_PATH . '/' . TIKI_SMARTY_DIR, SMARTY_DIR . 'plugins')); } $this->setTemplateDir([]); // when called from release.php TikiLib isn't initialised so we can ignore the themes and addons if (class_exists('TikiLib')) { // Theme templates $themelib = TikiLib::lib('theme'); if (!empty($prefs['theme']) && !in_array($prefs['theme'], ['custom_url'])) { $theme_path = $themelib->get_theme_path($prefs['theme'], $prefs['theme_option'], '', 'templates'); // path to the theme options $this->addTemplateDir(TIKI_PATH . "/{$theme_path}/"); //if theme_admin is empty, use main theme and site_layout instead of site_layout_admin if ($section != "admin" || empty($prefs['theme_admin'])) { $this->addTemplateDir(TIKI_PATH . "/{$theme_path}/" . 'layouts/' . $prefs['site_layout'] . '/'); } else { $this->addTemplateDir(TIKI_PATH . "/{$theme_path}/" . 'layouts/' . $prefs['site_layout_admin'] . '/'); } $this->addTemplateDir(TIKI_PATH . "/{$theme_path}/" . 'layouts/'); $main_theme_path = $themelib->get_theme_path($prefs['theme'], '', '', 'templates'); // path to the main theme $this->addTemplateDir(TIKI_PATH . "/{$main_theme_path}/"); //if theme_admin is empty, use main theme and site_layout instead of site_layout_admin if ($section != "admin" || empty($prefs['theme_admin'])) { $this->addTemplateDir(TIKI_PATH . "/{$main_theme_path}/" . 'layouts/' . $prefs['site_layout'] . '/'); } else { $this->addTemplateDir(TIKI_PATH . "/{$main_theme_path}/" . 'layouts/' . $prefs['site_layout_admin'] . '/'); } } // Tikidomain main template folder if (!empty($tikidomainslash)) { $this->addTemplateDir(TIKI_PATH . "/themes/{$tikidomainslash}templates/"); // This dir is for all the themes in the tikidomain $this->addTemplatedir($this->main_template_dir . '/' . $tikidomainslash); // legacy tpls just in case, for example: /templates/mydomain.ltd/ } $this->addTemplateDir(TIKI_PATH . "/themes/templates/"); //This dir stores templates for all the themes //Addon templates foreach (TikiAddons::getPaths() as $path) { $this->addTemplateDir($path . '/templates/'); } } //Layout templates if (!empty($prefs['site_layout']) && ($section != "admin" || empty($prefs['theme_admin']))) { //use the admin layout if in the admin section $this->addTemplateDir($this->main_template_dir . '/layouts/' . $prefs['site_layout'] . '/'); } elseif (!empty($prefs['site_layout_admin'])) { $this->addTemplateDir($this->main_template_dir . '/layouts/' . $prefs['site_layout_admin'] . '/'); } $this->addTemplateDir($this->main_template_dir . '/layouts/'); $this->addTemplateDir($this->main_template_dir); }
function getAddonFilePath($filepath) { foreach (TikiAddons::getPaths() as $path) { if (file_exists($path . "/" . $filepath)) { return $path . "/" . $filepath; } } return false; }