00001 <?php
00024 class SLayout
00025 {
00026 protected $parent;
00027
00028 function __construct ($parent)
00029 { $this->parent = $parent; }
00030
00045 public function layout() {
00046
00047 $mslots = $this->parent->getPageTemplate()->getMetaSlotsList();
00048 $page = $this->parent->getPage();
00049 $result = true;
00050
00051
00052 foreach($mslots as $ms)
00053 {
00054
00055
00056 $result = ($result && ($this->msBuild($page, $ms, $this->parent->getPageTemplate()->getLayoutForMetaSlot($ms)) == ""));
00057
00058
00059 $page->appendMetaSlotToPage($ms);
00060 }
00061 return $result;
00062 }
00063
00084 public function msBuild ($page, $ms, $layout) {
00085 $this->msBuildDefault($page, $ms, $layout);
00086 }
00087
00102 public function msBuildDefault ($page, $ms, $layout) {
00103 switch($ms) {
00104
00105
00106 case 'Head':
00107 return $this->layoutHead($page, $ms, $layout);
00108 case 'TopTags':
00109 return $this->layoutTopTags($page, $ms, $layout);
00110 case 'BottomTags':
00111 return $this->layoutBottomTags($page, $ms, $layout);
00112 case 'StartBodyTags':
00113 return $this->layoutStartBodyTags($page, $ms, $layout);
00114 default:
00115 break;
00116 }
00117 }
00118
00119
00120
00121
00122
00132 function layoutHead($page, $ms, $dl) {
00133 $title = $page->getSlot('WindowTitle');
00134 $js = $page->getSlot('ExtraJS');
00135 $css = $page->getSlot('ExtraCSS');
00136 $keywords = $page->getSlot('Keywords');
00137 $extraHeadTags = $page->getSlot('ExtraHeadTags');
00138 $libHeadTags = $page->getSlot('LibHeadTags');
00139
00140 $defaultCSSLinks = $page->getSlot('DefaultCSSLinks');
00141 $customCSSLinks = $page->getSlot('CustomCSSLinks');
00142 $defaultJSLinks = $page->getSlot('DefaultJSLinks');
00143
00144 $swatUI = SPath::getRelPath('UI') . '/swat';
00145 $defUI = SPath::getRelPath('DefaultSkin');
00146 $localUI = SPath::getRelPath('CustomSkin');
00147 $projCSS = SPath::getRelPath('ProjectCSS');
00148 $projJS = SPath::getRelPath('ProjectJS');
00149
00150 $ssName = "main.css";
00151 $jsName = "main.js";
00152 $ssURL = "/css/$ssName";
00153 $jsURL = "/js/$jsName";
00154
00155 $localSS = $localJS = "";
00156 if($defUI != $localUI){
00157 $localSS =<<<ENDSS
00158
00159 @import "$localUI$ssURL";
00160 ENDSS;
00161
00162 if ($this->parent->getOption('useLocalJS')){
00163 $localJS=<<<ENDJS
00164 <script type="text/javascript" src="$localUI$jsURL"></script>
00165 ENDJS;
00166 }
00167 }
00168
00169 if ($this->parent->getOption('useProjectCSS')){
00170 $localSS .= <<<ENDSS
00171
00172 @import "$projCSS/$ssName";
00173 ENDSS;
00174 }
00175
00176 if ($this->parent->getOption('useProjectJS')){
00177 $localJS .=<<<ENDJS
00178
00179 <script type="text/javascript" src="$projJS/$jsName"></script>
00180 ENDJS;
00181 }
00182
00183
00184 $jsLibs = "";
00185
00186 if ($this->parent->getOption('scriptaculous')){
00187 $this->parent->setOption('prototype', true);
00188 }
00189
00190 if ($this->parent->getOption('swatjs')) {
00191 $this->parent->setOption('prototype', true);
00192 }
00193
00194 if ($this->parent->getOption('prototype')){
00195 $jsLibs .=<<<END
00196 <script type="text/javascript" src="$defUI/js/prototype/prototype.js"></script>
00197
00198 END;
00199 }
00200
00201 if ($this->parent->getOption('scriptaculous')){
00202 $jsLibs .=<<<END
00203 <script type="text/javascript" src="$defUI/js/scriptaculous/scriptaculous.js"></script>
00204
00205 END;
00206 }
00207
00208 if($this->parent->getOption('swatjs')) {
00209 $ajaxPath = $this->parent->getOption('ajaxPath');
00210 if(!$ajaxPath) {
00211 $qpos = strpos($_SERVER['REQUEST_URI'], '?');
00212 if($qpos !== false)
00213 $ajaxPath = substr($_SERVER['REQUEST_URI'], 0, $qpos);
00214 else
00215 $ajaxPath = $_SERVER['REQUEST_URI'];
00216 }
00217 $ssPath = SPath::getRelPath('SDRService');
00218 if($this->parent->getOption('swatHomePaths')) {
00219 $homePaths = '';
00220 foreach($GLOBALS['PATH'] as $key => $val)
00221 $homePaths .= "'$key': '" . addslashes(htmlspecialchars($val)) ."', ";
00222 $homePaths = "\n\thomePaths: { " . rtrim($homePaths, ", ") . " },\n";
00223 }
00224 else
00225 $homePaths = '';
00226 $projPath = SPath::getRelPath('Project');
00227 $minify = $this->parent->getOption('useMinJS') ? 'true' : 'false';
00228 $minifyLibs = $this->parent->getOption('useMinLibJS') ? 'true' : 'false';
00229 $jsLibs .=<<<END_HTML
00230 <script type="text/javascript" src="$swatUI/js/SWAT.js"></script>
00231 <script type="text/javascript">
00232 SWAT.Paths = { $homePaths
00233 project: '$projJS',
00234 projectlib: '$projJS/libs',
00235 ui: '$swatUI/js',
00236 uilib: '$swatUI/js/libs'
00237 };
00238 SWAT.CssPaths = {
00239 project: '$projCSS',
00240 projectlib: '$projCSS/libs',
00241 ui: '$swatUI/css',
00242 uilib: '$swatUI/css/libs'
00243 };
00244 SWAT.AjaxPath = '$ajaxPath';
00245 SWAT.ProjectPath = '$projPath';
00246 SWAT.SearchServicePath = '$ssPath';
00247 SWAT.UseMinJS = $minify;
00248 SWAT.UseMinLibJS = $minifyLibs;
00249 </script>
00250
00251 END_HTML;
00252 }
00253
00254 $html =<<<END_HTML
00255
00256 <head>
00257 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
00258 <title>$title</title>
00259
00260 <style type="text/css" media="screen">
00261 @import "$defUI$ssURL";
00262 </style>
00263 $defaultCSSLinks
00264 <style type="text/css" media="screen">
00265 $localSS
00266 </style>
00267
00268 <meta content="$keywords" />
00269 <style type="text/css">
00270 $css
00271 </style>
00272 <script type="text/javascript" src="$defUI$jsURL"></script>
00273 $jsLibs
00274 $defaultJSLinks
00275 $localJS
00276 $libHeadTags
00277 <script type="text/javascript">
00278 <!--
00279 $js
00280 -->
00281 </script>
00282 $extraHeadTags
00283 </head>
00284 END_HTML;
00285 $page->setMetaSlot('Head', $html);
00286 }
00287
00288
00298 public function layoutTopTags ($page, $ms, $layout) {
00299 $commonDir = SConfig::getDefault('common.commonDir');
00300 $page->setMetaSlot('TopTags', <<<END_TAGS
00301 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00302 <html xmlns="http://www.w3.org/1999/xhtml">
00303 <!-- Generated by PageRender2 ($commonDir) for Shodor -->
00304 END_TAGS
00305 );
00306 }
00307
00318 public function layoutStartBodyTags($page, $ms, $layout) {
00319 $onload = $page->getSlot('OnLoad');
00320 $bodyId = $page->getSlot('BodyId');
00321 if ($bodyId != ""){ $bodyId = "id=\"$bodyId\""; }
00322 if ($onload != ""){ $onload = "javascript:" . $onload; }
00323 $page->setMetaSlot('StartBodyTags', <<<END_TAGS
00324
00325 <body $bodyId class="SPageBody" onload="$onload">
00326 <!-- table that contains the entire page, including visible margins -->
00327 <table border="0" width="100%" cellpadding="0" cellspacing="0" id="PageTable">
00328 END_TAGS
00329 );
00330
00331 }
00332
00343 public function layoutBottomTags ($page, $ms, $layout) {
00344 $width = $this->parent->getOption('minPageWidth');
00345 $analytics = $page->getSlot('Analytics');
00346 $page->setMetaSlot('BottomTags', <<<END_TAGS
00347
00348 <!--************************************
00349 WidthEnforcer
00350 ************************************-->
00351 <tbody id="WidthEnforcer"><tr><td>
00352 <table width="$width" border="0" cellspacing="0" cellpadding="0">
00353 <tr><td> </td></tr>
00354 </table>
00355 </td></tr></tbody>
00356 </table>$analytics
00357 </body>
00358 </html>
00359 END_TAGS
00360 );
00361 }
00362 }
00363
00364 ?>