00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00022 class SLayout2
00023 {
00024 protected $parent;
00025
00026 function __construct ($parent)
00027 { $this->parent = $parent; }
00028
00036 public function layout()
00037 {
00038
00039 $mslots = $this->parent->getPageTemplate()->getMetaSlotsList();
00040 $page = $this->parent->getPage();
00041 $result = true;
00042
00043
00044 foreach($mslots as $ms)
00045 {
00046
00047
00048 $result = ($result && ($this->msBuild($page, $ms, $this->parent->getPageTemplate()->getLayoutForMetaSlot($ms)) == ""));
00049
00050
00051 $page->appendMetaSlotToPage($ms);
00052 }
00053
00054 return $result;
00055 }
00056
00067 public function msBuild ($page, $ms, $layout)
00068 {
00069
00070 $this->msBuildDefault($page, $ms, $layout);
00071 }
00072
00083 public function msBuildDefault ($page, $ms, $layout)
00084 {
00085 switch($ms)
00086 {
00087
00088
00089 case 'Head':
00090 return $this->layoutHead($page, $ms, $layout);
00091 case 'TopTags':
00092 return $this->layoutTopTags($page, $ms, $layout);
00093 case 'BottomTags':
00094 return $this->layoutBottomTags($page, $ms, $layout);
00095 case 'StartBodyTags':
00096 return $this->layoutStartBodyTags($page, $ms, $layout);
00097 default:
00098 break;
00099 }
00100 }
00101
00102
00103
00104
00105
00106
00107
00108 function layoutHead($page, $ms, $dl)
00109 {
00110
00111 $title = $page->getSlot('WindowTitle');
00112 $js = $page->getSlot('ExtraJS');
00113 $css = $page->getSlot('ExtraCSS');
00114 $keywords = $page->getSlot('Keywords');
00115 $extraHeadTags = $page->getSlot('ExtraHeadTags');
00116 $libHeadTags = $page->getSlot('LibHeadTags');
00117
00118 $defaultCSSLinks = $page->getSlot('DefaultCSSLinks');
00119 $customCSSLinks = $page->getSlot('CustomCSSLinks');
00120 $defaultJSLinks = $page->getSlot('DefaultJSLinks');
00121
00122 $swatUI = SPath::getFullPath('UI') . '/swat';
00123 $defUI = SPath::getFullPath('DefaultSkin');
00124 $localUI = SPath::getFullPath('CustomSkin');
00125 $projCSS = SPath::getFullPath('ProjectCSS');
00126 $projJS = SPath::getFullPath('ProjectJS');
00127
00128 $ssName = "main.css";
00129 $jsName = "main.js";
00130 $ssURL = "/css/$ssName";
00131 $jsURL = "/js/$jsName";
00132
00133 $localSS = $localJS = "";
00134 if($defUI != $localUI){
00135 $localSS =<<<ENDSS
00136
00137 @import "$localUI$ssURL";
00138 ENDSS;
00139
00140 if ($this->parent->getOption('useLocalJS')){
00141 $localJS=<<<ENDJS
00142 <script type="text/javascript" src="$localUI$jsURL"></script>
00143 ENDJS;
00144 }
00145 }
00146
00147 if ($this->parent->getOption('useProjectCSS')){
00148 $localSS .= <<<ENDSS
00149
00150 @import "$projCSS/$ssName";
00151 ENDSS;
00152 }
00153
00154 if ($this->parent->getOption('useProjectJS')){
00155 $localJS .=<<<ENDJS
00156
00157 <script type="text/javascript" src="$projJS/$jsName"></script>
00158 ENDJS;
00159 }
00160
00161
00162 $jsLibs = "";
00163
00164 if ($this->parent->getOption('scriptaculous')){
00165 $this->parent->setOption('prototype', true);
00166 }
00167
00168 if ($this->parent->getOption('swatjs')) {
00169 $this->parent->setOption('prototype', true);
00170 }
00171
00172 if ($this->parent->getOption('prototype')){
00173 $jsLibs .=<<<END
00174 <script type="text/javascript" src="$defUI/js/prototype/prototype.js"></script>
00175
00176 END;
00177 }
00178
00179 if ($this->parent->getOption('scriptaculous')){
00180 $jsLibs .=<<<END
00181 <script type="text/javascript" src="$defUI/js/scriptaculous/scriptaculous.js"></script>
00182
00183 END;
00184 }
00185
00186 if($this->parent->getOption('swatjs')) {
00187 $ajaxPath = $this->parent->getOption('ajaxPath');
00188 if(!$ajaxPath) {
00189 $qpos = strpos($_SERVER['REQUEST_URI'], '?');
00190 if($qpos !== false)
00191 $ajaxPath = substr($_SERVER['REQUEST_URI'], 0, $qpos);
00192 else
00193 $ajaxPath = $_SERVER['REQUEST_URI'];
00194 }
00195 $ssPath = SPath::getRelPath('SDRService');
00196 if($this->parent->getOption('swatHomePaths')) {
00197 $homePaths = '';
00198 foreach($GLOBALS['PATH'] as $key => $val)
00199 $homePaths .= "'$key': '" . addslashes(htmlspecialchars($val)) ."', ";
00200 $homePaths = "\n\thomePaths: { " . rtrim($homePaths, ", ") . " },\n";
00201 }
00202 else
00203 $homePaths = '';
00204 $projPath = SPath::getRelPath('Project');
00205 $minify = $this->parent->getOption('useMinJS') ? 'true' : 'false';
00206 $minifyLibs = $this->parent->getOption('useMinLibJS') ? 'true' : 'false';
00207 $jsLibs .=<<<END_HTML
00208 <script type="text/javascript" src="$swatUI/js/SWAT.js"></script>
00209 <script type="text/javascript">
00210 SWAT.Paths = { $homePaths
00211 project: '$projJS',
00212 projectlib: '$projJS/libs',
00213 ui: '$swatUI/js',
00214 uilib: '$swatUI/js/libs'
00215 };
00216 SWAT.CssPaths = {
00217 project: '$projCSS',
00218 projectlib: '$projCSS/libs',
00219 ui: '$swatUI/css',
00220 uilib: '$swatUI/css/libs'
00221 };
00222 SWAT.AjaxPath = '$ajaxPath';
00223 SWAT.ProjectPath = '$projPath';
00224 SWAT.SearchServicePath = '$ssPath';
00225 SWAT.UseMinJS = $minify;
00226 SWAT.UseMinLibJS = $minifyLibs;
00227 </script>
00228 END_HTML;
00229
00230 }
00231
00232 $html =<<<END_HTML
00233
00234 <head>
00235 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
00236 <title>$title</title>
00237
00238 <style type="text/css" media="screen">
00239 @import "$defUI$ssURL";
00240 </style>
00241 $defaultCSSLinks
00242 <style type="text/css" media="screen">
00243 $localSS
00244 </style>
00245
00246 <meta content="$keywords" />
00247 <style type="text/css">
00248 $css
00249 </style>
00250 <script type="text/javascript" src="$defUI$jsURL"></script>
00251 $jsLibs
00252 $defaultJSLinks
00253 $localJS
00254 $libHeadTags
00255 <script type="text/javascript">
00256 <!--
00257 $js
00258
00259 -->
00260 </script>
00261 $extraHeadTags
00262 </head>
00263 END_HTML;
00264 $page->setMetaSlot('Head', $html);
00265 }
00266
00267
00278 public function layoutTopTags ($page, $ms, $layout)
00279 {
00280 $commonDir = SConfig::getDefault('common.commonDir');
00281 $page->setMetaSlot('TopTags', <<<END_TAGS
00282 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00283 <html xmlns="http://www.w3.org/1999/xhtml">
00284 <!-- Generated by PageRender2$commonDir, Copyright Shodor -->
00285 END_TAGS
00286 );
00287 }
00288
00299 public function layoutStartBodyTags($page, $ms, $layout)
00300 {
00301 $barHTML = <<<END_CONTENT
00302 <div class="PR2-MetaSlot-UniversalBar">
00303 <div class="PR2-UniversalBarLinks">
00304 <a class="PR2-UniversalBarLink" style="left: 245px;width: 75px;" href='/'></a>
00305 <a class="PR2-UniversalBarLink" style="left: 325px;width: 75px;" href='/about/'></a>
00306 <a class="PR2-UniversalBarLink" style="left: 400px;width: 75px;" href='/students/'></a>
00307 <a class="PR2-UniversalBarLink" style="left: 480px;width: 75px;" href='/parents/'></a>
00308 <a class="PR2-UniversalBarLink" style="left: 558px;width: 75px;" href='/educators/'></a>
00309 <a class="PR2-UniversalBarLink" style="left: 635px;width: 133px;" href='/activities/'></a>
00310 </div>
00311 </div>
00312 END_CONTENT;
00313 $onload = $page->getSlot('OnLoad');
00314 $bodyId = $page->getSlot('BodyId');
00315 if ($bodyId != ""){ $bodyId = "id=\"$bodyId\""; }
00316 if ($onload != ""){ $onload = "javascript:" . $onload; }
00317 $showUniversalBar = SConfig::getOption('pr2.showUniversalBar');
00318 $universalBar = ($showUniversalBar) ? $barHTML : '';
00319
00320 $page->setMetaSlot('StartBodyTags', <<<END_TAGS
00321
00322 <body $bodyId class="PR2-Body" onload="$onload">
00323 $universalBar
00324 <div id="LeftHalf"></div>
00325 <div id="RightHalf"></div>
00326 <div class="PR2-PageMargins">
00327 <div class="PR2-Page">
00328
00329 END_TAGS
00330 );
00331
00332 }
00333
00344 public function layoutBottomTags ($page, $ms, $layout)
00345 {
00346 $width = $this->parent->getOption('minPageWidth');
00347 $analytics = $page->getSlot('Analytics');
00348 $page->setMetaSlot('BottomTags', <<<END_TAGS
00349
00350 </div>
00351 </div>
00352 $analytics
00353 </body>
00354 </html>
00355 END_TAGS
00356 );
00357 }
00358 }
00359
00360 ?>