00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00036
00037 class FF_Output_Page extends FF_Output {
00038
00039
00044 var $o_tpl;
00045
00050 var $pageName;
00051
00052
00053
00054
00061 function FF_Output_Page()
00062 {
00063 parent::FF_Output();
00064
00065 $this->o_tpl =& new FF_Smarty('overall');
00066 $this->setDefaults();
00067
00068 $this->addScriptFile($this->o_registry->getRootFile('prototype.js', 'javascript', FASTFRAME_WEBPATH));
00069 $this->addScriptFile($this->o_registry->getRootFile('core.lib.js', 'javascript', FASTFRAME_WEBPATH));
00070 $this->addScriptFile($this->o_registry->getRootFile('scriptaculous/effects.js', 'javascript', FASTFRAME_WEBPATH));
00071
00072 $this->o_tpl->assign(array('content_left' => array(), 'content_middle' => array(),
00073 'content_right' => array(), 'status_messages' => array(), 'page_explanation' => array()));
00074 }
00075
00076
00077
00078
00085 function display()
00086 {
00087 $this->completeTpl();
00088 $this->o_tpl->display();
00089 }
00090
00091
00092
00093
00102 function completeTpl()
00103 {
00104 $this->_renderMessages();
00105
00106 $this->renderCSS('widgets', $this->o_registry->getRootFile('widgets', 'themes'));
00107 if (FF_Request::getParam('printerFriendly', 'gp', false)) {
00108 $this->renderCSS('widgets', $this->o_registry->getRootFile('widgets', 'themes'), 'print.tpl', 'all');
00109 }
00110 else {
00111
00112 $this->renderCSS($this->theme, $this->themeDir);
00113
00114 $this->renderCSS('widgets', $this->o_registry->getRootFile('widgets', 'themes'), 'print.tpl', 'print');
00115 }
00116
00117 if ($this->pageType != 'popup') {
00118 if ($this->o_registry->getConfigParam('help/show_link')) {
00119 $s_help = $this->link(FastFrame::selfURL(array('actionId' => ACTION_CONTACT)), _('Need Help?'));
00120 }
00121 else {
00122 $s_help = '';
00123 }
00124
00125 if (!FF_Auth::isGuest()) {
00126 $o_perms =& FF_Perms::factory();
00127 if ($o_perms->hasPerm('has_my_profile', 'profile')) {
00128 require_once $this->o_registry->getAppFile('ActionHandler/actions.php', 'profile', 'libs');
00129 $s_user = $this->link(FastFrame::selfURL(
00130 array('actionId' => ACTION_MYPROFILE, 'app' => 'profile', 'module' => 'Profile')),
00131 FF_auth::getCredential('username'));
00132 }
00133 else {
00134 $s_user = '<b>' . FF_Auth::getCredential('username') . '</b>';
00135 }
00136
00137 $s_status = sprintf(_('You are logged in as %s.'), $s_user);
00138 }
00139 else {
00140 $s_status = _('You are not logged in.');
00141 }
00142
00143 $this->o_tpl->assign(array('T_login_status' => $s_status, 'T_help_link' => $s_help));
00144 }
00145
00146 $this->o_tpl->assign(array(
00147 'COPYWRITE' => 'Copywrite © 2002-2006 The CodeJanitor Group',
00148 'CONTENT_ENCODING' => $this->o_registry->getConfigParam('language/charset', 'ISO-8859-1'),
00149 'U_SHORTCUT_ICON' => $this->o_registry->getConfigParam('general/favicon'),
00150 'PAGE_TITLE' => $this->getPageTitle(),
00151 'LANG' => getenv('LANG')));
00152 $this->_renderPageType();
00153 $this->_renderMenus();
00154
00155 $o_actionHandler =& FF_ActionHandler::singleton();
00156 $this->o_tpl->append('javascript', '<script>Event.observe(window, "load", function() { FastFrame.userId="' . FF_Auth::getCredential('userId') . '"; FastFrame.app="' . $o_actionHandler->getAppId() . '"; FastFrame.module="' . $o_actionHandler->getModuleId() . '"; });</script>');
00157 }
00158
00159
00160
00161
00174 function renderCSS($in_theme, $in_themeDir, $in_styleFile = 'style.tpl', $in_media = 'screen')
00175 {
00176 $o_fileCache =& FF_FileCache::singleton();
00177 $s_cssTemplateFile = $in_themeDir . '/' . $in_styleFile;
00178
00179
00180 $s_cssFileName = str_replace('.tpl', '', $in_styleFile) . '.css';
00181 $a_cssCacheFile = array('subdir' => 'css', 'id' => $in_theme, 'name' => $s_cssFileName);
00182
00183
00184 if (!$o_fileCache->exists($a_cssCacheFile) ||
00185 filemtime($s_cssTemplateFile) > filemtime($o_fileCache->getPath($a_cssCacheFile))) {
00186 $o_cssWidget =& new FF_Smarty($s_cssTemplateFile);
00187
00188 $o_cssWidget->force_compile = true;
00189
00190 $o_cssWidget->left_delimiter = '{{';
00191 $o_cssWidget->right_delimiter = '}}';
00192 $o_cssWidget->assign(array(
00193 'THEME_DIR' => $this->o_registry->rootPathToWebPath($in_themeDir),
00194 'ROOT_GRAPHICS_DIR' => $this->o_registry->getRootFile('', 'graphics', FASTFRAME_WEBPATH)));
00195 $o_result =& $o_fileCache->save($o_cssWidget->fetch(), $a_cssCacheFile);
00196 if (!$o_result->isSuccess()) {
00197 foreach ($o_result->getMessages() as $s_message) {
00198 trigger_error($s_message, E_USER_ERROR);
00199 }
00200 }
00201
00202 $o_fileCache->makeViewableFromWeb($a_cssCacheFile);
00203 }
00204
00205 $s_cssURL = $o_fileCache->getPath($a_cssCacheFile, false, FASTFRAME_WEBPATH);
00206
00207 $this->o_tpl->append('headers', '<link rel="stylesheet" type="text/css" media="' . $in_media . '" href="' . $s_cssURL . '" />');
00208 }
00209
00210
00211
00212
00222 function addScriptFile($in_file)
00223 {
00224 static $a_files;
00225 if (!isset($a_files)) {
00226 $a_files = array();
00227 }
00228
00229 if (!isset($a_files[$in_file])) {
00230 $a_files[$in_file] = 1;
00231 $this->o_tpl->append('javascript',
00232 '<script type="text/javascript" src="' . $in_file . '"></script>');
00233 }
00234 }
00235
00236
00237
00238
00245 function getPageTitle()
00246 {
00247 $s_title = $this->o_registry->getAppParam('name', 'NOOP');
00248 $s_page = $this->pageName;
00249
00250 if ($s_title != $s_page) {
00251 $s_title = "$s_title » $s_page";
00252 }
00253
00254 return $s_title;
00255 }
00256
00257
00258
00259
00268 function setPageName($in_name)
00269 {
00270 $this->pageName = $in_name;
00271 }
00272
00273
00274
00275
00284 function toggleRow($in_count)
00285 {
00286 return $in_count % 2 ? 'secondaryRow' : 'primaryRow';
00287 }
00288
00289
00290
00291
00298 function _renderMessages()
00299 {
00300 foreach ($this->messages as $s_key => $a_message) {
00301 $this->o_tpl->append('status_messages', array(
00302 'T_status_message' => $a_message[0],
00303 'I_status_message' => $this->imgTag($a_message[1], 'mini', array('title' => $a_message[2]))));
00304 }
00305 }
00306
00307
00308
00309
00317 function _renderPageType()
00318 {
00319 switch ($this->pageType) {
00320 case 'popup':
00321
00322 $this->menuType = 'none';
00323 $this->o_tpl->append('css', 'div#leftCol { display: none; } div#middleCol { margin: 0; padding: 0; } td.messageWrap { padding-left: 0; }');
00324 break;
00325 case 'normal':
00326 if ($s_header = $this->_getHeaderText()) {
00327 $this->o_tpl->assign('header', $s_header);
00328 }
00329
00330 if ($s_footer = $this->_getFooterText()) {
00331 $this->o_tpl->assign('footer', $s_footer);
00332 }
00333 break;
00334 default:
00335 break;
00336 }
00337 }
00338
00339
00340
00341
00348 function _renderMenus()
00349 {
00350 if ($this->menuType != 'none') {
00351 require_once dirname(__FILE__) . '/../Menu.php';
00352
00353 $o_menu =& FF_Menu::factory($this->menuType);
00354 $o_menu->renderMenu();
00355
00356 $o_menu =& FF_Menu::factory('QuickLinks');
00357 $o_menu->renderMenu();
00358 }
00359 }
00360
00361
00362
00363
00370 function _getHeaderText()
00371 {
00372 $s_header = $this->o_registry->getConfigParam('display/header_text');
00373 if (FastFrame::isEmpty($s_header)) {
00374 $s_header = false;
00375 }
00376 else {
00377 $s_header = str_replace('%title%', $this->getPageTitle(), $s_header);
00378 }
00379
00380 return $s_header;
00381 }
00382
00383
00384
00385
00392 function _getFooterText()
00393 {
00394 $s_footer = $this->o_registry->getConfigParam('display/footer_text');
00395 if (FastFrame::isEmpty($s_footer)) {
00396 $s_footer = false;
00397 }
00398 else {
00399 $s_footer = str_replace('%version%', $this->o_registry->getConfigParam('version/primary',
00400 null, FASTFRAME_DEFAULT_APP), $s_footer);
00401 $a_microtime = explode(' ', microtime());
00402 define('FASTFRAME_END_TIME', $a_microtime[1] . substr($a_microtime[0], 1));
00403 $s_footer = str_replace('%renderTime%', number_format(FASTFRAME_END_TIME - FASTFRAME_START_TIME, 2), $s_footer);
00404 }
00405
00406 return $s_footer;
00407 }
00408
00409
00410
00411
00420 function _isAbsolute($in_path)
00421 {
00422 if ((DIRECTORY_SEPARATOR == '/' && (substr($in_path, 0, 1) == '/' || substr($in_path, 0, 1) == '~')) ||
00423 (DIRECTORY_SEPARATOR == '\\' && preg_match('/^[a-z]:\\\/i', $in_path))) {
00424 return true;
00425 }
00426 else {
00427 return false;
00428 }
00429 }
00430
00431
00432 }
00433 ?>