本文整理汇总了PHP中factory::loadCfg方法的典型用法代码示例。如果您正苦于以下问题:PHP factory::loadCfg方法的具体用法?PHP factory::loadCfg怎么用?PHP factory::loadCfg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factory
的用法示例。
在下文中一共展示了factory::loadCfg方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* Get the unique cache instance
*
* @param array $cfg Config for the cache instance
* @return cache_abstract The instance
*/
public static function getInstance(array $cfg = array())
{
if (!self::$cfg) {
self::$cfg = new config(factory::loadCfg(__CLASS__));
}
return factory::get('cache_' . self::$cfg->use, $cfg);
}
示例2: init
/**
* Initialize nyro
*/
private static function init() {
if (!self::$cfg) {
factory::init();
if (DEV) {
debug::timer('nyro');
debug::timer('nyroProcess');
}
request::init();
self::$cfg = new config(factory::loadCfg(__CLASS__));
file::init();
session::initFlash();
}
}
示例3: init
/**
* Init the config object
*/
protected static function init()
{
if (self::$cfg == null) {
self::$cfg = new config(factory::loadCfg(__CLASS__));
}
}
示例4: initCfg
/**
* Init the session configuration
*/
private static function initCfg() {
if (!self::$cfg)
self::$cfg = new config(factory::loadCfg(__CLASS__));
}
示例5: overload
/**
* Overload a config from an other class.
* The class could not exists
*
* @param string $className
* @param bool $parent Indicate if the search should load the parent config (if virtual, should be false!)
*/
public function overload($className, $parent = false)
{
factory::mergeCfg($this->vars, factory::loadCfg($className, $parent));
}
示例6: init
/**
* Initialize the request object
* Call by the init function from nyro class
*/
public static function init() {
if (!empty(self::$requestArray))
return;
self::$cfg = new config(factory::loadCfg(__CLASS__));
$alias = array();
$outs = '(\.('.implode('|', array_keys(self::$cfg->outCfg)).'))';
foreach(self::$cfg->alias as $k=>$v) {
if ($k == '/') {
$alias['(/.{2})?/?'] = '\1'.$v;
$alias['(/.{2})?'.$outs] = '\1'.$v.'\2';
} else {
$k = '(/.{2})?'.$k;
$tmp = explode('\\', $v);
$t = '\\1'.$tmp[0];
unset($tmp[0]);
$i = 2;
foreach($tmp as $tt) {
$t.='\\'.(intval(substr($tt, 0, 1))+1).substr($tt, 1);
$i++;
}
if (!preg_match($outs, $k))
$alias[$k.'(.*)'] = $t.'\\'.$i;
$alias[$k] = $t;
}
}
$alias = array_reverse($alias, true);
self::$cfg->alias = $alias;
// Put the default lang at the top of available langs
$avlLangsTmp = self::$cfg->avlLang;
$avlLangs = array();
foreach($avlLangsTmp as $k=>$v) {
if ($k == self::$cfg->lang) {
$avlLangs[$k] = $v;
unset($avlLangsTmp[$k]);
}
}
self::$cfg->avlLang = array_merge($avlLangs, $avlLangsTmp);
$secure = (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on');
$protocol = $secure? 'https' : 'http';
$controller = basename($_SERVER['SCRIPT_FILENAME']);
$serverName = array_key_exists('HTTP_HOST', $_SERVER) ? $_SERVER['HTTP_HOST'] : (array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : self::$cfg->defaultServerName);
$stdPort = $secure ? '443' : '80';
$port = (array_key_exists('SERVER_PORT', $_SERVER) && $_SERVER['SERVER_PORT'] != $stdPort && $_SERVER['SERVER_PORT'])? ':'.$_SERVER['SERVER_PORT'] : '';
$domain = $protocol.'://'.$serverName.$port;
$scriptName = $_SERVER['SCRIPT_NAME'];
$requestUri = urldecode(array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : ('/'.$scriptName.(array_key_exists(1, $_SERVER['argv']) ? $_SERVER['argv'][1] : '')));
$redir = null;
$forceServerName = null;
if (self::$cfg->forceServerName
&& strpos($serverName, 'localhost') === false
&& strtolower(self::$cfg->forceServerName) != strtolower($serverName)) {
$forceServerName = self::$cfg->forceServerName;
$redir = $protocol.'://'.$forceServerName.$port.$requestUri;
}
if (self::$cfg->forceNoOut
&& self::$cfg->noOut
&& ($pos = strpos($requestUri, self::$cfg->noOut))
&& $pos + strlen(self::$cfg->noOut) == strlen($requestUri)
) {
if ($redir)
$redir = substr($redir, 0, -1*(strlen(self::$cfg->noOut)+1));
else
$redir = $domain.substr($requestUri, 0, $pos-1);
}
if (self::$cfg->noController && strpos($requestUri, self::$cfg->noController) !== false) {
if (!$redir)
$redir = $domain.$requestUri;
$redir = str_replace(self::$cfg->noController.'/', '', $redir);
if ($pos = strpos($redir, self::$cfg->noController))
$redir = substr($redir, 0, $pos);
}
$path = '/';
$requestUriTmp = explode('/', substr($requestUri, 1));
$scriptNameTmp = explode('/', substr($scriptName, 1));
$min = min(count($requestUriTmp), count($scriptNameTmp));
$i = 0;
while ($i < $min && $requestUriTmp[$i] == $scriptNameTmp[$i]) {
$path.= $requestUriTmp[$i].'/';
$i++;
}
$pathWithController = (strpos($requestUri, $controller) !== false);
if ($pathWithController) {
if (strpos($path, $controller) !== false)
$path = substr($path, 0, -strlen($controller)-1);
//.........这里部分代码省略.........
示例7: init
/**
* Initialize the security instance parametred
*/
private static function init() {
self::$cfg = new config(factory::loadCfg(__CLASS__));
self::$instance = factory::get('security_'.self::$cfg->use);
}
示例8: init
/**
* Initialize the factory configuration
*/
public static function init()
{
self::$constants = get_defined_constants(true);
self::initCache();
self::$cfg = new config(factory::loadCfg(__CLASS__));
}
示例9: getIcon
/**
* Get an icon
*
* @param array $prm Icon configuration. Available key:
* - string name: action name (required)
* - string type: icon type
* - bool imgTag: true if the return should be a valid html img tag. if false, will return he url
* - string alt: alt text for the image, used only if imgTag = true
* - array attr: attributes added to the img tag
* @return unknown
*/
public static function getIcon(array $prm) {
$ret = null;
static $cfg;
if (!$cfg)
$cfg = factory::loadCfg('icons', false);
if (config::initTab($prm, array(
'name'=>null,
'type'=>$cfg['default'],
'imgTag'=>true,
'alt'=>'',
'attr'=>array(),
))) {
if (array_key_exists($prm['type'], $cfg['icons'])
&& is_array($cfg['icons'][$prm['type']])
&& in_array($prm['name'], $cfg['icons'][$prm['type']])) {
$ret = request::get('path').$cfg['dir'].'/'.$prm['type'].request::getCfg('sepParam').$prm['name'].$cfg['ext'];
} else if ($prm['type'] != $cfg['default']) {
$ret = self::getIcon(array('name'=>$prm['name'], 'imgTag'=>false));
}
if ($ret && $prm['imgTag']) {
$alt = $prm['alt']? $prm['alt'] : ucFirst($prm['name']);
$ret = self::htmlTag('img', array_merge(array(
'src'=>$ret,
'alt'=>$alt
), $prm['attr']));
}
}
return $ret;
}