Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites
View Statistics - Next Notice - Previous NoticeDirectory filter : [ all ] / postnuke_official / html / includes [ view in CVS ]
Date | Directory [filter] | File(s) [view] | Author [filter] |
17 Aug 2002 01:16:51 | postnuke_official/html/includes | pnMod.php,1.78,1.79 | Marco Canini |
Added shortcut for pnModTemplate with custom template using $data['_template_'].Rearranged file layout. |
Update of /home/cvsroot/postnuke_official/html/includes In directory ns7.hostnuke.net:/tmp/cvs-serv11928 Modified Files: pnMod.php Log Message: Added shortcut for pnModTemplate with custom template using $data['_template_'].Rearranged file layout. Index: pnMod.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/includes/pnMod.php,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** pnMod.php 16 Aug 2002 15:49:17 -0000 1.78 --- pnMod.php 17 Aug 2002 01:16:49 -0000 1.79 *************** *** 468,471 **** --- 468,559 ---- /** + * load a module + * + @access public + * @param name - name of module to load + * @param type - type of functions to load + * @returns string + * @return name of module loaded + * @raise DATABASE_ERROR, BAD_PARAM, MODULE_NOT_EXIST, MODULE_FILE_NOT_EXIST + */ + function pnModLoad($modname, $type='user') + { + static $loaded = array(); + + pnLogMessage("pnModLoad: loading $modname:$type"); + + if (empty($modname)) { + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', + new SystemException(__FILE__."(".__LINE__."): Empty modname."));return; + } + + if (!empty($loaded["$modname$type"])) { + // Already loaded from somewhere else + return $modname; + } + + list($dbconn) = pnDBGetConn(); + $pntable = pnDBGetTables(); + $modulestable = $pntable['modules']; + + $query = "SELECT pn_directory, + pn_state + FROM $modulestable + WHERE pn_name = '" . pnVarPrepForStore($modname) . "'"; + $result = $dbconn->Execute($query); + + if($dbconn->ErrorNo() != 0) { + $msg = pnMLByKey('DATABASE_ERROR', $query); + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', + new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); + return; + } + + if ($result->EOF) { + $result->Close(); + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_NOT_EXIST', + new SystemException(__FILE__."(".__LINE__."): Module $modname doesn't exist."));return; + } + + list($directory, $state) = $result->fields; + $result->Close(); + + // Load the module files + list($osdirectory, $ostype) = pnVarPrepForOS($directory, $type); + $osfile = "modules/$osdirectory/pn$ostype.php"; + + if (!file_exists($osfile)) { + // File does not exist + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_FILE_NOT_EXIST', + new SystemException(__FILE__."(".__LINE__."): Module file $osfile doesn't exist."));return; + } + + // Load file + include $osfile; + $loaded["$modname$type"] = 1; + + // Load the module translations files + $res = pnML_loadModuleTranslations($modname, $osdirectory, $type); + if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { + return; // throw back exception + } + + // Load datbase info + $res = pnModDBInfoLoad($modname, $directory); + if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { + return; // throw back exception + } + + // Module loaded successfully, notify the proper event + /*pnEvt_notify($modname, $type, 'LoadModule', NULL); + if (pnExceptionMajor() != PN_NO_EXCEPTION) { + return; // throw back exception + }*/ + + // Return the module name + return $modname; + } + + /** * load an API for a module * *************** *** 481,484 **** --- 569,574 ---- static $loaded = array(); + pnLogMessage("pnModAPILoad: loading $modname:$type"); + if (empty($modname)) { pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', *************** *** 531,550 **** $loaded["$modname$type"] = 1; ! // Load the module language files ! $currentlang = pnUserGetLang(); ! $defaultlang = pnConfigGetVar('language'); ! if (empty($defaultlang)) { ! $defaultlang = 'eng'; ! } ! ! list($oscurrentlang, $osdefaultlang) = pnVarPrepForOS($currentlang, $defaultlang); ! if (file_exists("modules/$osdirectory/pnlang/$oscurrentlang/{$ostype}api.php")) { ! include "modules/$osdirectory/pnlang/$oscurrentlang/{$ostype}api.php"; ! } elseif (file_exists("modules/$osdirectory/pnlang/$osdefaultlang/{$ostype}api.php")) { ! include "modules/$osdirectory/pnlang/$osdefaultlang/{$ostype}api.php"; ! } ! ! // Load the module translations files ! $res = pnML_load($modname, $osdirectory, $type.'api'); if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { return; // throw back exception --- 621,626 ---- $loaded["$modname$type"] = 1; ! // Load the API translations files ! $res = pnML_loadModuleTranslations($modname, $osdirectory, $type.'api'); if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { return; // throw back exception *************** *** 626,740 **** /** ! * load a module ! * ! @access public ! * @param name - name of module to load ! * @param type - type of functions to load ! * @returns string ! * @return name of module loaded ! * @raise DATABASE_ERROR, BAD_PARAM, MODULE_NOT_EXIST, MODULE_FILE_NOT_EXIST ! */ ! function pnModLoad($modname, $type='user') ! { ! static $loaded = array(); ! ! if (empty($modname)) { ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__."(".__LINE__."): Empty modname."));return; ! } ! ! if (!empty($loaded["$modname$type"])) { ! // Already loaded from somewhere else ! return $modname; ! } ! ! list($dbconn) = pnDBGetConn(); ! $pntable = pnDBGetTables(); ! $modulestable = $pntable['modules']; ! ! $query = "SELECT pn_directory, ! pn_state ! FROM $modulestable ! WHERE pn_name = '" . pnVarPrepForStore($modname) . "'"; ! $result = $dbconn->Execute($query); ! ! if($dbconn->ErrorNo() != 0) { ! $msg = pnMLByKey('DATABASE_ERROR', $query); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } ! ! if ($result->EOF) { ! $result->Close(); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_NOT_EXIST', ! new SystemException(__FILE__."(".__LINE__."): Module $modname doesn't exist."));return; ! } ! ! list($directory, $state) = $result->fields; ! $result->Close(); ! ! // Load the module and module language files ! list($osdirectory, $ostype) = pnVarPrepForOS($directory, $type); ! $osfile = "modules/$osdirectory/pn$ostype.php"; ! ! if (!file_exists($osfile)) { ! // File does not exist ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_FILE_NOT_EXIST', ! new SystemException(__FILE__."(".__LINE__."): Module file $osfile doesn't exist."));return; ! } ! ! // Load file ! include $osfile; ! $loaded["$modname$type"] = 1; ! ! $currentlang = pnUserGetLang(); ! if (!isset($currentlang) && pnExceptionMajor() != PN_NO_EXCEPTION) { ! return; // throw back ! } ! if (file_exists("modules/$osdirectory/pnlang/$currentlang/$ostype.php")) { ! include "modules/$osdirectory/pnlang/" . pnVarPrepForOS($currentlang) . "/$ostype.php"; ! } else { ! $defaultlang = pnConfigGetVar('language'); ! if (!isset($defaultlang)) { ! if (pnExceptionMajor() != PN_NO_EXCEPTION) { ! return; // throw back ! } ! $defaultlang = 'eng'; ! } ! if (file_exists("modules/$osdirectory/pnlang/$defaultlang/$ostype.php")) { ! include "modules/$osdirectory/pnlang/" . pnVarPrepForOS($defaultlang) . "/$ostype.php"; ! } ! } ! ! // Load the module translations files ! $res = pnML_load($modname, $osdirectory, $type); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { ! return; // throw back exception ! } ! ! // Load datbase info ! $res = pnModDBInfoLoad($modname, $directory); ! if (!isset($res) && pnExceptionMajor() != PN_NO_EXCEPTION) { ! return; // throw back exception ! } ! ! // Return the module name ! return $modname; ! } ! ! /** ! * run a module API function ! * * @access public * @param modname registered name of module * @param type type of function to run * @param func specific function to run ! * @param args arguments to pass to the function * @returns mixed * @return The output of the function, or false on failure * @raise BAD_PARAM, MODULE_FUNCTION_NOT_EXIST */ ! function pnModAPIFunc($modname, $type='user', $func='main', $args=array()) { if (empty($modname)) { --- 702,717 ---- /** ! * run a module function ! * * @access public * @param modname registered name of module * @param type type of function to run * @param func specific function to run ! * @param args argument array * @returns mixed * @return The output of the function, or false on failure * @raise BAD_PARAM, MODULE_FUNCTION_NOT_EXIST */ ! function pnModFunc($modname, $type='user', $func='main', $args=array()) { if (empty($modname)) { *************** *** 751,776 **** // Build function name and call function ! $modapifunc = "{$modname}_{$type}api_{$func}"; ! if (!function_exists($modapifunc)) { pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_FUNCTION_NOT_EXIST', ! new SystemException(__FILE__."(".__LINE__."): Module API function $modapifunc doesn't exist."));return; } ! return $modapifunc($args); } /** ! * run a module function ! * * @access public * @param modname registered name of module * @param type type of function to run * @param func specific function to run ! * @param args argument array * @returns mixed * @return The output of the function, or false on failure * @raise BAD_PARAM, MODULE_FUNCTION_NOT_EXIST */ ! function pnModFunc($modname, $type='user', $func='main', $args=array()) { if (empty($modname)) { --- 728,768 ---- // Build function name and call function ! $modfunc = "{$modname}_{$type}_{$func}"; ! if (!function_exists($modfunc)) { pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_FUNCTION_NOT_EXIST', ! new SystemException(__FILE__."(".__LINE__."): Module function $modfunc doesn't exist."));return; } ! $data = $modfunc($args); ! ! if (!is_array($data)) { ! return $data; ! } ! ! // FIXME: <marco> I'm not convinced of this, it's more reasonable to get the tpl name from data ! $template = NULL; ! if (isset($args['template'])) { ! $template = $args['template']; ! } ! if (isset($data['_template_'])) { ! $template = $data['_template_']; ! } ! ! return pnModTemplate($modname, $type, $func, $data, $template); } /** ! * run a module API function ! * * @access public * @param modname registered name of module * @param type type of function to run * @param func specific function to run ! * @param args arguments to pass to the function * @returns mixed * @return The output of the function, or false on failure * @raise BAD_PARAM, MODULE_FUNCTION_NOT_EXIST */ ! function pnModAPIFunc($modname, $type='user', $func='main', $args=array()) { if (empty($modname)) { *************** *** 787,808 **** // Build function name and call function ! $modfunc = "{$modname}_{$type}_{$func}"; ! if (!function_exists($modfunc)) { pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_FUNCTION_NOT_EXIST', ! new SystemException(__FILE__."(".__LINE__."): Module function $modfunc doesn't exist."));return; ! } ! ! $data = $modfunc($args); ! ! if (!is_array($data)) { ! return $data; } ! $template = NULL; ! if (isset($args['template'])) { ! $template = $args['template']; ! } ! ! return pnModTemplate($modname, $type, $func, $data, $template); } --- 779,789 ---- // Build function name and call function ! $modapifunc = "{$modname}_{$type}api_{$func}"; ! if (!function_exists($modapifunc)) { pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_FUNCTION_NOT_EXIST', ! new SystemException(__FILE__."(".__LINE__."): Module API function $modapifunc doesn't exist."));return; } ! return $modapifunc($args); }
View Statistics - Next Notice - Previous Notice
Visit Developer Site - Browse CVS Repository |
Syndicate via backend.rss (max. once per hour please) | Powered by CVSNotice 0.1.3 |