public function getCode($sUrl, $sTitle, $aCustomVars = false)
 {
     $this->_addOpenGraphInfo($sTitle, isset($aCustomVars['img_url']) ? $aCustomVars['img_url'] : '');
     $aLang = bx_lang_info();
     // define markers for replacments
     $aMarkers = array('url' => $sUrl, 'url_encoded' => rawurlencode($sUrl), 'lang' => $GLOBALS['sCurrentLanguage'], 'locale' => $this->_getLocaleFacebook($aLang['LanguageCountry']), 'twit' => _t('_sys_social_sharing_twit'), 'title' => $sTitle, 'title_encoded' => rawurlencode($sTitle));
     if (!empty($aCustomVars) && is_array($aCustomVars)) {
         $aMarkers = array_merge($aMarkers, $aCustomVars);
     }
     // alert
     $sOverrideOutput = null;
     bx_import('BxDolAlerts');
     $oAlert = new BxDolAlerts('system', 'social_sharing_display', '', '', array('buttons' => &$this->_aSocialButtons, 'markers' => &$aMarkers, 'override_output' => &$sOverrideOutput));
     $oAlert->alert();
     // return custom code if there is one
     if ($sOverrideOutput) {
         return $sOverrideOutput;
     }
     // return empty string of there is no buttons
     if (empty($this->_aSocialButtons)) {
         return '';
     }
     // prepare buttons
     $aButtons = array();
     foreach ($this->_aSocialButtons as $aButton) {
         $sButton = $this->_replaceMarkers($aButton['content'], $aMarkers);
         if (preg_match('/{[A-Za-z0-9_]+}/', $sButton)) {
             continue;
         }
         $aButtons[] = array('button' => $sButton);
     }
     // output
     $aTemplateVars = array('bx_repeat:buttons' => $aButtons);
     return $GLOBALS['oSysTemplate']->parseHtmlByName('social_sharing.html', $aTemplateVars);
 }
 /**
  * Parse system keys.
  *
  * @param  string $sKey key
  * @return string value associated with the key.
  */
 function parseSystemKey($sKey, $mixedKeyWrapperHtml = null)
 {
     global $logged;
     $aKeyWrappers = $this->_getKeyWrappers($mixedKeyWrapperHtml);
     $sRet = '';
     switch ($sKey) {
         case 'current_version':
             $sRet = $GLOBALS['site']['ver'] . '.' . $GLOBALS['site']['build'];
             break;
         case 'dir':
             $a = bx_lang_info();
             return $a['Direction'];
         case 'page_charset':
             $sRet = 'UTF-8';
             break;
         case 'page_keywords':
             if (!empty($GLOBALS[$this->_sPrefix . 'PageKeywords']) && is_array($GLOBALS[$this->_sPrefix . 'PageKeywords'])) {
                 $sRet = '<meta name="keywords" content="' . process_line_output(implode(',', $GLOBALS[$this->_sPrefix . 'PageKeywords'])) . '" />';
             }
             break;
         case 'page_description':
             if (!empty($GLOBALS[$this->_sPrefix . 'PageDescription']) && is_string($GLOBALS[$this->_sPrefix . 'PageDescription'])) {
                 $sRet = '<meta name="description" content="' . process_line_output($GLOBALS[$this->_sPrefix . 'PageDescription']) . '" />';
             }
             break;
         case 'page_header':
             if (!empty($GLOBALS[$this->_sPrefix . 'PageTitle'])) {
                 $sRet = $GLOBALS[$this->_sPrefix . 'PageTitle'];
             } else {
                 if (isset($GLOBALS['_page']['header'])) {
                     $sRet = $GLOBALS['_page']['header'];
                 }
             }
             $sRet = process_line_output($sRet);
             break;
         case 'page_header_text':
             if (!empty($GLOBALS[$this->_sPrefix . 'PageMainBoxTitle'])) {
                 $sRet = process_line_output($GLOBALS[$this->_sPrefix . 'PageMainBoxTitle']);
             } else {
                 if (isset($GLOBALS['_page']['header_text'])) {
                     $sRet = $GLOBALS['_page']['header_text'];
                 }
             }
             $sRet = process_line_output($sRet);
             break;
         case 'main_div_width':
             if (!empty($GLOBALS[$this->_sPrefix . 'PageWidth'])) {
                 $sRet = process_line_output($GLOBALS[$this->_sPrefix . 'PageWidth']);
             }
             break;
         case 'top_menu':
             $sRet = BxDolAdminMenu::getTopMenu();
             break;
         case 'main_menu':
             $sRet = BxDolAdminMenu::getMainMenu();
             break;
         case 'dol_images':
             $sRet = $this->_processJsImages();
             break;
         case 'dol_lang':
             $sRet = $this->_processJsTranslations();
             break;
         case 'dol_options':
             $sRet = $this->_processJsOptions();
             break;
         case 'promo_code':
             if (defined('BX_PROMO_CODE')) {
                 $sRet = BX_PROMO_CODE;
             } else {
                 $sRet = ' ';
             }
             break;
         case 'copyright':
             $sRet = _t('_copyright', date('Y')) . getVersionComment();
             break;
     }
     $sRet = BxDolTemplate::processInjection($GLOBALS['_page']['name_index'], $sKey, $sRet);
     return $sRet;
 }
Example #3
0
 /**
  * Parse system keys.
  *
  * @param  string $sKey key
  * @return string value associated with the key.
  */
 function parseSystemKey($sKey, $mixedKeyWrapperHtml = null)
 {
     global $site;
     global $_page;
     global $oFunctions;
     global $oTemplConfig;
     global $logged;
     $aKeyWrappers = $this->_getKeyWrappers($mixedKeyWrapperHtml);
     $sRet = '';
     switch ($sKey) {
         case 'dir':
             $a = bx_lang_info();
             return $a['Direction'];
         case 'page_charset':
             $sRet = 'UTF-8';
             break;
         case 'meta_info':
             $sRet = $this->getMetaInfo();
             break;
         case 'page_header':
             if (!empty($GLOBALS[$this->_sPrefix . 'PageTitle'])) {
                 $sRet = $GLOBALS[$this->_sPrefix . 'PageTitle'];
             } else {
                 if (isset($_page['header'])) {
                     $sRet = $_page['header'];
                 }
             }
             //$sRet = process_line_output($sRet);
             break;
         case 'page_header_text':
             if (!empty($GLOBALS[$this->_sPrefix . 'PageMainBoxTitle'])) {
                 $sRet = $GLOBALS[$this->_sPrefix . 'PageMainBoxTitle'];
             } else {
                 if (isset($_page['header_text'])) {
                     $sRet = $_page['header_text'];
                 }
             }
             //$sRet = process_line_output($sRet);
             break;
         case 'main_div_width':
             if (!empty($GLOBALS[$this->_sPrefix . 'PageWidth'])) {
                 $sRet = process_line_output($GLOBALS[$this->_sPrefix . 'PageWidth']);
             }
             break;
         case 'main_logo':
             $sRet = $GLOBALS['oFunctions']->genSiteLogo();
             break;
         case 'main_splash':
             $sRet = $GLOBALS['oFunctions']->genSiteSplash();
             break;
         case 'main_search':
             $sRet = $GLOBALS['oFunctions']->genSiteSearch();
             break;
         case 'service_menu':
             $sRet = $GLOBALS['oFunctions']->genSiteServiceMenu();
             break;
         case 'top_menu':
             $sRet = $GLOBALS['oTopMenu']->getCode();
             break;
         case 'top_menu_breadcrumb':
             $sRet = !empty($GLOBALS['oTopMenu']->sBreadCrumb) ? $GLOBALS['oTopMenu']->sBreadCrumb : $GLOBALS['oTopMenu']->genBreadcrumb();
             break;
         case 'extra_top_menu':
             $iProfileId = getLoggedId();
             if ($iProfileId && getParam('ext_nav_menu_enabled')) {
                 bx_import('BxTemplMemberMenu');
                 $oMemberMenu = new BxTemplMemberMenu();
                 $sRet = $oMemberMenu->genMemberMenu($iProfileId);
             }
             break;
         case 'bottom_links':
             $sRet = $oFunctions->genSiteBottomMenu();
             break;
         case 'switch_skin_block':
             $sRet = getParam("enable_template") ? templates_select_txt() : '';
             break;
         case 'dol_images':
             $sRet = $this->_processJsImages();
             break;
         case 'dol_lang':
             $sRet = $this->_processJsTranslations();
             break;
         case 'dol_options':
             $sRet = $this->_processJsOptions();
             break;
         case 'bottom_text':
             $sRet = _t('_bottom_text', date('Y'));
             break;
         case 'copyright':
             $sRet = _t('_copyright', date('Y')) . getVersionComment();
             break;
         case 'flush_header':
             //TODO: add some variable to disable it if needed
             //flush();
             break;
         case 'extra_js':
             $sRet = empty($_page['extra_js']) ? '' : $_page['extra_js'];
             break;
         case 'is_profile_page':
             $sRet = defined('BX_PROFILE_PAGE') ? 'true' : 'false';
             break;
         default:
             $sRet = ($sTemplAdd = $oFunctions->TemplPageAddComponent($sKey)) !== false ? $sTemplAdd : $aKeyWrappers['left'] . $sKey . $aKeyWrappers['right'];
     }
     $sRet = BxDolTemplate::processInjection($_page['name_index'], $sKey, $sRet);
     return $sRet;
 }
Example #4
0
 function addCssJs($isDateControl = false, $isDateTimeControl = false)
 {
     $aTranslations = array('_add', '_add_other', '_Remove');
     $aJs = array('jquery.ui.core.min.js', 'jquery.ui.widget.min.js', 'jquery.ui.mouse.min.js', 'jquery.ui.slider.min.js');
     $aCss = array('forms_adv.css', 'plugins/jquery/themes/|jquery-ui.css');
     $aLang = bx_lang_info();
     $sLanguageCountry = str_replace('_', '-', $aLang['LanguageCountry']);
     if ($isDateControl || $isDateTimeControl) {
         $aUiLangs = array('af' => 1, 'ar-DZ' => 1, 'ar' => 1, 'az' => 1, 'be' => 1, 'bg' => 1, 'bs' => 1, 'ca' => 1, 'cs' => 1, 'cy-GB' => 1, 'da' => 1, 'de' => 1, 'el' => 1, 'en-AU' => 1, 'en-GB' => 1, 'en-NZ' => 1, 'en' => 1, 'eo' => 1, 'es' => 1, 'et' => 1, 'eu' => 1, 'fa' => 1, 'fi' => 1, 'fo' => 1, 'fr-CA' => 1, 'fr-CH' => 1, 'fr' => 1, 'gl' => 1, 'he' => 1, 'hi' => 1, 'hr' => 1, 'hu' => 1, 'hy' => 1, 'id' => 1, 'is' => 1, 'it' => 1, 'ja' => 1, 'ka' => 1, 'kk' => 1, 'km' => 1, 'ko' => 1, 'ky' => 1, 'lb' => 1, 'lt' => 1, 'lv' => 1, 'mk' => 1, 'ml' => 1, 'ms' => 1, 'nb' => 1, 'nl-BE' => 1, 'nl' => 1, 'nn' => 1, 'no' => 1, 'pl' => 1, 'pt-BR' => 1, 'pt' => 1, 'rm' => 1, 'ro' => 1, 'ru' => 1, 'sk' => 1, 'sl' => 1, 'sq' => 1, 'sr-SR' => 1, 'sr' => 1, 'sv' => 1, 'ta' => 1, 'th' => 1, 'tj' => 1, 'tr' => 1, 'uk' => 1, 'vi' => 1, 'zh-CN' => 1, 'zh-HK' => 1, 'zh-TW' => 1);
         // detect language
         if (isset($aUiLangs[$sLanguageCountry])) {
             $sLang = $sLanguageCountry;
         } elseif (isset($aUiLangs[$aLang['Name']])) {
             $sLang = $aLang['Name'];
         } else {
             $sLang = 'en';
         }
         $aJs[] = 'jquery.ui.datepicker.min.js';
         $aJs[] = 'plugins/jquery/i18n/|jquery.ui.datepicker-' . $sLang . '.js';
     }
     if ($isDateTimeControl) {
         $aCalendarLangs = array('af' => 1, 'am' => 1, 'bg' => 1, 'ca' => 1, 'cs' => 1, 'da' => 1, 'de' => 1, 'el' => 1, 'es' => 1, 'et' => 1, 'eu' => 1, 'fa' => 1, 'fi' => 1, 'fr' => 1, 'gl' => 1, 'he' => 1, 'hr' => 1, 'hu' => 1, 'id' => 1, 'it' => 1, 'ja' => 1, 'ko' => 1, 'lt' => 1, 'lv' => 1, 'mk' => 1, 'nl' => 1, 'no' => 1, 'pl' => 1, 'pt-BR' => 1, 'pt' => 1, 'ro' => 1, 'ru' => 1, 'sk' => 1, 'sl' => 1, 'sr-RS' => 1, 'sr-YU' => 1, 'sv' => 1, 'th' => 1, 'tr' => 1, 'uk' => 1, 'vi' => 1, 'zh-CN' => 1, 'zh-TW' => 1);
         $aJs[] = 'jquery-ui-timepicker-addon.min.js';
         $aJs[] = 'jquery-ui-sliderAccess.js';
         // detect language
         if (isset($aCalendarLangs[$sLanguageCountry])) {
             $aJs[] = 'plugins/jquery/i18n/|jquery-ui-timepicker-' . $sLanguageCountry . '.js';
         } elseif (isset($aCalendarLangs[$aLang['Name']])) {
             $aJs[] = 'plugins/jquery/i18n/|jquery-ui-timepicker-' . $aLang['Name'] . '.js';
         }
         $aCss[] = 'plugins/jquery/themes/|jquery-ui-timepicker-addon.css';
     }
     if (isset($GLOBALS['oSysTemplate'])) {
         $GLOBALS['oSysTemplate']->addCss($aCss);
         $GLOBALS['oSysTemplate']->addJs($aJs);
         $GLOBALS['oSysTemplate']->addJsTranslation($aTranslations);
     }
     if (isset($GLOBALS['oAdmTemplate'])) {
         $GLOBALS['oAdmTemplate']->addJs($aJs);
         $GLOBALS['oAdmTemplate']->addCss($aCss);
     }
 }
 /**
  * Attach editor to HTML element, in most cases - textarea.
  * @param $sSelector - jQuery selector to attach editor to.
  * @param $iViewMode - editor view mode: BX_EDITOR_STANDARD, BX_EDITOR_MINI, BX_EDITOR_FULL
  * @param $bDynamicMode - is AJAX mode or not, the HTML with editor area is loaded dynamically.
  */
 public function attachEditor($sSelector, $iViewMode = BX_EDITOR_STANDARD, $bDynamicMode = false)
 {
     // set visual mode
     switch ($iViewMode) {
         case BX_EDITOR_MINI:
             $sToolsItems = self::$CONF_MINI;
             $aModules = self::$MODULES_MINI;
             break;
         case BX_EDITOR_FULL:
             $sToolsItems = self::$CONF_FULL;
             $aModules = self::$MODULES_FULL;
             break;
         case BX_EDITOR_STANDARD:
         default:
             $sToolsItems = self::$CONF_STANDARD;
             $aModules = self::$MODULES_STANDARD;
     }
     // detect language
     $aLang = bx_lang_info();
     if (isset(self::$CONF_LANGS[$aLang['LanguageCountry']])) {
         $sLang = $aLang['LanguageCountry'];
     } elseif (isset(self::$CONF_LANGS[$aLang['Name']])) {
         $sLang = $aLang['Name'];
     } else {
         $sLang = 'en_GB';
     }
     $aMarkers = array('bx_var_custom_init' => &$sToolsItems, 'bx_var_custom_conf' => $this->_sConfCustom, 'bx_var_plugins_path' => bx_js_string(BX_DOL_URL_PLUGINS, BX_ESCAPE_STR_APOS), 'bx_var_css_path' => bx_js_string($this->_oTemplate->getCssUrl('editor.css'), BX_ESCAPE_STR_APOS), 'bx_var_skin' => bx_js_string($this->_aObject['skin'], BX_ESCAPE_STR_APOS), 'bx_var_lang' => bx_js_string($sLang, BX_ESCAPE_STR_APOS), 'bx_var_selector' => bx_js_string($sSelector, BX_ESCAPE_STR_APOS), 'bx_url_root' => bx_js_string(BX_DOL_URL_ROOT, BX_ESCAPE_STR_APOS), 'bx_url_tinymce' => bx_js_string(BX_DOL_URL_PLUGINS . 'tinymce/', BX_ESCAPE_STR_APOS));
     $o = new BxDolAlerts('system', 'attach_editor', 0, 0, array('markers' => &$aMarkers, 'modules' => &$aModules, 'view_mode' => $iViewMode, 'dynamic_mode' => $bDynamicMode, 'selector' => $sSelector, 'editor' => $this));
     $o->alert();
     $sToolsItems = str_replace('{modules}', join(",\n", $aModules), $sToolsItems);
     // initialize editor
     $sInitEditor = $this->_replaceMarkers(self::$CONF_COMMON, $aMarkers);
     if ($bDynamicMode) {
         $sScript = "<script>\n                if ('undefined' == typeof(jQuery(document).tinymce)) {\n                    window.tinyMCEPreInit = {base : '" . bx_js_string(BX_DOL_URL_PLUGINS . 'tinymce', BX_ESCAPE_STR_APOS) . "', suffix : '.min', query : ''};\n                    \$.getScript('" . bx_js_string(BX_DOL_URL_PLUGINS . 'tinymce/tinymce.min.js', BX_ESCAPE_STR_APOS) . "', function(data, textStatus, jqxhr) {\n                        \$.getScript('" . bx_js_string(BX_DOL_URL_PLUGINS . 'tinymce/jquery.tinymce.min.js', BX_ESCAPE_STR_APOS) . "', function(data, textStatus, jqxhr) {\n                            {$sInitEditor}\n                        });\n                    });\n                } else {\n                    setTimeout(function () {\n                        {$sInitEditor}\n                    }, 10); // wait while html is rendered in case of dynamic adding html with tinymce\n                }\n            </script>";
     } else {
         $sScript = "\n            <script>\n                \$(document).ready(function () {\n                    {$sInitEditor}\n                });\n            </script>";
     }
     return $this->_addJsCss($bDynamicMode) . $sScript;
 }