Exemplo n.º 1
0
 /**
  * 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;
             break;
         case BX_EDITOR_FULL:
             $sToolsItems = self::$CONF_FULL;
             break;
         case BX_EDITOR_STANDARD:
         default:
             $sToolsItems = self::$CONF_STANDARD;
     }
     // detect language
     $sLang = BxDolLanguages::getInstance()->detectLanguageFromArray(self::$CONF_LANGS);
     // initialize editor
     $sInitEditor = $this->_replaceMarkers(self::$CONF_COMMON, 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_PUBLIC . 'tinymce/', BX_ESCAPE_STR_APOS)));
     if ($bDynamicMode) {
         $sScript = "<script>\n                if ('undefined' == typeof(jQuery(document).tinymce)) {\n                    window.tinyMCEPreInit = {base : '" . bx_js_string(BX_DOL_URL_PLUGINS_PUBLIC . 'tinymce', BX_ESCAPE_STR_APOS) . "', suffix : '.min', query : ''};\n                    \$.getScript('" . bx_js_string(BX_DOL_URL_ROOT . 'inc/js/editor.tinymce.js', BX_ESCAPE_STR_APOS) . "');\n                    \$.getScript('" . bx_js_string(BX_DOL_URL_PLUGINS_PUBLIC . 'tinymce/tinymce.min.js', BX_ESCAPE_STR_APOS) . "', function(data, textStatus, jqxhr) {\n                        \$.getScript('" . bx_js_string(BX_DOL_URL_PLUGINS_PUBLIC . 'tinymce/jquery.tinymce.min.js', BX_ESCAPE_STR_APOS) . "', function(data, textStatus, jqxhr) {\n                            {$sInitEditor}\n                        });\n                    });\n                } else {\n                    {$sInitEditor}\n                }\n            </script>";
     } else {
         $sScript = "\n            <script>\n                \$(document).ready(function () {\n                    {$sInitEditor}\n                });\n            </script>";
     }
     return $this->_addJsCss($bDynamicMode) . $sScript;
 }
Exemplo n.º 2
0
 /**
  * Display captcha.
  */
 public function display($bDynamicMode = false)
 {
     // TODO: captcha don't display error in javascript mode, try to find the way on how to pass error code in this mode
     $sId = 'sys-captcha-' . time() . rand(0, PHP_INT_MAX);
     $sJsObject = 'Recaptcha';
     $sInit = $sJsObject . ".create('" . $this->_sKeyPublic . "', '" . $sId . "', {\n\t\t\tlang: '" . BxDolLanguages::getInstance()->getCurrentLanguage() . "',\n\t\t\ttheme: '" . $this->_sSkin . "',\n\t\t\tcustom_theme_widget: '" . $sId . "',\n\t\t\tcallback: " . $sJsObject . ".focus_response_field\n\t\t});";
     return $this->_addJsCss($bDynamicMode) . $this->_oTemplate->parseHtmlByName('reCaptcha.html', array('js_object' => $sJsObject, 'id' => $sId, 'bx_if:show_common' => array('condition' => !$bDynamicMode, 'content' => array('js_init' => $sInit)), 'bx_if:show_dynamic' => array('condition' => $bDynamicMode, 'content' => array('js_object' => $sJsObject, 'js_init' => $sInit))));
 }
Exemplo n.º 3
0
 public function serviceGetLanguages($bIdAsKey = false, $bActiveOnly = false)
 {
     $aValues = BxDolLanguages::getInstance()->getLanguages($bIdAsKey, $bActiveOnly);
     $aResult = array();
     foreach ($aValues as $sKey => $sValue) {
         $aResult[] = array('key' => $sKey, 'value' => $sValue);
     }
     return $aResult;
 }
Exemplo n.º 4
0
 function __construct($aOptions, $oTemplate = false)
 {
     parent::__construct($aOptions, $oTemplate);
     $this->oModule = BxDolModule::getInstance('bx_developer');
     $this->aLanguages = BxDolLanguages::getInstance()->getLanguages();
     $iWidth = floor(100 / (count($this->aLanguages) + 1));
     $this->_aOptions['fields']['title']['width'] = $iWidth;
     foreach ($this->aLanguages as $sName => $sTitle) {
         $this->_aOptions['fields'][$sName] = array('title' => $sTitle, 'width' => $iWidth, 'translatable' => '0', 'chars_limit' => '0');
     }
 }
Exemplo n.º 5
0
 /**
  * Display captcha.
  */
 public function display($bDynamicMode = false)
 {
     // TODO: captcha don't display error in javascript mode, try to find the way on how to pass error code in this mode
     $sId = 'sys-captcha-' . time() . rand(0, PHP_INT_MAX);
     $sInit = "\n            Recaptcha.create('" . $this->_sKeyPublic . "', '" . $sId . "', {\n                lang: '" . BxDolLanguages::getInstance()->getCurrentLanguage() . "',\n                theme: '" . $this->_sSkin . "',\n                callback: Recaptcha.focus_response_field\n            });\n        ";
     if ($bDynamicMode) {
         $sCode = "\n            <script>\n                if ('undefined' == typeof(window.Recaptcha)) {\n                    \$.getScript('http://www.google.com/recaptcha/api/js/recaptcha_ajax.js', function(data, textStatus, jqxhr) {\n                        {$sInit}\n                    });\n                } else {\n                    {$sInit}\n                }\n            </script>";
     } else {
         $sCode = "\n            <script>\n                \$(document).ready(function () {\n                    {$sInit}\n                });\n            </script>";
     }
     return $this->_addJsCss($bDynamicMode) . '<div id="' . $sId . '"></div>' . $sCode;
 }
Exemplo n.º 6
0
 /**
  * Class constructor.
  */
 protected function __construct()
 {
     if (isset($GLOBALS['bxDolClasses'][get_class($this)])) {
         trigger_error('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
     }
     parent::__construct();
     $oLang = BxDolLanguages::getInstance();
     $this->iDefaultLangId = $oLang->getCurrentLangId();
     $this->iFallbackLangId = $oLang->getLangId('en');
     $sAboutUsLink = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=about');
     $this->aDefaultKeys = array('site_url' => BX_DOL_URL_ROOT, 'site_name' => getParam('site_title'), 'about_us' => '<a href="' . $sAboutUsLink . '">' . _t('_sys_et_txt_about_us') . '</a>');
     $this->_oEmailTemplatesQuery = BxDolEmailTemplatesQuery::getInstance();
 }
Exemplo n.º 7
0
 /**
  * Get location map.
  * @param $sObject metatgs object to get keywords cloud for
  * @param $iId content id
  * @return map HTML string
  */
 public function serviceLocationsMap($sObject, $iId, $sMapSize = '1000x144', $sMapKey = '')
 {
     $o = BxDolMetatags::getObjectInstance($sObject);
     $sLocationHtml = $o->locationsString($iId);
     if (!$sLocationHtml) {
         return '';
     }
     $sLocationEncoded = rawurlencode(strip_tags($sLocationHtml));
     $sProto = 0 == strncmp('https', BX_DOL_URL_ROOT, 5) ? 'https' : 'http';
     $iScale = isset($_COOKIE['devicePixelRatio']) && (int) $_COOKIE['devicePixelRatio'] >= 2 ? 2 : 1;
     $sLang = BxDolLanguages::getInstance()->getCurrentLanguage();
     $aVars = array('map_img' => $sProto . '://maps.googleapis.com/maps/api/staticmap?center=' . $sLocationEncoded . '&zoom=7&size=' . $sMapSize . '&maptype=roadmap&markers=size:small%7C' . $sLocationEncoded . '&scale=' . $iScale . '&language=' . $sLang . ($sMapKey ? '&key=' . $sMapKey : ''), 'location_string' => $sLocationHtml);
     $this->addCssJs();
     return BxDolTemplate::getInstance()->parseHtmlByName('metatags_locations_map.html', $aVars);
 }
Exemplo n.º 8
0
 public function getCode($sContentId, $sModuleName, $sUrl, $sTitle, $aCustomVars = false)
 {
     // define markers for replacments
     bx_import('BxDolLanguages');
     $sLang = BxDolLanguages::getInstance()->getCurrentLanguage();
     $aMarkers = array('id' => $sContentId, 'module' => $sModuleName, 'url' => $sUrl, 'url_encoded' => rawurlencode($sUrl), 'lang' => $sLang, 'locale' => $this->_getLocaleFacebook($sLang), '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) {
         switch ($aButton['type']) {
             case 'html':
                 $sButton = $this->_replaceMarkers($aButton['content'], $aMarkers);
                 break;
             case 'service':
                 $a = @unserialize($aButton['content']);
                 if (false === $a || !is_array($a)) {
                     break;
                 }
                 $a = $this->_replaceMarkers($a, $aMarkers);
                 $sButton = BxDolService::call($a['module'], $a['method'], isset($a['params']) ? $a['params'] : array(), isset($a['class']) ? $a['class'] : 'Module');
                 break;
         }
         if (!isset($sButton) || preg_match('/{[A-Za-z0-9_]+}/', $sButton)) {
             // if not all markers are replaced skip it
             continue;
         }
         $aButtons[] = array('button' => $sButton, 'object' => $aButton['object']);
     }
     // output
     $aTemplateVars = array('bx_repeat:buttons' => $aButtons);
     return $this->_oTemplate->parseHtmlByName('social_sharing.html', $aTemplateVars);
 }
Exemplo n.º 9
0
 protected function loadData()
 {
     $sLanguage = BxDolLanguages::getInstance()->getCurrentLangName();
     $this->setSelected('', $sLanguage);
     $aPage = explode('?', $_SERVER['HTTP_REFERER']);
     $aPageParams = array();
     if (!empty($aPage[1])) {
         parse_str($aPage[1], $aPageParams);
     }
     $aLanguages = BxDolLanguagesQuery::getInstance()->getLanguages(false, true);
     $aItems = array();
     foreach ($aLanguages as $sName => $sLang) {
         $aPageParams['lang'] = $sName;
         $aItems[] = array('id' => $sName, 'name' => $sName, 'class' => '', 'title' => genFlag($sName) . ' ' . $sLang, 'target' => '_self', 'icon' => '', 'link' => bx_html_attribute(bx_append_url_params($aPage[0], $aPageParams)), 'onclick' => '');
     }
     $this->_aObject['menu_items'] = $aItems;
 }
Exemplo n.º 10
0
 public function getMenuItems()
 {
     $aItems = parent::getMenuItems();
     foreach ($aItems as $iKey => $aItem) {
         switch ($aItem['name']) {
             case 'switch_language':
                 $sLanguage = BxDolLanguages::getInstance()->getCurrentLangName();
                 $sIcon = $this->_oTemplate->parseHtmlByName('bx_img.html', array('src' => $this->_oTemplate->getIconUrl('sys_fl_' . $sLanguage . '.gif'), 'bx_repeat:attrs' => array()));
                 $aItems[$iKey]['title'] = _t('_sys_menu_item_title_switch_language_mask', $aItems[$iKey]['title'], $sIcon);
                 break;
             case 'switch_template':
                 $aTemplates = get_templates_array(true, true);
                 $sTemplate = $aTemplates[$this->_oTemplate->getCode()];
                 $aItems[$iKey]['title'] = _t('_sys_menu_item_title_switch_template_mask', $aItems[$iKey]['title'], $sTemplate);
                 break;
         }
     }
     return $aItems;
 }
Exemplo n.º 11
0
 /**
  * Display captcha.
  */
 public function display($bDynamicMode = false)
 {
     $sCode = '';
     $aApiParams = array();
     if ($bDynamicMode) {
         $sPostfix = $this->_sObject;
         $sId = 'sys-captcha-' . $sPostfix;
         $sOnLoadFunction = 'onLoadCallback' . $sPostfix;
         $sOnLoadCode = "\n\t        \tvar " . $sOnLoadFunction . " = function() {\n\t\t\t\t\tgrecaptcha.render('" . $sId . "', {\n\t\t\t\t\t\t'sitekey': '" . $this->_sKeyPublic . "',\n\t\t\t\t\t\t'theme': '" . $this->_sSkin . "'\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t        ";
         $aApiParams = array('onload' => $sOnLoadFunction, 'render' => 'explicit');
         $sCode .= $this->_oTemplate->_wrapInTagJsCode($sOnLoadCode);
         $sCode .= '<div id="' . $sId . '">';
     } else {
         $aApiParams = array('render' => 'onload');
         $sCode .= '<div class="g-recaptcha" data-sitekey="' . $this->_sKeyPublic . '" data-theme="' . $this->_sSkin . '"></div>';
     }
     $aApiParams['hl'] = BxDolLanguages::getInstance()->getCurrentLanguage();
     $sCodeJs = $this->_oTemplate->addJs(bx_append_url_params($this->sApiUrl, $aApiParams), $bDynamicMode);
     return ($bDynamicMode ? $sCodeJs : '') . $sCode;
 }
Exemplo n.º 12
0
function bx_lang_name()
{
    return BxDolLanguages::getInstance()->getCurrentLanguage();
}
Exemplo n.º 13
0
 function addCssJs()
 {
     if (isset($this->aParams['view_mode']) && $this->aParams['view_mode']) {
         if (self::$_isCssJsAddedViewMode) {
             return;
         }
         $this->oTemplate->addCss('forms.css');
         self::$_isCssJsAddedViewMode = true;
     } else {
         if (self::$_isCssJsAdded) {
             return;
         }
         $aCss = array('forms.css', 'jquery-ui/jquery-ui.css', 'timepicker-addon/jquery-ui-timepicker-addon.css');
         $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);
         $aCalendarLangs = array('af' => 1, 'am' => 1, 'bg' => 1, 'ca' => 1, 'cs' => 1, 'da' => 1, 'de' => 1, 'el' => 1, 'es' => 1, 'et' => 1, 'eu' => 1, 'fi' => 1, 'fr' => 1, 'gl' => 1, 'he' => 1, 'hr' => 1, 'hu' => 1, 'id' => 1, 'it' => 1, 'ja' => 1, 'ko' => 1, 'lt' => 1, 'nl' => 1, 'no' => 1, 'pl' => 1, 'pt-BR' => 1, 'pt' => 1, 'ro' => 1, 'ru' => 1, 'sk' => 1, 'sr-RS' => 1, 'sr-YU' => 1, 'sv' => 1, 'th' => 1, 'tr' => 1, 'uk' => 1, 'vi' => 1, 'zh-CN' => 1, 'zh-TW' => 1);
         bx_import('BxDolLanguages');
         $sCalendarLang = BxDolLanguages::getInstance()->detectLanguageFromArray($aCalendarLangs);
         $sUiLang = BxDolLanguages::getInstance()->detectLanguageFromArray($aUiLangs);
         $aJs = array('jquery.webForms.js', 'jquery-ui/jquery.ui.core.min.js', 'jquery-ui/jquery.ui.widget.min.js', 'jquery-ui/jquery.ui.mouse.min.js', 'jquery-ui/jquery.ui.position.min.js', 'jquery-ui/jquery.ui.slider.min.js', 'jquery-ui/jquery.ui.datepicker.min.js', 'jquery-ui/i18n/jquery.ui.datepicker-' . $sUiLang . '.js', 'timepicker-addon/jquery-ui-timepicker-addon.min.js', 'timepicker-addon/jquery-ui-sliderAccess.js', 'timepicker-addon/i18n/jquery-ui-timepicker-' . $sCalendarLang . '.js');
         foreach ($this->aInputs as $aInput) {
             if (!isset($aInput['type']) || 'files' != $aInput['type'] || !isset($aInput['uploaders'])) {
                 continue;
             }
             bx_import('BxDolUploader');
             foreach ($aInput['uploaders'] as $sUploaderObject) {
                 $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $aInput['storage_object'], '');
                 if ($oUploader) {
                     $oUploader->addCssJs();
                 }
             }
         }
         $this->oTemplate->addJs($aJs);
         $this->oTemplate->addCss($aCss);
         self::$_isCssJsAdded = true;
     }
 }
Exemplo n.º 14
0
 protected function _getDataSqlOrderClause($sOrderByFilter, $sOrderField, $sOrderDir)
 {
     $sOrderClause = '';
     if ($sOrderField && is_array($this->_aOptions['sorting_fields']) && in_array($sOrderField, $this->_aOptions['sorting_fields'])) {
         // explicit order
         $sDir = 0 == strcasecmp($sOrderDir, 'desc') ? 'DESC' : 'ASC';
         if (is_array($this->_aOptions['sorting_fields_translatable']) && in_array($sOrderField, $this->_aOptions['sorting_fields_translatable'])) {
             // translatable fields
             bx_import('BxDolLanguages');
             $iLang = BxDolLanguages::getInstance()->getCurrentLangId();
             $oDb = BxDolDb::getInstance();
             $sOrderClause = $oDb->prepare("ORDER BY (SELECT `s`.`string` FROM `sys_localization_strings` AS `s` INNER JOIN `sys_localization_keys` AS `k` ON (`k`.`ID` = `s`.`IDKey`) WHERE `k`.`KEY` = `{$sOrderField}` AND `s`.`IDLanguage` = ? LIMIT 1) ", $iLang) . $sDir;
         } else {
             // regular fields
             $sOrderClause = " ORDER BY `{$sOrderField}` {$sDir}";
         }
     } elseif ($sOrderByFilter) {
         // order by filter
         $sOrderClause = " ORDER BY {$sOrderByFilter} DESC";
     } elseif (!empty($this->_aOptions['field_order'])) {
         // order by "order" field
         if (false == strpos($this->_aOptions['field_order'], ',')) {
             $sOrderClause = " ORDER BY `" . $this->_aOptions['field_order'] . "` " . $this->_sDefaultSortingOrder;
         } else {
             $a = explode(',', $this->_aOptions['field_order']);
             foreach ($a as $sField) {
                 $sOrderClause .= "`" . trim($sField) . "` " . $this->_sDefaultSortingOrder . ", ";
             }
             if ($sOrderClause) {
                 $sOrderClause = " ORDER BY " . trim($sOrderClause, ', ');
             }
         }
     }
     return $sOrderClause;
 }
Exemplo n.º 15
0
function genFlag($sLang = '', $oTemplate = null)
{
    if (!$oTemplate) {
        $oTemplate = BxDolTemplate::getInstance();
    }
    $oTemplate->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'flag-icon-css/css/|flag-icon.min.css');
    $sFlag = BxDolLanguages::getInstance()->getLangFlag($sLang);
    return '<span title="' . $sFlag . '" class="flag-icon flag-icon-' . $sFlag . '"></span>';
}
Exemplo n.º 16
0
 protected function processModuleByField($sField, $sModuleUri, $aActions = array('install', 'enable'), $sModuleType = null)
 {
     if (!file_exists(BX_INSTALL_PATH_HEADER)) {
         return _t('_sys_inst_msg_script_isnt_installed');
     }
     require_once BX_INSTALL_PATH_HEADER;
     bx_import('BxDolStudioInstallerUtils');
     bx_import('BxDolLanguages');
     BxDolLanguages::getInstance();
     $oModulesTools = new BxDolInstallModulesTools();
     $aModules = $oModulesTools->getModules($sModuleType);
     foreach ($aModules as $aConfig) {
         if ($sModuleUri != $aConfig[$sField]) {
             continue;
         }
         foreach ($aActions as $sAction) {
             $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aConfig['home_dir'], $sAction);
             if ((!isset($aResult['code']) || $aResult['code']) && !empty($aResult['message'])) {
                 return _t('_sys_inst_msg_module_error', $aConfig['title'], $aResult['message']);
             }
         }
     }
     return '';
 }