| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup UnaStudio UNA Studio
- * @{
- */
- define('BX_DOL_STUDIO_PAGE_HOME', 'home');
- define('BX_DOL_STUDIO_PAGE_JS_OBJECT', 'oBxDolStudioPage');
- define('BX_DOL_STUDIO_MIT_CAPTION', 'caption');
- define('BX_DOL_STUDIO_MIT_ITEM', 'item');
- class BxDolStudioPage extends BxDol
- {
- protected $oDb;
- protected $aPage;
- protected $bPage;
- protected $bPageMultiple;
- protected $sPageUrl;
- protected $sPageSelected;
- protected $sPageRssHelpObject;
- protected $sPageRssHelpUrl;
- protected $iPageRssHelpLength;
- protected $sPageRssHelpId;
- protected $_sTypesPreList;
- protected $aActions;
- protected $aMarkers;
- protected $iError;
- protected $sError;
- protected $_bShowHeaderBreadcrumb;
- protected $_bShowHeaderRightSearch;
- protected $_bShowHeaderRightSite;
- protected $_bShowHeaderRightAssistant;
- function __construct($mixedPageName)
- {
- parent::__construct();
- $this->oDb = BxDolStudioPageQuery::getInstance();
- $this->aPage = [];
- $this->bPage = false;
- $this->bPageMultiple = false;
- $this->sPageSelected = '';
- $this->sPageRssHelpObject = 'sys_studio_page_help';
- $this->sPageRssHelpUrl = 'http://feed.una.io/?section={page_name}';
- $this->iPageRssHelpLength = 5;
- $this->_sTypesPreList = 'sys_studio_widget_types';
- $this->aActions = [];
- $this->aMarkers = [
- 'url_root' => BX_DOL_URL_ROOT,
- 'url_studio' => BX_DOL_URL_STUDIO
- ];
- $this->iError = 0;
- $this->sError = false;
- $this->_bShowHeaderBreadcrumb = getParam('sys_std_show_header_left') == 'on';
- $this->_bShowHeaderRightSearch = getParam('sys_std_show_header_right_search') == 'on';
- $this->_bShowHeaderRightSite = getParam('sys_std_show_header_right_site') == 'on';
- $this->_bShowHeaderRightAssistant = false;
- if(is_string($mixedPageName)) {
- $this->aPage = $this->oDb->getPages(array('type' => 'by_page_name_full', 'value' => $mixedPageName));
- if(empty($this->aPage) || !is_array($this->aPage))
- return;
- }
- else if(is_array($mixedPageName)) {
- $aPages = $this->oDb->getPages(array('type' => 'by_page_names_full', 'value' => array_keys($mixedPageName)));
- if(empty($aPages) || !is_array($aPages))
- return;
- $this->bPageMultiple = true;
- foreach($aPages as $aPage) {
- if((int)$mixedPageName[$aPage['name']] == 1)
- $this->sPageSelected = $aPage['name'];
- $this->aPage[$aPage['name']] = $aPage;
- }
- }
- $this->bPage = true;
- }
-
- public function checkAction()
- {
- return false;
- }
- public function getDb()
- {
- return $this->oDb;
- }
- public function getPageUrl()
- {
- if(empty($this->sPageUrl) && !empty($this->aPage['wid_url']))
- $this->sPageUrl = $this->aPage['wid_url'];
- return bx_replace_markers($this->sPageUrl, $this->aMarkers);
- }
- public function getPageTypeUrl()
- {
- $sUrl = BxTemplStudioLauncher::getInstance()->getPageUrl();
- if(empty($this->aPage['wid_type']))
- return $sUrl;
- return bx_append_url_params($sUrl, array(
- 'type' => $this->aPage['wid_type']
- ));
- }
- public function getRssHelpUrl()
- {
- return bx_replace_markers($this->sPageRssHelpUrl, $this->aMarkers);
- }
- public function getPageTypes($bFullInfo = true)
- {
- return BxDolFormQuery::getDataItems($this->_sTypesPreList, false, $bFullInfo ? BX_DATA_VALUES_ALL : BX_DATA_VALUES_DEFAULT);
- }
- public function getPageTypeIcon()
- {
- if(empty($this->aPage['wid_type']))
- return false;
- $sType = $this->aPage['wid_type'];
- $aTypes = $this->getPageTypes();
- if(empty($aTypes[$sType]) || empty($aTypes[$sType]['Data']))
- return false;
- $aTypeData = unserialize($aTypes[$sType]['Data']);
- if(empty($aTypeData['icon']))
- return false;
- return $aTypeData['icon'];
- }
- /**
- * Add replace markers.
- * @param $a array of markers as key => value
- * @return true on success or false on error
- */
- public function addMarkers ($a)
- {
- if(empty($a) || !is_array($a))
- return false;
- $this->aMarkers = array_merge($this->aMarkers, $a);
- return true;
- }
- public function setError($mixedError)
- {
- if(is_array($mixedError))
- list($this->iError, $this->sError) = $mixedError;
- else
- $this->sError = $mixedError;
- }
- public function getError($bToDisplay = true)
- {
- $sError = $this->sError;
- if($bToDisplay)
- $sError = MsgBox(_t($sError));
- return $this->iError ? [$this->iError, $sError]: $sError;
- }
- protected function getSystemName($sValue)
- {
- return BxDolStudioUtils::getSystemName($sValue);
- }
- protected function getClassName($sValue)
- {
- return BxDolStudioUtils::getClassName($sValue);
- }
- protected function getModuleTitle($sName)
- {
- return BxDolStudioUtils::getModuleTitle($sName);
- }
- protected function getModuleIcon($sName, $sType = 'menu', $bReturnAsUrl = true)
- {
- return BxDolStudioUtils::getModuleIcon($sName, $sType, $bReturnAsUrl);
- }
- protected function getModules($bShowCustom = true, $bShowSystem = true)
- {
- return BxDolStudioUtils::getModules($bShowCustom, $bShowSystem);
- }
- protected function updateHistory()
- {
- if(empty($this->aPage['wid_id']))
- return;
- BxTemplStudioMenuTop::historyAdd($this->aPage);
- }
- }
- /** @} */
|