Beispiel #1
0
 public function add($aVals)
 {
     $sVarName = strtolower(preg_replace('/ +/', '_', preg_replace('/[^0-9a-zA-Z ]+/', '', trim($aVals['var_name']))));
     $iId = $this->database()->insert($this->_sTable, array('group_id' => $sVarName, 'module_id' => $aVals['module_id'], 'product_id' => $aVals['product_id'], 'version_id' => Phpfox::getId(), 'var_name' => 'setting_group_' . $sVarName));
     $sPhrase = Phpfox::getService('language.phrase.process')->add(array('var_name' => 'setting_group_' . $sVarName, 'product_id' => $aVals['product_id'], 'module' => $aVals['module_id'] . '|' . $aVals['module_id'], 'text' => array('en' => '<title>' . $aVals['var_name'] . '</title><info>' . $aVals['info'] . '</info>')));
     return $sVarName;
 }
Beispiel #2
0
 /**
  * Gets any data we plan to place within the HTML tags <head></head>.
  * This method also groups the data to give the template a nice clean look.
  *
  * @return string|array $sData Returns the HTML data to be placed within <head></head>
  */
 public function getHeader($bReturnArray = false)
 {
     if (Phpfox::isAdminPanel()) {
         $this->setHeader(array('custom.css' => 'style_css'));
     }
     if ($this->delayedHeaders) {
         foreach ($this->delayedHeaders as $header) {
             $this->setHeader('cache', $header);
         }
     }
     // $this->setHeader('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">');
     Core\Event::trigger('lib_phpfox_template_getheader', $this);
     foreach ((new Core\App())->all() as $App) {
         if ($App->head && is_array($App->head)) {
             foreach ($App->head as $head) {
                 $this->setHeader($head);
             }
         }
         if ($App->settings) {
             $Setting = new Core\Setting();
             foreach ($App->settings as $key => $setting) {
                 if (isset($setting->js_variable)) {
                     $this->setHeader('<script>var ' . $key . ' = "' . $Setting->get($key) . '";</script>');
                 }
             }
         }
     }
     $aArrayData = array();
     $sData = '';
     $sJs = '';
     $iVersion = $this->getStaticVersion();
     $oUrl = Phpfox_Url::instance();
     $aUrl = $oUrl->getParams();
     if (!defined('PHPFOX_DESIGN_DND')) {
         define('PHPFOX_DESIGN_DND', false);
     }
     if (!PHPFOX_IS_AJAX_PAGE) {
         ($sPlugin = Phpfox_Plugin::get('template_getheader')) ? eval($sPlugin) : false;
         $sJs .= "\t\t\tvar oCore = {'core.is_admincp': " . (Phpfox::isAdminPanel() ? 'true' : 'false') . ", 'core.section_module': '" . Phpfox_Module::instance()->getModuleName() . "', 'profile.is_user_profile': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? 'true' : 'false') . ", 'log.security_token': '" . Phpfox::getService('log.session')->getToken() . "', 'core.url_rewrite': '" . Phpfox::getParam('core.url_rewrite') . "', 'core.country_iso': '" . (Phpfox::isUser() ? Phpfox::getUserBy('country_iso') : '') . "', 'core.can_move_on_a_y_and_x_axis' : " . (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.can_move_on_a_y_and_x_axis') ? 'true' : 'false') . ", 'core.default_currency': '" . (defined('PHPFOX_INSTALLER') ? 'USD' : Phpfox::getService('core.currency')->getDefault()) . "', 'core.enabled_edit_area': " . (Phpfox::getParam('core.enabled_edit_area') ? 'true' : 'false') . ", 'core.disable_hash_bang_support': " . (Phpfox::getParam('core.disable_hash_bang_support') ? 'true' : 'false') . ", 'core.site_wide_ajax_browsing': " . (!defined('PHPFOX_IN_DESIGN_MODE') && Phpfox::getParam('core.site_wide_ajax_browsing') && !Phpfox::isAdminPanel() && Phpfox::isUser() ? 'true' : 'false') . ", 'profile.user_id': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? Profile_Service_Profile::instance()->getProfileUserId() : 0) . "};\n";
         // You are filtering out the controllers which should not load 'content' ajaxly, finding a way for pages.view/1/info and like that
         $sProgressCssFile = $this->getStyle('css', 'progress.css');
         $sStylePath = str_replace(Phpfox::getParam('core.path'), '', str_replace('progress.css', '', $sProgressCssFile));
         $aJsVars = array('sJsHome' => Phpfox::getParam('core.path'), 'sJsHostname' => $_SERVER['HTTP_HOST'], 'sSiteName' => Phpfox::getParam('core.site_title'), 'sJsStatic' => $oUrl->getDomain() . PHPFOX_STATIC, 'sJsStaticImage' => Phpfox::getParam('core.url_static_image'), 'sImagePath' => $this->getStyle('image'), 'sStylePath' => $this->getStyle('css'), 'sVersion' => Phpfox::getId(), 'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php', 'sStaticVersion' => $iVersion, 'sGetMethod' => PHPFOX_GET_METHOD, 'sDateFormat' => defined('PHPFOX_INSTALLER') ? '' : Phpfox::getParam('core.date_field_order'), 'sEgiftStyle' => $this->getStyle('css', 'display.css', 'egift'), 'sGlobalTokenName' => Phpfox::getTokenName(), 'sController' => Phpfox_Module::instance()->getFullControllerName(), 'bJsIsMobile' => Phpfox::isMobile() ? true : false, 'sProgressCssFile' => $sProgressCssFile, 'sHostedVersionId' => defined('PHPFOX_IS_HOSTED_VERSION') ? PHPFOX_IS_HOSTED_VERSION : '');
         if (!defined('PHPFOX_INSTALLER')) {
             $aJsVars['bWysiwyg'] = Phpfox::getParam('core.wysiwyg') != 'default' && Phpfox::getParam('core.allow_html') ? true : false;
             $aJsVars['sEditor'] = Phpfox::getParam('core.wysiwyg');
             $aJsVars['sJsCookiePath'] = Phpfox::getParam('core.cookie_path');
             $aJsVars['sJsCookieDomain'] = Phpfox::getParam('core.cookie_domain');
             $aJsVars['sJsCookiePrefix'] = Phpfox::getParam('core.session_prefix');
             $aJsVars['bPhotoTheaterMode'] = Phpfox::isModule('photo') ? Phpfox::getParam('photo.view_photos_in_theater_mode') : false;
             $aJsVars['bUseHTML5Video'] = false;
             // ((Phpfox::isModule('video') && Phpfox::getParam('video.upload_for_html5')) ? true : false);
             if (Phpfox::isAdmin()) {
                 $aJsVars['sAdminCPLocation'] = Phpfox::getParam('admincp.admin_cp');
             } else {
                 $aJsVars['sAdminCPLocation'] = '';
             }
             if (Phpfox::isModule('notification')) {
                 $aJsVars['notification.notify_ajax_refresh'] = Phpfox::getParam('notification.notify_ajax_refresh');
             }
             $sLocalDatepicker = PHPFOX_STATIC . 'jscript/jquery/locale/jquery.ui.datepicker-' . strtolower(Phpfox_Locale::instance()->getLangId()) . '.js';
             if (file_exists($sLocalDatepicker)) {
                 $sFile = str_replace(PHPFOX_STATIC . 'jscript/', '', $sLocalDatepicker);
                 $this->setHeader(array($sFile => 'static_script'));
             }
             /* Only in a few cases will we want to add the visitor's IP */
             if (Phpfox::getParam('core.google_api_key') != '' && Phpfox::getParam('core.ip_infodb_api_key')) {
                 // $aJsVars['sIP'] = Phpfox_Request::instance()->getIp();
             }
             $aJsVars['bEnableMicroblogSite'] = Phpfox::isModule('microblog') ? Phpfox::getParam('microblog.enable_microblog_site') : false;
         }
         ($sPlugin = Phpfox_Plugin::get('template_getheader_setting')) ? eval($sPlugin) : false;
         if (Phpfox::isModule('input') && false) {
             $this->setHeader('cache', array('browse.css' => 'style_css'));
         }
         $sJs .= "\t\t\tvar oParams = {";
         $iCnt = 0;
         foreach ($aJsVars as $sVar => $sValue) {
             $iCnt++;
             if ($iCnt != 1) {
                 $sJs .= ",";
             }
             if (is_bool($sValue)) {
                 $sJs .= "'{$sVar}': " . ($sValue ? 'true' : 'false');
             } elseif (is_numeric($sValue)) {
                 $sJs .= "'{$sVar}': " . $sValue;
             } else {
                 $sJs .= "'{$sVar}': '" . str_replace("'", "\\'", $sValue) . "'";
             }
         }
         $sJs .= "};\n";
         if (!defined('PHPFOX_INSTALLER')) {
             $aLocaleVars = array('core.are_you_sure', 'core.yes', 'core.no', 'core.save', 'core.cancel', 'core.go_advanced', 'core.processing', 'emoticon.emoticons', 'attachment.attach_files', 'core.close', 'core.language_packages', 'core.move_this_block', 'core.uploading', 'language.loading', 'core.saving', 'core.loading_text_editor', 'core.quote', 'core.loading');
             if (Phpfox::isModule('im') && Phpfox::getParam('im.enable_im_in_footer_bar')) {
                 $aLocaleVars[] = 'im.find_your_friends';
             }
             ($sPlugin = Phpfox_Plugin::get('template_getheader_language')) ? eval($sPlugin) : false;
             $sJs .= "\t\t\tvar oTranslations = {";
             $iCnt = 0;
             foreach ($aLocaleVars as $sValue) {
                 $aParts = explode('.', $sValue);
                 if ($aParts[0] != 'core' && !Phpfox::isModule($aParts[0])) {
                     continue;
                 }
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sValue}': '" . html_entity_decode(str_replace("'", "\\'", Phpfox::getPhrase($sValue)), null, 'UTF-8') . "'";
             }
             $sJs .= "};\n";
             $aModules = Phpfox_Module::instance()->getModules();
             $sJs .= "\t\t\tvar oModules = {";
             $iCnt = 0;
             foreach ($aModules as $sModule => $iModuleId) {
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sModule}': true";
             }
             $sJs .= "};\n";
         }
         if (count($this->_aImages)) {
             $sJs .= "\t\t\tvar oJsImages = {";
             foreach ($this->_aImages as $sKey => $sImage) {
                 $sJs .= $sKey . ': \'' . $sImage . '\',';
             }
             $sJs = rtrim($sJs, ',');
             $sJs .= "};\n";
         }
         /*
         if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active'])
         {
         */
         $aEditorButtons = Phpfox::getLib('editor')->getButtons();
         $iCnt = 0;
         $sJs .= "\t\t\tvar oEditor = {";
         if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active']) {
             foreach ($this->_aEditor as $sVar => $mValue) {
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sVar}': " . (is_bool($mValue) ? $mValue === true ? 'true' : 'false' : "'{$mValue}'") . "";
             }
             $sJs .= ", ";
         }
         $sJs .= "images:[";
         foreach ($aEditorButtons as $mEditorButtonKey => $aEditorButton) {
             $sJs .= "{";
             foreach ($aEditorButton as $sEditorButtonKey => $sEditorButtonValue) {
                 $sJs .= "" . $sEditorButtonKey . ": '" . $sEditorButtonValue . "',";
             }
             $sJs = rtrim($sJs, ',') . "},";
         }
         $sJs = rtrim($sJs, ',') . "]";
         $sJs .= "};\n";
         // }
         if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn')) {
             $sData .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/' . Phpfox::getParam('core.jquery_google_cdn_version') . '/jquery.min.js"></script>' . "\n";
         }
     }
     if (PHPFOX_IS_AJAX_PAGE) {
         $this->_aCacheHeaders = array();
     }
     $bIsHttpsPage = false;
     if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.force_https_secure_pages')) {
         if (in_array(str_replace('mobile.', '', Phpfox_Module::instance()->getFullControllerName()), Phpfox::getService('core')->getSecurePages()) && (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
             $bIsHttpsPage = true;
         }
     }
     $aSubCache = array();
     $sStyleCacheData = '';
     $sJsCacheData = '';
     $aCacheJs = array();
     $aCacheCSS = array();
     $this->_sFooter = '';
     $sJs .= "\t\t\t" . 'var $Behavior = {}, $Ready = $Ready = function(callback) {$Behavior[callback.toString().length] = callback;}, $Events = {}, $Event = function(callback) {$Events[callback.toString().length] = callback;};' . "\n";
     $sJs .= "\t\t\t" . 'var $Core = {};' . "\n";
     $aCustomCssFile = array();
     foreach ($this->_aHeaders as $aHeaders) {
         if (!is_array($aHeaders)) {
             $aHeaders = array($aHeaders);
         }
         foreach ($aHeaders as $mKey => $mValue) {
             $sQmark = strpos($mKey, '?') ? '&amp;' : '?';
             if (is_numeric($mKey)) {
                 if ($mValue === null) {
                     continue;
                 }
                 if ($bReturnArray) {
                     $aArrayData[] = $mValue;
                 } else {
                     if (is_string($mValue) && (strpos($mValue, '.js') !== false || strpos($mValue, 'javascript') !== false)) {
                         if (strpos($mValue, 'RecaptchaOptions')) {
                             $sData .= "\t\t" . $mValue . "\n";
                         } else {
                             $this->_sFooter .= "\t\t" . $mValue;
                         }
                     } else {
                         if (is_string($mValue)) {
                             $sData .= "\t\t" . $mValue . "\n";
                         } else {
                             $sData .= "\t\t" . implode($mValue) . "\n";
                         }
                     }
                 }
             } else {
                 if ($mKey == 'master') {
                     $aMaster = array('css' => array(), 'jscript' => array());
                     foreach ($mValue as $sValKey => $sValVal) {
                         if (strpos($sValKey, '.css') !== false) {
                             if ($sValVal == 'style_css') {
                                 $aMaster['css'][] = 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $this->getThemeFolder() . PHPFOX_DS . 'style' . PHPFOX_DS . $this->getStyleFolder() . PHPFOX_DS . 'css' . PHPFOX_DS . $sValKey;
                             } else {
                                 if (strpos($sValVal, 'module_') !== false) {
                                     $aMaster['css'][] = 'module' . PHPFOX_DS . str_replace('module_', '', $sValVal) . PHPFOX_DS . 'static' . PHPFOX_DS . 'css' . PHFPFOX_DS . $this->getThemeFolder() . PHPFOX_DS . $this->getStyleFolder() . PHPFOX_DS . $sValKey;
                                 }
                             }
                         } else {
                             if (strpos($sValKey, '.js') !== false) {
                                 if ($sValVal == 'static_script') {
                                     $aMaster['jscript'][] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $sValKey;
                                 } else {
                                     if (strpos($sValVal, 'module_') !== false) {
                                         $aMaster['jscript'][] = 'module' . PHPFOX_DS . str_replace('module_', '', $sValVal) . PHPFOX_DS . 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $sValKey;
                                     }
                                 }
                             }
                         }
                     }
                     unset($this->_aHeaders[$mKey]);
                     // just to avoid confusions
                     $this->_aHeaders['master'] = $aMaster;
                 } else {
                     $bToHead = false;
                     // This happens when the developer needs something to go to <head>
                     if (is_array($mValue)) {
                         $aKeyHead = array_keys($mValue);
                         $aKeyValue = array_values($mValue);
                         $bToHead = $mKey == 'head';
                         $mKey = array_pop($aKeyHead);
                         $mValue = array_pop($aKeyValue);
                     }
                     switch ($mValue) {
                         case 'style_script':
                             if (isset($aSubCache[$mKey][$mValue])) {
                                 continue;
                             }
                             if ($bReturnArray) {
                                 $aArrayData[] = $this->getStyle('jscript', $mKey);
                             } else {
                                 //$sJsCacheData .= str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey)) . ',';
                                 if ($bToHead == 'head') {
                                     $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey));
                                 } else {
                                     $aCacheJs[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey));
                                 }
                             }
                             break;
                         case 'style_css':
                             $bCustomStyle = false;
                             if ($bCustomStyle === false) {
                                 if ($bReturnArray) {
                                     $aArrayData[] = $this->getStyle('css', $mKey);
                                 } else {
                                     $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey));
                                 }
                             } else {
                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT')) {
                                     $bLoadCustomThemeOverwrite = true;
                                 } else {
                                     if ($bReturnArray) {
                                         $aArrayData[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey;
                                     } else {
                                         if (isset($this->_aCacheHeaders[$mKey])) {
                                             // $sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . ',';
                                             $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '';
                                         } else {
                                             if ($bIsHttpsPage) {
                                                 //$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_secure_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
                                                 $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_secure_' . $mKey;
                                             } else {
                                                 //$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
                                                 $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey;
                                             }
                                         }
                                     }
                                 }
                             }
                             break;
                         case 'static_script':
                             if (isset($aSubCache[$mKey][$mValue])) {
                                 continue;
                             }
                             if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn')) {
                                 if ($mKey == 'jquery/ui.js' || $mKey == 'jquery/jquery.js') {
                                     if ($mKey == 'jquery/ui.js') {
                                         $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/' . Phpfox::getParam('core.jquery_ui_google_cdn_version') . '/jquery-ui.min.js"></script>' . "\n";
                                     }
                                     continue;
                                 }
                             }
                             if ($bReturnArray) {
                                 $aArrayData[] = Phpfox::getParam('core.url_static_script') . $mKey;
                             } else {
                                 if (isset($this->_aCacheHeaders[$mKey])) {
                                     // $sJsCacheData .= $mKey . ',';
                                     if ($bToHead == 'head') {
                                         $aCacheCSS[] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $mKey;
                                     } else {
                                         $aCacheJs[] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $mKey;
                                     }
                                 } else {
                                     //$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static_script') . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                     if ($bToHead == 'head') {
                                         $aCacheCSS[] = 'static/jscript/' . $mKey;
                                     } else {
                                         $aCacheJs[] = 'static/jscript/' . $mKey;
                                     }
                                 }
                             }
                             break;
                         default:
                             if (preg_match('/module/i', $mValue)) {
                                 $aParts = explode('_', $mValue);
                                 if (isset($aParts[1]) && Phpfox::isModule($aParts[1])) {
                                     if (substr($mKey, -3) == '.js') {
                                         if ($bReturnArray) {
                                             $aArrayData[] = Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                         } else {
                                             if (isset($this->_aCacheHeaders[$mKey])) {
                                                 //$sJsCacheData .= 'module/' . $aParts[1] . '/static/jscript/' . $mKey . ',';
                                                 $aCacheJs[] = 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                             } else {
                                                 /*
                                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT'))
                                                 {
                                                 	$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getCdnPath() . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                                 }	
                                                 else
                                                 {
                                                 */
                                                 //$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                                 $aCacheJs[] = 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                                 // }
                                             }
                                         }
                                     } elseif (substr($mKey, -4) == '.css') {
                                         $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                         $bCustomStyle = false;
                                         if ($bCustomStyle === false) {
                                             if ($bReturnArray) {
                                                 //$aArrayData[] = $this->getStyle('css', $mKey, $aParts[1]);
                                                 $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                             } else {
                                                 /*
                                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT'))
                                                 {
                                                     $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . str_replace(Phpfox::getParam('core.path'), Phpfox::getCdnPath(), $this->getStyle('css', $mKey, $aParts[1])) . $sQmark . 'v=' . $iVersion . '" />' . "\n";
                                                 }
                                                 else
                                                 {
                                                 */
                                                 $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                                 // }
                                             }
                                         } else {
                                             //$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey . ',';
                                             $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey;
                                         }
                                     }
                                 }
                             }
                             break;
                     }
                     $aSubCache[$mKey][$mValue] = true;
                 }
             }
         }
     }
     $sCacheData = '';
     $sCacheData .= "\n\t\t<script type=\"text/javascript\">\n";
     $sCacheData .= $sJs;
     $sCacheData .= "\t\t</script>";
     if (!empty($sStyleCacheData)) {
         $sCacheData .= "\n\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=css&amp;s=' . $sStylePath . '&amp;f=' . rtrim($sStyleCacheData, ',') . '&amp;v=' . $iVersion . '" />';
     }
     if (!empty($sJsCacheData)) {
         $sCacheData .= "\n\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=js&amp;f=' . rtrim($sJsCacheData, ',') . '&amp;v=' . $iVersion . '"></script>';
     }
     if (!empty($sCacheData)) {
         $sData = preg_replace('/<link rel="shortcut icon" type="image\\/x-icon" href="(.*?)" \\/>/i', '<link rel="shortcut icon" type="image/x-icon" href="\\1" />' . $sCacheData, $sData);
     }
     if ($bReturnArray) {
         $sData = '';
     }
     $aCacheJs = array_unique($aCacheJs);
     $aSubCacheCheck = array();
     foreach ($aCacheCSS as $sFile) {
         if (defined('PHPFOX_INSTALLER')) {
             $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . $sFile . $sQmark . 'v=' . $iVersion . '" />' . "\n";
         } else {
             if (isset($aSubCacheCheck[$sFile])) {
                 continue;
             }
             $aSubCacheCheck[$sFile] = true;
             $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.path') . $sFile . $sQmark . 'v=' . $iVersion . '" />' . "\n";
         }
     }
     foreach ($aCacheJs as $sFile) {
         if (defined('PHPFOX_INSTALLER')) {
             $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="../' . $sFile . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
         } else {
             $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . $sFile . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
         }
     }
     if (!defined('PHPFOX_INSTALLER')) {
         $this->_sFooter .= "\t\t" . '<script type="text/javascript"> $Core.init(); </script>' . "\n";
     }
     if (count($this->_aPhrases)) {
         $sData .= "\n\t\t<script type=\"text/javascript\">\n\t\t";
         foreach ($this->_aPhrases as $sVar => $sPhrase) {
             $sPhrase = html_entity_decode($sPhrase, null, 'UTF-8');
             $sData .= "\t\t\toTranslations['{$sVar}'] = '" . str_replace("'", "\\'", $sPhrase) . "';\n";
         }
         $sData .= "\t\t</script>\n";
     }
     if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel()) {
         $Request = \Phpfox_Request::instance();
         if ($Request->segment(1) == 'theme' && $Request->segment(2) == 'demo') {
             $sData .= '<link href="' . Phpfox::getParam('core.path') . 'theme/default/flavor/default.css?v=' . Phpfox::internalVersion() . '" rel="stylesheet">';
         } else {
             $Theme = $this->_theme->get();
             $sData .= '<link href="' . Phpfox::getParam('core.path') . 'themes/' . $Theme->folder . '/flavor/' . $Theme->flavor_folder . '.css?v=' . Phpfox::internalVersion() . '" rel="stylesheet">';
         }
     }
     if (!defined('PHPFOX_INSTALLER')) {
         $Apps = new Core\App();
         foreach ($Apps->all() as $App) {
             $assets = $App->path . 'assets/';
             if (file_exists($assets . 'autoload.js')) {
                 $url = str_replace(PHPFOX_DIR_SITE, Phpfox::getParam('core.path'), $assets) . 'autoload.js';
                 $this->_sFooter .= '<script src="' . $url . '?v=' . Phpfox::internalVersion() . '"></script>';
             }
             if (file_exists($assets . 'autoload.css')) {
                 $url = str_replace(PHPFOX_DIR_SITE, Phpfox::getParam('core.path'), $assets) . 'autoload.css';
                 $sData .= '<link href="' . $url . '?v=' . Phpfox::internalVersion() . '" rel="stylesheet">';
             }
         }
         if (!Phpfox::isAdminPanel() && is_object($this->_theme)) {
             $asset = $this->_theme->get()->getPath() . 'assets/autoload.js';
             if (file_exists($asset)) {
                 $url = str_replace([PHPFOX_DIR_SITE, PHPFOX_DIR], Phpfox::getParam('core.path'), $asset);
                 $this->_sFooter .= '<script src="' . $url . '?v=' . Phpfox::internalVersion() . '"></script>';
             }
         }
     }
     if (isset($this->_meta['head'])) {
         $sData .= $this->_meta['head'];
         if (Phpfox::isAdmin()) {
             $this->_sFooter .= '<script>var page_editor_meta = ' . json_encode(['head' => $this->_meta['head']]) . ';</script>';
         }
     }
     if ($bReturnArray) {
         $aArrayData[] = $sData;
         return $aArrayData;
     }
     // Convert meta data
     $bHasNoDescription = false;
     if (count($this->_aMeta) && !PHPFOX_IS_AJAX_PAGE && !defined('PHPFOX_INSTALLER')) {
         $oPhpfoxParseOutput = Phpfox::getLib('parse.output');
         $aFind = array('&lt;', '&gt;', '$');
         $aReplace = array('<', '>', '&36;');
         foreach ($this->_aMeta as $sMeta => $sMetaValue) {
             $sMetaValue = str_replace($aFind, $aReplace, $sMetaValue);
             $sMetaValue = strip_tags($sMetaValue);
             $sMetaValue = str_replace(array("\n", "\r"), "", $sMetaValue);
             $bIsCustomMeta = false;
             switch ($sMeta) {
                 case 'keywords':
                     if (isset($this->_meta['keywords'])) {
                         $sMetaValue = $this->_meta['keywords'];
                         continue;
                     }
                     $sKeywordSearch = Phpfox::getParam('core.words_remove_in_keywords');
                     if (!empty($sKeywordSearch)) {
                         $aKeywordsSearch = array_map('trim', explode(',', $sKeywordSearch));
                     }
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_keyword_limit'));
                     $sMetaValue = trim(rtrim(trim($sMetaValue), ','));
                     $aParts = explode(',', $sMetaValue);
                     $sMetaValue = '';
                     $aKeywordCache = array();
                     foreach ($aParts as $sPart) {
                         $sPart = trim($sPart);
                         if (isset($aKeywordCache[$sPart])) {
                             continue;
                         }
                         if (isset($aKeywordsSearch) && in_array(strtolower($sPart), array_map('strtolower', $aKeywordsSearch))) {
                             continue;
                         }
                         $sMetaValue .= $sPart . ', ';
                         $aKeywordCache[$sPart] = true;
                     }
                     $sMetaValue = rtrim(trim($sMetaValue), ',');
                     break;
                 case 'description':
                     if (isset($this->_meta['description'])) {
                         $sMetaValue = $this->_meta['description'];
                         continue;
                     }
                     $bHasNoDescription = true;
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
                     break;
                 case 'robots':
                     $bIsCustomMeta = false;
                     break;
                 default:
                     $bIsCustomMeta = true;
                     break;
             }
             $sMetaValue = str_replace('"', '\\"', $sMetaValue);
             $sMetaValue = Phpfox_Locale::instance()->convert($sMetaValue);
             $sMetaValue = html_entity_decode($sMetaValue, null, 'UTF-8');
             $sMetaValue = str_replace(array('<', '>'), '', $sMetaValue);
             if ($bIsCustomMeta) {
                 if ($sMeta == 'og:description') {
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
                 }
                 switch ($sMeta) {
                     case 'canonical':
                         $sCanonical = $sMetaValue;
                         $sCanonical = preg_replace('/\\/when\\_([a-zA-Z0-9\\-]+)\\//i', '/', $sCanonical);
                         $sCanonical = preg_replace('/\\/show\\_([a-zA-Z0-9\\-]+)\\//i', '/', $sCanonical);
                         $sCanonical = preg_replace('/\\/view\\_\\//i', '/', $sCanonical);
                         if (Phpfox::isMobile()) {
                             if (Phpfox::getParam('core.url_rewrite') == '1') {
                                 $sCanonical = str_replace(Phpfox::getParam('core.path') . 'mobile/', Phpfox::getParam('core.path'), $sMetaValue);
                             } elseif (Phpfox::getParam('core.url_rewrite') == '2') {
                                 $sCanonical = str_replace('?' . PHPFOX_GET_METHOD . '=/mobile/', '?' . PHPFOX_GET_METHOD . '=/', $sMetaValue);
                             }
                         }
                         $sData .= "\t\t<link rel=\"canonical\" href=\"{$sCanonical}\" />\n";
                         if (!Phpfox::isMobile()) {
                             $sMobileReplace = '';
                             if (Phpfox::getParam('core.url_rewrite') == '1') {
                                 $sMobileReplace = str_replace(Phpfox::getParam('core.path'), Phpfox::getParam('core.path') . 'mobile/', $sCanonical);
                             } elseif (Phpfox::getParam('core.url_rewrite') == '2') {
                                 $sMobileReplace = str_replace('?' . PHPFOX_GET_METHOD . '=/', '?' . PHPFOX_GET_METHOD . '=/mobile/', $sCanonical);
                             }
                             $sData .= "\t\t<link rel=\"alternate\" media=\"only screen and (max-width: 640px)\" href=\"{$sMobileReplace}\" />\n";
                         }
                         break;
                     default:
                         $sData .= "\t\t<meta property=\"{$sMeta}\" content=\"{$sMetaValue}\" />\n";
                         break;
                 }
             } else {
                 if (strpos($sData, 'meta name="' . $sMeta . '"') !== false) {
                     $sData = preg_replace("/<meta name=\"{$sMeta}\" content=\"(.*?)\" \\/>\n\t/i", "<meta" . ($sMeta == 'description' ? ' property="og:description" ' : '') . " name=\"{$sMeta}\" content=\"" . $sMetaValue . "\" />\n\t", $sData);
                 } else {
                     $sData = preg_replace('/<meta/', '<meta name="' . $sMeta . '" content="' . $sMetaValue . '" />' . "\n\t\t" . '<meta', $sData, 1);
                 }
             }
         }
         if (!$bHasNoDescription) {
             $sData .= "\t\t" . '<meta name="description" content="' . Phpfox::getLib('parse.output')->clean(Phpfox_Locale::instance()->convert(Phpfox::getParam('core.description'))) . '" />' . "\n";
         }
     }
     // Clear from memory
     $this->_aHeaders = array();
     $this->_aMeta = array();
     return $sData;
 }
Beispiel #3
0
     $aRows = $this->_db()->select('p.*')->from($this->_getOldT('pages'), 'p')->execute('getRows');
     foreach ($aRows as $aRow) {
         $iPageId = $this->_db()->insert(Phpfox::getT('page'), array('user_id' => '0', 'module_id' => 'core', 'product_id' => 'phpfox', 'is_active' => '1', 'is_phrase' => '0', 'parse_php' => $aRow['allow_php'], 'has_bookmark' => '0', 'add_view' => '0', 'full_size' => '1', 'title' => Phpfox::getLib('parse.input')->clean($aRow['title_head']), 'title_url' => $aRow['title_url'], 'disallow_access' => null, 'added' => PHPFOX_TIME, 'total_view' => '0', 'total_attachment' => '0', 'total_tag' => '0'));
         $this->_db()->insert(Phpfox::getT('page_text'), array('page_id' => $iPageId, 'text' => Phpfox::getLib('parse.input')->clean($aRow['content']), 'text_parsed' => Phpfox::getLib('parse.input')->prepare($aRow['content']), 'keyword' => $aRow['meta'], 'description' => null));
         if (!empty($aRow['title_menu'])) {
             $aMenu = $this->_db()->select('*')->from($this->_getOldT('menu'))->where('parent = ' . $aRow['page_id'])->execute('getRow');
             if (isset($aMenu['menu_id'])) {
                 $sVarName = 'core_' . Phpfox::getService('language.phrase.process')->prepare($aMenu['title_menu']);
                 $sVarName = 'menu_' . $sVarName;
                 $sConnection = 'main';
                 if ($aMenu['location'] == '1') {
                     $sConnection = 'main_right';
                 } elseif ($aMenu['location'] == '2') {
                     $sConnection = 'footer';
                 }
                 $this->_db()->insert(Phpfox::getT('menu'), array('parent_id' => '0', 'page_id' => $iPageId, 'm_connection' => $sConnection, 'module_id' => 'core', 'product_id' => 'phpfox', 'var_name' => $sVarName, 'is_active' => '1', 'url_value' => str_replace('-', '.', $aMenu['url']), 'disallow_access' => null, 'version_id' => Phpfox::getId()));
                 Phpfox::getService('language.phrase.process')->add(array('var_name' => $sVarName, 'module' => 'core|core', 'product_id' => 'phpfox', 'text' => array('en' => $aMenu['title_menu'])));
             }
         }
     }
     $sMessage = 'importing of custom pages completed.';
     $sAction = 'import-setting';
     $iPage = 0;
     break;
 case 'import-user-background-photo':
     // Limit how many items to import per round
     $iLimit = 200;
     $iCnt = $this->_db()->select('COUNT(*)')->from($this->_getOldT('template'))->execute('getField');
     $aRows = $this->_db()->select('m.*, unew.user_id AS new_user_id')->from($this->_getOldT('template'), 'm')->join($this->_getOldT('user'), 'u', 'u.user = m.user')->join(Phpfox::getT('user'), 'unew', 'unew.upgrade_user_id = u.id')->where('m.bg_img = \'image\'')->limit($this->_sPage, $iLimit, $iCnt)->execute('getRows');
     foreach ($aRows as $aRow) {
         if (file_exists(PHPFOX_DIR_FILE . 'pic' . PHPFOX_DS . 'user_bg' . PHPFOX_DS . $aRow['user'] . '.jpg')) {
Beispiel #4
0
 /**
  * Gets any data we plan to place within the HTML tags <head></head>.
  * This method also groups the data to give the template a nice clean look.
  *
  * @return string $sData Returns the HTML data to be placed within <head></head>
  */
 public function getHeader($bReturnArray = false)
 {
     if (Phpfox::isMobile()) {
         $this->setHeader(array('mobile.css' => 'style_css'));
     }
     if (!defined('PHPFOX_INSTALLER')) {
         $this->setHeader(array('custom.css' => 'style_css'));
         $aLocale = Phpfox::getLib('locale')->getLang();
         if ($aLocale['direction'] == 'rtl') {
             $this->setHeader(array('rtl.css' => 'style_css'));
         }
         $sCustomCss = '';
         $aThemeCache = $this->getThemeCache();
         if (isset($aThemeCache['l_width']) && $aThemeCache['l_width'] > 0) {
             $sCustomCss .= '#left { width:' . (int) $aThemeCache['l_width'] . 'px; }';
             $sCustomCss .= '#main_content { margin-left:' . (int) $aThemeCache['l_width'] . 'px; }';
         }
         if (isset($aThemeCache['c_width']) && $aThemeCache['c_width'] > 0) {
             $sCustomCss .= '.content3, .item_view .js_feed_comment_border, .item_view .item_tag_holder, .item_view .attachment_holder_view { width:' . (int) $aThemeCache['c_width'] . 'px; }';
         }
         if (isset($aThemeCache['r_width']) && $aThemeCache['r_width'] > 0) {
             $sCustomCss .= '#right { width:' . (int) $aThemeCache['r_width'] . 'px; }';
             $sCustomCss .= '.content4 { width:' . (960 - (int) $aThemeCache['r_width']) . 'px; }';
         }
         if (!empty($sCustomCss)) {
             $this->setHeader('<style type="text/css">' . $sCustomCss . '</style>');
         }
     }
     $aArrayData = array();
     $sData = '';
     $sCss = '';
     $sJs = '';
     $iVersion = $this->getStaticVersion();
     $oUrl = Phpfox::getLib('url');
     if (defined('PHPFOX_IS_HOSTED_SCRIPT')) {
         $oCache = Phpfox::getLib('cache');
     } else {
         $oCache = Phpfox::getLib('cache', array('storage' => 'file', 'free' => true));
     }
     $aUrl = $oUrl->getParams();
     if (Phpfox::getUserParam('core.can_design_dnd') && Phpfox::getService('theme')->isInDnDMode() && (!isset($aUrl['req2']) || $aUrl['req2'] != 'designer')) {
         if (!defined('PHPFOX_DESIGN_DND')) {
             define('PHPFOX_DESIGN_DND', true);
         }
         /* .
          * Tells if the user is Design mode with Drag and Drop support.
          * Its important to note the difference in the purpose of this
          * constant as it does Not tell if the user CAN enter DesignDND 
          * mode but instead it tells if the user IS already in this 
          * mode
          * .
          */
         $this->_aHeaders[] = array('designdnd.js' => 'module_theme');
     } else {
         if (!defined('PHPFOX_DESIGN_DND')) {
             define('PHPFOX_DESIGN_DND', false);
         }
     }
     if (!PHPFOX_IS_AJAX_PAGE) {
         if (!defined('PHPFOX_INSTALLER')) {
             if (!Phpfox::isAdminPanel()) {
                 $oDb = Phpfox::getLib('database');
                 $oFileCache = Phpfox::getLib('cache');
                 $sFileThemeCssId = $oFileCache->set(array('theme', 'theme_css' . $iVersion));
                 $aCacheStyles = array();
                 if (!($aCacheStyles = $oFileCache->get($sFileThemeCssId))) {
                     $aSavedStyles = $oDb->select('tc.module_id, tc.file_name')->from(Phpfox::getT('theme_css'), 'tc')->where('style_id = ' . (int) $this->_aTheme['style_id'] . '')->execute('getRows');
                     foreach ($aSavedStyles as $aSavedStyle) {
                         $aCacheStyles[$aSavedStyle['module_id'] ? $aSavedStyle['module_id'] : null][$aSavedStyle['file_name']] = true;
                     }
                     $oFileCache->save($sFileThemeCssId, $aCacheStyles);
                 }
             }
         }
         ($sPlugin = Phpfox_Plugin::get('template_getheader')) ? eval($sPlugin) : false;
         $sJs .= "\t\t\tvar oCore = {'core.is_admincp': " . (Phpfox::isAdminPanel() ? 'true' : 'false') . ", 'core.section_module': '" . Phpfox::getLib('module')->getModuleName() . "', 'profile.is_user_profile': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? 'true' : 'false') . ", 'log.security_token': '" . Phpfox::getService('log.session')->getToken() . "', 'core.url_rewrite': '" . Phpfox::getParam('core.url_rewrite') . "', 'core.country_iso': '" . (Phpfox::isUser() ? Phpfox::getUserBy('country_iso') : '') . "', 'core.can_move_on_a_y_and_x_axis' : " . (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.can_move_on_a_y_and_x_axis') ? 'true' : 'false') . ", 'core.default_currency': '" . (defined('PHPFOX_INSTALLER') ? 'USD' : Phpfox::getService('core.currency')->getDefault()) . "', 'core.enabled_edit_area': " . (Phpfox::getParam('core.enabled_edit_area') ? 'true' : 'false') . ", 'core.disable_hash_bang_support': " . (Phpfox::getParam('core.disable_hash_bang_support') ? 'true' : 'false') . ", 'core.site_wide_ajax_browsing': " . (!defined('PHPFOX_IN_DESIGN_MODE') && Phpfox::getParam('core.site_wide_ajax_browsing') && !Phpfox::isAdminPanel() && Phpfox::isUser() ? 'true' : 'false') . ", 'profile.user_id': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? Phpfox::getService('profile')->getProfileUserId() : 0) . "};\n";
         // You are filtering out the controllers which should not load 'content' ajaxly, finding a way for pages.view/1/info and like that
         $sProgressCssFile = $this->getStyle('css', 'progress.css');
         $sStylePath = str_replace(Phpfox::getParam('core.path'), '', str_replace('progress.css', '', $sProgressCssFile));
         $aJsVars = array('sJsHome' => Phpfox::getParam('core.path'), 'sJsHostname' => $_SERVER['HTTP_HOST'], 'sSiteName' => Phpfox::getParam('core.site_title'), 'sJsStatic' => $oUrl->getDomain() . PHPFOX_STATIC, 'sJsStaticImage' => Phpfox::getParam('core.url_static_image'), 'sImagePath' => $this->getStyle('image'), 'sStylePath' => $this->getStyle('css'), 'sVersion' => Phpfox::getId(), 'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php', 'sStaticVersion' => $iVersion, 'sGetMethod' => PHPFOX_GET_METHOD, 'sDateFormat' => defined('PHPFOX_INSTALLER') ? '' : Phpfox::getParam('core.date_field_order'), 'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php', 'sEgiftStyle' => $this->getStyle('css', 'display.css', 'egift'), 'sGlobalTokenName' => Phpfox::getTokenName(), 'sController' => Phpfox::getLib('module')->getFullControllerName(), 'bJsIsMobile' => Phpfox::isMobile() ? true : false, 'sProgressCssFile' => $sProgressCssFile, 'sHostedVersionId' => defined('PHPFOX_IS_HOSTED_VERSION') ? PHPFOX_IS_HOSTED_VERSION : '');
         if (!defined('PHPFOX_INSTALLER')) {
             $aJsVars['bWysiwyg'] = Phpfox::getParam('core.wysiwyg') != 'default' && Phpfox::getParam('core.allow_html') ? true : false;
             $aJsVars['sEditor'] = Phpfox::getParam('core.wysiwyg');
             $aJsVars['sJsCookiePath'] = Phpfox::getParam('core.cookie_path');
             $aJsVars['sJsCookieDomain'] = Phpfox::getParam('core.cookie_domain');
             $aJsVars['sJsCookiePrefix'] = Phpfox::getParam('core.session_prefix');
             $aJsVars['bPhotoTheaterMode'] = Phpfox::isModule('photo') ? Phpfox::getParam('photo.view_photos_in_theater_mode') : false;
             $aJsVars['bUseHTML5Video'] = Phpfox::getParam('video.upload_for_html5') ? true : false;
             if (Phpfox::isAdmin()) {
                 $aJsVars['sAdminCPLocation'] = Phpfox::getParam('admincp.admin_cp');
             } else {
                 $aJsVars['sAdminCPLocation'] = '';
             }
             if (Phpfox::isModule('notification')) {
                 $aJsVars['notification.notify_ajax_refresh'] = Phpfox::getParam('notification.notify_ajax_refresh');
             }
             if (Phpfox::isModule('im')) {
                 if (Phpfox::isUser()) {
                     $aJsVars['im_beep'] = Phpfox::getUserBy('im_beep');
                 }
                 $this->setHeader(array('player/' . Phpfox::getParam('core.default_music_player') . '/core.js' => 'static_script'));
                 $aJsVars['im_interval_for_update'] = Phpfox::getParam('im.js_interval_value');
                 if (Phpfox::getParam('im.server_for_ajax_calls') != '') {
                     $aJsVars['im_server'] = Phpfox::getParam('im.server_for_ajax_calls');
                 }
             } elseif (Phpfox::isModule('video')) {
                 $this->setHeader(array('player/' . Phpfox::getParam('core.default_music_player') . '/core.js' => 'static_script'));
             }
             $sLocalDatepicker = PHPFOX_STATIC . 'jscript/jquery/locale/jquery.ui.datepicker-' . strtolower(Phpfox::getLib('locale')->getLangId()) . '.js';
             if (file_exists($sLocalDatepicker)) {
                 $sFile = str_replace(PHPFOX_STATIC . 'jscript/', '', $sLocalDatepicker);
                 $this->setHeader(array($sFile => 'static_script'));
             }
             /* Only in a few cases will we want to add the visitor's IP */
             if (Phpfox::getParam('core.google_api_key') != '' && Phpfox::getParam('core.ip_infodb_api_key')) {
                 // $aJsVars['sIP'] = Phpfox::getLib('request')->getIp();
             }
             $aJsVars['bEnableMicroblogSite'] = Phpfox::isModule('microblog') ? Phpfox::getParam('microblog.enable_microblog_site') : false;
         }
         ($sPlugin = Phpfox_Plugin::get('template_getheader_setting')) ? eval($sPlugin) : false;
         if (Phpfox::isModule('input') && false) {
             $this->setHeader('cache', array('browse.css' => 'style_css'));
         }
         $sJs .= "\t\t\tvar oParams = {";
         $iCnt = 0;
         foreach ($aJsVars as $sVar => $sValue) {
             $iCnt++;
             if ($iCnt != 1) {
                 $sJs .= ",";
             }
             if (is_bool($sValue)) {
                 $sJs .= "'{$sVar}': " . ($sValue ? 'true' : 'false');
             } elseif (is_numeric($sValue)) {
                 $sJs .= "'{$sVar}': " . $sValue;
             } else {
                 $sJs .= "'{$sVar}': '" . str_replace("'", "\\'", $sValue) . "'";
             }
         }
         $sJs .= "};\n";
         if (!defined('PHPFOX_INSTALLER')) {
             $aLocaleVars = array('core.are_you_sure', 'core.yes', 'core.no', 'core.save', 'core.cancel', 'core.go_advanced', 'core.processing', 'emoticon.emoticons', 'attachment.attach_files', 'core.close', 'core.language_packages', 'core.move_this_block', 'core.uploading', 'language.loading', 'core.saving', 'core.loading_text_editor', 'core.quote', 'core.loading');
             if (Phpfox::isModule('im') && Phpfox::getParam('im.enable_im_in_footer_bar')) {
                 $aLocaleVars[] = 'im.find_your_friends';
             }
             ($sPlugin = Phpfox_Plugin::get('template_getheader_language')) ? eval($sPlugin) : false;
             $sJs .= "\t\t\tvar oTranslations = {";
             $iCnt = 0;
             foreach ($aLocaleVars as $sValue) {
                 $aParts = explode('.', $sValue);
                 if ($aParts[0] != 'core' && !Phpfox::isModule($aParts[0])) {
                     continue;
                 }
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sValue}': '" . html_entity_decode(str_replace("'", "\\'", Phpfox::getPhrase($sValue)), null, 'UTF-8') . "'";
             }
             $sJs .= "};\n";
             $aModules = Phpfox::getLib('module')->getModules();
             $sJs .= "\t\t\tvar oModules = {";
             $iCnt = 0;
             foreach ($aModules as $sModule => $iModuleId) {
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sModule}': true";
             }
             $sJs .= "};\n";
         }
         if (count($this->_aImages)) {
             $sJs .= "\t\t\tvar oJsImages = {";
             foreach ($this->_aImages as $sKey => $sImage) {
                 $sJs .= $sKey . ': \'' . $sImage . '\',';
             }
             $sJs = rtrim($sJs, ',');
             $sJs .= "};\n";
         }
         /*
         if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active'])
         {
         */
         $aEditorButtons = Phpfox::getLib('editor')->getButtons();
         $iCnt = 0;
         $sJs .= "\t\t\tvar oEditor = {";
         if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active']) {
             foreach ($this->_aEditor as $sVar => $mValue) {
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sVar}': " . (is_bool($mValue) ? $mValue === true ? 'true' : 'false' : "'{$mValue}'") . "";
             }
             $sJs .= ", ";
         }
         $sJs .= "images:[";
         foreach ($aEditorButtons as $mEditorButtonKey => $aEditorButton) {
             $sJs .= "{";
             foreach ($aEditorButton as $sEditorButtonKey => $sEditorButtonValue) {
                 $sJs .= "" . $sEditorButtonKey . ": '" . $sEditorButtonValue . "',";
             }
             $sJs = rtrim($sJs, ',') . "},";
         }
         $sJs = rtrim($sJs, ',') . "]";
         $sJs .= "};\n";
         // }
         if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn')) {
             $sData .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/' . Phpfox::getParam('core.jquery_google_cdn_version') . '/jquery.min.js"></script>' . "\n";
         }
     }
     if (PHPFOX_IS_AJAX_PAGE) {
         $this->_aCacheHeaders = array();
     }
     $bIsHttpsPage = false;
     if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.force_https_secure_pages')) {
         if (in_array(str_replace('mobile.', '', Phpfox::getLib('module')->getFullControllerName()), Phpfox::getService('core')->getSecurePages()) && (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
             $bIsHttpsPage = true;
         }
     }
     $aSubCache = array();
     $sStyleCacheData = '';
     $sJsCacheData = '';
     $aUrl = Phpfox::getLib('url')->getParams();
     // These two arrays hold the files to be combined+minified and put in CDN (if available)
     $aCacheJs = array();
     $aCacheCSS = array();
     $this->_sFooter = '';
     $sJs .= "\t\t\t" . 'var $Behavior = {};' . "\n";
     $sJs .= "\t\t\t" . 'var $Core = {};' . "\n";
     if (Phpfox::getParam('core.defer_loading_user_images') || Phpfox::getParam('core.defer_loading_images')) {
         $this->setHeader('cache', array('defer_image.js' => 'module_core'));
     }
     if (Phpfox::getParam('core.include_master_files')) {
         $aMasterJS = array();
         $aMasterCSS = array();
     }
     $aCustomCssFile = array();
     foreach ($this->_aHeaders as $aHeaders) {
         if (!is_array($aHeaders)) {
             $aHeaders = array($aHeaders);
         }
         foreach ($aHeaders as $mKey => $mValue) {
             $sQmark = strpos($mKey, '?') ? '&amp;' : '?';
             if (is_numeric($mKey)) {
                 if ($mValue === null) {
                     continue;
                 }
                 if ($bReturnArray) {
                     $aArrayData[] = $mValue;
                 } else {
                     if (is_string($mValue) && (strpos($mValue, '.js') !== false || strpos($mValue, 'javascript') !== false)) {
                         if (strpos($mValue, 'RecaptchaOptions')) {
                             $sData .= "\t\t" . $mValue . "\n";
                         } else {
                             $this->_sFooter .= "\t\t" . $mValue;
                         }
                     } else {
                         if (is_string($mValue)) {
                             $sData .= "\t\t" . $mValue . "\n";
                         } else {
                             $sData .= "\t\t" . implode($mValue) . "\n";
                         }
                     }
                 }
             } else {
                 if ($mKey == 'master') {
                     $aMaster = array('css' => array(), 'jscript' => array());
                     foreach ($mValue as $sValKey => $sValVal) {
                         if (strpos($sValKey, '.css') !== false) {
                             if ($sValVal == 'style_css') {
                                 $aMaster['css'][] = 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $this->getThemeFolder() . PHPFOX_DS . 'style' . PHPFOX_DS . $this->getStyleFolder() . PHPFOX_DS . 'css' . PHPFOX_DS . $sValKey;
                             } else {
                                 if (strpos($sValVal, 'module_') !== false) {
                                     $aMaster['css'][] = 'module' . PHPFOX_DS . str_replace('module_', '', $sValVal) . PHPFOX_DS . 'static' . PHPFOX_DS . 'css' . PHFPFOX_DS . $this->getThemeFolder() . PHPFOX_DS . $this->getStyleFolder() . PHPFOX_DS . $sValKey;
                                 }
                             }
                         } else {
                             if (strpos($sValKey, '.js') !== false) {
                                 if ($sValVal == 'static_script') {
                                     $aMaster['jscript'][] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $sValKey;
                                 } else {
                                     if (strpos($sValVal, 'module_') !== false) {
                                         $aMaster['jscript'][] = 'module' . PHPFOX_DS . str_replace('module_', '', $sValVal) . PHPFOX_DS . 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $sValKey;
                                     }
                                 }
                             }
                         }
                     }
                     unset($this->_aHeaders[$mKey]);
                     // just to avoid confusions
                     $this->_aHeaders['master'] = $aMaster;
                 } else {
                     $bToHead = false;
                     // This happens when the developer needs something to go to <head>
                     if (is_array($mValue)) {
                         $aKeyHead = array_keys($mValue);
                         $aKeyValue = array_values($mValue);
                         $bToHead = $mKey == 'head';
                         $mKey = array_pop($aKeyHead);
                         $mValue = array_pop($aKeyValue);
                     }
                     switch ($mValue) {
                         case 'style_script':
                             if (isset($aSubCache[$mKey][$mValue])) {
                                 continue;
                             }
                             if ($bReturnArray) {
                                 $aArrayData[] = $this->getStyle('jscript', $mKey);
                             } else {
                                 //$sJsCacheData .= str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey)) . ',';
                                 if ($bToHead == 'head') {
                                     $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey));
                                 } else {
                                     $aCacheJs[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey));
                                 }
                             }
                             break;
                         case 'style_css':
                             $bCustomStyle = false;
                             if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel()) {
                                 if (isset($aCacheStyles[null][$mKey])) {
                                     if (defined('PHPFOX_IS_HOSTED_SCRIPT')) {
                                         $sCssCustomCacheId = $oCache->set($this->_aTheme['style_id'] . '_custom_css_file');
                                     } else {
                                         if ($bIsHttpsPage) {
                                             $sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_secure_' . $mKey);
                                         } else {
                                             $sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey);
                                         }
                                     }
                                     if (!($aCss = defined('PHPFOX_IS_HOSTED_SCRIPT') ? $oCache->get($sCssCustomCacheId) : $oCache->isCached($sCssCustomCacheId))) {
                                         $oDb = Phpfox::getLib('database');
                                         $aCss = $oDb->select('tc.css_id, tc.css_data, tc.css_data_original')->from(Phpfox::getT('theme_css'), 'tc')->where('style_id = ' . (int) $this->_aTheme['style_id'] . ' AND file_name = \'' . $oDb->escape($mKey) . '\'')->execute('getRow');
                                         if (isset($aCss['css_id'])) {
                                             $oCache->save($sCssCustomCacheId, defined('PHPFOX_IS_HOSTED_SCRIPT') ? $aCss : Phpfox::getLib('file.minimize')->css($aCss['css_data']));
                                             $bCustomStyle = true;
                                         }
                                     } else {
                                         if (defined('PHPFOX_IS_HOSTED_SCRIPT') && isset($aCss['css_id'])) {
                                             $bCustomStyle = true;
                                         } else {
                                             if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey)) {
                                                 $bCustomStyle = true;
                                             }
                                         }
                                     }
                                 } else {
                                     if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey)) {
                                         $bCustomStyle = true;
                                     }
                                 }
                             }
                             if ($bCustomStyle === false) {
                                 if ($bReturnArray) {
                                     $aArrayData[] = $this->getStyle('css', $mKey);
                                 } else {
                                     $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey));
                                 }
                             } else {
                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT')) {
                                     $bLoadCustomThemeOverwrite = true;
                                 } else {
                                     if ($bReturnArray) {
                                         $aArrayData[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey;
                                     } else {
                                         if (isset($this->_aCacheHeaders[$mKey])) {
                                             // $sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . ',';
                                             $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '';
                                         } else {
                                             if ($bIsHttpsPage) {
                                                 //$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_secure_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
                                                 $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_secure_' . $mKey;
                                             } else {
                                                 //$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
                                                 $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey;
                                             }
                                         }
                                     }
                                 }
                             }
                             break;
                         case 'static_script':
                             if (isset($aSubCache[$mKey][$mValue])) {
                                 continue;
                             }
                             if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn')) {
                                 if ($mKey == 'jquery/ui.js' || $mKey == 'jquery/jquery.js') {
                                     if ($mKey == 'jquery/ui.js') {
                                         $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/' . Phpfox::getParam('core.jquery_ui_google_cdn_version') . '/jquery-ui.min.js"></script>' . "\n";
                                     }
                                     continue;
                                 }
                             }
                             if ($bReturnArray) {
                                 $aArrayData[] = Phpfox::getParam('core.url_static_script') . $mKey;
                             } else {
                                 if (isset($this->_aCacheHeaders[$mKey])) {
                                     // $sJsCacheData .= $mKey . ',';
                                     if ($bToHead == 'head') {
                                         $aCacheCSS[] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $mKey;
                                     } else {
                                         $aCacheJs[] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $mKey;
                                     }
                                 } else {
                                     //$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static_script') . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                     if ($bToHead == 'head') {
                                         $aCacheCSS[] = 'static/jscript/' . $mKey;
                                     } else {
                                         $aCacheJs[] = 'static/jscript/' . $mKey;
                                     }
                                 }
                             }
                             break;
                         default:
                             if (preg_match('/module/i', $mValue)) {
                                 $aParts = explode('_', $mValue);
                                 if (isset($aParts[1]) && Phpfox::isModule($aParts[1])) {
                                     if (substr($mKey, -3) == '.js') {
                                         if ($bReturnArray) {
                                             $aArrayData[] = Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                         } else {
                                             if (isset($this->_aCacheHeaders[$mKey])) {
                                                 //$sJsCacheData .= 'module/' . $aParts[1] . '/static/jscript/' . $mKey . ',';
                                                 $aCacheJs[] = 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                             } else {
                                                 /*
                                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT'))
                                                 {
                                                 	$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getCdnPath() . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                                 }	
                                                 else
                                                 {
                                                 */
                                                 //$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                                 $aCacheJs[] = 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                                 // }
                                             }
                                         }
                                     } elseif (substr($mKey, -4) == '.css') {
                                         $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                         $bCustomStyle = false;
                                         if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel()) {
                                             if (isset($aCacheStyles[$aParts[1]][$mKey])) {
                                                 $sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey);
                                                 if (!$oCache->isCached($sCssCustomCacheId)) {
                                                     $oDb = Phpfox::getLib('database');
                                                     $aCss = $oDb->select('tc.css_id, tc.css_data')->from(Phpfox::getT('theme_css'), 'tc')->where('module_id = \'' . $oDb->escape($aParts[1]) . '\' AND style_id = ' . (int) $this->_aTheme['style_id'] . ' AND file_name = \'' . $oDb->escape($mKey) . '\'')->execute('getRow');
                                                     if (isset($aCss['css_id'])) {
                                                         $oCache->save($sCssCustomCacheId, Phpfox::getLib('file.minimize')->css($aCss['css_data']));
                                                         $bCustomStyle = true;
                                                     }
                                                 } else {
                                                     if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey)) {
                                                         $bCustomStyle = true;
                                                     }
                                                 }
                                             } else {
                                                 if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey)) {
                                                     $bCustomStyle = true;
                                                 }
                                             }
                                         }
                                         if ($bCustomStyle === false) {
                                             if ($bReturnArray) {
                                                 //$aArrayData[] = $this->getStyle('css', $mKey, $aParts[1]);
                                                 $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                             } else {
                                                 /*
                                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT'))
                                                 {
                                                     $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . str_replace(Phpfox::getParam('core.path'), Phpfox::getCdnPath(), $this->getStyle('css', $mKey, $aParts[1])) . $sQmark . 'v=' . $iVersion . '" />' . "\n";
                                                 }
                                                 else
                                                 {
                                                 */
                                                 $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                                 // }
                                             }
                                         } else {
                                             //$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey . ',';
                                             $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey;
                                         }
                                     }
                                 }
                             }
                             break;
                     }
                     $aSubCache[$mKey][$mValue] = true;
                 }
             }
         }
     }
     $sCacheData = '';
     $sCacheData .= "\n\t\t<script type=\"text/javascript\">\n";
     $sCacheData .= $sJs;
     $sCacheData .= "\t\t</script>";
     if (!empty($sStyleCacheData)) {
         $sCacheData .= "\n\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=css&amp;s=' . $sStylePath . '&amp;f=' . rtrim($sStyleCacheData, ',') . '&amp;v=' . $iVersion . '" />';
     }
     if (!empty($sJsCacheData)) {
         $sCacheData .= "\n\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=js&amp;f=' . rtrim($sJsCacheData, ',') . '&amp;v=' . $iVersion . '"></script>';
     }
     if (Phpfox::getParam('core.include_master_files') && Phpfox::isAdminPanel() != true && isset($this->_aHeaders['master'])) {
         // $this->_aHeaders[master] is created in the foreach above and it takes the files listed in Phpfox::getMasterFiles
         $aMasterFiles = $this->_aHeaders['master'];
         require_once PHPFOX_DIR_LIB . 'jsmin/jsmin2.class.php';
         // if the file doesnt exist load the default ones
         if ($this->_sThemeFolder != 'default' || $this->_sStyleFolder != 'default') {
             foreach ($aMasterFiles['css'] as $iKey => $sFile) {
                 if (file_exists(PHPFOX_DIR . $sFile) != true) {
                     // include the default master file
                     $sFile = str_replace($this->getThemeFolder(), 'default', $sFile);
                     $sFile = str_replace($this->getStyleFolder(), 'default', $sFile);
                     $aMasterFiles['css'][$iKey] = $sFile;
                 }
             }
         }
         $sMasterCSSUrl = Phpfox::getLib('file.minimize')->minify($aMasterFiles['css'], $sQmark . 'v=' . $iVersion, false);
         $sCacheData .= "\n\t\t" . '<!-- CSS Master --> <link rel="stylesheet" type="text/css" href="' . $sMasterCSSUrl . '" />';
         $sMasterJSUrl = Phpfox::getLib('file.minimize')->minify($aMasterFiles['jscript'], $sQmark . 'v=' . $iVersion, true);
         $this->_sFooter .= "\n\t\t" . '<!-- JS Master --> <script type="text/javascript" src="' . $sMasterJSUrl . '"></script>';
     }
     if (!empty($sCacheData)) {
         $sData = preg_replace('/<link rel="shortcut icon" type="image\\/x-icon" href="(.*?)" \\/>/i', '<link rel="shortcut icon" type="image/x-icon" href="\\1" />' . $sCacheData, $sData);
     }
     if ($bReturnArray) {
         $sData = '';
     }
     $aCacheJs = array_unique($aCacheJs);
     if (Phpfox::getParam('core.cache_js_css')) {
         $aJqueryPlugins = array();
         foreach ($aCacheJs as $iKey => $sFile) {
             //  if ( (strpos($sFile, 'jquery') !== false) && (strpos($sFile, 'plugin') !== false) )
             if (strpos($sFile, 'jquery') !== false) {
                 // We minify JQuery plug-ins in their own file
                 $aJqueryPlugins[] = $sFile;
                 unset($aCacheJs[$iKey]);
             }
             if ($sFile == 'static/jscript/wysiwyg/tiny_mce/tiny_mce.js') {
                 $this->_sFooter .= "\n\t\t" . '<!-- TinyMCE --> <script type="text/javascript" src="' . Phpfox::getParam('core.path') . $sFile . '?v=' . $iVersion . '"></script>' . "";
                 unset($aCacheJs[$iKey]);
             }
         }
         require_once PHPFOX_DIR_LIB . 'jsmin/jsmin2.class.php';
         if (!empty($aJqueryPlugins)) {
             $sPluginsUrl = Phpfox::getLib('file.minimize')->minify($aJqueryPlugins, $sQmark . 'v=' . $iVersion, true);
             $this->_sFooter .= "\n\t\t" . '<!-- JQuery Plugins --> <script type="text/javascript" src="' . $sPluginsUrl . '"></script>' . "";
         }
         if (!empty($aCacheJs)) {
             $aCacheJs = array_unique($aCacheJs);
             $sJsUrl = Phpfox::getLib('file.minimize')->minify($aCacheJs, $sQmark . 'v=' . $iVersion, true, true);
             $this->_sFooter .= "\n\t\t" . '<!-- Minified --> <script type="text/javascript" src="' . $sJsUrl . '"></script>' . "";
         }
         if (!empty($aCacheCSS)) {
             $sCSSUrl = Phpfox::getLib('file.minimize')->minify($aCacheCSS, $sQmark . 'v=' . $iVersion, false);
             $sData .= "\n\t\t" . '<!-- Minified --> <link rel="stylesheet" type="text/css" href="' . $sCSSUrl . '" />' . "";
         }
         if (!empty($aCustomCssFile)) {
             foreach ($aCustomCssFile as $sCustomCssFile) {
                 $sData .= "\n\t\t" . '<!-- Custom --> <link rel="stylesheet" type="text/css" href="' . $sCustomCssFile . '" />' . "";
             }
         }
     } else {
         $aSubCacheCheck = array();
         foreach ($aCacheCSS as $sFile) {
             if (defined('PHPFOX_INSTALLER')) {
                 $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . $sFile . $sQmark . 'v=' . $iVersion . '" />' . "\n";
             } else {
                 if (isset($aSubCacheCheck[$sFile])) {
                     continue;
                 }
                 $aSubCacheCheck[$sFile] = true;
                 $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.path') . $sFile . $sQmark . 'v=' . $iVersion . '" />' . "\n";
             }
         }
         if (!empty($aCustomCssFile)) {
             foreach ($aCustomCssFile as $sCustomCssFile) {
                 $sData .= "\n\t\t" . '<!-- Custom --> <link rel="stylesheet" type="text/css" href="' . $sCustomCssFile . '" />' . "";
             }
         }
         if (Phpfox::getParam('core.defer_loading_js')) {
         } else {
             foreach ($aCacheJs as $sFile) {
                 if (defined('PHPFOX_INSTALLER')) {
                     $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="../' . $sFile . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                 } else {
                     $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . $sFile . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                 }
             }
         }
         if (!defined('PHPFOX_INSTALLER')) {
             $this->_sFooter .= "\t\t" . '<script type="text/javascript"> $Core.init(); </script>' . "\n";
         }
     }
     if (defined('PHPFOX_TEMPLATE_CSS_FILE')) {
         //$this->setHeader(PHPFOX_TEMPLATE_CSS_FILE);
         $sData .= PHPFOX_TEMPLATE_CSS_FILE;
     }
     // And in its own file custom.css maybe check if its not empty like when using the default theme
     /*
             $sCustomFile = 'theme/' . (Phpfox::isAdminPanel() ? 'adminpanel' : (Phpfox::isMobile() ? 'mobile' : 'frontend')) . '/' . $this->getThemeFolder() . '/style/' . $this->getStyleFolder() . '/css/custom.css';
             
             if (Phpfox::getParam('core.cache_js_css') && file_exists(PHPFOX_DIR . $sCustomFile) && filesize(PHPFOX_DIR . $sCustomFile) > 0)
             {
     	$sCustomUrl = Phpfox::getLib('file.minimize')->minify($sCustomFile, $sQmark . 'v=' . $iVersion, false);
     	$sData .= "\n\t\t" . '<!-- Custom --> <link rel="stylesheet" type="text/css" href="' . $sCustomUrl .'" />';
     }
     */
     if (count($this->_aPhrases)) {
         $sData .= "\n\t\t<script type=\"text/javascript\">\n\t\t";
         foreach ($this->_aPhrases as $sVar => $sPhrase) {
             $sPhrase = html_entity_decode($sPhrase, null, 'UTF-8');
             $sData .= "\t\t\toTranslations['{$sVar}'] = '" . str_replace("'", "\\'", $sPhrase) . "';\n";
         }
         $sData .= "\t\t</script>\n";
     }
     if ($bReturnArray) {
         $aArrayData[] = $sData;
         return $aArrayData;
     }
     // Convert meta data
     $bHasNoDescription = false;
     if (count($this->_aMeta) && !PHPFOX_IS_AJAX_PAGE && !defined('PHPFOX_INSTALLER')) {
         $oPhpfoxParseOutput = Phpfox::getLib('parse.output');
         $aFind = array('&lt;', '&gt;', '$');
         $aReplace = array('<', '>', '&36;');
         foreach ($this->_aMeta as $sMeta => $sMetaValue) {
             $sMetaValue = str_replace($aFind, $aReplace, $sMetaValue);
             $sMetaValue = strip_tags($sMetaValue);
             $sMetaValue = str_replace(array("\n", "\r"), "", $sMetaValue);
             $bIsCustomMeta = false;
             switch ($sMeta) {
                 case 'keywords':
                     $sKeywordSearch = Phpfox::getParam('core.words_remove_in_keywords');
                     if (!empty($sKeywordSearch)) {
                         $aKeywordsSearch = array_map('trim', explode(',', $sKeywordSearch));
                     }
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_keyword_limit'));
                     $sMetaValue = trim(rtrim(trim($sMetaValue), ','));
                     $aParts = explode(',', $sMetaValue);
                     $sMetaValue = '';
                     $aKeywordCache = array();
                     foreach ($aParts as $sPart) {
                         $sPart = trim($sPart);
                         if (isset($aKeywordCache[$sPart])) {
                             continue;
                         }
                         if (isset($aKeywordsSearch) && in_array(strtolower($sPart), array_map('strtolower', $aKeywordsSearch))) {
                             continue;
                         }
                         $sMetaValue .= $sPart . ', ';
                         $aKeywordCache[$sPart] = true;
                     }
                     $sMetaValue = rtrim(trim($sMetaValue), ',');
                     break;
                 case 'description':
                     $bHasNoDescription = true;
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
                     break;
                 case 'robots':
                     $bIsCustomMeta = false;
                     break;
                 default:
                     $bIsCustomMeta = true;
                     break;
             }
             $sMetaValue = str_replace('"', '\\"', $sMetaValue);
             $sMetaValue = Phpfox::getLib('locale')->convert($sMetaValue);
             $sMetaValue = html_entity_decode($sMetaValue, null, 'UTF-8');
             $sMetaValue = str_replace(array('<', '>'), '', $sMetaValue);
             if ($bIsCustomMeta) {
                 if ($sMeta == 'og:description') {
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
                 }
                 switch ($sMeta) {
                     case 'canonical':
                         $sCanonical = $sMetaValue;
                         $sCanonical = preg_replace('/\\/when\\_([a-zA-Z0-9\\-]+)\\//i', '/', $sCanonical);
                         $sCanonical = preg_replace('/\\/show\\_([a-zA-Z0-9\\-]+)\\//i', '/', $sCanonical);
                         $sCanonical = preg_replace('/\\/view\\_\\//i', '/', $sCanonical);
                         if (Phpfox::isMobile()) {
                             if (Phpfox::getParam('core.url_rewrite') == '1') {
                                 $sCanonical = str_replace(Phpfox::getParam('core.path') . 'mobile/', Phpfox::getParam('core.path'), $sMetaValue);
                             } elseif (Phpfox::getParam('core.url_rewrite') == '2') {
                                 $sCanonical = str_replace('?' . PHPFOX_GET_METHOD . '=/mobile/', '?' . PHPFOX_GET_METHOD . '=/', $sMetaValue);
                             }
                         }
                         $sData .= "\t\t<link rel=\"canonical\" href=\"{$sCanonical}\" />\n";
                         if (!Phpfox::isMobile()) {
                             $sMobileReplace = '';
                             if (Phpfox::getParam('core.url_rewrite') == '1') {
                                 $sMobileReplace = str_replace(Phpfox::getParam('core.path'), Phpfox::getParam('core.path') . 'mobile/', $sCanonical);
                             } elseif (Phpfox::getParam('core.url_rewrite') == '2') {
                                 $sMobileReplace = str_replace('?' . PHPFOX_GET_METHOD . '=/', '?' . PHPFOX_GET_METHOD . '=/mobile/', $sCanonical);
                             }
                             $sData .= "\t\t<link rel=\"alternate\" media=\"only screen and (max-width: 640px)\" href=\"{$sMobileReplace}\" />\n";
                         }
                         break;
                     default:
                         $sData .= "\t\t<meta property=\"{$sMeta}\" content=\"{$sMetaValue}\" />\n";
                         break;
                 }
             } else {
                 if (strpos($sData, 'meta name="' . $sMeta . '"') !== false) {
                     $sData = preg_replace("/<meta name=\"{$sMeta}\" content=\"(.*?)\" \\/>\n\t/i", "<meta" . ($sMeta == 'description' ? ' property="og:description" ' : '') . " name=\"{$sMeta}\" content=\"" . $sMetaValue . "\" />\n\t", $sData);
                 } else {
                     $sData = preg_replace('/<meta/', '<meta name="' . $sMeta . '" content="' . $sMetaValue . '" />' . "\n\t\t" . '<meta', $sData, 1);
                 }
             }
         }
         if (!$bHasNoDescription) {
             $sData .= "\t\t" . '<meta name="description" content="' . Phpfox::getLib('parse.output')->clean(Phpfox::getLib('locale')->convert(Phpfox::getParam('core.description'))) . '" />' . "\n";
         }
     }
     // Clear from memory
     $this->_aHeaders = array();
     $this->_aMeta = array();
     if (isset($bLoadCustomThemeOverwrite)) {
         $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.rackspace_url') . 'file/static/' . $aCss['css_data_original'] . '" />' . "\n";
     }
     return $sData;
 }
Beispiel #5
0
 public function addHook($aVals)
 {
     if ($this->database()->select('COUNT(*)')->from(Phpfox::getT('plugin_hook'))->where('call_name = \'' . $this->database()->escape($aVals['call_name']) . '\'')->execute('getField')) {
         return Phpfox_Error::set(Phpfox::getPhrase('admincp.hook_already_exists'));
     }
     $this->database()->insert(Phpfox::getT('plugin_hook'), array('hook_type' => $aVals['hook_type'], 'module_id' => empty($aVals['module_id']) ? null : $aVals['module_id'], 'product_id' => $aVals['product_id'], 'call_name' => $aVals['call_name'], 'added' => PHPFOX_TIME, 'version_id' => Phpfox::getId(), 'is_active' => (int) $aVals['is_active']));
     $this->cache()->remove();
     return true;
 }
Beispiel #6
0
	/**
	 * Gets any data we plan to place within the HTML tags <head></head>.
	 * This method also groups the data to give the template a nice clean look.
	 *
	 * @return string $sData Returns the HTML data to be placed within <head></head>
	 */
	public function getHeader($bReturnArray = false)
	{		
		if (Phpfox::isMobile())
		{				
			$this->setHeader(array(
					'mobile.css' => 'style_css'
				)
			);			
		}

		if (!defined('PHPFOX_INSTALLER'))
		{
			$this->setHeader(array(
					'custom.css' => 'style_css'
				)
			);
			
			if (defined('PHPFOX_TEMPLATE_CSS_FILE'))
			{
				$this->setHeader(PHPFOX_TEMPLATE_CSS_FILE);
			}
			
			$sCustomCss = '';			
			$aThemeCache = $this->getThemeCache();
			if (isset($aThemeCache['l_width']) && $aThemeCache['l_width'] > 0)
			{
				$sCustomCss .= '#left { width:' . (int) $aThemeCache['l_width'] . 'px; }';
				$sCustomCss .= '#main_content { margin-left:' . (int) $aThemeCache['l_width'] . 'px; }';
			}			
			if (isset($aThemeCache['c_width']) && $aThemeCache['c_width'] > 0)
			{
				$sCustomCss .= '.content3, .item_view .js_feed_comment_border, .item_view .item_tag_holder, .item_view .attachment_holder_view { width:' . (int) $aThemeCache['c_width'] . 'px; }';				
			}
			if (isset($aThemeCache['r_width']) && $aThemeCache['r_width'] > 0)
			{
				$sCustomCss .= '#right { width:' . (int) $aThemeCache['r_width'] . 'px; }';
				$sCustomCss .= '.content4 { width:' . (960 - (int) $aThemeCache['r_width']) . 'px; }';
			}

			if (!empty($sCustomCss))
			{
				$this->setHeader('<style type="text/css">' . $sCustomCss . '</style>');
			}			
		}
		$aArrayData = array();
		$sData = '';
		$sCss = '';
		$sJs = '';
		$iVersion = $this->getStaticVersion();
		$oUrl = Phpfox::getLib('url');		
		$oCache = Phpfox::getLib('cache', array(
				'storage' => 'file',
				'free' => true
			)
		);		
		$aUrl = $oUrl->getParams();
		if (Phpfox::getUserParam('core.can_design_dnd') && Phpfox::getService('theme')->isInDnDMode() && (!isset($aUrl['req2']) || $aUrl['req2'] != 'designer'))
		{
			define('PHPFOX_DESIGN_DND', true);
			/* .
			 * Tells if the user is Design mode with Drag and Drop support.
			 * Its important to note the difference in the purpose of this
			 * constant as it does Not tell if the user CAN enter DesignDND 
			 * mode but instead it tells if the user IS already in this 
			 * mode
			 * .
			 */
			$this->_aHeaders[] = array('designdnd.js' => 'module_theme');
		}
		else
		{
			if (!defined('PHPFOX_DESIGN_DND'))
			{
				define('PHPFOX_DESIGN_DND', false);
			}
		}
			
		if (!PHPFOX_IS_AJAX_PAGE)
		{
			if (!defined('PHPFOX_INSTALLER'))
			{
				if (!Phpfox::isAdminPanel())
				{
					$oDb = Phpfox::getLib('database');
					$oFileCache = Phpfox::getLib('cache');
					$sFileThemeCssId = $oFileCache->set(array('theme', 'theme_css' . $iVersion));
					$aCacheStyles = array();
					if (!($aCacheStyles = $oFileCache->get($sFileThemeCssId)))
					{
						$aSavedStyles = $oDb->select('tc.module_id, tc.file_name')
							->from(Phpfox::getT('theme_css'), 'tc')
							->where('style_id = ' . (int) $this->_aTheme['style_id'] . '')		
							->execute('getRows');
						foreach ($aSavedStyles as $aSavedStyle)
						{
							$aCacheStyles[($aSavedStyle['module_id'] ? $aSavedStyle['module_id'] : null)][$aSavedStyle['file_name']] = true;
						}			
						
						$oFileCache->save($sFileThemeCssId, $aCacheStyles);
					}					
				}
			}			
		
			(($sPlugin = Phpfox_Plugin::get('template_getheader')) ? eval($sPlugin) : false);
			
			$sJs .= "\t\t\tvar oCore = {'core.is_admincp': " . (Phpfox::isAdminPanel() ? 'true' : 'false') . ", 'core.section_module': '" . Phpfox::getLib('module')->getModuleName() . "', 'profile.is_user_profile': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? 'true' : 'false') . ", 'log.security_token': '" . Phpfox::getService('log.session')->getToken() . "', 'core.url_rewrite': '" . Phpfox::getParam('core.url_rewrite') . "', 'core.country_iso': '" . (Phpfox::isUser() ? Phpfox::getUserBy('country_iso') : '') . "', 'core.can_move_on_a_y_and_x_axis' : " . ((!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.can_move_on_a_y_and_x_axis')) ? 'true' : 'false') . ", 'core.default_currency': '" . (defined('PHPFOX_INSTALLER') ? 'USD' : Phpfox::getService('core.currency')->getDefault()) . "', 'core.enabled_edit_area': " . (Phpfox::getParam('core.enabled_edit_area') ? 'true' : 'false') . ", 'core.disable_hash_bang_support': " . (Phpfox::getParam('core.disable_hash_bang_support') ? 'true' : 'false') . ", 'core.site_wide_ajax_browsing': " . ((!defined('PHPFOX_IN_DESIGN_MODE') && Phpfox::getParam('core.site_wide_ajax_browsing') && !Phpfox::isAdminPanel() && Phpfox::isUser()) ? 'true' : 'false') . ", 'profile.user_id': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? Phpfox::getService('profile')->getProfileUserId() : 0) . "};\n";

			$sProgressCssFile = $this->getStyle('css', 'progress.css');
			$sStylePath = str_replace(Phpfox::getParam('core.path'), '', str_replace('progress.css', '', $sProgressCssFile));
			
			$aJsVars = array(
				'sJsHome' => Phpfox::getParam('core.path'),
				'sJsHostname' => $_SERVER['HTTP_HOST'],
				'sJsStatic' => $oUrl->getDomain() . PHPFOX_STATIC,
				'sJsStaticImage' => Phpfox::getParam('core.url_static_image'),
				'sImagePath' => $this->getStyle('image'),
				'sStylePath' => $this->getStyle('css'),
				'sVersion' => Phpfox::getId(),
				'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php',
				'sStaticVersion' => $iVersion,
				'sGetMethod' => PHPFOX_GET_METHOD,
				'sDateFormat' => (defined('PHPFOX_INSTALLER') ? '' : Phpfox::getParam('core.date_field_order')),
				'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php',
				'sEgiftStyle' => $this->getStyle('css','display.css','egift'),
				'sGlobalTokenName' => Phpfox::getTokenName(),
				'sController' => Phpfox::getLib('module')->getFullControllerName(),
				'bJsIsMobile' => (Phpfox::isMobile() ? true : false),
				'sProgressCssFile' => $sProgressCssFile
			);	
			
			if (!defined('PHPFOX_INSTALLER'))
			{
				$aJsVars['bWysiwyg'] = ((Phpfox::getParam('core.wysiwyg') != 'default' && Phpfox::getParam('core.allow_html')) ? true : false);
				$aJsVars['sEditor'] = Phpfox::getParam('core.wysiwyg');	
				$aJsVars['sJsCookiePath'] = Phpfox::getParam('core.cookie_path');
				$aJsVars['sJsCookieDomain'] = Phpfox::getParam('core.cookie_domain');
				$aJsVars['sJsCookiePrefix'] = Phpfox::getParam('core.session_prefix');	
				$aJsVars['bPhotoTheaterMode'] = (Phpfox::isModule('photo') ? Phpfox::getParam('photo.view_photos_in_theater_mode') : false);
				if (Phpfox::isAdmin())
				{
					$aJsVars['sAdminCPLocation'] = Phpfox::getParam('admincp.admin_cp');
				}
				else
				{
					$aJsVars['sAdminCPLocation'] = '';
				}
				if (Phpfox::isModule('notification'))
				{
					$aJsVars['notification.notify_ajax_refresh'] = Phpfox::getParam('notification.notify_ajax_refresh');
				}
				if (Phpfox::isModule('im'))
				{
					$aJsVars['im_interval_for_update'] = Phpfox::getParam('im.js_interval_value');
					if (Phpfox::getParam('im.server_for_ajax_calls') != '')
					{
						$aJsVars['im_server'] = Phpfox::getParam('im.server_for_ajax_calls');
					}
				}
			}
			
			(($sPlugin = Phpfox_Plugin::get('template_getheader_setting')) ? eval($sPlugin) : false);

			$sJs .= "\t\t\tvar oParams = {";
			$iCnt = 0;
			foreach ($aJsVars as $sVar => $sValue)
			{
				$iCnt++;
				if ($iCnt != 1)
				{
					$sJs .= ",";
				}
				
				if (is_bool($sValue))
				{
					$sJs .= "'{$sVar}': " . ($sValue ? 'true' : 'false');	
				}
				elseif (is_numeric($sValue))
				{
					$sJs .= "'{$sVar}': " . $sValue;	
				}
				else 
				{
					$sJs .= "'{$sVar}': '{$sValue}'";	
				}
			}			
			$sJs .= "};\n";		
			
			if (!defined('PHPFOX_INSTALLER'))
			{			
				$aLocaleVars = array(
					'core.are_you_sure',
					'core.yes',
					'core.no',
					'core.save',
					'core.cancel',
					'core.go_advanced',
					'core.processing',
					'emoticon.emoticons',
					'attachment.attach_files',
					'core.close',					
//					'core.toggle_fullscreen',	
					'core.language_packages',
					'core.move_this_block',
					'core.uploading',
					'language.loading',
					'core.saving',
					'core.loading_text_editor',
					'core.quote'
				);
				
				if (Phpfox::isModule('im') && Phpfox::getParam('im.enable_im_in_footer_bar'))
				{
					$aLocaleVars[] = 'im.find_your_friends';
				}
				
				(($sPlugin = Phpfox_Plugin::get('template_getheader_language')) ? eval($sPlugin) : false);
				
				$sJs .= "\t\t\tvar oTranslations = {";
				$iCnt = 0;
				foreach ($aLocaleVars as $sValue)
				{
					$aParts = explode('.', $sValue);
					
					if ($aParts[0] != 'core' && !Phpfox::isModule($aParts[0]))
					{
						continue;
					}					
					
					$iCnt++;
					if ($iCnt != 1)
					{
						$sJs .= ",";
					}
	
					$sJs .= "'{$sValue}': '" . html_entity_decode(str_replace("'", "\'", Phpfox::getPhrase($sValue)), null, 'UTF-8') . "'";
				}				
				$sJs .= "};\n";			
					
				$aModules = Phpfox::getLib('module')->getModules();
				$sJs .= "\t\t\tvar oModules = {";
				$iCnt = 0;
				foreach ($aModules as $sModule => $iModuleId)
				{
					$iCnt++;
					if ($iCnt != 1)
					{
						$sJs .= ",";
					}				
					$sJs .= "'{$sModule}': true";
				}
				$sJs .= "};\n";			
			}			

			if (count($this->_aImages))
			{
				$sJs .= "\t\t\tvar oJsImages = {";
				foreach ($this->_aImages as $sKey => $sImage)
				{
					$sJs .= $sKey . ': \'' . $sImage. '\',';
				}
				$sJs = rtrim($sJs, ',');
				$sJs .= "};\n";			
			}		
		
		/*
		if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active'])
		{
		*/
			$aEditorButtons = Phpfox::getLib('editor')->getButtons();
			
			$iCnt = 0;						
			$sJs .= "\t\t\tvar oEditor = {";
			
			if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active'])
			{
				foreach ($this->_aEditor as $sVar => $mValue)
				{
					$iCnt++;
					if ($iCnt != 1)
					{
						$sJs .= ",";
					}				
					$sJs .= "'{$sVar}': " . (is_bool($mValue) ? ($mValue === true ? 'true' : 'false') : "'{$mValue}'") . "";
				}
				
				$sJs .= ", ";
			}
			$sJs .= "images:[";
			foreach ($aEditorButtons as $mEditorButtonKey => $aEditorButton)
			{
				$sJs .= "{";
				foreach ($aEditorButton as $sEditorButtonKey => $sEditorButtonValue)			
				{
					$sJs .= "" . $sEditorButtonKey . ": '" . $sEditorButtonValue . "',";	
				}
				$sJs = rtrim($sJs, ',') . "},";
			}	
			$sJs = rtrim($sJs, ',') . "]";
			
			$sJs .= "};\n";	
		// }

			if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn'))
			{
				$sData .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/' . Phpfox::getParam('core.jquery_google_cdn_version') . '/jquery.min.js"></script>' . "\n";
			}
		}
		
		if (PHPFOX_IS_AJAX_PAGE)
		{
			$this->_aCacheHeaders = array();
		}
		
			$aSubCache = array();
			$sStyleCacheData = '';
			$sJsCacheData = '';		
			$aUrl = Phpfox::getLib('url')->getParams();
			
			foreach ($this->_aHeaders as $aHeaders)
			{
				if (!is_array($aHeaders))
				{
					$aHeaders = array($aHeaders);
				}			
				
				foreach ($aHeaders as $mKey => $mValue)
				{															
					$sQmark = (strpos($mKey, '?') ? '&amp;' : '?');
					
					if (is_numeric($mKey))
					{
						if ($mValue === null)
						{
							continue;
						}				

						if ($bReturnArray)
						{
							$aArrayData[] = $mValue;
						}
						else 
						{
							$sData .= "\t\t" . $mValue . "\n";
						}
					}
					else 
					{							
						switch ($mValue)
						{
							case 'style_script':
								
								if (isset($aSubCache[$mKey][$mValue]))
								{
									continue;
								}								
								
								if ($bReturnArray)
								{
									$aArrayData[] = $this->getStyle('jscript', $mKey);	
								}
								else 
								{
									if (isset($this->_aCacheHeaders[$mKey]))
									{
										$sJsCacheData .= str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey)) . ',';
									}
									else 
									{
										$sData .= "\t\t" . '<script type="text/javascript" src="' . $this->getStyle('jscript', $mKey) . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
									}
								}
							break;							
							case 'style_css':							
								$bCustomStyle = false;
								if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel())
								{
									if (isset($aCacheStyles[null][$mKey]))
									{
										$sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey);
										
										if (!($oCache->isCached($sCssCustomCacheId)))										
										{									
											$oDb = Phpfox::getLib('database');
											$aCss = $oDb->select('tc.css_id, tc.css_data')
												->from(Phpfox::getT('theme_css'), 'tc')
												->where('style_id = ' . (int) $this->_aTheme['style_id'] . ' AND file_name = \'' . $oDb->escape($mKey) . '\'')		
												->execute('getRow');
												
											if (isset($aCss['css_id']))
											{											
												$aCss['css_data'] = str_replace('../image/layout/', $this->getStyle('image') . 'layout/', $aCss['css_data']);
												
												$oCache->save($sCssCustomCacheId, Phpfox::getLib('file.minimize')->css($aCss['css_data']));												
												
												$bCustomStyle = true;
											}									
										}
										else 
										{
											if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey))
											{
												$bCustomStyle = true;
											}
										}								
									}
									else 
									{
										if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey))
										{
											$bCustomStyle = true;
										}										
									}
								}
							
								if ($bCustomStyle === false)
								{
									if ($bReturnArray)
									{
										$aArrayData[] = $this->getStyle('css', $mKey);
									}
									else 
									{
										if (isset($this->_aCacheHeaders[$mKey]))
										{
											$sStyleCacheData .= (Phpfox::isAdminPanel() ? str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey)) : $mKey) . ',';
										}
										else 
										{
											$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . $this->getStyle('css', $mKey) . $sQmark . 'v=' . $iVersion . '" />' . "\n";
										}
									}
								}
								else 
								{
									if (isset($this->_aCacheHeaders[$mKey]))
									{
										$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . ',';
									}
									else 
									{
										$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
									}									
								}
								
								break;
							case 'static_script':				
							
								if (isset($aSubCache[$mKey][$mValue]))
								{
									continue;
								}							
											
								if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn'))
								{											
									if ($mKey == 'jquery/ui.js' || $mKey == 'jquery/jquery.js')
									{				
										if ($mKey == 'jquery/ui.js')
										{					
											$sData .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/' . Phpfox::getParam('core.jquery_ui_google_cdn_version') . '/jquery-ui.min.js"></script>' . "\n";											
										}
										
										continue;
									}									
								}								
								
								if ($bReturnArray)
								{
									$aArrayData[] = Phpfox::getParam('core.url_static_script') . $mKey;	
								}
								else 
								{
									if (isset($this->_aCacheHeaders[$mKey]))
									{
										$sJsCacheData .= $mKey . ',';
									}
									else 
									{									
										$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static_script') . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
									}
								}
								break;
							default:							
								if (preg_match('/module/i', $mValue))
								{
									$aParts = explode('_', $mValue);
									if (isset($aParts[1]) && Phpfox::isModule($aParts[1]))
									{
										if (substr($mKey, -3) == '.js')
										{											
											if ($bReturnArray)
											{
												$aArrayData[] = Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
											}
											else 
											{
												if (isset($this->_aCacheHeaders[$mKey]))
												{
													$sJsCacheData .= 'module/' . $aParts[1] . '/static/jscript/' . $mKey . ',';
												}
												else 
												{																		
													$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
												}
											}
										}
										elseif (substr($mKey, -4) == '.css')
										{											
											$bCustomStyle = false;
											if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel())
											{											
												if (isset($aCacheStyles[$aParts[1]][$mKey]))
												{
													$sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey);
													
													if (!($oCache->isCached($sCssCustomCacheId)))										
													{									
														$oDb = Phpfox::getLib('database');
														$aCss = $oDb->select('tc.css_id, tc.css_data')
															->from(Phpfox::getT('theme_css'), 'tc')
															->where('module_id = \'' . $oDb->escape($aParts[1]) . '\' AND style_id = ' . (int) $this->_aTheme['style_id'] . ' AND file_name = \'' . $oDb->escape($mKey) . '\'')		
															->execute('getRow');
															
														if (isset($aCss['css_id']))
														{															
															$oCache->save($sCssCustomCacheId, Phpfox::getLib('file.minimize')->css($aCss['css_data']));																							
															
															$bCustomStyle = true;
														}									
													}
													else 
													{
														if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey))
														{
															$bCustomStyle = true;
														}
													}										
												}
												else 
												{
													if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey))
													{
														$bCustomStyle = true;
													}													
												}
											}
											
											if ($bCustomStyle === false)
											{
												if ($bReturnArray)
												{
													$aArrayData[] = $this->getStyle('css', $mKey, $aParts[1]);
												}
												else 
												{																								
													if (isset($this->_aCacheHeaders[$mKey]))
													{
														$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1])) . ',';	
													}
													else 
													{
														$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . $this->getStyle('css', $mKey, $aParts[1]) . $sQmark . 'v=' . $iVersion . '" />' . "\n";											
													}
												}
											}
											else 
											{
												if (isset($this->_aCacheHeaders[$mKey]))
												{
													$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey . ',';
												}
												else 
												{
													$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
												}												
											}
										}
									}
								}							
								break;							
							}
							
						$aSubCache[$mKey][$mValue] = true;
					}
				}
			}	
		
		$sCacheData = '';
		$sCacheData .= "\n\t\t<script type=\"text/javascript\">\n";
		$sCacheData .= $sJs;
		$sCacheData .= "\t\t</script>";			
		if (!empty($sStyleCacheData))
		{
			$sCacheData .= "\n\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=css&amp;s=' . $sStylePath . '&amp;f=' . rtrim($sStyleCacheData, ',') . '&amp;v=' . $iVersion . '" />';
		}
		
		if (!empty($sJsCacheData))
		{
			$sCacheData .= "\n\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=js&amp;f=' . rtrim($sJsCacheData, ',') . '&amp;v=' . $iVersion . '"></script>';
		}		
		
		if (!empty($sCacheData))
		{
			$sData = preg_replace('/<link rel="shortcut icon" type="image\/x-icon" href="(.*?)" \/>/i', '<link rel="shortcut icon" type="image/x-icon" href="\\1" />' . $sCacheData, $sData);
		}		
		
		if ($bReturnArray)
		{
			$sData = '';
		}
		
		if (count($this->_aPhrases))
		{
			$sData .= "\t\t<script type=\"text/javascript\">\n\t\t<!--\n";
			foreach ($this->_aPhrases as $sVar => $sPhrase)
			{
				$sData .= "\t\t\toTranslations['{$sVar}'] = '" . str_replace("'", "\'", $sPhrase) . "';\n";
			}
			$sData .= "\t\t-->\n\t\t</script>\n";
		}		
		
		if ($bReturnArray)
		{
			$aArrayData[] = $sData;			
			
			return $aArrayData;
		}
	
		// Convert meta data		
		if (count($this->_aMeta) && !PHPFOX_IS_AJAX_PAGE && !defined('PHPFOX_INSTALLER'))
		{
			$oPhpfoxParseOutput = Phpfox::getLib('parse.output');
			$aFind = array(
				'&lt;',
				'&gt;',
				'$'
			);
			$aReplace = array(
				'<',
				'>',
				'&36;'
			);			
			
			foreach ($this->_aMeta as $sMeta => $sMetaValue)
			{
				$sMetaValue = str_replace($aFind, $aReplace, $sMetaValue);
				$sMetaValue = strip_tags($sMetaValue);
				$sMetaValue = str_replace(array("\n", "\r"), "", $sMetaValue);		
				$bIsCustomMeta = false;
						
				switch ($sMeta)
				{
					case 'keywords':						
						$sKeywordSearch = Phpfox::getParam('core.words_remove_in_keywords');
						if (!empty($sKeywordSearch))
						{
							$aKeywordsSearch = array_map('trim', explode(',', $sKeywordSearch));							
						}
						$sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_keyword_limit'));
						$sMetaValue = trim(rtrim(trim($sMetaValue), ','));
						$aParts = explode(',', $sMetaValue);
						$sMetaValue = '';
						$aKeywordCache = array();
						foreach ($aParts as $sPart)
						{
							$sPart = trim($sPart);
							
							if (isset($aKeywordCache[$sPart]))
							{
								continue;
							}
							
							if (isset($aKeywordsSearch) && in_array(strtolower($sPart), array_map('strtolower', $aKeywordsSearch)))
							{
								continue;
							}
							
							$sMetaValue .= $sPart . ', ';
							
							$aKeywordCache[$sPart] = true;
						}
						$sMetaValue = rtrim(trim($sMetaValue), ',');
						break;
					case 'description':
						$sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
						break;
					default:
						$bIsCustomMeta = true;
						break;
				}
				$sMetaValue = str_replace('"', '\"', $sMetaValue);
				$sMetaValue = Phpfox::getLib('locale')->convert($sMetaValue);				
				$sMetaValue = html_entity_decode($sMetaValue, null, 'UTF-8');
				$sMetaValue = str_replace(array('<', '>'), '', $sMetaValue);		
				if ($bIsCustomMeta)
				{
					if ($sMeta == 'og:description')
					{
						$sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
					}
					
					$sData .= "\t\t<meta property=\"{$sMeta}\" content=\"{$sMetaValue}\" />\n";	
				}
				else 
				{
					$sData = preg_replace("/<meta name=\"{$sMeta}\" content=\"(.*?)\" \/>\n\t/i", "<meta name=\"{$sMeta}\" content=\"" . $sMetaValue . "\" />\n\t", $sData);
				}
			}
		}
			
		// Clear from memory
		$this->_aHeaders = array();		
		$this->_aMeta = array();		
		
		return $sData;
	}