profection the base classes

This commit is contained in:
Jianxuan Li 2015-01-09 23:33:25 +08:00
parent 40b58bda04
commit 1864044f8e
3 changed files with 35 additions and 29 deletions

View File

@ -1,9 +1,8 @@
<?php
namespace Westdc\Helpers;
use \Zend\Authentication\AuthenticationService;
use \Zend\Authentication\Storage\Session as SessionStorage;
use \Westdc\Helpers\Config;
use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Storage\Session as SessionStorage;
class Auth
{

View File

@ -3,26 +3,43 @@ namespace Westdc\Helpers;
class Config
{
private $config_path = array(
'local' => "config/autoload/local.php",
'global' => "config/autoload/global.php"
);
function __construct()
{
//$reader = new \Zend\Config\Reader\Ini();
//$data = $reader->fromFile('config/config.ini');
}
static function get($type = 'global')
static function get($configName = 'global')
{
$config_path = array(
'local' => "config/autoload/local.php",
'global' => "config/autoload/global.php",
'file' => "config/autoload/file.php"
if(defined(CONFIG_PATH))
{
throw new \RuntimeException('Not found the config files path');
}
$config_path = CONFIG_PATH;
if(empty($configName))
$configName = "global.php";
if(!preg_match("/(\\/|\\\)$/",$config_path))
{
$config_path .= "/";
}
$config_names = array(
'local' => "local.php",
'global' => "global.php",
'file' => "file.php"
);
$configFile = $config_path .'autoload/' . $config_names[$configName];
unset($config_path);
unset($configName);
$config = new \Zend\Config\Config(include $config_path[$type]);
$config = new \Zend\Config\Config(include $configFile);
return $config;
}

View File

@ -3,17 +3,15 @@ namespace Westdc\Helpers;
use \Zend\Authentication\AuthenticationService;
use \Zend\Authentication\Storage\Session as SessionStorage;
use \Westdc\Helpers\Config;
use Westdc\Helpers\MobileDetect;
use View as view;
class Layout
{
public $config;
function __construct()
{
$this->config = Config::get();
}
//设置网页标题
@ -26,8 +24,8 @@ class Layout
return;
}
$action = $matches->getParam('action');
$controller = $matches->getParam('controller');
// $action = $matches->getParam('action');
// $controller = $matches->getParam('controller');
$viewHelperManager = $e->getApplication()->getServiceManager()->get('viewHelperManager');
@ -36,15 +34,7 @@ class Layout
// Setting a separator string for segments
$headTitleHelper->setSeparator(' - ');
if(isset($this->config->title_map->$controller->action->$action))
{
$headTitleHelper->append($this->config->title_map->$controller->action->$action->title);
}
if(isset($this->config->title_map->$controller))
{
$headTitleHelper->append($this->config->title_map->$controller->title);
}
return;
}
//导航条按钮激活