mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
e107 class & API cahnges: initial work done. Related tasks
- tests - review of marked with DEPRECATED commment areas - (optional) e107_include* funcs to e107_class.php - (optional) move all 'misc' functions to core_functions.php (new file in e_HANDLER) - 'hide' more globals from the API through e107 methods/properties - transfrom core/plugin templates (BC) to the new template variable standards
This commit is contained in:
25
class2.php
25
class2.php
@@ -9,8 +9,8 @@
|
|||||||
* General purpose file
|
* General purpose file
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/class2.php,v $
|
* $Source: /cvs_backup/e107_0.8/class2.php,v $
|
||||||
* $Revision: 1.113 $
|
* $Revision: 1.114 $
|
||||||
* $Date: 2009-07-22 00:49:34 $
|
* $Date: 2009-07-22 14:32:51 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -1823,10 +1823,11 @@ function e107_require($fname)
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//DEPRECATED - use e107::getLan();
|
||||||
function include_lan($path, $force = false)
|
function include_lan($path, $force = false)
|
||||||
{
|
{
|
||||||
global $pref;
|
return e107::getLan($path, $force);
|
||||||
|
/*global $pref;
|
||||||
if (!is_readable($path))
|
if (!is_readable($path))
|
||||||
{
|
{
|
||||||
if (varsettrue($pref['noLanguageSubs']) || (e_LANGUAGE == 'English'))
|
if (varsettrue($pref['noLanguageSubs']) || (e_LANGUAGE == 'English'))
|
||||||
@@ -1836,7 +1837,7 @@ function include_lan($path, $force = false)
|
|||||||
$path = str_replace(e_LANGUAGE, 'English', $path);
|
$path = str_replace(e_LANGUAGE, 'English', $path);
|
||||||
}
|
}
|
||||||
$ret = ($force) ? include($path) : include_once($path);
|
$ret = ($force) ? include($path) : include_once($path);
|
||||||
return (isset($ret)) ? $ret : "";
|
return (isset($ret)) ? $ret : "";*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1865,10 +1866,12 @@ function include_lan_admin($path)
|
|||||||
// Note - if the code knows precisely where the language file is located, use include_lan()
|
// Note - if the code knows precisely where the language file is located, use include_lan()
|
||||||
|
|
||||||
// $pref['noLanguageSubs'] can be set TRUE to prevent searching for the English files if the files for the current site language don't exist.
|
// $pref['noLanguageSubs'] can be set TRUE to prevent searching for the English files if the files for the current site language don't exist.
|
||||||
|
//DEPRECATED - use e107::loadLanFiles();
|
||||||
function loadLanFiles($unitName, $type='runtime')
|
function loadLanFiles($unitName, $type='runtime')
|
||||||
{
|
{
|
||||||
global $pref;
|
return e107::loadLanFiles($unitName, $type);
|
||||||
|
|
||||||
|
/*global $pref;
|
||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
case 'runtime' :
|
case 'runtime' :
|
||||||
@@ -1909,7 +1912,7 @@ function loadLanFiles($unitName, $type='runtime')
|
|||||||
return (isset($ret)) ? $ret : "";
|
return (isset($ret)) ? $ret : "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE; // Nothing found
|
return FALSE; // Nothing found*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2117,11 +2120,13 @@ function e107_ini_set($var, $value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return true if specified plugin installed, false if not
|
// Return true if specified plugin installed, false if not
|
||||||
|
//DEPRECATED - use e107::isInstalled();
|
||||||
function plugInstalled($plugname)
|
function plugInstalled($plugname)
|
||||||
{
|
{
|
||||||
global $pref;
|
return e107::isInstalled($plugname);
|
||||||
|
/*global $pref;
|
||||||
// Could add more checks here later if appropriate
|
// Could add more checks here later if appropriate
|
||||||
return isset($pref['plug_installed'][$plugname]);
|
return isset($pref['plug_installed'][$plugname]);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
* e107 Main
|
* e107 Main
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
||||||
* $Revision: 1.30 $
|
* $Revision: 1.31 $
|
||||||
* $Date: 2009-07-22 00:49:35 $
|
* $Date: 2009-07-22 14:32:50 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -306,6 +306,21 @@ class e107
|
|||||||
return self::getSingleton('eURL', e_HANDLER.'e107Url.php');
|
return self::getSingleton('eURL', e_HANDLER.'e107Url.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve file handler singleton or new fresh object
|
||||||
|
*
|
||||||
|
* @param boolean $singleton
|
||||||
|
* @return e_file
|
||||||
|
*/
|
||||||
|
public static function getFile($singleton = true)
|
||||||
|
{
|
||||||
|
if($singleton)
|
||||||
|
{
|
||||||
|
return self::getSingleton('e_file', e_HANDLER.'file_class.php');
|
||||||
|
}
|
||||||
|
return self::getObject('e_file', null, e_HANDLER.'file_class.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve admin log singleton object
|
* Retrieve admin log singleton object
|
||||||
*
|
*
|
||||||
@@ -326,6 +341,221 @@ class e107
|
|||||||
return self::getSingleton('convert', e_HANDLER.'date_handler.php');
|
return self::getSingleton('convert', e_HANDLER.'date_handler.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get core template. Use this method for templates, which are following the
|
||||||
|
* new template standards:
|
||||||
|
* - template variables naming convetnions
|
||||||
|
* - one array variable per template only
|
||||||
|
* - theme override is made now by current_theme/templates/ folder
|
||||||
|
*
|
||||||
|
* <br><br>Results are cached (depending on $id and $override so it's safe to use
|
||||||
|
* this method e.g. in loop for retrieving a template string. If template (or template key) is not
|
||||||
|
* found, <b>null</b> is returned.<br><br>
|
||||||
|
*
|
||||||
|
* Example usage: <code>e107::getCoreTemplate('user', 'short_start');</code>
|
||||||
|
* Will search for:
|
||||||
|
* - e107_themes/current_frontend_theme/templates/user_template.php (if $override is true)
|
||||||
|
* - e107_themes/templates/user_template.php (if override not found or $override is false)
|
||||||
|
* - $USER_TEMPLATE array which contains all user templates
|
||||||
|
* - $USER_TEMPLATE['short_start'] (if key is null, $USER_TEMPLATE will be returned)
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @param string|null $key
|
||||||
|
* @param boolean $override
|
||||||
|
*
|
||||||
|
* @return string|array
|
||||||
|
*/
|
||||||
|
public static function getCoreTemplate($id, $key = null, $override = true)
|
||||||
|
{
|
||||||
|
global $pref;
|
||||||
|
$reg_path = 'core/e107/templates';
|
||||||
|
$override_path = $override ? e_THEME.$pref['sitetheme'].'/templates/'.$id.'_template.php' : null;
|
||||||
|
$default_path = e_THEME.'/templates/'.$id.'_template.php';
|
||||||
|
|
||||||
|
return e107::_getTemplate($id, $key, $reg_path, $default_path, $override_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get plugin template. Use this method for plugin templates, which are following the
|
||||||
|
* new template standards:
|
||||||
|
* - template variables naming convetnions
|
||||||
|
* - one array variable per template only
|
||||||
|
* - theme override is made now by current_theme/templates/plugin_name/ folder
|
||||||
|
*
|
||||||
|
* <br><br>Results are cached (depending on $id and $override so it's safe to use
|
||||||
|
* this method e.g. in loop for retrieving a template string. If template (or template key) is not
|
||||||
|
* found, <b>null</b> is returned.<br><br>
|
||||||
|
*
|
||||||
|
* Example usage: <code>e107::getTemplate('user', 'short_start');</code>
|
||||||
|
* Will search for:
|
||||||
|
* - e107_themes/current_frontend_theme/templates/user_template.php (if $override is true)
|
||||||
|
* - e107_themes/templates/user_template.php (if override not found or $override is false)
|
||||||
|
* - $USER_TEMPLATE array which contains all user templates
|
||||||
|
* - $USER_TEMPLATE['short_start'] (if key is null, $USER_TEMPLATE will be returned)
|
||||||
|
*
|
||||||
|
* @param string $plug_name
|
||||||
|
* @param string $id
|
||||||
|
* @param string|null $key
|
||||||
|
* @param boolean $override
|
||||||
|
*
|
||||||
|
* @return string|array
|
||||||
|
*/
|
||||||
|
public static function getTemplate($plug_name, $id, $key = null, $override = true)
|
||||||
|
{
|
||||||
|
global $pref;
|
||||||
|
$reg_path = 'plugin/'.$plug_name.'/templates';
|
||||||
|
$override_path = $override ? e_THEME.$pref['sitetheme'].'/templates/'.$plug_name.'/'.$id.'_template.php' : null;
|
||||||
|
$default_path = e_PLUGIN.$plug_name.'/templates/'.$id.'_template.php';
|
||||||
|
|
||||||
|
return e107::_getTemplate($id, $key, $reg_path, $default_path, $override_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* More abstsract template loader, used
|
||||||
|
* internal in {@link getTemplate()} and {@link getCoreTemplate()} methods
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @param string|null $key
|
||||||
|
* @param string $reg_path
|
||||||
|
* @param string $default_path
|
||||||
|
* @param string $override_path
|
||||||
|
* @return string|array
|
||||||
|
*/
|
||||||
|
public static function _getTemplate($id, $key = null, $reg_path, $default_path, $override_path = null)
|
||||||
|
{
|
||||||
|
$regPath = $reg_path.'/'.$id.($override_path ? '/ext' : '');
|
||||||
|
$var = strtoupper($id).'_TEMPLATE';
|
||||||
|
|
||||||
|
if(!e107::getRegistry($regPath))
|
||||||
|
{
|
||||||
|
if($override_path)
|
||||||
|
{
|
||||||
|
$path = $override_path.$id.'_template.php';
|
||||||
|
if(is_readable($path))
|
||||||
|
{
|
||||||
|
include_once($path);
|
||||||
|
if(isset($$var))
|
||||||
|
{
|
||||||
|
e107::setRegistry($regPath, $$var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($$var))
|
||||||
|
{
|
||||||
|
$path = $default_path.$id.'_template.php';
|
||||||
|
e107_include_once($path);
|
||||||
|
if(isset($$var))
|
||||||
|
{
|
||||||
|
e107::setRegistry($regPath, $$var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$key)
|
||||||
|
{
|
||||||
|
e107::getRegistry($regPath);
|
||||||
|
}
|
||||||
|
$ret = e107::getRegistry($regPath);
|
||||||
|
return ($ret && is_array($ret) && isset($ret[$key]) ? $ret[$key] : $ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load language file, replacement of include_lan()
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param boolean $force
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getLan($path, $force = false)
|
||||||
|
{
|
||||||
|
global $pref;
|
||||||
|
if (!is_readable($path))
|
||||||
|
{
|
||||||
|
if (varsettrue($pref['noLanguageSubs']) || (e_LANGUAGE == 'English'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
$path = str_replace(e_LANGUAGE, 'English', $path);
|
||||||
|
}
|
||||||
|
$ret = ($force) ? include($path) : include_once($path);
|
||||||
|
return (isset($ret)) ? $ret : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Routine looks in standard paths for language files associated with a plugin or
|
||||||
|
* theme - primarily for core routines, which won't know for sure where the author has put them.
|
||||||
|
* $unitName is the name (directory path) of the plugin or theme
|
||||||
|
* $type determines what is to be loaded:
|
||||||
|
* - 'runtime' - the standard runtime language file for a plugin
|
||||||
|
* - 'admin' - the standard admin language file for a plugin
|
||||||
|
* - 'theme' - the standard language file for a plugin (these are usually pretty small, so one is enough)
|
||||||
|
* Otherwise, $type is treated as part of a filename within the plugin's language directory,
|
||||||
|
* prefixed with the current language.
|
||||||
|
* Returns FALSE on failure (not found).
|
||||||
|
* Returns the include_once error return if there is one
|
||||||
|
* Otherwise returns an empty string.
|
||||||
|
* Note - if the code knows precisely where the language file is located, use {@link getLan()}
|
||||||
|
* $pref['noLanguageSubs'] can be set TRUE to prevent searching for the English files if
|
||||||
|
* the files for the current site language don't exist.
|
||||||
|
*
|
||||||
|
* @param string $unitName
|
||||||
|
* @param string $type predefined types are runtime|admin|theme
|
||||||
|
* @return boolean|string
|
||||||
|
*/
|
||||||
|
public static function loadLanFiles($unitName, $type='runtime')
|
||||||
|
{
|
||||||
|
global $pref;
|
||||||
|
switch ($type)
|
||||||
|
{
|
||||||
|
case 'runtime' :
|
||||||
|
$searchPath[1] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'_'.$unitName.'.php';
|
||||||
|
$searchPath[2] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'/'.$unitName.'.php';
|
||||||
|
break;
|
||||||
|
case 'admin' :
|
||||||
|
$searchPath[1] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'_admin_'.$unitName.'.php';
|
||||||
|
$searchPath[2] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'/'.'admin_'.$unitName.'.php';
|
||||||
|
break;
|
||||||
|
case 'theme' :
|
||||||
|
$searchPath[1] = e_THEME.$unitName.'/languages/'.e_LANGUAGE.'_'.$unitName.'.php';
|
||||||
|
$searchPath[2] = e_THEME.$unitName.'/languages/'.e_LANGUAGE.'/'.$unitName.'.php';
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
$searchPath[1] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'_'.$type.'.php';
|
||||||
|
$searchPath[2] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'/'.$type.'.php';
|
||||||
|
}
|
||||||
|
foreach ($searchPath as $s) // Look for files in current language first - should usually be found
|
||||||
|
{
|
||||||
|
if (is_readable($s))
|
||||||
|
{
|
||||||
|
$ret = include_once($s);
|
||||||
|
return (isset($ret)) ? $ret : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (varsettrue($pref['noLanguageSubs']) || (e_LANGUAGE == 'English'))
|
||||||
|
{
|
||||||
|
return FALSE; // No point looking for the English files twice
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($searchPath as $s) // Now look for the English files
|
||||||
|
{
|
||||||
|
$s = str_replace(e_LANGUAGE, 'English', $s);
|
||||||
|
if (is_readable($s))
|
||||||
|
{
|
||||||
|
$ret = include_once($s);
|
||||||
|
return (isset($ret)) ? $ret : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE; // Nothing found
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isInstalled($plugname)
|
||||||
|
{
|
||||||
|
global $pref;
|
||||||
|
// Could add more checks here later if appropriate
|
||||||
|
return isset($pref['plug_installed'][$plugname]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return e107
|
* @return e107
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user