Example #1
0
 public function __construct($oTemplate)
 {
     parent::__construct();
     if ($oTemplate) {
         $this->_oTemplate = $oTemplate;
     } else {
         $this->_oTemplate = BxDolTemplate::getInstance();
     }
 }
 public function __construct($aObject, $oTemplate = false)
 {
     parent::__construct($aObject, $oTemplate);
     $CNF =& $this->_oModule->_oConfig->CNF;
     $aInformers = array();
     // get profile info
     $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
     $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
     if ($iProfileId) {
         $this->_oProfile = BxDolProfile::getInstance($iProfileId);
     }
     if (!$this->_oProfile && $iContentId) {
         $this->_oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->MODULE);
     }
     if ($this->_oProfile) {
         $this->_aProfileInfo = $this->_oProfile->getInfo();
         $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_aProfileInfo['content_id']);
     }
     if (!$this->_aContentInfo || !$this->_oProfile) {
         return;
     }
     // select view profile submenu
     $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
     $oMenuSubmenu->setObjectSubmenu($CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'], array('title' => $this->_oProfile->getDisplayName(), 'link' => $this->_oProfile->getUrl(), 'icon' => $CNF['ICON']));
     // add replaceable markers
     $this->addMarkers($this->_aProfileInfo);
     // every content field can be used as marker
     $this->addMarkers(array('profile_id' => $this->_oProfile->id()));
     // profile id field
     $this->addMarkers(array('display_name' => $this->_oProfile->getDisplayName()));
     // profile display name
     $this->addMarkers(array('profile_link' => $this->_oProfile->getUrl()));
     // profile link
     // display message if profile isn't active
     if (bx_get_logged_profile_id() == $this->_oProfile->id() && !empty($CNF['INFORMERS']['status'])) {
         $sStatus = $this->_aContentInfo['profile_status'];
         if (isset($CNF['INFORMERS']['status']['map'][$sStatus])) {
             $aInformers[] = array('name' => $CNF['INFORMERS']['status']['name'], 'msg' => _t($CNF['INFORMERS']['status']['map'][$sStatus]), 'type' => BX_INFORMER_ALERT);
         }
     }
     // display message if it is possible to switch to this profile
     $oProfile = $this->_aContentInfo ? BxDolProfile::getInstanceByContentTypeAccount($this->_aContentInfo['id'], $this->MODULE) : false;
     if ($oProfile) {
         $oProfile->checkSwitchToProfile($this->_oTemplate);
     }
     // add informers
     if ($aInformers) {
         $oInformer = BxDolInformer::getInstance($this->_oTemplate);
         if ($oInformer) {
             foreach ($aInformers as $a) {
                 $oInformer->add($a['name'], $this->_replaceMarkers($a['msg']), $a['type']);
             }
         }
     }
 }
Example #3
0
 public function __construct($aObject, $oTemplate)
 {
     parent::__construct($aObject, $oTemplate);
     bx_import('BxDolProfile');
     $oProfile = BxDolProfile::getInstance();
     $aProfileInfo = $oProfile ? $oProfile->getInfo() : false;
     $this->addMarkers(array('account_id' => $aProfileInfo ? $aProfileInfo['account_id'] : 0, 'profile_id' => $aProfileInfo ? $aProfileInfo['id'] : 0, 'profile_type' => $aProfileInfo ? $aProfileInfo['type'] : 0, 'profile_content_id' => $aProfileInfo ? $aProfileInfo['content_id'] : 0));
     // set settings submenu
     bx_import('BxDolMenu');
     $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
     if ($oMenuSubmenu) {
         $oMenuSubmenu->setObjectSubmenu('sys_account_settings_submenu', array('title' => _t('_sys_menu_item_title_account_settings'), 'link' => BX_DOL_URL_ROOT . 'member.php', 'icon' => ''));
     }
     // display message if profile isn't active
     if ($oProfile) {
         $sStatus = $oProfile->getStatus();
         if (isset($this->_aMapStatus2LangKey[$sStatus])) {
             bx_import('BxDolInformer');
             $oInformer = BxDolInformer::getInstance($this->_oTemplate);
             if ($oInformer) {
                 $oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
             }
         }
     }
     // switch profile context
     if ($iSwitchToProfileId = (int) bx_get('switch_to_profile')) {
         bx_import('BxDolInformer');
         $oInformer = BxDolInformer::getInstance($this->_oTemplate);
         $oProfile = BxDolProfile::getInstance($iSwitchToProfileId);
         $sInformerMsg = '';
         if ($oProfile && $oProfile->getAccountId() == getLoggedId()) {
             bx_import('BxDolProfile');
             $oAccount = BxDolAccount::getInstance();
             if ($oAccount->updateProfileContext($iSwitchToProfileId)) {
                 $sInformerMsg = _t('_sys_txt_account_profile_context_changed_success', $oProfile->getDisplayName());
             }
         }
         if ($oInformer) {
             $oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_error occured'), $sInformerMsg ? BX_INFORMER_INFO : BX_INFORMER_ERROR);
         }
     }
 }
Example #4
0
 /**
  * Parse system keys.
  *
  * @param  string $sKey key
  * @return string value associated with the key.
  */
 function parseSystemKey($sKey, $mixedKeyWrapperHtml = null, $bProcessInjection = true)
 {
     $aKeyWrappers = $this->_getKeyWrappers($mixedKeyWrapperHtml);
     $sRet = '';
     switch ($sKey) {
         case 'page_charset':
             $sRet = 'UTF-8';
             break;
         case 'page_robots':
             if (!empty($this->aPage['robots']) && is_string($this->aPage['robots'])) {
                 $sRet = '<meta name="robots" content="' . bx_html_attribute($this->aPage['robots']) . '" />';
             }
             break;
         case 'meta_info':
             $sRet = $this->getMetaInfo();
             break;
         case 'page_header':
             if (isset($this->aPage['header'])) {
                 $sRet = bx_process_output(strip_tags($this->aPage['header']));
             }
             break;
         case 'page_header_text':
             if (isset($this->aPage['header_text'])) {
                 $sRet = bx_process_output($this->aPage['header_text']);
             }
             break;
         case 'popup_loading':
             bx_import('BxTemplFunctions');
             $s = $this->parsePageByName('popup_loading.html', array());
             $sRet = BxTemplFunctions::getInstance()->transBox('bx-popup-loading', $s, true);
             bx_import('BxTemplSearch');
             $oSearch = new BxTemplSearch();
             $oSearch->setLiveSearch(true);
             $sRet .= $this->parsePageByName('search.html', array('search_form' => $oSearch->getForm(BX_DB_CONTENT_ONLY), 'results' => $oSearch->getResultsContainer()));
             $sRet .= $this->getMenu('sys_site');
             $sRet .= isLogged() ? $this->getMenu('sys_add_content') : '';
             $sRet .= isLogged() ? $this->getMenu('sys_account_popup') : '';
             break;
         case 'lang':
             $sRet = bx_lang_name();
             break;
         case 'main_logo':
             bx_import('BxTemplFunctions');
             $sRet = BxTemplFunctions::getInstance()->getMainLogo();
             break;
         case 'informer':
             bx_import('BxDolInformer');
             $oInformer = BxDolInformer::getInstance($this);
             $sRet = $oInformer ? $oInformer->display() : '';
             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 'extra_js':
             $sRet = empty($this->aPage['extra_js']) ? '' : $this->aPage['extra_js'];
             break;
         case 'is_profile_page':
             $sRet = defined('BX_PROFILE_PAGE') ? 'true' : 'false';
             break;
         default:
             bx_import('BxTemplFunctions');
             $sRet = ($sTemplAdd = BxTemplFunctions::getInstance()->TemplPageAddComponent($sKey)) !== false ? $sTemplAdd : $aKeyWrappers['left'] . $sKey . $aKeyWrappers['right'];
     }
     if ($bProcessInjection) {
         $sRet = $this->processInjection($this->getPageNameIndex(), $sKey, $sRet);
     }
     return $sRet;
 }
Example #5
0
 /**
  * Display informer message if it is possible to switch to this profile
  */
 public function checkSwitchToProfile($oTemplate = null, $iViewerAccountId = false, $iViewerProfileId = false)
 {
     if (false === $iViewerAccountId) {
         $iViewerAccountId = getLoggedId();
     }
     if (false === $iViewerProfileId) {
         $iViewerProfileId = bx_get_logged_profile_id();
     }
     if (!$iViewerAccountId || !$iViewerProfileId) {
         return;
     }
     if ($iViewerAccountId != $this->getAccountId() || $iViewerProfileId == $this->id()) {
         return;
     }
     bx_import('BxDolInformer');
     bx_import('BxDolPermalinks');
     $oInformer = BxDolInformer::getInstance($oTemplate);
     if ($oInformer) {
         $oInformer->add('sys-switch-profile-context', _t('_sys_txt_account_profile_context_change_suggestion', BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher', array('switch_to_profile' => $this->id()))), BX_INFORMER_INFO);
     }
 }
Example #6
0
 /**
  * Parse system keys.
  *
  * @param  string $sKey key
  * @return string value associated with the key.
  */
 function parseSystemKey($sKey, $mixedKeyWrapperHtml = null, $bProcessInjection = true)
 {
     $aKeyWrappers = $this->_getKeyWrappers($mixedKeyWrapperHtml);
     $sRet = '';
     switch ($sKey) {
         case 'page_charset':
             $sRet = 'UTF-8';
             break;
         case 'page_robots':
             if (!empty($this->aPage['robots']) && is_string($this->aPage['robots'])) {
                 $sRet = '<meta name="robots" content="' . bx_html_attribute($this->aPage['robots']) . '" />';
             }
             break;
         case 'page_keywords':
             if (!empty($this->aPage['keywords']) && is_array($this->aPage['keywords'])) {
                 $sRet = '<meta name="keywords" content="' . bx_html_attribute(implode(',', $this->aPage['keywords'])) . '" />';
             }
             break;
         case 'page_description':
             if (!empty($this->aPage['description']) && is_string($this->aPage['description'])) {
                 $sRet = '<meta name="description" content="' . bx_html_attribute($this->aPage['description']) . '" />';
             }
             break;
         case 'page_header':
             if (isset($this->aPage['header'])) {
                 $sRet = bx_process_output(strip_tags($this->aPage['header']));
             }
             break;
         case 'page_header_text':
             if (isset($this->aPage['header_text'])) {
                 $sRet = bx_process_output($this->aPage['header_text']);
             }
             break;
         case 'page_icons':
             bx_import('BxTemplFunctions');
             $sRet = BxTemplFunctions::getInstance()->getMetaIcons();
             break;
         case 'popup_loading':
             $sContent = $this->parsePageByName('popup_loading.html', array());
             bx_import('BxTemplFunctions');
             $sRet = BxTemplFunctions::getInstance()->transBox('bx-popup-loading', $sContent, true);
             break;
         case 'lang':
             $sRet = bx_lang_name();
             break;
         case 'main_logo':
             bx_import('BxTemplFunctions');
             $sRet = BxTemplFunctions::getInstance()->getMainLogo();
             break;
         case 'informer':
             bx_import('BxDolInformer');
             $oInformer = BxDolInformer::getInstance($this);
             $sRet = $oInformer ? $oInformer->display() : '';
             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 'extra_js':
             $sRet = empty($this->aPage['extra_js']) ? '' : $this->aPage['extra_js'];
             break;
         case 'is_profile_page':
             $sRet = defined('BX_PROFILE_PAGE') ? 'true' : 'false';
             break;
         default:
             bx_import('BxTemplFunctions');
             $sRet = ($sTemplAdd = BxTemplFunctions::getInstance()->TemplPageAddComponent($sKey)) !== false ? $sTemplAdd : $aKeyWrappers['left'] . $sKey . $aKeyWrappers['right'];
     }
     if ($bProcessInjection) {
         $sRet = $this->processInjection($this->getPageNameIndex(), $sKey, $sRet);
     }
     return $sRet;
 }