/** * add core data to the template * * This function adds some basic data to the template depending on the * current user and the PN settings. * * @param list of module names. all mod vars of these modules will be included too The mod vars of the current module will always be included * @return boolean true if ok, otherwise false * @access public */ function add_core_data() { $pncore = array(); $pncore['version_num'] = _PN_VERSION_NUM; $pncore['version_id'] = _PN_VERSION_ID; $pncore['version_sub'] = _PN_VERSION_SUB; $pncore['logged_in'] = pnUserLoggedIn(); $pncore['language'] = pnUserGetLang(); $pncore['themeinfo'] = pnThemeInfo(pnUserGetTheme()); pnThemeLoad($pncore['themeinfo']['name']); $colors = array(); $colors['bgcolor1'] = pnThemeGetVar('bgcolor1'); $colors['bgcolor2'] = pnThemeGetVar('bgcolor2'); $colors['bgcolor3'] = pnThemeGetVar('bgcolor3'); $colors['bgcolor4'] = pnThemeGetVar('bgcolor4'); $colors['bgcolor5'] = pnThemeGetVar('bgcolor5'); $colors['sepcolor'] = pnThemeGetVar('sepcolor'); $colors['textcolor1'] = pnThemeGetVar('textcolor1'); $colors['textcolor2'] = pnThemeGetVar('textcolor2'); // add userdata $pncore['user'] = pnUserGetVars(pnSessionGetVar('uid')); // add modvars of current module $pncore[$this->module] = pnModGetVar($this->module); // add mod vars of all modules supplied as parameter foreach (func_get_args() as $modulename) { // if the modulename is empty do nothing if (!empty($modulename) && !is_array($modulename) && $modulename != $this->module) { // check if user wants to have /PNConfig if ($modulename == _PN_CONFIG_MODULE) { $pnconfig = pnModGetVar(_PN_CONFIG_MODULE); foreach ($pnconfig as $key => $value) { // unserialize all config vars $pncore['pnconfig'][$key] = @unserialize($value); } } else { $pncore[$modulename] = pnModGetVar($modulename); } } } $this->assign('pncore', $pncore); $this->assign($colors); return true; }
/** * get the user's theme * <br /> * This function will return the current theme for the user. * Order of theme priority: * - page-specific * - category * - user * - system * * @public * @return string the name of the user's theme **/ function pnUserGetTheme() { static $theme; if (isset($theme)) { return $theme; } // Page-specific theme $pagetheme = pnVarCleanFromInput('theme'); if (!empty($pagetheme)) { $themeinfo = pnThemeInfo($pagetheme); if ($themeinfo && $themeinfo['active']) { $theme = $pagetheme; return $pagetheme; } } // set a new theme for the user $pagetheme = pnVarCleanFromInput('newtheme'); if (!empty($pagetheme) && !pnConfigGetVar('theme_change')) { $themeinfo = pnThemeInfo($pagetheme); if ($themeinfo && $themeinfo['active']) { if (pnUserLoggedIn()) { $uid = pnUserGetVar('uid'); $dbconn =& pnDBGetConn(true); $pntable =& pnDBGetTables(); $column =& $pntable['users_column']; $sql = "UPDATE {$pntable['users']}\n SET {$column['theme']}='" . pnVarPrepForStore($pagetheme) . "'\n WHERE {$column['uid']}='" . pnVarPrepForStore($uid) . "'"; $dbconn->Execute($sql); } else { pnSessionSetVar('theme', $pagetheme); } $theme = $pagetheme; return $pagetheme; } } // eugenio themeover 20020413 // override the theme per category or story // precedence is story over category override list($sid, $file) = pnVarCleanFromInput('sid', 'file'); if (pnModGetName() == 'News' && (!empty($sid) || strtolower($file) == 'article')) { $modinfo = pnModGetInfo(pnModGetIDFromName('News')); include_once 'modules/' . $modinfo['directory'] . '/funcs.php'; $pntable =& pnDBGetTables(); $results = getArticles("{$pntable['stories_column']['sid']}='" . (int) pnVarPrepForStore($sid) . "'", "", ""); if (is_array($results) && count($results) > 0) { $info = genArticleInfo($results[0]); $themeinfo = pnThemeInfo($info['catthemeoverride']); if ($themeinfo && $themeinfo['active']) { $theme = $info['catthemeoverride']; return $theme; } $themeinfo = pnThemeInfo($info['themeoverride']); if ($themeinfo && $themeinfo['active']) { $theme = $info['themeoverride']; return $theme; } } } // User theme if (!pnConfigGetVar('theme_change')) { if (pnUserLoggedIn()) { $usertheme = pnUserGetVar('theme'); } else { $usertheme = pnSessionGetVar('theme'); } $themeinfo = pnThemeInfo($usertheme); if ($themeinfo && $themeinfo['active']) { $theme = $usertheme; return $usertheme; } } // default site theme $defaulttheme = pnConfigGetVar('Default_Theme'); $themeinfo = pnThemeInfo($defaulttheme); if ($themeinfo && $themeinfo['active']) { $theme = $defaulttheme; return $theme; } return false; }
/** * pnThemeGetAllThemes() * * list all available themes * * @param boolean $removeXanthia set to true to remove inactive Xanthia themes from the list * @param boolean $hideHiddenThemes set to true to remove hidden (special purpose) themes from the list * @return array of available themes **/ function pnThemeGetAllThemes($removeXanthia = true, $hideHiddenThemes = true) { // all themes in the file system static $_allthemes = array(); // all inactive Xanthia themes static $_inactive = array(); // all hidden themes static $_hidden = array(); $themelist = array(); // get all themes from the file system if (empty($_allthemes)) { // get all theme names from the normal location $handle = opendir('themes'); while ($f = readdir($handle)) { if (pnThemeInfo($f)) { $_allthemes["{$f}"] = $f; } } closedir($handle); // get all theme names from the Multisites location if (strlen(WHERE_IS_PERSO) != 0) { $handle = opendir(WHERE_IS_PERSO . 'themes'); while ($f = readdir($handle)) { if (pnThemeInfo($f)) { $_allthemes["{$f}"] = $f; } } closedir($handle); } } $themelist = $_allthemes; // Remove inactive Xanthia themes from the theme list if ($removeXanthia) { if (empty($_inactive)) { if (pnModAPILoad('Xanthia', 'user')) { // Get a list of all Xanthia themes $allthemes = pnModAPIFunc('Xanthia', 'user', 'getAllThemes'); if ($allthemes) { // Get a list of all active Xanthia themes $allskins = pnModAPIFunc('Xanthia', 'user', 'getAllSkins'); $activethemes = array(); if ($allskins) { foreach ($allskins as $allskin) { $activethemes[] = $allskin['name']; } } // The difference are the inactive Xanthia themes, they need to be removed $_inactive = array_diff($allthemes, $activethemes); } } } $themelist = array_diff($themelist, $_inactive); } // Remove hidden themes from the theme list if ($hideHiddenThemes) { if (empty($_hidden)) { foreach ($_allthemes as $thistheme) { $themeinfo = pnThemeInfo($thistheme); if ($themeinfo['hidden']) { $_hidden[] = $thistheme; } } } $themelist = array_diff($themelist, $_hidden); } // sort array ksort($themelist); // return result set return $themelist; }