62
62
<div class="contents">
63
63
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <?php
64
<a name="l00002"></a>00002 require_once (dirname(__FILE__) . <span class="stringliteral">'/../../../../../lib/vendor/symfony/lib/yaml/sfYaml.php'</span>);
65
<a name="l00003"></a>00003 require_once (sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/ProjectConfiguration.class.php'</span>);
66
<a name="l00004"></a>00004 require_once (sfConfig::get(<span class="stringliteral">'sf_web_dir'</span>) . <span class="stringliteral">'/requirements.inc.php'</span>);
67
<a name="l00005"></a>00005 require_once (sfConfig::get(<span class="stringliteral">'sf_web_dir'</span>) . <span class="stringliteral">'/func.inc.php'</span>);
68
<a name="l00006"></a>00006 $configuration = ProjectConfiguration::getApplicationConfiguration(<span class="stringliteral">'frontend'</span>, <span class="stringliteral">'all'</span>, <span class="keyword">false</span>);
69
<a name="l00007"></a>00007
70
<a name="l00008"></a><a class="code" href="classagConfig.html">00008</a> <span class="keyword">class </span><a class="code" href="classagConfig.html">agConfig</a>
71
<a name="l00009"></a>00009 {
72
<a name="l00010"></a>00010 <span class="keyword">private</span> <span class="keyword">static</span> $instance;
73
<a name="l00011"></a>00011 <span class="keyword">public</span> <span class="keyword">static</span> $AG_CONFIG;
74
<a name="l00012"></a>00012 <span class="comment">// A private constructor; prevents direct creation of object</span>
75
<a name="l00013"></a>00013 <span class="keyword">private</span> function __construct()
76
<a name="l00014"></a>00014 {
77
<a name="l00015"></a>00015 <span class="comment">//echo 'I am constructed';</span>
78
<a name="l00016"></a>00016 }
79
<a name="l00017"></a>00017 <span class="keyword">public</span> <span class="keyword">static</span> function singleton() {
80
<a name="l00018"></a>00018 <span class="keywordflow">if</span>(!isset(self::$instance)) {
81
<a name="l00019"></a>00019 $c = __CLASS__;
82
<a name="l00020"></a>00020 self::$instance = <span class="keyword">new</span> $c();
83
<a name="l00021"></a>00021 }
84
<a name="l00022"></a>00022 <span class="keywordflow">return</span> self::$instance;
85
<a name="l00023"></a>00023 }
86
<a name="l00024"></a>00024 <span class="keyword">public</span> <span class="keyword">static</span> function getCurrent()
87
<a name="l00025"></a>00025 {
88
<a name="l00026"></a>00026 <span class="keywordflow">if</span> (file_exists(sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/databases.yml'</span>) == TRUE) {
89
<a name="l00027"></a>00027 $dbArray = sfYaml::load(sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/databases.yml'</span>);
90
<a name="l00028"></a>00028 } <span class="keywordflow">else</span> {
91
<a name="l00029"></a>00029 $install_flag = <span class="keyword">false</span>;
92
<a name="l00030"></a>00030 }
93
<a name="l00031"></a>00031 <span class="keywordflow">if</span> (file_exists(sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/config.yml'</span>) == TRUE) {
94
<a name="l00032"></a>00032 $cfgArray = sfYaml::load(sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/config.yml'</span>);
95
<a name="l00033"></a>00033 } <span class="keywordflow">else</span> {
96
<a name="l00034"></a>00034 $install_flag = <span class="keyword">true</span>;
97
<a name="l00035"></a>00035 $existing_auth_method = <span class="stringliteral">"bypass"</span>;
98
<a name="l00036"></a>00036 }
99
<a name="l00037"></a>00037 <span class="keywordflow">try</span> {
100
<a name="l00038"></a>00038 $db_params = parseDSN($dbArray[<span class="stringliteral">'all'</span>][<span class="stringliteral">'doctrine'</span>][<span class="stringliteral">'param'</span>][<span class="stringliteral">'dsn'</span>]);
101
<a name="l00039"></a>00039 self::setConfig(<span class="stringliteral">'db_config'</span>, $dbArray);
102
<a name="l00040"></a>00040 self::setConfig(<span class="stringliteral">'DB_SERVER'</span>, $db_params[<span class="stringliteral">'host'</span>]);
103
<a name="l00041"></a>00041 self::setConfig(<span class="stringliteral">'DB_DATABASE'</span>, $db_params[<span class="stringliteral">'dbname'</span>]);
104
<a name="l00042"></a>00042 self::setConfig(<span class="stringliteral">'DB_USER'</span>, $dbArray[<span class="stringliteral">'all'</span>][<span class="stringliteral">'doctrine'</span>][<span class="stringliteral">'param'</span>][<span class="stringliteral">'username'</span>]);
105
<a name="l00043"></a>00043 self::setConfig(<span class="stringliteral">'DB_PASSWORD'</span>, $dbArray[<span class="stringliteral">'all'</span>][<span class="stringliteral">'doctrine'</span>][<span class="stringliteral">'param'</span>][<span class="stringliteral">'password'</span>]);
106
<a name="l00044"></a>00044 self::setConfig(<span class="stringliteral">'ADMIN_NAME'</span>, $cfgArray[<span class="stringliteral">'admin'</span>][<span class="stringliteral">'admin_name'</span>]);
107
<a name="l00045"></a>00045 self::setConfig(<span class="stringliteral">'ADMIN_EMAIL'</span>, $cfgArray[<span class="stringliteral">'admin'</span>][<span class="stringliteral">'admin_email'</span>]);
108
<a name="l00046"></a>00046 self::setConfig(<span class="stringliteral">'AUTH_METHOD'</span>, $cfgArray[<span class="stringliteral">'admin'</span>][<span class="stringliteral">'auth_method'</span>][<span class="stringliteral">'value'</span>]);
109
<a name="l00047"></a>00047 } <span class="keywordflow">catch</span> (Exception $e) {
110
<a name="l00048"></a>00048 <span class="keywordflow">return</span> <span class="stringliteral">'file was unreadable'</span>;
111
<a name="l00049"></a>00049 }
112
<a name="l00050"></a>00050 <span class="keywordflow">return</span> array($dbArray, $cfgArray);
113
<a name="l00051"></a>00051 }
114
<a name="l00052"></a>00052
115
<a name="l00053"></a>00053 <span class="keyword">public</span> <span class="keyword">static</span> function getConfig($name, $default = null)
116
<a name="l00054"></a>00054 {
117
<a name="l00055"></a>00055 <span class="keywordflow">return</span> isset(self::$AG_CONFIG[$name]) ? self::$AG_CONFIG[$name] : $default;
118
<a name="l00056"></a>00056 }
119
<a name="l00057"></a>00057
120
<a name="l00058"></a>00058 <span class="keyword">public</span> <span class="keyword">static</span> function setConfig($name, $value)
121
<a name="l00059"></a>00059 {
122
<a name="l00060"></a>00060 <span class="keywordflow">return</span> (self::$AG_CONFIG[$name] = $value);
123
<a name="l00061"></a>00061 }
124
<a name="l00062"></a>00062
125
<a name="l00063"></a>00063
126
<a name="l00064"></a>00064 }
64
<a name="l00002"></a>00002
65
<a name="l00016"></a>00016 require_once (dirname(__FILE__) . <span class="stringliteral">'/../../../../../lib/vendor/symfony/lib/yaml/sfYaml.php'</span>);
66
<a name="l00017"></a>00017 require_once (sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/ProjectConfiguration.class.php'</span>);
67
<a name="l00018"></a>00018 require_once (sfConfig::get(<span class="stringliteral">'sf_web_dir'</span>) . <span class="stringliteral">'/requirements.inc.php'</span>);
68
<a name="l00019"></a>00019 require_once (sfConfig::get(<span class="stringliteral">'sf_web_dir'</span>) . <span class="stringliteral">'/func.inc.php'</span>);
69
<a name="l00020"></a>00020 $configuration = ProjectConfiguration::getApplicationConfiguration(<span class="stringliteral">'frontend'</span>, <span class="stringliteral">'all'</span>, <span class="keyword">false</span>);
70
<a name="l00021"></a>00021
71
<a name="l00022"></a><a class="code" href="classagConfig.html">00022</a> <span class="keyword">class </span><a class="code" href="classagConfig.html">agConfig</a>
72
<a name="l00023"></a>00023 {
73
<a name="l00024"></a>00024 <span class="keyword">private</span> <span class="keyword">static</span> $instance;
74
<a name="l00025"></a>00025 <span class="keyword">public</span> <span class="keyword">static</span> $AG_CONFIG;
75
<a name="l00026"></a>00026 <span class="comment">// A private constructor; prevents direct creation of object</span>
76
<a name="l00027"></a>00027 <span class="keyword">private</span> function __construct()
77
<a name="l00028"></a>00028 {
78
<a name="l00029"></a>00029 <span class="comment">//echo 'I am constructed';</span>
79
<a name="l00030"></a>00030 }
80
<a name="l00031"></a>00031 <span class="keyword">public</span> <span class="keyword">static</span> function singleton() {
81
<a name="l00032"></a>00032 <span class="keywordflow">if</span>(!isset(self::$instance)) {
82
<a name="l00033"></a>00033 $c = __CLASS__;
83
<a name="l00034"></a>00034 self::$instance = <span class="keyword">new</span> $c();
84
<a name="l00035"></a>00035 }
85
<a name="l00036"></a>00036 <span class="keywordflow">return</span> self::$instance;
86
<a name="l00037"></a>00037 }
87
<a name="l00038"></a>00038 <span class="keyword">public</span> <span class="keyword">static</span> function getCurrent()
88
<a name="l00039"></a>00039 {
89
<a name="l00040"></a>00040 <span class="keywordflow">if</span> (file_exists(sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/databases.yml'</span>) == TRUE) {
90
<a name="l00041"></a>00041 $dbArray = sfYaml::load(sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/databases.yml'</span>);
91
<a name="l00042"></a>00042 } <span class="keywordflow">else</span> {
92
<a name="l00043"></a>00043 $install_flag = <span class="keyword">false</span>;
93
<a name="l00044"></a>00044 }
94
<a name="l00045"></a>00045 <span class="keywordflow">if</span> (file_exists(sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/config.yml'</span>) == TRUE) {
95
<a name="l00046"></a>00046 $cfgArray = sfYaml::load(sfConfig::get(<span class="stringliteral">'sf_config_dir'</span>) . <span class="stringliteral">'/config.yml'</span>);
96
<a name="l00047"></a>00047 } <span class="keywordflow">else</span> {
97
<a name="l00048"></a>00048 $install_flag = <span class="keyword">true</span>;
98
<a name="l00049"></a>00049 $existing_auth_method = <span class="stringliteral">"bypass"</span>;
99
<a name="l00050"></a>00050 }
100
<a name="l00051"></a>00051 <span class="keywordflow">try</span> {
101
<a name="l00052"></a>00052 $db_params = parseDSN($dbArray[<span class="stringliteral">'all'</span>][<span class="stringliteral">'doctrine'</span>][<span class="stringliteral">'param'</span>][<span class="stringliteral">'dsn'</span>]);
102
<a name="l00053"></a>00053 self::setConfig(<span class="stringliteral">'db_config'</span>, $dbArray);
103
<a name="l00054"></a>00054 self::setConfig(<span class="stringliteral">'DB_SERVER'</span>, $db_params[<span class="stringliteral">'host'</span>]);
104
<a name="l00055"></a>00055 self::setConfig(<span class="stringliteral">'DB_DATABASE'</span>, $db_params[<span class="stringliteral">'dbname'</span>]);
105
<a name="l00056"></a>00056 self::setConfig(<span class="stringliteral">'DB_USER'</span>, $dbArray[<span class="stringliteral">'all'</span>][<span class="stringliteral">'doctrine'</span>][<span class="stringliteral">'param'</span>][<span class="stringliteral">'username'</span>]);
106
<a name="l00057"></a>00057 self::setConfig(<span class="stringliteral">'DB_PASSWORD'</span>, $dbArray[<span class="stringliteral">'all'</span>][<span class="stringliteral">'doctrine'</span>][<span class="stringliteral">'param'</span>][<span class="stringliteral">'password'</span>]);
107
<a name="l00058"></a>00058 self::setConfig(<span class="stringliteral">'ADMIN_NAME'</span>, $cfgArray[<span class="stringliteral">'admin'</span>][<span class="stringliteral">'admin_name'</span>]);
108
<a name="l00059"></a>00059 self::setConfig(<span class="stringliteral">'ADMIN_EMAIL'</span>, $cfgArray[<span class="stringliteral">'admin'</span>][<span class="stringliteral">'admin_email'</span>]);
109
<a name="l00060"></a>00060 self::setConfig(<span class="stringliteral">'AUTH_METHOD'</span>, $cfgArray[<span class="stringliteral">'admin'</span>][<span class="stringliteral">'auth_method'</span>][<span class="stringliteral">'value'</span>]);
110
<a name="l00061"></a>00061 } <span class="keywordflow">catch</span> (Exception $e) {
111
<a name="l00062"></a>00062 <span class="keywordflow">return</span> <span class="stringliteral">'file was unreadable'</span>;
112
<a name="l00063"></a>00063 }
113
<a name="l00064"></a>00064 <span class="keywordflow">return</span> array($dbArray, $cfgArray);
114
<a name="l00065"></a>00065 }
115
<a name="l00066"></a>00066
116
<a name="l00067"></a>00067 <span class="keyword">public</span> <span class="keyword">static</span> function getConfig($name, $default = null)
117
<a name="l00068"></a>00068 {
118
<a name="l00069"></a>00069 <span class="keywordflow">return</span> isset(self::$AG_CONFIG[$name]) ? self::$AG_CONFIG[$name] : $default;
119
<a name="l00070"></a>00070 }
120
<a name="l00071"></a>00071
121
<a name="l00072"></a>00072 <span class="keyword">public</span> <span class="keyword">static</span> function setConfig($name, $value)
122
<a name="l00073"></a>00073 {
123
<a name="l00074"></a>00074 <span class="keywordflow">return</span> (self::$AG_CONFIG[$name] = $value);
124
<a name="l00075"></a>00075 }
125
<a name="l00076"></a>00076
126
<a name="l00077"></a>00077
127
<a name="l00078"></a>00078 }
127
128
</pre></div></div>
129
130
<!--- window showing the filter options -->