~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to doc/doxygen/html/config_8inc_8php_source.html

  • Committer: Chad Heuschober
  • Date: 2011-05-04 18:50:43 UTC
  • mfrom: (1.1.971 trunk)
  • Revision ID: chad.heuschober@mail.cuny.edu-20110504185043-k91xu7u2hbzxlblx
Merged in most recent changes from cuny-sps-trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
</div>
62
62
<div class="contents">
63
63
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?php
64
 
<a name="l00002"></a>00002 require_once (dirname(__FILE__) . <span class="stringliteral">&#39;/../../../../../lib/vendor/symfony/lib/yaml/sfYaml.php&#39;</span>);
65
 
<a name="l00003"></a>00003 require_once (sfConfig::get(<span class="stringliteral">&#39;sf_config_dir&#39;</span>) . <span class="stringliteral">&#39;/ProjectConfiguration.class.php&#39;</span>);
66
 
<a name="l00004"></a>00004 require_once (sfConfig::get(<span class="stringliteral">&#39;sf_web_dir&#39;</span>) . <span class="stringliteral">&#39;/requirements.inc.php&#39;</span>);
67
 
<a name="l00005"></a>00005 require_once (sfConfig::get(<span class="stringliteral">&#39;sf_web_dir&#39;</span>) . <span class="stringliteral">&#39;/func.inc.php&#39;</span>);
68
 
<a name="l00006"></a>00006 $configuration = ProjectConfiguration::getApplicationConfiguration(<span class="stringliteral">&#39;frontend&#39;</span>, <span class="stringliteral">&#39;all&#39;</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 &#39;I am constructed&#39;;</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">&#39;sf_config_dir&#39;</span>) . <span class="stringliteral">&#39;/databases.yml&#39;</span>) == TRUE) {
89
 
<a name="l00027"></a>00027       $dbArray = sfYaml::load(sfConfig::get(<span class="stringliteral">&#39;sf_config_dir&#39;</span>) . <span class="stringliteral">&#39;/databases.yml&#39;</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">&#39;sf_config_dir&#39;</span>) .  <span class="stringliteral">&#39;/config.yml&#39;</span>) == TRUE) {
94
 
<a name="l00032"></a>00032       $cfgArray = sfYaml::load(sfConfig::get(<span class="stringliteral">&#39;sf_config_dir&#39;</span>) .  <span class="stringliteral">&#39;/config.yml&#39;</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">&quot;bypass&quot;</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">&#39;all&#39;</span>][<span class="stringliteral">&#39;doctrine&#39;</span>][<span class="stringliteral">&#39;param&#39;</span>][<span class="stringliteral">&#39;dsn&#39;</span>]);
101
 
<a name="l00039"></a>00039       self::setConfig(<span class="stringliteral">&#39;db_config&#39;</span>, $dbArray);
102
 
<a name="l00040"></a>00040       self::setConfig(<span class="stringliteral">&#39;DB_SERVER&#39;</span>, $db_params[<span class="stringliteral">&#39;host&#39;</span>]);
103
 
<a name="l00041"></a>00041       self::setConfig(<span class="stringliteral">&#39;DB_DATABASE&#39;</span>, $db_params[<span class="stringliteral">&#39;dbname&#39;</span>]);
104
 
<a name="l00042"></a>00042       self::setConfig(<span class="stringliteral">&#39;DB_USER&#39;</span>, $dbArray[<span class="stringliteral">&#39;all&#39;</span>][<span class="stringliteral">&#39;doctrine&#39;</span>][<span class="stringliteral">&#39;param&#39;</span>][<span class="stringliteral">&#39;username&#39;</span>]);
105
 
<a name="l00043"></a>00043       self::setConfig(<span class="stringliteral">&#39;DB_PASSWORD&#39;</span>, $dbArray[<span class="stringliteral">&#39;all&#39;</span>][<span class="stringliteral">&#39;doctrine&#39;</span>][<span class="stringliteral">&#39;param&#39;</span>][<span class="stringliteral">&#39;password&#39;</span>]);
106
 
<a name="l00044"></a>00044       self::setConfig(<span class="stringliteral">&#39;ADMIN_NAME&#39;</span>, $cfgArray[<span class="stringliteral">&#39;admin&#39;</span>][<span class="stringliteral">&#39;admin_name&#39;</span>]);
107
 
<a name="l00045"></a>00045       self::setConfig(<span class="stringliteral">&#39;ADMIN_EMAIL&#39;</span>, $cfgArray[<span class="stringliteral">&#39;admin&#39;</span>][<span class="stringliteral">&#39;admin_email&#39;</span>]);
108
 
<a name="l00046"></a>00046       self::setConfig(<span class="stringliteral">&#39;AUTH_METHOD&#39;</span>, $cfgArray[<span class="stringliteral">&#39;admin&#39;</span>][<span class="stringliteral">&#39;auth_method&#39;</span>][<span class="stringliteral">&#39;value&#39;</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">&#39;file was unreadable&#39;</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">&#39;/../../../../../lib/vendor/symfony/lib/yaml/sfYaml.php&#39;</span>);
 
66
<a name="l00017"></a>00017 require_once (sfConfig::get(<span class="stringliteral">&#39;sf_config_dir&#39;</span>) . <span class="stringliteral">&#39;/ProjectConfiguration.class.php&#39;</span>);
 
67
<a name="l00018"></a>00018 require_once (sfConfig::get(<span class="stringliteral">&#39;sf_web_dir&#39;</span>) . <span class="stringliteral">&#39;/requirements.inc.php&#39;</span>);
 
68
<a name="l00019"></a>00019 require_once (sfConfig::get(<span class="stringliteral">&#39;sf_web_dir&#39;</span>) . <span class="stringliteral">&#39;/func.inc.php&#39;</span>);
 
69
<a name="l00020"></a>00020 $configuration = ProjectConfiguration::getApplicationConfiguration(<span class="stringliteral">&#39;frontend&#39;</span>, <span class="stringliteral">&#39;all&#39;</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 &#39;I am constructed&#39;;</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">&#39;sf_config_dir&#39;</span>) . <span class="stringliteral">&#39;/databases.yml&#39;</span>) == TRUE) {
 
90
<a name="l00041"></a>00041       $dbArray = sfYaml::load(sfConfig::get(<span class="stringliteral">&#39;sf_config_dir&#39;</span>) . <span class="stringliteral">&#39;/databases.yml&#39;</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">&#39;sf_config_dir&#39;</span>) .  <span class="stringliteral">&#39;/config.yml&#39;</span>) == TRUE) {
 
95
<a name="l00046"></a>00046       $cfgArray = sfYaml::load(sfConfig::get(<span class="stringliteral">&#39;sf_config_dir&#39;</span>) .  <span class="stringliteral">&#39;/config.yml&#39;</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">&quot;bypass&quot;</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">&#39;all&#39;</span>][<span class="stringliteral">&#39;doctrine&#39;</span>][<span class="stringliteral">&#39;param&#39;</span>][<span class="stringliteral">&#39;dsn&#39;</span>]);
 
102
<a name="l00053"></a>00053       self::setConfig(<span class="stringliteral">&#39;db_config&#39;</span>, $dbArray);
 
103
<a name="l00054"></a>00054       self::setConfig(<span class="stringliteral">&#39;DB_SERVER&#39;</span>, $db_params[<span class="stringliteral">&#39;host&#39;</span>]);
 
104
<a name="l00055"></a>00055       self::setConfig(<span class="stringliteral">&#39;DB_DATABASE&#39;</span>, $db_params[<span class="stringliteral">&#39;dbname&#39;</span>]);
 
105
<a name="l00056"></a>00056       self::setConfig(<span class="stringliteral">&#39;DB_USER&#39;</span>, $dbArray[<span class="stringliteral">&#39;all&#39;</span>][<span class="stringliteral">&#39;doctrine&#39;</span>][<span class="stringliteral">&#39;param&#39;</span>][<span class="stringliteral">&#39;username&#39;</span>]);
 
106
<a name="l00057"></a>00057       self::setConfig(<span class="stringliteral">&#39;DB_PASSWORD&#39;</span>, $dbArray[<span class="stringliteral">&#39;all&#39;</span>][<span class="stringliteral">&#39;doctrine&#39;</span>][<span class="stringliteral">&#39;param&#39;</span>][<span class="stringliteral">&#39;password&#39;</span>]);
 
107
<a name="l00058"></a>00058       self::setConfig(<span class="stringliteral">&#39;ADMIN_NAME&#39;</span>, $cfgArray[<span class="stringliteral">&#39;admin&#39;</span>][<span class="stringliteral">&#39;admin_name&#39;</span>]);
 
108
<a name="l00059"></a>00059       self::setConfig(<span class="stringliteral">&#39;ADMIN_EMAIL&#39;</span>, $cfgArray[<span class="stringliteral">&#39;admin&#39;</span>][<span class="stringliteral">&#39;admin_email&#39;</span>]);
 
109
<a name="l00060"></a>00060       self::setConfig(<span class="stringliteral">&#39;AUTH_METHOD&#39;</span>, $cfgArray[<span class="stringliteral">&#39;admin&#39;</span>][<span class="stringliteral">&#39;auth_method&#39;</span>][<span class="stringliteral">&#39;value&#39;</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">&#39;file was unreadable&#39;</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>
128
129
</div>
129
130
<!--- window showing the filter options -->