예제 #1
0
/**
 * 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;
}
예제 #2
0
/**
 * Loads the required manual for module
 */
function modules_get_manual()
{
    $currentlang = pnSessionGetVar('lang');
    $language = pnConfigGetVar('language');
    if (!isset($GLOBALS['ModName'])) {
        $modname = pnModGetName();
    } else {
        $modname = $GLOBALS['ModName'];
    }
    $modinfo = pnModGetInfo(pnModGetIDFromName($modname));
    if (file_exists('modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($currentlang) . '/manual.html')) {
        $hlpfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($currentlang) . '/manual.html';
    } elseif (!empty($language)) {
        if (file_exists('modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($language) . '/manual.html')) {
            $hlpfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($language) . '/manual.html';
        }
    } else {
        $hlpfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/eng/manual.html';
    }
    return;
}
예제 #3
0
파일: pnMod.php 프로젝트: katopenzz/openemr
/**
 * carry out hook operations for module
 * @param hookobject the object the hook is called for - either 'item' or 'category'
 * @param hookaction the action the hook is called for - one of 'create', 'delete', 'transform', or 'display'
 * @param hookid the id of the object the hook is called for (module-specific)
 * @param extrainfo extra information for the hook, dependent on hookaction
 * @returns string
 * @return output from hooks
 */
function pnModCallHooks($hookobject, $hookaction, $hookid, $extrainfo)
{
    // Get database info
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $hookstable = $pntable['hooks'];
    $hookscolumn =& $pntable['hooks_column'];
    // Get applicable hooks
    $sql = "SELECT {$hookscolumn['tarea']},\n                   {$hookscolumn['tmodule']},\n                   {$hookscolumn['ttype']},\n                   {$hookscolumn['tfunc']}\n            FROM {$hookstable}\n            WHERE {$hookscolumn['smodule']} = '" . pnVarPrepForStore(pnModGetName()) . "'\n            AND {$hookscolumn['object']} = '" . pnVarPrepForStore($hookobject) . "'\n            AND {$hookscolumn['action']} = '" . pnVarPrepForStore($hookaction) . "'";
    $result = $dbconn->Execute($sql);
    if ($dbconn->ErrorNo() != 0) {
        return null;
    }
    $output = '';
    // Call each hook
    for (; !$result->EOF; $result->MoveNext()) {
        list($hookarea, $hookmodule, $hooktype, $hookfunc) = $result->fields;
        if ($hookarea == 'GUI') {
            if (pnModAvailable($hookmodule, $hooktype) && pnModLoad($hookmodule, $hooktype)) {
                $output .= pnModFunc($hookmodule, $hooktype, $hookfunc, array('objectid' => $hookid, 'extrainfo' => $extrainfo));
            }
        } else {
            if (pnModAvailable($hookmodule, $hooktype) && pnModAPILoad($hookmodule, $hooktype)) {
                $extrainfo = pnModAPIFunc($hookmodule, $hooktype, $hookfunc, array('objectid' => $hookid, 'extrainfo' => $extrainfo));
            }
        }
    }
    if ($hookaction == 'display') {
        return $output;
    } else {
        return $extrainfo;
    }
}
예제 #4
0
/**
 * remove censored words
 * @deprecated
 */
function pnVarCensor()
{
    LogUtil::log(__f('Error! The \'pnVarCensor\' function used in \'%s\' is deprecated. Instead, please activate the \'MultiHook\' for this module.', DataUtil::formatForDisplay(pnModGetName())));

    $resarray = array();
    $ourvars = func_get_args();
    foreach ($ourvars as $ourvar) {
        $resarray[] = DataUtil::censor($ourvar);
    }

    // Return vars
    if (func_num_args() == 1) {
        return $resarray[0];
    }

    return $resarray;
}
 /**
  * Checks which path to use for required template
  *
  * @param string $template
  */
 function get_template_path($template)
 {
     // the current module
     $pnmodgetname = pnModGetName();
     // get the module path to templates
     $module = $this->module;
     $modinfo = pnModGetInfo(pnModGetIDFromName($module));
     // get the theme path to templates
     $theme = pnUserGetTheme();
     // prepare the values for OS
     $os_pnmodgetname = pnVarPrepForOS($pnmodgetname);
     $os_module = pnVarPrepForOS($module);
     $os_modpath = pnVarPrepForOS($modinfo['directory']);
     $os_theme = pnVarPrepForOS($theme);
     // Define the locations in which we will look for templates
     // (in this order)
     // Note: Paths 1, 3, 5 - This allows for the hook or block functions
     // (such as ratings and comments) to use different templates depending
     // on the top level module. e.g. the comments dialog can be different
     // for news  and polls...
     // They are only evaluated when the calling module is not the current one.
     //
     // 1. The top level module directory in the requested module folder
     // in the theme directory.
     $themehookpath = "themes/{$theme}/templates/modules/{$module}/{$pnmodgetname}";
     // 2. The module directory in the current theme.
     $themepath = "themes/{$theme}/templates/modules/{$module}";
     // 3. The top level module directory in the requested module folder
     // in the modules sub folder.
     $modhookpath = "modules/{$modinfo['directory']}/pntemplates/{$pnmodgetname}";
     // 4. The module directory in the modules sub folder.
     $modpath = "modules/{$modinfo['directory']}/pntemplates";
     // 5. The top level module directory in the requested module folder
     // in the system sub folder.
     $syshookpath = "system/{$modinfo['directory']}/pntemplates/{$pnmodgetname}";
     // 6. The module directory in the system sub folder.
     $syspath = "system/{$modinfo['directory']}/pntemplates";
     $ostemplate = pnVarPrepForOS($template);
     //.'.htm';
     // check the module for which we're looking for a template is the
     // same as the top level mods. This limits the places to look for
     // templates.
     if ($module == $pnmodgetname) {
         $search_path = array($themepath, $modpath, $syspath);
     } else {
         $search_path = array($themehookpath, $themepath, $modhookpath, $modpath, $syshookpath, $syspath);
     }
     foreach ($search_path as $path) {
         if (file_exists("{$path}/{$ostemplate}") && is_readable("{$path}/{$ostemplate}")) {
             return $path;
         }
     }
     // when we arrive here, no path was found
     return false;
 }
예제 #6
0
/**
 * Get the base directory for a module
 *
 * Example: If the webroot is located at
 * /var/www/html
 * and the module name is Template and is found
 * in the modules directory then this function
 * would return /var/www/html/modules/Template
 *
 * If the Template module was located in the system
 * directory then this function would return
 * /var/www/html/system/Template
 *
 * This allows you to say:
 * include(pnModGetBaseDir() . '/includes/private_functions.php');
 *
 * @author Chris Miller
 * @param   $modname - name of module to that you want the
 *                     base directory of.
 * @return  string - the path from the root directory to the
 *                   specified module.
 */
function pnModGetBaseDir($modname = '')
{
    if (empty($modname)) {
        $modname = pnModGetName();
    }
    $path = pnGetBaseURI();
    $directory = 'modules/' . $modname;
    if ($path != '') {
        $path .= '/';
    }
    $url = $path . $directory;
    return $url;
}