| // +---------------------------------------------------------------------------+ // $Id$ /** * High level HTML transform methods, 'Template Helpers' in Yahoo speak, 50% html, * 50% php. * * @package SGL * @author Demian Turner * @version $Revision: 1.22 $ * @todo look at PEAR::Date to improve various date methods used here */ class SGL_Output { var $onLoad = ''; var $aOnLoadEvents = array(); var $onUnload = ''; var $aOnUnloadEvents = array(); var $onReadyDom = ''; var $aOnReadyDomEvents = array(); var $aJavascriptFiles = array(); var $aRawJavascriptFiles = array(); var $aCssFiles = array(); var $aHeaders = array(); /** * Translates source text into target language. * * @access public * @static * @param string $key translation term * @param string $filter optional filter fn, ie, strtoupper() * @return string translated text * @see setLanguage() */ function translate($key, $filter = false, $aParams = array(), $output = null) { // in case translation params are specified as a string // e.g. {translate(#my string to translate#,#vprintf#,#param1|value1||param2||value2#)} if (!empty($aParams) && is_string($aParams)) { $aResultParams = array(); $aStringParams = explode('||', $aParams); foreach ($aStringParams as $stringPair) { $aStringValues = explode('|', $stringPair); if (isset($aStringValues[1])) { if ($var = SGL_Output::_extractVariableValue($aStringValues[1], $output)) { $aResultParams[$aStringValues[0]] = $var; } else { if (isset($output) && is_a($output, 'SGL_Output')) { $aResultParams[$aStringValues[0]] = isset($output->{$aStringValues[1]}) ? $output->{$aStringValues[1]} : null; } elseif (is_a($this, 'SGL_Output')) { $aResultParams[$aStringValues[0]] = isset($this->{$aStringValues[1]}) ? $this->{$aStringValues[1]} : null; } } } else { if ($var = SGL_Output::_extractVariableValue($aStringValues[0], $output)) { $aStringValues[] = $var; } else { if (isset($output) && is_a($output, 'SGL_Output')) { $aResultParams[] = isset($output->{$aStringValues[0]}) ? $output->{$aStringValues[0]} : null; } elseif (is_a($this, 'SGL_Output')) { $aResultParams[] = isset($this->{$aStringValues[0]}) ? $this->{$aStringValues[0]} : null; } } } } $aParams = $aResultParams; } return SGL_String::translate($key, $filter, $aParams); } function _extractVariableValue($varString, $output = null) { $ret = false; if (strpos($varString, '.') !== false) { $aVar = explode('.', $varString); if (isset($output) && is_a($output, 'SGL_Output')) { $var = &$output->{$aVar[0]}; } else { $var = &$this->{$aVar[0]}; } if (isset($var) && is_object($var) && isset($var->{$aVar[1]})) { $ret = $var->{$aVar[1]}; } } return $ret; } function tr($key, $filter = false, $aParams = array(), $output = null) { return SGL_Output::translate($key, $filter, $aParams, $output); } /** * Generates options for an HTML select object. * * @access public * @param array $array hash of select values * @param mixed $selected default selected element, array for multiple elements * @param boolean $multiple true if multiple * @param array $options attibutes to add to the input tag : array() {"class" => "myClass", "onclick" => "myClickEventHandler()"} * @return string select options */ function generateSelect($aValues, $selected = null, $multiple = false, $options = null) { SGL::logMessage(null, PEAR_LOG_DEBUG); if (!is_array($aValues) || (isset($options) && !is_array($options))) { SGL::raiseError('Incorrect param passed to ' . __CLASS__ . '::' . __FUNCTION__, SGL_ERROR_INVALIDARGS); } if (is_numeric($selected)) { $selected = (int) $selected; } $optionsString = ''; if (isset($options)) { foreach ($options as $k => $v) { $optionsString .= ' ' . $k . '="' . $v . '"'; } } $r = ''; if ($multiple && is_array($selected)) { foreach ($aValues as $k => $v) { $isSelected = in_array($k, $selected) ? ' selected="selected"' : ''; $r .= "\n"; } } else { // ensure $selected is not the default null arg, allowing // zeros to be selected array elements $r = ''; foreach ($aValues as $k => $v) { $isSelected = ($k === $selected && !is_null($selected)) ? ' selected="selected"' : ''; $r .= "\n"; } } return $r; } /** * Generates sequence checkboxes. * * @access public * @param array $hElements hash of checkbox values * @param array $aChecked array of checked elements * @param string $groupName name of element group * @param array $options attibutes to add to the input tag : array() {"class" => "myClass", "onclick" => "myClickEventHandler()"} * @return string html list of checkboxes */ function generateCheckboxList($hElements, $aChecked, $groupName, $options = null) { SGL::logMessage(null, PEAR_LOG_DEBUG); if (!is_array($hElements) || !is_array($aChecked) || (isset($options) && !is_array($options))) { SGL::raiseError('Incorrect param passed to ' . __CLASS__ . '::' . __FUNCTION__, SGL_ERROR_INVALIDARGS); return false; } $optionsString = ''; if (isset($options)) { foreach ($options as $k => $v) { $optionsString .= ' ' . $k . '="' . $v . '"'; } } $html = ''; foreach ($hElements as $k => $v) { $isChecked = (in_array($k, $aChecked)) ? ' checked' : ''; $html .= "
\n"; } return $html; } /** * Generate checkbox. * * @access public * @param string $name element name * @param string $value element value * @param boolean $checked is checked * @param array $options attibutes to add to the input tag : array() {"class" => "myClass", "onclick" => "myClickEventHandler()"} * @return string html checkbox tag w/label */ function generateCheckbox($name, $value, $checked, $options = null) { SGL::logMessage(null, PEAR_LOG_DEBUG); if (isset($options) && !is_array($options)) { SGL::raiseError('Incorrect param passed to ' . __CLASS__ . '::' . __FUNCTION__, SGL_ERROR_INVALIDARGS); return false; } $isChecked = $checked ? ' checked' : ''; $optionsString = ''; if (isset($options)) { foreach ($options as $k => $v) { $optionsString .= ' ' . $k . '="' . $v . '"'; } } $html = "
\n"; return $html; } /** * Generates a yes/no radio pair. * * @access public * @param string $radioName name of radio element * @param boolean $checked is checked * @param array $options attibutes to add to the input tag : array() {"class" => "myClass", "onclick" => "myClickEventHandler()"} * @return string html yes/no radio pair */ function generateRadioPair($radioName, $checked, $options = null) { SGL::logMessage(null, PEAR_LOG_DEBUG); if (isset($options) && !is_array($options)) { SGL::raiseError('Incorrect param passed to ' . __CLASS__ . '::' . __FUNCTION__, SGL_ERROR_INVALIDARGS); return false; } $radioString = ''; if ($checked) { $yesChecked = ' checked="checked"'; $noChecked = ''; } else { $yesChecked = ''; $noChecked = ' checked="checked"'; } $optionsString = ''; if (isset($options)) { foreach ($options as $k => $v) { $optionsString .= ' ' . $k . '="' . $v . '"'; } } $radioString .= "".SGL_String::translate('no')."\n"; $radioString .= "".SGL_String::translate('yes')."\n"; return $radioString; } /** * Generates sequence of radio button from array. * * @access public * @param array $elements array of values or radio button * @param string $selected selected key (there can be only one selected element in a radio list) * @param string $groupname usually an array name that will contain all elements * @param integer $newline how many columns to display for this radio group (one if not informed) * @param array $options attibutes to add to the input tag : array() {"class" => "myClass", "onclick" => "myClickEventHandler()"} * @param boolean $inTable true for adding table formatting * @return string $html a list of radio buttons */ function generateRadioList($elements, $selected, $groupname, $newline = false, $inTable = true, $options = null) { SGL::logMessage(null, PEAR_LOG_DEBUG); if (!is_array($elements) || (isset($options) && !is_array($options))) { SGL::raiseError('Incorrect param passed to ' . __CLASS__ . '::' . __FUNCTION__, SGL_ERROR_INVALIDARGS); return false; } $elementcount = count($elements); $html = ''; $i = 0; $optionsString = ''; if (isset($options)) { foreach ($options as $k => $v) { $optionsString .= ' ' . $k . '="' . $v . '"'; } } if ($inTable == false){ foreach ($elements as $k => $v) { $i = $i + 1; $html .= " $v) { $i = $i + 1; $html .= " '.SGL_Output::translate('No expire'); } /** * Generates alternate classes for rows in tables, used to switch * row colors. * * @access public * @param boolean $isBold * @param string $pColor optional primary color, override default * @param string $sColor optional secondary color, override default * @return string $curRowClass string representing class found in stylesheet */ function switchRowClass($isBold = false, $pColor = 'backDark', $sColor = 'backLight', $id = 'default') { // remember the last color we used static $curRowClass; static $_id; if ($_id != $id) { $curRowClass = ''; $_id = $id; } if (strpos($curRowClass, $sColor) === false) { $curRowClass = $sColor; } else { $curRowClass = $pColor; } if ($isBold) { $curRowClass .= ' bold'; } return $curRowClass; } /** * Generates alternate value (false/true) to be used in template * * @access public * @param int $elementsToCount Number of elements to reach to switch from false/true, default 2 * @return bool $switcher */ function switchTrueFalse($elementsToCount=2) { static $count; if (empty($elementsToCount)) { // reset counter $count = 0; return; } if ($count % $elementsToCount) { $switcher = false; } else { $switcher = true; } $count++; return $switcher; } /** * Wrapper for SGL_String::summarise(), * Returns a shortened version of text string. * * @access public * @param string $str Text to be shortened * @param integer $limit Number of characters to cut to * @param string $appendString Trailing string to be appended * @return string $processedString Correctly shortened text */ function summarise($str, $limit=50, $element=SGL_WORD, $appendString=' ...') { $ret = SGL_String::summarise($str, $limit, $element, $appendString); return $ret; } /** * Prints formatted error message to standard out. * (For default_admin theme) * * @return mixed */ function msgGetAdmin() { SGL::logMessage(null, PEAR_LOG_DEBUG); $message = SGL_Session::get('message'); $messageType = SGL_Session::get('messageType'); if (isset($message) && $message != '') { SGL_Session::remove('message'); SGL_Session::remove('messageType'); switch ($messageType) { case SGL_MESSAGE_INFO: $class = 'info'; break; case SGL_MESSAGE_WARNING: $class = 'warning'; break; default: $class = 'error'; } echo '
' . $message . '
'; // required to remove message that persists when register_globals = on unset($GLOBALS['message']); unset($GLOBALS['messageType']); } if (SGL_Error::count()) { // get all errors from stack while ($msg = SGL_Error::pop()) { $msg = SGL_Error::toString($msg); echo '
Error
' . $msg . '
'; } } else { return false; } } /** * Returns true if current user or passed role ID is that of an admin. * * @return boolean */ function isAdmin($rid = null) { if (is_null($rid)) { $rid = SGL_Session::getRoleId(); } return ($rid && $rid == SGL_ADMIN) ? true : false; } /** * Returns true if $rid is 1 or -1. * * @return boolean */ function isAdminOrUnassigned($rid) { return (abs($rid) == SGL_ADMIN) ? true : false; } function isAuthenticated() { $rid = SGL_Session::getRoleId(); return ($rid == SGL_GUEST) ? false : true; } function addOnLoadEvent($event, $bOnReady = false) { if ($bOnReady) { $this->aOnReadyDomEvents[] = $event; } else { $this->aOnLoadEvents[] = $event; } } function addOnUnloadEvent($event) { $this->aOnUnloadEvents[] = $event; } function getOnLoadEvents() { $c = & SGL_Config::singleton(); $conf = $c->getAll(); if (!empty($conf['site']['globalJavascriptOnload'])) { $this->aOnLoadEvents[] = $conf['site']['globalJavascriptOnload']; } if (count($this->aOnLoadEvents)) { return $this->aOnLoadEvents; } } function getOnUnloadEvents() { $c = & SGL_Config::singleton(); $conf = $c->getAll(); if (!empty($conf['site']['globalJavascriptOnUnload'])) { $this->aOnUnloadEvents[] = $conf['site']['globalJavascriptOnUnload']; } if (count($this->aOnUnloadEvents)) { return $this->aOnUnloadEvents; } } function getOnReadyDomEvents() { $c = & SGL_Config::singleton(); $conf = $c->getAll(); if (!empty($conf['site']['globalJavascriptOnReadyDom'])) { $this->aOnReadyDomEvents[] = $conf['site']['globalJavascriptOnReadyDom']; } if (count($this->aOnReadyDomEvents)) { return $this->aOnReadyDomEvents; } } /** * For adding JavaScript files to include. * * @param mixed $file or array $file path/to/jsFile, relative to www/ dir e.g. js/foo.js. can also be remote js file e.g. http://example.com/foo.js * @return void */ function addJavascriptFile($file, $optimize = true) { if ($optimize) { $aFiles = &$this->aJavascriptFiles; } else { $aFiles = &$this->aRawJavascriptFiles; } if (is_array($file)) { foreach ($file as $jsFile) { if (!in_array($jsFile, $aFiles)) { $aFiles[] = (strpos($jsFile, 'http://') === 0) ? $jsFile : SGL_BASE_URL . '/' . $jsFile; } } } else { if (!in_array($file, $aFiles)) { $aFiles[] = (strpos($file, 'http://') === 0) ? $file : SGL_BASE_URL . '/' . $file; } } } function getJavascriptFiles() { $aFiles = array(); $c = & SGL_Config::singleton(); $conf = $c->getAll(); // Check for global files to include if (!empty($conf['site']['globalJavascriptFiles'])) { $aTmp = explode(';', $conf['site']['globalJavascriptFiles']); foreach ($aTmp as $file) { $aFiles[] = (strpos($file, 'http://') === 0) ? $file : SGL_BASE_URL . '/' . $file; } } // BC with old way of including js files if (isset($this->javascriptSrc)) { if (is_array($this->javascriptSrc)) { foreach ($this->javascriptSrc as $file) { $aFiles[] = (strpos($file, 'http://') === 0) ? $file : SGL_BASE_URL . '/' . $file; } } else { $aFiles[] = (strpos($this->javascriptSrc, 'http://') === 0) ? $this->javascriptSrc : SGL_BASE_URL . '/' . $this->javascriptSrc; } } // Get files added with $output->addJavascriptFile() if (count($this->aJavascriptFiles)) { $aFiles = array_merge( $aFiles, $this->aJavascriptFiles ); } return $aFiles; } /** * For adding CSS files to include. * * @param mixed $file or array $file path/to/cssFile, relative to www/ dir e.g. css/foo.css * @return void */ function addCssFile($file) { if (is_array($file)) { foreach ($file as $cssFile) { if (!in_array($cssFile, $this->aCssFiles)) { $this->aCssFiles[] = $cssFile; } } } else { if (!in_array($file, $this->aCssFiles)) { $this->aCssFiles[] = $file; } } } /** * Wrapper for SGL_Url::makeLink. * Generates URL for easy access to modules and actions. * * @access public * * @param string $action * @param string $mgr * @param string $mod * @param array $aList * @param string $params * @param integer $idx * * @return string */ function makeUrl($action = '', $mgr = '', $mod = '', $aList = array(), $params = '', $idx = 0) { $input = &SGL_Registry::singleton(); $req = $input->getRequest(); // Horde routes work only for browser request types if ($req->type == SGL_REQUEST_BROWSER && SGL_Config::get('site.inputUrlHandlers') == 'Horde_Routes') { $aArgs = func_get_args(); // new style call if (count($aArgs) == 1) { if (strpos($aArgs[0], '|') !== false) { $aVars = explode('||', $aArgs[0]); $aArgs = array(); foreach ($aVars as $varString) { list($k, $v) = explode('|', $varString); $aArgs[$k] = $v; } if (isset($aArgs['module'])) { $aArgs['moduleName'] = $aArgs['module']; unset($aArgs['module']); } if (isset($aArgs['manager'])) { $aArgs['managerName'] = $aArgs['manager']; unset($aArgs['manager']); } // named route } else { $aArgs = $aArgs[0]; } // old style: params string specified as not part of array } elseif (count($aArgs) == 5 && empty($aList)) { $aVars = explode('||', $aArgs[4]); foreach ($aVars as $varKey => $varString) { $aVar = explode('|', $varString); if (isset($aVar[1]) && isset($this->{$aVar[1]})) { $aVar[1] = $this->{$aVar[1]}; } $aVars[$varKey] = implode('|', $aVar); } $aArgs[4] = implode('||', $aVars); } $url = $input->getCurrentUrl(); $ret = $url->makeLink($aArgs); } else { $ret = SGL_Url::makeLink($action, $mgr, $mod, $aList, $params, $idx, $this); } return $ret; } function getCurrentUrl() { $reg =& SGL_Registry::singleton(); $oCurrentUrl = $reg->getCurrentUrl(); return $oCurrentUrl->toString(); } function isVerticalNav($styleSheet) { return in_array($styleSheet, array('SglListamaticSubtle', 'verticalSimple')); } function outputBody($templateEngine = null) { if (empty($this->template)) { $this->template = 'null.html'; } $this->masterTemplate = $this->template; $view = &new SGL_HtmlSimpleView($this, $templateEngine); echo $view->render(); // suppress error notices in templates SGL::setNoticeBehaviour(SGL_NOTICES_DISABLED); } /** * Returns true if client OS is windows. * * @return boolean */ function isWin() { return SGL_CLIENT_OS == 'Win'; } /** * Returns true if a and b are equal. * */ function isEqual($a, $b) { return $a == $b; } /** * Makes new var and assign value. * */ function assign(&$a, $b) { $a = $b; return; } function increment($int) { return ++ $int; } function isChecked($value) { if ($value) { $ret = 'checked="checked"'; } else { $ret = ''; } return $ret; } function getCurrentModule() { $reg =& SGL_Registry::singleton(); $req = $reg->getRequest(); $frmCallerMod = $req->get('frmCallerMod'); $modName = (is_null($frmCallerMod)) ? $req->getModuleName() : $frmCallerMod; return $modName; } function getCurrentManager() { $reg =& SGL_Registry::singleton(); $req = $reg->getRequest(); $frmCallerMgr = $req->get('frmCallerMgr'); $mgrName = (is_null($frmCallerMgr)) ? $req->getManagerName() : $frmCallerMgr; return $mgrName; } function getCurrentTemplate() { $reg =& SGL_Registry::singleton(); $req = $reg->getRequest(); $frmCallerTmpl = $req->get('frmCallerTmpl'); $tmplName = (is_null($frmCallerTmpl)) ? $this->template : $frmCallerTmpl; return $tmplName; } function getCurrentId() { $reg =& SGL_Registry::singleton(); $req = $reg->getRequest(); $frmCallerId = $req->get('frmCallerId'); $id = (is_null($frmCallerId)) ? $this->articleID : $frmCallerId; return $id; } /** * Check permission at the template level and returns true if permission * exists. * * Use as follows in any Flexy template: * * {if:hasPerms(#faqmgr_delete#)} on {else:} off {end:} * * * To get various perm names, select User module then go to 'perms' section. * * @access public * @param string $permName Name of permission eg. "faqmgr_delete" * @return boolean * */ function hasPerms($permName) { $permId = @constant('SGL_PERMS_' . strtoupper($permName)); return (!empty($permId) && SGL_Session::hasPerms($permId) ? true : false); } /** * printf function wrapper. * * @return string */ function printf() { $argv = func_get_args(); return @call_user_func_array('sprintf', $argv); } function makeCssLink($theme, $navStylesheet, $moduleName) { // check first if CSS file exists in module if (is_file(SGL_MOD_DIR . "/$moduleName/www/css/$moduleName.php")) { $ret = SGL_BASE_URL . "/themes/$theme/css/style.php?navStylesheet=$navStylesheet&moduleName=$moduleName&isSymlink=1"; // else default to standard css loading with modulename passed as param } else { $ret = SGL_BASE_URL . "/themes/$theme/css/style.php?navStylesheet=$navStylesheet&moduleName=$moduleName"; } return $ret; } function humanise($lowerCaseAndUnderscoredWord) { return SGL_Inflector::humanise($lowerCaseAndUnderscoredWord); } function camelise($lowerCaseWithSpacesWordsString) { return SGL_Inflector::camelise($lowerCaseWithSpacesWordsString); } /** * @return current ms since script start */ function getExecutionTime() { return getSystemTime() - @SGL_START_TIME; } /** * @return query count */ function getQueryCount() { return $GLOBALS['_SGL']['QUERY_COUNT']; } /** * @return memory usage */ function getMemoryUsage() { if (function_exists('memory_get_usage')) { return number_format(memory_get_usage()); } else { return 'unknown'; } } function addHeader($header) { if (!in_array($header, $this->aHeaders)) { $this->aHeaders[] = $header; } } function getHeaders() { return $this->aHeaders; } /** * Makes optimizer link for JavaScript files. * * How to use: * 1. in your template you need to add the following line * \n"; foreach ($this->aRawJavascriptFiles as $jsFile) { $ret .= "\n"; } return $ret; } /** * Makes CSS optimizer link. * * @access public * * @param array $aCssHelperParams additional params passed to css helper * @param mixed $aDefaultThemeFiles if null default css files are loaded * otherwise custom files specified as array * or string (CSV) * @param string $themePreloadFile file which is "prepended" to every CSS request * (even in non-production mode) * * @return string */ function makeCssOptimizerLink($aCssHelperParams = array(), $aDefaultThemeFiles = null, $themePreloadFile = null) { $theme = $this->theme; // get master layout $masterLayout = !empty($this->masterLayout) ? $this->masterLayout : 'layout-navtop-3col.css'; // needs to be customized // layout is specified in request for demo purpose on home page $req = &SGL_Request::singleton(); $masterLayout = $req->get('masterLayout') ? $req->get('masterLayout') : $masterLayout; // make sure we pass layout to output $this->masterLayout = $masterLayout; if (!empty($aDefaultThemeFiles) && is_string($aDefaultThemeFiles)) { $aTmpThemeFiles = explode(',', $aDefaultThemeFiles); $aDefaultThemeFiles = array(); foreach ($aTmpThemeFiles as $file) { $aDefaultThemeFiles[] = "themes/$theme/css/$file"; } } if (!is_array($aDefaultThemeFiles)) { // default files loaded $aDefaultThemeFiles = array( // we need to be able to customize it "themes/$theme/css/reset.css", "themes/$theme/css/tools.css", "themes/$theme/css/typo.css", "themes/$theme/css/forms.css", "themes/$theme/css/layout.css", "themes/$theme/css/blocks.css", "themes/$theme/css/common.css", "themes/$theme/css/$masterLayout", ); } // custom loaded files $aCurrentFiles = $this->aCssFiles; $this->aCssFiles = array(); // add common css files $this->addCssFile($aDefaultThemeFiles); // add custom files $this->addCssFile($aCurrentFiles); $module = !empty($this->moduleName) ? $this->moduleName : 'default'; $defaultModule = SGL_Config::get('site.defaultModule') ? SGL_Config::get('site.defaultModule') : $module; // params passed to csshelper $aCssHelperParams['theme'] = $theme; $aCssHelperParams['langDir'] = $this->langDir; $aCssHelperParams['isFormSubmitted'] = !empty($this->submitted); $aCssHelperParams['module'] = $module; $aCssHelperParams['defaultModule'] = $defaultModule; // autoload module's css file if (is_file(realpath(SGL_WEB_ROOT . "/$module/css/$module.css"))) { $this->addCssFile("$module/css/$module.css"); } elseif (is_file(realpath(SGL_WEB_ROOT . "/themes/$theme/css/$module.css"))) { $this->addCssFile("themes/$theme/css/$module.css"); } // BC if (is_file(realpath(SGL_WEB_ROOT . "/$module/css/$module.php"))) { $this->addCssFile("$module/css/$module.php"); } elseif (is_file(realpath(SGL_WEB_ROOT . "/themes/$theme/css/$module.php"))) { $this->addCssFile("themes/$theme/css/$module.php"); } $params = ''; foreach ($aCssHelperParams as $k => $v) { $params .= '&aParams[' . urlencode($k) . ']=' . urlencode($v); } // allow to load each file in a separate request for debug purposes if (!SGL_Config::get('debug.production')) { $ret = ''; $rev = time(); foreach ($this->aCssFiles as $file) { $aFiles = array(); if (!empty($themePreloadFile)) { $aFiles[] = "themes/$theme/css/$themePreloadFile"; } $aFiles[] = $file; $cssString = implode(',', $aFiles); $link = SGL_BASE_URL . "/optimizer.php?type=css&rev=$rev&files=" . $cssString . $params; $ret .= "\n"; } } else { $aFiles = !empty($themePreloadFile) ? array_merge( array("themes/$theme/css/$themePreloadFile"), $this->aCssFiles ) : $this->aCssFiles; $rev = SGL_Output::_getFilesModifiedTime($aFiles); $cssString = implode(',', $aFiles); $link = SGL_BASE_URL . "/optimizer.php?type=css&rev=$rev&files=" . $cssString . $params; $ret = "\n"; } return $ret; } /** * Identifies latest mod time for specified files array. * Is used to get "revision" number for optimizer link. * * @access private * * @param array $aFiles * * @return integer */ function _getFilesModifiedTime($aFiles) { $lastMod = 0; foreach ($aFiles as $fileName) { if (is_file(realpath(SGL_WEB_ROOT . '/' . $fileName))) { $lastMod = max($lastMod, filemtime(SGL_WEB_ROOT . '/' . $fileName)); } } return $lastMod; } /** * Get message, which outputs html in default2 style. * * @access public * * @return void */ function msgGet() { // BC for admin GUI if ($this->adminGuiAllowed) { return SGL_Output::msgGetAdmin(); } $message = SGL_Session::get('message'); $messageType = SGL_Session::get('messageType'); $html = ''; // get html for SGL messages if (!empty($message)) { SGL_Session::remove('message'); SGL_Session::remove('messageType'); switch ($messageType) { case SGL_MESSAGE_INFO: $class = 'info'; break; case SGL_MESSAGE_WARNING: $class = 'warning'; break; default: $class = 'error'; break; } $html .= "

$message

"; // required to remove message that persists // when register_globals = on unset($GLOBALS['message']); unset($GLOBALS['messageType']); } // get html for SGL errors if (SGL_Error::count()) { // get all errors from stack while ($msg = SGL_Error::pop()) { $msg = SGL_Error::toString($msg); $html .= "

Error

$msg

"; } } if (empty($html)) { $html = ''; } echo $html; // we need to echo, do not replace to return } function getLangDirection() { $ret = $this->langDir == 'rtl' ? 'right' : 'left'; return $ret; } function getLangDirectionOpposite() { $ret = $this->langDir == 'rtl' ? 'left' : 'right'; return $ret; } } ?>