XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
Legacy_PublicControllerStrategy.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
17{
18 public $mStatusFlag = LEGACY_CONTROLLER_STATE_PUBLIC;
19
20 public function __construct(&$controller)
21 {
22 parent::__construct($controller);
23
24 $controller->mRoot->mContext->mBaseRenderSystemName = 'Legacy_RenderSystem';
25
26 if (!defined('LEGACY_DEPENDENCE_RENDERER')) {
27 define('LEGACY_DEPENDENCE_RENDERER', 'Legacy_RenderSystem');
28 }
29 }
30
31 public function setupBlock()
32 {
33 $showFlag =0;
34 $mid=0;
35
36 if (null != $this->mController->mRoot->mContext->mModule) {
37 $showFlag = (preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) && $this->mController->mRoot->mContext->mXoopsConfig['startpage'] == $this->mController->mRoot->mContext->mXoopsModule->get('dirname'));
38 $mid = $this->mController->mRoot->mContext->mXoopsModule->get('mid');
39 } else {
40 //
41 // If you don't have module_controller, this request is to toppage or other pages of toppage.
42 //
43
44 // $mid = preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) ? -1 : 0;
45 $pathArray = parse_url(!empty($_SERVER['PATH_INFO']) ? substr($_SERVER['PHP_SELF'], 0, - strlen($_SERVER['PATH_INFO'])) : $_SERVER['PHP_SELF']);
46 $mid = preg_match("#(/index\.php|/)$#i", @$pathArray['path']) ? -1 : 0;
47 }
48
49 $blockHandler =& xoops_gethandler('block');
50 $showCenterFlag = (SHOW_CENTERBLOCK_LEFT | SHOW_CENTERBLOCK_CENTER | SHOW_CENTERBLOCK_RIGHT);
51 $showRightFlag = SHOW_SIDEBLOCK_RIGHT;
52 $showFlag = SHOW_SIDEBLOCK_LEFT | $showRightFlag | $showCenterFlag;
53 $groups = is_object($this->mController->mRoot->mContext->mXoopsUser) ? $this->mController->mRoot->mContext->mXoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
54
55 $blockObjects =& $blockHandler->getBlocks($groups, $mid, $showFlag);
56 foreach ($blockObjects as $blockObject) {
57 $block =& Legacy_Utils::createBlockProcedure($blockObject);
58
59 if (false !== $block->prepare()) {
60 $this->mController->_mBlockChain[] =& $block;
61 }
62 unset($block);
63 unset($blockObject);
64 }
65 }
66
67 public function &getMainThemeObject()
68 {
69 // @TODO
70 // Because get() of the virtual handler is heavy, we have to consider
71 // a new solution about this process.
72 //
73 $handler =& xoops_getmodulehandler('theme', 'legacy');
74 $theme =& $handler->get($this->mController->mRoot->mContext->getThemeName());
75 if (is_object($theme)) {
76 return $theme;
77 }
78
79 //-----------
80 // Fail safe
81 //-----------
82
83 $root =& XCube_Root::getSingleton();
84 foreach ($root->mContext->mXoopsConfig['theme_set_allowed'] as $theme) {
85 $theme =& $handler->get($theme);
86 if (is_object($theme)) {
87 $root->mContext->setThemeName($theme->get('dirname'));
88 return $theme;
89 }
90 }
91
92 $objs =& $handler->getObjects();
93 if ((is_countable($objs) ? count($objs) : 0) > 0) {
94 return $objs[0];
95 }
96
97 $theme = null;
98 return $theme;
99 }
100
101 public function isEnableCacheFeature()
102 {
103 return true;
104 }
105
106 public function enableAccess()
107 {
108 if (null != $this->mController->mRoot->mContext->mModule) {
109 $dirname = $this->mController->mRoot->mContext->mXoopsModule->get('dirname');
110
111 return $this->mController->mRoot->mContext->mUser->isInRole("Module.{$dirname}.Visitor");
112 }
113
114 return true;
115 }
116
117 public function setupModuleLanguage()
118 {
119 $root =& XCube_Root::getSingleton();
120 $root->mLanguageManager->loadModuleMessageCatalog($root->mContext->mXoopsModule->get('dirname'));
121 }
122}